]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GTabularCreate.C
A lean, clean and working start to the new, improved gnome frontend.
[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 <gtk--/spinbutton.h>
23 #include <gtk--/button.h>
24
25 FormTabularCreate::FormTabularCreate(ControlTabularCreate & c)
26         : FormCB<ControlTabularCreate>(c, "FormTabularCreate")
27 {}
28
29
30 FormTabularCreate::~FormTabularCreate()
31 {}
32
33
34 void FormTabularCreate::build()
35 {
36         // Connect the buttons.
37         ok_btn()->clicked.connect(SigC::slot(this, 
38                                          &FormTabularCreate::OKClicked));
39         cancel_btn()->clicked.connect(SigC::slot(this, 
40                                          &FormTabularCreate::CancelClicked));
41         apply_btn()->clicked.connect(SigC::slot(this, 
42                                      &FormTabularCreate::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 FormTabularCreate::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 FormTabularCreate::update()
64 {}
65
66
67 bool FormTabularCreate::validate() const
68 {
69         return ( rows()->get_value_as_int() > 0 ) && 
70                ( cols()->get_value_as_int() > 0 );
71 }
72
73
74 Gtk::Button * FormTabularCreate::ok_btn() const 
75 {
76         return getWidget<Gtk::Button>("r_ok_btn");
77 }
78 Gtk::Button * FormTabularCreate::apply_btn() const 
79 {
80         return getWidget<Gtk::Button>("r_apply_btn");
81 }
82 Gtk::Button * FormTabularCreate::cancel_btn() const 
83 {
84         return getWidget<Gtk::Button>("r_cancel_btn");
85 }
86 Gtk::SpinButton * FormTabularCreate::rows() const 
87 {
88         return getWidget<Gtk::SpinButton>("r_rows");
89 }
90 Gtk::SpinButton * FormTabularCreate::cols() const 
91 {
92         return getWidget<Gtk::SpinButton>("r_cols");
93 }
94