From: Angus Leeming Date: Wed, 23 Oct 2002 16:24:44 +0000 (+0000) Subject: (Rob Lahaye): improvements to the xforms float dialog. X-Git-Tag: 1.6.10~18114 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=74b7bcc2f3d86d31f81b41e1a8e4c0584f05b1ab;p=features.git (Rob Lahaye): improvements to the xforms float dialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5481 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 42d19f12ea..70965568e2 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2002-10-23 Rob Lahaye + + * forms/form_float.fd: prettify and implement gravity/resize policy + correctly. + + * FormFloat.C: add tooltips, lots of comments and check the + input more carefully. + 2002-10-23 Angus Leeming * checkedwidgets.C (setWidget): Don't set icol2 to alert_col when diff --git a/src/frontends/xforms/FormFloat.C b/src/frontends/xforms/FormFloat.C index ebd130a68a..8d60284976 100644 --- a/src/frontends/xforms/FormFloat.C +++ b/src/frontends/xforms/FormFloat.C @@ -4,7 +4,8 @@ * Licence details can be found in the file COPYING. * * \author Lars Gullik Bjønnes - * \author Juergen Spitzmueller j.spitzmueller@gmx.de + * \author Jürgen Spitzmüller + * \author Rob Lahaye * * Full author contact details are available in file CREDITS */ @@ -19,10 +20,22 @@ #include "ControlFloat.h" #include "FormFloat.h" #include "forms/form_float.h" -#include "support/lstrings.h" +#include "Tooltips.h" #include "xforms_helpers.h" +#include "support/lstrings.h" #include FORMS_H_LOCATION +namespace { + +enum { + DOCUMENT_DEFAULTS, + HERE_DEFINITELY, + ALTERNATIVES +}; + +} // namespace anon + + typedef FormCB > base_class; FormFloat::FormFloat() @@ -40,164 +53,178 @@ void FormFloat::build() bc().setCancel(dialog_->button_close); bc().setRestore(dialog_->button_restore); - bc().addReadOnly(dialog_->check_default); + // disable for read-only documents + bc().addReadOnly(dialog_->radio_default); + bc().addReadOnly(dialog_->radio_here_definitely); + bc().addReadOnly(dialog_->radio_alternatives); bc().addReadOnly(dialog_->check_top); bc().addReadOnly(dialog_->check_bottom); bc().addReadOnly(dialog_->check_page); bc().addReadOnly(dialog_->check_here); bc().addReadOnly(dialog_->check_force); - bc().addReadOnly(dialog_->check_here_definitely); bc().addReadOnly(dialog_->check_wide); + + placement_.init(dialog_->radio_default, DOCUMENT_DEFAULTS); + placement_.init(dialog_->radio_here_definitely, HERE_DEFINITELY); + placement_.init(dialog_->radio_alternatives, ALTERNATIVES); + + // set up the tooltips + string str = _("Use the document's default settings."); + tooltips().init(dialog_->radio_default, str); + str = _("Enforce placement of float here."); + tooltips().init(dialog_->radio_here_definitely, str); + str = _("Alternative suggestions for placement of float."); + tooltips().init(dialog_->radio_alternatives, str); + str = _("Try top of page."); + tooltips().init(dialog_->check_top, str); + str = _("Try bottom of page."); + tooltips().init(dialog_->check_bottom, str); + str = _("Put float on a separate page of floats."); + tooltips().init(dialog_->check_page, str); + str = _("Try float here."); + tooltips().init(dialog_->check_here, str); + str = _("Ignore internal settings. This is the \"!\" in LaTeX."); + tooltips().init(dialog_->check_force, str); + str = _("Span float over the columns."); + tooltips().init(dialog_->check_wide, str); } void FormFloat::apply() { + bool const wide = fl_get_button(dialog_->check_wide); + string placement; - if (fl_get_button(dialog_->check_here_definitely)) { - placement += "H"; - } else { + switch (placement_.get()) { + case ALTERNATIVES: if (fl_get_button(dialog_->check_force)) { + // Ignore internal LaTeX rules placement += "!"; } - if (fl_get_button(dialog_->check_here)) { - placement += "h"; - } if (fl_get_button(dialog_->check_top)) { + // Top of page placement += "t"; } if (fl_get_button(dialog_->check_bottom)) { + // Bottom of page placement += "b"; } if (fl_get_button(dialog_->check_page)) { + // Page of floats placement += "p"; } + // ignore if wide is selected + if (!wide && fl_get_button(dialog_->check_here)) { + // Here, if possible + placement += "h"; + } + if (placement == "!") { + // ignore placement if only force is selected. + placement.erase(); + } + if (placement.length() == 0) { + // none of Alternatives is selected; flip to default + placement.erase(); + placement_.set(dialog_->radio_default); + setEnabled(dialog_->check_force, false); + setEnabled(dialog_->check_top, false); + setEnabled(dialog_->check_bottom, false); + setEnabled(dialog_->check_page, false); + setEnabled(dialog_->check_here, false); + } + break; + + case HERE_DEFINITELY: + placement = "H"; + break; + + case DOCUMENT_DEFAULTS: + // default, do nothing. + break; } + controller().params().placement = placement; - controller().params().wide = fl_get_button(dialog_->check_wide); + controller().params().wide = wide; } void FormFloat::update() { - bool def_placement = false; - bool top = false; - bool bottom = false; - bool page = false; - bool here = false; - bool force = false; - bool here_definitely = false; - string placement(controller().params().placement); + bool const wide = controller().params().wide; - if (placement.empty()) { - def_placement = true; + bool const here_definitely = contains(placement, "H"); - } else if (contains(placement, "H")) { - here_definitely = true; + bool const top = contains(placement, "t"); + bool const bottom = contains(placement, "b"); + bool const page = contains(placement, "p"); + bool const here = contains(placement, "h"); + bool const force = contains(placement, "!"); + bool const alternatives = top || bottom || page || (here && !wide); + if (alternatives) { + placement_.set(dialog_->radio_alternatives); + } else if (here_definitely) { + placement_.set(dialog_->radio_here_definitely); } else { - if (contains(placement, "!")) { - force = true; - } - if (contains(placement, "t")) { - top = true; - } - if (contains(placement, "b")) { - bottom = true; - } - if (contains(placement, "p")) { - page = true; - } - if (contains(placement, "h")) { - here = true; - } + placement_.set(dialog_->radio_default); } - fl_set_button(dialog_->check_default, def_placement); + fl_set_button(dialog_->check_force, force); fl_set_button(dialog_->check_top, top); fl_set_button(dialog_->check_bottom, bottom); fl_set_button(dialog_->check_page, page); fl_set_button(dialog_->check_here, here); - fl_set_button(dialog_->check_force, force); - fl_set_button(dialog_->check_here_definitely, here_definitely); - setEnabled(dialog_->check_here_definitely, !controller().params().wide - && !def_placement); - if (controller().params().wide) { - fl_set_button(dialog_->check_here, false); - fl_set_button(dialog_->check_bottom, false); - } - setEnabled(dialog_->check_here, !controller().params().wide && !def_placement); - setEnabled(dialog_->check_bottom, !controller().params().wide && !def_placement); - fl_set_button(dialog_->check_wide, controller().params().wide); - setEnabled(dialog_->check_top, !def_placement); - setEnabled(dialog_->check_page, !def_placement); - setEnabled(dialog_->check_force, top || bottom || page || here); + fl_set_button(dialog_->check_wide, wide); + + setEnabled(dialog_->radio_here_definitely, !wide); + setEnabled(dialog_->check_force, alternatives); + setEnabled(dialog_->check_top, alternatives); + setEnabled(dialog_->check_bottom, alternatives); + setEnabled(dialog_->check_page, alternatives); + setEnabled(dialog_->check_here, alternatives && !wide); } ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long) { - bool const def_place = fl_get_button(dialog_->check_default); - bool const wide_float = fl_get_button(dialog_->check_wide); - // with wide floats, h[ere] is not allowed - // b[ottom] is allowed (only) for figure* in multicolumn, don't - // disallow it therefore - bool const wide_options = (fl_get_button(dialog_->check_top) - || fl_get_button(dialog_->check_bottom) - || fl_get_button(dialog_->check_page)); - // The !-option is only allowed together with h, t, b, or p - // We have to take this into account - bool const standard_options = (wide_options || fl_get_button(dialog_->check_here)); - - if (ob == dialog_->check_default) { - if (def_place) { - fl_set_button(dialog_->check_top, false); - fl_set_button(dialog_->check_bottom, false); - fl_set_button(dialog_->check_page, false); - fl_set_button(dialog_->check_here, false); - fl_set_button(dialog_->check_force, false); - fl_set_button(dialog_->check_here_definitely, false); - } - setEnabled(dialog_->check_top, !def_place); - setEnabled(dialog_->check_bottom, !def_place); - setEnabled(dialog_->check_page, !def_place); - setEnabled(dialog_->check_here, !def_place && !wide_float); - setEnabled(dialog_->check_force, !def_place && standard_options); - setEnabled(dialog_->check_here_definitely, !def_place && !wide_float); + bool alternatives = placement_.get() == ALTERNATIVES; + bool const wide = fl_get_button(dialog_->check_wide); - } else if (ob == dialog_->check_wide) { - if (wide_float) { - fl_set_button(dialog_->check_here_definitely, false); - fl_set_button(dialog_->check_here, false); - if (!wide_options) { - fl_set_button(dialog_->check_force, false); - setEnabled(dialog_->check_force, false); - } - } - setEnabled(dialog_->check_here, !def_place && !wide_float); - setEnabled(dialog_->check_force, !def_place && wide_options); - setEnabled(dialog_->check_here_definitely, !def_place && !wide_float); - - } else if (ob == dialog_->check_here_definitely) { - if (fl_get_button(dialog_->check_here_definitely)) { - fl_set_button(dialog_->check_top, false); - fl_set_button(dialog_->check_bottom, false); - fl_set_button(dialog_->check_page, false); - fl_set_button(dialog_->check_here, false); - fl_set_button(dialog_->check_force, false); - setEnabled(dialog_->check_force, false); - } + if (ob == dialog_->radio_default || + ob == dialog_->radio_here_definitely || + ob == dialog_->radio_alternatives) { - } else if (ob == dialog_->check_here || ob == dialog_->check_top - || ob == dialog_->check_bottom || ob == dialog_->check_page) { - if (!standard_options) - fl_set_button(dialog_->check_force, false); - else - fl_set_button(dialog_->check_here_definitely, false); - setEnabled(dialog_->check_force, standard_options); + // set radio button + placement_.set(ob); + alternatives = placement_.get() == ALTERNATIVES; + // enable check buttons for Alternatives + setEnabled(dialog_->check_top, alternatives); + setEnabled(dialog_->check_bottom, alternatives); + setEnabled(dialog_->check_page, alternatives); + // wide float doesn't allow 'here' placement + setEnabled(dialog_->check_here, alternatives && !wide); + + } else if (ob == dialog_->check_wide) { + // wide float doesn't allow 'Here, definitely!' and 'here' + setEnabled(dialog_->radio_here_definitely, !wide); + setEnabled(dialog_->check_here, alternatives && !wide); + + // flip to default, if 'Here, definitely!' was selected + if (wide && placement_.get() == HERE_DEFINITELY) { + placement_.set(dialog_->radio_default); + } } + // enable force button, if Alternatives is selected and at least + // one of its check buttons + bool const enable_force = alternatives && + (fl_get_button(dialog_->check_top) || + fl_get_button(dialog_->check_bottom) || + fl_get_button(dialog_->check_page) || + (fl_get_button(dialog_->check_here) && !wide)); + setEnabled(dialog_->check_force, enable_force); + return ButtonPolicy::SMI_VALID; } diff --git a/src/frontends/xforms/FormFloat.h b/src/frontends/xforms/FormFloat.h index c973ef2df2..38c2932cb0 100644 --- a/src/frontends/xforms/FormFloat.h +++ b/src/frontends/xforms/FormFloat.h @@ -17,6 +17,7 @@ #endif #include "FormBase.h" +#include "RadioButtonGroup.h" class ControlFloat; struct FD_float; @@ -37,6 +38,9 @@ private: virtual void update(); /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + + /// placement + RadioButtonGroup placement_; }; #endif // FORMFLOAT_H diff --git a/src/frontends/xforms/forms/form_float.fd b/src/frontends/xforms/forms/form_float.fd index e26ef268f1..8feabdf8f4 100644 --- a/src/frontends/xforms/forms/form_float.fd +++ b/src/frontends/xforms/forms/form_float.fd @@ -5,17 +5,18 @@ Internal Form Definition File Number of forms: 1 Unit of measure: FL_COORD_PIXEL +SnapGrid: 5 =============== FORM =============== Name: form_float -Width: 370 -Height: 320 -Number of Objects: 14 +Width: 395 +Height: 260 +Number of Objects: 17 -------------------- class: FL_BOX type: FLAT_BOX -box: 0 0 370 320 +box: 0 0 395 260 boxtype: FL_FLAT_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -31,99 +32,99 @@ callback: argument: -------------------- -class: FL_CHECKBUTTON -type: PUSH_BUTTON -box: 20 75 152 30 +class: FL_LABELFRAME +type: ENGRAVED_FRAME +box: 5 10 385 185 boxtype: FL_NO_BOX -colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_CENTER +colors: FL_BLACK FL_COL1 +alignment: FL_ALIGN_TOP_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Top of the page|#T +label: Placement shortcut: resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: check_top -callback: C_FormBaseInputCB -argument: 0 +gravity: FL_NorthWest FL_SouthEast +name: +callback: +argument: -------------------- class: FL_CHECKBUTTON type: PUSH_BUTTON -box: 20 105 152 30 +box: 215 115 170 25 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: Bottom of the page|#B +label: Page of floats|#P shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: check_bottom +resize: FL_RESIZE_NONE +gravity: FL_East FL_NoGravity +name: check_page callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_CHECKBUTTON type: PUSH_BUTTON -box: 190 75 152 30 +box: 45 140 170 25 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: Page of floats|#P +label: Bottom of the page|#B shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: check_page +resize: FL_RESIZE_NONE +gravity: FL_West FL_NoGravity +name: check_bottom callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_CHECKBUTTON type: PUSH_BUTTON -box: 190 105 152 30 +box: 45 115 170 25 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 +label: Top of the page|#T shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: check_here +resize: FL_RESIZE_NONE +gravity: FL_West FL_NoGravity +name: check_top callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_CHECKBUTTON type: PUSH_BUTTON -box: 20 180 152 30 +box: 215 140 170 25 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 +label: Here, if possible|#r shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: check_here_definitely +resize: FL_RESIZE_NONE +gravity: FL_East FL_NoGravity +name: check_here callback: C_FormBaseInputCB argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 10 280 100 30 +box: 5 230 90 25 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -132,8 +133,8 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Restore|#R shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity +resize: FL_RESIZE_NONE +gravity: FL_SouthWest FL_SouthWest name: button_restore callback: C_FormBaseRestoreCB argument: 0 @@ -141,7 +142,7 @@ argument: 0 -------------------- class: FL_BUTTON type: RETURN_BUTTON -box: 130 280 70 30 +box: 110 230 90 25 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -150,8 +151,8 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: OK shortcut: ^M -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity +resize: FL_RESIZE_NONE +gravity: FL_SouthEast FL_SouthEast name: button_ok callback: C_FormBaseOKCB argument: 0 @@ -159,7 +160,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 210 280 70 30 +box: 205 230 90 25 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -168,8 +169,8 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Apply|#A shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity +resize: FL_RESIZE_NONE +gravity: FL_SouthEast FL_SouthEast name: button_apply callback: C_FormBaseApplyCB argument: 0 @@ -177,7 +178,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 290 280 70 30 +box: 300 230 90 25 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -186,8 +187,8 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Cancel|^[ shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity +resize: FL_RESIZE_NONE +gravity: FL_SouthEast FL_SouthEast name: button_close callback: C_FormBaseCancelCB argument: 0 @@ -195,7 +196,7 @@ argument: 0 -------------------- class: FL_CHECKBUTTON type: PUSH_BUTTON -box: 20 230 30 30 +box: 5 200 385 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -204,23 +205,41 @@ size: FL_NORMAL_SIZE lcol: FL_BLACK label: Span columns|#S shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity +resize: FL_RESIZE_NONE +gravity: FL_SouthWest FL_SouthWest name: check_wide callback: C_FormBaseInputCB argument: 0 -------------------- -class: FL_LABELFRAME -type: ENGRAVED_FRAME -box: 10 20 350 200 +class: FL_CHECKBUTTON +type: PUSH_BUTTON +box: 125 165 260 25 boxtype: FL_NO_BOX -colors: FL_BLACK FL_COL1 -alignment: FL_ALIGN_TOP_LEFT +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Ignore internal LaTeX rules|#I +shortcut: +resize: FL_RESIZE_NONE +gravity: FL_NoGravity FL_NoGravity +name: check_force +callback: C_FormBaseInputCB +argument: 0 + +-------------------- +class: FL_BEGIN_GROUP +type: 0 +box: 0 10 10 0 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_MCOL +alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_DEFAULT_SIZE lcol: FL_BLACK -label: Placement +label: shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity @@ -229,40 +248,77 @@ callback: argument: -------------------- -class: FL_CHECKBUTTON +class: FL_ROUND3DBUTTON type: PUSH_BUTTON -box: 20 135 30 30 +box: 10 85 200 25 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: Ignore internal placement rules|#g +label: Alternatives|#l shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: check_force +resize: FL_RESIZE_NONE +gravity: FL_West FL_NoGravity +name: radio_alternatives callback: C_FormBaseInputCB argument: 0 -------------------- -class: FL_CHECKBUTTON +class: FL_ROUND3DBUTTON type: PUSH_BUTTON -box: 20 30 30 30 +box: 10 55 200 25 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: Float Defaults|#D +label: Here, definitely!|#H shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: check_default +resize: FL_RESIZE_NONE +gravity: FL_West FL_NoGravity +name: radio_here_definitely callback: C_FormBaseInputCB argument: 0 +-------------------- +class: FL_ROUND3DBUTTON +type: PUSH_BUTTON +box: 10 25 200 25 +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: Document default|#D +shortcut: +resize: FL_RESIZE_NONE +gravity: FL_West FL_NoGravity +name: radio_default +callback: C_FormBaseInputCB +argument: 0 + value: 1 + +-------------------- +class: FL_END_GROUP +type: 0 +box: 0 0 0 0 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_MCOL +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: +callback: +argument: + ============================== create_the_forms