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 #ifndef FORMS_H
00028 #define FORMS_H
00029
00030 #include <vdk/application.h>
00031 #include <vdk/dlist.h>
00032 #include <vdk/vdktypes.h>
00033 #include <vdk/rawobj.h>
00034 #include <vdk/vdkprops.h>
00035 #include <vdk/vdkutils.h>
00036 #include <vdk/vdkstring.h>
00037 #include <vdk/vdkobj.h>
00038 class VDKObject;
00039
00040 class VDKColor;
00041 class VDKForm;
00042 class VDKFont;
00043 class VDKBox;
00044 class VDKRawPixmap;
00045
00046 typedef VDKList<VDKForm> ChildList;
00047 typedef VDKListiterator<VDKForm> ChildListIterator;
00048
00049 typedef VDKList<VDKObject> ObjectList;
00050 typedef VDKListiterator<VDKObject> ObjectListIterator;
00051
00052
00068 class VDKForm : public VDKObject
00069 {
00070
00071 private:
00075 VDKForm(VDKForm& ):VDKObject( NULL) {}
00079 VDKForm& operator=(VDKForm& ) { return *this; }
00080 protected:
00084 void SignalsConnect();
00088 VDKApplication* app;
00092 ChildList childs,childsGarbage;
00096 GtkWidget *window;
00100 VDKBox* box;
00104 bool isModal;
00108 bool never_showed;
00109
00110
00111
00112 VDKPoint _oldPos;
00116 VDKPoint _oldSize;
00121 int modalCount;
00122
00123
00124
00125 static int ConfigureEvent(GtkWidget* ,
00126 GdkEventConfigure* ev,
00127 gpointer gp);
00128
00129
00130
00131 static gboolean WindowStateEvent (GtkWidget *widget, GdkEventWindowState *event);
00132
00133
00134
00135 static int DestroyEvent (GtkWidget*, gpointer gp);
00136
00137
00138
00139 static int DeleteEvent(GtkWidget* , GdkEvent* , gpointer gp);
00140
00141
00142
00143 static int ExposeEvent(GtkWidget* ,
00144 GdkEventExpose* ev, gpointer gp);
00145
00146
00147
00148 static void RealizeSignal(GtkWidget* , gpointer gp);
00149
00150
00151
00152 static int MapEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
00153
00154
00155
00156 static int UnmapEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
00157
00158
00159
00160 static int FocusInEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
00161
00162
00163
00164 static int FocusOutEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
00165
00166
00167
00168 static void SizeAllocateSignal(GtkWidget *widget,
00169 GtkAllocation *allocation,
00170 gpointer gp);
00171 public:
00172
00173
00174
00175 VDKReadWriteValueProp<VDKForm,bool> Visible;
00176 VDKReadWriteValueProp<VDKForm,VDKString> Title;
00177 VDKReadWriteValueProp<VDKForm,VDKPoint> Position;
00178 VDKReadWriteValueProp<VDKForm,bool> Iconized;
00179 VDKReadWriteValueProp<VDKForm,VDKRawPixmap*> BackgroundPixmap;
00180 VDKReadWriteValueProp<VDKForm,VDKObject*> FocusWidget;
00181
00182
00183
00184
00197 VDKForm(VDKApplication* app,
00198 char* title = (char*) NULL,
00199 int mode = v_box,
00200 GtkWindowType display = GTK_WINDOW_TOPLEVEL);
00213 VDKForm(VDKForm* owner,
00214 char* title = (char*) NULL,
00215 int mode = v_box,
00216 GtkWindowType display = GTK_WINDOW_TOPLEVEL);
00220 VDKForm(VDKApplication* app,
00221 GtkWidget* wid,
00222 char* title = (char*) NULL);
00223
00224 #if HAVE_GNOME
00225
00228 VDKForm(VDKForm* owner,
00229 GtkWidget* wid,
00230 char* title = (char*) NULL);
00231 #endif
00232
00235 virtual ~VDKForm();
00239 bool Destroy();
00243 virtual int isA() { return form_class; }
00247 VDKBox* Box() { return box; }
00257 virtual void Show(GtkWindowPosition pos = GTK_WIN_POS_NONE);
00261 virtual void Hide();
00271 virtual void ShowModal(GtkWindowPosition pos = GTK_WIN_POS_NONE);
00275 bool IsModal() { return isModal; }
00288 virtual void Add(VDKObject* obj, int justify = l_justify,
00289 int expand = TRUE, int fill = TRUE ,
00290 int padding = 1);
00294 void AddChild(VDKForm* child);
00299 VDKForm* Owner() { return owner; }
00303 void RemoveChild(VDKForm* child);
00309 virtual bool CanClose(void);
00316 virtual void Close(void);
00317
00318
00323 virtual void Setup(void) = 0;
00324
00325 void SetTitle(VDKString title)
00326 { gtk_window_set_title(GTK_WINDOW(window),(char*) title); }
00327
00328 VDKString GetTitle(void)
00329 {
00330 VDKString title = Title;
00331 return VDKString(title);
00332 }
00333
00334 GtkWidget* Window() { return window; }
00335
00336 VDKApplication* Application() { return app; }
00337
00338 void CloseChilds(void);
00339
00340 void CollectGarbage();
00341
00342 ObjectList& Objects(void) { return items; }
00343
00344 ChildList& Childs(void) { return childs; }
00345 ChildList& ChildsGarbage(void)
00346 { return childsGarbage; }
00350 void Raise();
00354 void Lower();
00355
00356 void SetVisible(bool flag)
00357 {
00358 if(flag) Show();
00359 else Hide();
00360 }
00361 bool GetVisible()
00362 { return GTK_WIDGET_VISIBLE(window); };
00363
00364
00365 void SetIcon(VDKRawPixmap*);
00366 void SetIconName(char* name);
00367 void SetPosition(VDKPoint p);
00368 VDKPoint GetPosition();
00369
00370 void SetDefaultSize(VDKPoint p);
00371 void SetFormSize(VDKPoint p)
00372 { if(window) gdk_window_resize(window->window,p.X(),p.Y()); }
00373 bool GetIconized();
00374 void SetIconized(bool flag);
00375 void SetBackgroundPixmap(VDKRawPixmap* pix);
00376 void SetFocusWidget(VDKObject* focuswidget);
00377
00378
00379
00380 static void ButtonPressEvent(GtkWidget* ,
00381 GdkEventButton* ev,
00382 gpointer gp);
00383
00384 virtual void OnExpose( VDKForm* sender, GdkRectangle area);
00385 virtual void OnChildClosing(VDKForm* child);
00386 virtual void OnShow(VDKForm* sender);
00387 virtual void OnRealize(VDKForm* sender);
00388 virtual void OnConfigure(VDKForm* sender);
00389 virtual void OnMove(VDKForm* sender);
00390 virtual void OnResize(VDKForm* sender, VDKPoint& size);
00391 virtual void OnIconize(VDKForm* sender);
00392 virtual void OnRestore(VDKForm* sender);
00393 virtual void OnFormActivate(VDKForm* sender, bool in_out);
00394
00395
00396
00397
00398
00399
00400 virtual int
00401 WindozeMessage(int ,
00402 unsigned int ,
00403 long unsigned int )
00404 {
00405 return 0;
00406 }
00407 };
00408
00409 #endif
00410
00411
00412