mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Graphics dialog fixes following Michael's suggestions.
Probably doesn't fix memory access problem. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2756 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
233aebda9a
commit
0fa2f8db17
@ -22,6 +22,7 @@
|
||||
#include "FormGraphics.h"
|
||||
#include "form_graphics.h"
|
||||
|
||||
#include "xforms_helpers.h"
|
||||
#include "input_validators.h"
|
||||
#include "debug.h" // for lyxerr
|
||||
#include "support/lstrings.h" // for strToDbl & tostr
|
||||
@ -56,6 +57,7 @@ void FormGraphics::build()
|
||||
fl_set_input_return (dialog_->input_subcaption, FL_RETURN_CHANGED);
|
||||
|
||||
// Set the maximum characters that can be written in the input texts.
|
||||
fl_set_input_maxchars(dialog_->input_scale, SCALE_MAXDIGITS);
|
||||
fl_set_input_maxchars(dialog_->input_width, WIDTH_MAXDIGITS);
|
||||
fl_set_input_maxchars(dialog_->input_height, HEIGHT_MAXDIGITS);
|
||||
fl_set_input_maxchars(dialog_->input_filename, FILENAME_MAXCHARS);
|
||||
@ -111,10 +113,11 @@ void FormGraphics::apply()
|
||||
igp.display = InsetGraphicsParams::NONE;
|
||||
}
|
||||
|
||||
double const scale = strToDbl(fl_get_input(dialog_->input_scale));
|
||||
double const scale =
|
||||
strToDbl(strip(fl_get_input(dialog_->input_scale)));
|
||||
if (scale < tol) {
|
||||
double const width =
|
||||
strToDbl(fl_get_input(dialog_->input_width));
|
||||
strToDbl(strip(fl_get_input(dialog_->input_width)));
|
||||
|
||||
if (width < tol) {
|
||||
igp.widthResize = InsetGraphicsParams::DEFAULT_SIZE;
|
||||
@ -140,7 +143,7 @@ void FormGraphics::apply()
|
||||
}
|
||||
|
||||
double const height =
|
||||
strToDbl(fl_get_input(dialog_->input_height));
|
||||
strToDbl(strip(fl_get_input(dialog_->input_height)));
|
||||
|
||||
if (height < tol) {
|
||||
igp.heightResize = InsetGraphicsParams::DEFAULT_SIZE;
|
||||
@ -168,7 +171,8 @@ void FormGraphics::apply()
|
||||
igp.heightSize = scale;
|
||||
}
|
||||
|
||||
igp.rotateAngle = strToDbl(fl_get_input(dialog_->input_rotate_angle));
|
||||
igp.rotateAngle =
|
||||
strToDbl(strip(fl_get_input(dialog_->input_rotate_angle)));
|
||||
while (igp.rotateAngle < 0.0 || igp.rotateAngle > 360.0) {
|
||||
if (igp.rotateAngle < 0.0) {
|
||||
igp.rotateAngle += 360.0;
|
||||
@ -263,8 +267,8 @@ void FormGraphics::update()
|
||||
fl_set_input(dialog_->input_subcaption,
|
||||
igp.subcaptionText.c_str());
|
||||
|
||||
// Now make sure that the buttons are set correctly.
|
||||
input(0, 0);
|
||||
setEnabled(dialog_->input_subcaption,
|
||||
fl_get_button(dialog_->check_subcaption));
|
||||
}
|
||||
|
||||
|
||||
@ -282,7 +286,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
|
||||
|
||||
if (ob == dialog_->input_scale) {
|
||||
double const scale =
|
||||
strToDbl(fl_get_input(dialog_->input_scale));
|
||||
strToDbl(strip(fl_get_input(dialog_->input_scale)));
|
||||
if (scale > tol) {
|
||||
fl_set_input(dialog_->input_width, "");
|
||||
fl_set_choice(dialog_->choice_width_units, 1);
|
||||
@ -293,15 +297,20 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
|
||||
|
||||
if (ob == dialog_->input_width || ob == dialog_->input_height) {
|
||||
double const width =
|
||||
strToDbl(fl_get_input(dialog_->input_width));
|
||||
strToDbl(strip(fl_get_input(dialog_->input_width)));
|
||||
double const height =
|
||||
strToDbl(fl_get_input(dialog_->input_height));
|
||||
strToDbl(strip(fl_get_input(dialog_->input_height)));
|
||||
|
||||
if (width > tol || height > tol) {
|
||||
fl_set_input(dialog_->input_scale, "");
|
||||
}
|
||||
}
|
||||
|
||||
if (ob == dialog_->check_subcaption) {
|
||||
setEnabled(dialog_->input_subcaption,
|
||||
fl_get_button(dialog_->check_subcaption));
|
||||
}
|
||||
|
||||
return checkInput();
|
||||
}
|
||||
|
||||
|
@ -42,35 +42,16 @@ private:
|
||||
/// Filter the inputs on callback from xforms
|
||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||
|
||||
/// The maximum digits for the image width (cm, inch, percent)
|
||||
enum {
|
||||
///
|
||||
WIDTH_MAXDIGITS = 3
|
||||
};
|
||||
/// The maximum digits for the image height (cm, inch, percent)
|
||||
enum {
|
||||
///
|
||||
HEIGHT_MAXDIGITS = 3
|
||||
};
|
||||
/// The maximum characters in the rotation angle (minus sign and 3 digits)
|
||||
enum {
|
||||
///
|
||||
ROTATE_MAXCHARS = 4
|
||||
};
|
||||
/// The maximum digits for the image scale
|
||||
static const int SCALE_MAXDIGITS = 3;
|
||||
/// The maximum digits for the image width
|
||||
static const int WIDTH_MAXDIGITS = 3;
|
||||
/// The maximum digits for the image height
|
||||
static const int HEIGHT_MAXDIGITS = 3;
|
||||
/// The max characters in the rotation angle (minus sign and 3 digits)
|
||||
static const int ROTATE_MAXCHARS = 4;
|
||||
/// The maximum characters in a filename.
|
||||
enum {
|
||||
///
|
||||
FILENAME_MAXCHARS = 1024
|
||||
};
|
||||
///
|
||||
enum State {
|
||||
///
|
||||
CHECKINPUT,
|
||||
///
|
||||
BROWSE,
|
||||
///
|
||||
ADVANCEDINPUT
|
||||
};
|
||||
static const int FILENAME_MAXCHARS = 1024;
|
||||
|
||||
/// Verify that the input is correct. If not disable ok/apply buttons.
|
||||
ButtonPolicy::SMInput checkInput();
|
||||
|
@ -32,13 +32,13 @@ FD_form_graphics * FormGraphics::build_graphics()
|
||||
fdui->input_filename = obj = fl_add_input(FL_NORMAL_INPUT, 90, 20, 280, 30, idex(_(dummy)));
|
||||
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
|
||||
}
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||
{
|
||||
char const * const dummy = N_("Browse|#B");
|
||||
fdui->button_browse = obj = fl_add_button(FL_NORMAL_BUTTON, 380, 20, 90, 30, idex(_(dummy)));
|
||||
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
|
||||
}
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, BROWSE);
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 70, 240, 140, _("Size"));
|
||||
{
|
||||
char const * const dummy = N_("Width|#W");
|
||||
@ -47,8 +47,7 @@ FD_form_graphics * FormGraphics::build_graphics()
|
||||
}
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||
fdui->choice_width_units = obj = fl_add_choice(FL_NORMAL_CHOICE, 180, 80, 65, 30, "");
|
||||
fl_set_object_boxtype(obj, FL_BORDER_BOX);
|
||||
fdui->choice_width_units = obj = fl_add_choice(FL_NORMAL_CHOICE2, 180, 80, 65, 30, "");
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||
{
|
||||
char const * const dummy = N_("Height|#H");
|
||||
@ -57,8 +56,7 @@ FD_form_graphics * FormGraphics::build_graphics()
|
||||
}
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||
fdui->choice_height_units = obj = fl_add_choice(FL_NORMAL_CHOICE, 180, 120, 65, 30, "");
|
||||
fl_set_object_boxtype(obj, FL_BORDER_BOX);
|
||||
fdui->choice_height_units = obj = fl_add_choice(FL_NORMAL_CHOICE2, 180, 120, 65, 30, "");
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||
{
|
||||
char const * const dummy = N_("Scale|#S");
|
||||
@ -94,13 +92,13 @@ FD_form_graphics * FormGraphics::build_graphics()
|
||||
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
|
||||
}
|
||||
fl_set_object_lalign(obj, FL_ALIGN_LEFT);
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||
{
|
||||
char const * const dummy = N_("Title|#T");
|
||||
fdui->input_subcaption = obj = fl_add_input(FL_NORMAL_INPUT, 110, 280, 350, 30, idex(_(dummy)));
|
||||
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
|
||||
}
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
|
||||
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
|
||||
{
|
||||
char const * const dummy = N_("Restore|#R");
|
||||
fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 20, 350, 90, 30, idex(_(dummy)));
|
||||
|
@ -46,7 +46,7 @@ resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: input_filename
|
||||
callback: C_FormBaseInputCB
|
||||
argument: CHECKINPUT
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
@ -64,7 +64,7 @@ resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: button_browse
|
||||
callback: C_FormBaseInputCB
|
||||
argument: BROWSE
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
class: FL_LABELFRAME
|
||||
@ -104,9 +104,9 @@ argument: 0
|
||||
|
||||
--------------------
|
||||
class: FL_CHOICE
|
||||
type: NORMAL_CHOICE
|
||||
type: NORMAL_CHOICE2
|
||||
box: 180 80 65 30
|
||||
boxtype: FL_BORDER_BOX
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_BLACK
|
||||
alignment: FL_ALIGN_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
@ -140,9 +140,9 @@ argument: 0
|
||||
|
||||
--------------------
|
||||
class: FL_CHOICE
|
||||
type: NORMAL_CHOICE
|
||||
type: NORMAL_CHOICE2
|
||||
box: 180 120 65 30
|
||||
boxtype: FL_BORDER_BOX
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_BLACK
|
||||
alignment: FL_ALIGN_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
@ -316,7 +316,7 @@ resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: check_subcaption
|
||||
callback: C_FormBaseInputCB
|
||||
argument: CHECKINPUT
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
class: FL_INPUT
|
||||
@ -334,7 +334,7 @@ resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: input_subcaption
|
||||
callback: C_FormBaseInputCB
|
||||
argument: CHECKINPUT
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
|
Loading…
Reference in New Issue
Block a user