]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormGraphics.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormGraphics.C
index 37a32f274beb158fe7d5b74ef8b906802e8306bc..af3f41d5cccedf081fc626648ca5f27369ac51d5 100644 (file)
@@ -4,44 +4,48 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Baruch Even
- * \author Herbert Voss
+ * \author Herbert Voß
  * \author Rob Lahaye
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-
-#include "xformsBC.h"
-#include "ControlGraphics.h"
 #include "FormGraphics.h"
+#include "ControlGraphics.h"
 #include "forms/form_graphics.h"
 
+#include "controllers/helper_funcs.h"
+
 #include "checkedwidgets.h"
 #include "input_validators.h"
 #include "Tooltips.h"
 #include "xforms_helpers.h"
+#include "xformsBC.h"
 
-#include "debug.h" // for lyxerr
 #include "lyxrc.h" // for lyxrc.display_graphics
 
 #include "insets/insetgraphicsParams.h"
 
-#include "controllers/helper_funcs.h" // for getStringFromVector
-
 #include "frontends/Alert.h"
 
-#include "support/lstrings.h"  // for strToDbl & tostr
 #include "support/lyxlib.h"  // for float_equal
-#include "support/filetools.h"  // for MakeAbsPath etc
+#include "support/tostr.h"
 
-#include "support/BoostFormat.h"
+#include "lyx_forms.h"
 
-#include FORMS_H_LOCATION
+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;
 
 using std::endl;
+
 using std::vector;
+using std::string;
 
 
 namespace {
@@ -90,26 +94,26 @@ void FormGraphics::build()
        bcview().setCancel(dialog_->button_close);
        bcview().setRestore(dialog_->button_restore);
 
-       // the file section
+       // The file section.
        file_.reset(build_graphics_file(this));
 
-       // disable for read-only documents
+       // Disable for read-only documents.
        bcview().addReadOnly(file_->button_browse);
        bcview().addReadOnly(file_->check_aspectratio);
        bcview().addReadOnly(file_->check_draft);
        bcview().addReadOnly(file_->check_nounzip);
 
-       // check validity of "length + unit" input
+       // Check validity of "length + unit" input.
        addCheckedGlueLength(bcview(), file_->input_width);
        addCheckedGlueLength(bcview(), file_->input_height);
 
-       // trigger an input event for cut&paste with middle mouse button.
+       // Trigger an input event for cut&paste with middle mouse button.
        setPrehandler(file_->input_filename);
        setPrehandler(file_->input_lyxscale);
        setPrehandler(file_->input_width);
        setPrehandler(file_->input_height);
 
-       // for activate ok/apply immediately upon input
+       // Activate ok/apply immediately upon input.
        fl_set_input_return(file_->input_filename, FL_RETURN_CHANGED);
        fl_set_input_return(file_->input_lyxscale, FL_RETURN_CHANGED);
        fl_set_input_return(file_->input_width, FL_RETURN_CHANGED);
@@ -118,7 +122,7 @@ void FormGraphics::build()
        fl_set_input_maxchars(file_->input_filename, FILENAME_MAXCHARS);
        fl_set_input_filter(file_->input_lyxscale, fl_unsigned_int_filter);
 
-       // width default is scaling: use unsigned float filter
+       // Width default is scaling: use unsigned float filter.
        fl_set_input_filter(file_->input_width, fl_unsigned_float_filter);
        fl_set_input_maxchars(file_->input_height, SIZE_MAXDIGITS);
 
@@ -263,20 +267,23 @@ void FormGraphics::build()
                fl_set_tabfolder_autofit(dialog_->tabfolder, FL_FIT);
 
        // Stack tabs
-       fl_addto_tabfolder(dialog_->tabfolder, _("File"), file_->form);
-       fl_addto_tabfolder(dialog_->tabfolder, _("Bounding Box"), bbox_->form);
-       fl_addto_tabfolder(dialog_->tabfolder, _("Extra"), extra_->form);
+       fl_addto_tabfolder(dialog_->tabfolder, _("File").c_str(),
+                          file_->form);
+       fl_addto_tabfolder(dialog_->tabfolder, _("Bounding Box").c_str(),
+                          bbox_->form);
+       fl_addto_tabfolder(dialog_->tabfolder, _("Extra").c_str(),
+                          extra_->form);
 
        // set the right default unit
        switch (lyxrc.default_papersize) {
-       case BufferParams::PAPER_DEFAULT: break;
-       case BufferParams::PAPER_USLETTER:
-       case BufferParams::PAPER_LEGALPAPER:
-       case BufferParams::PAPER_EXECUTIVEPAPER: defaultUnit = "in"; break;
-       case BufferParams::PAPER_A3PAPER:
-       case BufferParams::PAPER_A4PAPER:
-       case BufferParams::PAPER_A5PAPER:
-       case BufferParams::PAPER_B5PAPER: defaultUnit = "cm"; break;
+       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;
        }
 }
 
@@ -287,7 +294,8 @@ void FormGraphics::apply()
        InsetGraphicsParams & igp = controller().params();
 
        // the file section
-       igp.filename = getString(file_->input_filename);
+       igp.filename.set(getString(file_->input_filename),
+                        kernel().bufferFilepath());
 
        igp.lyxscale = strToInt(getString(file_->input_lyxscale));
        if (igp.lyxscale == 0) {
@@ -296,25 +304,25 @@ void FormGraphics::apply()
 
        switch (fl_get_choice(file_->choice_display)) {
        case 5:
-               igp.display = grfx::NoDisplay;
+               igp.display = lyx::graphics::NoDisplay;
                break;
        case 4:
-               igp.display = grfx::ColorDisplay;
+               igp.display = lyx::graphics::ColorDisplay;
                break;
        case 3:
-               igp.display = grfx::GrayscaleDisplay;
+               igp.display = lyx::graphics::GrayscaleDisplay;
                break;
        case 2:
-               igp.display = grfx::MonochromeDisplay;
+               igp.display = lyx::graphics::MonochromeDisplay;
                break;
        case 1:
-               igp.display = grfx::DefaultDisplay;
+               igp.display = lyx::graphics::DefaultDisplay;
        }
 
        // first item in choice_width means scaling
        if (fl_get_choice(file_->choice_width) == 1) {
                igp.scale = strToDbl(getString(file_->input_width));
-               if (lyx::float_equal(igp.scale, 0.0, 0.05)) {
+               if (float_equal(igp.scale, 0.0, 0.05)) {
                        igp.scale = 100.0;
                }
                igp.width = LyXLength();
@@ -419,28 +427,30 @@ void FormGraphics::update() {
        InsetGraphicsParams & igp = controller().params();
 
        // the file section
-       fl_set_input(file_->input_filename, igp.filename.c_str());
+       string const name =
+               igp.filename.outputFilename(kernel().bufferFilepath());
+       fl_set_input(file_->input_filename, name.c_str());
        fl_set_input(file_->input_lyxscale, tostr(igp.lyxscale).c_str());
 
        switch (igp.display) {
-       case grfx::NoDisplay:
+       case lyx::graphics::NoDisplay:
                fl_set_choice(file_->choice_display, 5);
                break;
-       case grfx::ColorDisplay:
+       case lyx::graphics::ColorDisplay:
                fl_set_choice(file_->choice_display, 4);
                break;
-       case grfx::GrayscaleDisplay:
+       case lyx::graphics::GrayscaleDisplay:
                fl_set_choice(file_->choice_display, 3);
                break;
-       case grfx::MonochromeDisplay:
+       case lyx::graphics::MonochromeDisplay:
                fl_set_choice(file_->choice_display, 2);
                break;
-       case grfx::DefaultDisplay:
+       case lyx::graphics::DefaultDisplay:
                fl_set_choice(file_->choice_display, 1);
        }
 
        // set width input fields according to scaling or width/height input
-       if (!lyx::float_equal(igp.scale, 0.0, 0.05)) {
+       if (!float_equal(igp.scale, 0.0, 0.05)) {
                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());
@@ -456,7 +466,7 @@ void FormGraphics::update() {
                                igp.height, defaultUnit);
 
        // disable height input in case of scaling
-       bool const disable_height = !lyx::float_equal(igp.scale, 0.0, 0.05);
+       bool const disable_height = !float_equal(igp.scale, 0.0, 0.05);
        setEnabled(file_->input_height, !disable_height);
        setEnabled(file_->choice_height, !disable_height);
 
@@ -474,7 +484,7 @@ void FormGraphics::update() {
        // the bb section
        // set the bounding box values, if exists. First we need the whole
        // path, because the controller knows nothing about the doc-dir
-       updateBB(igp.filename, igp.bb);
+       updateBB(igp.filename.absFilename(), igp.bb);
        fl_set_button(bbox_->check_clip, igp.clip);
 
        // the extra section
@@ -564,7 +574,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
        if (ob == file_->button_browse) {
                // Get the filename from the dialog
                string const in_name = getString(file_->input_filename);
-               string const out_name = controller().Browse(in_name);
+               string const out_name = controller().browse(in_name);
                lyxerr[Debug::GRAPHICS]
                        << "[FormGraphics]out_name: " << out_name << endl;
                if (out_name != in_name && !out_name.empty()) {