#include <config.h>
+// Too hard to make concept checks work with this file
+#ifdef _GLIBCPP_CONCEPT_CHECKS
+#undef _GLIBCPP_CONCEPT_CHECKS
+#endif
+
#include "GGraphics.h"
#include "ControlGraphics.h"
// Store the identifiers for later
origins_ = getSecond(origindata);
PopulateComboBox(origincombo_, getFirst(origindata));
-
- // set the right default unit
- switch (lyxrc.default_papersize) {
- case PAPER_DEFAULT: break;
- case PAPER_USLETTER:
- case PAPER_LEGALPAPER:
- case PAPER_EXECUTIVEPAPER: defaultUnit = "in"; break;
- case PAPER_A3PAPER:
- case PAPER_A4PAPER:
- case PAPER_A5PAPER:
- case PAPER_B5PAPER: defaultUnit = "cm"; break;
- }
}
}
-void GGraphics::updateComboFromLength(Gtk::ComboBox * combo,
- LyXLength const & len)
-{
- string unit = stringFromUnit(len.unit());
- if (unit.empty())
- unit = defaultUnit;
-
- Gtk::TreeModel::iterator it = combo->get_model()->children().begin();
- Gtk::TreeModel::iterator end = combo->get_model()->children().end();
- for (; it != end ; ++it) {
- if ((*it)[stringcol_] == unit) {
- combo->set_active(it);
- return;
- }
- }
- // Fallen through, we didn't find the target length!
- combo->set_active(0);
- lyxerr << "GGraphics::updateComboFromLength: couldn't find "
- "target unit '" << unit << "'\n";
-}
-
-
void GGraphics::apply()
{
// Create the parameters structure and fill the data from the dialog.
void GGraphics::update() {
+ // set the right default unit
+ defaultUnit = getDefaultUnit();
+
// Update dialog with details from inset
InsetGraphicsParams & igp = controller().params();
outputscalespin_->get_adjustment()->set_value(igp.scale);
widthspin_->get_adjustment()->set_value(igp.width.value());
- updateComboFromLength(widthunitscombo_, igp.width);
+ unitsComboFromLength(widthunitscombo_, stringcol_,
+ igp.width, defaultUnit);
heightspin_->get_adjustment()->set_value(igp.height.value());
- updateComboFromLength(heightunitscombo_, igp.height);
+ unitsComboFromLength(heightunitscombo_, stringcol_,
+ igp.height, defaultUnit);
if (!float_equal(igp.scale, 0.0, 0.05)) {
// scaling sizing mode
righttopxspin_->set_text("");
righttopyspin_->set_text("");
}
- updateComboFromLength(bbunitscombo_,LyXLength("bp"));
+ unitsComboFromLength(bbunitscombo_, stringcol_,
+ LyXLength("bp"), defaultUnit);
} else {
// get the values from the inset
lyxerr[Debug::GRAPHICS]
LyXLength anyLength;
anyLength = LyXLength(token(bb_inset, ' ', 0));
- updateComboFromLength(bbunitscombo_, anyLength);
+ unitsComboFromLength(bbunitscombo_, stringcol_, anyLength, defaultUnit);
leftbottomxspin_->get_adjustment()->set_value(anyLength.value());
leftbottomyspin_->set_text(token(bb, ' ', 1));
righttopxspin_->set_text(token(bb, ' ', 2));
righttopyspin_->set_text(token(bb, ' ', 3));
- updateComboFromLength(bbunitscombo_,LyXLength("bp"));
+ unitsComboFromLength(bbunitscombo_, stringcol_,
+ LyXLength("bp"), defaultUnit);
}
controller().bbChanged = false;
} else {
leftbottomyspin_->set_text("");
righttopxspin_->set_text("");
righttopyspin_->set_text("");
- updateComboFromLength(bbunitscombo_,LyXLength("bp"));
+ unitsComboFromLength(bbunitscombo_, stringcol_,
+ LyXLength("bp"), defaultUnit);
}
bc().input(ButtonPolicy::SMI_VALID);
}