3 * See the file COPYING.
5 * \author Lars Gullik Bjønnes
6 * \author Juergen Spitzmueller j.spitzmueller@gmx.de
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
18 #include "ControlFloat.h"
19 #include "FormFloat.h"
20 #include "forms/form_float.h"
21 #include "support/lstrings.h"
22 #include "xforms_helpers.h"
23 #include FORMS_H_LOCATION
25 typedef FormCB<ControlFloat, FormDB<FD_float> > base_class;
27 FormFloat::FormFloat()
28 : base_class(_("Float Options"))
32 void FormFloat::build()
34 dialog_.reset(build_float(this));
36 // Manage the ok, apply and cancel/close buttons
37 bc().setOK(dialog_->button_ok);
38 bc().setApply(dialog_->button_apply);
39 bc().setCancel(dialog_->button_close);
40 bc().setRestore(dialog_->button_restore);
42 bc().addReadOnly(dialog_->check_default);
43 bc().addReadOnly(dialog_->check_top);
44 bc().addReadOnly(dialog_->check_bottom);
45 bc().addReadOnly(dialog_->check_page);
46 bc().addReadOnly(dialog_->check_here);
47 bc().addReadOnly(dialog_->check_force);
48 bc().addReadOnly(dialog_->check_here_definitely);
49 bc().addReadOnly(dialog_->check_wide);
53 void FormFloat::apply()
56 if (fl_get_button(dialog_->check_here_definitely)) {
59 if (fl_get_button(dialog_->check_force)) {
62 if (fl_get_button(dialog_->check_here)) {
65 if (fl_get_button(dialog_->check_top)) {
68 if (fl_get_button(dialog_->check_bottom)) {
71 if (fl_get_button(dialog_->check_page)) {
76 controller().params().placement = placement;
77 controller().params().wide = fl_get_button(dialog_->check_wide);
81 void FormFloat::update()
83 bool def_placement = false;
89 bool here_definitely = false;
91 string placement(controller().params().placement);
93 if (placement.empty()) {
96 } else if (contains(placement, "H")) {
97 here_definitely = true;
100 if (contains(placement, "!")) {
103 if (contains(placement, "t")) {
106 if (contains(placement, "b")) {
109 if (contains(placement, "p")) {
112 if (contains(placement, "h")) {
116 fl_set_button(dialog_->check_default, def_placement);
117 fl_set_button(dialog_->check_top, top);
118 fl_set_button(dialog_->check_bottom, bottom);
119 fl_set_button(dialog_->check_page, page);
120 fl_set_button(dialog_->check_here, here);
121 fl_set_button(dialog_->check_force, force);
122 fl_set_button(dialog_->check_here_definitely, here_definitely);
123 setEnabled(dialog_->check_here_definitely, !controller().params().wide
125 if (controller().params().wide) {
126 fl_set_button(dialog_->check_here, false);
127 fl_set_button(dialog_->check_bottom, false);
129 setEnabled(dialog_->check_here, !controller().params().wide && !def_placement);
130 setEnabled(dialog_->check_bottom, !controller().params().wide && !def_placement);
131 fl_set_button(dialog_->check_wide, controller().params().wide);
132 setEnabled(dialog_->check_top, !def_placement);
133 setEnabled(dialog_->check_page, !def_placement);
134 setEnabled(dialog_->check_force, top || bottom || page || here);
138 ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
140 bool const def_place = fl_get_button(dialog_->check_default);
141 bool const wide_float = fl_get_button(dialog_->check_wide);
142 // with wide floats, h[ere] is not allowed
143 // b[ottom] is allowed (only) for figure* in multicolumn, don't
144 // disallow it therefore
145 bool const wide_options = (fl_get_button(dialog_->check_top)
146 || fl_get_button(dialog_->check_bottom)
147 || fl_get_button(dialog_->check_page));
148 // The !-option is only allowed together with h, t, b, or p
149 // We have to take this into account
150 bool const standard_options = (wide_options || fl_get_button(dialog_->check_here));
152 if (ob == dialog_->check_default) {
154 fl_set_button(dialog_->check_top, false);
155 fl_set_button(dialog_->check_bottom, false);
156 fl_set_button(dialog_->check_page, false);
157 fl_set_button(dialog_->check_here, false);
158 fl_set_button(dialog_->check_force, false);
159 fl_set_button(dialog_->check_here_definitely, false);
161 setEnabled(dialog_->check_top, !def_place);
162 setEnabled(dialog_->check_bottom, !def_place);
163 setEnabled(dialog_->check_page, !def_place);
164 setEnabled(dialog_->check_here, !def_place && !wide_float);
165 setEnabled(dialog_->check_force, !def_place && standard_options);
166 setEnabled(dialog_->check_here_definitely, !def_place && !wide_float);
168 } else if (ob == dialog_->check_wide) {
170 fl_set_button(dialog_->check_here_definitely, false);
171 fl_set_button(dialog_->check_here, false);
173 fl_set_button(dialog_->check_force, false);
174 setEnabled(dialog_->check_force, false);
177 setEnabled(dialog_->check_here, !def_place && !wide_float);
178 setEnabled(dialog_->check_force, !def_place && wide_options);
179 setEnabled(dialog_->check_here_definitely, !def_place && !wide_float);
181 } else if (ob == dialog_->check_here_definitely) {
182 if (fl_get_button(dialog_->check_here_definitely)) {
183 fl_set_button(dialog_->check_top, false);
184 fl_set_button(dialog_->check_bottom, false);
185 fl_set_button(dialog_->check_page, false);
186 fl_set_button(dialog_->check_here, false);
187 fl_set_button(dialog_->check_force, false);
188 setEnabled(dialog_->check_force, false);
191 } else if (ob == dialog_->check_here || ob == dialog_->check_top
192 || ob == dialog_->check_bottom || ob == dialog_->check_page) {
193 if (!standard_options)
194 fl_set_button(dialog_->check_force, false);
196 fl_set_button(dialog_->check_here_definitely, false);
197 setEnabled(dialog_->check_force, standard_options);
201 return ButtonPolicy::SMI_VALID;