]> git.lyx.org Git - features.git/commitdiff
* Add a DEFAULT state to InsetGraphicsParams::DisplayType.
authorAngus Leeming <leeming@lyx.org>
Fri, 1 Feb 2002 18:53:50 +0000 (18:53 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 1 Feb 2002 18:53:50 +0000 (18:53 +0000)
* InsetGraphics::updateInset will interogate lyxrc.display_graphics if
params.display == DEFAULT.
* Ensure that the "default" display is read to and written from file correctly.

Next to do: pass a GraphicsParams struct to the GraphicsCache when adding
an image rather tahn just the filename and use this to decide exactly
how to display the image. Will therefore be able to strip out the
lyxrc stuff from ImageLoader et al.

Angus

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3476 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FormGraphics.C
src/insets/ChangeLog
src/insets/insetgraphics.C
src/insets/insetgraphicsParams.C
src/insets/insetgraphicsParams.h

index 164de5cfdaeafb7e110a0138bd66b89dd9d1425a..09e08562c15d8ea93d4d8c32c2dc90ea663b4768 100644 (file)
@@ -1,3 +1,8 @@
+2002-02-01  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormGraphics.C (apply, update): respect the new DEFAULT state of
+       InsetGraphicsParams::DisplayType.
+
 2002-01-31  Martin Vermeer <martin.vermeer@hut.fi>
 
        * forms/form_graphics.fd: tweeks.
index e88aab309b554a4ba338f364f9085a15b07d9df5..68cb4f662f82c3f2962e629be9621c056a8bb078 100644 (file)
@@ -195,25 +195,25 @@ void FormGraphics::apply()
        igp.clip = fl_get_button(bbox_->button_clip);
        igp.subcaption = fl_get_button(file_->check_subcaption);
        igp.subcaptionText = getStringFromInput(file_->input_subcaption);
-       // use preferences settings if choice is set to default
-       if (fl_get_choice(file_->choice_display) == 1) {
-               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 if (lyxrc.display_graphics == "no")
-                       igp.display = InsetGraphicsParams::NONE;
-       } else if (fl_get_choice(file_->choice_display) == 2) {
-               igp.display = InsetGraphicsParams::MONOCHROME;
-       } else if (fl_get_choice(file_->choice_display) == 3) {
-               igp.display = InsetGraphicsParams::GRAYSCALE;
-       } else if (fl_get_choice(file_->choice_display) == 4) {
-               igp.display = InsetGraphicsParams::COLOR;
-       } else if (fl_get_choice(file_->choice_display) == 5) {
-               igp.display = InsetGraphicsParams::NONE;
-       }
+
+       switch (fl_get_choice(file_->choice_display)) {
+       case 1:
+               igp.display = InsetGraphicsParams::DEFAULT;             
+               break;
+       case 2:
+               igp.display = InsetGraphicsParams::MONOCHROME;          
+               break;
+       case 3:
+               igp.display = InsetGraphicsParams::GRAYSCALE;           
+               break;
+       case 4:
+               igp.display = InsetGraphicsParams::COLOR;               
+               break;
+       case 5:
+               igp.display = InsetGraphicsParams::NONE;                
+               break;
+       }
+
        if (fl_get_button(size_->button_default))
            igp.size_type = InsetGraphicsParams::DEFAULT_SIZE;
        else if (fl_get_button(size_->button_wh))
@@ -299,23 +299,23 @@ void FormGraphics::update()
                   fl_get_button(file_->check_subcaption));
 
        switch (igp.display) {
-           case InsetGraphicsParams::NONE: {   // dont't display
-               fl_set_choice(file_->choice_display, 5);
+       case InsetGraphicsParams::DEFAULT:
+               fl_set_choice(file_->choice_display, 1);
                break;
-           }
-           case InsetGraphicsParams::MONOCHROME: {
+       case InsetGraphicsParams::MONOCHROME:
                fl_set_choice(file_->choice_display, 2);
                break;
-           }
-           case InsetGraphicsParams::GRAYSCALE: {
+       case InsetGraphicsParams::GRAYSCALE:
                fl_set_choice(file_->choice_display, 3);
                break;
-           }
-           case InsetGraphicsParams::COLOR: {
+       case InsetGraphicsParams::COLOR:
                fl_set_choice(file_->choice_display, 4);
                break;
-           }
-       }
+       case InsetGraphicsParams::NONE:
+               fl_set_choice(file_->choice_display, 5);
+               break;
+       }
+
        updateWidgetsFromLength(size_->input_width,
                size_->choice_width_units,igp.width,defaultUnit);
        updateWidgetsFromLength(size_->input_height,
index 81c2a05f4a3b5ded40b9eb0b56c006d6e0f0af4c..13dce25c8a14031adddce5b175cba9a44958ba66 100644 (file)
@@ -1,3 +1,11 @@
+2002-02-01  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * insetgraphics.C (updateInset): if params.display == DEFAULT,
+       interogate lyxrc.display_graphics before diaplaying the graphic.
+
+       * insetgraphicsParams.[Ch]: respect the new DEFAULT state of
+       InsetGraphicsParams::DisplayType.
+
 2002-01-31  Herbert Voss  <voss@lyx.org>
 
        * insetgraphic.C: (readfigInset) set display to pref-default
index c75b0fe8980d0b3f0e1c60f055917ac566d0d34e..803a81f99eedc646a22ec50f0e910812b96f5c9d 100644 (file)
@@ -665,8 +665,20 @@ void InsetGraphics::updateInset() const
 
        // We do it this way so that in the face of some error, we will still
        // be in a valid state.
-       if (!params.filename.empty() && lyxrc.use_gui
-           && params.display != InsetGraphicsParams::NONE) {
+       InsetGraphicsParams::DisplayType local_display = params.display;
+       if (local_display == InsetGraphicsParams::DEFAULT) {
+               if (lyxrc.display_graphics == "mono")
+                       local_display = InsetGraphicsParams::MONOCHROME;
+               else if (lyxrc.display_graphics == "gray")
+                       local_display = InsetGraphicsParams::GRAYSCALE;
+               else if (lyxrc.display_graphics == "color")
+                       local_display = InsetGraphicsParams::COLOR;
+               else
+                       local_display = InsetGraphicsParams::NONE;
+       }
+
+       if (!params.filename.empty() && lyxrc.use_gui &&
+           local_display != InsetGraphicsParams::NONE) {
                temp = gc.addFile(params.filename);
        }
 
index b790ce1c5f3bb861b432c2aa41a60bc315e140b2..870f8d18dd9c8ad2e5115ae77c908c144b85f837 100644 (file)
 
 #include "insetgraphicsParams.h"
 
+#include "lyxrc.h"
 #include "support/translator.h"
 #include "support/filetools.h"
 #include "support/lyxlib.h"
 #include "support/LOstream.h"
-#include "lyxrc.h"
-
 #include "support/LAssert.h"
 
 namespace {
@@ -35,7 +34,7 @@ bool translatorsSet = false;
 /// This is the translator between the Display enum and corresponding lyx
 /// file strings.
 Translator< InsetGraphicsParams::DisplayType, string >
-displayTranslator(InsetGraphicsParams::MONOCHROME, "monochrome");
+displayTranslator(InsetGraphicsParams::DEFAULT, "default");
 
 // this is only compatibility stuff for the first 1.2 version
 // it is obselete until 1.3
@@ -67,6 +66,7 @@ InsetGraphicsParams::InsetGraphicsParams()
        if (! translatorsSet) {
                translatorsSet = true;
                // Fill the display translator
+               displayTranslator.addPair(DEFAULT, "default");
                displayTranslator.addPair(MONOCHROME, "monochrome");
                displayTranslator.addPair(GRAYSCALE, "grayscale");
                displayTranslator.addPair(COLOR, "color");
@@ -149,7 +149,8 @@ void InsetGraphicsParams::testInvariant() const
 {
        // Filename might be empty (when the dialog is first created).
        // Assert(!filename.empty());
-       lyx::Assert(display == COLOR ||
+       lyx::Assert(display == DEFAULT ||
+              display == COLOR ||
               display == MONOCHROME ||
               display == GRAYSCALE ||
               display == NONE
index 719aa22019c0dc9e90637959bc189672de5fc870..7cf32bf02c144d821ab40ee389ac24386d4624c1 100644 (file)
@@ -29,11 +29,13 @@ struct InsetGraphicsParams
 {
        /// How do we display the image?
        enum DisplayType {
+           DEFAULT,            // whatever is in lyxrc.display_graphics
            COLOR,              // full color range
            GRAYSCALE,          // 256 shades of gray
            MONOCHROME,         // In black and white.
            NONE                // only keep a frame in place.
        };
+       ///
        enum sizeType {
            DEFAULT_SIZE,       // like none
            WH,                 // width/height values