2 * This file is part of RawTherapee.
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
19 #include <lwbuttonset.h>
21 LWButtonSet::LWButtonSet () : aw(0), ah(0) {
24 LWButtonSet::~LWButtonSet () {
26 for (int i
=0; i
<buttons
.size(); i
++)
30 void LWButtonSet::add (LWButton
* b
) {
32 buttons
.push_back (b
);
35 void LWButtonSet::getMinimalDimensions (int& w
, int& h
) {
38 for (int i
=0; i
<buttons
.size(); i
++) {
40 buttons
[i
]->getSize (bw
, bh
);
47 int LWButtonSet::arrangeButtons (int x
, int y
, int w
, int h
) {
50 getMinimalDimensions (mw
, mh
);
59 for (int i
=0; i
<buttons
.size(); i
++) {
60 LWButton::Alignment halign
, valign
;
62 buttons
[i
]->getSize (bw
, bh
);
63 buttons
[i
]->getAlignment (halign
, valign
);
64 if (halign
== LWButton::Left
) {
68 else if (halign
== LWButton::Right
) {
72 if (valign
== LWButton::Top
)
74 else if (valign
== LWButton::Bottom
)
76 else if (valign
== LWButton::Center
)
78 buttons
[i
]->setPosition (bx
, by
);
86 void LWButtonSet::move (int nx
, int ny
) {
88 for (int i
=0; i
<buttons
.size(); i
++) {
90 buttons
[i
]->getPosition (x
, y
);
91 buttons
[i
]->setPosition (x
+nx
-ax
, y
+ny
-ay
);
98 void LWButtonSet::redraw (Cairo::RefPtr
<Cairo::Context
> context
) {
100 for (int i
=0; i
<buttons
.size(); i
++)
101 buttons
[i
]->redraw (context
);
104 bool LWButtonSet::motionNotify (int x
, int y
) {
107 for (int i
=0; i
<buttons
.size(); i
++) {
108 bool handled
= buttons
[i
]->motionNotify (x
, y
);
109 res
= res
|| handled
;
115 bool LWButtonSet::pressNotify (int x
, int y
) {
118 for (int i
=0; i
<buttons
.size(); i
++) {
119 bool handled
= buttons
[i
]->pressNotify (x
, y
);
120 res
= res
|| handled
;
125 bool LWButtonSet::releaseNotify (int x
, int y
) {
128 for (int i
=0; i
<buttons
.size(); i
++) {
129 bool handled
= buttons
[i
]->releaseNotify (x
, y
);
130 res
= res
|| handled
;
135 bool LWButtonSet::inside (int x
, int y
) {
137 for (int i
=0; i
<buttons
.size(); i
++)
138 if (buttons
[i
]->inside (x
, y
))
143 void LWButtonSet::setButtonListener (LWButtonListener
* bl
) {
145 for (int i
=0; i
<buttons
.size(); i
++)
146 buttons
[i
]->setButtonListener (bl
);
149 void LWButtonSet::getAllocatedDimensions (int& w
, int& h
) {
155 void LWButtonSet::setColors (const Gdk::Color
& bg
, const Gdk::Color
& fg
) {
157 for (int i
=0; i
<buttons
.size(); i
++)
158 buttons
[i
]->setColors (bg
, fg
);
161 Glib::ustring
LWButtonSet::getToolTip (int x
, int y
) {
163 for (int i
=0; i
<buttons
.size(); i
++) {
164 Glib::ustring ttip
= buttons
[i
]->getToolTip (x
, y
);