From: Jürgen Spitzmüller Date: Tue, 28 Dec 2004 11:27:51 +0000 (+0000) Subject: float2string changes #1 (Graphics), missing bits X-Git-Tag: 1.6.10~14716 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=99edaf8969a551cf929f394dbc91444e5674fb19;p=features.git float2string changes #1 (Graphics), missing bits git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9405 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index ac4bfac61e..328392af8f 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,7 @@ +2004-12-28 Jürgen Spitzmüller + + * GGraphics.C: store all values as strings. + 2004-12-19 Angus Leeming * lyx_gui.C (start): s/slashify_path/internal_path/ diff --git a/src/frontends/gtk/GGraphics.C b/src/frontends/gtk/GGraphics.C index 9fba9d0b29..e62422fd10 100644 --- a/src/frontends/gtk/GGraphics.C +++ b/src/frontends/gtk/GGraphics.C @@ -28,6 +28,7 @@ #include "support/lyxlib.h" // for float_equal #include "support/lstrings.h" +#include "support/tostr.h" #include "debug.h" @@ -37,6 +38,7 @@ using std::string; namespace lyx { using support::float_equal; +using support::strToDbl; using support::token; namespace frontend { @@ -265,12 +267,13 @@ void GGraphics::apply() } if (setscalingradio_->get_active()) { - igp.scale = outputscalespin_->get_adjustment()->get_value(); - if (float_equal(igp.scale, 0.0, 0.05)) - igp.scale = 100.0; + float scaleValue = outputscalespin_->get_adjustment()->get_value(); + igp.scale = tostr(scaleValue); + if (float_equal(scaleValue, 0.0, 0.05)) + igp.scale = string(); igp.width = LyXLength(); } else { - igp.scale = 0.0; + igp.scale = string(); Glib::ustring const widthunit = (*widthunitscombo_->get_active())[stringcol_]; igp.width = LyXLength(widthspin_->get_text() + widthunit); @@ -326,7 +329,7 @@ void GGraphics::apply() igp.clip = clipcheck_->get_active(); // the extra section - igp.rotateAngle = anglespin_->get_adjustment()->get_value(); + igp.rotateAngle = tostr(anglespin_->get_adjustment()->get_value()); int const origin_pos = origincombo_->get_active_row_number(); igp.rotateOrigin = origins_[origin_pos]; @@ -369,7 +372,7 @@ void GGraphics::update() { displaycombo_->set_active(0); } - outputscalespin_->get_adjustment()->set_value(igp.scale); + outputscalespin_->get_adjustment()->set_value(strToDbl(igp.scale)); widthspin_->get_adjustment()->set_value(igp.width.value()); unitsComboFromLength(widthunitscombo_, stringcol_, igp.width, defaultUnit); @@ -377,7 +380,7 @@ void GGraphics::update() { unitsComboFromLength(heightunitscombo_, stringcol_, igp.height, defaultUnit); - if (!float_equal(igp.scale, 0.0, 0.05)) { + if (!igp.scale.empty() && igp.scale != "0") { // scaling sizing mode setscalingradio_->set_active(true); } else { @@ -396,7 +399,7 @@ void GGraphics::update() { clipcheck_->set_active(igp.clip); // the extra section - anglespin_->get_adjustment()->set_value(igp.rotateAngle); + anglespin_->get_adjustment()->set_value(strToDbl(igp.rotateAngle)); int origin_pos; if (igp.rotateOrigin.empty()) { diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 76d103119e..1065949fd8 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2004-12-28 Jürgen Spitzmüller + + * QGraphics.C: store all values as strings. + 2004-12-19 Angus Leeming * lyx_gui.C (start): s/slashify_path/internal_path/ diff --git a/src/frontends/qt2/QGraphics.C b/src/frontends/qt2/QGraphics.C index 0a16e18801..836bdf203b 100644 --- a/src/frontends/qt2/QGraphics.C +++ b/src/frontends/qt2/QGraphics.C @@ -256,9 +256,8 @@ void QGraphics::update_contents() for (int i = 0; i < num_units; i++) dialog_->widthUnit->insertItem(unit_name_gui[i], -1); - if (!float_equal(igp.scale, 0.0, 0.05)) { - // there is a scale value > 0.05 - dialog_->width->setText(toqstr(tostr(igp.scale))); + if (!igp.scale.empty() && igp.scale != "0") { + dialog_->width->setText(toqstr(igp.scale)); dialog_->widthUnit->setCurrentItem(0); } else { // no scale means default width/height @@ -280,7 +279,7 @@ void QGraphics::update_contents() dialog_->aspectratio->setChecked(igp.keepAspectRatio); - dialog_->angle->setText(toqstr(tostr(igp.rotateAngle))); + dialog_->angle->setText(toqstr(igp.rotateAngle)); dialog_->origin->clear(); @@ -364,10 +363,10 @@ void QGraphics::apply() // width/height combination igp.width = widgetsToLength(dialog_->width, dialog_->widthUnit); - igp.scale = 0.0; + igp.scale = string(); } else { // scaling instead of a width - igp.scale = strToDbl(value); + igp.scale = value; igp.width = LyXLength(); } value = fromqstr(dialog_->height->text()); @@ -380,10 +379,13 @@ void QGraphics::apply() igp.lyxscale = strToInt(fromqstr(dialog_->displayscale->text())); - igp.rotateAngle = strToDbl(fromqstr(dialog_->angle->text())); + igp.rotateAngle = fromqstr(dialog_->angle->text()); - if (std::abs(igp.rotateAngle) > 360.0) - igp.rotateAngle -= 360.0 * floor(igp.rotateAngle / 360.0); + float rotAngle = strToDbl(igp.rotateAngle); + if (std::abs(rotAngle) > 360.0) { + rotAngle -= 360.0 * floor(rotAngle / 360.0); + igp.rotateAngle = tostr(rotAngle); + } // save the latex name for the origin. If it is the default // then origin_ltx returns "" diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 25f2ef7e2b..64a16a188e 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2004-12-28 Jürgen Spitzmüller + + * FormGraphics.C: store all values as strings. + 2004-12-19 Angus Leeming * lyx_gui.C (start): s/slashify_path/internal_path/ diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 026676d194..3ce01d793f 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -330,13 +330,13 @@ void FormGraphics::apply() // first item in choice_width means scaling if (fl_get_choice(file_->choice_width) == 1) { - igp.scale = strToDbl(getString(file_->input_width)); - if (float_equal(igp.scale, 0.0, 0.05)) { - igp.scale = 100.0; + igp.scale = getString(file_->input_width); + if (igp.scale.empty() || igp.scale == "0" || igp.scale == "100") { + igp.scale = string(); } igp.width = LyXLength(); } else { - igp.scale = 0.0; + igp.scale = string(); igp.width = LyXLength(getLengthFromWidgets(file_->input_width, file_->choice_width)); } @@ -406,13 +406,16 @@ void FormGraphics::apply() igp.clip = fl_get_button(bbox_->check_clip); // the extra section - igp.rotateAngle = strToDbl(getString(extra_->input_rotate_angle)); + igp.rotateAngle = getString(extra_->input_rotate_angle); // map angle into -360 (clock-wise) to +360 (counter clock-wise) - if (std::abs(igp.rotateAngle) > 360.0) - igp.rotateAngle -= 360.0 * floor(igp.rotateAngle / 360.0); + float rotAngle = strToDbl(igp.rotateAngle); + if (std::abs(rotAngle) > 360.0) { + rotAngle -= 360.0 * floor(rotAngle / 360.0); + igp.rotateAngle = tostr(rotAngle); + } - fl_set_input(extra_->input_rotate_angle, tostr(igp.rotateAngle).c_str()); + fl_set_input(extra_->input_rotate_angle, igp.rotateAngle.c_str()); int const origin_pos = fl_get_choice(extra_->choice_origin); if (origin_pos == 0) { @@ -456,10 +459,10 @@ void FormGraphics::update() { } // set width input fields according to scaling or width/height input - if (!float_equal(igp.scale, 0.0, 0.05)) { + if (!igp.scale.empty() && igp.scale != "0") { fl_set_input_filter(file_->input_width, fl_unsigned_float_filter); fl_set_input_maxchars(file_->input_width, 0); - fl_set_input(file_->input_width, tostr(igp.scale).c_str()); + fl_set_input(file_->input_width, igp.scale.c_str()); fl_set_choice(file_->choice_width, 1); } else { fl_set_input_filter(file_->input_width, NULL); @@ -472,7 +475,7 @@ void FormGraphics::update() { igp.height, defaultUnit); // disable height input in case of scaling - bool const disable_height = !float_equal(igp.scale, 0.0, 0.05); + bool const disable_height = (!igp.scale.empty() && igp.scale != "0"); setEnabled(file_->input_height, !disable_height); setEnabled(file_->choice_height, !disable_height); @@ -494,8 +497,7 @@ void FormGraphics::update() { fl_set_button(bbox_->check_clip, igp.clip); // the extra section - fl_set_input(extra_->input_rotate_angle, - tostr(igp.rotateAngle).c_str()); + fl_set_input(extra_->input_rotate_angle, igp.rotateAngle.c_str()); int origin_pos; if (igp.rotateOrigin.empty()) {