aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2005-05-02 01:17:08 (GMT)
committerfluxgen <fluxgen>2005-05-02 01:17:08 (GMT)
commitd3362370f5e8f440d2233629cc57e6f355b17b11 (patch)
treef6df824ebb52664c4061afc563f83bc4d116fee1
parent55f62bc5cc64f0b8c41f7db343ecd871c250ae8f (diff)
downloadfluxbox_pavel-d3362370f5e8f440d2233629cc57e6f355b17b11.zip
fluxbox_pavel-d3362370f5e8f440d2233629cc57e6f355b17b11.tar.bz2
cleaning, create and delete tabs with FbWinFrame createTab/removeTab
-rw-r--r--src/FbWinFrame.cc37
-rw-r--r--src/FbWinFrame.hh16
-rw-r--r--src/Window.cc79
3 files changed, 59 insertions, 73 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index a1745ef..fe33c09 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -331,33 +331,41 @@ void FbWinFrame::removeAllButtons() {
331 } 331 }
332} 332}
333 333
334void FbWinFrame::addLabelButton(FbTk::TextButton &btn) { 334FbWinFrame::ButtonId FbWinFrame::createTab(const std::string &title, FbTk::Command *command) {
335 LabelList::iterator found_it = find(m_labelbuttons.begin(), 335 FbTk::TextButton *button = new FbTk::TextButton(label(),
336 m_labelbuttons.end(), 336 theme().font(),
337 &btn); 337 title);
338 button->show();
339 button->setEventMask(ExposureMask | ButtonPressMask |
340 ButtonReleaseMask | ButtonMotionMask |
341 EnterWindowMask);
338 342
339 if (found_it != m_labelbuttons.end()) 343 FbTk::RefCount<FbTk::Command> refcmd(command);
340 return; 344 button->setOnClick(refcmd);
341 345
342 btn.setTextPadding(Fluxbox::instance()->getTabsPadding()); 346 button->setTextPadding(Fluxbox::instance()->getTabsPadding());
343 m_labelbuttons.push_back(&btn); 347 button->setJustify(theme().justify());
348
349 m_labelbuttons.push_back(button);
344 350
345 if (currentLabel() == 0) 351 if (currentLabel() == 0)
346 setLabelButtonFocus(btn); 352 setLabelButtonFocus(*button);
353
354 return button;
347} 355}
348 356
349void FbWinFrame::removeLabelButton(FbTk::TextButton &btn) { 357void FbWinFrame::removeTab(ButtonId btn) {
350 LabelList::iterator erase_it = remove(m_labelbuttons.begin(), 358 LabelList::iterator erase_it = remove(m_labelbuttons.begin(),
351 m_labelbuttons.end(), 359 m_labelbuttons.end(),
352 &btn); 360 btn);
353 if (erase_it == m_labelbuttons.end()) 361 if (erase_it == m_labelbuttons.end())
354 return; 362 return;
355 363
356 if (&btn == m_current_label) 364 if (btn == m_current_label)
357 m_current_label = 0; 365 m_current_label = 0;
358 366
359 m_labelbuttons.erase(erase_it); 367 m_labelbuttons.erase(erase_it);
360 368 delete btn;
361} 369}
362 370
363 371
@@ -550,6 +558,7 @@ void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {
550 m_clientarea.raise(); 558 m_clientarea.raise();
551 win.raise(); 559 win.raise();
552 m_window.showSubwindows(); 560 m_window.showSubwindows();
561
553} 562}
554 563
555bool FbWinFrame::hideTitlebar() { 564bool FbWinFrame::hideTitlebar() {
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh
index 9bff974..1335694 100644
--- a/src/FbWinFrame.hh
+++ b/src/FbWinFrame.hh
@@ -51,6 +51,7 @@ class Texture;
51/// (see: <a href="fluxbox_fbwinframe.png">image</a>) 51/// (see: <a href="fluxbox_fbwinframe.png">image</a>)
52class FbWinFrame:public FbTk::EventHandler { 52class FbWinFrame:public FbTk::EventHandler {
53public: 53public:
54 typedef FbTk::TextButton *ButtonId; ///< defines a button id
54 55
55 /// create a top level window 56 /// create a top level window
56 FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, 57 FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
@@ -81,10 +82,14 @@ public:
81 void resizeForClient(unsigned int width, unsigned int height, int win_gravity=ForgetGravity); 82 void resizeForClient(unsigned int width, unsigned int height, int win_gravity=ForgetGravity);
82 83
83 // for when there needs to be an atomic move+resize operation 84 // for when there needs to be an atomic move+resize operation
84 void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity); 85 void moveResizeForClient(int x, int y,
86 unsigned int width, unsigned int height,
87 bool move = true, bool resize = true, int win_gravity=ForgetGravity);
85 88
86 // can elect to ignore move or resize (mainly for use of move/resize individual functions 89 // can elect to ignore move or resize (mainly for use of move/resize individual functions
87 void moveResize(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity); 90 void moveResize(int x, int y,
91 unsigned int width, unsigned int height,
92 bool move = true, bool resize = true, int win_gravity=ForgetGravity);
88 93
89 /// some outside move/resize happened, and we need to notify all of our windows 94 /// some outside move/resize happened, and we need to notify all of our windows
90 /// in case of transparency 95 /// in case of transparency
@@ -101,10 +106,11 @@ public:
101 void addRightButton(FbTk::Button *btn); 106 void addRightButton(FbTk::Button *btn);
102 /// remove all buttons from titlebar 107 /// remove all buttons from titlebar
103 void removeAllButtons(); 108 void removeAllButtons();
104 /// adds a button to label window 109 /// adds a button to label window with specified title and command
105 void addLabelButton(FbTk::TextButton &btn); 110 ButtonId createTab(const std::string &title, FbTk::Command *cmd);
111 // void addLabelButton(FbTk::TextButton &btn);
106 /// removes a specific button from label window 112 /// removes a specific button from label window
107 void removeLabelButton(FbTk::TextButton &btn); 113 void removeTab(ButtonId id);
108 /// move label button to the left 114 /// move label button to the left
109 void moveLabelButtonLeft(const FbTk::TextButton &btn); 115 void moveLabelButtonLeft(const FbTk::TextButton &btn);
110 /// move label button to the right 116 /// move label button to the right
diff --git a/src/Window.cc b/src/Window.cc
index e899300..50b6f53 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -338,10 +338,9 @@ FluxboxWindow::~FluxboxWindow() {
338 338
339 Client2ButtonMap::iterator it = m_labelbuttons.begin(); 339 Client2ButtonMap::iterator it = m_labelbuttons.begin();
340 Client2ButtonMap::iterator it_end = m_labelbuttons.end(); 340 Client2ButtonMap::iterator it_end = m_labelbuttons.end();
341 for (; it != it_end; ++it) { 341 for (; it != it_end; ++it)
342 frame().removeLabelButton(*(*it).second); 342 frame().removeTab((*it).second);
343 delete (*it).second; 343
344 }
345 m_labelbuttons.clear(); 344 m_labelbuttons.clear();
346 345
347 m_timer.stop(); 346 m_timer.stop();
@@ -420,21 +419,14 @@ void FluxboxWindow::init() {
420 frame().gripRight().setCursor(frame().theme().lowerRightAngleCursor()); 419 frame().gripRight().setCursor(frame().theme().lowerRightAngleCursor());
421 420
422 421
423 FbTk::TextButton *btn = new FbTk::TextButton(frame().label(), 422 FbWinFrame::ButtonId btn = frame().createTab(m_client->title(),
424 frame().theme().font(), 423 new SetClientCmd(*m_client));
425 m_client->title()); 424
426 btn->setJustify(frame().theme().justify());
427 m_labelbuttons[m_client] = btn; 425 m_labelbuttons[m_client] = btn;
428 frame().addLabelButton(*btn);
429 frame().setLabelButtonFocus(*btn); 426 frame().setLabelButtonFocus(*btn);
430 btn->show(); 427
431 FbTk::EventManager &evm = *FbTk::EventManager::instance(); 428 FbTk::EventManager &evm = *FbTk::EventManager::instance();
432 // we need motion notify so we mask it
433 btn->setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask |
434 ButtonMotionMask | EnterWindowMask);
435 429
436 FbTk::RefCount<FbTk::Command> set_client_cmd(new SetClientCmd(*m_client));
437 btn->setOnClick(set_client_cmd);
438 evm.add(*this, btn->window()); // we take care of button events for this 430 evm.add(*this, btn->window()); // we take care of button events for this
439 evm.add(*this, m_client->window()); 431 evm.add(*this, m_client->window());
440 432
@@ -668,11 +660,10 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
668 if (client.fbwindow() != 0) { 660 if (client.fbwindow() != 0) {
669 FluxboxWindow *old_win = client.fbwindow(); // store old window 661 FluxboxWindow *old_win = client.fbwindow(); // store old window
670 662
671 ClientList::iterator client_insert_pos=getClientInsertPosition(x,y); 663 ClientList::iterator client_insert_pos = getClientInsertPosition(x, y);
672 FbTk::TextButton *button_insert_pos=NULL; 664 FbTk::TextButton *button_insert_pos = NULL;
673 if(client_insert_pos!=m_clientlist.end()) 665 if(client_insert_pos != m_clientlist.end())
674 button_insert_pos=m_labelbuttons[*client_insert_pos]; 666 button_insert_pos = m_labelbuttons[*client_insert_pos];
675
676 667
677 // make sure we set new window search for each client 668 // make sure we set new window search for each client
678 ClientList::iterator client_it = old_win->clientList().begin(); 669 ClientList::iterator client_it = old_win->clientList().begin();
@@ -693,29 +684,18 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
693 frame().clientArea().height()); 684 frame().clientArea().height());
694 685
695 (*client_it)->setFluxboxWindow(this); 686 (*client_it)->setFluxboxWindow(this);
687
696 // create a labelbutton for this client and 688 // create a labelbutton for this client and
697 // associate it with the pointer 689 // associate it with the pointer
698 FbTk::TextButton *btn = new FbTk::TextButton(frame().label(), 690 FbWinFrame::ButtonId btn = frame().createTab((*client_it)->title(),
699 frame().theme().font(), 691 new SetClientCmd(*(*client_it)));
700 (*client_it)->title());
701 btn->setJustify(frame().theme().justify());
702 m_labelbuttons[(*client_it)] = btn; 692 m_labelbuttons[(*client_it)] = btn;
703 frame().addLabelButton(*btn); 693
704 if(x >= 0) { 694 //null if we want the new button at the end of the list
705 if(button_insert_pos){ //null if we want the new button at the end of the list 695 if(x >= 0 && button_insert_pos)
706 frame().moveLabelButtonLeftOf(*btn, *button_insert_pos); 696 frame().moveLabelButtonLeftOf(*btn, *button_insert_pos);
707 } 697
708 } 698
709 btn->show();
710 // we need motion notify so we mask it
711 btn->setEventMask(ExposureMask | ButtonPressMask |
712 ButtonReleaseMask | ButtonMotionMask |
713 EnterWindowMask);
714
715
716 FbTk::RefCount<FbTk::Command>
717 set_client_cmd(new SetClientCmd(*(*client_it)));
718 btn->setOnClick(set_client_cmd);
719 evm.add(*this, btn->window()); // we take care of button events for this 699 evm.add(*this, btn->window()); // we take care of button events for this
720 700
721 (*client_it)->saveBlackboxAttribs(m_blackbox_attrib); 701 (*client_it)->saveBlackboxAttribs(m_blackbox_attrib);
@@ -731,25 +711,17 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
731 711
732 } else { // client.fbwindow() == 0 712 } else { // client.fbwindow() == 0
733 // create a labelbutton for this client and associate it with the pointer 713 // create a labelbutton for this client and associate it with the pointer
734 FbTk::TextButton *btn = new FbTk::TextButton(frame().label(), 714 FbWinFrame::ButtonId btn = frame().createTab(client.title(),
735 frame().theme().font(), 715 new SetClientCmd(client));
736 client.title());
737 m_labelbuttons[&client] = btn; 716 m_labelbuttons[&client] = btn;
738 frame().addLabelButton(*btn);
739 btn->show();
740 FbTk::EventManager &evm = *FbTk::EventManager::instance();
741 // we need motion notify so we mask it
742 btn->setEventMask(ExposureMask | ButtonPressMask |
743 ButtonReleaseMask | ButtonMotionMask |
744 EnterWindowMask);
745 717
718 FbTk::EventManager &evm = *FbTk::EventManager::instance();
746 719
747 FbTk::RefCount<FbTk::Command> set_client_cmd(new SetClientCmd(client));
748 btn->setOnClick(set_client_cmd);
749 evm.add(*this, btn->window()); // we take care of button events for this 720 evm.add(*this, btn->window()); // we take care of button events for this
750 721
751 if (&client == focused_win) 722 if (&client == focused_win)
752 was_focused = focused_win; 723 was_focused = focused_win;
724
753 client.setFluxboxWindow(this); 725 client.setFluxboxWindow(this);
754 726
755 client.saveBlackboxAttribs(m_blackbox_attrib); 727 client.saveBlackboxAttribs(m_blackbox_attrib);
@@ -871,9 +843,8 @@ bool FluxboxWindow::removeClient(WinClient &client) {
871 843
872 FbTk::TextButton *label_btn = m_labelbuttons[&client]; 844 FbTk::TextButton *label_btn = m_labelbuttons[&client];
873 if (label_btn != 0) { 845 if (label_btn != 0) {
874 frame().removeLabelButton(*label_btn); 846 frame().removeTab(label_btn);
875 evm.remove(label_btn->window()); 847 evm.remove(label_btn->window());
876 delete label_btn;
877 label_btn = 0; 848 label_btn = 0;
878 } 849 }
879 850