]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GFloat.C
Minipage is no more (long live the box inset)
[lyx.git] / src / frontends / gnome / GFloat.C
1 /**
2  * \file GFloat.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Michael Koziarski
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11
12 #include <config.h>
13
14 #include "gnomeBC.h"
15 #include "GFloat.h"
16 #include "support/lstrings.h"
17
18 #include <gtkmm/button.h>
19 #include <gtkmm/checkbutton.h>
20 #include <gtkmm/radiobutton.h>
21 #include <gtkmm/box.h>
22
23 GFloat::GFloat()
24         : GnomeCB<ControlFloat>("GFloat")
25 {}
26
27
28 GFloat::~GFloat()
29 {}
30
31
32 void GFloat::build()
33 {
34         // Connect the buttons.
35         close_btn()->signal_clicked().connect(SigC::slot(*this, &GFloat::OKClicked));
36         // Manage the buttons state
37         bc().setCancel(close_btn());
38         bc().refresh();
39         connect_signals();
40 }
41
42 void GFloat::apply()
43 {
44         string placement;
45         if (here_definitely()->get_active()) {
46                 placement += 'H';
47         } else {
48                 if (top_of_page()->get_active()) {
49                         placement += 't';
50                 }
51                 if (bottom_of_page()->get_active()) {
52                         placement += 'b';
53                 }
54                 if (page_of_floats()->get_active()) {
55                         placement += 'p';
56                 }
57                 if (here_if_possible()->get_active()) {
58                         placement += 'h';
59                 }
60         }
61         controller().params().placement = placement;
62 }
63
64
65 void GFloat::update()
66 {
67         disconnect_signals();
68         bool top = false;
69         bool bottom = false;
70         bool page = false;
71         bool here = false;
72         bool forcehere = false;
73
74         string placement(controller().params().placement);
75
76         if (contains(placement, "H")) {
77                 forcehere = true;
78         } else {
79                 if (contains(placement, "t")) {
80                         top = true;
81                 }
82                 if (contains(placement, "b")) {
83                         bottom = true;
84                 }
85                 if (contains(placement, "p")) {
86                         page = true;
87                 }
88                 if (contains(placement, "h")) {
89                         here = true;
90                 }
91         }
92
93         top_of_page()->set_active(top);
94         page_of_floats()->set_active(page);
95         bottom_of_page()->set_active(bottom);
96         here_if_possible()->set_active(here);
97         here_definitely()->set_active(forcehere);
98         connect_signals();
99 }
100
101 void GFloat::connect_signals()
102 {
103         conn_top_        = top_of_page()->signal_toggled().connect(
104                 SigC::slot(*this, &GFloat::ApplyClicked)
105                 );
106         conn_bottom_     = bottom_of_page()->signal_toggled().connect(
107                 SigC::slot(*this, &GFloat::ApplyClicked)
108                 );
109         conn_page_       = page_of_floats()->signal_toggled().connect(
110                 SigC::slot(*this, &GFloat::ApplyClicked)
111                 );
112         conn_ifposs_     = here_if_possible()->signal_toggled().connect(
113                 SigC::slot(*this, &GFloat::ApplyClicked)
114                 );
115         conn_definitely_ = here_definitely()->signal_toggled().connect(
116                 SigC::slot(*this, &GFloat::ApplyClicked)
117                 );
118         conn_disable_    = here_definitely()->signal_toggled().connect(
119                 SigC::slot(*this, &GFloat::update_sensitive)
120                 );
121 }
122
123 void GFloat::disconnect_signals()
124 {
125         conn_top_.disconnect();
126         conn_bottom_.disconnect();
127         conn_page_.disconnect();
128         conn_ifposs_.disconnect();
129         conn_definitely_.disconnect();
130         conn_disable_.disconnect();
131 }
132
133 void GFloat::update_sensitive()
134 {
135         if (here_definitely()->get_active())
136                 other_options()->set_sensitive(false);
137         else
138                 other_options()->set_sensitive(true);
139
140 }
141
142 Gtk::HBox * GFloat::other_options() const
143 {
144         return getWidget<Gtk::HBox>("r_other_options");
145 }
146 Gtk::CheckButton * GFloat::page_of_floats() const
147 {
148         return getWidget<Gtk::CheckButton>("r_page_of_floats");
149 }
150 Gtk::CheckButton * GFloat::top_of_page() const
151 {
152         return getWidget<Gtk::CheckButton>("r_top_of_page");
153 }
154 Gtk::CheckButton * GFloat::bottom_of_page() const
155 {
156         return getWidget<Gtk::CheckButton>("r_bottom_of_page");
157 }
158 Gtk::CheckButton * GFloat::here_if_possible() const
159 {
160         return getWidget<Gtk::CheckButton>("r_here_if_possible");
161 }
162 Gtk::RadioButton * GFloat::here_definitely() const
163 {
164         return getWidget<Gtk::RadioButton>("r_here_definitely");
165 }
166
167 Gtk::Button * GFloat::close_btn() const
168 {
169         return getWidget<Gtk::Button>("r_close_btn");
170 }