[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In the following discussion I will try to explain how to build simple applications using the Crystal Space Windowing System. I hope you will understand enough to start writing your own applications; I also hope you will get a deeper knowledge of CSWS during your development (or lab) sessions. In fact, I highly recommend perusing the CSWS header files (or alternatively at the HTML documentation generated from the header files) as they contain a lot of useful information which is not present here.
The simplest possible application should do the following:
Let's try:
#include "csws/csws.h" int main(int argc, char const* const argv[]) { SysSystemDriver sys; if (!sys.Initialize(argc, argv, "/config/cswstest,cfg")) return -1; if (!sys.Open("Crystal Space Windowing System")) return -1; csApp app(&sys); if (app.Initialize("/csws/csws.cfg")) app.Loop(); } |
Pretty simple, eh? So the result is simple as well. We got a grey background, a mouse and nothing more. What the program does is:
iSystem::RequestPlugin()
method).
csApp::Initialize()
. You pass the name of the
CSWS configuration file (which is different from system configuration
file). This configuration file tells CSWS which textures to use for
windowing system components; where on the textures the respective pictures are
placed; and other skin-dependent information. You may want to override this
method to initialize your application here (after calling the parent's
Initialize()
). For instance, create a popup menu, insert it onto the
desktop, add some windows, check configuration files, etc.
HandleEvent()
. If there weren't any events in the loop,
it calls Idle()
method to give some time slices to other running
applications (if csSystemDriver::Sleep()
method is implemented
properly). If some window needs redrawing, it is redrawn. After this the
screen is updated and everything starts again from the beginning.
If you observe, the above program does not delete the `SysSystemDriver' or `csApp' objects. That's because they are automatic variables and not pointers, so they are automatically deleted when they go out of scope.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |