git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@4514 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-07-02 14:12:17 +00:00
parent 1369281252
commit eabfce925a
10 changed files with 116 additions and 30 deletions

View File

@ -131,6 +131,7 @@ void FormGraphics::build()
bc().addReadOnly(lyxview_->radio_gray);
bc().addReadOnly(lyxview_->radio_color);
bc().addReadOnly(lyxview_->radio_nodisplay);
bc().addReadOnly(lyxview_->check_lyxaspectratio);
// the size section
size_.reset(build_size());
@ -251,6 +252,7 @@ void FormGraphics::apply()
lyxview_->choice_lyxheight);
igp.lyxscale = strToInt(getStringFromInput(lyxview_->input_lyxscale));
igp.keepLyXAspectRatio = fl_get_button(lyxview_->check_lyxaspectratio);
// the size section
if (fl_get_button(size_->radio_asis))
@ -360,6 +362,7 @@ void FormGraphics::update() {
setEnabled(lyxview_->choice_lyxwidth, 0);
setEnabled(lyxview_->input_lyxheight, 0);
setEnabled(lyxview_->choice_lyxheight, 0);
setEnabled(lyxview_->check_lyxaspectratio, 0);
setEnabled(lyxview_->input_lyxscale, 0);
break;
}
@ -369,6 +372,7 @@ void FormGraphics::update() {
setEnabled(lyxview_->choice_lyxwidth, 1);
setEnabled(lyxview_->input_lyxheight, 1);
setEnabled(lyxview_->choice_lyxheight, 1);
setEnabled(lyxview_->check_lyxaspectratio, 1);
setEnabled(lyxview_->input_lyxscale, 0);
break;
}
@ -378,11 +382,14 @@ void FormGraphics::update() {
setEnabled(lyxview_->choice_lyxwidth, 0);
setEnabled(lyxview_->input_lyxheight, 0);
setEnabled(lyxview_->choice_lyxheight, 0);
setEnabled(lyxview_->check_lyxaspectratio, 0);
setEnabled(lyxview_->input_lyxscale, 1);
break;
}
}
fl_set_button(lyxview_->check_lyxaspectratio, igp.keepLyXAspectRatio);
// the size section
// Update the draft and clip mode
updateWidgetsFromLength(size_->input_width,
@ -529,18 +536,21 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
setEnabled(lyxview_->choice_lyxwidth, 0);
setEnabled(lyxview_->input_lyxheight, 0);
setEnabled(lyxview_->choice_lyxheight, 0);
setEnabled(lyxview_->check_lyxaspectratio, 0);
setEnabled(lyxview_->input_lyxscale, 0);
} else if (ob == lyxview_->radio_lyxwh) {
setEnabled(lyxview_->input_lyxwidth, 1);
setEnabled(lyxview_->choice_lyxwidth, 1);
setEnabled(lyxview_->input_lyxheight, 1);
setEnabled(lyxview_->choice_lyxheight, 1);
setEnabled(lyxview_->check_lyxaspectratio, 1);
setEnabled(lyxview_->input_lyxscale, 0);
} else if (ob == lyxview_->radio_lyxscale) {
setEnabled(lyxview_->input_lyxwidth, 0);
setEnabled(lyxview_->choice_lyxwidth, 0);
setEnabled(lyxview_->input_lyxheight, 0);
setEnabled(lyxview_->choice_lyxheight, 0);
setEnabled(lyxview_->check_lyxaspectratio, 0);
setEnabled(lyxview_->input_lyxscale, 1);
} else if (ob == lyxview_->button_latex_values) {
if (contains(fl_get_choice_text(size_->choice_width),'%'))
@ -568,6 +578,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
setEnabled(lyxview_->choice_lyxwidth, 0);
setEnabled(lyxview_->input_lyxheight, 0);
setEnabled(lyxview_->choice_lyxheight, 0);
setEnabled(lyxview_->check_lyxaspectratio, 0);
setEnabled(lyxview_->input_lyxscale, 0);
} else if (fl_get_button (size_->radio_wh) == 1) {
fl_set_button (lyxview_->radio_lyxwh, 1);
@ -575,6 +586,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
setEnabled(lyxview_->choice_lyxwidth, 1);
setEnabled(lyxview_->input_lyxheight, 1);
setEnabled(lyxview_->choice_lyxheight, 1);
setEnabled(lyxview_->check_lyxaspectratio, 1);
setEnabled(lyxview_->input_lyxscale, 0);
} else if (fl_get_button (size_->radio_scale) ==1) {
fl_set_button (lyxview_->radio_lyxscale, 1);
@ -582,9 +594,12 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
setEnabled(lyxview_->choice_lyxwidth, 0);
setEnabled(lyxview_->input_lyxheight, 0);
setEnabled(lyxview_->choice_lyxheight, 0);
setEnabled(lyxview_->check_lyxaspectratio, 0);
setEnabled(lyxview_->input_lyxscale, 1);
}
}
fl_set_button(lyxview_->check_lyxaspectratio,
fl_get_button(size_->check_aspectratio));
// the bb section
} else if (!controller().bbChanged &&
@ -673,6 +688,8 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
setEnabled(size_->check_aspectratio, 0);
setEnabled(size_->input_scale, 1);
}
fl_set_button(size_->check_aspectratio,
fl_get_button(lyxview_->check_lyxaspectratio));
}
// check if the input is valid

View File

@ -405,7 +405,7 @@ FD_form_lyxview * FormGraphics::build_lyxview()
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
{
char const * const dummy = N_("Value|#V");
fdui->input_lyxscale = obj = fl_add_input(FL_NORMAL_INPUT, 350, 95, 70, 30, idex(_(dummy)));
fdui->input_lyxscale = obj = fl_add_input(FL_NORMAL_INPUT, 350, 75, 70, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
@ -413,35 +413,35 @@ FD_form_lyxview * FormGraphics::build_lyxview()
fl_bgn_group();
{
char const * const dummy = N_("Original size|#O");
fdui->radio_lyxasis = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 255, 25, 30, 30, idex(_(dummy)));
fdui->radio_lyxasis = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 170, 25, 30, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_color(obj, FL_COL1, FL_YELLOW);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lalign(obj, FL_ALIGN_LEFT);
fl_set_object_lalign(obj, FL_ALIGN_RIGHT);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Scale|#S");
fdui->radio_lyxscale = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 255, 90, 30, 30, idex(_(dummy)));
fdui->radio_lyxscale = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 170, 75, 30, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_color(obj, FL_COL1, FL_YELLOW);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lalign(obj, FL_ALIGN_LEFT);
fl_set_object_lalign(obj, FL_ALIGN_RIGHT);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Custom|#u");
fdui->radio_lyxwh = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 255, 155, 30, 30, idex(_(dummy)));
fdui->radio_lyxwh = obj = fl_add_round3dbutton(FL_RADIO_BUTTON, 170, 140, 30, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_color(obj, FL_COL1, FL_YELLOW);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lalign(obj, FL_ALIGN_LEFT);
fl_set_object_lalign(obj, FL_ALIGN_RIGHT);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_group();
// xgettext:no-c-format
obj = fl_add_text(FL_NORMAL_TEXT, 420, 95, 25, 30, _("%"));
obj = fl_add_text(FL_NORMAL_TEXT, 420, 75, 25, 30, _("%"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
fl_bgn_group();
@ -489,23 +489,23 @@ FD_form_lyxview * FormGraphics::build_lyxview()
{
char const * const dummy = N_("Width|#W");
fdui->input_lyxwidth = obj = fl_add_input(FL_NORMAL_INPUT, 350, 155, 70, 30, idex(_(dummy)));
fdui->input_lyxwidth = obj = fl_add_input(FL_NORMAL_INPUT, 350, 135, 70, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fdui->choice_lyxwidth = obj = fl_add_choice(FL_NORMAL_CHOICE, 425, 155, 50, 30, "");
fdui->choice_lyxwidth = obj = fl_add_choice(FL_NORMAL_CHOICE, 425, 135, 50, 30, "");
fl_set_object_boxtype(obj, FL_FRAME_BOX);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Height|#H");
fdui->input_lyxheight = obj = fl_add_input(FL_NORMAL_INPUT, 350, 190, 70, 30, idex(_(dummy)));
fdui->input_lyxheight = obj = fl_add_input(FL_NORMAL_INPUT, 350, 170, 70, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fdui->choice_lyxheight = obj = fl_add_choice(FL_NORMAL_CHOICE, 425, 190, 50, 30, "");
fdui->choice_lyxheight = obj = fl_add_choice(FL_NORMAL_CHOICE, 425, 170, 50, 30, "");
fl_set_object_boxtype(obj, FL_FRAME_BOX);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
@ -516,6 +516,14 @@ FD_form_lyxview * FormGraphics::build_lyxview()
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("keep Aspect ratio|#A");
fdui->check_lyxaspectratio = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 210, 200, 30, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lalign(obj, FL_ALIGN_RIGHT);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_form();
fdui->form->fdui = fdui;

View File

@ -99,6 +99,7 @@ struct FD_form_lyxview {
FL_OBJECT *input_lyxheight;
FL_OBJECT *choice_lyxheight;
FL_OBJECT *button_latex_values;
FL_OBJECT *check_lyxaspectratio;
};
#endif /* FD_form_graphics_h_ */

View File

@ -442,7 +442,7 @@ argument:
--------------------
class: FL_BEGIN_GROUP
type: 0
box: 0 0 0 0
box: 0 10 10 0
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
@ -453,7 +453,7 @@ label:
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
name:
callback:
argument:
@ -923,7 +923,7 @@ argument: 0
Name: form_lyxview
Width: 500
Height: 245
Number of Objects: 23
Number of Objects: 24
--------------------
class: FL_BOX
@ -1000,7 +1000,7 @@ argument:
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 350 95 70 30
box: 350 75 70 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
@ -1018,7 +1018,7 @@ argument: 0
--------------------
class: FL_BEGIN_GROUP
type: 0
box: 0 0 0 0
box: 0 10 10 0
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
@ -1036,10 +1036,10 @@ argument:
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
box: 255 25 30 30
box: 170 25 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_LEFT
alignment: FL_ALIGN_RIGHT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
@ -1054,10 +1054,10 @@ argument: 0
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
box: 255 90 30 30
box: 170 75 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_LEFT
alignment: FL_ALIGN_RIGHT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
@ -1072,10 +1072,10 @@ argument: 0
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
box: 255 155 30 30
box: 170 140 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_LEFT
alignment: FL_ALIGN_RIGHT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
@ -1108,7 +1108,7 @@ argument:
--------------------
class: FL_TEXT
type: NORMAL_TEXT
box: 420 95 25 30
box: 420 75 25 30
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
@ -1126,7 +1126,7 @@ argument:
--------------------
class: FL_BEGIN_GROUP
type: 0
box: 0 0 0 0
box: 0 10 10 0
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
@ -1137,7 +1137,7 @@ label:
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
name:
callback:
argument:
@ -1252,7 +1252,7 @@ argument:
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 350 155 70 30
box: 350 135 70 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
@ -1270,7 +1270,7 @@ argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 425 155 50 30
box: 425 135 50 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
@ -1288,7 +1288,7 @@ argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 350 190 70 30
box: 350 170 70 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
@ -1306,7 +1306,7 @@ argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 425 190 50 30
box: 425 170 50 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
@ -1339,5 +1339,23 @@ name: button_latex_values
callback: C_FormBaseInputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 210 200 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_RIGHT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: keep Aspect ratio|#A
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_lyxaspectratio
callback: C_FormBaseInputCB
argument: 0
==============================
--------------------

View File

@ -1,3 +1,8 @@
2002-05-01 Herbert Voss <voss@lyx.org>
* GraphicsParams.C (GParams c-tor): use the new keepLyXAspectRatio
parameter.
2002-07-01 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* GraphicsConverter.C (convert): do not use ChangeExtension

View File

@ -13,6 +13,7 @@
#endif
#include "GraphicsParams.h"
#include "GraphicsCache.h"
#include "insets/insetgraphicsParams.h"
#include "lyxrc.h"
#include "debug.h"
@ -112,6 +113,27 @@ GParams::GParams(InsetGraphicsParams const & iparams, string const & filepath)
double const scaling_factor = 100.0 / double(lyxrc.zoom);
width = uint(scaling_factor * width);
height = uint(scaling_factor * height);
if (iparams.keepLyXAspectRatio) {
// get the imagesize from the cache
grfx::GCache & gc = grfx::GCache::get();
float const rw = gc.raw_width(filename);
float const rh = gc.raw_height(filename);
float const ratio = (rw > 0.001) ? rh/rw : 1.0;
lyxerr[Debug::GRAPHICS]
<< "Value of LyXAspectRatio: "
<< ratio << std::endl;
if (!iparams.lyxwidth.zero() &&
!iparams.lyxheight.zero()) {
if (width < height)
height = int(ratio * width);
else
width = int(ratio * height);
} else if (iparams.lyxwidth.zero())
width = int(ratio * height);
else if (iparams.lyxheight.zero())
height = int(ratio * width);
}
}
}

View File

@ -1,3 +1,7 @@
2002-05-01 Herbert Voss <voss@lyx.org>
* insetgraphicsParams.[Ch]: define a new keepLyXAspectRatio parameter.
2002-07-01 Claus Hentschel <claus.hentschel@mbau.fh-hannover.de>
* insetgraphics.C (latex): make sure file name is in os native

View File

@ -93,6 +93,7 @@ void InsetGraphicsParams::init()
lyxscale = 0; // same for lyxview
size_type = DEFAULT_SIZE; // do nothing
lyxsize_type = DEFAULT_SIZE; // do nothing
keepLyXAspectRatio = false; // only for LyXview
keepAspectRatio = false; // only for latex
rotate = false; // Rotating
rotateOrigin = "center"; // Origin
@ -118,6 +119,7 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
lyxsize_type = igp.lyxsize_type;
lyxwidth = igp.lyxwidth;
lyxheight = igp.lyxheight;
keepLyXAspectRatio = igp.keepLyXAspectRatio;
lyxscale = igp.lyxscale;
rotate = igp.rotate;
rotateOrigin = igp.rotateOrigin;
@ -144,6 +146,7 @@ bool operator==(InsetGraphicsParams const & left,
left.lyxsize_type == right.lyxsize_type &&
left.lyxwidth == right.lyxwidth &&
left.lyxheight == right.lyxheight &&
left.keepLyXAspectRatio == right.keepLyXAspectRatio &&
left.lyxscale == right.lyxscale &&
left.rotate == right.rotate &&
left.rotateOrigin == right.rotateOrigin &&
@ -210,6 +213,8 @@ void InsetGraphicsParams::Write(ostream & os) const
os << "\tlyxwidth " << lyxwidth.asString() << '\n';
if (!lyxheight.zero())
os << "\tlyxheight " << lyxheight.asString();
if (keepLyXAspectRatio)
os << "\tkeepLyXAspectRatio\n";
if (lyxscale != 0)
os << "\tlyxscale " << lyxscale << '\n';
}
@ -291,6 +296,8 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const& token)
} else if (token == "lyxheight") {
lex.next();
lyxheight = LyXLength(lex.getString());
} else if (token == "keepLyXAspectRatio") {
keepLyXAspectRatio = true;
} else if (token == "lyxscale") {
lex.next();
lyxscale = lex.getInteger();

View File

@ -79,6 +79,8 @@ struct InsetGraphicsParams
LyXLength lyxwidth;
///
LyXLength lyxheight;
/// Keep the ratio between lyxheight and lyxwidth when resizing.
bool keepLyXAspectRatio;
/// Typ of rescaling the Screen inside lyx
int lyxscale;
///

View File

@ -20,6 +20,8 @@ What's new
** Updates
- new option 'keep aspect ratio' in graphics dialog
- update finnish, danish, french and russian localizations
- update Tutorial to be more up to date