return to index
VDKApplication class
Header: <vdk/application.h>
Description
This class initializes GTK+ library and start events loop. Normally
user overrides this class using his own application object. Application
objects are responsible to manage also terminating and clean-up procedures.
Public members
VDKForm* MainForm
Is the application main form, must be user initialized otherwise a
useless default main form will be constructed by the VDKApplication base
object.
Properties
None
Methods
-
VDKApplication(int* argc, char** argv, char* rc
= NULL, bool have_locale = false);
Constructor, receives main() arguments and pass them to GTK+ library.
Normally user overrides this using his own Application object. (See programming
tips). If <rc> arg isn?t NULL <rc> resource file will be laoded and
parsed. Setting <have_locale> to true let's vdk to invoke gtk_set_locale()
and support any languages that Gtk supports.
-
virtual ~VDKApplication();
Destructor.
-
bool HasResources()
Indicates if the resource file was loaded and parsed or not.
-
void Run(void);
Initiates event loop.
-
void Terminate(void);
Terminates event loop and quit GTK+ library.
(Tip: This method is called after a destroy event on MainForm, user
doesn't care)
-
GtkWidget* MainWindow();
Return application mainform underlying gtk+ window.
-
virtual void Setup();
Initialize MainWindow, normally user override this to provide his own
initializing procedures
-
void SetResourceFile(char* rcf);
Set a resource file.
Tip: this should be done before Run()ning app.
-
VDKPoint ScreenSize();
Returns screen size in pixels.
-
void SetIdleCallback(GtkFunction idlecb, gpointer
data);
Sets idle callback function, if a previous idle callback was installed,
uninstall it.
Tip: <data> will be passed to <idlecb> user defined function
and must a be a non NULL pointer otherwise SetIdleCallback() won't work.
<idlecb> must be declared as: void idlecb(gpointer
data);
-
void SetGarbageCollection(unsigned int timing
= 1000)
Set a timed garbage collection that will be invoked each <timing>
msecs.
-
void RemoveGarbageCollection()
Remove timed garbage collection.
-
gint MessageBox(char*
caption, char* text, int mode = MB_OK, char *oktext = NULL,
char *canceltext = NULL. unsigned int wait = 0);
Provide a modal dialog window for messages to user.
Modes:
-
MB_OK provide only one button with a "OK" default caption
-
MB_YESNO provides two button with "YES" and "NO" default captions
Mode can be ored with:
-
MB_ICONSTOP provides an "hand stop" icon
-
MB_ICONINFORMATION provides a "information icon"
-
MB_ICONQUESTION provides a question mark icon
MessageBox returns an integer that depends on modes and user response:
-
IDOK, user pressed OK button in MB_OK mode
-
IDYES, user pressed YES button in MB_YESNO mode
-
IDNO, user pressed NO button in MB_YESNO mode
Both OK,YES and NO buttons captions can be customized using oktext and
canceltext arguments.
<wait> arg if set other than 0 makes MessageBox automatically closed
after <wait> msecs with IDCANCEL or IDNO result. MessageBox() accepts
CR as "yes" and ESC as "no" default answers.
Others
VDK_VERSION_MAJOR
VDK_VERSION_MINOR
VDK_REVISION
For instance:
printf("VDK %d.%d.%d", VDK_VERSION_MAJOR,VDK_VERSION_MINOR
,VDK_REVISION);
fflush(stdout);
will ouput VDK 1.0.1