]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormFloat.C
Add fl_set_input_return to input_paperoption.
[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 #warning Needs to be implemented. (Lgb)
33 // A way to set to float default is missing.
34 // A way to set "force[!]" is missing.
35 // Also there are two groups of buttons [Here] and [top,bottom,page,here],
36 // is is not really possible to choose from both groups. So this should
37 // be disallowed by the dialog too.
38
39 void FormFloat::build()
40 {
41         dialog_.reset(build_float());
42
43         // Manage the ok, apply and cancel/close buttons
44         bc().setOK(dialog_->button_ok);
45         bc().setApply(dialog_->button_apply);
46         bc().setCancel(dialog_->button_cancel);
47         bc().setRestore(dialog_->button_restore);
48
49         bc().addReadOnly(dialog_->radio_top);
50         bc().addReadOnly(dialog_->radio_bottom);
51         bc().addReadOnly(dialog_->radio_page);
52         bc().addReadOnly(dialog_->radio_here);
53         bc().addReadOnly(dialog_->Here);
54 }
55
56
57 void FormFloat::apply()
58 {
59         string placement;
60         if (fl_get_button(dialog_->Here)) {
61                 placement += "H";
62         } else {
63                 if (fl_get_button(dialog_->radio_top)) {
64                         placement += "t";
65                 }
66                 if (fl_get_button(dialog_->radio_bottom)) {
67                         placement += "b";
68                 }
69                 if (fl_get_button(dialog_->radio_page)) {
70                         placement += "p";
71                 }
72                 if (fl_get_button(dialog_->radio_here)) {
73                         placement += "h";
74                 }
75         }
76         controller().params().placement = placement;
77 }
78
79
80 void FormFloat::update()
81 {
82         bool top = false;
83         bool bottom = false;
84         bool page = false;
85         bool here = false;
86         bool Here = false;
87
88         string placement(controller().params().placement);
89         
90         if (contains(placement, "H")) {
91                 Here = true;
92         } else {
93                 if (contains(placement, "t")) {
94                         top = true;
95                 }
96                 if (contains(placement, "b")) {
97                         bottom = true;
98                 }
99                 if (contains(placement, "p")) {
100                         page = true;
101                 }
102                 if (contains(placement, "h")) {
103                         here = true;
104                 }
105         }
106         fl_set_button(dialog_->radio_top, top);
107         fl_set_button(dialog_->radio_bottom, bottom);
108         fl_set_button(dialog_->radio_page, page);
109         fl_set_button(dialog_->radio_here, here);
110         fl_set_button(dialog_->Here, Here);
111
112 }
113