1 /* This file is part of
2 * =================================================
4 * LyX, The Document Processor
5 * Copyright 1995-2000 The LyX Team.
7 * =================================================
9 * \author Michael Koziarski <michael@koziarski.org>
13 #pragma implementation
20 #include "FormTabularCreate.h"
22 #include <gtk--/spinbutton.h>
23 #include <gtk--/button.h>
25 FormTabularCreate::FormTabularCreate(ControlTabularCreate & c)
26 : FormCB<ControlTabularCreate>(c, "FormTabularCreate")
30 FormTabularCreate::~FormTabularCreate()
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.
39 void FormTabularCreate::build()
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));
49 // Manage the buttons state
51 bc().setCancel(cancel_btn());
52 bc().setApply(apply_btn());
54 // Make sure everything is in the correct state.
59 void FormTabularCreate::apply()
61 unsigned int ysize = (unsigned int)(rows()->get_value_as_int());
62 unsigned int xsize = (unsigned int)(cols()->get_value_as_int());
64 controller().params() = std::make_pair(xsize, ysize);
68 void FormTabularCreate::update()
72 bool FormTabularCreate::validate() const
74 return ( rows()->get_value_as_int() > 0 ) &&
75 ( cols()->get_value_as_int() > 0 );
79 Gtk::Button * FormTabularCreate::ok_btn() const
81 return getWidget<Gtk::Button>("r_ok_btn");
83 Gtk::Button * FormTabularCreate::apply_btn() const
85 return getWidget<Gtk::Button>("r_apply_btn");
87 Gtk::Button * FormTabularCreate::cancel_btn() const
89 return getWidget<Gtk::Button>("r_cancel_btn");
91 Gtk::SpinButton * FormTabularCreate::rows() const
93 return getWidget<Gtk::SpinButton>("r_rows");
95 Gtk::SpinButton * FormTabularCreate::cols() const
97 return getWidget<Gtk::SpinButton>("r_cols");