#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
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);
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;
}
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;
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;
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));
}
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);
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();
}
/// 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();
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");
}
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");
}
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");
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)));
gravity: FL_NoGravity FL_NoGravity
name: input_filename
callback: C_FormBaseInputCB
-argument: CHECKINPUT
+argument: 0
--------------------
class: FL_BUTTON
gravity: FL_NoGravity FL_NoGravity
name: button_browse
callback: C_FormBaseInputCB
-argument: BROWSE
+argument: 0
--------------------
class: FL_LABELFRAME
--------------------
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
--------------------
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
gravity: FL_NoGravity FL_NoGravity
name: check_subcaption
callback: C_FormBaseInputCB
-argument: CHECKINPUT
+argument: 0
--------------------
class: FL_INPUT
gravity: FL_NoGravity FL_NoGravity
name: input_subcaption
callback: C_FormBaseInputCB
-argument: CHECKINPUT
+argument: 0
--------------------
class: FL_BUTTON