aboutsummaryrefslogtreecommitdiff
path: root/src/FbWinFrame.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-01-05 01:39:19 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-01-05 01:39:19 (GMT)
commitac1bd7e0981222bf340ce7defb2bb8307d42a0a2 (patch)
treec8fb9c618184e7ac44f6138409cab3fab86b23e4 /src/FbWinFrame.cc
parent60ba709c2f47cc2c7b877aef1b0f297b097853e5 (diff)
downloadfluxbox-ac1bd7e0981222bf340ce7defb2bb8307d42a0a2.zip
fluxbox-ac1bd7e0981222bf340ce7defb2bb8307d42a0a2.tar.bz2
update code to use ThemeProxy
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r--src/FbWinFrame.cc104
1 files changed, 53 insertions, 51 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 9056d54..36bf251 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -39,14 +39,16 @@
39using std::mem_fun; 39using std::mem_fun;
40using std::string; 40using std::string;
41 41
42FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, 42FbWinFrame::FbWinFrame(BScreen &screen,
43 FbTk::ThemeProxy<FbWinFrameTheme> &theme,
44 FbTk::ImageControl &imgctrl,
43 FbTk::XLayer &layer, 45 FbTk::XLayer &layer,
44 int x, int y, 46 int x, int y,
45 unsigned int width, unsigned int height): 47 unsigned int width, unsigned int height):
46 m_screen(screen), 48 m_screen(screen),
47 m_theme(theme), 49 m_theme(theme),
48 m_imagectrl(imgctrl), 50 m_imagectrl(imgctrl),
49 m_window(theme.screenNum(), x, y, width, height, 51 m_window(theme->screenNum(), x, y, width, height,
50 ButtonPressMask | ButtonReleaseMask | 52 ButtonPressMask | ButtonReleaseMask |
51 ButtonMotionMask | EnterWindowMask | 53 ButtonMotionMask | EnterWindowMask |
52 LeaveWindowMask, true), 54 LeaveWindowMask, true),
@@ -56,7 +58,7 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr
56 ButtonMotionMask | ExposureMask | 58 ButtonMotionMask | ExposureMask |
57 EnterWindowMask | LeaveWindowMask), 59 EnterWindowMask | LeaveWindowMask),
58 m_tab_container(m_titlebar), 60 m_tab_container(m_titlebar),
59 m_label(m_titlebar, m_theme.font(), ""), 61 m_label(m_titlebar, m_theme->font(), ""),
60 m_handle(m_window, 0, 0, 100, 5, 62 m_handle(m_window, 0, 0, 100, 5,
61 ButtonPressMask | ButtonReleaseMask | 63 ButtonPressMask | ButtonReleaseMask |
62 ButtonMotionMask | ExposureMask | 64 ButtonMotionMask | ExposureMask |
@@ -88,9 +90,9 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr
88 m_button_size(1), 90 m_button_size(1),
89 m_height_before_shade(1), 91 m_height_before_shade(1),
90 m_shaded(false), 92 m_shaded(false),
91 m_focused_alpha(AlphaAcc(theme, &FbWinFrameTheme::focusedAlpha)), 93 m_focused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::focusedAlpha)),
92 m_unfocused_alpha(AlphaAcc(theme, &FbWinFrameTheme::unfocusedAlpha)), 94 m_unfocused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::unfocusedAlpha)),
93 m_shape(m_window, theme.shapePlace()), 95 m_shape(m_window, theme->shapePlace()),
94 m_disable_themeshape(false) { 96 m_disable_themeshape(false) {
95 init(); 97 init();
96} 98}
@@ -117,7 +119,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) {
117 if (tabmode == EXTERNAL) { 119 if (tabmode == EXTERNAL) {
118 m_label.show(); 120 m_label.show();
119 m_tab_container.setBorderWidth(m_window.borderWidth()); 121 m_tab_container.setBorderWidth(m_window.borderWidth());
120 m_tab_container.setBorderColor(theme().border(m_focused).color()); 122 m_tab_container.setBorderColor(theme()->border(m_focused).color());
121 m_tab_container.setEventMask( 123 m_tab_container.setEventMask(
122 ButtonPressMask | ButtonReleaseMask | 124 ButtonPressMask | ButtonReleaseMask |
123 ButtonMotionMask | ExposureMask | 125 ButtonMotionMask | ExposureMask |
@@ -484,10 +486,10 @@ void FbWinFrame::setFocus(bool newvalue) {
484 } 486 }
485 487
486 if (m_decoration_mask & DECORM_BORDER && 488 if (m_decoration_mask & DECORM_BORDER &&
487 (theme().border(true).width() != theme().border(false).width() || 489 (theme()->border(true).width() != theme()->border(false).width() ||
488 theme().border(true).color().pixel() != 490 theme()->border(true).color().pixel() !=
489 theme().border(false).color().pixel())) 491 theme()->border(false).color().pixel()))
490 setBorderWidth(theme().border(newvalue).width()); 492 setBorderWidth(theme()->border(newvalue).width());
491 493
492 applyAll(); 494 applyAll();
493 clearAll(); 495 clearAll();
@@ -562,7 +564,7 @@ void FbWinFrame::removeAllButtons() {
562} 564}
563 565
564IconButton *FbWinFrame::createTab(Focusable &client) { 566IconButton *FbWinFrame::createTab(Focusable &client) {
565 IconButton *button = new IconButton(m_tab_container, theme().iconbarTheme(), 567 IconButton *button = new IconButton(m_tab_container, theme()->iconbarTheme(),
566 client); 568 client);
567 569
568 button->show(); 570 button->show();
@@ -742,7 +744,7 @@ bool FbWinFrame::hideHandle() {
742} 744}
743 745
744bool FbWinFrame::showHandle() { 746bool FbWinFrame::showHandle() {
745 if (m_use_handle || theme().handleWidth() == 0) 747 if (m_use_handle || theme()->handleWidth() == 0)
746 return false; 748 return false;
747 749
748 m_use_handle = true; 750 m_use_handle = true;
@@ -870,19 +872,19 @@ void FbWinFrame::reconfigure() {
870 // negate gravity 872 // negate gravity
871 gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false); 873 gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false);
872 874
873 m_bevel = theme().bevelWidth(); 875 m_bevel = theme()->bevelWidth();
874 // reconfigure can't set borderwidth, as it doesn't know 876 // reconfigure can't set borderwidth, as it doesn't know
875 // if it's meant to be borderless or not 877 // if it's meant to be borderless or not
876 878
877 unsigned int orig_handle_h = handle().height(); 879 unsigned int orig_handle_h = handle().height();
878 if (m_use_handle && orig_handle_h != theme().handleWidth()) 880 if (m_use_handle && orig_handle_h != theme()->handleWidth())
879 m_window.resize(m_window.width(), m_window.height() - 881 m_window.resize(m_window.width(), m_window.height() -
880 orig_handle_h + theme().handleWidth()); 882 orig_handle_h + theme()->handleWidth());
881 883
882 handle().resize(handle().width(), 884 handle().resize(handle().width(),
883 theme().handleWidth()); 885 theme()->handleWidth());
884 gripLeft().resize(buttonHeight(), 886 gripLeft().resize(buttonHeight(),
885 theme().handleWidth()); 887 theme()->handleWidth());
886 gripRight().resize(gripLeft().width(), 888 gripRight().resize(gripLeft().width(),
887 gripLeft().height()); 889 gripLeft().height());
888 890
@@ -988,7 +990,7 @@ void FbWinFrame::reconfigure() {
988 if (m_disable_themeshape) 990 if (m_disable_themeshape)
989 m_shape.setPlaces(FbTk::Shape::NONE); 991 m_shape.setPlaces(FbTk::Shape::NONE);
990 else 992 else
991 m_shape.setPlaces(theme().shapePlace()); 993 m_shape.setPlaces(theme()->shapePlace());
992 994
993 m_shape.setShapeOffsets(0, titlebarHeight()); 995 m_shape.setShapeOffsets(0, titlebarHeight());
994 996
@@ -1001,7 +1003,7 @@ void FbWinFrame::setUseShape(bool value) {
1001 if (m_disable_themeshape) 1003 if (m_disable_themeshape)
1002 m_shape.setPlaces(FbTk::Shape::NONE); 1004 m_shape.setPlaces(FbTk::Shape::NONE);
1003 else 1005 else
1004 m_shape.setPlaces(theme().shapePlace()); 1006 m_shape.setPlaces(theme()->shapePlace());
1005 1007
1006} 1008}
1007 1009
@@ -1038,10 +1040,10 @@ void FbWinFrame::reconfigureTitlebar() {
1038 1040
1039 int orig_height = m_titlebar.height(); 1041 int orig_height = m_titlebar.height();
1040 // resize titlebar to window size with font height 1042 // resize titlebar to window size with font height
1041 int title_height = m_theme.font().height() == 0 ? 16 : 1043 int title_height = theme()->font().height() == 0 ? 16 :
1042 m_theme.font().height() + m_bevel*2 + 2; 1044 theme()->font().height() + m_bevel*2 + 2;
1043 if (m_theme.titleHeight() != 0) 1045 if (theme()->titleHeight() != 0)
1044 title_height = m_theme.titleHeight(); 1046 title_height = theme()->titleHeight();
1045 1047
1046 // if the titlebar grows in size, make sure the whole window does too 1048 // if the titlebar grows in size, make sure the whole window does too
1047 if (orig_height != title_height) 1049 if (orig_height != title_height)
@@ -1128,21 +1130,21 @@ void FbWinFrame::renderTitlebar() {
1128 } 1130 }
1129 1131
1130 // render pixmaps 1132 // render pixmaps
1131 render(m_theme.titleFocusTexture(), m_title_focused_color, 1133 render(theme()->titleFocusTexture(), m_title_focused_color,
1132 m_title_focused_pm, 1134 m_title_focused_pm,
1133 m_titlebar.width(), m_titlebar.height()); 1135 m_titlebar.width(), m_titlebar.height());
1134 1136
1135 render(m_theme.titleUnfocusTexture(), m_title_unfocused_color, 1137 render(theme()->titleUnfocusTexture(), m_title_unfocused_color,
1136 m_title_unfocused_pm, 1138 m_title_unfocused_pm,
1137 m_titlebar.width(), m_titlebar.height()); 1139 m_titlebar.width(), m_titlebar.height());
1138 1140
1139 //!! TODO: don't render label if internal tabs 1141 //!! TODO: don't render label if internal tabs
1140 1142
1141 render(m_theme.iconbarTheme().focusedTexture(), m_label_focused_color, 1143 render(theme()->iconbarTheme()->focusedTexture(), m_label_focused_color,
1142 m_label_focused_pm, 1144 m_label_focused_pm,
1143 m_label.width(), m_label.height()); 1145 m_label.width(), m_label.height());
1144 1146
1145 render(m_theme.iconbarTheme().unfocusedTexture(), m_label_unfocused_color, 1147 render(theme()->iconbarTheme()->unfocusedTexture(), m_label_unfocused_color,
1146 m_label_unfocused_pm, 1148 m_label_unfocused_pm,
1147 m_label.width(), m_label.height()); 1149 m_label.width(), m_label.height());
1148 1150
@@ -1154,13 +1156,13 @@ void FbWinFrame::renderTabContainer() {
1154 return; 1156 return;
1155 } 1157 }
1156 1158
1157 const FbTk::Texture *tc_focused = &m_theme.iconbarTheme().focusedTexture(); 1159 const FbTk::Texture *tc_focused = &theme()->iconbarTheme()->focusedTexture();
1158 const FbTk::Texture *tc_unfocused = &m_theme.iconbarTheme().unfocusedTexture(); 1160 const FbTk::Texture *tc_unfocused = &theme()->iconbarTheme()->unfocusedTexture();
1159 1161
1160 if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE) 1162 if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE)
1161 tc_focused = &m_theme.titleFocusTexture(); 1163 tc_focused = &theme()->titleFocusTexture();
1162 if (m_tabmode == EXTERNAL && tc_unfocused->type() & FbTk::Texture::PARENTRELATIVE) 1164 if (m_tabmode == EXTERNAL && tc_unfocused->type() & FbTk::Texture::PARENTRELATIVE)
1163 tc_unfocused = &m_theme.titleUnfocusTexture(); 1165 tc_unfocused = &theme()->titleUnfocusTexture();
1164 1166
1165 render(*tc_focused, m_tabcontainer_focused_color, 1167 render(*tc_focused, m_tabcontainer_focused_color,
1166 m_tabcontainer_focused_pm, 1168 m_tabcontainer_focused_pm,
@@ -1190,11 +1192,11 @@ void FbWinFrame::applyTitlebar() {
1190 1192
1191 if (m_tabmode != INTERNAL) { 1193 if (m_tabmode != INTERNAL) {
1192 m_label.setGC(m_focused ? 1194 m_label.setGC(m_focused ?
1193 theme().iconbarTheme().focusedText().textGC() : 1195 theme()->iconbarTheme()->focusedText().textGC() :
1194 theme().iconbarTheme().unfocusedText().textGC()); 1196 theme()->iconbarTheme()->unfocusedText().textGC());
1195 m_label.setJustify(m_focused ? 1197 m_label.setJustify(m_focused ?
1196 theme().iconbarTheme().focusedText().justify() : 1198 theme()->iconbarTheme()->focusedText().justify() :
1197 theme().iconbarTheme().unfocusedText().justify()); 1199 theme()->iconbarTheme()->unfocusedText().justify());
1198 1200
1199 if (label_pm != 0) 1201 if (label_pm != 0)
1200 m_label.setBackgroundPixmap(label_pm); 1202 m_label.setBackgroundPixmap(label_pm);
@@ -1220,18 +1222,18 @@ void FbWinFrame::renderHandles() {
1220 return; 1222 return;
1221 } 1223 }
1222 1224
1223 render(m_theme.handleFocusTexture(), m_handle_focused_color, 1225 render(theme()->handleFocusTexture(), m_handle_focused_color,
1224 m_handle_focused_pm, 1226 m_handle_focused_pm,
1225 m_handle.width(), m_handle.height()); 1227 m_handle.width(), m_handle.height());
1226 1228
1227 render(m_theme.handleUnfocusTexture(), m_handle_unfocused_color, 1229 render(theme()->handleUnfocusTexture(), m_handle_unfocused_color,
1228 m_handle_unfocused_pm, 1230 m_handle_unfocused_pm,
1229 m_handle.width(), m_handle.height()); 1231 m_handle.width(), m_handle.height());
1230 1232
1231 render(m_theme.gripFocusTexture(), m_grip_focused_color, m_grip_focused_pm, 1233 render(theme()->gripFocusTexture(), m_grip_focused_color, m_grip_focused_pm,
1232 m_grip_left.width(), m_grip_left.height()); 1234 m_grip_left.width(), m_grip_left.height());
1233 1235
1234 render(m_theme.gripUnfocusTexture(), m_grip_unfocused_color, 1236 render(theme()->gripUnfocusTexture(), m_grip_unfocused_color,
1235 m_grip_unfocused_pm, 1237 m_grip_unfocused_pm,
1236 m_grip_left.width(), m_grip_left.height()); 1238 m_grip_left.width(), m_grip_left.height());
1237 1239
@@ -1286,15 +1288,15 @@ void FbWinFrame::renderButtons() {
1286 return; 1288 return;
1287 } 1289 }
1288 1290
1289 render(m_theme.buttonFocusTexture(), m_button_color, 1291 render(theme()->buttonFocusTexture(), m_button_color,
1290 m_button_pm, 1292 m_button_pm,
1291 m_button_size, m_button_size); 1293 m_button_size, m_button_size);
1292 1294
1293 render(m_theme.buttonUnfocusTexture(), m_button_unfocused_color, 1295 render(theme()->buttonUnfocusTexture(), m_button_unfocused_color,
1294 m_button_unfocused_pm, 1296 m_button_unfocused_pm,
1295 m_button_size, m_button_size); 1297 m_button_size, m_button_size);
1296 1298
1297 render(m_theme.buttonPressedTexture(), m_button_pressed_color, 1299 render(theme()->buttonPressedTexture(), m_button_pressed_color,
1298 m_button_pressed_pm, 1300 m_button_pressed_pm,
1299 m_button_size, m_button_size); 1301 m_button_size, m_button_size);
1300} 1302}
@@ -1310,7 +1312,7 @@ void FbWinFrame::applyButtons() {
1310 1312
1311void FbWinFrame::init() { 1313void FbWinFrame::init() {
1312 1314
1313 if (theme().handleWidth() == 0) 1315 if (theme()->handleWidth() == 0)
1314 m_use_handle = false; 1316 m_use_handle = false;
1315 1317
1316 m_disable_themeshape = false; 1318 m_disable_themeshape = false;
@@ -1357,7 +1359,7 @@ void FbWinFrame::applyButton(FbTk::Button &btn) {
1357 if (focused()) { // focused 1359 if (focused()) { // focused
1358 btn.setAlpha(getAlpha(true)); 1360 btn.setAlpha(getAlpha(true));
1359 1361
1360 btn.setGC(m_theme.buttonPicFocusGC()); 1362 btn.setGC(theme()->buttonPicFocusGC());
1361 if (m_button_pm) 1363 if (m_button_pm)
1362 btn.setBackgroundPixmap(m_button_pm); 1364 btn.setBackgroundPixmap(m_button_pm);
1363 else 1365 else
@@ -1365,7 +1367,7 @@ void FbWinFrame::applyButton(FbTk::Button &btn) {
1365 } else { // unfocused 1367 } else { // unfocused
1366 btn.setAlpha(getAlpha(false)); 1368 btn.setAlpha(getAlpha(false));
1367 1369
1368 btn.setGC(m_theme.buttonPicUnfocusGC()); 1370 btn.setGC(theme()->buttonPicUnfocusGC());
1369 if (m_button_unfocused_pm) 1371 if (m_button_unfocused_pm)
1370 btn.setBackgroundPixmap(m_button_unfocused_pm); 1372 btn.setBackgroundPixmap(m_button_unfocused_pm);
1371 else 1373 else
@@ -1463,21 +1465,21 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) {
1463 bw_changes += static_cast<signed>(border_width - handle().borderWidth()); 1465 bw_changes += static_cast<signed>(border_width - handle().borderWidth());
1464 1466
1465 window().setBorderWidth(border_width); 1467 window().setBorderWidth(border_width);
1466 window().setBorderColor(theme().border(m_focused).color()); 1468 window().setBorderColor(theme()->border(m_focused).color());
1467 1469
1468 setTabMode(NOTSET); 1470 setTabMode(NOTSET);
1469 1471
1470 titlebar().setBorderWidth(border_width); 1472 titlebar().setBorderWidth(border_width);
1471 titlebar().setBorderColor(theme().border(m_focused).color()); 1473 titlebar().setBorderColor(theme()->border(m_focused).color());
1472 1474
1473 handle().setBorderWidth(border_width); 1475 handle().setBorderWidth(border_width);
1474 handle().setBorderColor(theme().border(m_focused).color()); 1476 handle().setBorderColor(theme()->border(m_focused).color());
1475 1477
1476 gripLeft().setBorderWidth(border_width); 1478 gripLeft().setBorderWidth(border_width);
1477 gripLeft().setBorderColor(theme().border(m_focused).color()); 1479 gripLeft().setBorderColor(theme()->border(m_focused).color());
1478 1480
1479 gripRight().setBorderWidth(border_width); 1481 gripRight().setBorderWidth(border_width);
1480 gripRight().setBorderColor(theme().border(m_focused).color()); 1482 gripRight().setBorderColor(theme()->border(m_focused).color());
1481 1483
1482 if (bw_changes != 0) 1484 if (bw_changes != 0)
1483 resize(width(), height() + bw_changes); 1485 resize(width(), height() + bw_changes);