File: window_opengl.cpp

package info (click to toggle)
clanlib 0.5.4-1-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,320 kB
  • ctags: 10,893
  • sloc: cpp: 76,056; xml: 3,281; sh: 2,961; perl: 1,204; asm: 837; makefile: 775
file content (58 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download | duplicates (3)
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
#include <ClanLib/display.h>
#include <ClanLib/gl.h>

#include "window_opengl.h"
#include "stylemanager_opengl.h"

CL_Window_OpenGL::CL_Window_OpenGL(
	CL_Window *window,
	CL_StyleManager_OpenGL *style)
:
	CL_ComponentStyle(window),
	window(window),
	move_handler(CL_Rect(18, 0, window->get_width()-18, 20), window, style),
	style(style),
	resources(style->get_resources())
{
	slot_paint = window->sig_paint().connect(this, &CL_Window_OpenGL::on_paint);

	button_quit = new CL_Button(CL_Rect(3,3,17,17), "", window, style);

	slot_quit = button_quit->sig_clicked().connect(this, &CL_Window_OpenGL::on_quit);
}

CL_Window_OpenGL::~CL_Window_OpenGL()
{
}

void CL_Window_OpenGL::on_paint()
{
	// Window
	style->fill_rect(
		1, 19, window->get_width() - 1, window->get_height() - 1,
		0.0f, 0.0f, 0.0f,
		0.7f, 0.7f, 0.7f, 0.7f);

	// Titlebar
	style->fill_rect(
		0, 0, window->get_width(), 19,
		0.0f, 0.0f, 0.0f,
		0.0f, 0.0f, 0.0f,
		0.0f, 0.61f, 0.67f,
		0.0f, 0.61f, 0.67f,
		0.9f);

	// Left line
	CL_Display::draw_line(0, 18, 0, window->get_height() - 1, 0.0f, 0.61f, 0.67f, 1.0f);

	// Right line
	CL_Display::draw_line(window->get_width() - 1, 18, window->get_width() - 1, window->get_height() - 1, 0.0f, 0.61f, 0.67f, 1.0f);

	// Bottom line
	CL_Display::draw_line(0, window->get_height() - 2, window->get_width() - 1, window->get_height() - 2, 0.0f, 0.61f, 0.67f, 1.0f);
}

void CL_Window_OpenGL::on_quit()
{
	window->close();
}