* \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 <config.h>
-#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 lyx::support::contains;
+
+using std::string;
+
namespace {
HERE_DEFINITELY,
ALTERNATIVES
};
-
+
} // namespace anon
-typedef FormCB<ControlFloat, FormDB<FD_float> > base_class;
+typedef FormController<ControlFloat, FormView<FD_float> > base_class;
-FormFloat::FormFloat()
- : base_class(_("Float Options"))
+FormFloat::FormFloat(Dialog & parent)
+ : base_class(parent, _("Float Settings"))
{}
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);
placement_.init(dialog_->radio_default, DOCUMENT_DEFAULTS);
placement_.init(dialog_->radio_here_definitely, HERE_DEFINITELY);
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.
string placement(controller().params().placement);
bool const wide = controller().params().wide;
- 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) {
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);
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);
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) {
+ // 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);
}
// enable force button, if Alternatives is selected and at least