File: toolbar.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 (81 lines) | stat: -rw-r--r-- 2,177 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

#ifdef WIN32
#pragma warning(disable : 4355)
#pragma warning(disable : 4786)
#endif

#include "toolbar.h"
#include "mainframe.h"

/////////////////////////////////////////////////////////////////////////////
// ToolBar construction:

ToolBar::ToolBar(MainFrame *mainframe)
: CL_Component(mainframe), mainframe(mainframe), new_document(this),
	load_document(this), save_document(this), new_component_mode(this),
	select_mode(this)
{
	new_document.set_position(CL_Rect(0, 0, 36, 36));
	load_document.set_position(CL_Rect(40, 0, 40+36, 36));
	save_document.set_position(CL_Rect(80, 0, 80+36, 36));
	new_component_mode.set_position(CL_Rect(120, 0, 120+36, 36));
	select_mode.set_position(CL_Rect(160, 0, 160+36, 36));

	// todo: draw some icons or something. Setting text strings instead:
	new_document.set_text("New");
	load_document.set_text("Load");
	save_document.set_text("Save");
	new_component_mode.set_text("+");
	select_mode.set_text("*");

	Document &doc = get_document();
	slots.connect(new_document.sig_clicked(), this, &ToolBar::on_new_document);
	slots.connect(load_document.sig_clicked(), this, &ToolBar::on_load_document);
	slots.connect(save_document.sig_clicked(), this, &ToolBar::on_save_document);
	slots.connect(new_component_mode.sig_clicked(), this, &ToolBar::on_new_component_mode);
	slots.connect(select_mode.sig_clicked(), this, &ToolBar::on_select_mode);
}

ToolBar::~ToolBar()
{
}

/////////////////////////////////////////////////////////////////////////////
// ToolBar attributes:

Document &ToolBar::get_document()
{
	return mainframe->document;
}

/////////////////////////////////////////////////////////////////////////////
// ToolBar operations:


/////////////////////////////////////////////////////////////////////////////
// ToolBar implementation:

void ToolBar::on_new_document()
{
	get_document().clear();
}

void ToolBar::on_load_document()
{
	get_document().load("test.gui");
}

void ToolBar::on_save_document()
{
	get_document().save("test.gui");
}

void ToolBar::on_new_component_mode()
{
	mainframe->editview->set_mode(EditView::mode_new);
}

void ToolBar::on_select_mode()
{
	mainframe->editview->set_mode(EditView::mode_select);
}