]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormGraphics.C
Bugfixes: checkboxes to radiobuttons (from J�rgen S) and remove a little
[lyx.git] / src / frontends / xforms / FormGraphics.C
index 1656510920ec91af7a96ff3f681f720fb1d63a07..936c19bdcd954bc2799ddba8054ca0702fce7fa4 100644 (file)
 #include "support/lstrings.h"  // for strToDbl & tostr
 #include "support/FileInfo.h"  // for FileInfo
 #include "insets/insetgraphicsParams.h"
+#include "lyxrc.h" // for lyxrc.display_graphics
 
 using std::endl;
 
-static double const tol = 1.0e-08;
+namespace {
+
+// Zero test for double precision numbers
+double const tol = 1.0e-08;
+
+// The maximum digits for the image scale
+int const SCALE_MAXDIGITS = 3;
+
+// The maximum digits for the image width
+int const WIDTH_MAXDIGITS = 3;
+
+// The maximum digits for the image height
+int const HEIGHT_MAXDIGITS = 3;
+
+// The max characters in the rotation angle (minus sign and 3 digits)
+int const ROTATE_MAXCHARS = 4;
+
+// The maximum characters in a filename.
+int const FILENAME_MAXCHARS = 1024;
+} // namespace anon
+
 
 typedef FormCB<ControlGraphics, FormDB<FD_form_graphics> > base_class;
 
@@ -107,10 +129,22 @@ void FormGraphics::apply()
 
        igp.filename = fl_get_input(dialog_->input_filename);
 
-       if (fl_get_button(dialog_->check_display)) {
-               igp.display = InsetGraphicsParams::COLOR;
-       } else {
+       if (lyxrc.display_graphics == "no") {
                igp.display = InsetGraphicsParams::NONE;
+
+       } else {
+               if (fl_get_button(dialog_->check_display)) {
+                       if (lyxrc.display_graphics == "mono") {
+                               igp.display = InsetGraphicsParams::MONOCHROME;
+                       } else if (lyxrc.display_graphics == "gray") {
+                               igp.display = InsetGraphicsParams::GRAYSCALE;
+                       } else if (lyxrc.display_graphics == "color") {
+                               igp.display = InsetGraphicsParams::COLOR;
+                       }
+                       
+               } else {
+                       igp.display = InsetGraphicsParams::NONE;
+               }
        }
 
        double const scale =
@@ -198,12 +232,18 @@ void FormGraphics::update()
                     igp.filename.c_str());
 
        // To display or not to display
-       if (igp.display == InsetGraphicsParams::NONE) {
+       if (lyxrc.display_graphics == "no") {
                fl_set_button(dialog_->check_display, 0);
        } else {
-               fl_set_button(dialog_->check_display, 1);
+               if (igp.display == InsetGraphicsParams::NONE) {
+                       fl_set_button(dialog_->check_display, 0);
+               } else {
+                       fl_set_button(dialog_->check_display, 1);
+               }
        }
 
+       setEnabled(dialog_->check_display, (lyxrc.display_graphics != "no"));
+
        if (igp.heightResize == InsetGraphicsParams::SCALE) {
                string number = tostr(igp.heightSize);
                fl_set_input(dialog_->input_scale, number.c_str());
@@ -222,7 +262,13 @@ void FormGraphics::update()
                fl_set_input(dialog_->input_width, number.c_str());
 
                int pos = 1;
+               //use inch as default with US papersizes in lyxrc
+               if (lyxrc.default_papersize < 3)
+                       pos = 2;
                switch (igp.widthResize) {
+               case InsetGraphicsParams::CM:
+                       pos = 1; break;
+
                case InsetGraphicsParams::INCH:
                        pos = 2; break;
 
@@ -244,7 +290,13 @@ void FormGraphics::update()
                fl_set_input(dialog_->input_height, number.c_str());
 
                pos = 1;
+               //use inch as default with US papersizes in lyxrc
+               if (lyxrc.default_papersize < 3)
+                       pos = 2;
                switch (igp.heightResize) {
+               case InsetGraphicsParams::CM:
+                       pos = 1; break;
+
                case InsetGraphicsParams::INCH:
                        pos = 2; break;
 
@@ -254,7 +306,7 @@ void FormGraphics::update()
                default:
                        break;
                }
-               fl_set_choice(dialog_->choice_width_units, pos);
+               fl_set_choice(dialog_->choice_height_units, pos);
        }
                
        // Update the rotate angle