X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FFormFloat.C;h=c38b68a99885fef5d75cffa361477afb8262a61d;hb=37e82a546392d43f787826b85481a11f2a27af15;hp=8d60284976516489286e90524fb51d43790bc0b5;hpb=74b7bcc2f3d86d31f81b41e1a8e4c0584f05b1ab;p=lyx.git diff --git a/src/frontends/xforms/FormFloat.C b/src/frontends/xforms/FormFloat.C index 8d60284976..c38b68a998 100644 --- a/src/frontends/xforms/FormFloat.C +++ b/src/frontends/xforms/FormFloat.C @@ -7,23 +7,32 @@ * \author Jürgen Spitzmüller * \author Rob Lahaye * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ #include -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "xformsBC.h" -#include "ControlFloat.h" #include "FormFloat.h" +#include "ControlFloat.h" #include "forms/form_float.h" + #include "Tooltips.h" #include "xforms_helpers.h" +#include "xformsBC.h" + +#include "insets/insetfloat.h" + #include "support/lstrings.h" -#include FORMS_H_LOCATION + +#include "lyx_forms.h" + +using std::string; + +namespace lyx { + +using support::contains; + +namespace frontend { namespace { @@ -32,14 +41,14 @@ enum { HERE_DEFINITELY, ALTERNATIVES }; - + } // namespace anon -typedef FormCB > base_class; +typedef FormController > base_class; -FormFloat::FormFloat() - : base_class(_("Float Options")) +FormFloat::FormFloat(Dialog & parent) + : base_class(parent, _("Float Settings")) {} @@ -48,21 +57,22 @@ void FormFloat::build() dialog_.reset(build_float(this)); // Manage the ok, apply and cancel/close buttons - bc().setOK(dialog_->button_ok); - bc().setApply(dialog_->button_apply); - bc().setCancel(dialog_->button_close); - bc().setRestore(dialog_->button_restore); + bcview().setOK(dialog_->button_ok); + bcview().setApply(dialog_->button_apply); + bcview().setCancel(dialog_->button_close); + bcview().setRestore(dialog_->button_restore); // 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_wide); + bcview().addReadOnly(dialog_->radio_default); + bcview().addReadOnly(dialog_->radio_here_definitely); + bcview().addReadOnly(dialog_->radio_alternatives); + bcview().addReadOnly(dialog_->check_top); + bcview().addReadOnly(dialog_->check_bottom); + bcview().addReadOnly(dialog_->check_page); + bcview().addReadOnly(dialog_->check_here); + bcview().addReadOnly(dialog_->check_force); + bcview().addReadOnly(dialog_->check_wide); + bcview().addReadOnly(dialog_->check_sideways); placement_.init(dialog_->radio_default, DOCUMENT_DEFAULTS); placement_.init(dialog_->radio_here_definitely, HERE_DEFINITELY); @@ -87,36 +97,39 @@ void FormFloat::build() tooltips().init(dialog_->check_force, str); str = _("Span float over the columns."); tooltips().init(dialog_->check_wide, str); + str = _("Rotate the float sideways by 90 degs."); + tooltips().init(dialog_->check_sideways, str); } void FormFloat::apply() { bool const wide = fl_get_button(dialog_->check_wide); + bool const sideways = fl_get_button(dialog_->check_sideways); string placement; switch (placement_.get()) { case ALTERNATIVES: if (fl_get_button(dialog_->check_force)) { // Ignore internal LaTeX rules - placement += "!"; + placement += '!'; } if (fl_get_button(dialog_->check_top)) { // Top of page - placement += "t"; + placement += 't'; } if (fl_get_button(dialog_->check_bottom)) { // Bottom of page - placement += "b"; + placement += 'b'; } if (fl_get_button(dialog_->check_page)) { // Page of floats - placement += "p"; + placement += 'p'; } // ignore if wide is selected if (!wide && fl_get_button(dialog_->check_here)) { // Here, if possible - placement += "h"; + placement += 'h'; } if (placement == "!") { // ignore placement if only force is selected. @@ -146,6 +159,7 @@ void FormFloat::apply() controller().params().placement = placement; controller().params().wide = wide; + controller().params().sideways = sideways; } @@ -153,14 +167,17 @@ void FormFloat::update() { string placement(controller().params().placement); bool const wide = controller().params().wide; + bool const sideways = controller().params().sideways; + bool const sideways_possible = (controller().params().type == "figure" + || controller().params().type == "table"); - bool const here_definitely = contains(placement, "H"); + bool const here_definitely = contains(placement, 'H'); - 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 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) { @@ -176,50 +193,62 @@ void FormFloat::update() fl_set_button(dialog_->check_page, page); fl_set_button(dialog_->check_here, 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); + fl_set_button(dialog_->check_sideways, sideways); + + setEnabled(dialog_->radio_here_definitely, !wide && !sideways); + setEnabled(dialog_->check_force, alternatives && !sideways); + setEnabled(dialog_->check_top, alternatives && !sideways); + setEnabled(dialog_->check_bottom, alternatives && !sideways); + setEnabled(dialog_->check_page, alternatives && !sideways); + setEnabled(dialog_->check_here, alternatives && !wide && !sideways); + setEnabled(dialog_->check_wide, !sideways); + setEnabled(dialog_->radio_default, !sideways); + setEnabled(dialog_->radio_alternatives, !sideways); + setEnabled(dialog_->check_sideways, sideways_possible); } ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long) { - bool alternatives = placement_.get() == ALTERNATIVES; + bool const alternatives = placement_.get() == ALTERNATIVES; bool const wide = fl_get_button(dialog_->check_wide); + bool const sideways = fl_get_button(dialog_->check_sideways); if (ob == dialog_->radio_default || ob == dialog_->radio_here_definitely || ob == dialog_->radio_alternatives) { - - // set radio button - placement_.set(ob); - alternatives = placement_.get() == ALTERNATIVES; - - // enable check buttons for Alternatives + // enable check buttons only for Alternatives setEnabled(dialog_->check_top, alternatives); - setEnabled(dialog_->check_bottom, alternatives); setEnabled(dialog_->check_page, alternatives); - // wide float doesn't allow 'here' placement + // wide float doesn't allow 'here' or 'bottom' placement setEnabled(dialog_->check_here, alternatives && !wide); + setEnabled(dialog_->check_bottom, 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) { + // wide float doesn't allow 'Here, definitely!' + // placement placement_.set(dialog_->radio_default); } + setEnabled(dialog_->check_here, alternatives && !wide); + setEnabled(dialog_->radio_here_definitely, !wide); + setEnabled(dialog_->check_bottom, alternatives && !wide); + + } else if (ob == dialog_->check_sideways) { + setEnabled(dialog_->radio_default, !sideways); + setEnabled(dialog_->radio_alternatives, !sideways); + setEnabled(dialog_->radio_here_definitely, !wide && !sideways); + setEnabled(dialog_->check_top, alternatives && !sideways); + setEnabled(dialog_->check_bottom, + alternatives && !wide && !sideways); + setEnabled(dialog_->check_page, alternatives && !sideways); + setEnabled(dialog_->check_here, alternatives && !wide && !sideways); + setEnabled(dialog_->check_wide, !sideways); } // enable force button, if Alternatives is selected and at least // one of its check buttons - bool const enable_force = alternatives && + bool const enable_force = alternatives && !sideways && (fl_get_button(dialog_->check_top) || fl_get_button(dialog_->check_bottom) || fl_get_button(dialog_->check_page) || @@ -228,3 +257,6 @@ ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long) return ButtonPolicy::SMI_VALID; } + +} // namespace frontend +} // namespace lyx