comparison ext/guichan-0.8.1/examples/hgewidgets.cpp @ 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 * This is an example that shows of the widgets present in
3 * Guichan. The example uses the HGE back end.
4 */
5
6 #include <guichan.hpp>
7 #include <iostream>
8
9 // Here we store a global Gui object. We make it global
10 // so it's easily accessable. Of course, global variables
11 // should normally be avioded when it comes to OOP, but
12 // this examples it not an example that shows how to make a
13 // good and clean C++ application but merely an example
14 // that shows how to use Guichan.
15 namespace globals
16 {
17 gcn::Gui* gui;
18 }
19
20 // Include code to set up an HGE application with Guichan.
21 // The hge.hpp file is responsible for creating and deleting
22 // the global Gui object.
23 #include "hge.hpp"
24 // Include code to set up a Guichan GUI with all the widgets
25 // of Guichan. The code populates the global Gui object.
26 #include "widgets.hpp"
27
28 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
29 {
30 HGE* hge = hgeCreate(HGE_VERSION);
31 try
32 {
33 hge::init();
34 widgets::init();
35 hge::run();
36 widgets::halt();
37 hge::halt();
38 }
39 // Catch all Guichan exceptions.
40 catch (gcn::Exception e)
41 {
42 MessageBox(NULL,
43 e.getMessage().c_str(),
44 "Guichan exception",
45 MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
46 return 1;
47 }
48 // Catch all Std exceptions.
49 catch (std::exception e)
50 {
51 MessageBox(NULL,
52 e.what(),
53 "Std exception",
54 MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
55 return 1;
56 }
57 // Catch all unknown exceptions.
58 catch (...)
59 {
60 MessageBox(NULL,
61 hge->System_GetErrorMessage(),
62 "Unknown exception",
63 MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
64 return 1;
65 }
66
67 return 0;
68 }