]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormFloat.C
change some __GNUG_ to __GNUG__
[lyx.git] / src / frontends / xforms / FormFloat.C
1 /**
2  * \file FormFloat.C
3  * Copyright 2001 The LyX Team.
4  * See the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes, larsbj@lyx.org
7  */
8
9 #include <config.h>
10
11 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include "xformsBC.h"
16 #include "ControlFloat.h"
17 #include "FormFloat.h"
18 #include "form_float.h"
19 #include "support/lstrings.h"
20 #include "xforms_helpers.h"
21
22 typedef FormCB<ControlFloat, FormDB<FD_form_float> > base_class;
23
24 FormFloat::FormFloat(ControlFloat & c)
25         : base_class(c, _("Float Options"))
26 {}
27
28
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.
32
33 void FormFloat::build()
34 {
35         dialog_.reset(build_float());
36
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_close);
41         bc().setRestore(dialog_->button_restore);
42
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_here_definitely);
48 }
49
50
51 void FormFloat::apply()
52 {
53         string placement;
54         if (fl_get_button(dialog_->check_here_definitely)) {
55                 placement += "H";
56         } else {
57                 if (fl_get_button(dialog_->check_top)) {
58                         placement += "t";
59                 }
60                 if (fl_get_button(dialog_->check_bottom)) {
61                         placement += "b";
62                 }
63                 if (fl_get_button(dialog_->check_page)) {
64                         placement += "p";
65                 }
66                 if (fl_get_button(dialog_->check_here)) {
67                         placement += "h";
68                 }
69         }
70         controller().params().placement = placement;
71 }
72
73
74 void FormFloat::update()
75 {
76         bool top = false;
77         bool bottom = false;
78         bool page = false;
79         bool here = false;
80         bool here_definitely = false;
81
82         string placement(controller().params().placement);
83
84         if (contains(placement, "H")) {
85                 here_definitely = true;
86         } else {
87                 if (contains(placement, "t")) {
88                         top = true;
89                 }
90                 if (contains(placement, "b")) {
91                         bottom = true;
92                 }
93                 if (contains(placement, "p")) {
94                         page = true;
95                 }
96                 if (contains(placement, "h")) {
97                         here = true;
98                 }
99         }
100         fl_set_button(dialog_->check_top, top);
101         fl_set_button(dialog_->check_bottom, bottom);
102         fl_set_button(dialog_->check_page, page);
103         fl_set_button(dialog_->check_here, here);
104         fl_set_button(dialog_->check_here_definitely, here_definitely);
105         setEnabled(dialog_->check_here_definitely, controller().params().allow_here_definitely);
106 }
107
108
109 ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
110 {
111         if (ob == dialog_->check_here_definitely) {
112                 if (fl_get_button(dialog_->check_here_definitely)) {
113                         fl_set_button(dialog_->check_top,    false);
114                         fl_set_button(dialog_->check_bottom, false);
115                         fl_set_button(dialog_->check_page,   false);
116                         fl_set_button(dialog_->check_here,   false);
117                 }
118         } else {
119                 if (fl_get_button(dialog_->check_here_definitely)) {
120                         fl_set_button(dialog_->check_here_definitely, false);
121                 }
122         }
123
124         return ButtonPolicy::SMI_VALID;
125 }