diff options
author | fluxgen <fluxgen> | 2004-09-11 13:45:16 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2004-09-11 13:45:16 (GMT) |
commit | 768d98a39d3640f24ebe13e2c304fac3436a0a0d (patch) | |
tree | 3a5a60b06c4c2f3ba2e98e59c288c99ae93527b9 /src/FbTk | |
parent | 37757769634c836895d205b0a5149ffffaae9bfb (diff) | |
download | fluxbox-768d98a39d3640f24ebe13e2c304fac3436a0a0d.zip fluxbox-768d98a39d3640f24ebe13e2c304fac3436a0a0d.tar.bz2 |
head specific strut, patch from Mathieu De Zutter
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/Menu.cc | 55 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 7 |
2 files changed, 37 insertions, 25 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index c784498..a82f441 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.81 2004/09/11 12:33:14 rathnor Exp $ | 25 | // $Id: Menu.cc,v 1.82 2004/09/11 13:45:16 fluxgen Exp $ |
26 | 26 | ||
27 | //use GNU extensions | 27 | //use GNU extensions |
28 | #ifndef _GNU_SOURCE | 28 | #ifndef _GNU_SOURCE |
@@ -79,6 +79,8 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): | |||
79 | m_theme(tm), | 79 | m_theme(tm), |
80 | m_parent(0), | 80 | m_parent(0), |
81 | m_image_ctrl(imgctrl), | 81 | m_image_ctrl(imgctrl), |
82 | m_screen_x(0), | ||
83 | m_screen_y(0), | ||
82 | m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm.screenNum())), | 84 | m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm.screenNum())), |
83 | m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())), | 85 | m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())), |
84 | m_alignment(ALIGNDONTCARE), | 86 | m_alignment(ALIGNDONTCARE), |
@@ -192,8 +194,6 @@ Menu::~Menu() { | |||
192 | if (menu.sel_pixmap) | 194 | if (menu.sel_pixmap) |
193 | m_image_ctrl.removeImage(menu.sel_pixmap); | 195 | m_image_ctrl.removeImage(menu.sel_pixmap); |
194 | 196 | ||
195 | FbTk::EventManager &evm = *FbTk::EventManager::instance(); | ||
196 | |||
197 | if (s_focused == this) | 197 | if (s_focused == this) |
198 | s_focused = 0; | 198 | s_focused = 0; |
199 | } | 199 | } |
@@ -236,6 +236,7 @@ int Menu::remove(unsigned int index) { | |||
236 | 236 | ||
237 | if (item) { | 237 | if (item) { |
238 | menuitems.erase(it); | 238 | menuitems.erase(it); |
239 | |||
239 | if (!internal_menu && item->submenu() != 0) { | 240 | if (!internal_menu && item->submenu() != 0) { |
240 | Menu *tmp = item->submenu(); | 241 | Menu *tmp = item->submenu(); |
241 | // if menu is interal we should just hide it instead | 242 | // if menu is interal we should just hide it instead |
@@ -796,6 +797,8 @@ void Menu::drawSubmenu(unsigned int index) { | |||
796 | 797 | ||
797 | if (item->submenu()->m_parent != this) | 798 | if (item->submenu()->m_parent != this) |
798 | item->submenu()->m_parent = this; | 799 | item->submenu()->m_parent = this; |
800 | |||
801 | item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height); | ||
799 | 802 | ||
800 | int sbl = index / menu.persub, i = index - (sbl * menu.persub); | 803 | int sbl = index / menu.persub, i = index - (sbl * menu.persub); |
801 | int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth()); | 804 | int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth()); |
@@ -821,24 +824,26 @@ void Menu::drawSubmenu(unsigned int index) { | |||
821 | height() - item->submenu()->height()); | 824 | height() - item->submenu()->height()); |
822 | } | 825 | } |
823 | 826 | ||
824 | if ((new_x + item->submenu()->width()) > m_screen_width) { | 827 | int borderw = item->submenu()->fbwindow().borderWidth(); |
828 | |||
829 | if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { | ||
825 | new_x = ((shifted) ? menu.x_shift : x()) - | 830 | new_x = ((shifted) ? menu.x_shift : x()) - |
826 | item->submenu()->width() - menu.window.borderWidth(); | 831 | item->submenu()->width() - menu.window.borderWidth(); |
827 | } | 832 | } |
828 | 833 | ||
829 | if (new_x < 0) | 834 | if (new_x < m_screen_x) |
830 | new_x = 0; | 835 | new_x = m_screen_x; |
831 | 836 | ||
832 | if ((new_y + item->submenu()->height()) > m_screen_height) { | 837 | if ((new_y + item->submenu()->height()) > m_screen_y + m_screen_height) { |
833 | new_y = m_screen_height - item->submenu()->height() - | 838 | new_y = m_screen_y + m_screen_height - item->submenu()->height() - |
834 | menu.window.borderWidth() * 2; | 839 | menu.window.borderWidth() * 2; |
835 | } | 840 | } |
836 | 841 | ||
837 | item->submenu()->moving = moving; | 842 | item->submenu()->moving = moving; |
838 | which_sub = index; | 843 | which_sub = index; |
839 | 844 | ||
840 | if (new_y < 0) | 845 | if (new_y < m_screen_y) |
841 | new_y = 0; | 846 | new_y = m_screen_y; |
842 | 847 | ||
843 | item->submenu()->move(new_x, new_y); | 848 | item->submenu()->move(new_x, new_y); |
844 | if (! moving) | 849 | if (! moving) |
@@ -1085,10 +1090,11 @@ void Menu::buttonPressEvent(XButtonEvent &be) { | |||
1085 | if (item->submenu()) { | 1090 | if (item->submenu()) { |
1086 | if (!item->submenu()->isVisible()) | 1091 | if (!item->submenu()->isVisible()) |
1087 | drawSubmenu(w); | 1092 | drawSubmenu(w); |
1088 | } else | 1093 | } else { |
1089 | drawItem(w, | 1094 | drawItem(w, |
1090 | true, // clear | 1095 | true, // clear |
1091 | true); // render transparency | 1096 | true); // render transparency |
1097 | } | ||
1092 | 1098 | ||
1093 | } | 1099 | } |
1094 | } else { | 1100 | } else { |
@@ -1120,14 +1126,10 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { | |||
1120 | } | 1126 | } |
1121 | } | 1127 | } |
1122 | 1128 | ||
1123 | if (re.x >= 0 && re.x <= (signed) width() && | 1129 | if (re.button == 3) |
1124 | re.y >= 0 && re.y <= (signed) theme().titleHeight() && | ||
1125 | re.button == 3) | ||
1126 | hide(); | 1130 | hide(); |
1127 | 1131 | ||
1128 | } else if (re.window == menu.frame && | 1132 | } else if (re.window == menu.frame) { |
1129 | re.x >= 0 && re.x < (signed) width() && | ||
1130 | re.y >= 0 && re.y < (signed) menu.frame_h) { | ||
1131 | 1133 | ||
1132 | int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), | 1134 | int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), |
1133 | ix = sbl * menu.item_w, iy = i * theme().itemHeight(), | 1135 | ix = sbl * menu.item_w, iy = i * theme().itemHeight(), |
@@ -1140,17 +1142,16 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { | |||
1140 | re.y > iy && re.y < (signed) (iy + theme().itemHeight())) { | 1142 | re.y > iy && re.y < (signed) (iy + theme().itemHeight())) { |
1141 | menuitems[w]->click(re.button, re.time); | 1143 | menuitems[w]->click(re.button, re.time); |
1142 | itemSelected(re.button, w); | 1144 | itemSelected(re.button, w); |
1143 | // just redraw this item | 1145 | drawItem(w, |
1144 | drawItem(w, | ||
1145 | true, // clear | 1146 | true, // clear |
1146 | true); // transparent | 1147 | true); // transparent |
1147 | } | 1148 | } |
1149 | |||
1148 | } else { | 1150 | } else { |
1149 | drawItem(p, | 1151 | drawItem(p, |
1150 | true, // clear | 1152 | true, // clear |
1151 | true); // transparent | 1153 | true); // transparent |
1152 | } | 1154 | } |
1153 | |||
1154 | } else { | 1155 | } else { |
1155 | drawItem(p, | 1156 | drawItem(p, |
1156 | true, // clear | 1157 | true, // clear |
@@ -1284,8 +1285,8 @@ void Menu::enterNotifyEvent(XCrossingEvent &ce) { | |||
1284 | return; | 1285 | return; |
1285 | 1286 | ||
1286 | menu.x_shift = x(), menu.y_shift = y(); | 1287 | menu.x_shift = x(), menu.y_shift = y(); |
1287 | if (x() + width() > m_screen_width) { | 1288 | if (x() + width() > m_screen_x + m_screen_width) { |
1288 | menu.x_shift = m_screen_width - width() - 2*theme().borderWidth(); | 1289 | menu.x_shift = m_screen_x + m_screen_width - width() - 2*theme().borderWidth(); |
1289 | shifted = true; | 1290 | shifted = true; |
1290 | } else if (x() < 0) { | 1291 | } else if (x() < 0) { |
1291 | menu.x_shift = 0; //-theme().borderWidth(); | 1292 | menu.x_shift = 0; //-theme().borderWidth(); |
@@ -1381,6 +1382,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1381 | } | 1382 | } |
1382 | } | 1383 | } |
1383 | 1384 | ||
1385 | |||
1384 | void Menu::reconfigure() { | 1386 | void Menu::reconfigure() { |
1385 | 1387 | ||
1386 | 1388 | ||
@@ -1515,4 +1517,11 @@ void Menu::renderTransp(int x, int y, | |||
1515 | 1517 | ||
1516 | } | 1518 | } |
1517 | 1519 | ||
1520 | void Menu::setScreen(int x, int y, int w, int h) { | ||
1521 | m_screen_x = x; | ||
1522 | m_screen_y = y; | ||
1523 | m_screen_width = w; | ||
1524 | m_screen_height = h; | ||
1525 | } | ||
1526 | |||
1518 | }; // end namespace FbTk | 1527 | }; // end namespace FbTk |
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index d5f6b83..43ca828 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -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.hh,v 1.39 2004/08/29 12:35:29 rathnor Exp $ | 25 | // $Id: Menu.hh,v 1.40 2004/09/11 13:45:16 fluxgen Exp $ |
26 | 26 | ||
27 | #ifndef FBTK_MENU_HH | 27 | #ifndef FBTK_MENU_HH |
28 | #define FBTK_MENU_HH | 28 | #define FBTK_MENU_HH |
@@ -95,6 +95,8 @@ public: | |||
95 | void disableTitle(); | 95 | void disableTitle(); |
96 | void enableTitle(); | 96 | void enableTitle(); |
97 | 97 | ||
98 | void setScreen(int x, int y, int w, int h); | ||
99 | |||
98 | /** | 100 | /** |
99 | @name event handlers | 101 | @name event handlers |
100 | */ | 102 | */ |
@@ -200,7 +202,8 @@ private: | |||
200 | ImageControl &m_image_ctrl; | 202 | ImageControl &m_image_ctrl; |
201 | Menuitems menuitems; | 203 | Menuitems menuitems; |
202 | 204 | ||
203 | const unsigned int m_screen_width, m_screen_height; | 205 | int m_screen_x, m_screen_y; |
206 | int m_screen_width, m_screen_height; | ||
204 | bool moving; ///< if we're moving/draging or not | 207 | bool moving; ///< if we're moving/draging or not |
205 | bool visible; ///< menu visibility | 208 | bool visible; ///< menu visibility |
206 | bool torn; ///< torn from parent | 209 | bool torn; ///< torn from parent |