bbtkWidgetBlackBox.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00046 #ifndef __bbtkWidgetBlackBox_h_INCLUDED__
00047 #define __bbtkWidgetBlackBox_h_INCLUDED__
00048
00049 #include "bbtkAtomicBlackBox.h"
00050
00051 namespace bbtk
00052 {
00053
00054
00055
00056
00057
00062
00063
00064 template <class W>
00065
00066 class WidgetBlackBox : public bbtk::AtomicBlackBox
00067 {
00068 public:
00069
00070 typedef W Widget;
00071 typedef Widget* WidgetPointer;
00072
00073
00074 BBTK_BLACK_BOX_INTERFACE(WidgetBlackBox,bbtk::AtomicBlackBox);
00075 BBTK_DECLARE_INPUT(WinTitle,std::string);
00076 BBTK_DECLARE_INPUT(WinWidth,int);
00077 BBTK_DECLARE_INPUT(WinHeight,int);
00078 BBTK_DECLARE_INPUT(WinDialog,bool);
00079 BBTK_DECLARE_INPUT(WinHide,Void);
00080 BBTK_DECLARE_INPUT(WinClose,Void);
00081 BBTK_DECLARE_OUTPUT(Widget,Widget*);
00082
00083
00086 virtual void bbCreateWindow();
00087 virtual bool bbWindowIsCreated() { return false; }
00088
00089
00090
00093 virtual void bbShowWindow() {}
00094
00095
00096
00098 bool bbIsOutputWidgetConnected();
00099
00100
00101 bool bbIsShown();
00102
00103
00104
00105
00108 virtual void bbUserCreateWidget(Widget* parent)
00109 {
00110 bbtkError(bbGetTypeName()<<" is a WidgetBlackBox whose bbUserCreateWidget methods is not overloaded : is it a feature or a bug ?!?");
00111 }
00112
00113
00114
00115 protected:
00116
00117 void bbSetShown(bool);
00118
00119
00124 Widget* bbCreateWidgetOfInput(const std::string& in,
00125 Widget* parent);
00126
00127
00128
00131 virtual void bbCreateDialogWindow()
00132 {
00133 bbtkError(bbGetTypeName()<<" is a WidgetBlackBox whose bbCreateDialogWindow method is not overloaded ?!?");
00134 }
00135
00136
00137
00140 virtual void bbCreateFrameWindow()
00141 {
00142 bbtkError(bbGetTypeName()<<" is a WidgetBlackBox whose bbCreateFrameWindow method is not overloaded ?!?");
00143 }
00144
00145
00147 virtual void bbProcess();
00148
00149
00150
00152 virtual void bbDestroyWindow() {}
00153
00154
00155
00156
00157 private:
00158
00161 bool bbmShown;
00167 std::vector<BlackBox::WeakPointer> bbmNestedWidgetBoxes;
00168 };
00169
00170
00171
00172
00174 #define BBTK_CREATE_WIDGET(CALLBACK) \
00175 public: \
00176 inline void bbUserCreateWidget(Widget* parent) \
00177 { \
00178 bbtkBlackBoxDebugMessage("widget",1,"**> Creating widget" \
00179 <<std::endl); \
00180 CALLBACK(parent); \
00181 }
00182
00183
00184
00185
00187 #define BBTK_ON_SHOW_WIDGET(CALLBACK) \
00188 public: \
00189 inline void bbUserOnShow() \
00190 { \
00191 bbtkBlackBoxDebugMessage("widget",1,"**> Showing" \
00192 <<std::endl); \
00193 CALLBACK(); \
00194 }
00195
00196
00197
00198
00199
00200 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(WidgetBlackBox,bbtk::AtomicBlackBox);
00201 BBTK_NAME("WidgetBlackBox_"+HumanTypeName<T>());
00202
00203 BBTK_CATEGORY("widget");
00204 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinTitle,
00205 "Title of the window (*)",
00206 std::string);
00207 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinWidth,
00208 "Width of the window (* : only used if the widget is not connected to a Layout box)",int);
00209 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHeight,
00210 "Height of the window (*)",int);
00211 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinDialog,
00212 "Set to 'true' to create a dialog window, i.e. which blocks the pipeline until it is closed (modal) (*)",bool);
00213 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHide,
00214 "Any signal received hides the window (*)",Void);
00215 BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinClose,
00216 "Any signal received closes the window (*)",Void);
00217 typedef typename WidgetBlackBox<T>::WidgetPointer WidgetPointer;
00218 BBTK_TEMPLATE_OUTPUT(WidgetBlackBox,Widget,"Output widget",WidgetPointer);
00219 BBTK_END_DESCRIBE_BLACK_BOX(WidgetBlackBox);
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 }
00231
00232
00233 #include "bbtkWidgetBlackBox.txx"
00234
00235
00236 #include "bbtkWidgetBlackBoxWindow.h"
00237
00238 #endif //__bbtkWidgetBlackBox_h__