]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GTabularCreate.C
applying Martin Craig's gnome patch. Upgrading to gtkmm-2.0+ from the 1.3 developmen...
[lyx.git] / src / frontends / gnome / GTabularCreate.C
1 /**
2  * \file GTabularCreate.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Michael Koziarski
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include <config.h>
16 #include <utility>
17
18 #include "gnomeBC.h"
19 #include "GTabularCreate.h"
20
21 #include <gtkmm/spinbutton.h>
22 #include <gtkmm/button.h>
23
24 GTabularCreate::GTabularCreate()
25         : GnomeCB<ControlTabularCreate>("GTabularCreate")
26 {}
27
28
29 GTabularCreate::~GTabularCreate()
30 {}
31
32
33 void GTabularCreate::build()
34 {
35         // Connect the buttons.
36         ok_btn()->signal_clicked().connect(SigC::slot(*this,
37                                          &GTabularCreate::OKClicked));
38         cancel_btn()->signal_clicked().connect(SigC::slot(*this,
39                                          &GTabularCreate::CancelClicked));
40         apply_btn()->signal_clicked().connect(SigC::slot(*this,
41                                          &GTabularCreate::ApplyClicked));
42
43         // Manage the buttons state
44         bc().setOK(ok_btn());
45         bc().setCancel(cancel_btn());
46         bc().setApply(apply_btn());
47
48         // Make sure everything is in the correct state.
49         bc().refresh();
50 }
51
52
53 void GTabularCreate::apply()
54 {
55         unsigned int xsize = (unsigned int)(rows()->get_value_as_int());
56         unsigned int ysize = (unsigned int)(cols()->get_value_as_int());
57
58         controller().params() = std::make_pair(xsize, ysize);
59 }
60
61
62 void GTabularCreate::update()
63 {}
64
65
66 bool GTabularCreate::validate() const
67 {
68         return ( rows()->get_value_as_int() > 0 ) &&
69                ( cols()->get_value_as_int() > 0 );
70 }
71
72
73 Gtk::Button * GTabularCreate::ok_btn() const
74 {
75         return getWidget<Gtk::Button>("r_ok_btn");
76 }
77 Gtk::Button * GTabularCreate::apply_btn() const
78 {
79         return getWidget<Gtk::Button>("r_apply_btn");
80 }
81 Gtk::Button * GTabularCreate::cancel_btn() const
82 {
83         return getWidget<Gtk::Button>("r_cancel_btn");
84 }
85 Gtk::SpinButton * GTabularCreate::rows() const
86 {
87         return getWidget<Gtk::SpinButton>("r_rows");
88 }
89 Gtk::SpinButton * GTabularCreate::cols() const
90 {
91         return getWidget<Gtk::SpinButton>("r_cols");
92 }