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