aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Menu.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r--src/FbTk/Menu.cc29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 7b18520..8c09c7f 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.71 2004/07/14 18:30:37 fluxgen Exp $ 25// $Id: Menu.cc,v 1.72 2004/08/03 21:25:51 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -36,6 +36,7 @@
36#endif //HAVE_CONFIG_H 36#endif //HAVE_CONFIG_H
37 37
38#include "MenuItem.hh" 38#include "MenuItem.hh"
39#include "MenuSeparator.hh"
39#include "ImageControl.hh" 40#include "ImageControl.hh"
40#include "MenuTheme.hh" 41#include "MenuTheme.hh"
41#include "App.hh" 42#include "App.hh"
@@ -51,6 +52,7 @@
51#include <cstdlib> 52#include <cstdlib>
52#include <cstring> 53#include <cstring>
53#include <iostream> 54#include <iostream>
55#include <typeinfo>
54 56
55using namespace std; 57using namespace std;
56 58
@@ -309,6 +311,11 @@ void Menu::nextItem() {
309 return; 311 return;
310 } 312 }
311 313
314 if (!isItemSelectable(which_press)) {
315 nextItem();
316 return;
317 }
318
312 m_active_index = which_press; 319 m_active_index = which_press;
313 320
314 drawItem(which_press, 321 drawItem(which_press,
@@ -344,6 +351,11 @@ void Menu::prevItem() {
344 return; 351 return;
345 } 352 }
346 353
354 if (!isItemSelectable(which_press)) {
355 prevItem();
356 return;
357 }
358
347 m_active_index = which_press; 359 m_active_index = which_press;
348 360
349 drawItem(which_press, 361 drawItem(which_press,
@@ -1038,6 +1050,18 @@ bool Menu::isItemEnabled(unsigned int index) const {
1038 return item->isEnabled(); 1050 return item->isEnabled();
1039} 1051}
1040 1052
1053bool Menu::isItemSelectable(unsigned int index) const {
1054
1055 if (index >= menuitems.size()) return false;
1056
1057 const MenuItem *item = find(index);
1058 if (!item)
1059 return false;
1060
1061 return (typeid(*item) != typeid(FbTk::MenuSeparator));
1062}
1063
1064
1041void Menu::handleEvent(XEvent &event) { 1065void Menu::handleEvent(XEvent &event) {
1042 if (event.type == FocusOut) { 1066 if (event.type == FocusOut) {
1043 if (s_focused == this) 1067 if (s_focused == this)
@@ -1189,6 +1213,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
1189 !item->submenu()->isTorn()) { 1213 !item->submenu()->isTorn()) {
1190 // setup hide timer for submenu 1214 // setup hide timer for submenu
1191 item->submenu()->startHide(); 1215 item->submenu()->startHide();
1216 which_sub = -1;
1192 } 1217 }
1193 } 1218 }
1194 1219
@@ -1231,7 +1256,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
1231 1256
1232 } 1257 }
1233 1258
1234 } else { 1259 } else if (isItemSelectable(w)){
1235 // else normal menu item 1260 // else normal menu item
1236 // draw highlighted 1261 // draw highlighted
1237 m_submenu_timer.stop(); 1262 m_submenu_timer.stop();