2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkWidgetBlackBox.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.8 $
34 ========================================================================*/
39 * \brief Short description in one line
41 * Long description which
42 * can span multiple lines
52 #ifndef __bbtkWidgetBlackBox_h_INCLUDED__
53 #define __bbtkWidgetBlackBox_h_INCLUDED__
55 #include "bbtkAtomicBlackBox.h"
63 //==================================================================
64 /// Generic (template) Widget black box from which all
65 /// widget black boxes for a specific GUI toolkit inherit with
66 /// apropriate traits.
67 /// Declares the common inputs / outputs and interface to all widget boxes
69 //JCP 09JUIN2009 BBTK_EXPORT
72 class /*BBTK_EXPORT*/ WidgetBlackBox : public bbtk::AtomicBlackBox
75 // typedef WidgetTraits Traits;
77 typedef Widget* WidgetPointer;
80 BBTK_BLACK_BOX_INTERFACE(WidgetBlackBox,bbtk::AtomicBlackBox);
81 BBTK_DECLARE_INPUT(WinTitle,std::string);
82 BBTK_DECLARE_INPUT(WinWidth,int);
83 BBTK_DECLARE_INPUT(WinHeight,int);
84 BBTK_DECLARE_INPUT(WinDialog,bool);
85 BBTK_DECLARE_INPUT(WinHide,Void);
86 BBTK_DECLARE_INPUT(WinClose,Void);
87 BBTK_DECLARE_OUTPUT(Widget,Widget*);
89 //==================================================================
90 /// Overloaded bbCreateWindow method for WidgetBlackBoxes which handles
91 /// the window creation if needed
92 virtual void bbCreateWindow();
93 virtual bool bbWindowIsCreated() { return false; }
94 //==================================================================
96 //==================================================================
97 /// Overloaded bbShowWindow method for WidgetBlackBoxes which handles
98 /// the window creation if needed
99 virtual void bbShowWindow() {}
100 //==================================================================
103 /// Convenient method which returns true iff the output Widget is connected
104 bool bbIsOutputWidgetConnected();
106 //==================================================================
108 //==================================================================
111 //==================================================================
112 /// User callback for creating the widget associated to the box
113 /// ** Must be defined ** in user classes
114 virtual void bbUserCreateWidget(Widget* parent)
116 bbtkError(bbGetTypeName()<<" is a WidgetBlackBox whose bbUserCreateWidget methods is not overloaded : is it a feature or a bug ?!?");
118 //==================================================================
123 void bbSetShown(bool);
125 //==================================================================
126 /// Convenient method for layout widgets which creates and returns
127 /// (calls bbUserCreateWidget)
128 /// the widget of the box connected to the input in.
129 /// Returns NULL if the input is not connected
130 Widget* bbCreateWidgetOfInput(const std::string& in,
132 //==================================================================
134 //==================================================================
135 /// Callback for creating a Dialog window (modal)
136 /// ** Must be defined ** in toolkit specific descendants
137 virtual void bbCreateDialogWindow()
139 bbtkError(bbGetTypeName()<<" is a WidgetBlackBox whose bbCreateDialogWindow method is not overloaded ?!?");
141 //==================================================================
143 //==================================================================
144 /// Callback for creating a Frame window
145 /// ** Must be defined ** in toolkit specific descendants
146 virtual void bbCreateFrameWindow()
148 bbtkError(bbGetTypeName()<<" is a WidgetBlackBox whose bbCreateFrameWindow method is not overloaded ?!?");
150 //==================================================================
151 //==================================================================
152 /// Overloaded processing method for WidgetBlackBoxes
153 virtual void bbProcess();
154 //==================================================================
156 //==================================================================
157 /// Destroys the WidgetBlackBoxWindow associated to the box (if exists)
158 virtual void bbDestroyWindow() {}
159 //==================================================================
161 //==================================================================
162 // method to be added in the proces of a window
163 virtual void PutWinTitle() {}
164 //==================================================================
169 /// Set to true when the
170 /// window containing the widget is shown
172 /// Contains the "nested" WidgetBlackBoxes,
173 /// i.e. if this WidgetBox is a Layout the ones
174 /// which are inserted into the layout
175 /// The list is updated by the method bbCreateWidgetOfInput
176 /// It is emptied when ?
177 std::vector<BlackBox::WeakPointer> bbmNestedWidgetBoxes;
179 //=================================================================
182 //======================================================================
183 /// Defines the bbUserCreateWidget method
184 #define BBTK_CREATE_WIDGET(CALLBACK) \
186 inline void bbUserCreateWidget(Widget* parent) \
188 bbtkBlackBoxDebugMessage("widget",1,"**> Creating widget" \
193 //======================================================================
195 //======================================================================
196 /// Defines the bbUserOnShow method
197 #define BBTK_ON_SHOW_WIDGET(CALLBACK) \
199 inline void bbUserOnShow() \
201 bbtkBlackBoxDebugMessage("widget",1,"**> Showing" \
206 //======================================================================
208 //=================================================================
209 // WidgetBlackBoxDescriptor declaration
210 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(WidgetBlackBox,bbtk::AtomicBlackBox);
211 BBTK_NAME("WidgetBlackBox_"+HumanTypeName<T>());
212 // BBTK_DESCRIPTION("Widget box. The inputs marked with (*) are only used if the widget is not inserted in another widget.\n");
213 BBTK_CATEGORY("widget");
214 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinTitle,
215 "Title of the window (*)",
217 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinWidth,
218 "Width of the window (* : only used if the widget is not connected to a Layout box)",int);
219 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHeight,
220 "Height of the window (*)",int);
221 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinDialog,
222 "Set to 'true' to create a dialog window, i.e. which blocks the pipeline until it is closed (modal) (*)",bool);
223 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHide,
224 "Any signal received hides the window (*)",Void);
225 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinClose,
226 "Any signal received closes the window (*)",Void);
227 typedef typename WidgetBlackBox<T>::WidgetPointer WidgetPointer;
228 BBTK_TEMPLATE_OUTPUT(WidgetBlackBox,Widget,"Output widget",WidgetPointer);
229 BBTK_END_DESCRIBE_BLACK_BOX(WidgetBlackBox);
230 //=================================================================
242 // template code inclusion
243 #include "bbtkWidgetBlackBox.txx"
245 // WidgetBlackBoxWindow interface + code inclusion
246 #include "bbtkWidgetBlackBoxWindow.h"
248 #endif //__bbtkWidgetBlackBox_h__