aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-07-28 12:11:57 (GMT)
committerfluxgen <fluxgen>2003-07-28 12:11:57 (GMT)
commit88c3562634b946523b55b9932e4f4044561c7276 (patch)
tree489444a827f4c816caeaf5ce3d59d4723260e675
parent7c76910844e8b6f13fe4b8eda1a37cb636e0e8c4 (diff)
downloadfluxbox-88c3562634b946523b55b9932e4f4044561c7276.zip
fluxbox-88c3562634b946523b55b9932e4f4044561c7276.tar.bz2
using list instead of vector so we can rearrange labels better
-rw-r--r--src/FbWinFrame.cc72
-rw-r--r--src/FbWinFrame.hh12
2 files changed, 64 insertions, 20 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index ada5f00..418efdb 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbWinFrame.cc,v 1.31 2003/07/26 16:17:01 rathnor Exp $ 22// $Id: FbWinFrame.cc,v 1.32 2003/07/28 12:11:57 fluxgen Exp $
23 23
24#include "FbWinFrame.hh" 24#include "FbWinFrame.hh"
25#include "ImageControl.hh" 25#include "ImageControl.hh"
@@ -244,9 +244,9 @@ void FbWinFrame::removeAllButtons() {
244} 244}
245 245
246void FbWinFrame::addLabelButton(FbTk::Button &btn) { 246void FbWinFrame::addLabelButton(FbTk::Button &btn) {
247 ButtonList::iterator found_it = find(m_labelbuttons.begin(), 247 LabelList::iterator found_it = find(m_labelbuttons.begin(),
248 m_labelbuttons.end(), 248 m_labelbuttons.end(),
249 &btn); 249 &btn);
250 250
251 if (found_it != m_labelbuttons.end()) 251 if (found_it != m_labelbuttons.end())
252 return; 252 return;
@@ -255,19 +255,57 @@ void FbWinFrame::addLabelButton(FbTk::Button &btn) {
255} 255}
256 256
257void FbWinFrame::removeLabelButton(FbTk::Button &btn) { 257void FbWinFrame::removeLabelButton(FbTk::Button &btn) {
258 ButtonList::iterator erase_it = remove(m_labelbuttons.begin(), 258 LabelList::iterator erase_it = remove(m_labelbuttons.begin(),
259 m_labelbuttons.end(), 259 m_labelbuttons.end(),
260 &btn); 260 &btn);
261 if (erase_it == m_labelbuttons.end()) 261 if (erase_it == m_labelbuttons.end())
262 return; 262 return;
263 263
264 m_labelbuttons.erase(erase_it); 264 m_labelbuttons.erase(erase_it);
265} 265}
266 266
267void FbWinFrame::setLabelButtonFocus(FbTk::Button &btn) { 267
268 ButtonList::iterator it = find(m_labelbuttons.begin(), 268void FbWinFrame::moveLabelButtonLeft(const FbTk::Button &btn) {
269 LabelList::iterator it = find(m_labelbuttons.begin(),
269 m_labelbuttons.end(), 270 m_labelbuttons.end(),
270 &btn); 271 &btn);
272 // make sure we found it and we're not at the begining
273 if (it == m_labelbuttons.end() || it == m_labelbuttons.begin())
274 return;
275
276 LabelList::iterator new_pos = it;
277 new_pos--;
278 FbTk::Button *item = *it;
279 // remove from list
280 m_labelbuttons.erase(it);
281 // insert on the new place
282 m_labelbuttons.insert(new_pos, item);
283 // update titlebar
284 redrawTitle();
285}
286
287void FbWinFrame::moveLabelButtonRight(const FbTk::Button &btn) {
288 LabelList::iterator it = find(m_labelbuttons.begin(),
289 m_labelbuttons.end(),
290 &btn);
291 // make sure we found it and we're not at the last item
292 if (it == m_labelbuttons.end() || *it == m_labelbuttons.back())
293 return;
294
295 FbTk::Button *item = *it;
296 // remove from list
297 LabelList::iterator new_pos = m_labelbuttons.erase(it);
298 new_pos++;
299 // insert on the new place
300 m_labelbuttons.insert(new_pos, item);
301 // update titlebar
302 redrawTitle();
303}
304
305void FbWinFrame::setLabelButtonFocus(FbTk::Button &btn) {
306 LabelList::iterator it = find(m_labelbuttons.begin(),
307 m_labelbuttons.end(),
308 &btn);
271 if (it == m_labelbuttons.end()) 309 if (it == m_labelbuttons.end())
272 return; 310 return;
273 311
@@ -410,8 +448,8 @@ void FbWinFrame::removeEventHandler() {
410 448
411void FbWinFrame::buttonPressEvent(XButtonEvent &event) { 449void FbWinFrame::buttonPressEvent(XButtonEvent &event) {
412 // we can ignore which window the event was generated for 450 // we can ignore which window the event was generated for
413 ButtonList::iterator btn_it = m_labelbuttons.begin(); 451 LabelList::iterator btn_it = m_labelbuttons.begin();
414 ButtonList::iterator btn_it_end = m_labelbuttons.end(); 452 LabelList::iterator btn_it_end = m_labelbuttons.end();
415 for (; btn_it != btn_it_end; ++btn_it) { 453 for (; btn_it != btn_it_end; ++btn_it) {
416 if ((*btn_it)->window() == event.window) { 454 if ((*btn_it)->window() == event.window) {
417 (*btn_it)->buttonPressEvent(event); 455 (*btn_it)->buttonPressEvent(event);
@@ -434,8 +472,8 @@ void FbWinFrame::buttonPressEvent(XButtonEvent &event) {
434void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { 472void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) {
435 // we can ignore which window the event was generated for 473 // we can ignore which window the event was generated for
436 474
437 ButtonList::iterator btn_it = m_labelbuttons.begin(); 475 LabelList::iterator btn_it = m_labelbuttons.begin();
438 ButtonList::iterator btn_it_end = m_labelbuttons.end(); 476 LabelList::iterator btn_it_end = m_labelbuttons.end();
439 for (; btn_it != btn_it_end; ++btn_it) { 477 for (; btn_it != btn_it_end; ++btn_it) {
440 if ((*btn_it)->window() == event.window) { 478 if ((*btn_it)->window() == event.window) {
441 (*btn_it)->buttonReleaseEvent(event); 479 (*btn_it)->buttonReleaseEvent(event);
@@ -574,8 +612,8 @@ void FbWinFrame::redrawTitle() {
574 int border_width = m_labelbuttons.size() != 0 ? 612 int border_width = m_labelbuttons.size() != 0 ?
575 m_labelbuttons.front()->window().borderWidth() : 0; 613 m_labelbuttons.front()->window().borderWidth() : 0;
576 614
577 ButtonList::iterator btn_it = m_labelbuttons.begin(); 615 LabelList::iterator btn_it = m_labelbuttons.begin();
578 ButtonList::iterator btn_it_end = m_labelbuttons.end(); 616 LabelList::iterator btn_it_end = m_labelbuttons.end();
579 for (unsigned int last_x = 0; 617 for (unsigned int last_x = 0;
580 btn_it != btn_it_end; 618 btn_it != btn_it_end;
581 ++btn_it, last_x += button_width + border_width) { 619 ++btn_it, last_x += button_width + border_width) {
@@ -888,8 +926,8 @@ void FbWinFrame::renderLabelButtons() {
888 getCurrentFocusPixmap(label_pm, not_used_pm, 926 getCurrentFocusPixmap(label_pm, not_used_pm,
889 label_color, not_used_color); 927 label_color, not_used_color);
890 928
891 ButtonList::iterator btn_it = m_labelbuttons.begin(); 929 LabelList::iterator btn_it = m_labelbuttons.begin();
892 ButtonList::iterator btn_it_end = m_labelbuttons.end(); 930 LabelList::iterator btn_it_end = m_labelbuttons.end();
893 for (; btn_it != btn_it_end; ++btn_it) { 931 for (; btn_it != btn_it_end; ++btn_it) {
894 932
895 (*btn_it)->setGC(theme().labelTextFocusGC()); 933 (*btn_it)->setGC(theme().labelTextFocusGC());
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh
index 2632311..1b7b197 100644
--- a/src/FbWinFrame.hh
+++ b/src/FbWinFrame.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbWinFrame.hh,v 1.10 2003/07/26 16:17:01 rathnor Exp $ 22// $Id: FbWinFrame.hh,v 1.11 2003/07/28 12:11:57 fluxgen Exp $
23 23
24#ifndef FBWINFRAME_HH 24#ifndef FBWINFRAME_HH
25#define FBWINFRAME_HH 25#define FBWINFRAME_HH
@@ -32,6 +32,7 @@
32#include "FbPixmap.hh" 32#include "FbPixmap.hh"
33 33
34#include <vector> 34#include <vector>
35#include <list>
35#include <string> 36#include <string>
36#include <memory> 37#include <memory>
37 38
@@ -93,6 +94,10 @@ public:
93 void addLabelButton(FbTk::Button &btn); 94 void addLabelButton(FbTk::Button &btn);
94 /// removes a specific button from label window 95 /// removes a specific button from label window
95 void removeLabelButton(FbTk::Button &btn); 96 void removeLabelButton(FbTk::Button &btn);
97 /// move label button to the left
98 void moveLabelButtonLeft(const FbTk::Button &btn);
99 /// move label button to the right
100 void moveLabelButtonRight(const FbTk::Button &btn);
96 /// which button is to be rendered focused 101 /// which button is to be rendered focused
97 void setLabelButtonFocus(FbTk::Button &btn); 102 void setLabelButtonFocus(FbTk::Button &btn);
98 /// attach a client window for client area 103 /// attach a client window for client area
@@ -208,8 +213,9 @@ private:
208 typedef std::vector<FbTk::Button *> ButtonList; 213 typedef std::vector<FbTk::Button *> ButtonList;
209 ButtonList m_buttons_left, ///< buttons to the left 214 ButtonList m_buttons_left, ///< buttons to the left
210 m_buttons_right; ///< buttons to the right 215 m_buttons_right; ///< buttons to the right
211 ButtonList m_labelbuttons; ///< holds buttons inside label window 216 typedef std::list<FbTk::Button *> LabelList;
212 FbTk::Button *m_current_label; ///< which button is focused at the moment 217 LabelList m_labelbuttons; ///< holds label buttons inside label window
218 FbTk::Button *m_current_label; ///< which client button is focused at the moment
213 std::string m_titletext; ///< text to be displayed int m_label 219 std::string m_titletext; ///< text to be displayed int m_label
214 int m_bevel; ///< bevel between titlebar items and titlebar 220 int m_bevel; ///< bevel between titlebar items and titlebar
215 bool m_use_titlebar; ///< if we should use titlebar 221 bool m_use_titlebar; ///< if we should use titlebar