comparison ext/guichan-0.8.1/examples/helloworld.hpp @ 0:4a0efb7baf70

* Datasets becomes the new trunk and retires after that :-)
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 29 Jun 2008 18:44:17 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4a0efb7baf70
1 /**
2 * Code to populate a global Gui object with a simple
3 * Hello World example.
4 */
5
6 namespace helloworld
7 {
8 gcn::Container* top;
9 gcn::ImageFont* font;
10 gcn::Label* label;
11
12 /**
13 * Initialises the Hello World example by populating the global Gui
14 * object.
15 */
16 void init()
17 {
18 // We first create a container to be used as the top widget.
19 // The top widget in Guichan can be any kind of widget, but
20 // in order to make the Gui contain more than one widget we
21 // make the top widget a container.
22 top = new gcn::Container();
23 // We set the dimension of the top container to match the screen.
24 top->setDimension(gcn::Rectangle(0, 0, 640, 480));
25 // Finally we pass the top widget to the Gui object.
26 globals::gui->setTop(top);
27
28 // Now we load the font used in this example.
29 font = new gcn::ImageFont("fixedfont.bmp", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
30 // Widgets may have a global font so we don't need to pass the
31 // font object to every created widget. The global font is static.
32 gcn::Widget::setGlobalFont(font);
33
34 // Now we create a label with the text "Hello World".
35 label = new gcn::Label("Hello World");
36 // We give the label a position.
37 label->setPosition(280, 220);
38 // And finally we add the label to the top container.
39 top->add(label);
40 }
41
42 /**
43 * Halts the Hello World example.
44 */
45 void halt()
46 {
47 delete label;
48 delete font;
49 delete top;
50 }
51 }