3 * Copyright 2001 The LyX Team.
4 * See the file COPYING.
6 * \author Lars Gullik Bjønnes, larsbj@lyx.org
12 #pragma implementation
16 #include "ControlFloat.h"
17 #include "FormFloat.h"
18 #include "form_float.h"
19 #include "support/lstrings.h"
20 #include "xforms_helpers.h"
22 typedef FormCB<ControlFloat, FormDB<FD_form_float> > base_class;
24 FormFloat::FormFloat(ControlFloat & c)
25 : base_class(c, _("Float Options"))
29 // FIX: Needs to be implemented. (Lgb)
30 // A way to set to float default is missing.
31 // A way to set "force[!]" is missing.
33 void FormFloat::build()
35 dialog_.reset(build_float());
37 // Manage the ok, apply and cancel/close buttons
38 bc().setOK(dialog_->button_ok);
39 bc().setApply(dialog_->button_apply);
40 bc().setCancel(dialog_->button_cancel);
41 bc().setRestore(dialog_->button_restore);
43 bc().addReadOnly(dialog_->radio_top);
44 bc().addReadOnly(dialog_->radio_bottom);
45 bc().addReadOnly(dialog_->radio_page);
46 bc().addReadOnly(dialog_->radio_here);
47 bc().addReadOnly(dialog_->button_here_definitely);
51 void FormFloat::apply()
54 if (fl_get_button(dialog_->button_here_definitely)) {
57 if (fl_get_button(dialog_->radio_top)) {
60 if (fl_get_button(dialog_->radio_bottom)) {
63 if (fl_get_button(dialog_->radio_page)) {
66 if (fl_get_button(dialog_->radio_here)) {
70 controller().params().placement = placement;
74 void FormFloat::update()
80 bool here_definitely = false;
82 string placement(controller().params().placement);
84 if (contains(placement, "H")) {
85 here_definitely = true;
87 if (contains(placement, "t")) {
90 if (contains(placement, "b")) {
93 if (contains(placement, "p")) {
96 if (contains(placement, "h")) {
100 fl_set_button(dialog_->radio_top, top);
101 fl_set_button(dialog_->radio_bottom, bottom);
102 fl_set_button(dialog_->radio_page, page);
103 fl_set_button(dialog_->radio_here, here);
104 fl_set_button(dialog_->button_here_definitely, here_definitely);
105 setEnabled(dialog_->button_here_definitely, controller().params().allow_here_definitely);
109 ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
111 if (ob == dialog_->button_here_definitely) {
112 if (fl_get_button(dialog_->button_here_definitely)) {
113 fl_set_button(dialog_->radio_top, false);
114 fl_set_button(dialog_->radio_bottom, false);
115 fl_set_button(dialog_->radio_page, false);
116 fl_set_button(dialog_->radio_here, false);
119 if (fl_get_button(dialog_->button_here_definitely)) {
120 fl_set_button(dialog_->button_here_definitely, false);
124 return ButtonPolicy::SMI_VALID;