diff options
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r-- | src/FbTk/Menu.cc | 77 |
1 files changed, 8 insertions, 69 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 3524ee1..ee678c1 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -101,17 +101,14 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): | |||
101 | 101 | ||
102 | m_title_vis = true; | 102 | m_title_vis = true; |
103 | 103 | ||
104 | m_shifted = | 104 | m_internal_menu = |
105 | m_internal_menu = | ||
106 | m_moving = | 105 | m_moving = |
107 | m_torn = | 106 | m_torn = |
108 | m_visible = false; | 107 | m_visible = false; |
109 | 108 | ||
110 | 109 | ||
111 | 110 | ||
112 | menu.x_shift = | 111 | menu.x_move = |
113 | menu.y_shift = | ||
114 | menu.x_move = | ||
115 | menu.y_move = 0; | 112 | menu.y_move = 0; |
116 | 113 | ||
117 | m_which_sub = | 114 | m_which_sub = |
@@ -692,30 +689,25 @@ void Menu::drawSubmenu(unsigned int index) { | |||
692 | int new_y; | 689 | int new_y; |
693 | 690 | ||
694 | if (m_alignment == ALIGNTOP) { | 691 | if (m_alignment == ALIGNTOP) { |
695 | new_y = (((m_shifted) ? menu.y_shift : y()) + | 692 | new_y = (y() + ((m_title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - |
696 | ((m_title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - | ||
697 | ((item->submenu()->m_title_vis) ? | 693 | ((item->submenu()->m_title_vis) ? |
698 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); | 694 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); |
699 | } else { | 695 | } else { |
700 | new_y = (((m_shifted) ? menu.y_shift : y()) + | 696 | new_y = (y() + (theme().itemHeight() * i) + |
701 | (theme().itemHeight() * i) + | ||
702 | ((m_title_vis) ? theme().titleHeight() + menu.window.borderWidth() : 0) - | 697 | ((m_title_vis) ? theme().titleHeight() + menu.window.borderWidth() : 0) - |
703 | ((item->submenu()->m_title_vis) ? | 698 | ((item->submenu()->m_title_vis) ? |
704 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); | 699 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); |
705 | } | 700 | } |
706 | 701 | ||
707 | if (m_alignment == ALIGNBOTTOM && | 702 | if (m_alignment == ALIGNBOTTOM && |
708 | (new_y + item->submenu()->height()) > ((m_shifted) ? menu.y_shift : | 703 | (new_y + item->submenu()->height()) > (y() + height())) { |
709 | y()) + height()) { | 704 | new_y = (y() + height() - item->submenu()->height()); |
710 | new_y = (((m_shifted) ? menu.y_shift : y()) + | ||
711 | height() - item->submenu()->height()); | ||
712 | } | 705 | } |
713 | 706 | ||
714 | int borderw = item->submenu()->fbwindow().borderWidth(); | 707 | int borderw = item->submenu()->fbwindow().borderWidth(); |
715 | 708 | ||
716 | if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { | 709 | if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { |
717 | new_x = ((m_shifted) ? menu.x_shift : x()) - | 710 | new_x = x() - item->submenu()->width() - menu.window.borderWidth(); |
718 | item->submenu()->width() - menu.window.borderWidth(); | ||
719 | } | 711 | } |
720 | 712 | ||
721 | if (new_x < m_screen_x) | 713 | if (new_x < m_screen_x) |
@@ -735,7 +727,7 @@ void Menu::drawSubmenu(unsigned int index) { | |||
735 | item->submenu()->move(new_x, new_y); | 727 | item->submenu()->move(new_x, new_y); |
736 | if (! m_moving) | 728 | if (! m_moving) |
737 | clearItem(index); | 729 | clearItem(index); |
738 | 730 | ||
739 | if (! item->submenu()->isVisible()) { | 731 | if (! item->submenu()->isVisible()) { |
740 | item->showSubmenu(); | 732 | item->showSubmenu(); |
741 | item->submenu()->raise(); | 733 | item->submenu()->raise(); |
@@ -1060,59 +1052,6 @@ void Menu::exposeEvent(XExposeEvent &ee) { | |||
1060 | } | 1052 | } |
1061 | } | 1053 | } |
1062 | 1054 | ||
1063 | |||
1064 | void Menu::enterNotifyEvent(XCrossingEvent &ce) { | ||
1065 | |||
1066 | if (menu.frame != ce.window) | ||
1067 | return; | ||
1068 | |||
1069 | menu.x_shift = x(), menu.y_shift = y(); | ||
1070 | if (x() + width() > m_screen_x + m_screen_width) { | ||
1071 | menu.x_shift = m_screen_x + m_screen_width - width() - 2*theme().borderWidth(); | ||
1072 | m_shifted = true; | ||
1073 | } else if (x() < 0) { | ||
1074 | menu.x_shift = 0; //-theme().borderWidth(); | ||
1075 | m_shifted = true; | ||
1076 | } | ||
1077 | |||
1078 | if (y() + height() + 2*theme().borderWidth() > m_screen_y + m_screen_height) { | ||
1079 | menu.y_shift = m_screen_y + m_screen_height - height() - 2*theme().borderWidth(); | ||
1080 | m_shifted = true; | ||
1081 | } else if (y() + (signed) theme().titleHeight() < 0) { | ||
1082 | menu.y_shift = 0; // -theme().borderWidth();; | ||
1083 | m_shifted = true; | ||
1084 | } | ||
1085 | |||
1086 | |||
1087 | if (m_shifted) { | ||
1088 | menu.window.move(menu.x_shift, menu.y_shift); | ||
1089 | menu.title.parentMoved(); | ||
1090 | menu.frame.parentMoved(); | ||
1091 | clearWindow(); | ||
1092 | } | ||
1093 | |||
1094 | if (validIndex(m_which_sub)) { | ||
1095 | MenuItem *tmp = menuitems[m_which_sub]; | ||
1096 | if (tmp->submenu()->isVisible()) { | ||
1097 | int sbl = (ce.x / menu.item_w), i = (ce.y / theme().itemHeight()), | ||
1098 | w = (sbl * menu.persub) + i; | ||
1099 | |||
1100 | if (w != m_which_sub && (! tmp->submenu()->isTorn())) { | ||
1101 | tmp->submenu()->internal_hide(); | ||
1102 | |||
1103 | clearItem(m_which_sub); // not highlighted anymore | ||
1104 | m_which_sub = -1; | ||
1105 | } | ||
1106 | } | ||
1107 | } | ||
1108 | } | ||
1109 | |||
1110 | void Menu::leaveNotifyEvent(XCrossingEvent &ce) { | ||
1111 | if (menu.frame != ce.window) | ||
1112 | return; | ||
1113 | |||
1114 | } | ||
1115 | |||
1116 | void Menu::keyPressEvent(XKeyEvent &event) { | 1055 | void Menu::keyPressEvent(XKeyEvent &event) { |
1117 | KeySym ks; | 1056 | KeySym ks; |
1118 | char keychar[1]; | 1057 | char keychar[1]; |