From 6a3d139c9eb091ba3adb417ed6dd3a43fce9695d Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Tue, 11 Sep 2001 17:27:28 +0000 Subject: [PATCH] Fix for float dialog bug git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2728 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/ChangeLog | 4 ++ src/frontends/xforms/FormFloat.C | 31 +++++++--- src/frontends/xforms/FormFloat.h | 2 + src/frontends/xforms/form_float.C | 28 ++++----- src/frontends/xforms/form_float.h | 4 +- src/frontends/xforms/forms/form_float.fd | 72 ++++++++++++------------ 6 files changed, 80 insertions(+), 61 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 146c2684f2..41fae88b09 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -4,6 +4,10 @@ Author-Year/Numerical citation choice only if the natbib checkbox is active. + * FormFloat.[Ch]: added new method input() to control the behaviour of + the buttons better. + * forms/form_float.fd: renamed Here as button_here_definitely. + * FormGraphics.C: * forms/form_graphics.fd: add callbacks to a few widgets that didn't have them, so enabling the Ok, Apply buttons appropriately. diff --git a/src/frontends/xforms/FormFloat.C b/src/frontends/xforms/FormFloat.C index f8446144db..588932d162 100644 --- a/src/frontends/xforms/FormFloat.C +++ b/src/frontends/xforms/FormFloat.C @@ -32,9 +32,6 @@ FormFloat::FormFloat(ControlFloat & c) // FIX: Needs to be implemented. (Lgb) // A way to set to float default is missing. // A way to set "force[!]" is missing. -// Also there are two groups of buttons [Here] and [top,bottom,page,here], -// is is not really possible to choose from both groups. So this should -// be disallowed by the dialog too. void FormFloat::build() { @@ -50,14 +47,14 @@ void FormFloat::build() bc().addReadOnly(dialog_->radio_bottom); bc().addReadOnly(dialog_->radio_page); bc().addReadOnly(dialog_->radio_here); - bc().addReadOnly(dialog_->Here); + bc().addReadOnly(dialog_->button_here_definitely); } void FormFloat::apply() { string placement; - if (fl_get_button(dialog_->Here)) { + if (fl_get_button(dialog_->button_here_definitely)) { placement += "H"; } else { if (fl_get_button(dialog_->radio_top)) { @@ -83,12 +80,13 @@ void FormFloat::update() bool bottom = false; bool page = false; bool here = false; - bool Here = false; + bool here_definitely = false; string placement(controller().params().placement); + std::cerr << "FormFloat::update() " << placement << std::endl; if (contains(placement, "H")) { - Here = true; + here_definitely = true; } else { if (contains(placement, "t")) { top = true; @@ -107,7 +105,22 @@ void FormFloat::update() fl_set_button(dialog_->radio_bottom, bottom); fl_set_button(dialog_->radio_page, page); fl_set_button(dialog_->radio_here, here); - fl_set_button(dialog_->Here, Here); - + fl_set_button(dialog_->button_here_definitely, here_definitely); } + +ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long) +{ + if (ob == dialog_->button_here_definitely) { + if (fl_get_button(dialog_->button_here_definitely)) { + fl_set_button(dialog_->radio_top, false); + fl_set_button(dialog_->radio_bottom, false); + fl_set_button(dialog_->radio_page, false); + fl_set_button(dialog_->radio_here, false); + } + } else { + if (fl_get_button(dialog_->button_here_definitely)) { + fl_set_button(dialog_->button_here_definitely, false); + } + } +} diff --git a/src/frontends/xforms/FormFloat.h b/src/frontends/xforms/FormFloat.h index 2263ebb529..e07b4e2eae 100644 --- a/src/frontends/xforms/FormFloat.h +++ b/src/frontends/xforms/FormFloat.h @@ -38,6 +38,8 @@ private: virtual void build(); /// Update dialog before/whilst showing it. virtual void update(); + /// Filter the inputs on callback from xforms + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /// Fdesign generated method FD_form_float * build_float(); diff --git a/src/frontends/xforms/form_float.C b/src/frontends/xforms/form_float.C index 3fd8c3117c..342dbca0d5 100644 --- a/src/frontends/xforms/form_float.C +++ b/src/frontends/xforms/form_float.C @@ -50,6 +50,20 @@ FD_form_float * FormFloat::build_float() } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseInputCB, 0); + { + char const * const dummy = N_("Here, if possible|#i"); + fdui->radio_here = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 190, 60, 152, 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); + { + char const * const dummy = N_("Here, definitely|#H"); + fdui->button_here_definitely = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 110, 152, 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); { char const * const dummy = N_("Cancel|^["); fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 280, 160, 70, 30, idex(_(dummy))); @@ -74,20 +88,6 @@ FD_form_float * FormFloat::build_float() } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormBaseRestoreCB, 0); - { - char const * const dummy = N_("Here, if possible|#i"); - fdui->radio_here = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 190, 60, 152, 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); - { - char const * const dummy = N_("Here, definitely|#H"); - fdui->Here = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 110, 152, 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); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_float.h b/src/frontends/xforms/form_float.h index 5033b13fbc..97820f09f7 100644 --- a/src/frontends/xforms/form_float.h +++ b/src/frontends/xforms/form_float.h @@ -20,12 +20,12 @@ struct FD_form_float { FL_OBJECT *radio_top; FL_OBJECT *radio_bottom; FL_OBJECT *radio_page; + FL_OBJECT *radio_here; + FL_OBJECT *button_here_definitely; FL_OBJECT *button_cancel; FL_OBJECT *button_apply; FL_OBJECT *button_ok; FL_OBJECT *button_restore; - FL_OBJECT *radio_here; - FL_OBJECT *Here; }; #endif /* FD_form_float_h_ */ diff --git a/src/frontends/xforms/forms/form_float.fd b/src/frontends/xforms/forms/form_float.fd index 88aa4b1610..41db410917 100644 --- a/src/frontends/xforms/forms/form_float.fd +++ b/src/frontends/xforms/forms/form_float.fd @@ -120,6 +120,42 @@ name: radio_page callback: C_FormBaseInputCB argument: 0 +-------------------- +class: FL_CHECKBUTTON +type: PUSH_BUTTON +box: 190 60 152 30 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Here, if possible|#i +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: radio_here +callback: C_FormBaseInputCB +argument: 0 + +-------------------- +class: FL_CHECKBUTTON +type: PUSH_BUTTON +box: 20 110 152 30 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Here, definitely|#H +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: button_here_definitely +callback: C_FormBaseInputCB +argument: 0 + -------------------- class: FL_BUTTON type: NORMAL_BUTTON @@ -192,41 +228,5 @@ name: button_restore callback: C_FormBaseRestoreCB argument: 0 --------------------- -class: FL_CHECKBUTTON -type: PUSH_BUTTON -box: 190 60 152 30 -boxtype: FL_NO_BOX -colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Here, if possible|#i -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: radio_here -callback: C_FormBaseInputCB -argument: 0 - --------------------- -class: FL_CHECKBUTTON -type: PUSH_BUTTON -box: 20 110 152 30 -boxtype: FL_NO_BOX -colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Here, definitely|#H -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: Here -callback: C_FormBaseInputCB -argument: 0 - ============================== create_the_forms -- 2.39.2