File: guisimple.cpp

package info (click to toggle)
clanlib 1.0~svn3827-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 24,600 kB
  • sloc: cpp: 101,591; xml: 6,410; makefile: 1,743; ansic: 463; perl: 424; php: 247; sh: 53
file content (65 lines) | stat: -rw-r--r-- 1,458 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <ClanLib/core.h>
#include <ClanLib/gui.h>
#include <ClanLib/guistylesilver.h>
#include <ClanLib/application.h>
#include <ClanLib/display.h>
#include <ClanLib/gl.h>

// The main application
class App : public CL_ClanApplication
{
public:
	int main(int argc, char** argv)
	{
		// Create a console window for text-output if not available
		CL_ConsoleWindow console("Console");
		console.redirect_stdio();

		try
		{
			CL_SetupCore setup_core;
			CL_SetupDisplay setup_display;
			CL_SetupGL setup_gl;
			CL_SetupGUI setup_gui;

			CL_DisplayWindow display("GUI Simple example", 640, 480);

			// Connect the Window close event
			CL_Slot slot_quit = display.sig_window_close().connect(this, &App::on_window_close);
			
			// Create the GUI using the default style
			CL_ResourceManager gui_resources("../../Resources/GUIStyleSilver/gui.xml");
			CL_StyleManager_Silver style(&gui_resources);
			CL_GUIManager guimanager(&style);
			gui = &guimanager;

			CL_Window window(CL_Rect(10, 10, 300, 300), "Window", &guimanager);
			
			CL_Slot slot_paint = guimanager.sig_paint().connect(this, &App::on_paint);

			guimanager.run();
		}
		catch (CL_Error e)
		{
 			std::cout << e.message.c_str() << std::endl;

			// Display console close message and wait for a key
			console.display_close_message();
		}

		return 0;
	}
	
private:
	void on_window_close()
	{
		gui->quit();
	}
	
	void on_paint()
	{
		CL_Display::clear();
	}
	
	CL_GUIManager *gui;
} app;