aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-27 14:14:04 (GMT)
committerfluxgen <fluxgen>2003-08-27 14:14:04 (GMT)
commit2be2a2b5cccefa775c3f6dd917da00984f99cc1a (patch)
tree2aad3e5ba4857b6945dd39214efba3b0bcf5f310 /src/FbTk
parent097fcff44f305dcd4c10cc6d2cac9ad5092d5e94 (diff)
downloadfluxbox_paul-2be2a2b5cccefa775c3f6dd917da00984f99cc1a.zip
fluxbox_paul-2be2a2b5cccefa775c3f6dd917da00984f99cc1a.tar.bz2
added pixmap for bullet and selected and unselected
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Menu.cc270
-rw-r--r--src/FbTk/MenuTheme.cc75
2 files changed, 176 insertions, 169 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index dcef424..62fff0c 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Menu.cc,v 1.35 2003/08/24 16:57:38 fluxgen Exp $ 25// $Id: Menu.cc,v 1.36 2003/08/27 14:14:04 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -658,20 +658,20 @@ void Menu::redrawTitle() {
658 dx, font.ascent() + menu.bevel_w); // position 658 dx, font.ascent() + menu.bevel_w); // position
659 /* if (m_trans.get()) { 659 /* if (m_trans.get()) {
660 660
661 if (m_trans->alpha() != 255) { 661 if (m_trans->alpha() != 255) {
662 Pixmap root_pm = getRootPixmap(menu.window.screenNumber()); 662 Pixmap root_pm = getRootPixmap(menu.window.screenNumber());
663 663
664 if (m_root_pm != root_pm) { 664 if (m_root_pm != root_pm) {
665 m_trans->setSource(root_pm, menu.title.screenNumber()); 665 m_trans->setSource(root_pm, menu.title.screenNumber());
666 m_root_pm = root_pm; 666 m_root_pm = root_pm;
667 } 667 }
668 m_trans->setDest(menu.title.window(), menu.title.screenNumber()); 668 m_trans->setDest(menu.title.window(), menu.title.screenNumber());
669 m_trans->render(menu.window.x() + menu.title.x() + menu.window.borderWidth()*2, 669 m_trans->render(menu.window.x() + menu.title.x() + menu.window.borderWidth()*2,
670 menu.window.y() + menu.title.y() + menu.window.borderWidth()*2, 670 menu.window.y() + menu.title.y() + menu.window.borderWidth()*2,
671 0, 0, 671 0, 0,
672 menu.title.width(), menu.title.height()); 672 menu.title.width(), menu.title.height());
673 } 673 }
674 }*/ 674 }*/
675 menu.title.updateTransparent(); 675 menu.title.updateTransparent();
676 676
677} 677}
@@ -820,21 +820,18 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
820 sel_y = item_y + quarter_w; 820 sel_y = item_y + quarter_w;
821 821
822 if (clear) { 822 if (clear) {
823 823 FbTk::GContext def_gc(menu.frame.window());
824 GC def_gc = XCreateGC(m_display, menu.frame.window(), 0, 0);
825 if (menu.frame_pixmap == 0) { 824 if (menu.frame_pixmap == 0) {
826 825 def_gc.setForeground(m_theme.frameTexture().color());
827 XSetForeground(m_display, def_gc, m_theme.frameTexture().color().pixel()); 826 m_frame_pm.fillRectangle(def_gc.gc(), item_x, item_y, menu.item_w, menu.item_h);
828 m_frame_pm.fillRectangle(def_gc, item_x, item_y, menu.item_w, menu.item_h);
829 827
830 } else { 828 } else {
831 829
832 m_frame_pm.copyArea(menu.frame_pixmap, def_gc, 830 m_frame_pm.copyArea(menu.frame_pixmap, def_gc.gc(),
833 item_x, item_y, 831 item_x, item_y,
834 item_x, item_y, 832 item_x, item_y,
835 menu.item_w, menu.item_h); 833 menu.item_w, menu.item_h);
836 } 834 }
837 XFreeGC(m_display, def_gc);
838 } else if (! (x == y && y == -1 && w == h && h == 0)) { 835 } else if (! (x == y && y == -1 && w == h && h == 0)) {
839 // calculate the which part of the hilite to redraw 836 // calculate the which part of the hilite to redraw
840 if (! (std::max(item_x, x) <= (signed) std::min(item_x + menu.item_w, x + w) && 837 if (! (std::max(item_x, x) <= (signed) std::min(item_x + menu.item_w, x + w) &&
@@ -861,7 +858,7 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
861 dosel = false; 858 dosel = false;
862 859
863 } 860 }
864 861
865 if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) { 862 if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) {
866 if (menu.hilite_pixmap) { 863 if (menu.hilite_pixmap) {
867 m_frame_pm.copyArea(menu.hilite_pixmap, 864 m_frame_pm.copyArea(menu.hilite_pixmap,
@@ -875,21 +872,60 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
875 872
876 } 873 }
877 874
878 if (dosel && item->isSelected() && 875
879 (menu.sel_pixmap != ParentRelative)) { 876 if (item->isToggleItem() && item->isSelected() &&
880 if (menu.sel_pixmap) { 877 menu.sel_pixmap != ParentRelative) {
881 m_frame_pm.copyArea(highlight ? menu.frame_pixmap : menu.sel_pixmap, 878 if (m_theme.selectedPixmap().pixmap().drawable()) {
882 m_theme.hiliteGC(), 879 // enable clip mask
883 0, 0, 880 XSetClipMask(FbTk::App::instance()->display(),
884 sel_x, sel_y, 881 gc,
885 half_w, half_w); 882 m_theme.selectedPixmap().mask().drawable());
883 XSetClipOrigin(FbTk::App::instance()->display(),
884 gc, sel_x, item_y);
885 // copy bullet pixmap to frame
886 m_frame_pm.copyArea(m_theme.selectedPixmap().pixmap().drawable(),
887 gc,
888 0, 0,
889 sel_x, item_y,
890 m_theme.selectedPixmap().width(),
891 m_theme.selectedPixmap().height());
892 // disable clip mask
893 XSetClipMask(FbTk::App::instance()->display(),
894 gc,
895 None);
886 } else { 896 } else {
887 m_frame_pm.fillRectangle(m_theme.hiliteGC(), 897 if (menu.sel_pixmap) {
888 sel_x, sel_y, half_w, half_w); 898 m_frame_pm.copyArea(highlight ? menu.frame_pixmap : menu.sel_pixmap,
899 m_theme.hiliteGC(),
900 0, 0,
901 sel_x, sel_y,
902 half_w, half_w);
903 } else {
904 m_frame_pm.fillRectangle(m_theme.hiliteGC(),
905 sel_x, sel_y, half_w, half_w);
906 }
889 } 907 }
890 908
909 } else if (item->isToggleItem() && m_theme.unselectedPixmap().pixmap().drawable() != 0) {
910 // enable clip mask
911 XSetClipMask(FbTk::App::instance()->display(),
912 gc,
913 m_theme.unselectedPixmap().mask().drawable());
914 XSetClipOrigin(FbTk::App::instance()->display(),
915 gc, sel_x, item_y);
916 // copy bullet pixmap to frame
917 m_frame_pm.copyArea(m_theme.unselectedPixmap().pixmap().drawable(),
918 gc,
919 0, 0,
920 sel_x, item_y,
921 m_theme.unselectedPixmap().width(),
922 m_theme.unselectedPixmap().height());
923 // disable clip mask
924 XSetClipMask(FbTk::App::instance()->display(),
925 gc,
926 None);
891 } 927 }
892 928
893 if (dotext && text) { 929 if (dotext && text) {
894 m_theme.frameFont().drawText(m_frame_pm.drawable(), // drawable 930 m_theme.frameFont().drawText(m_frame_pm.drawable(), // drawable
895 screenNumber(), 931 screenNumber(),
@@ -899,51 +935,71 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
899 } 935 }
900 936
901 if (dosel && item->submenu()) { 937 if (dosel && item->submenu()) {
902 switch (m_theme.bullet()) { 938 if (m_theme.bulletPixmap().pixmap().drawable() != 0) {
903 case MenuTheme::SQUARE: 939 // enable clip mask
904 m_frame_pm.drawRectangle(gc, sel_x, sel_y, half_w, half_w); 940 XSetClipMask(FbTk::App::instance()->display(),
905 break; 941 gc,
906 942 m_theme.bulletPixmap().mask().drawable());
907 case MenuTheme::TRIANGLE: 943 XSetClipOrigin(FbTk::App::instance()->display(),
908 XPoint tri[3]; 944 gc, sel_x, item_y);
909 945 // copy bullet pixmap to frame
910 if (m_theme.bulletPos() == FbTk::RIGHT) { 946 m_frame_pm.copyArea(m_theme.bulletPixmap().pixmap().drawable(),
911 tri[0].x = sel_x + quarter_w - 2; 947 gc,
912 tri[0].y = sel_y + quarter_w - 2; 948 0, 0,
913 tri[1].x = 4; 949 sel_x, item_y,
914 tri[1].y = 2; 950 m_theme.bulletPixmap().width(),
915 tri[2].x = -4; 951 m_theme.bulletPixmap().height());
916 tri[2].y = 2; 952 // disable clip mask
917 } else { 953 XSetClipMask(FbTk::App::instance()->display(),
918 tri[0].x = sel_x + quarter_w - 2; 954 gc,
919 tri[0].y = item_y + half_w; 955 None);
920 tri[1].x = 4; 956 } else {
921 tri[1].y = 2; 957 switch (m_theme.bullet()) {
922 tri[2].x = 0; 958 case MenuTheme::SQUARE:
923 tri[2].y = -4; 959 m_frame_pm.drawRectangle(gc, sel_x, sel_y, half_w, half_w);
924 } 960 break;
961
962 case MenuTheme::TRIANGLE:
963 XPoint tri[3];
964
965 if (m_theme.bulletPos() == FbTk::RIGHT) {
966 tri[0].x = sel_x + quarter_w - 2;
967 tri[0].y = sel_y + quarter_w - 2;
968 tri[1].x = 4;
969 tri[1].y = 2;
970 tri[2].x = -4;
971 tri[2].y = 2;
972 } else {
973 tri[0].x = sel_x + quarter_w - 2;
974 tri[0].y = item_y + half_w;
975 tri[1].x = 4;
976 tri[1].y = 2;
977 tri[2].x = 0;
978 tri[2].y = -4;
979 }
925 980
926 m_frame_pm.fillPolygon(gc, tri, 3, Convex, 981 m_frame_pm.fillPolygon(gc, tri, 3, Convex,
927 CoordModePrevious); 982 CoordModePrevious);
928 break; 983 break;
929 984
930 case MenuTheme::DIAMOND: 985 case MenuTheme::DIAMOND:
931 XPoint dia[4]; 986 XPoint dia[4];
932 987
933 dia[0].x = sel_x + quarter_w - 3; 988 dia[0].x = sel_x + quarter_w - 3;
934 dia[0].y = item_y + half_w; 989 dia[0].y = item_y + half_w;
935 dia[1].x = 3; 990 dia[1].x = 3;
936 dia[1].y = -3; 991 dia[1].y = -3;
937 dia[2].x = 3; 992 dia[2].x = 3;
938 dia[2].y = 3; 993 dia[2].y = 3;
939 dia[3].x = -3; 994 dia[3].x = -3;
940 dia[3].y = 3; 995 dia[3].y = 3;
941 996
942 m_frame_pm.fillPolygon(gc, dia, 4, Convex, 997 m_frame_pm.fillPolygon(gc, dia, 4, Convex,
943 CoordModePrevious); 998 CoordModePrevious);
944 break; 999 break;
945 default: 1000 default:
946 break; 1001 break;
1002 }
947 } 1003 }
948 } 1004 }
949 1005
@@ -951,38 +1007,12 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
951 item_x, item_y, 1007 item_x, item_y,
952 menu.item_w, menu.item_h, False); 1008 menu.item_w, menu.item_h, False);
953 1009
954 // if (m_trans->alpha() != alpha())
955 // m_trans->setAlpha(alpha());
956 menu.title.setAlpha(alpha()); 1010 menu.title.setAlpha(alpha());
957 menu.frame.setAlpha(alpha()); 1011 menu.frame.setAlpha(alpha());
958 menu.window.setAlpha(alpha()); 1012 menu.window.setAlpha(alpha());
959 1013
960 menu.frame.updateTransparent(item_x, item_y, 1014 menu.frame.updateTransparent(item_x, item_y,
961 menu.item_w, menu.item_h); 1015 menu.item_w, menu.item_h);
962
963
964 /*
965 if (m_trans.get() && render_trans) {
966
967 if (m_trans->alpha() != 255) {
968 Pixmap root_pm = getRootPixmap(menu.window.screenNumber());
969
970 if (m_root_pm != root_pm) {
971 m_trans->setSource(root_pm, menu.window.screenNumber());
972 m_root_pm = root_pm;
973 }
974
975 m_trans->setDest(menu.frame.window(), menu.frame.screenNumber());
976 m_trans->render(menu.window.x() + menu.frame.x() + item_x +
977 menu.window.borderWidth(),
978 menu.window.y() + menu.frame.y() + item_y +
979 menu.window.borderWidth(),
980 item_x, item_y,
981 menu.item_w, menu.item_h);
982 }
983 }
984 XSync(m_display, False);
985 */
986} 1016}
987 1017
988void Menu::setLabel(const char *labelstr) { 1018void Menu::setLabel(const char *labelstr) {
@@ -1354,35 +1384,35 @@ void Menu::reconfigure() {
1354 menu.title.setAlpha(alpha()); 1384 menu.title.setAlpha(alpha());
1355 menu.window.setAlpha(alpha()); 1385 menu.window.setAlpha(alpha());
1356 /* 1386 /*
1357 if (m_trans.get() && m_trans->alpha() != alpha()) 1387 if (m_trans.get() && m_trans->alpha() != alpha())
1358 m_trans->setAlpha(alpha()); 1388 m_trans->setAlpha(alpha());
1359 */ 1389 */
1360 update(); 1390 update();
1361} 1391}
1362 1392
1363void Menu::renderTransFrame() { 1393void Menu::renderTransFrame() {
1364 /* if (m_trans.get() == 0 || moving) 1394 /* if (m_trans.get() == 0 || moving)
1365 return; 1395 return;
1366 1396
1367 if (m_trans->alpha() != alpha()) 1397 if (m_trans->alpha() != alpha())
1368 m_trans->setAlpha(alpha()); 1398 m_trans->setAlpha(alpha());
1369 1399
1370 if (m_trans->alpha() != 255) { 1400 if (m_trans->alpha() != 255) {
1371 1401
1372 Pixmap root_pm = getRootPixmap(menu.window.screenNumber()); 1402 Pixmap root_pm = getRootPixmap(menu.window.screenNumber());
1373 1403
1374 if (m_root_pm != root_pm) { 1404 if (m_root_pm != root_pm) {
1375 m_trans->setSource(root_pm, menu.window.screenNumber()); 1405 m_trans->setSource(root_pm, menu.window.screenNumber());
1376 m_root_pm = root_pm; 1406 m_root_pm = root_pm;
1377 } 1407 }
1378 menu.frame.clear(); 1408 menu.frame.clear();
1379 m_trans->setDest(menu.frame.window(), menu.window.screenNumber()); 1409 m_trans->setDest(menu.frame.window(), menu.window.screenNumber());
1380 m_trans->render(menu.window.x() + menu.frame.x() + menu.window.borderWidth(), 1410 m_trans->render(menu.window.x() + menu.frame.x() + menu.window.borderWidth(),
1381 menu.window.y() + menu.frame.y() + menu.window.borderWidth(), 1411 menu.window.y() + menu.frame.y() + menu.window.borderWidth(),
1382 0, 0, 1412 0, 0,
1383 menu.frame.width(), menu.frame.height()); 1413 menu.frame.width(), menu.frame.height());
1384 1414
1385 } 1415 }
1386 */ 1416 */
1387 menu.frame.clear(); 1417 menu.frame.clear();
1388 menu.frame.updateTransparent(); 1418 menu.frame.updateTransparent();
diff --git a/src/FbTk/MenuTheme.cc b/src/FbTk/MenuTheme.cc
index c83c480..2ecb38b 100644
--- a/src/FbTk/MenuTheme.cc
+++ b/src/FbTk/MenuTheme.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: MenuTheme.cc,v 1.9 2003/08/16 12:23:17 fluxgen Exp $ 22// $Id: MenuTheme.cc,v 1.10 2003/08/27 14:12:45 fluxgen Exp $
23 23
24#include "MenuTheme.hh" 24#include "MenuTheme.hh"
25 25
@@ -51,41 +51,33 @@ MenuTheme::MenuTheme(int screen_num):
51 m_border_width(*this, "borderWidth", "BorderWidth"), 51 m_border_width(*this, "borderWidth", "BorderWidth"),
52 m_bevel_width(*this, "bevelWidth", "BevelWidth"), 52 m_bevel_width(*this, "bevelWidth", "BevelWidth"),
53 m_border_color(*this, "borderColor", "BorderColor"), 53 m_border_color(*this, "borderColor", "BorderColor"),
54 m_bullet_pixmap(*this, "menu.submenu.pixmap", "Menu.Submenu.Pixmap"),
55 m_selected_pixmap(*this, "menu.selected.pixmap", "Menu.Selected.Pixmap"),
56 m_unselected_pixmap(*this, "menu.unselected.pixmap", "Menu.Unselected.Pixmap"),
54 m_display(FbTk::App::instance()->display()), 57 m_display(FbTk::App::instance()->display()),
55 m_alpha(255) 58 t_text_gc(RootWindow(m_display, screen_num)),
56{ 59 f_text_gc(RootWindow(m_display, screen_num)),
60 h_text_gc(RootWindow(m_display, screen_num)),
61 d_text_gc(RootWindow(m_display, screen_num)),
62 hilite_gc(RootWindow(m_display, screen_num)),
63 m_alpha(255) {
64
57 // set default values 65 // set default values
58 *m_border_width = 0; 66 *m_border_width = 0;
59 *m_bevel_width = 0; 67 *m_bevel_width = 0;
60 68
61 Window rootwindow = RootWindow(m_display, screen_num); 69 Window rootwindow = RootWindow(m_display, screen_num);
62 70
63 XGCValues gcv; 71 t_text_gc.setForeground(*t_text);
64 unsigned long gc_value_mask = GCForeground; 72 f_text_gc.setForeground(*f_text);
65 gcv.foreground = t_text->pixel(); 73 h_text_gc.setForeground(*h_text);
66 74 d_text_gc.setForeground(*d_text);
67 t_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv); 75 hilite_gc.setForeground(hilite->color());
68
69 gcv.foreground = f_text->pixel();
70
71 f_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
72 76
73 gcv.foreground = h_text->pixel();
74 h_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
75
76 gcv.foreground = d_text->pixel();
77 d_text_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
78
79 gcv.foreground = hilite->color().pixel();
80 hilite_gc = XCreateGC(m_display, rootwindow, gc_value_mask, &gcv);
81} 77}
82 78
83MenuTheme::~MenuTheme() { 79MenuTheme::~MenuTheme() {
84 XFreeGC(m_display, t_text_gc); 80
85 XFreeGC(m_display, f_text_gc);
86 XFreeGC(m_display, h_text_gc);
87 XFreeGC(m_display, d_text_gc);
88 XFreeGC(m_display, hilite_gc);
89} 81}
90 82
91void MenuTheme::reconfigTheme() { 83void MenuTheme::reconfigTheme() {
@@ -95,30 +87,15 @@ void MenuTheme::reconfigTheme() {
95 if (*m_border_width > 20) 87 if (*m_border_width > 20)
96 *m_border_width = 20; 88 *m_border_width = 20;
97 89
98 XGCValues gcv; 90 m_bullet_pixmap->scale(frameFont().height(), frameFont().height());
99 unsigned long gc_value_mask = GCForeground; 91 m_selected_pixmap->scale(frameFont().height(), frameFont().height());
100 92 m_unselected_pixmap->scale(frameFont().height(), frameFont().height());
101 gcv.foreground = t_text->pixel(); 93
102 94 t_text_gc.setForeground(*t_text);
103 XChangeGC(m_display, t_text_gc, 95 f_text_gc.setForeground(*f_text);
104 gc_value_mask, &gcv); 96 h_text_gc.setForeground(*h_text);
105 97 d_text_gc.setForeground(*d_text);
106 gcv.foreground = f_text->pixel(); 98 hilite_gc.setForeground(hilite->color());
107
108 XChangeGC(m_display, f_text_gc,
109 gc_value_mask, &gcv);
110
111 gcv.foreground = h_text->pixel();
112 XChangeGC(m_display, h_text_gc,
113 gc_value_mask, &gcv);
114
115 gcv.foreground = d_text->pixel();
116 XChangeGC(m_display, d_text_gc,
117 gc_value_mask, &gcv);
118
119 gcv.foreground = hilite->color().pixel();
120 XChangeGC(m_display, hilite_gc,
121 gc_value_mask, &gcv);
122 99
123 // notify any listeners 100 // notify any listeners
124 m_theme_change_sig.notify(); 101 m_theme_change_sig.notify();