diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Menu.cc | 236 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 28 |
2 files changed, 132 insertions, 132 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 7cf076b..7f01c77 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -1,5 +1,5 @@ | |||
1 | // Menu.cc for FbTk - Fluxbox Toolkit | 1 | // Menu.cc for FbTk - Fluxbox Toolkit |
2 | // Copyright (c) 2001 - 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) | 2 | // Copyright (c) 2001 - 2005 Henrik Kinnunen (fluxgen at users.sourceforge.net) |
3 | // | 3 | // |
4 | // Basemenu.cc for blackbox - an X11 Window manager | 4 | // Basemenu.cc for blackbox - an X11 Window manager |
5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net) | 5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net) |
@@ -101,13 +101,13 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): | |||
101 | // make sure we get updated when the theme is reloaded | 101 | // make sure we get updated when the theme is reloaded |
102 | tm.reconfigSig().attach(this); | 102 | tm.reconfigSig().attach(this); |
103 | 103 | ||
104 | title_vis = true; | 104 | m_title_vis = true; |
105 | 105 | ||
106 | shifted = | 106 | m_shifted = |
107 | internal_menu = | 107 | m_internal_menu = |
108 | moving = | 108 | m_moving = |
109 | torn = | 109 | m_torn = |
110 | visible = false; | 110 | m_visible = false; |
111 | 111 | ||
112 | 112 | ||
113 | 113 | ||
@@ -116,9 +116,9 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl): | |||
116 | menu.x_move = | 116 | menu.x_move = |
117 | menu.y_move = 0; | 117 | menu.y_move = 0; |
118 | 118 | ||
119 | which_sub = | 119 | m_which_sub = |
120 | which_press = | 120 | m_which_press = |
121 | which_sbl = -1; | 121 | m_which_sbl = -1; |
122 | 122 | ||
123 | menu.frame_pixmap = | 123 | menu.frame_pixmap = |
124 | menu.title_pixmap = | 124 | menu.title_pixmap = |
@@ -237,11 +237,11 @@ int Menu::remove(unsigned int index) { | |||
237 | if (item) { | 237 | if (item) { |
238 | menuitems.erase(it); | 238 | menuitems.erase(it); |
239 | 239 | ||
240 | if (!internal_menu && item->submenu() != 0) { | 240 | if (!m_internal_menu && item->submenu() != 0) { |
241 | Menu *tmp = item->submenu(); | 241 | Menu *tmp = item->submenu(); |
242 | // if menu is interal we should just hide it instead | 242 | // if menu is interal we should just hide it instead |
243 | // if destroying it | 243 | // if destroying it |
244 | if (! tmp->internal_menu) { | 244 | if (! tmp->m_internal_menu) { |
245 | delete tmp; | 245 | delete tmp; |
246 | } else | 246 | } else |
247 | tmp->internal_hide(); | 247 | tmp->internal_hide(); |
@@ -251,10 +251,10 @@ int Menu::remove(unsigned int index) { | |||
251 | delete item; | 251 | delete item; |
252 | } | 252 | } |
253 | 253 | ||
254 | if (static_cast<unsigned int>(which_sub) == index) | 254 | if (static_cast<unsigned int>(m_which_sub) == index) |
255 | which_sub = -1; | 255 | m_which_sub = -1; |
256 | else if (static_cast<unsigned int>(which_sub) > index) | 256 | else if (static_cast<unsigned int>(m_which_sub) > index) |
257 | which_sub--; | 257 | m_which_sub--; |
258 | 258 | ||
259 | m_need_update = true; // we need to redraw the menu | 259 | m_need_update = true; // we need to redraw the menu |
260 | 260 | ||
@@ -277,7 +277,7 @@ void Menu::lower() { | |||
277 | } | 277 | } |
278 | 278 | ||
279 | void Menu::nextItem() { | 279 | void Menu::nextItem() { |
280 | int old_which_press = which_press; | 280 | int old_which_press = m_which_press; |
281 | m_active_index = -1; | 281 | m_active_index = -1; |
282 | if (validIndex(old_which_press) && | 282 | if (validIndex(old_which_press) && |
283 | menuitems[old_which_press] != 0) { | 283 | menuitems[old_which_press] != 0) { |
@@ -291,25 +291,25 @@ void Menu::nextItem() { | |||
291 | true); // transp | 291 | true); // transp |
292 | } | 292 | } |
293 | 293 | ||
294 | // restore old in case we changed which_press | 294 | // restore old in case we changed m_which_press |
295 | which_press = old_which_press + 1; | 295 | m_which_press = old_which_press + 1; |
296 | if (!validIndex(which_press)) | 296 | if (!validIndex(m_which_press)) |
297 | which_press = 0; | 297 | m_which_press = 0; |
298 | 298 | ||
299 | 299 | ||
300 | if (menuitems[which_press] == 0) { | 300 | if (menuitems[m_which_press] == 0) { |
301 | m_active_index = -1; | 301 | m_active_index = -1; |
302 | return; | 302 | return; |
303 | } | 303 | } |
304 | 304 | ||
305 | if (!isItemSelectable(which_press)) { | 305 | if (!isItemSelectable(m_which_press)) { |
306 | nextItem(); | 306 | nextItem(); |
307 | return; | 307 | return; |
308 | } | 308 | } |
309 | 309 | ||
310 | m_active_index = which_press; | 310 | m_active_index = m_which_press; |
311 | 311 | ||
312 | drawItem(which_press, | 312 | drawItem(m_which_press, |
313 | true, // clear | 313 | true, // clear |
314 | true); // transp | 314 | true); // transp |
315 | 315 | ||
@@ -317,7 +317,7 @@ void Menu::nextItem() { | |||
317 | 317 | ||
318 | void Menu::prevItem() { | 318 | void Menu::prevItem() { |
319 | 319 | ||
320 | int old_which_press = which_press; | 320 | int old_which_press = m_which_press; |
321 | m_active_index = -1; | 321 | m_active_index = -1; |
322 | if (validIndex(old_which_press)) { | 322 | if (validIndex(old_which_press)) { |
323 | if (menuitems[old_which_press]->submenu()) { | 323 | if (menuitems[old_which_press]->submenu()) { |
@@ -329,62 +329,62 @@ void Menu::prevItem() { | |||
329 | true, // clear | 329 | true, // clear |
330 | true); // transp | 330 | true); // transp |
331 | } | 331 | } |
332 | // restore old in case we changed which_press | 332 | // restore old in case we changed m_which_press |
333 | which_press = old_which_press - 1; | 333 | m_which_press = old_which_press - 1; |
334 | 334 | ||
335 | if (!validIndex(which_press)) | 335 | if (!validIndex(m_which_press)) |
336 | which_press = menuitems.size() - 1; | 336 | m_which_press = menuitems.size() - 1; |
337 | 337 | ||
338 | if (menuitems[which_press] == 0) { | 338 | if (menuitems[m_which_press] == 0) { |
339 | m_active_index = -1; | 339 | m_active_index = -1; |
340 | return; | 340 | return; |
341 | } | 341 | } |
342 | 342 | ||
343 | if (!isItemSelectable(which_press)) { | 343 | if (!isItemSelectable(m_which_press)) { |
344 | prevItem(); | 344 | prevItem(); |
345 | return; | 345 | return; |
346 | } | 346 | } |
347 | 347 | ||
348 | m_active_index = which_press; | 348 | m_active_index = m_which_press; |
349 | 349 | ||
350 | drawItem(which_press, | 350 | drawItem(m_which_press, |
351 | true, // clear | 351 | true, // clear |
352 | true); // transp | 352 | true); // transp |
353 | 353 | ||
354 | } | 354 | } |
355 | 355 | ||
356 | void Menu::enterSubmenu() { | 356 | void Menu::enterSubmenu() { |
357 | if (!validIndex(which_press)) | 357 | if (!validIndex(m_which_press)) |
358 | return; | 358 | return; |
359 | 359 | ||
360 | Menu *submenu = menuitems[which_press]->submenu(); | 360 | Menu *submenu = menuitems[m_which_press]->submenu(); |
361 | if (submenu == 0) | 361 | if (submenu == 0) |
362 | return; | 362 | return; |
363 | 363 | ||
364 | if (submenu->menuitems.size() == 0) | 364 | if (submenu->menuitems.size() == 0) |
365 | return; | 365 | return; |
366 | 366 | ||
367 | drawSubmenu(which_press); | 367 | drawSubmenu(m_which_press); |
368 | submenu->grabInputFocus(); | 368 | submenu->grabInputFocus(); |
369 | submenu->which_press = -1; // so we land on 0 after nextItem() | 369 | submenu->m_which_press = -1; // so we land on 0 after nextItem() |
370 | submenu->nextItem(); | 370 | submenu->nextItem(); |
371 | } | 371 | } |
372 | 372 | ||
373 | void Menu::enterParent() { | 373 | void Menu::enterParent() { |
374 | if (!validIndex(which_press) || parent() == 0) | 374 | if (!validIndex(m_which_press) || parent() == 0) |
375 | return; | 375 | return; |
376 | 376 | ||
377 | Menu *submenu = menuitems[which_press]->submenu(); | 377 | Menu *submenu = menuitems[m_which_press]->submenu(); |
378 | if (submenu) | 378 | if (submenu) |
379 | submenu->internal_hide(); | 379 | submenu->internal_hide(); |
380 | 380 | ||
381 | m_active_index = -1; | 381 | m_active_index = -1; |
382 | drawItem(which_press, | 382 | drawItem(m_which_press, |
383 | true, // clear | 383 | true, // clear |
384 | true); // transp | 384 | true); // transp |
385 | which_press = -1; // dont select any in this | 385 | m_which_press = -1; // dont select any in this |
386 | // hide self | 386 | // hide self |
387 | visible = false; | 387 | m_visible = false; |
388 | menu.window.hide(); | 388 | menu.window.hide(); |
389 | // return focus to parent | 389 | // return focus to parent |
390 | parent()->grabInputFocus(); | 390 | parent()->grabInputFocus(); |
@@ -399,7 +399,7 @@ void Menu::enableTitle() { | |||
399 | } | 399 | } |
400 | 400 | ||
401 | void Menu::updateMenu(int active_index) { | 401 | void Menu::updateMenu(int active_index) { |
402 | if (title_vis) { | 402 | if (m_title_vis) { |
403 | menu.item_w = theme().titleFont().textWidth(menu.label.c_str(), | 403 | menu.item_w = theme().titleFont().textWidth(menu.label.c_str(), |
404 | menu.label.size()); | 404 | menu.label.size()); |
405 | 405 | ||
@@ -439,7 +439,7 @@ void Menu::updateMenu(int active_index) { | |||
439 | int new_width = (menu.sublevels * menu.item_w); | 439 | int new_width = (menu.sublevels * menu.item_w); |
440 | int new_height = menu.frame_h; | 440 | int new_height = menu.frame_h; |
441 | 441 | ||
442 | if (title_vis) | 442 | if (m_title_vis) |
443 | new_height += theme().titleHeight() + ((menu.frame_h > 0)?menu.title.borderWidth():0); | 443 | new_height += theme().titleHeight() + ((menu.frame_h > 0)?menu.title.borderWidth():0); |
444 | 444 | ||
445 | 445 | ||
@@ -456,7 +456,7 @@ void Menu::updateMenu(int active_index) { | |||
456 | menu.window.resize(new_width, new_height); | 456 | menu.window.resize(new_width, new_height); |
457 | 457 | ||
458 | Pixmap tmp = 0; | 458 | Pixmap tmp = 0; |
459 | if (title_vis && m_need_update) { | 459 | if (m_title_vis && m_need_update) { |
460 | tmp = menu.title_pixmap; | 460 | tmp = menu.title_pixmap; |
461 | const FbTk::Texture &tex = theme().titleTexture(); | 461 | const FbTk::Texture &tex = theme().titleTexture(); |
462 | if (!tex.usePixmap()) { | 462 | if (!tex.usePixmap()) { |
@@ -547,12 +547,12 @@ void Menu::updateMenu(int active_index) { | |||
547 | 547 | ||
548 | 548 | ||
549 | 549 | ||
550 | if (title_vis) { | 550 | if (m_title_vis) { |
551 | menu.title.moveResize(-menu.title.borderWidth(), -menu.title.borderWidth(), | 551 | menu.title.moveResize(-menu.title.borderWidth(), -menu.title.borderWidth(), |
552 | width() + menu.title.borderWidth(), theme().titleHeight()); | 552 | width() + menu.title.borderWidth(), theme().titleHeight()); |
553 | } | 553 | } |
554 | 554 | ||
555 | menu.frame.moveResize(0, ((title_vis) ? menu.title.y() + menu.title.height() + | 555 | menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + |
556 | menu.title.borderWidth()*2 : 1), | 556 | menu.title.borderWidth()*2 : 1), |
557 | width(), menu.frame_h); | 557 | width(), menu.frame_h); |
558 | 558 | ||
@@ -603,8 +603,8 @@ void Menu::updateMenu(int active_index) { | |||
603 | 603 | ||
604 | } | 604 | } |
605 | 605 | ||
606 | // if menu visible and title visible | 606 | // if menu m_visible and title m_visible |
607 | if (title_vis && visible) | 607 | if (m_title_vis && m_visible) |
608 | redrawTitle(); | 608 | redrawTitle(); |
609 | 609 | ||
610 | if (active_index >= 0 || m_need_update) { | 610 | if (active_index >= 0 || m_need_update) { |
@@ -631,10 +631,10 @@ void Menu::show() { | |||
631 | menu.window.showSubwindows(); | 631 | menu.window.showSubwindows(); |
632 | menu.window.show(); | 632 | menu.window.show(); |
633 | raise(); | 633 | raise(); |
634 | visible = true; | 634 | m_visible = true; |
635 | 635 | ||
636 | if (! m_parent && shown != this) { | 636 | if (! m_parent && shown != this) { |
637 | if (shown && (! shown->torn)) | 637 | if (shown && (! shown->m_torn)) |
638 | shown->hide(); | 638 | shown->hide(); |
639 | 639 | ||
640 | shown = this; | 640 | shown = this; |
@@ -649,12 +649,12 @@ void Menu::hide() { | |||
649 | return; | 649 | return; |
650 | 650 | ||
651 | 651 | ||
652 | // if not torn and parent is visible, go to first parent | 652 | // if not m_torn and parent is m_visible, go to first parent |
653 | // and hide it | 653 | // and hide it |
654 | if (!torn && m_parent && m_parent->isVisible()) { | 654 | if (!m_torn && m_parent && m_parent->isVisible()) { |
655 | Menu *p = m_parent; | 655 | Menu *p = m_parent; |
656 | 656 | ||
657 | while ((! p->torn) && p->m_parent && p->m_parent->isVisible()) | 657 | while ((! p->m_torn) && p->m_parent && p->m_parent->isVisible()) |
658 | p = p->m_parent; | 658 | p = p->m_parent; |
659 | 659 | ||
660 | p->internal_hide(); | 660 | p->internal_hide(); |
@@ -686,8 +686,8 @@ void Menu::clearWindow() { | |||
686 | 686 | ||
687 | void Menu::internal_hide() { | 687 | void Menu::internal_hide() { |
688 | 688 | ||
689 | if (validIndex(which_sub)) { | 689 | if (validIndex(m_which_sub)) { |
690 | MenuItem *tmp = menuitems[which_sub]; | 690 | MenuItem *tmp = menuitems[m_which_sub]; |
691 | tmp->submenu()->internal_hide(); | 691 | tmp->submenu()->internal_hide(); |
692 | } | 692 | } |
693 | 693 | ||
@@ -700,8 +700,8 @@ void Menu::internal_hide() { | |||
700 | if (shown && shown->menu.window == menu.window) | 700 | if (shown && shown->menu.window == menu.window) |
701 | shown = (Menu *) 0; | 701 | shown = (Menu *) 0; |
702 | 702 | ||
703 | torn = visible = false; | 703 | m_torn = m_visible = false; |
704 | which_sub = which_press = which_sub = -1; | 704 | m_which_sub = m_which_press = m_which_sub = -1; |
705 | 705 | ||
706 | menu.window.hide(); | 706 | menu.window.hide(); |
707 | } | 707 | } |
@@ -711,7 +711,7 @@ void Menu::move(int x, int y) { | |||
711 | if (x == this->x() && y == this->y()) | 711 | if (x == this->x() && y == this->y()) |
712 | return; | 712 | return; |
713 | 713 | ||
714 | // if we're not visible and we do transparency | 714 | // if we're not m_visible and we do transparency |
715 | // we need to update transparency when we call | 715 | // we need to update transparency when we call |
716 | // show() next time | 716 | // show() next time |
717 | if (alpha() < 255) | 717 | if (alpha() < 255) |
@@ -722,8 +722,8 @@ void Menu::move(int x, int y) { | |||
722 | if (!isVisible()) | 722 | if (!isVisible()) |
723 | return; | 723 | return; |
724 | 724 | ||
725 | if (which_sub != -1) | 725 | if (m_which_sub != -1) |
726 | drawSubmenu(which_sub); | 726 | drawSubmenu(m_which_sub); |
727 | 727 | ||
728 | if (alpha() < 255) { | 728 | if (alpha() < 255) { |
729 | redrawTitle(); | 729 | redrawTitle(); |
@@ -783,8 +783,8 @@ void Menu::redrawTitle() { | |||
783 | 783 | ||
784 | 784 | ||
785 | void Menu::drawSubmenu(unsigned int index) { | 785 | void Menu::drawSubmenu(unsigned int index) { |
786 | if (validIndex(which_sub) && static_cast<unsigned int>(which_sub) != index) { | 786 | if (validIndex(m_which_sub) && static_cast<unsigned int>(m_which_sub) != index) { |
787 | MenuItem *itmp = menuitems[which_sub]; | 787 | MenuItem *itmp = menuitems[m_which_sub]; |
788 | 788 | ||
789 | if (! itmp->submenu()->isTorn()) | 789 | if (! itmp->submenu()->isTorn()) |
790 | itmp->submenu()->internal_hide(); | 790 | itmp->submenu()->internal_hide(); |
@@ -794,7 +794,7 @@ void Menu::drawSubmenu(unsigned int index) { | |||
794 | return; | 794 | return; |
795 | 795 | ||
796 | MenuItem *item = menuitems[index]; | 796 | MenuItem *item = menuitems[index]; |
797 | if (item->submenu() && visible && (! item->submenu()->isTorn()) && | 797 | if (item->submenu() && m_visible && (! item->submenu()->isTorn()) && |
798 | item->isEnabled()) { | 798 | item->isEnabled()) { |
799 | 799 | ||
800 | if (item->submenu()->m_parent != this) | 800 | if (item->submenu()->m_parent != this) |
@@ -807,29 +807,29 @@ void Menu::drawSubmenu(unsigned int index) { | |||
807 | int new_y; | 807 | int new_y; |
808 | 808 | ||
809 | if (m_alignment == ALIGNTOP) { | 809 | if (m_alignment == ALIGNTOP) { |
810 | new_y = (((shifted) ? menu.y_shift : y()) + | 810 | new_y = (((m_shifted) ? menu.y_shift : y()) + |
811 | ((title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - | 811 | ((m_title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - |
812 | ((item->submenu()->title_vis) ? | 812 | ((item->submenu()->m_title_vis) ? |
813 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); | 813 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); |
814 | } else { | 814 | } else { |
815 | new_y = (((shifted) ? menu.y_shift : y()) + | 815 | new_y = (((m_shifted) ? menu.y_shift : y()) + |
816 | (theme().itemHeight() * i) + | 816 | (theme().itemHeight() * i) + |
817 | ((title_vis) ? theme().titleHeight() + menu.window.borderWidth() : 0) - | 817 | ((m_title_vis) ? theme().titleHeight() + menu.window.borderWidth() : 0) - |
818 | ((item->submenu()->title_vis) ? | 818 | ((item->submenu()->m_title_vis) ? |
819 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); | 819 | item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); |
820 | } | 820 | } |
821 | 821 | ||
822 | if (m_alignment == ALIGNBOTTOM && | 822 | if (m_alignment == ALIGNBOTTOM && |
823 | (new_y + item->submenu()->height()) > ((shifted) ? menu.y_shift : | 823 | (new_y + item->submenu()->height()) > ((m_shifted) ? menu.y_shift : |
824 | y()) + height()) { | 824 | y()) + height()) { |
825 | new_y = (((shifted) ? menu.y_shift : y()) + | 825 | new_y = (((m_shifted) ? menu.y_shift : y()) + |
826 | height() - item->submenu()->height()); | 826 | height() - item->submenu()->height()); |
827 | } | 827 | } |
828 | 828 | ||
829 | int borderw = item->submenu()->fbwindow().borderWidth(); | 829 | int borderw = item->submenu()->fbwindow().borderWidth(); |
830 | 830 | ||
831 | if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { | 831 | if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { |
832 | new_x = ((shifted) ? menu.x_shift : x()) - | 832 | new_x = ((m_shifted) ? menu.x_shift : x()) - |
833 | item->submenu()->width() - menu.window.borderWidth(); | 833 | item->submenu()->width() - menu.window.borderWidth(); |
834 | } | 834 | } |
835 | 835 | ||
@@ -841,14 +841,14 @@ void Menu::drawSubmenu(unsigned int index) { | |||
841 | menu.window.borderWidth() * 2; | 841 | menu.window.borderWidth() * 2; |
842 | } | 842 | } |
843 | 843 | ||
844 | item->submenu()->moving = moving; | 844 | item->submenu()->m_moving = m_moving; |
845 | which_sub = index; | 845 | m_which_sub = index; |
846 | 846 | ||
847 | if (new_y < m_screen_y) | 847 | if (new_y < m_screen_y) |
848 | new_y = m_screen_y; | 848 | new_y = m_screen_y; |
849 | 849 | ||
850 | item->submenu()->move(new_x, new_y); | 850 | item->submenu()->move(new_x, new_y); |
851 | if (! moving) | 851 | if (! m_moving) |
852 | drawItem(index); | 852 | drawItem(index); |
853 | 853 | ||
854 | if (! item->submenu()->isVisible()) { | 854 | if (! item->submenu()->isVisible()) { |
@@ -858,7 +858,7 @@ void Menu::drawSubmenu(unsigned int index) { | |||
858 | 858 | ||
859 | 859 | ||
860 | } else | 860 | } else |
861 | which_sub = -1; | 861 | m_which_sub = -1; |
862 | 862 | ||
863 | } | 863 | } |
864 | 864 | ||
@@ -1084,8 +1084,8 @@ void Menu::buttonPressEvent(XButtonEvent &be) { | |||
1084 | int w = (sbl * menu.persub) + i; | 1084 | int w = (sbl * menu.persub) + i; |
1085 | 1085 | ||
1086 | if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) { | 1086 | if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) { |
1087 | which_press = i; | 1087 | m_which_press = i; |
1088 | which_sbl = sbl; | 1088 | m_which_sbl = sbl; |
1089 | 1089 | ||
1090 | MenuItem *item = menuitems[w]; | 1090 | MenuItem *item = menuitems[w]; |
1091 | 1091 | ||
@@ -1108,11 +1108,11 @@ void Menu::buttonPressEvent(XButtonEvent &be) { | |||
1108 | 1108 | ||
1109 | void Menu::buttonReleaseEvent(XButtonEvent &re) { | 1109 | void Menu::buttonReleaseEvent(XButtonEvent &re) { |
1110 | if (re.window == menu.title) { | 1110 | if (re.window == menu.title) { |
1111 | if (moving) { | 1111 | if (m_moving) { |
1112 | moving = false; | 1112 | m_moving = false; |
1113 | 1113 | ||
1114 | if (which_sub != -1) | 1114 | if (m_which_sub != -1) |
1115 | drawSubmenu(which_sub); | 1115 | drawSubmenu(m_which_sub); |
1116 | 1116 | ||
1117 | if (alpha() < 255) { | 1117 | if (alpha() < 255) { |
1118 | redrawTitle(); | 1118 | redrawTitle(); |
@@ -1136,7 +1136,7 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { | |||
1136 | int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), | 1136 | int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), |
1137 | ix = sbl * menu.item_w, iy = i * theme().itemHeight(), | 1137 | ix = sbl * menu.item_w, iy = i * theme().itemHeight(), |
1138 | w = (sbl * menu.persub) + i, | 1138 | w = (sbl * menu.persub) + i, |
1139 | p = (which_sbl * menu.persub) + which_press; | 1139 | p = (m_which_sbl * menu.persub) + m_which_press; |
1140 | 1140 | ||
1141 | if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) { | 1141 | if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) { |
1142 | if (p == w && isItemEnabled(w)) { | 1142 | if (p == w && isItemEnabled(w)) { |
@@ -1160,19 +1160,19 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { | |||
1160 | if (me.window == menu.title && (me.state & Button1Mask)) { | 1160 | if (me.window == menu.title && (me.state & Button1Mask)) { |
1161 | stopHide(); | 1161 | stopHide(); |
1162 | 1162 | ||
1163 | if (! moving) { | 1163 | if (! m_moving) { |
1164 | // if not moving: start moving operation | 1164 | // if not m_moving: start m_moving operation |
1165 | if (m_parent && (! torn)) { | 1165 | if (m_parent && (! m_torn)) { |
1166 | m_parent->drawItem(m_parent->which_sub, | 1166 | m_parent->drawItem(m_parent->m_which_sub, |
1167 | true, // clear | 1167 | true, // clear |
1168 | true); // render transparency | 1168 | true); // render transparency |
1169 | m_parent->which_sub = -1; | 1169 | m_parent->m_which_sub = -1; |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | moving = torn = true; | 1172 | m_moving = m_torn = true; |
1173 | 1173 | ||
1174 | if (which_sub >= 0) | 1174 | if (m_which_sub >= 0) |
1175 | drawSubmenu(which_sub); | 1175 | drawSubmenu(m_which_sub); |
1176 | } else { | 1176 | } else { |
1177 | // we dont call ::move here 'cause we dont want to update transparency | 1177 | // we dont call ::move here 'cause we dont want to update transparency |
1178 | // while draging the menu (which is slow) | 1178 | // while draging the menu (which is slow) |
@@ -1206,7 +1206,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { | |||
1206 | !item->submenu()->isTorn()) { | 1206 | !item->submenu()->isTorn()) { |
1207 | // setup hide timer for submenu | 1207 | // setup hide timer for submenu |
1208 | item->submenu()->startHide(); | 1208 | item->submenu()->startHide(); |
1209 | which_sub = -1; | 1209 | m_which_sub = -1; |
1210 | } | 1210 | } |
1211 | } | 1211 | } |
1212 | 1212 | ||
@@ -1215,8 +1215,8 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { | |||
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | 1217 | ||
1218 | which_press = i; | 1218 | m_which_press = i; |
1219 | which_sbl = sbl; | 1219 | m_which_sbl = sbl; |
1220 | 1220 | ||
1221 | m_active_index = -1; | 1221 | m_active_index = -1; |
1222 | 1222 | ||
@@ -1281,37 +1281,37 @@ void Menu::enterNotifyEvent(XCrossingEvent &ce) { | |||
1281 | menu.x_shift = x(), menu.y_shift = y(); | 1281 | menu.x_shift = x(), menu.y_shift = y(); |
1282 | if (x() + width() > m_screen_x + m_screen_width) { | 1282 | if (x() + width() > m_screen_x + m_screen_width) { |
1283 | menu.x_shift = m_screen_x + m_screen_width - width() - 2*theme().borderWidth(); | 1283 | menu.x_shift = m_screen_x + m_screen_width - width() - 2*theme().borderWidth(); |
1284 | shifted = true; | 1284 | m_shifted = true; |
1285 | } else if (x() < 0) { | 1285 | } else if (x() < 0) { |
1286 | menu.x_shift = 0; //-theme().borderWidth(); | 1286 | menu.x_shift = 0; //-theme().borderWidth(); |
1287 | shifted = true; | 1287 | m_shifted = true; |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | if (y() + height() + 2*theme().borderWidth() > m_screen_height) { | 1290 | if (y() + height() + 2*theme().borderWidth() > m_screen_height) { |
1291 | menu.y_shift = m_screen_height - height() - 2*theme().borderWidth(); | 1291 | menu.y_shift = m_screen_height - height() - 2*theme().borderWidth(); |
1292 | shifted = true; | 1292 | m_shifted = true; |
1293 | } else if (y() + (signed) theme().titleHeight() < 0) { | 1293 | } else if (y() + (signed) theme().titleHeight() < 0) { |
1294 | menu.y_shift = 0; // -theme().borderWidth();; | 1294 | menu.y_shift = 0; // -theme().borderWidth();; |
1295 | shifted = true; | 1295 | m_shifted = true; |
1296 | } | 1296 | } |
1297 | 1297 | ||
1298 | 1298 | ||
1299 | if (shifted) | 1299 | if (m_shifted) |
1300 | menu.window.move(menu.x_shift, menu.y_shift); | 1300 | menu.window.move(menu.x_shift, menu.y_shift); |
1301 | 1301 | ||
1302 | if (validIndex(which_sub)) { | 1302 | if (validIndex(m_which_sub)) { |
1303 | MenuItem *tmp = menuitems[which_sub]; | 1303 | MenuItem *tmp = menuitems[m_which_sub]; |
1304 | if (tmp->submenu()->isVisible()) { | 1304 | if (tmp->submenu()->isVisible()) { |
1305 | int sbl = (ce.x / menu.item_w), i = (ce.y / theme().itemHeight()), | 1305 | int sbl = (ce.x / menu.item_w), i = (ce.y / theme().itemHeight()), |
1306 | w = (sbl * menu.persub) + i; | 1306 | w = (sbl * menu.persub) + i; |
1307 | 1307 | ||
1308 | if (w != which_sub && (! tmp->submenu()->isTorn())) { | 1308 | if (w != m_which_sub && (! tmp->submenu()->isTorn())) { |
1309 | tmp->submenu()->internal_hide(); | 1309 | tmp->submenu()->internal_hide(); |
1310 | 1310 | ||
1311 | drawItem(which_sub, | 1311 | drawItem(m_which_sub, |
1312 | true, // clear | 1312 | true, // clear |
1313 | true); // transp | 1313 | true); // transp |
1314 | which_sub = -1; | 1314 | m_which_sub = -1; |
1315 | } | 1315 | } |
1316 | } | 1316 | } |
1317 | } | 1317 | } |
@@ -1321,19 +1321,19 @@ void Menu::leaveNotifyEvent(XCrossingEvent &ce) { | |||
1321 | if (menu.frame != ce.window) | 1321 | if (menu.frame != ce.window) |
1322 | return; | 1322 | return; |
1323 | 1323 | ||
1324 | if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) { | 1324 | if (m_which_press != -1 && m_which_sbl != -1 && menuitems.size() > 0) { |
1325 | int p = (which_sbl * menu.persub) + which_press; | 1325 | int p = (m_which_sbl * menu.persub) + m_which_press; |
1326 | 1326 | ||
1327 | drawItem(p, | 1327 | drawItem(p, |
1328 | true, // clear | 1328 | true, // clear |
1329 | true); // transp | 1329 | true); // transp |
1330 | 1330 | ||
1331 | which_sbl = which_press = -1; | 1331 | m_which_sbl = m_which_press = -1; |
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | if (shifted) { | 1334 | if (m_shifted) { |
1335 | // menu.window.move(menu.x, menu.y); | 1335 | // menu.window.move(menu.x, menu.y); |
1336 | shifted = false; | 1336 | m_shifted = false; |
1337 | } | 1337 | } |
1338 | } | 1338 | } |
1339 | 1339 | ||
@@ -1363,10 +1363,10 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1363 | break; | 1363 | break; |
1364 | case XK_Return: | 1364 | case XK_Return: |
1365 | // send fake button 1 click | 1365 | // send fake button 1 click |
1366 | if (validIndex(which_press) && | 1366 | if (validIndex(m_which_press) && |
1367 | isItemEnabled(which_press)) { | 1367 | isItemEnabled(m_which_press)) { |
1368 | menuitems[which_press]->click(1, event.time); | 1368 | menuitems[m_which_press]->click(1, event.time); |
1369 | itemSelected(1, which_press); | 1369 | itemSelected(1, m_which_press); |
1370 | m_need_update = true; | 1370 | m_need_update = true; |
1371 | updateMenu(); | 1371 | updateMenu(); |
1372 | } | 1372 | } |
@@ -1419,11 +1419,11 @@ void Menu::reconfigure() { | |||
1419 | 1419 | ||
1420 | 1420 | ||
1421 | void Menu::openSubmenu() { | 1421 | void Menu::openSubmenu() { |
1422 | if (!isVisible() || ! validIndex(which_press) || | 1422 | if (!isVisible() || ! validIndex(m_which_press) || |
1423 | ! validIndex(which_sbl)) | 1423 | ! validIndex(m_which_sbl)) |
1424 | return; | 1424 | return; |
1425 | 1425 | ||
1426 | int item = which_sbl * menu.persub + which_press; | 1426 | int item = m_which_sbl * menu.persub + m_which_press; |
1427 | if (!validIndex(item)) | 1427 | if (!validIndex(item)) |
1428 | return; | 1428 | return; |
1429 | 1429 | ||
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 423b80a..de10d0f 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -77,10 +77,10 @@ public: | |||
77 | int remove(unsigned int item); | 77 | int remove(unsigned int item); |
78 | /// remove all items | 78 | /// remove all items |
79 | void removeAll(); | 79 | void removeAll(); |
80 | inline void setInternalMenu(bool val = true) { internal_menu = val; } | 80 | inline void setInternalMenu(bool val = true) { m_internal_menu = val; } |
81 | inline void setAlignment(Alignment a) { m_alignment = a; } | 81 | inline void setAlignment(Alignment a) { m_alignment = a; } |
82 | inline void setTorn() { torn = true; } | 82 | inline void setTorn() { m_torn = true; } |
83 | inline void removeParent() { if (internal_menu) m_parent = 0; } | 83 | inline void removeParent() { if (m_internal_menu) m_parent = 0; } |
84 | /// raise this window | 84 | /// raise this window |
85 | virtual void raise(); | 85 | virtual void raise(); |
86 | /// lower this window | 86 | /// lower this window |
@@ -135,8 +135,8 @@ public: | |||
135 | */ | 135 | */ |
136 | //@{ | 136 | //@{ |
137 | inline int activeIndex() const { return m_active_index; } | 137 | inline int activeIndex() const { return m_active_index; } |
138 | inline bool isTorn() const { return torn; } | 138 | inline bool isTorn() const { return m_torn; } |
139 | inline bool isVisible() const { return visible; } | 139 | inline bool isVisible() const { return m_visible; } |
140 | inline int screenNumber() const { return menu.window.screenNumber(); } | 140 | inline int screenNumber() const { return menu.window.screenNumber(); } |
141 | inline Window window() const { return menu.window.window(); } | 141 | inline Window window() const { return menu.window.window(); } |
142 | inline FbWindow &fbwindow() { return menu.window; } | 142 | inline FbWindow &fbwindow() { return menu.window; } |
@@ -149,7 +149,7 @@ public: | |||
149 | inline unsigned int width() const { return menu.window.width(); } | 149 | inline unsigned int width() const { return menu.window.width(); } |
150 | inline unsigned int height() const { return menu.window.height(); } | 150 | inline unsigned int height() const { return menu.window.height(); } |
151 | inline unsigned int numberOfItems() const { return menuitems.size(); } | 151 | inline unsigned int numberOfItems() const { return menuitems.size(); } |
152 | inline int currentSubmenu() const { return which_sub; } | 152 | inline int currentSubmenu() const { return m_which_sub; } |
153 | bool hasSubmenu(unsigned int index) const; | 153 | bool hasSubmenu(unsigned int index) const; |
154 | bool isItemSelected(unsigned int index) const; | 154 | bool isItemSelected(unsigned int index) const; |
155 | bool isItemEnabled(unsigned int index) const; | 155 | bool isItemEnabled(unsigned int index) const; |
@@ -170,7 +170,7 @@ public: | |||
170 | protected: | 170 | protected: |
171 | 171 | ||
172 | inline void setTitleVisibility(bool b) { | 172 | inline void setTitleVisibility(bool b) { |
173 | title_vis = b; m_need_update = true; | 173 | m_title_vis = b; m_need_update = true; |
174 | if (!b) | 174 | if (!b) |
175 | titleWindow().lower(); | 175 | titleWindow().lower(); |
176 | else | 176 | else |
@@ -204,14 +204,14 @@ private: | |||
204 | 204 | ||
205 | int m_screen_x, m_screen_y; | 205 | int m_screen_x, m_screen_y; |
206 | int m_screen_width, m_screen_height; | 206 | int m_screen_width, m_screen_height; |
207 | bool moving; ///< if we're moving/draging or not | 207 | bool m_moving; ///< if we're moving/draging or not |
208 | bool visible; ///< menu visibility | 208 | bool m_visible; ///< menu visibility |
209 | bool torn; ///< torn from parent | 209 | bool m_torn; ///< torn from parent |
210 | bool internal_menu; ///< whether we should destroy this menu or if it's managed somewhere else | 210 | bool m_internal_menu; ///< whether we should destroy this menu or if it's managed somewhere else |
211 | bool title_vis; ///< title visibility | 211 | bool m_title_vis; ///< title visibility |
212 | bool shifted; ///< if the menu is shifted to the other side of the parent | 212 | bool m_shifted; ///< if the menu is shifted to the other side of the parent |
213 | 213 | ||
214 | int which_sub, which_press, which_sbl; | 214 | int m_which_sub, m_which_press, m_which_sbl; |
215 | Alignment m_alignment; | 215 | Alignment m_alignment; |
216 | 216 | ||
217 | struct _menu { | 217 | struct _menu { |