]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormGraphics.C
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / xforms / FormGraphics.C
index 7063625e96204a6b9870892cafbd3d0ba9dda1aa..026676d19438b6cda9bab2c9e0867ceb6490206f 100644 (file)
 
 #include "lyx_forms.h"
 
-using lyx::support::bformat;
-using lyx::support::float_equal;
-using lyx::support::getStringFromVector;
-using lyx::support::strToDbl;
-using lyx::support::strToInt;
-using lyx::support::token;
+#include <cmath>
+
+#ifndef CXX_GLOBAL_CSTD
+using std::floor;
+#endif
 
 using std::endl;
 
 using std::vector;
 using std::string;
 
+namespace lyx {
+
+using support::bformat;
+using support::float_equal;
+using support::getStringFromVector;
+using support::strToDbl;
+using support::strToInt;
+using support::token;
+
+namespace frontend {
 
 namespace {
 
@@ -194,7 +203,7 @@ void FormGraphics::build()
        fl_set_input_filter(bbox_->input_bb_y0, fl_unsigned_float_filter);
        fl_set_input_filter(bbox_->input_bb_y1, fl_unsigned_float_filter);
 
-       string const bb_units = getStringFromVector(frnt::getBBUnits(), "|");
+       string const bb_units = getStringFromVector(getBBUnits(), "|");
        fl_addto_choice(bbox_->choice_bb_units, bb_units.c_str());
 
        // set up the tooltips for the bounding-box-section
@@ -239,7 +248,6 @@ void FormGraphics::build()
 
        fl_set_input_filter(extra_->input_rotate_angle, fl_float_filter);
 
-       using namespace frnt;
        vector<RotationOriginPair> origindata = getRotationOriginData();
 
        // Store the identifiers for later
@@ -305,19 +313,19 @@ void FormGraphics::apply()
 
        switch (fl_get_choice(file_->choice_display)) {
        case 5:
-               igp.display = lyx::graphics::NoDisplay;
+               igp.display = graphics::NoDisplay;
                break;
        case 4:
-               igp.display = lyx::graphics::ColorDisplay;
+               igp.display = graphics::ColorDisplay;
                break;
        case 3:
-               igp.display = lyx::graphics::GrayscaleDisplay;
+               igp.display = graphics::GrayscaleDisplay;
                break;
        case 2:
-               igp.display = lyx::graphics::MonochromeDisplay;
+               igp.display = graphics::MonochromeDisplay;
                break;
        case 1:
-               igp.display = lyx::graphics::DefaultDisplay;
+               igp.display = graphics::DefaultDisplay;
        }
 
        // first item in choice_width means scaling
@@ -401,12 +409,9 @@ void FormGraphics::apply()
        igp.rotateAngle = strToDbl(getString(extra_->input_rotate_angle));
 
        // map angle into -360 (clock-wise) to +360 (counter clock-wise)
-       while (igp.rotateAngle <= -360.0) {
-               igp.rotateAngle += 360.0;
-       }
-       while (igp.rotateAngle >=  360.0) {
-               igp.rotateAngle -= 360.0;
-       }
+       if (std::abs(igp.rotateAngle) > 360.0)
+               igp.rotateAngle -= 360.0 * floor(igp.rotateAngle / 360.0);
+
        fl_set_input(extra_->input_rotate_angle, tostr(igp.rotateAngle).c_str());
 
        int const origin_pos = fl_get_choice(extra_->choice_origin);
@@ -434,19 +439,19 @@ void FormGraphics::update() {
        fl_set_input(file_->input_lyxscale, tostr(igp.lyxscale).c_str());
 
        switch (igp.display) {
-       case lyx::graphics::NoDisplay:
+       case graphics::NoDisplay:
                fl_set_choice(file_->choice_display, 5);
                break;
-       case lyx::graphics::ColorDisplay:
+       case graphics::ColorDisplay:
                fl_set_choice(file_->choice_display, 4);
                break;
-       case lyx::graphics::GrayscaleDisplay:
+       case graphics::GrayscaleDisplay:
                fl_set_choice(file_->choice_display, 3);
                break;
-       case lyx::graphics::MonochromeDisplay:
+       case graphics::MonochromeDisplay:
                fl_set_choice(file_->choice_display, 2);
                break;
-       case lyx::graphics::DefaultDisplay:
+       case graphics::DefaultDisplay:
                fl_set_choice(file_->choice_display, 1);
        }
 
@@ -571,8 +576,12 @@ void FormGraphics::updateBB(string const & filename, string const & bb_inset)
 
 ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
 {
+       ButtonPolicy::SMInput activate = ButtonPolicy::SMI_VALID;
+
        // the file section
        if (ob == file_->button_browse) {
+               activate = ButtonPolicy::SMI_NOOP;
+
                // Get the filename from the dialog
                string const in_name = getString(file_->input_filename);
                string const out_name = controller().browse(in_name);
@@ -642,7 +651,14 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
                setEnabled(extra_->input_subcaption,
                           fl_get_button(extra_->check_subcaption));
 
+       } else if (ob == file_->button_edit) {
+               activate = ButtonPolicy::SMI_NOOP;
+               controller().editGraphics();
        }
 
-       return ButtonPolicy::SMI_VALID;
+
+       return activate;
 }
+
+} // namespace frontend
+} // namespace lyx