aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Menu.cc
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/Menu.cc
parent097fcff44f305dcd4c10cc6d2cac9ad5092d5e94 (diff)
downloadfluxbox-2be2a2b5cccefa775c3f6dd917da00984f99cc1a.zip
fluxbox-2be2a2b5cccefa775c3f6dd917da00984f99cc1a.tar.bz2
added pixmap for bullet and selected and unselected
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r--src/FbTk/Menu.cc270
1 files changed, 150 insertions, 120 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();