3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
22 #include "ControlVSpace.h"
25 #include <libglademm.h>
33 GVSpace::GVSpace(Dialog & parent)
34 : GViewCB<ControlVSpace, GViewGladeB>(parent, _("VSpace Settings"), false)
38 void GVSpace::doBuild()
40 string const gladeName = findGladeFile("vspace");
41 xml_ = Gnome::Glade::Xml::create(gladeName);
44 xml_->get_widget("Cancel", button);
46 xml_->get_widget("OK", button);
49 xml_->get_widget("Spacing", spacingcombo_);
50 xml_->get_widget("Value", valuespin_);
52 xml_->get_widget("ValueUnits", box);
53 box->pack_start(valueunitscombo_, true, true, 0);
56 xml_->get_widget("Protect", protectcheck_);
58 populateUnitCombo(valueunitscombo_, false);
60 spacingcombo_->signal_changed().connect(
61 sigc::mem_fun(*this, &GVSpace::onSpacingComboChanged));
65 void GVSpace::update()
67 VSpace const space = controller().params();
70 switch (space.kind()) {
74 case VSpace::SMALLSKIP:
91 spacingcombo_->set_active(pos);
93 protectcheck_->set_active(space.keep());
95 bool const custom_vspace = space.kind() == VSpace::LENGTH;
97 setWidgetsFromLength(*valuespin_->get_adjustment(), valueunitscombo_, space.length().len());
99 setWidgetsFromLength(*valuespin_->get_adjustment(), valueunitscombo_, LyXLength());
105 void GVSpace::apply()
108 switch (spacingcombo_->get_active_row_number()) {
110 space = VSpace(VSpace::DEFSKIP);
113 space = VSpace(VSpace::SMALLSKIP);
116 space = VSpace(VSpace::MEDSKIP);
119 space = VSpace(VSpace::BIGSKIP);
122 space = VSpace(VSpace::VFILL);
125 space = VSpace(LyXGlueLength(getLengthFromWidgets(*valuespin_->get_adjustment(), valueunitscombo_)));
129 space.setKeep(protectcheck_->get_active());
131 controller().params() = space;
135 void GVSpace::onSpacingComboChanged()
137 bool const custom = spacingcombo_->get_active_row_number() == 5;
138 valueunitscombo_.set_sensitive(custom);
139 valuespin_->set_sensitive(custom);
142 } // namespace frontend