From e173216d0aed9ea76bbd0d2916d77259a4b93223 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 1 Feb 2002 18:53:50 +0000 Subject: [PATCH] * Add a DEFAULT state to InsetGraphicsParams::DisplayType. * 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 | 5 +++ src/frontends/xforms/FormGraphics.C | 58 ++++++++++++++--------------- src/insets/ChangeLog | 8 ++++ src/insets/insetgraphics.C | 16 +++++++- src/insets/insetgraphicsParams.C | 9 +++-- src/insets/insetgraphicsParams.h | 2 + 6 files changed, 63 insertions(+), 35 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 164de5cfda..09e08562c1 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2002-02-01 Angus Leeming + + * FormGraphics.C (apply, update): respect the new DEFAULT state of + InsetGraphicsParams::DisplayType. + 2002-01-31 Martin Vermeer * forms/form_graphics.fd: tweeks. diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index e88aab309b..68cb4f662f 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -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, diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 81c2a05f4a..13dce25c8a 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,11 @@ +2002-02-01 Angus Leeming + + * 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 * insetgraphic.C: (readfigInset) set display to pref-default diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index c75b0fe898..803a81f99e 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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); } diff --git a/src/insets/insetgraphicsParams.C b/src/insets/insetgraphicsParams.C index b790ce1c5f..870f8d18dd 100644 --- a/src/insets/insetgraphicsParams.C +++ b/src/insets/insetgraphicsParams.C @@ -18,12 +18,11 @@ #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 diff --git a/src/insets/insetgraphicsParams.h b/src/insets/insetgraphicsParams.h index 719aa22019..7cf32bf02c 100644 --- a/src/insets/insetgraphicsParams.h +++ b/src/insets/insetgraphicsParams.h @@ -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 -- 2.39.2