]> git.tdb.fi Git - r2c2.git/blob - source/engineer/dialog.cpp
Add framework for generating simple meshes for vehicles
[r2c2.git] / source / engineer / dialog.cpp
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
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(const GLtk::Resources &r):
13         GLtk::Widget(r),
14         GLtk::Panel(r),
15         stale(false)
16 {
17         add(*(btn_ok=new GLtk::Button(res, "OK")));
18         btn_ok->set_style("green");
19         btn_ok->set_geometry(GLtk::Geometry(geom.w-40, 10, 30, 25));
20         btn_ok->signal_clicked.connect(sigc::mem_fun(this, &Dialog::on_ok_clicked));
21         btn_ok->signal_clicked.connect(signal_ok);
22         btn_ok->signal_clicked.connect(sigc::mem_fun(this, &Dialog::dismiss));
23
24         add(*(btn_cancel=new GLtk::Button(res, "Cncl")));
25         btn_cancel->set_style("red");
26         btn_cancel->set_geometry(GLtk::Geometry(geom.w-80, 10, 30, 25));
27         btn_cancel->signal_clicked.connect(signal_cancel);
28         btn_cancel->signal_clicked.connect(sigc::mem_fun(this, &Dialog::dismiss));
29 }
30
31 void Dialog::button_release(int x, int y, unsigned btn)
32 {
33         Panel::button_release(x, y, btn);
34         if(stale)
35                 delete this;
36 }
37
38 void Dialog::on_geometry_change()
39 {
40         btn_ok->set_geometry(GLtk::Geometry(geom.w-40, 10, 30, 25));
41         btn_cancel->set_geometry(GLtk::Geometry(geom.w-80, 10, 30, 25));
42 }
43
44 void Dialog::dismiss()
45 {
46         stale = true;
47 }