1 /*=========================================================================
3 Module: $RCSfile: bbtkWxBlackBox.h,v $
5 Date: $Date: 2009/05/14 14:43:34 $
6 Version: $Revision: 1.27 $
7 ========================================================================*/
10 /* ---------------------------------------------------------------------
12 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
13 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
32 * \brief Short description in one line
34 * Long description which
35 * can span multiple lines
50 #ifndef __bbtkWxBlackBox_h__
51 #define __bbtkWxBlackBox_h__
55 #include "bbtkWidgetBlackBox.h"
65 //==================================================================
66 // Forward declaration of the widget event handler class
67 class WxBlackBoxWidgetEventHandler;
68 //==================================================================
71 //==================================================================
72 /// Widget black boxes
73 class BBTK_EXPORT WxBlackBox : public bbtk::WidgetBlackBox<wxWindow>
76 BBTK_BLACK_BOX_INTERFACE(WxBlackBox,bbtk::WidgetBlackBox<wxWindow>);
83 //==================================================================
84 /// Callback for creating a Dialog window (modal)
85 /// ** Must be defined ** in toolkit specific descendants
86 virtual void bbCreateDialogWindow();
87 //==================================================================
89 //==================================================================
90 /// Callback for creating a Frame window
91 /// ** Must be defined ** in toolkit specific descendants
92 virtual void bbCreateFrameWindow();
93 //==================================================================
97 //==================================================================
98 // virtual void InitWindowManagerIfNeeded();
99 virtual void IncNbWindowsAlive();
100 virtual void DecNbWindowsAlive();
101 virtual int GetNbWindowsAlive();
102 virtual bool IsSomeWindowAlive();
104 virtual void IncNbWindowsShown();
105 virtual void DecNbWindowsShown();
106 virtual int GetNbWindowsShown();
107 virtual bool IsSomeWindowShown();
108 //==================================================================
112 //==================================================================
113 void bbCreateWidgetAndEventHandler(wxWindow* parent);
114 //==================================================================
116 //==================================================================
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;
130 //=================================================================
133 //=================================================================
134 // WxBlackBoxDescriptor declaration
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 //=================================================================
151 //==================================================================
152 // Dialog window which is modal
153 class BBTK_EXPORT WxBlackBoxDialog : public wxDialog,
154 public WidgetBlackBoxWindow<wxWindow>
157 typedef WidgetBlackBoxWindow<wxWindow> Parent;
158 WxBlackBoxDialog(WxBlackBox::Pointer box,
159 wxWindow *parent, wxString title, wxSize size);
164 bool IsDialog() { return true; }
165 bool IsFrame() { return false; }
166 wxDialog* bbGetDialog() { return this; }
168 //==================================================================
170 //==================================================================
171 // Frame window which is not modal
172 class BBTK_EXPORT WxBlackBoxFrame : public wxFrame,
173 public WidgetBlackBoxWindow<wxWindow>
176 typedef WidgetBlackBoxWindow<wxWindow> Parent;
177 WxBlackBoxFrame(WxBlackBox::Pointer box,
178 wxWindow *parent, wxString title, wxSize size);
183 bool IsDialog() { return false; }
184 bool IsFrame() { return true; }
185 wxFrame* bbGetFrame() { return this; }
187 //==================================================================
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
197 /// Ctor with the box and widget
198 WxBlackBoxWidgetEventHandler( WxBlackBox::Pointer box, wxWindow *widget );
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&);
207 //bool IsDead() { return mDead; }
210 WxBlackBox::WeakPointer mBox;
214 //=================================================================
220 #endif //__bbtkWxBlackBox_h__
222 #endif //USE_WXWIDGETS