1 /*=========================================================================
3 Module: $RCSfile: bbtkWxBlackBox.h,v $
5 Date: $Date: 2009/04/08 07:56:11 $
6 Version: $Revision: 1.26 $
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 //==================================================================
95 //==================================================================
96 /// User callback called in the box contructor
97 virtual void bbUserConstructor();
98 /// User callback called in the box copy constructor
99 virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer);
100 //==================================================================
103 //==================================================================
104 // virtual void InitWindowManagerIfNeeded();
105 virtual void IncNbWindowsAlive();
106 virtual void DecNbWindowsAlive();
107 virtual int GetNbWindowsAlive();
108 virtual bool IsSomeWindowAlive();
110 virtual void IncNbWindowsShown();
111 virtual void DecNbWindowsShown();
112 virtual int GetNbWindowsShown();
113 virtual bool IsSomeWindowShown();
114 //==================================================================
118 //==================================================================
119 void bbCreateWidgetAndEventHandler(wxWindow* parent);
120 //==================================================================
122 //==================================================================
126 friend class WxBlackBoxWidgetEventHandler;
127 /// Sets the Widget Event Handler
128 inline void bbSetWidgetEventHandler(WxBlackBoxWidgetEventHandler* w)
129 { bbmWidgetEventHandler = w; }
130 /// Gets the Widget Event Handler
131 inline WxBlackBoxWidgetEventHandler* bbGetWidgetEventHandler()
132 { return bbmWidgetEventHandler; }
133 /// The WxBlackBoxWidgetEventHandler associated to the box
134 WxBlackBoxWidgetEventHandler* bbmWidgetEventHandler;
135 /// Init the attributes
136 void bbInitAttributes();
138 //=================================================================
141 //=================================================================
142 // WxBlackBoxDescriptor declaration
144 class WxBlackBoxDescriptor : public WidgetBlackBoxDescriptor<wxWindow>
145 BBTK_BEGIN_DESCRIBE_BLACK_BOX_BODY(WxBlackBox);
146 BBTK_NAME("WxBlackBox");
147 BBTK_END_DESCRIBE_BLACK_BOX(WxBlackBox);
148 //=================================================================
159 //==================================================================
160 // Dialog window which is modal
161 class BBTK_EXPORT WxBlackBoxDialog : public wxDialog,
162 public WidgetBlackBoxWindow<wxWindow>
165 typedef WidgetBlackBoxWindow<wxWindow> Parent;
166 WxBlackBoxDialog(WxBlackBox::Pointer box,
167 wxWindow *parent, wxString title, wxSize size);
172 bool IsDialog() { return true; }
173 bool IsFrame() { return false; }
174 wxDialog* bbGetDialog() { return this; }
176 //==================================================================
178 //==================================================================
179 // Frame window which is not modal
180 class BBTK_EXPORT WxBlackBoxFrame : public wxFrame,
181 public WidgetBlackBoxWindow<wxWindow>
184 typedef WidgetBlackBoxWindow<wxWindow> Parent;
185 WxBlackBoxFrame(WxBlackBox::Pointer box,
186 wxWindow *parent, wxString title, wxSize size);
191 bool IsDialog() { return false; }
192 bool IsFrame() { return true; }
193 wxFrame* bbGetFrame() { return this; }
195 //==================================================================
199 //=================================================================
200 // Handles the destroy events of a widget associated to a WxBlackBox
201 // in order to signal the widget death to its associated box
202 class BBTK_EXPORT WxBlackBoxWidgetEventHandler : public wxEvtHandler
205 /// Ctor with the box and widget
206 WxBlackBoxWidgetEventHandler( WxBlackBox::Pointer box, wxWindow *widget );
208 ~WxBlackBoxWidgetEventHandler();
209 /// Returns true iff is the handler for that window
210 bool IsHandlerOf( wxWindow* w ) { return mWindow == w; }
211 // wxWindow* GetWxWindow() { return mWindow; }
212 /// Method processing the destroy event of the widget
213 void OnWindowDestroy(wxWindowDestroyEvent&);
215 //bool IsDead() { return mDead; }
218 WxBlackBox::WeakPointer mBox;
222 //=================================================================
228 #endif //__bbtkWxBlackBox_h__
230 #endif //USE_WXWIDGETS