]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/FormTabularCreate.C
ws cleanup
[lyx.git] / src / frontends / gnome / FormTabularCreate.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 "FormTabularCreate.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         // Note that there is no need to destroy the class itself, it seems
33         // like everything is managed inside it. Deleting the class itself will
34         // a crash at the end of the program.
35         //dialog_->destroy();
36 }
37
38
39 void FormTabularCreate::build()
40 {
41         // Connect the buttons.
42         ok_btn()->clicked.connect(SigC::slot(this,
43                                          &FormTabularCreate::OKClicked));
44         cancel_btn()->clicked.connect(SigC::slot(this,
45                                          &FormTabularCreate::CancelClicked));
46         apply_btn()->clicked.connect(SigC::slot(this,
47                                      &FormTabularCreate::ApplyClicked));
48
49         // Manage the buttons state
50         bc().setOK(ok_btn());
51         bc().setCancel(cancel_btn());
52         bc().setApply(apply_btn());
53
54         // Make sure everything is in the correct state.
55         bc().refresh();
56 }
57
58
59 void FormTabularCreate::apply()
60 {
61         unsigned int ysize = (unsigned int)(rows()->get_value_as_int());
62         unsigned int xsize = (unsigned int)(cols()->get_value_as_int());
63
64         controller().params() = std::make_pair(xsize, ysize);
65 }
66
67
68 void FormTabularCreate::update()
69 {}
70
71
72 bool FormTabularCreate::validate() const
73 {
74         return ( rows()->get_value_as_int() > 0 ) &&
75                ( cols()->get_value_as_int() > 0 );
76 }
77
78
79 Gtk::Button * FormTabularCreate::ok_btn() const
80 {
81         return getWidget<Gtk::Button>("r_ok_btn");
82 }
83 Gtk::Button * FormTabularCreate::apply_btn() const
84 {
85         return getWidget<Gtk::Button>("r_apply_btn");
86 }
87 Gtk::Button * FormTabularCreate::cancel_btn() const
88 {
89         return getWidget<Gtk::Button>("r_cancel_btn");
90 }
91 Gtk::SpinButton * FormTabularCreate::rows() const
92 {
93         return getWidget<Gtk::SpinButton>("r_rows");
94 }
95 Gtk::SpinButton * FormTabularCreate::cols() const
96 {
97         return getWidget<Gtk::SpinButton>("r_cols");
98 }