]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxBlackBox.h
*** MAJOR CHANGE *** NOT WORKING YET !!!
[bbtk.git] / kernel / src / bbtkWxBlackBox.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkWxBlackBox.h,v $
4   Language:  C++
5   Date:      $Date: 2009/05/14 14:43:34 $
6   Version:   $Revision: 1.27 $
7 ========================================================================*/
8
9
10 /* ---------------------------------------------------------------------
11
12 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
13 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 *
15 *  This software is governed by the CeCILL-B license under French law and 
16 *  abiding by the rules of distribution of free software. You can  use, 
17 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
18 *  license as circulated by CEA, CNRS and INRIA at the following URL 
19 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
20 *  or in the file LICENSE.txt.
21 *
22 *  As a counterpart to the access to the source code and  rights to copy,
23 *  modify and redistribute granted by the license, users are provided only
24 *  with a limited warranty  and the software's author,  the holder of the
25 *  economic rights,  and the successive licensors  have only  limited
26 *  liability. 
27 *
28 *  The fact that you are presently reading this means that you have had
29 *  knowledge of the CeCILL-B license and that you accept its terms.
30 * ------------------------------------------------------------------------ */                                                                         
31 /**
32  * \brief Short description in one line
33  * 
34  * Long description which 
35  * can span multiple lines
36  */
37 /**
38  * \file 
39  * \brief 
40  */
41 /**
42  * \class bbtk::
43  * \brief 
44  */
45
46
47 #ifdef USE_WXWIDGETS
48
49
50 #ifndef __bbtkWxBlackBox_h__
51 #define __bbtkWxBlackBox_h__
52
53
54 #include "bbtkWx.h"
55 #include "bbtkWidgetBlackBox.h"
56
57
58 namespace bbtk
59 {
60
61
62
63
64
65   //==================================================================
66   // Forward declaration of the widget event handler class
67   class WxBlackBoxWidgetEventHandler;
68   //==================================================================
69
70
71   //==================================================================
72   /// Widget black boxes
73   class BBTK_EXPORT WxBlackBox : public bbtk::WidgetBlackBox<wxWindow>
74   { 
75   public:
76     BBTK_BLACK_BOX_INTERFACE(WxBlackBox,bbtk::WidgetBlackBox<wxWindow>);
77
78           
79     //  protected:
80     
81   public:
82   
83    //==================================================================    
84     /// Callback for creating a Dialog window (modal)
85     /// ** Must be defined ** in toolkit specific descendants 
86     virtual void bbCreateDialogWindow();
87     //==================================================================    
88
89     //==================================================================    
90     /// Callback for creating a Frame window 
91     /// ** Must be defined ** in toolkit specific descendants 
92     virtual void bbCreateFrameWindow();
93     //==================================================================    
94
95   
96   
97     //==================================================================
98     //    virtual void InitWindowManagerIfNeeded();
99     virtual void IncNbWindowsAlive();
100     virtual void DecNbWindowsAlive();
101     virtual int  GetNbWindowsAlive();
102     virtual bool IsSomeWindowAlive();
103     
104     virtual void IncNbWindowsShown();
105     virtual void DecNbWindowsShown();
106     virtual int  GetNbWindowsShown();
107     virtual bool IsSomeWindowShown();
108     //==================================================================
109
110
111           
112     //==================================================================    
113     void bbCreateWidgetAndEventHandler(wxWindow* parent); 
114     //==================================================================    
115     
116     //==================================================================    
117
118   private:
119     /// friendship
120     friend class WxBlackBoxWidgetEventHandler;
121     /// Sets the Widget Event Handler
122     inline void bbSetWidgetEventHandler(WxBlackBoxWidgetEventHandler* w) 
123     { bbmWidgetEventHandler = w; }
124     /// Gets the Widget Event Handler
125     inline WxBlackBoxWidgetEventHandler* bbGetWidgetEventHandler()
126     { return bbmWidgetEventHandler; }
127     /// The WxBlackBoxWidgetEventHandler associated to the box
128     WxBlackBoxWidgetEventHandler* bbmWidgetEventHandler;
129   };
130   //=================================================================
131  
132
133   //=================================================================
134   // WxBlackBoxDescriptor declaration
135   //
136   class WxBlackBoxDescriptor : public WidgetBlackBoxDescriptor<wxWindow>
137   BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(WxBlackBox);
138   BBTK_NAME("WxBlackBox");
139   BBTK_END_DESCRIBE_BLACK_BOX(WxBlackBox);
140   //=================================================================
141
142
143
144
145
146
147
148
149
150
151   //==================================================================
152   // Dialog window which is modal
153   class BBTK_EXPORT  WxBlackBoxDialog : public wxDialog, 
154                                         public WidgetBlackBoxWindow<wxWindow>
155   {
156   public:
157     typedef WidgetBlackBoxWindow<wxWindow> Parent;
158     WxBlackBoxDialog(WxBlackBox::Pointer box, 
159                      wxWindow *parent, wxString title, wxSize size);
160     ~WxBlackBoxDialog();
161     void bbShow();  
162     void bbHide();
163     void bbClose();
164     bool IsDialog() { return true; }
165     bool IsFrame() { return false; }
166     wxDialog* bbGetDialog() { return this; } 
167   };
168   //==================================================================
169
170   //==================================================================
171   // Frame window which is not modal
172   class BBTK_EXPORT  WxBlackBoxFrame : public wxFrame, 
173                                        public WidgetBlackBoxWindow<wxWindow>
174   {
175   public:
176     typedef WidgetBlackBoxWindow<wxWindow> Parent;
177     WxBlackBoxFrame(WxBlackBox::Pointer box,
178                     wxWindow *parent, wxString title, wxSize size);
179     ~WxBlackBoxFrame();
180     void bbShow();
181     void bbHide();
182     void bbClose();
183     bool IsDialog() { return false; }
184     bool IsFrame() { return true; }
185     wxFrame* bbGetFrame() { return this; } 
186   };
187   //==================================================================
188
189
190
191   //=================================================================
192   // Handles the destroy events of a widget associated to a WxBlackBox 
193   // in order to signal the widget death to its associated box
194   class BBTK_EXPORT WxBlackBoxWidgetEventHandler : public wxEvtHandler
195   {
196   public:
197     /// Ctor with the box and widget 
198     WxBlackBoxWidgetEventHandler( WxBlackBox::Pointer box, wxWindow *widget );
199     /// Dtor
200     ~WxBlackBoxWidgetEventHandler();
201     /// Returns true iff is the handler for that window  
202     bool IsHandlerOf( wxWindow* w ) { return mWindow == w; }
203     // wxWindow* GetWxWindow() { return mWindow; }
204     /// Method processing the destroy event of the widget
205     void OnWindowDestroy(wxWindowDestroyEvent&);
206     //
207     //bool IsDead() { return mDead; }
208
209   private:
210     WxBlackBox::WeakPointer mBox;
211     wxWindow* mWindow;
212     //bool mDead;
213   };  
214   //=================================================================
215
216
217
218 } //namespace bbtk
219
220 #endif  //__bbtkWxBlackBox_h__
221
222 #endif  //USE_WXWIDGETS