* 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
This commit is contained in:
Angus Leeming 2002-02-01 18:53:50 +00:00
parent 14f1b208db
commit e173216d0a
6 changed files with 63 additions and 35 deletions

View 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> 2002-01-31 Martin Vermeer <martin.vermeer@hut.fi>
* forms/form_graphics.fd: tweeks. * forms/form_graphics.fd: tweeks.

View File

@ -195,25 +195,25 @@ void FormGraphics::apply()
igp.clip = fl_get_button(bbox_->button_clip); igp.clip = fl_get_button(bbox_->button_clip);
igp.subcaption = fl_get_button(file_->check_subcaption); igp.subcaption = fl_get_button(file_->check_subcaption);
igp.subcaptionText = getStringFromInput(file_->input_subcaption); igp.subcaptionText = getStringFromInput(file_->input_subcaption);
// use preferences settings if choice is set to default
if (fl_get_choice(file_->choice_display) == 1) { switch (fl_get_choice(file_->choice_display)) {
if (lyxrc.display_graphics == "mono") case 1:
igp.display = InsetGraphicsParams::MONOCHROME; igp.display = InsetGraphicsParams::DEFAULT;
else if (lyxrc.display_graphics == "gray") break;
igp.display = InsetGraphicsParams::GRAYSCALE; case 2:
else if (lyxrc.display_graphics == "color") igp.display = InsetGraphicsParams::MONOCHROME;
igp.display = InsetGraphicsParams::COLOR; break;
else if (lyxrc.display_graphics == "no") case 3:
igp.display = InsetGraphicsParams::NONE; igp.display = InsetGraphicsParams::GRAYSCALE;
} else if (fl_get_choice(file_->choice_display) == 2) { break;
igp.display = InsetGraphicsParams::MONOCHROME; case 4:
} else if (fl_get_choice(file_->choice_display) == 3) { igp.display = InsetGraphicsParams::COLOR;
igp.display = InsetGraphicsParams::GRAYSCALE; break;
} else if (fl_get_choice(file_->choice_display) == 4) { case 5:
igp.display = InsetGraphicsParams::COLOR; igp.display = InsetGraphicsParams::NONE;
} else if (fl_get_choice(file_->choice_display) == 5) { break;
igp.display = InsetGraphicsParams::NONE; }
}
if (fl_get_button(size_->button_default)) if (fl_get_button(size_->button_default))
igp.size_type = InsetGraphicsParams::DEFAULT_SIZE; igp.size_type = InsetGraphicsParams::DEFAULT_SIZE;
else if (fl_get_button(size_->button_wh)) else if (fl_get_button(size_->button_wh))
@ -299,23 +299,23 @@ void FormGraphics::update()
fl_get_button(file_->check_subcaption)); fl_get_button(file_->check_subcaption));
switch (igp.display) { switch (igp.display) {
case InsetGraphicsParams::NONE: { // dont't display case InsetGraphicsParams::DEFAULT:
fl_set_choice(file_->choice_display, 5); fl_set_choice(file_->choice_display, 1);
break; break;
} case InsetGraphicsParams::MONOCHROME:
case InsetGraphicsParams::MONOCHROME: {
fl_set_choice(file_->choice_display, 2); fl_set_choice(file_->choice_display, 2);
break; break;
} case InsetGraphicsParams::GRAYSCALE:
case InsetGraphicsParams::GRAYSCALE: {
fl_set_choice(file_->choice_display, 3); fl_set_choice(file_->choice_display, 3);
break; break;
} case InsetGraphicsParams::COLOR:
case InsetGraphicsParams::COLOR: {
fl_set_choice(file_->choice_display, 4); fl_set_choice(file_->choice_display, 4);
break; break;
} case InsetGraphicsParams::NONE:
} fl_set_choice(file_->choice_display, 5);
break;
}
updateWidgetsFromLength(size_->input_width, updateWidgetsFromLength(size_->input_width,
size_->choice_width_units,igp.width,defaultUnit); size_->choice_width_units,igp.width,defaultUnit);
updateWidgetsFromLength(size_->input_height, updateWidgetsFromLength(size_->input_height,

View 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> 2002-01-31 Herbert Voss <voss@lyx.org>
* insetgraphic.C: (readfigInset) set display to pref-default * insetgraphic.C: (readfigInset) set display to pref-default

View 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 // We do it this way so that in the face of some error, we will still
// be in a valid state. // be in a valid state.
if (!params.filename.empty() && lyxrc.use_gui InsetGraphicsParams::DisplayType local_display = params.display;
&& params.display != InsetGraphicsParams::NONE) { 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); temp = gc.addFile(params.filename);
} }

View File

@ -18,12 +18,11 @@
#include "insetgraphicsParams.h" #include "insetgraphicsParams.h"
#include "lyxrc.h"
#include "support/translator.h" #include "support/translator.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include "support/LOstream.h" #include "support/LOstream.h"
#include "lyxrc.h"
#include "support/LAssert.h" #include "support/LAssert.h"
namespace { namespace {
@ -35,7 +34,7 @@ bool translatorsSet = false;
/// This is the translator between the Display enum and corresponding lyx /// This is the translator between the Display enum and corresponding lyx
/// file strings. /// file strings.
Translator< InsetGraphicsParams::DisplayType, string > Translator< InsetGraphicsParams::DisplayType, string >
displayTranslator(InsetGraphicsParams::MONOCHROME, "monochrome"); displayTranslator(InsetGraphicsParams::DEFAULT, "default");
// this is only compatibility stuff for the first 1.2 version // this is only compatibility stuff for the first 1.2 version
// it is obselete until 1.3 // it is obselete until 1.3
@ -67,6 +66,7 @@ InsetGraphicsParams::InsetGraphicsParams()
if (! translatorsSet) { if (! translatorsSet) {
translatorsSet = true; translatorsSet = true;
// Fill the display translator // Fill the display translator
displayTranslator.addPair(DEFAULT, "default");
displayTranslator.addPair(MONOCHROME, "monochrome"); displayTranslator.addPair(MONOCHROME, "monochrome");
displayTranslator.addPair(GRAYSCALE, "grayscale"); displayTranslator.addPair(GRAYSCALE, "grayscale");
displayTranslator.addPair(COLOR, "color"); displayTranslator.addPair(COLOR, "color");
@ -149,7 +149,8 @@ void InsetGraphicsParams::testInvariant() const
{ {
// Filename might be empty (when the dialog is first created). // Filename might be empty (when the dialog is first created).
// Assert(!filename.empty()); // Assert(!filename.empty());
lyx::Assert(display == COLOR || lyx::Assert(display == DEFAULT ||
display == COLOR ||
display == MONOCHROME || display == MONOCHROME ||
display == GRAYSCALE || display == GRAYSCALE ||
display == NONE display == NONE

View File

@ -29,11 +29,13 @@ struct InsetGraphicsParams
{ {
/// How do we display the image? /// How do we display the image?
enum DisplayType { enum DisplayType {
DEFAULT, // whatever is in lyxrc.display_graphics
COLOR, // full color range COLOR, // full color range
GRAYSCALE, // 256 shades of gray GRAYSCALE, // 256 shades of gray
MONOCHROME, // In black and white. MONOCHROME, // In black and white.
NONE // only keep a frame in place. NONE // only keep a frame in place.
}; };
///
enum sizeType { enum sizeType {
DEFAULT_SIZE, // like none DEFAULT_SIZE, // like none
WH, // width/height values WH, // width/height values