]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GTabularCreate.C
Martin's changes to the Note inset.
[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
12 #include <config.h>
13 #include <utility>
14
15 #include "gnomeBC.h"
16 #include "GTabularCreate.h"
17
18 #include <gtkmm/spinbutton.h>
19 #include <gtkmm/button.h>
20
21 GTabularCreate::GTabularCreate()
22         : GnomeCB<ControlTabularCreate>("GTabularCreate")
23 {}
24
25
26 GTabularCreate::~GTabularCreate()
27 {}
28
29
30 void GTabularCreate::build()
31 {
32         // Connect the buttons.
33         ok_btn()->signal_clicked().connect(SigC::slot(*this,
34                                          &GTabularCreate::OKClicked));
35         cancel_btn()->signal_clicked().connect(SigC::slot(*this,
36                                          &GTabularCreate::CancelClicked));
37         apply_btn()->signal_clicked().connect(SigC::slot(*this,
38                                          &GTabularCreate::ApplyClicked));
39
40         // Manage the buttons state
41         bc().setOK(ok_btn());
42         bc().setCancel(cancel_btn());
43         bc().setApply(apply_btn());
44
45         // Make sure everything is in the correct state.
46         bc().refresh();
47 }
48
49
50 void GTabularCreate::apply()
51 {
52         unsigned int xsize = (unsigned int)(rows()->get_value_as_int());
53         unsigned int ysize = (unsigned int)(cols()->get_value_as_int());
54
55         controller().params() = std::make_pair(xsize, ysize);
56 }
57
58
59 void GTabularCreate::update()
60 {}
61
62
63 bool GTabularCreate::validate() const
64 {
65         return ( rows()->get_value_as_int() > 0 ) &&
66                ( cols()->get_value_as_int() > 0 );
67 }
68
69
70 Gtk::Button * GTabularCreate::ok_btn() const
71 {
72         return getWidget<Gtk::Button>("r_ok_btn");
73 }
74 Gtk::Button * GTabularCreate::apply_btn() const
75 {
76         return getWidget<Gtk::Button>("r_apply_btn");
77 }
78 Gtk::Button * GTabularCreate::cancel_btn() const
79 {
80         return getWidget<Gtk::Button>("r_cancel_btn");
81 }
82 Gtk::SpinButton * GTabularCreate::rows() const
83 {
84         return getWidget<Gtk::SpinButton>("r_rows");
85 }
86 Gtk::SpinButton * GTabularCreate::cols() const
87 {
88         return getWidget<Gtk::SpinButton>("r_cols");
89 }