]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormFloat.C
change X-windows to X window
[lyx.git] / src / frontends / xforms / FormFloat.C
1 /* This file is part of
2  * ====================================================== 
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file FormFloat.C
11  */
12
13 #include <config.h>
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "xformsBC.h"
20 #include "ControlFloat.h"
21 #include "FormFloat.h"
22 #include "form_float.h"
23 #include "support/lstrings.h"
24
25 typedef FormCB<ControlFloat, FormDB<FD_form_float> > base_class;
26
27 FormFloat::FormFloat(ControlFloat & c)
28         : base_class(c, _("Float Options"))
29 {}
30
31
32 // FIX: Needs to be implemented. (Lgb)
33 // A way to set to float default is missing.
34 // A way to set "force[!]" is missing.
35
36 void FormFloat::build()
37 {
38         dialog_.reset(build_float());
39
40         // Manage the ok, apply and cancel/close buttons
41         bc().setOK(dialog_->button_ok);
42         bc().setApply(dialog_->button_apply);
43         bc().setCancel(dialog_->button_cancel);
44         bc().setRestore(dialog_->button_restore);
45
46         bc().addReadOnly(dialog_->radio_top);
47         bc().addReadOnly(dialog_->radio_bottom);
48         bc().addReadOnly(dialog_->radio_page);
49         bc().addReadOnly(dialog_->radio_here);
50         bc().addReadOnly(dialog_->button_here_definitely);
51 }
52
53
54 void FormFloat::apply()
55 {
56         string placement;
57         if (fl_get_button(dialog_->button_here_definitely)) {
58                 placement += "H";
59         } else {
60                 if (fl_get_button(dialog_->radio_top)) {
61                         placement += "t";
62                 }
63                 if (fl_get_button(dialog_->radio_bottom)) {
64                         placement += "b";
65                 }
66                 if (fl_get_button(dialog_->radio_page)) {
67                         placement += "p";
68                 }
69                 if (fl_get_button(dialog_->radio_here)) {
70                         placement += "h";
71                 }
72         }
73         controller().params().placement = placement;
74 }
75
76
77 void FormFloat::update()
78 {
79         bool top = false;
80         bool bottom = false;
81         bool page = false;
82         bool here = false;
83         bool here_definitely = false;
84
85         string placement(controller().params().placement);
86         
87         if (contains(placement, "H")) {
88                 here_definitely = true;
89         } else {
90                 if (contains(placement, "t")) {
91                         top = true;
92                 }
93                 if (contains(placement, "b")) {
94                         bottom = true;
95                 }
96                 if (contains(placement, "p")) {
97                         page = true;
98                 }
99                 if (contains(placement, "h")) {
100                         here = true;
101                 }
102         }
103         fl_set_button(dialog_->radio_top, top);
104         fl_set_button(dialog_->radio_bottom, bottom);
105         fl_set_button(dialog_->radio_page, page);
106         fl_set_button(dialog_->radio_here, here);
107         fl_set_button(dialog_->button_here_definitely, here_definitely);
108 }
109
110
111 ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
112 {
113         if (ob == dialog_->button_here_definitely) {
114                 if (fl_get_button(dialog_->button_here_definitely)) {
115                         fl_set_button(dialog_->radio_top,    false);
116                         fl_set_button(dialog_->radio_bottom, false);
117                         fl_set_button(dialog_->radio_page,   false);
118                         fl_set_button(dialog_->radio_here,   false);
119                 }
120         } else {
121                 if (fl_get_button(dialog_->button_here_definitely)) {
122                         fl_set_button(dialog_->button_here_definitely, false);
123                 }
124         }
125
126         return ButtonPolicy::SMI_VALID;
127 }