vdk 2.4.0
forms.h
1/*
2 * ===========================
3 * VDK Visual Develeopment Kit
4 * Version 0.4
5 * October 1998
6 * ===========================
7 *
8 * Copyright (C) 1998, Mario Motta
9 * Developed by Mario Motta <mmotta@guest.net>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 * 02111-1307, USA.
25 */
26
27#ifndef FORMS_H
28#define FORMS_H
29
30#include <vdk/application.h>
31#include <vdk/dlist.h>
32#include <vdk/vdktypes.h>
33#include <vdk/rawobj.h>
34#include <vdk/vdkprops.h>
35#include <vdk/vdkutils.h>
36#include <vdk/vdkstring.h>
37#include <vdk/vdkobj.h>
38class VDKObject;
39
40class VDKColor;
41class VDKForm;
42class VDKFont;
43class VDKBox;
44class VDKRawPixmap;
45
48
51
52
68class VDKForm : public VDKObject
69{
70
71 private:
79 VDKForm& operator=(VDKForm& ) { return *this; }
80protected:
84 void SignalsConnect();
92 ChildList childs,childsGarbage;
96 GtkWidget *window;
109 /*
110 position storage
111 */
112 VDKPoint _oldPos;
122 /*
123 \internal
124 */
125 static int ConfigureEvent(GtkWidget* ,
126 GdkEventConfigure* ev,
127 gpointer gp);
128 /*
129 \internal
130 */
131 static gboolean WindowStateEvent (GtkWidget *widget, GdkEventWindowState *event);
132 /*
133 \internal
134 */
135 static int DestroyEvent (GtkWidget*, gpointer gp);
136 /*
137 \internal
138 */
139 static int DeleteEvent(GtkWidget* , GdkEvent* , gpointer gp);
140 /*
141 \internal
142 */
143 static int ExposeEvent(GtkWidget* ,
144 GdkEventExpose* ev, gpointer gp);
145 /*
146 \internal
147 */
148 static void RealizeSignal(GtkWidget* , gpointer gp);
149 /*
150 \internal
151 */
152 static int MapEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
153 /*
154 \internal
155 */
156 static int UnmapEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
157 /*
158 \internal
159 */
160 static int FocusInEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
161 /*
162 \internal
163 */
164 static int FocusOutEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
165 /*
166 \internal
167 */
168 static void SizeAllocateSignal(GtkWidget *widget,
169 GtkAllocation *allocation,
170 gpointer gp);
171public:
172 /*
173 properties
174 */
175 VDKReadWriteValueProp<VDKForm,bool> Visible;
176 VDKReadWriteValueProp<VDKForm,VDKString> Title;
177 VDKReadWriteValueProp<VDKForm,VDKPoint> Position;
178 VDKReadWriteValueProp<VDKForm,bool> Iconized;
179 VDKReadWriteValueProp<VDKForm,VDKRawPixmap*> BackgroundPixmap;
180 VDKReadWriteValueProp<VDKForm,VDKObject*> FocusWidget;
181
182 /*
183 constructors
184 */
198 char* title = (char*) NULL,
199 int mode = v_box,
200 GtkWindowType display = GTK_WINDOW_TOPLEVEL);
214 char* title = (char*) NULL,
215 int mode = v_box,
216 GtkWindowType display = GTK_WINDOW_TOPLEVEL);
221 GtkWidget* wid,
222 char* title = (char*) NULL);
223
224#if HAVE_GNOME
228VDKForm(VDKForm* owner,
229 GtkWidget* wid,
230 char* title = (char*) NULL);
231#endif
235 virtual ~VDKForm();
239 bool Destroy();
243 virtual int isA() { return form_class; }
247 VDKBox* Box() { return box; }
257 virtual void Show(GtkWindowPosition pos = GTK_WIN_POS_NONE);
261 virtual void Hide();
271 virtual void ShowModal(GtkWindowPosition pos = GTK_WIN_POS_NONE);
275 bool IsModal() { return isModal; }
288 virtual void Add(VDKObject* obj, int justify = l_justify,
289 int expand = TRUE, int fill = TRUE ,
290 int padding = 1);
294 void AddChild(VDKForm* child);
299 VDKForm* Owner() { return owner; }
303 void RemoveChild(VDKForm* child);
309 virtual bool CanClose(void);
316 virtual void Close(void);
317
318 // this makes a VDKForm an abstract class
323 virtual void Setup(void) = 0;
324
325 void SetTitle(VDKString title)
326 { gtk_window_set_title(GTK_WINDOW(window),(char*) title); }
327
328 VDKString GetTitle(void)
329 {
330 VDKString title = Title;
331 return VDKString(title);
332 }
333
334 GtkWidget* Window() { return window; }
335
336 VDKApplication* Application() { return app; }
337
338 void CloseChilds(void);
339
340 void CollectGarbage();
341
342 ObjectList& Objects(void) { return items; }
343
344 ChildList& Childs(void) { return childs; }
345 ChildList& ChildsGarbage(void)
346 { return childsGarbage; }
350 void Raise();
354 void Lower();
355
356 void SetVisible(bool flag)
357 {
358 if(flag) Show();
359 else Hide();
360 }
361 bool GetVisible()
362 { return GTK_WIDGET_VISIBLE(window); };
363 /*
364 */
365 void SetIcon(VDKRawPixmap*);
366 void SetIconName(char* name);
367 void SetPosition(VDKPoint p);
368 VDKPoint GetPosition();
369 //
370 void SetDefaultSize(VDKPoint p);
371 void SetFormSize(VDKPoint p)
372 { if(window) gdk_window_resize(window->window,p.X(),p.Y()); }
373 bool GetIconized();
374 void SetIconized(bool flag);
375 void SetBackgroundPixmap(VDKRawPixmap* pix);
376 void SetFocusWidget(VDKObject* focuswidget);
377 /*
378event response (place holders for subclasses)
379*/
380 static void ButtonPressEvent(GtkWidget* ,
381 GdkEventButton* ev,
382 gpointer gp);
383
384 virtual void OnExpose( VDKForm* sender, GdkRectangle area);
385 virtual void OnChildClosing(VDKForm* child);
386 virtual void OnShow(VDKForm* sender);
387 virtual void OnRealize(VDKForm* sender);
388 virtual void OnConfigure(VDKForm* sender);
389 virtual void OnMove(VDKForm* sender);
390 virtual void OnResize(VDKForm* sender, VDKPoint& size);
391 virtual void OnIconize(VDKForm* sender);
392 virtual void OnRestore(VDKForm* sender);
393 virtual void OnFormActivate(VDKForm* sender, bool in_out);
394/*
395 Answers to a MS Windows-like message.
396 Not very useful, just added to facilitate
397 porting my neural lib from MS Windows to VDK.
398 Casual user should override in his own forms.
399 */
400 virtual int
401 WindozeMessage(int /*msg*/,
402 unsigned int /*wParam*/,
403 long unsigned int /*lParam*/)
404 {
405 return 0;
406 }
407};
408
409#endif
410
411
412
Application object.
Definition: application.h:131
One of the most used widget containers.
Definition: boxes.h:38
provides a raw color object
Definition: colors.h:37
Provides a raw font.
Definition: vdkfont.h:38
VDKForm widgets, generally the outermost widget container.
Definition: forms.h:69
virtual void ShowModal(GtkWindowPosition pos=GTK_WIN_POS_NONE)
Definition: forms.cc:576
virtual void Show(GtkWindowPosition pos=GTK_WIN_POS_NONE)
Definition: forms.cc:548
VDKForm(VDKApplication *app, char *title=(char *) NULL, int mode=v_box, GtkWindowType display=GTK_WINDOW_TOPLEVEL)
GtkWidget * window
Definition: forms.h:96
virtual void Hide()
Definition: forms.cc:566
VDKBox * Box()
Definition: forms.h:247
bool Destroy()
Definition: forms.cc:527
bool never_showed
Definition: forms.h:108
virtual void Close(void)
Definition: forms.cc:645
VDKForm * Owner()
Definition: forms.h:299
virtual void Setup(void)=0
bool isModal
Definition: forms.h:104
VDKForm(VDKForm *owner, char *title=(char *) NULL, int mode=v_box, GtkWindowType display=GTK_WINDOW_TOPLEVEL)
VDKForm & operator=(VDKForm &)
Definition: forms.h:79
ChildList childs
Definition: forms.h:92
VDKForm(VDKForm &)
Definition: forms.h:75
int modalCount
Definition: forms.h:121
VDKPoint _oldSize
Definition: forms.h:116
void Raise()
Definition: forms.cc:682
virtual bool CanClose(void)
Definition: forms.cc:674
bool IsModal()
Definition: forms.h:275
void Lower()
Definition: forms.cc:689
virtual ~VDKForm()
Definition: forms.cc:434
virtual void Add(VDKObject *obj, int justify=l_justify, int expand=TRUE, int fill=TRUE, int padding=1)
Definition: forms.cc:613
virtual int isA()
Definition: forms.h:243
VDKBox * box
Definition: forms.h:100
VDKApplication * app
Definition: forms.h:88
Provides a VDKList iterator.
Definition: dlist.h:201
Definition: vdkobj.h:141
GtkWidget * widget
Definition: vdkobj.h:241
Provides a simple point object.
Definition: vdkutils.h:94
Provides a raw pixmap.
Definition: rawpixmap.h:38
Implements famous cont referenced string objects.
Definition: vdkstring.h:46