aboutsummaryrefslogtreecommitdiff
path: root/src/FbWinFrame.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2006-03-20 11:31:24 (GMT)
committersimonb <simonb>2006-03-20 11:31:24 (GMT)
commitf2d3fff4d4db7677814379139dcec3e31fc68047 (patch)
tree95bd9dc99986104613acc37945895b0812e63801 /src/FbWinFrame.cc
parenteba0040373179cc6d34f8ee132209f2fa01c2889 (diff)
downloadfluxbox_pavel-f2d3fff4d4db7677814379139dcec3e31fc68047.zip
fluxbox_pavel-f2d3fff4d4db7677814379139dcec3e31fc68047.tar.bz2
external tabs
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r--src/FbWinFrame.cc349
1 files changed, 272 insertions, 77 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 8e7c455..ec74f4b 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -25,13 +25,13 @@
25 25
26#include "FbTk/ImageControl.hh" 26#include "FbTk/ImageControl.hh"
27#include "FbTk/EventManager.hh" 27#include "FbTk/EventManager.hh"
28#include "FbTk/TextButton.hh"
29#include "FbTk/App.hh" 28#include "FbTk/App.hh"
30#include "FbTk/SimpleCommand.hh" 29#include "FbTk/SimpleCommand.hh"
31#include "FbTk/Compose.hh" 30#include "FbTk/Compose.hh"
32#include "FbTk/Transparent.hh" 31#include "FbTk/Transparent.hh"
33#include "CompareWindow.hh" 32#include "CompareWindow.hh"
34#include "FbWinFrameTheme.hh" 33#include "FbWinFrameTheme.hh"
34#include "Screen.hh"
35 35
36#include "Container.hh" 36#include "Container.hh"
37 37
@@ -46,24 +46,22 @@
46 46
47using namespace std; 47using namespace std;
48 48
49FbWinFrame::FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, 49FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
50 FbTk::XLayer &layer,
50 int x, int y, 51 int x, int y,
51 unsigned int width, unsigned int height): 52 unsigned int width, unsigned int height):
53 m_screen(screen),
52 m_theme(theme), 54 m_theme(theme),
53 m_imagectrl(imgctrl), 55 m_imagectrl(imgctrl),
54 m_window(theme.screenNum(), x, y, width, height, ButtonPressMask | ButtonReleaseMask | 56 m_window(theme.screenNum(), x, y, width, height, ButtonPressMask | ButtonReleaseMask |
55 ButtonMotionMask | EnterWindowMask, true), 57 ButtonMotionMask | EnterWindowMask, true),
58 m_layeritem(window(), layer),
56 m_titlebar(m_window, 0, 0, 100, 16, 59 m_titlebar(m_window, 0, 0, 100, 16,
57 ButtonPressMask | ButtonReleaseMask | 60 ButtonPressMask | ButtonReleaseMask |
58 ButtonMotionMask | ExposureMask | 61 ButtonMotionMask | ExposureMask |
59 EnterWindowMask | LeaveWindowMask), 62 EnterWindowMask | LeaveWindowMask),
60 m_tab_container(m_titlebar), 63 m_tab_container(m_titlebar),
61/* 64 m_label(m_titlebar, m_theme.font(), ""),
62 m_label(m_titlebar, 0, 0, 100, 16,
63 ButtonPressMask | ButtonReleaseMask |
64 ButtonMotionMask | ExposureMask |
65 EnterWindowMask | LeaveWindowMask),
66*/
67 m_handle(m_window, 0, 0, 100, 5, 65 m_handle(m_window, 0, 0, 100, 5,
68 ButtonPressMask | ButtonReleaseMask | 66 ButtonPressMask | ButtonReleaseMask |
69 ButtonMotionMask | ExposureMask | 67 ButtonMotionMask | ExposureMask |
@@ -82,11 +80,12 @@ FbWinFrame::FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
82 EnterWindowMask | LeaveWindowMask), 80 EnterWindowMask | LeaveWindowMask),
83 m_bevel(1), 81 m_bevel(1),
84 m_use_titlebar(true), 82 m_use_titlebar(true),
83 m_use_tabs(true),
85 m_use_handle(true), 84 m_use_handle(true),
86 m_focused(false), 85 m_focused(false),
87 m_visible(false), 86 m_visible(false),
88 m_button_pm(0), 87 m_button_pm(0),
89 m_tabmode(INTERNAL), // TODO: configurable default (on compile, for backwards compat) 88 m_tabmode(NOTSET),
90 m_need_render(true), 89 m_need_render(true),
91 m_themelistener(*this), 90 m_themelistener(*this),
92 m_shape(new Shape(m_window, theme.shapePlace())) { 91 m_shape(new Shape(m_window, theme.shapePlace())) {
@@ -116,8 +115,78 @@ bool FbWinFrame::setOnClickTitlebar(FbTk::RefCount<FbTk::Command> &ref, int mous
116 return true; 115 return true;
117} 116}
118 117
118bool FbWinFrame::setTabMode(TabMode tabmode) {
119 if (m_tabmode == tabmode)
120 return false;
121
122 bool ret = true;
123
124 // setting tabmode to notset forces it through when
125 // something is likely to change
126 if (tabmode == NOTSET)
127 tabmode = m_tabmode;
128
129 // reparent tab container
130 if (tabmode == EXTERNAL) {
131
132 m_tab_container.setBorderWidth(m_window.borderWidth());
133 m_tab_container.setBorderColor(theme().border().color());
134 m_tab_container.setEventMask(
135 ButtonPressMask | ButtonReleaseMask |
136 ButtonMotionMask | ExposureMask |
137 EnterWindowMask | LeaveWindowMask);
138
139 XGrabButton(m_tab_container.display(), Button1, AnyModifier,
140 m_tab_container.window(), True, ButtonPressMask,
141 GrabModeSync, GrabModeSync, None, None);
142 XUngrabButton(m_tab_container.display(), Button1, Mod1Mask|Mod2Mask|Mod3Mask, m_tab_container.window());
143
144 if (m_tab_container.parent()->window() != m_screen.rootWindow().window()) {
145 int tabx = x();
146 // one borderwidth only, so the adjacent borders overlab
147 int taby = y() - m_tab_container.height() - m_tab_container.borderWidth();
148 m_tab_container.reparent(m_screen.rootWindow(), tabx, taby);
149 m_layeritem.addWindow(m_tab_container);
150 }
151
152 m_tab_container.setAlignment(Container::LEFT);
153 m_tab_container.setMaxSizePerClient(64); //!!TODO make this a setting
154 m_tab_container.setMaxTotalSize(window().width());
155
156 // TODO: tab position
157 if (m_use_tabs && m_visible)
158 m_tab_container.show();
159 else {
160 ret = false;
161 m_tab_container.hide();
162 }
163
164 } else {
165 if (m_tab_container.parent()->window() == m_screen.rootWindow().window()) {
166 m_layeritem.removeWindow(m_tab_container);
167 m_tab_container.reparent(m_titlebar, m_label.x(), m_label.y());
168 m_tab_container.raise();
169 }
170 m_tab_container.setBorderWidth(0);
171 m_tab_container.setMaxTotalSize(0);
172 m_tab_container.setMaxSizePerClient(0);
173 m_tab_container.setAlignment(Container::RELATIVE);
174 if (!m_use_tabs)
175 m_tab_container.show();
176 else
177 ret = false;
178// reconfigure();
179 }
180
181 m_tabmode = tabmode;
182 return true;
183}
184
119void FbWinFrame::hide() { 185void FbWinFrame::hide() {
120 m_window.hide(); 186 m_window.hide();
187 if (m_tabmode == EXTERNAL && m_use_tabs)
188 m_tab_container.hide();
189
121 m_visible = false; 190 m_visible = false;
122} 191}
123 192
@@ -130,6 +199,9 @@ void FbWinFrame::show() {
130 clearAll(); 199 clearAll();
131 } 200 }
132 201
202 if (m_tabmode == EXTERNAL && m_use_tabs)
203 m_tab_container.show();
204
133 m_window.showSubwindows(); 205 m_window.showSubwindows();
134 m_window.show(); 206 m_window.show();
135} 207}
@@ -214,8 +286,28 @@ void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int heigh
214 m_window.resize(width, height); 286 m_window.resize(width, height);
215 } 287 }
216 288
217 if (resize) 289 if (move)
290 alignTabs();
291
292 if (resize) {
293 if (m_tabmode == EXTERNAL)
294 m_tab_container.setMaxTotalSize(width);
218 reconfigure(); 295 reconfigure();
296 }
297}
298
299void FbWinFrame::quietMoveResize(int x, int y,
300 unsigned int width, unsigned int height) {
301 m_window.moveResize(x, y, width, height);
302 if (m_tabmode == EXTERNAL) {
303 m_tab_container.setMaxTotalSize(width);
304 alignTabs();
305 }
306}
307
308void FbWinFrame::alignTabs() {
309 if (m_tabmode == EXTERNAL)
310 m_tab_container.move(m_window.x(), m_window.y() - m_tab_container.height() - m_tab_container.borderWidth());
219} 311}
220 312
221void FbWinFrame::notifyMoved(bool clear) { 313void FbWinFrame::notifyMoved(bool clear) {
@@ -224,10 +316,16 @@ void FbWinFrame::notifyMoved(bool clear) {
224 if (alpha == 255) 316 if (alpha == 255)
225 return; 317 return;
226 318
319 if (m_tabmode == EXTERNAL && m_use_tabs || m_use_titlebar) {
320 m_tab_container.parentMoved();
321 m_tab_container.for_each(mem_fun(&FbTk::Button::parentMoved));
322 }
323
227 if (m_use_titlebar) { 324 if (m_use_titlebar) {
325 if (m_tabmode == INTERNAL)
326 m_label.parentMoved();
327
228 m_titlebar.parentMoved(); 328 m_titlebar.parentMoved();
229 //m_label.parentMoved();
230 m_tab_container.parentMoved();
231 329
232 for_each(m_buttons_left.begin(), 330 for_each(m_buttons_left.begin(),
233 m_buttons_left.end(), 331 m_buttons_left.end(),
@@ -235,7 +333,6 @@ void FbWinFrame::notifyMoved(bool clear) {
235 for_each(m_buttons_right.begin(), 333 for_each(m_buttons_right.begin(),
236 m_buttons_right.end(), 334 m_buttons_right.end(),
237 mem_fun(&FbTk::Button::parentMoved)); 335 mem_fun(&FbTk::Button::parentMoved));
238 m_tab_container.for_each(mem_fun(&FbTk::Button::parentMoved));
239 } 336 }
240 337
241 if (m_use_handle) { 338 if (m_use_handle) {
@@ -246,7 +343,8 @@ void FbWinFrame::notifyMoved(bool clear) {
246 343
247 if (clear && (m_use_handle || m_use_titlebar)) { 344 if (clear && (m_use_handle || m_use_titlebar)) {
248 clearAll(); 345 clearAll();
249 } 346 } else if (clear && m_tabmode == EXTERNAL && m_use_tabs)
347 m_tab_container.clear();
250} 348}
251 349
252void FbWinFrame::clearAll() { 350void FbWinFrame::clearAll() {
@@ -260,7 +358,8 @@ void FbWinFrame::clearAll() {
260 for_each(m_buttons_right.begin(), 358 for_each(m_buttons_right.begin(),
261 m_buttons_right.end(), 359 m_buttons_right.end(),
262 mem_fun(&FbTk::Button::clear)); 360 mem_fun(&FbTk::Button::clear));
263 } 361 } else if (m_tabmode == EXTERNAL && m_use_tabs)
362 m_tab_container.clear();
264 363
265 if (m_use_handle) { 364 if (m_use_handle) {
266 m_handle.clear(); 365 m_handle.clear();
@@ -293,6 +392,7 @@ void FbWinFrame::setFocus(bool newvalue) {
293 392
294 applyTitlebar(); 393 applyTitlebar();
295 applyHandles(); 394 applyHandles();
395 applyTabContainer();
296 clearAll(); 396 clearAll();
297} 397}
298 398
@@ -416,6 +516,7 @@ void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) {
416 applyUnfocusLabel(*m_current_label); 516 applyUnfocusLabel(*m_current_label);
417 517
418 m_current_label = &btn; // current focused button 518 m_current_label = &btn; // current focused button
519 m_label.setText(btn.text());
419 520
420 if (m_focused) 521 if (m_focused)
421 applyFocusLabel(*m_current_label); 522 applyFocusLabel(*m_current_label);
@@ -451,11 +552,35 @@ void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {
451 XChangeWindowAttributes(win.display(), win.window(), CWEventMask|CWDontPropagate, &attrib_set); 552 XChangeWindowAttributes(win.display(), win.window(), CWEventMask|CWDontPropagate, &attrib_set);
452 553
453 m_clientarea.raise(); 554 m_clientarea.raise();
555 win.show();
454 win.raise(); 556 win.raise();
455 m_window.showSubwindows(); 557 m_window.showSubwindows();
456 558
457} 559}
458 560
561bool FbWinFrame::hideTabs() {
562 if (m_tabmode == INTERNAL || !m_use_tabs) {
563 m_use_tabs = false;
564 return false;
565 }
566
567 m_use_tabs = false;
568 m_tab_container.hide();
569 return true;
570}
571
572bool FbWinFrame::showTabs() {
573 if (m_tabmode == INTERNAL || m_use_tabs) {
574 m_use_tabs = true;
575 return false; // nothing changed
576 }
577
578 m_use_tabs = true;
579 if (m_visible)
580 m_tab_container.show();
581 return true;
582}
583
459bool FbWinFrame::hideTitlebar() { 584bool FbWinFrame::hideTitlebar() {
460 if (!m_use_titlebar) 585 if (!m_use_titlebar)
461 return false; 586 return false;
@@ -484,6 +609,7 @@ bool FbWinFrame::showTitlebar() {
484 // only add one borderwidth (as the other border is still the "top" border) 609 // only add one borderwidth (as the other border is still the "top" border)
485 m_window.resize(m_window.width(), m_window.height() + m_titlebar.height() + 610 m_window.resize(m_window.width(), m_window.height() + m_titlebar.height() +
486 m_titlebar.borderWidth()); 611 m_titlebar.borderWidth());
612
487 return true; 613 return true;
488 614
489} 615}
@@ -555,6 +681,7 @@ void FbWinFrame::setEventHandler(FbTk::EventHandler &evh) {
555 681
556 FbTk::EventManager &evm = *FbTk::EventManager::instance(); 682 FbTk::EventManager &evm = *FbTk::EventManager::instance();
557 evm.add(evh, m_tab_container); 683 evm.add(evh, m_tab_container);
684 evm.add(evh, m_label);
558 evm.add(evh, m_titlebar); 685 evm.add(evh, m_titlebar);
559 evm.add(evh, m_handle); 686 evm.add(evh, m_handle);
560 evm.add(evh, m_grip_right); 687 evm.add(evh, m_grip_right);
@@ -569,6 +696,7 @@ void FbWinFrame::setEventHandler(FbTk::EventHandler &evh) {
569void FbWinFrame::removeEventHandler() { 696void FbWinFrame::removeEventHandler() {
570 FbTk::EventManager &evm = *FbTk::EventManager::instance(); 697 FbTk::EventManager &evm = *FbTk::EventManager::instance();
571 evm.remove(m_tab_container); 698 evm.remove(m_tab_container);
699 evm.remove(m_label);
572 evm.remove(m_titlebar); 700 evm.remove(m_titlebar);
573 evm.remove(m_handle); 701 evm.remove(m_handle);
574 evm.remove(m_grip_right); 702 evm.remove(m_grip_right);
@@ -579,6 +707,9 @@ void FbWinFrame::removeEventHandler() {
579 707
580void FbWinFrame::buttonPressEvent(XButtonEvent &event) { 708void FbWinFrame::buttonPressEvent(XButtonEvent &event) {
581 // we can ignore which window the event was generated for 709 // we can ignore which window the event was generated for
710 if (event.window == m_label.window() && m_current_label)
711 event.window = m_current_label->window();
712
582 m_tab_container.tryButtonPressEvent(event); 713 m_tab_container.tryButtonPressEvent(event);
583 if (event.window == m_grip_right.window() || 714 if (event.window == m_grip_right.window() ||
584 event.window == m_grip_left.window() || 715 event.window == m_grip_left.window() ||
@@ -595,6 +726,8 @@ void FbWinFrame::buttonPressEvent(XButtonEvent &event) {
595 726
596void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { 727void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) {
597 // we can ignore which window the event was generated for 728 // we can ignore which window the event was generated for
729 if (event.window == m_label.window() && m_current_label)
730 event.window = m_current_label->window();
598 731
599 // we continue even if a button got the event 732 // we continue even if a button got the event
600 m_tab_container.tryButtonReleaseEvent(event); 733 m_tab_container.tryButtonReleaseEvent(event);
@@ -626,6 +759,8 @@ void FbWinFrame::exposeEvent(XExposeEvent &event) {
626 m_titlebar.clearArea(event.x, event.y, event.width, event.height); 759 m_titlebar.clearArea(event.x, event.y, event.width, event.height);
627 } else if (m_tab_container == event.window) { 760 } else if (m_tab_container == event.window) {
628 m_tab_container.clearArea(event.x, event.y, event.width, event.height); 761 m_tab_container.clearArea(event.x, event.y, event.width, event.height);
762 } else if (m_label == event.window) {
763 m_label.clearArea(event.x, event.y, event.width, event.height);
629 } else if (m_handle == event.window) { 764 } else if (m_handle == event.window) {
630 m_handle.clearArea(event.x, event.y, event.width, event.height); 765 m_handle.clearArea(event.x, event.y, event.width, event.height);
631 } else if (m_grip_left == event.window) { 766 } else if (m_grip_left == event.window) {
@@ -696,6 +831,8 @@ void FbWinFrame::reconfigure() {
696 } else 831 } else
697 m_titlebar.lower(); 832 m_titlebar.lower();
698 833
834 if (m_tabmode == EXTERNAL)
835 m_tab_container.resize(m_tab_container.width(), buttonHeight());
699 836
700 // leave client+grips alone if we're shaded (it'll get fixed when we unshade) 837 // leave client+grips alone if we're shaded (it'll get fixed when we unshade)
701 if (!m_shaded) { 838 if (!m_shaded) {
@@ -788,7 +925,7 @@ void FbWinFrame::redrawTitlebar() {
788 925
789 if (isVisible()) { 926 if (isVisible()) {
790 m_tab_container.clear(); 927 m_tab_container.clear();
791 //m_label.clear(); 928 m_label.clear();
792 m_titlebar.clear(); 929 m_titlebar.clear();
793 } 930 }
794} 931}
@@ -825,16 +962,23 @@ void FbWinFrame::reconfigureTitlebar() {
825 next_x += m_bevel; 962 next_x += m_bevel;
826 963
827 // space left on titlebar between left and right buttons 964 // space left on titlebar between left and right buttons
828 unsigned int space_left = m_titlebar.width() - next_x; 965 int space_left = m_titlebar.width() - next_x;
966
829 if (!m_buttons_right.empty()) 967 if (!m_buttons_right.empty())
830 space_left -= m_buttons_right.size() * (button_size + m_bevel); 968 space_left -= m_buttons_right.size() * (button_size + m_bevel);
831 969
832 space_left -= m_bevel; 970 space_left -= m_bevel;
833
834 m_tab_container.moveResize(next_x, m_bevel,
835 space_left, button_size);
836 971
837 next_x += m_tab_container.width() + m_bevel;; 972 if (space_left <= 0)
973 space_left = 1;
974
975 m_label.moveResize(next_x, m_bevel, space_left, button_size);
976
977 if (m_tabmode == INTERNAL)
978 m_tab_container.moveResize(next_x, m_bevel,
979 space_left, button_size);
980
981 next_x += m_label.width() + m_bevel;
838 982
839 // finaly set new buttons to the right 983 // finaly set new buttons to the right
840 for (size_t i=0; i < m_buttons_right.size(); 984 for (size_t i=0; i < m_buttons_right.size();
@@ -851,13 +995,13 @@ void FbWinFrame::renderAll() {
851 995
852 renderTitlebar(); 996 renderTitlebar();
853 renderHandles(); 997 renderHandles();
854 renderLabelButtons(); 998 renderTabContainer();
855} 999}
856 1000
857void FbWinFrame::applyAll() { 1001void FbWinFrame::applyAll() {
858 applyTitlebar(); 1002 applyTitlebar();
859 applyHandles(); 1003 applyHandles();
860 applyLabelButtons(); 1004 applyTabContainer();
861} 1005}
862 1006
863void FbWinFrame::renderTitlebar() { 1007void FbWinFrame::renderTitlebar() {
@@ -878,18 +1022,47 @@ void FbWinFrame::renderTitlebar() {
878 m_title_unfocused_pm, 1022 m_title_unfocused_pm,
879 m_titlebar.width(), m_titlebar.height()); 1023 m_titlebar.width(), m_titlebar.height());
880 1024
1025 //!! TODO: don't render label if internal tabs
1026
881 render(m_theme.labelFocusTexture(), m_label_focused_color, 1027 render(m_theme.labelFocusTexture(), m_label_focused_color,
882 m_label_focused_pm, 1028 m_label_focused_pm,
883 m_tab_container.width(), m_tab_container.height()); 1029 m_label.width(), m_label.height());
884
885 1030
886 render(m_theme.labelUnfocusTexture(), m_label_unfocused_color, 1031 render(m_theme.labelUnfocusTexture(), m_label_unfocused_color,
887 m_label_unfocused_pm, 1032 m_label_unfocused_pm,
888 m_tab_container.width(), m_tab_container.height()); 1033 m_label.width(), m_label.height());
889 1034
890 renderButtons(); 1035 renderButtons();
891} 1036}
892 1037
1038void FbWinFrame::renderTabContainer() {
1039 if (!isVisible()) {
1040 m_need_render = true;
1041 return;
1042 }
1043
1044 render(m_theme.labelFocusTexture(), m_tabcontainer_focused_color,
1045 m_tabcontainer_focused_pm,
1046 m_tab_container.width(), m_tab_container.height());
1047
1048 render(m_theme.labelUnfocusTexture(), m_tabcontainer_unfocused_color,
1049 m_tabcontainer_unfocused_pm,
1050 m_tab_container.width(), m_tab_container.height());
1051
1052 render(m_theme.labelFocusTexture(), m_labelbutton_focused_color,
1053 m_labelbutton_focused_pm,
1054 m_tab_container.width(), m_tab_container.height());
1055
1056 render(m_theme.labelUnfocusTexture(), m_labelbutton_unfocused_color,
1057 m_labelbutton_unfocused_pm,
1058 m_tab_container.width(), m_tab_container.height());
1059
1060 render(m_theme.labelActiveTexture(), m_labelbutton_active_color,
1061 m_labelbutton_active_pm,
1062 m_tab_container.width(), m_tab_container.height());
1063
1064}
1065
893void FbWinFrame::applyTitlebar() { 1066void FbWinFrame::applyTitlebar() {
894 1067
895 // set up pixmaps for titlebar windows 1068 // set up pixmaps for titlebar windows
@@ -902,13 +1075,13 @@ void FbWinFrame::applyTitlebar() {
902 1075
903 unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 1076 unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha());
904 m_titlebar.setAlpha(alpha); 1077 m_titlebar.setAlpha(alpha);
905 m_tab_container.setAlpha(alpha); 1078 m_label.setAlpha(alpha);
906 1079
907 if (label_pm != 0) 1080 if (label_pm != 0)
908 m_tab_container.setBackgroundPixmap(label_pm); 1081 m_label.setBackgroundPixmap(label_pm);
909 else 1082 else
910 m_tab_container.setBackgroundColor(label_color); 1083 m_label.setBackgroundColor(label_color);
911 1084
912 if (title_pm != 0) 1085 if (title_pm != 0)
913 m_titlebar.setBackgroundPixmap(title_pm); 1086 m_titlebar.setBackgroundPixmap(title_pm);
914 else 1087 else
@@ -1036,6 +1209,7 @@ void FbWinFrame::init() {
1036 // clear pixmaps 1209 // clear pixmaps
1037 m_title_focused_pm = m_title_unfocused_pm = 0; 1210 m_title_focused_pm = m_title_unfocused_pm = 0;
1038 m_label_focused_pm = m_label_unfocused_pm = 0; 1211 m_label_focused_pm = m_label_unfocused_pm = 0;
1212 m_tabcontainer_focused_pm = m_tabcontainer_unfocused_pm = 0;
1039 m_labelbutton_focused_pm = m_labelbutton_unfocused_pm = m_labelbutton_active_pm = 0; 1213 m_labelbutton_focused_pm = m_labelbutton_unfocused_pm = m_labelbutton_active_pm = 0;
1040 m_handle_focused_pm = m_handle_unfocused_pm = 0; 1214 m_handle_focused_pm = m_handle_unfocused_pm = 0;
1041 m_button_pm = m_button_unfocused_pm = m_button_pressed_pm = 0; 1215 m_button_pm = m_button_unfocused_pm = m_button_pressed_pm = 0;
@@ -1045,8 +1219,20 @@ void FbWinFrame::init() {
1045 m_button_size = 26; 1219 m_button_size = 26;
1046 1220
1047 m_clientarea.setBorderWidth(0); 1221 m_clientarea.setBorderWidth(0);
1222 m_label.setBorderWidth(0);
1048 m_shaded = false; 1223 m_shaded = false;
1224
1225 // TODO: configurable default (on compile, for backwards compat)
1226// setTabMode(EXTERNAL);
1227 setTabMode(INTERNAL);
1228
1229 m_label.setEventMask(ExposureMask | ButtonPressMask |
1230 ButtonReleaseMask | ButtonMotionMask |
1231 EnterWindowMask);
1232 m_label.show();
1233
1049 m_tab_container.show(); 1234 m_tab_container.show();
1235 m_tab_container.raise();
1050 1236
1051 showHandle(); 1237 showHandle();
1052 showTitlebar(); 1238 showTitlebar();
@@ -1104,62 +1290,52 @@ void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,
1104void FbWinFrame::getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm, 1290void FbWinFrame::getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm,
1105 FbTk::Color &label_color, FbTk::Color &title_color) { 1291 FbTk::Color &label_color, FbTk::Color &title_color) {
1106 if (m_focused) { 1292 if (m_focused) {
1107 if (m_labelbutton_focused_pm != 0) 1293 if (m_label_focused_pm != 0)
1108 label_pm = m_labelbutton_focused_pm; 1294 label_pm = m_label_focused_pm;
1109 else 1295 else
1110 label_color = m_labelbutton_focused_color; 1296 label_color = m_label_focused_color;
1111 1297
1112 if (m_title_focused_pm != 0) 1298 if (m_title_focused_pm != 0)
1113 title_pm = m_title_focused_pm; 1299 title_pm = m_title_focused_pm;
1114 else 1300 else
1115 title_color = m_title_focused_color; 1301 title_color = m_title_focused_color;
1116
1117 } else { 1302 } else {
1118 getActiveLabelPixmap(label_pm, title_pm, 1303 if (m_label_unfocused_pm != 0)
1119 label_color, title_color); 1304 label_pm = m_label_unfocused_pm;
1120 } 1305 else
1121 1306 label_color = m_label_unfocused_color;
1307
1308 if (m_title_unfocused_pm != 0)
1309 title_pm = m_title_unfocused_pm;
1310 else
1311 title_color = m_title_unfocused_color;
1312 }
1122} 1313}
1123 1314
1124// only called if not focused 1315void FbWinFrame::applyTabContainer() {
1125void FbWinFrame::getActiveLabelPixmap(Pixmap &label_pm, Pixmap &title_pm, 1316 m_tab_container.setAlpha(m_focused?theme().focusedAlpha():theme().unfocusedAlpha());
1126 FbTk::Color &label_color,
1127 FbTk::Color &title_color) {
1128
1129 if (m_labelbutton_active_pm != 0)
1130 label_pm = m_labelbutton_active_pm;
1131 else
1132 label_color = m_labelbutton_active_color;
1133
1134 if (m_title_unfocused_pm != 0)
1135 title_pm = m_title_unfocused_pm;
1136 else
1137 title_color = m_title_unfocused_color;
1138}
1139 1317
1140void FbWinFrame::renderLabelButtons() { 1318 // do the parent container
1141 if (!isVisible()) { 1319 Pixmap tabcontainer_pm = None;
1142 m_need_render = true; 1320 FbTk::Color *tabcontainer_color = NULL;
1143 return; 1321 if (m_focused) {
1322 if (m_tabcontainer_focused_pm != 0)
1323 tabcontainer_pm = m_tabcontainer_focused_pm;
1324 else
1325 tabcontainer_color = &m_tabcontainer_focused_color;
1326 } else {
1327 if (m_tabcontainer_unfocused_pm != 0)
1328 tabcontainer_pm = m_tabcontainer_unfocused_pm;
1329 else
1330 tabcontainer_color = &m_tabcontainer_unfocused_color;
1144 } 1331 }
1145 1332
1146 render(m_theme.labelFocusTexture(), m_labelbutton_focused_color, 1333 if (tabcontainer_pm != 0)
1147 m_labelbutton_focused_pm, 1334 m_tab_container.setBackgroundPixmap(tabcontainer_pm);
1148 m_tab_container.width(), m_tab_container.height()); 1335 else
1149 1336 m_tab_container.setBackgroundColor(*tabcontainer_color);
1150
1151 render(m_theme.labelUnfocusTexture(), m_labelbutton_unfocused_color,
1152 m_labelbutton_unfocused_pm,
1153 m_tab_container.width(), m_tab_container.height());
1154
1155 render(m_theme.labelActiveTexture(), m_labelbutton_active_color,
1156 m_labelbutton_active_pm,
1157 m_tab_container.width(), m_tab_container.height());
1158
1159}
1160
1161void FbWinFrame::applyLabelButtons() {
1162 1337
1338 // and the labelbuttons in it
1163 Container::ItemList::iterator btn_it = m_tab_container.begin(); 1339 Container::ItemList::iterator btn_it = m_tab_container.begin();
1164 Container::ItemList::iterator btn_it_end = m_tab_container.end(); 1340 Container::ItemList::iterator btn_it_end = m_tab_container.end();
1165 for (; btn_it != btn_it_end; ++btn_it) { 1341 for (; btn_it != btn_it_end; ++btn_it) {
@@ -1186,6 +1362,8 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) {
1186 window().setBorderWidth(border_width); 1362 window().setBorderWidth(border_width);
1187 window().setBorderColor(theme().border().color()); 1363 window().setBorderColor(theme().border().color());
1188 1364
1365 setTabMode(NOTSET);
1366
1189 titlebar().setBorderWidth(border_width); 1367 titlebar().setBorderWidth(border_width);
1190 titlebar().setBorderColor(theme().border().color()); 1368 titlebar().setBorderColor(theme().border().color());
1191 1369
@@ -1200,13 +1378,16 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) {
1200 1378
1201 if (bw_changes != 0) 1379 if (bw_changes != 0)
1202 resize(width(), height() + bw_changes); 1380 resize(width(), height() + bw_changes);
1381
1382 if (m_tabmode == EXTERNAL)
1383 alignTabs();
1203} 1384}
1204 1385
1205void FbWinFrame::applyFocusLabel(FbTk::TextButton &button) { 1386void FbWinFrame::applyFocusLabel(FbTk::TextButton &button) {
1206 1387
1388 button.setBorderWidth(1);
1207 button.setGC(theme().labelTextFocusGC()); 1389 button.setGC(theme().labelTextFocusGC());
1208 button.setJustify(theme().justify()); 1390 button.setJustify(theme().justify());
1209 button.setBorderWidth(1);
1210 button.setAlpha(m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 1391 button.setAlpha(m_focused?theme().focusedAlpha():theme().unfocusedAlpha());
1211 1392
1212 if (m_labelbutton_focused_pm != 0) { 1393 if (m_labelbutton_focused_pm != 0) {
@@ -1217,10 +1398,9 @@ void FbWinFrame::applyFocusLabel(FbTk::TextButton &button) {
1217} 1398}
1218 1399
1219void FbWinFrame::applyActiveLabel(FbTk::TextButton &button) { 1400void FbWinFrame::applyActiveLabel(FbTk::TextButton &button) {
1220 1401 button.setBorderWidth(1);
1221 button.setGC(theme().labelTextActiveGC()); 1402 button.setGC(theme().labelTextActiveGC());
1222 button.setJustify(theme().justify()); 1403 button.setJustify(theme().justify());
1223 button.setBorderWidth(1);
1224 button.setAlpha(m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); 1404 button.setAlpha(m_focused?theme().focusedAlpha():theme().unfocusedAlpha());
1225 1405
1226 if (m_labelbutton_active_pm != 0) { 1406 if (m_labelbutton_active_pm != 0) {
@@ -1362,3 +1542,18 @@ void FbWinFrame::gravityTranslate(int &x, int &y, unsigned int width, unsigned i
1362 move(x, y); 1542 move(x, y);
1363 } 1543 }
1364} 1544}
1545
1546int FbWinFrame::heightOffset() const {
1547 if (m_tabmode == EXTERNAL && m_use_tabs)
1548 return m_tab_container.height() + m_window.borderWidth();
1549 else
1550 return 0;
1551}
1552
1553int FbWinFrame::yOffset() const {
1554 if (m_tabmode == EXTERNAL && m_use_tabs)
1555 return m_tab_container.height() + m_window.borderWidth();
1556 else
1557 return 0;
1558}
1559