aboutsummaryrefslogtreecommitdiff
path: root/src/FbWinFrame.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-01-07 20:08:56 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-01-07 20:08:56 (GMT)
commitec3125aeb95a06f08cd4895c5b7c3a8911c1b368 (patch)
tree136d27f04589d0191c48b0abe940c9eb0a17a0db /src/FbWinFrame.cc
parentdbfddf8e0bcf8e7abbba671eff64c9679332a774 (diff)
downloadfluxbox-ec3125aeb95a06f08cd4895c5b7c3a8911c1b368.zip
fluxbox-ec3125aeb95a06f08cd4895c5b7c3a8911c1b368.tar.bz2
switch FbWinFrameTheme to use FocusableTheme
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r--src/FbWinFrame.cc97
1 files changed, 43 insertions, 54 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 5cc7631..ea1236a 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -28,9 +28,10 @@
28#include "FbTk/Compose.hh" 28#include "FbTk/Compose.hh"
29#include "FbTk/Transparent.hh" 29#include "FbTk/Transparent.hh"
30#include "FbTk/CompareEqual.hh" 30#include "FbTk/CompareEqual.hh"
31
31#include "FbWinFrameTheme.hh" 32#include "FbWinFrameTheme.hh"
32#include "Screen.hh" 33#include "Screen.hh"
33 34#include "FocusableTheme.hh"
34#include "IconButton.hh" 35#include "IconButton.hh"
35 36
36#include <algorithm> 37#include <algorithm>
@@ -40,7 +41,7 @@ using std::mem_fun;
40using std::string; 41using std::string;
41 42
42FbWinFrame::FbWinFrame(BScreen &screen, 43FbWinFrame::FbWinFrame(BScreen &screen,
43 FbTk::ThemeProxy<FbWinFrameTheme> &theme, 44 FocusableTheme<FbWinFrameTheme> &theme,
44 FbTk::ImageControl &imgctrl, 45 FbTk::ImageControl &imgctrl,
45 FbTk::XLayer &layer, 46 FbTk::XLayer &layer,
46 int x, int y, 47 int x, int y,
@@ -90,8 +91,8 @@ FbWinFrame::FbWinFrame(BScreen &screen,
90 m_button_size(1), 91 m_button_size(1),
91 m_height_before_shade(1), 92 m_height_before_shade(1),
92 m_shaded(false), 93 m_shaded(false),
93 m_focused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::focusedAlpha)), 94 m_focused_alpha(AlphaAcc(*theme.focusedTheme(), &FbWinFrameTheme::alpha)),
94 m_unfocused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::unfocusedAlpha)), 95 m_unfocused_alpha(AlphaAcc(*theme.unfocusedTheme(), &FbWinFrameTheme::alpha)),
95 m_shape(m_window, theme->shapePlace()), 96 m_shape(m_window, theme->shapePlace()),
96 m_disable_themeshape(false) { 97 m_disable_themeshape(false) {
97 init(); 98 init();
@@ -119,7 +120,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) {
119 if (tabmode == EXTERNAL) { 120 if (tabmode == EXTERNAL) {
120 m_label.show(); 121 m_label.show();
121 m_tab_container.setBorderWidth(m_window.borderWidth()); 122 m_tab_container.setBorderWidth(m_window.borderWidth());
122 m_tab_container.setBorderColor(theme()->border(m_focused).color()); 123 m_tab_container.setBorderColor(theme()->border().color());
123 m_tab_container.setEventMask( 124 m_tab_container.setEventMask(
124 ButtonPressMask | ButtonReleaseMask | 125 ButtonPressMask | ButtonReleaseMask |
125 ButtonMotionMask | ExposureMask | 126 ButtonMotionMask | ExposureMask |
@@ -486,10 +487,11 @@ void FbWinFrame::setFocus(bool newvalue) {
486 } 487 }
487 488
488 if (m_decoration_mask & DECORM_BORDER && 489 if (m_decoration_mask & DECORM_BORDER &&
489 (theme()->border(true).width() != theme()->border(false).width() || 490 (theme().focusedTheme()->border().width() !=
490 theme()->border(true).color().pixel() != 491 theme().unfocusedTheme()->border().width() ||
491 theme()->border(false).color().pixel())) 492 theme().focusedTheme()->border().color().pixel() !=
492 setBorderWidth(theme()->border(newvalue).width()); 493 theme().unfocusedTheme()->border().color().pixel()))
494 setBorderWidth(theme()->border().width());
493 495
494 applyAll(); 496 applyAll();
495 clearAll(); 497 clearAll();
@@ -1125,22 +1127,22 @@ void FbWinFrame::renderTitlebar() {
1125 } 1127 }
1126 1128
1127 // render pixmaps 1129 // render pixmaps
1128 render(theme()->titleFocusTexture(), m_title_focused_color, 1130 render(theme().focusedTheme()->titleTexture(), m_title_focused_color,
1129 m_title_focused_pm, 1131 m_title_focused_pm,
1130 m_titlebar.width(), m_titlebar.height()); 1132 m_titlebar.width(), m_titlebar.height());
1131 1133
1132 render(theme()->titleUnfocusTexture(), m_title_unfocused_color, 1134 render(theme().unfocusedTheme()->titleTexture(), m_title_unfocused_color,
1133 m_title_unfocused_pm, 1135 m_title_unfocused_pm,
1134 m_titlebar.width(), m_titlebar.height()); 1136 m_titlebar.width(), m_titlebar.height());
1135 1137
1136 //!! TODO: don't render label if internal tabs 1138 //!! TODO: don't render label if internal tabs
1137 1139
1138 render(theme()->focusedIconbarTheme()->texture(), m_label_focused_color, 1140 render(theme().focusedTheme()->iconbarTheme()->texture(),
1139 m_label_focused_pm, 1141 m_label_focused_color, m_label_focused_pm,
1140 m_label.width(), m_label.height()); 1142 m_label.width(), m_label.height());
1141 1143
1142 render(theme()->unfocusedIconbarTheme()->texture(), m_label_unfocused_color, 1144 render(theme().unfocusedTheme()->iconbarTheme()->texture(),
1143 m_label_unfocused_pm, 1145 m_label_unfocused_color, m_label_unfocused_pm,
1144 m_label.width(), m_label.height()); 1146 m_label.width(), m_label.height());
1145 1147
1146} 1148}
@@ -1151,13 +1153,13 @@ void FbWinFrame::renderTabContainer() {
1151 return; 1153 return;
1152 } 1154 }
1153 1155
1154 const FbTk::Texture *tc_focused = &theme()->focusedIconbarTheme()->texture(); 1156 const FbTk::Texture *tc_focused = &theme().focusedTheme()->iconbarTheme()->texture();
1155 const FbTk::Texture *tc_unfocused = &theme()->unfocusedIconbarTheme()->texture(); 1157 const FbTk::Texture *tc_unfocused = &theme().unfocusedTheme()->iconbarTheme()->texture();
1156 1158
1157 if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE) 1159 if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE)
1158 tc_focused = &theme()->titleFocusTexture(); 1160 tc_focused = &theme().focusedTheme()->titleTexture();
1159 if (m_tabmode == EXTERNAL && tc_unfocused->type() & FbTk::Texture::PARENTRELATIVE) 1161 if (m_tabmode == EXTERNAL && tc_unfocused->type() & FbTk::Texture::PARENTRELATIVE)
1160 tc_unfocused = &theme()->titleUnfocusTexture(); 1162 tc_unfocused = &theme().unfocusedTheme()->titleTexture();
1161 1163
1162 render(*tc_focused, m_tabcontainer_focused_color, 1164 render(*tc_focused, m_tabcontainer_focused_color,
1163 m_tabcontainer_focused_pm, 1165 m_tabcontainer_focused_pm,
@@ -1186,12 +1188,8 @@ void FbWinFrame::applyTitlebar() {
1186 m_label.setAlpha(alpha); 1188 m_label.setAlpha(alpha);
1187 1189
1188 if (m_tabmode != INTERNAL) { 1190 if (m_tabmode != INTERNAL) {
1189 m_label.setGC(m_focused ? 1191 m_label.setGC(theme()->iconbarTheme()->text().textGC());
1190 theme()->focusedIconbarTheme()->text().textGC() : 1192 m_label.setJustify(theme()->iconbarTheme()->text().justify());
1191 theme()->unfocusedIconbarTheme()->text().textGC());
1192 m_label.setJustify(m_focused ?
1193 theme()->focusedIconbarTheme()->text().justify() :
1194 theme()->unfocusedIconbarTheme()->text().justify());
1195 1193
1196 if (label_pm != 0) 1194 if (label_pm != 0)
1197 m_label.setBackgroundPixmap(label_pm); 1195 m_label.setBackgroundPixmap(label_pm);
@@ -1217,18 +1215,19 @@ void FbWinFrame::renderHandles() {
1217 return; 1215 return;
1218 } 1216 }
1219 1217
1220 render(theme()->handleFocusTexture(), m_handle_focused_color, 1218 render(theme().focusedTheme()->handleTexture(), m_handle_focused_color,
1221 m_handle_focused_pm, 1219 m_handle_focused_pm,
1222 m_handle.width(), m_handle.height()); 1220 m_handle.width(), m_handle.height());
1223 1221
1224 render(theme()->handleUnfocusTexture(), m_handle_unfocused_color, 1222 render(theme().unfocusedTheme()->handleTexture(), m_handle_unfocused_color,
1225 m_handle_unfocused_pm, 1223 m_handle_unfocused_pm,
1226 m_handle.width(), m_handle.height()); 1224 m_handle.width(), m_handle.height());
1227 1225
1228 render(theme()->gripFocusTexture(), m_grip_focused_color, m_grip_focused_pm, 1226 render(theme().focusedTheme()->gripTexture(), m_grip_focused_color,
1227 m_grip_focused_pm,
1229 m_grip_left.width(), m_grip_left.height()); 1228 m_grip_left.width(), m_grip_left.height());
1230 1229
1231 render(theme()->gripUnfocusTexture(), m_grip_unfocused_color, 1230 render(theme().unfocusedTheme()->gripTexture(), m_grip_unfocused_color,
1232 m_grip_unfocused_pm, 1231 m_grip_unfocused_pm,
1233 m_grip_left.width(), m_grip_left.height()); 1232 m_grip_left.width(), m_grip_left.height());
1234 1233
@@ -1283,11 +1282,11 @@ void FbWinFrame::renderButtons() {
1283 return; 1282 return;
1284 } 1283 }
1285 1284
1286 render(theme()->buttonFocusTexture(), m_button_color, 1285 render(theme().focusedTheme()->buttonTexture(), m_button_color,
1287 m_button_pm, 1286 m_button_pm,
1288 m_button_size, m_button_size); 1287 m_button_size, m_button_size);
1289 1288
1290 render(theme()->buttonUnfocusTexture(), m_button_unfocused_color, 1289 render(theme().unfocusedTheme()->buttonTexture(), m_button_unfocused_color,
1291 m_button_unfocused_pm, 1290 m_button_unfocused_pm,
1292 m_button_size, m_button_size); 1291 m_button_size, m_button_size);
1293 1292
@@ -1351,24 +1350,14 @@ void FbWinFrame::applyButton(FbTk::Button &btn) {
1351 else 1350 else
1352 btn.setPressedColor(m_button_pressed_color); 1351 btn.setPressedColor(m_button_pressed_color);
1353 1352
1354 if (focused()) { // focused 1353 Pixmap pm = m_focused ? m_button_pm : m_button_unfocused_pm;
1355 btn.setAlpha(getAlpha(true)); 1354 btn.setAlpha(getAlpha(m_focused));
1356 1355 btn.setGC(theme()->buttonPicGC());
1357 btn.setGC(theme()->buttonPicFocusGC()); 1356 if (pm)
1358 if (m_button_pm) 1357 btn.setBackgroundPixmap(pm);
1359 btn.setBackgroundPixmap(m_button_pm); 1358 else
1360 else 1359 btn.setBackgroundColor(m_focused ? m_button_color
1361 btn.setBackgroundColor(m_button_color); 1360 : m_button_unfocused_color);
1362 } else { // unfocused
1363 btn.setAlpha(getAlpha(false));
1364
1365 btn.setGC(theme()->buttonPicUnfocusGC());
1366 if (m_button_unfocused_pm)
1367 btn.setBackgroundPixmap(m_button_unfocused_pm);
1368 else
1369 btn.setBackgroundColor(m_button_unfocused_color);
1370 }
1371
1372} 1361}
1373 1362
1374void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm, 1363void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,
@@ -1460,21 +1449,21 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) {
1460 bw_changes += static_cast<signed>(border_width - handle().borderWidth()); 1449 bw_changes += static_cast<signed>(border_width - handle().borderWidth());
1461 1450
1462 window().setBorderWidth(border_width); 1451 window().setBorderWidth(border_width);
1463 window().setBorderColor(theme()->border(m_focused).color()); 1452 window().setBorderColor(theme()->border().color());
1464 1453
1465 setTabMode(NOTSET); 1454 setTabMode(NOTSET);
1466 1455
1467 titlebar().setBorderWidth(border_width); 1456 titlebar().setBorderWidth(border_width);
1468 titlebar().setBorderColor(theme()->border(m_focused).color()); 1457 titlebar().setBorderColor(theme()->border().color());
1469 1458
1470 handle().setBorderWidth(border_width); 1459 handle().setBorderWidth(border_width);
1471 handle().setBorderColor(theme()->border(m_focused).color()); 1460 handle().setBorderColor(theme()->border().color());
1472 1461
1473 gripLeft().setBorderWidth(border_width); 1462 gripLeft().setBorderWidth(border_width);
1474 gripLeft().setBorderColor(theme()->border(m_focused).color()); 1463 gripLeft().setBorderColor(theme()->border().color());
1475 1464
1476 gripRight().setBorderWidth(border_width); 1465 gripRight().setBorderWidth(border_width);
1477 gripRight().setBorderColor(theme()->border(m_focused).color()); 1466 gripRight().setBorderColor(theme()->border().color());
1478 1467
1479 if (bw_changes != 0) 1468 if (bw_changes != 0)
1480 resize(width(), height() + bw_changes); 1469 resize(width(), height() + bw_changes);