]> git.tdb.fi Git - r2c2.git/blob - dialog.cpp
2d2bae3c21db1da080a1b3a82ded8ed76b3c1492
[r2c2.git] / dialog.cpp
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2009 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #include "dialog.h"
9
10 using namespace Msp;
11
12 Dialog::Dialog():
13         stale(false)
14 {
15         add(*(btn_ok=new GLtk::Button("OK")));
16         btn_ok->set_style("green");
17         btn_ok->set_geometry(GLtk::Geometry(geom.w-40, 10, 30, 25));
18         btn_ok->signal_clicked.connect(sigc::mem_fun(this, &Dialog::on_ok_clicked));
19         btn_ok->signal_clicked.connect(signal_ok);
20         btn_ok->signal_clicked.connect(sigc::mem_fun(this, &Dialog::dismiss));
21
22         add(*(btn_cancel=new GLtk::Button("Cncl")));
23         btn_cancel->set_style("red");
24         btn_cancel->set_geometry(GLtk::Geometry(geom.w-80, 10, 30, 25));
25         btn_cancel->signal_clicked.connect(signal_cancel);
26         btn_cancel->signal_clicked.connect(sigc::mem_fun(this, &Dialog::dismiss));
27 }
28
29 void Dialog::button_release(int x, int y, unsigned btn)
30 {
31         Panel::button_release(x, y, btn);
32         if(stale)
33                 delete this;
34 }
35
36 void Dialog::on_geometry_change()
37 {
38         btn_ok->set_geometry(GLtk::Geometry(geom.w-40, 10, 30, 25));
39         btn_cancel->set_geometry(GLtk::Geometry(geom.w-80, 10, 30, 25));
40 }
41
42 void Dialog::dismiss()
43 {
44         stale = true;
45 }