float2string changes #1 (Graphics), missing bits

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9405 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2004-12-28 11:27:51 +00:00
parent ec0c2e5bc0
commit 99edaf8969
6 changed files with 49 additions and 30 deletions

View File

@ -1,3 +1,7 @@
2004-12-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* GGraphics.C: store all values as strings.
2004-12-19 Angus Leeming <leeming@lyx.org> 2004-12-19 Angus Leeming <leeming@lyx.org>
* lyx_gui.C (start): s/slashify_path/internal_path/ * lyx_gui.C (start): s/slashify_path/internal_path/

View File

@ -28,6 +28,7 @@
#include "support/lyxlib.h" // for float_equal #include "support/lyxlib.h" // for float_equal
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/tostr.h"
#include "debug.h" #include "debug.h"
@ -37,6 +38,7 @@ using std::string;
namespace lyx { namespace lyx {
using support::float_equal; using support::float_equal;
using support::strToDbl;
using support::token; using support::token;
namespace frontend { namespace frontend {
@ -265,12 +267,13 @@ void GGraphics::apply()
} }
if (setscalingradio_->get_active()) { if (setscalingradio_->get_active()) {
igp.scale = outputscalespin_->get_adjustment()->get_value(); float scaleValue = outputscalespin_->get_adjustment()->get_value();
if (float_equal(igp.scale, 0.0, 0.05)) igp.scale = tostr(scaleValue);
igp.scale = 100.0; if (float_equal(scaleValue, 0.0, 0.05))
igp.scale = string();
igp.width = LyXLength(); igp.width = LyXLength();
} else { } else {
igp.scale = 0.0; igp.scale = string();
Glib::ustring const widthunit = Glib::ustring const widthunit =
(*widthunitscombo_->get_active())[stringcol_]; (*widthunitscombo_->get_active())[stringcol_];
igp.width = LyXLength(widthspin_->get_text() + widthunit); igp.width = LyXLength(widthspin_->get_text() + widthunit);
@ -326,7 +329,7 @@ void GGraphics::apply()
igp.clip = clipcheck_->get_active(); igp.clip = clipcheck_->get_active();
// the extra section // 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(); int const origin_pos = origincombo_->get_active_row_number();
igp.rotateOrigin = origins_[origin_pos]; igp.rotateOrigin = origins_[origin_pos];
@ -369,7 +372,7 @@ void GGraphics::update() {
displaycombo_->set_active(0); 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()); widthspin_->get_adjustment()->set_value(igp.width.value());
unitsComboFromLength(widthunitscombo_, stringcol_, unitsComboFromLength(widthunitscombo_, stringcol_,
igp.width, defaultUnit); igp.width, defaultUnit);
@ -377,7 +380,7 @@ void GGraphics::update() {
unitsComboFromLength(heightunitscombo_, stringcol_, unitsComboFromLength(heightunitscombo_, stringcol_,
igp.height, defaultUnit); igp.height, defaultUnit);
if (!float_equal(igp.scale, 0.0, 0.05)) { if (!igp.scale.empty() && igp.scale != "0") {
// scaling sizing mode // scaling sizing mode
setscalingradio_->set_active(true); setscalingradio_->set_active(true);
} else { } else {
@ -396,7 +399,7 @@ void GGraphics::update() {
clipcheck_->set_active(igp.clip); clipcheck_->set_active(igp.clip);
// the extra section // the extra section
anglespin_->get_adjustment()->set_value(igp.rotateAngle); anglespin_->get_adjustment()->set_value(strToDbl(igp.rotateAngle));
int origin_pos; int origin_pos;
if (igp.rotateOrigin.empty()) { if (igp.rotateOrigin.empty()) {

View File

@ -1,3 +1,7 @@
2004-12-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* QGraphics.C: store all values as strings.
2004-12-19 Angus Leeming <leeming@lyx.org> 2004-12-19 Angus Leeming <leeming@lyx.org>
* lyx_gui.C (start): s/slashify_path/internal_path/ * lyx_gui.C (start): s/slashify_path/internal_path/

View File

@ -256,9 +256,8 @@ void QGraphics::update_contents()
for (int i = 0; i < num_units; i++) for (int i = 0; i < num_units; i++)
dialog_->widthUnit->insertItem(unit_name_gui[i], -1); dialog_->widthUnit->insertItem(unit_name_gui[i], -1);
if (!float_equal(igp.scale, 0.0, 0.05)) { if (!igp.scale.empty() && igp.scale != "0") {
// there is a scale value > 0.05 dialog_->width->setText(toqstr(igp.scale));
dialog_->width->setText(toqstr(tostr(igp.scale)));
dialog_->widthUnit->setCurrentItem(0); dialog_->widthUnit->setCurrentItem(0);
} else { } else {
// no scale means default width/height // no scale means default width/height
@ -280,7 +279,7 @@ void QGraphics::update_contents()
dialog_->aspectratio->setChecked(igp.keepAspectRatio); dialog_->aspectratio->setChecked(igp.keepAspectRatio);
dialog_->angle->setText(toqstr(tostr(igp.rotateAngle))); dialog_->angle->setText(toqstr(igp.rotateAngle));
dialog_->origin->clear(); dialog_->origin->clear();
@ -364,10 +363,10 @@ void QGraphics::apply()
// width/height combination // width/height combination
igp.width = igp.width =
widgetsToLength(dialog_->width, dialog_->widthUnit); widgetsToLength(dialog_->width, dialog_->widthUnit);
igp.scale = 0.0; igp.scale = string();
} else { } else {
// scaling instead of a width // scaling instead of a width
igp.scale = strToDbl(value); igp.scale = value;
igp.width = LyXLength(); igp.width = LyXLength();
} }
value = fromqstr(dialog_->height->text()); value = fromqstr(dialog_->height->text());
@ -380,10 +379,13 @@ void QGraphics::apply()
igp.lyxscale = strToInt(fromqstr(dialog_->displayscale->text())); 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) float rotAngle = strToDbl(igp.rotateAngle);
igp.rotateAngle -= 360.0 * floor(igp.rotateAngle / 360.0); 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 // save the latex name for the origin. If it is the default
// then origin_ltx returns "" // then origin_ltx returns ""

View File

@ -1,3 +1,7 @@
2004-12-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* FormGraphics.C: store all values as strings.
2004-12-19 Angus Leeming <leeming@lyx.org> 2004-12-19 Angus Leeming <leeming@lyx.org>
* lyx_gui.C (start): s/slashify_path/internal_path/ * lyx_gui.C (start): s/slashify_path/internal_path/

View File

@ -330,13 +330,13 @@ void FormGraphics::apply()
// first item in choice_width means scaling // first item in choice_width means scaling
if (fl_get_choice(file_->choice_width) == 1) { if (fl_get_choice(file_->choice_width) == 1) {
igp.scale = strToDbl(getString(file_->input_width)); igp.scale = getString(file_->input_width);
if (float_equal(igp.scale, 0.0, 0.05)) { if (igp.scale.empty() || igp.scale == "0" || igp.scale == "100") {
igp.scale = 100.0; igp.scale = string();
} }
igp.width = LyXLength(); igp.width = LyXLength();
} else { } else {
igp.scale = 0.0; igp.scale = string();
igp.width = LyXLength(getLengthFromWidgets(file_->input_width, igp.width = LyXLength(getLengthFromWidgets(file_->input_width,
file_->choice_width)); file_->choice_width));
} }
@ -406,13 +406,16 @@ void FormGraphics::apply()
igp.clip = fl_get_button(bbox_->check_clip); igp.clip = fl_get_button(bbox_->check_clip);
// the extra section // 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) // map angle into -360 (clock-wise) to +360 (counter clock-wise)
if (std::abs(igp.rotateAngle) > 360.0) float rotAngle = strToDbl(igp.rotateAngle);
igp.rotateAngle -= 360.0 * floor(igp.rotateAngle / 360.0); 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); int const origin_pos = fl_get_choice(extra_->choice_origin);
if (origin_pos == 0) { if (origin_pos == 0) {
@ -456,10 +459,10 @@ void FormGraphics::update() {
} }
// set width input fields according to scaling or width/height input // 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_filter(file_->input_width, fl_unsigned_float_filter);
fl_set_input_maxchars(file_->input_width, 0); 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); fl_set_choice(file_->choice_width, 1);
} else { } else {
fl_set_input_filter(file_->input_width, NULL); fl_set_input_filter(file_->input_width, NULL);
@ -472,7 +475,7 @@ void FormGraphics::update() {
igp.height, defaultUnit); igp.height, defaultUnit);
// disable height input in case of scaling // 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_->input_height, !disable_height);
setEnabled(file_->choice_height, !disable_height); setEnabled(file_->choice_height, !disable_height);
@ -494,8 +497,7 @@ void FormGraphics::update() {
fl_set_button(bbox_->check_clip, igp.clip); fl_set_button(bbox_->check_clip, igp.clip);
// the extra section // the extra section
fl_set_input(extra_->input_rotate_angle, fl_set_input(extra_->input_rotate_angle, igp.rotateAngle.c_str());
tostr(igp.rotateAngle).c_str());
int origin_pos; int origin_pos;
if (igp.rotateOrigin.empty()) { if (igp.rotateOrigin.empty()) {