return to index
VDKForm class <forms.h>
Inherits from VDKObject
Description
This class provides a common interface with GTK+ windows that are here
called "Forms". VDKForm provides common functionalities for all derived
classes.
Public members
None
Properties
VDKString Title
bool Iconized
VDKPoint Position
VDKRawPixmap* BackgroundPixmap
VDKObject* FocusWidget
Methods
-
VDKForm(VDKApplication* app, gchar* title
= "", int mode = v_box,
GtkWindowType display = GTK_WINDOW_TOPLEVEL);
Constructor, makes a form wich belong to an application object. Usually
invoke this constructor to make the application MainForm. Form displays
title if arg <title> isn?t null. Form is made with an inner "box" that
is vertical if arg <mode> is v_box, horizontal otherwise. Display mode
is according to <display> arg that follows usual GTK+ definitions.
-
VDKForm(VDKForm* owner, char* title = "",
int mode = v_box,
GtkWindowType display = GTK_WINDOW_TOPLEVEL);
Constructor, makes a form wich belong to another form. Usually invoke
this constructor to make a "child" form wich will be "added" to form.
-
virtual ~VDKForm();
Destructor.
-
void AddChild(VDKForm* child);
Used to add child forms to a form. (Tip: Normally user do not need
to explicitely add a form to a form, appropriate constructor makes the
job)
-
VDKApplication* Application();
Returns the application wich form belongs. If form is a child the parent
application will be returned.
-
VDKBox* Box()
Return inner box.
Tip: gtk_container_border_width (GTK_CONTAINER (Box->Widget()),
10);
-
virtual bool CanClose(void);
This function is invoked from Window Manager "delete" and "destroy"
events and Close() function as well. Answering true allows the form to
be closed and destroyed, otherwise form will not be closed. Recall that
closing MainForm will terminate application. VDKForm::CanClose() answers
always "true", user should override this to obtain different behaviours
(i.e: asking to a confirmation or memory clean-up and closing files).
-
ChildList& Childs(void)
Return form child list.
-
virtual void Close(void);
Triggers destroy event, CanClose() will be called before actually closing.
If CanClose() answers true the form will be closed and destroyed. If user
overrides this, recall to make an ancestor VDKForm::Close() after his operations.
-
void Destroy()
Explicitely destroy a form freeing associated memory and collecting
garbage if any
Tips :never use VDKForm::delete operator otherwise garbage collection
will fail and program probably will crash.
In those rare cases you explicitely destroy a form make a Close()
call immediately before destroying , this assures no meam leaks from underlying
gtk window.
-
void Hide()
Hides form.
-
bool IsModal()
Return true if form was showed as modal.
-
ObjectList& Objects(void)
Return form objects list.
-
VDKForm* Owner();
Return form owner, if it is the MainForm Owner() returns NULL.
-
void Remove(VDKForm* child);
Remove the form from child list adding it to the garbage list that
will be destroyed eith GC
(Tip: Normally user don?t need to use explicitly this function,
VDKForm::Close() does the job)
-
void SetIcon(VDKRawPixmap* pix)
Set <pix> as window icon
-
void SetIconName(char* name)
Set <name> as window icon name
-
virtual void Setup(void) = 0; (pure virtual)
The purposes is to fill the form with interface objects, user must
override this, otherwise will obtain a compilation error.
-
virtual void SetTitle(VDKString title);
Sets form title
-
VDKString GetTitle();
Gets form title.
-
void Show(GtkWindowPosition pos = GTK_WIN_POS_NONE);
Show the form. Window position follows <pos> arg as documented in
Gtk+ Reference manual.
-
void ShowModal(GtkWindowPosition pos = GTK_WIN_POS_NONE);
Show the form in a modal behave. Modal forms deactivate their parent
and parent childs if any. Window position follows <pos> arg as documented
in Gtk+ Reference manual. Modal forms aren?t clipped or shadowed by their
parents.
-
GtkWidget* Window();
Returns the underlying GTK+ window.
-
void Raise()
Raises the form on windows stack top, thus if it is hidden by other
windows will appear on the screen.
-
void Lower()
Opposite as Raise() do.
-
void SetDefaultSize(VDKPoint p);
Set form default size
-
void SetFormSize(VDKPoint p);
Change form size
Using properties
-
VDKString Title
Setting this property will set the form title.
-
bool Iconized
Use this property to iconize/restore the form or know if form is iconized
or not.
-
VDKRawPixmap BackgroundPixmap
Lets to set a pixmap as form background.
Here a code frag:
VDKRawPixmap *pix = new VDKRawPixmap(this,"pix_file.xpm");
if(pix) BackgroundPixmap = pix;
-
VDKObject* FocusWidget
Set/get the widget that will have the focus when form is showed
Predefined events handler
At VDKForm level all these functions are placeholder for subclasses.
User should override these in order to intercept appropriate events.
-
virtual void OnExpose( VDKForm* sender, GdkRectangle
area)
Answers to an Expose event, <area> arg contains the form rectangle
interested to. (Tip: many expose events are normally generated during
form motions, OnExpose() answers only to the last one, when the event->count
drops to 0)
-
virtual void OnShow(VdKForm* sender)
Called immediately after form is displayed into the screen.
-
virtual void OnChildClosing(VDKForm* child)
Child forward this event to the parent when is to be closing.
-
virtual void OnIconize(VDKForm* sender)
Called whenever form is iconized
-
virtual void OnRestore(VDKForm* sender)
Called whenever form is restored.
-
virtual void OnMove(VDKForm* sender);
Answer to a move event
-
virtual void OnResize(VDKForm* sender, VDKPoint&
new_size);
Answer to a resize event
-
virtual void OnFormActivate(VDKForm* sender, bool in_out);
handler that is called when form gets/looses focus. User should override
this handler in his own subclasses to trap the event. <in_out> flag
is either true, form has gained focus, or <false> form has lost focus.
-
virtual int WindozeMessage(int msg,unsigned int wParam,long unsigned
int lParam);
Answers to a MS Windows-like message. Not very useful for other users,
just added to make easier porting my neural networks API from MS Windows
to VDK. Most of vdk users should neglect it.