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 "forms/form_float.h"
19 #include "support/lstrings.h"
20 #include "xforms_helpers.h"
21 #include FORMS_H_LOCATION
23 typedef FormCB<ControlFloat, FormDB<FD_float> > base_class;
25 FormFloat::FormFloat(ControlFloat & c, Dialogs & d)
26 : base_class(c, d, _("Float Options"))
30 // FIX: Needs to be implemented. (Lgb)
31 // A way to set to float default is missing.
32 // A way to set "force[!]" is missing.
34 void FormFloat::build()
36 dialog_.reset(build_float(this));
38 // Manage the ok, apply and cancel/close buttons
39 bc().setOK(dialog_->button_ok);
40 bc().setApply(dialog_->button_apply);
41 bc().setCancel(dialog_->button_close);
42 bc().setRestore(dialog_->button_restore);
44 bc().addReadOnly(dialog_->check_top);
45 bc().addReadOnly(dialog_->check_bottom);
46 bc().addReadOnly(dialog_->check_page);
47 bc().addReadOnly(dialog_->check_here);
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_top)) {
62 if (fl_get_button(dialog_->check_bottom)) {
65 if (fl_get_button(dialog_->check_page)) {
68 if (fl_get_button(dialog_->check_here)) {
72 controller().params().placement = placement;
73 controller().params().wide = fl_get_button(dialog_->check_wide);
77 void FormFloat::update()
83 bool here_definitely = false;
85 string placement(controller().params().placement);
87 if (contains(placement, "H")) {
88 here_definitely = true;
90 if (contains(placement, "t")) {
93 if (contains(placement, "b")) {
96 if (contains(placement, "p")) {
99 if (contains(placement, "h")) {
103 fl_set_button(dialog_->check_top, top);
104 fl_set_button(dialog_->check_bottom, bottom);
105 fl_set_button(dialog_->check_page, page);
106 fl_set_button(dialog_->check_here, here);
107 fl_set_button(dialog_->check_here_definitely, here_definitely);
108 setEnabled(dialog_->check_here_definitely, !controller().params().wide);
109 fl_set_button(dialog_->check_wide, controller().params().wide);
113 ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
115 if (ob == dialog_->check_here_definitely) {
116 if (fl_get_button(dialog_->check_here_definitely)) {
117 fl_set_button(dialog_->check_top, false);
118 fl_set_button(dialog_->check_bottom, false);
119 fl_set_button(dialog_->check_page, false);
120 fl_set_button(dialog_->check_here, false);
123 if (fl_get_button(dialog_->check_here_definitely)) {
124 fl_set_button(dialog_->check_here_definitely, false);
127 if (ob == dialog_->check_wide) {
128 if (fl_get_button(dialog_->check_wide)) {
129 fl_set_button(dialog_->check_here_definitely, false);
130 setEnabled(dialog_->check_here_definitely, false);
133 setEnabled(dialog_->check_here_definitely, true);
136 return ButtonPolicy::SMI_VALID;