]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/XFormsMenubar.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / XFormsMenubar.C
index 6e92aacb4c991c705c658f2a851c76318eb5cb65..e8a3c0f4216fbb4a1e0471e8b8b58e854a4937ba 100644 (file)
 
 #include "lyx_forms.h"
 
-using namespace lyx::support;
+using lyx::support::lowercase;
+using lyx::support::subst;
 
+using std::distance;
 using std::endl;
 using std::for_each;
+using std::string;
 using std::vector;
 
 
@@ -190,9 +193,10 @@ string const fixlabel(string const & str)
 
 
 int XFormsMenubar::create_submenu(Window win, XFormsView * view,
-                                  Menu const & menu, vector<int> & smn)
+                                 Menu const & menu,
+                                 vector<int> & smn, Funcs & funcs)
 {
-       const int menuid = get_new_submenu(smn, win);
+       int const menuid = get_new_submenu(smn, win);
        lyxerr[Debug::GUI] << "XFormsMenubar::create_submenu: creating "
                           << menu.name() << " as menuid=" << menuid << endl;
 
@@ -224,7 +228,7 @@ int XFormsMenubar::create_submenu(Window win, XFormsView * view,
                ++count;
                // add a More... submenu if the menu is too long (but
                // not just for one extra entry!)
-               if (count > max_number_of_items && (i+1) != end) {
+               if (count > max_number_of_items && (i + 1) != end) {
                        int tmpmenuid = get_new_submenu(smn, win);
                        lyxerr[Debug::GUI] << "Too many items, creating "
                                           << "new menu " << tmpmenuid << endl;
@@ -256,7 +260,7 @@ int XFormsMenubar::create_submenu(Window win, XFormsView * view,
                        }
 
                        // Is there a separator after the item?
-                       if ((i+1) != end
+                       if ((i + 1) != end
                            && (i + 1)->kind() == MenuItem::Separator)
                                label += "%l";
 
@@ -265,7 +269,7 @@ int XFormsMenubar::create_submenu(Window win, XFormsView * view,
                                label += "%B";
                        if (flag.onoff(false))
                                label += "%b";
-                       if (flag.disabled())
+                       if (!flag.enabled())
                                label += "%i";
 
                        // Add the shortcut
@@ -280,7 +284,7 @@ int XFormsMenubar::create_submenu(Window win, XFormsView * view,
                                // create the submenu
                                submenuid =
                                        create_submenu(win, view,
-                                                      *item.submenu(), smn);
+                                                      *item.submenu(), smn, funcs);
                                if (submenuid == -1)
                                        return -1;
                                label += "%x" + tostr(smn.size());
@@ -290,10 +294,16 @@ int XFormsMenubar::create_submenu(Window win, XFormsView * view,
                                        << "), ";
                        } else {
                                // Add the action
-                               label += "%x" + tostr(item.action()
-                                                     + action_offset);
+                               Funcs::iterator fit =
+                                       funcs.insert(funcs.end(), item.func());
+                               int const action_count =
+                                       distance(funcs.begin(), fit);
+
+                               label += "%x" + tostr(action_count + action_offset);
                                lyxerr[Debug::GUI] << "Action: \""
-                                                  << item.action() << "\", ";
+                                                  << item.func().action
+                                                  << "(" << item.func().argument
+                                                  << ")\", ";
                        }
 
                        // Add everything to the menu
@@ -351,9 +361,10 @@ void XFormsMenubar::MenuCallback(FL_OBJECT * ob, long button)
        Menu tomenu;
        Menu const frommenu = menubackend_->getMenu(item->submenuname());
        menubackend_->expand(frommenu, tomenu, view);
+       Funcs funcs;
        vector<int> submenus;
        int menu = iteminfo->menubar_->create_submenu(FL_ObjWin(ob), view,
-                                                   tomenu, submenus);
+                                                   tomenu, submenus, funcs);
        if (menu != -1) {
                // place popup
                fl_setpup_position(view->getForm()->x + ob->x,
@@ -368,8 +379,8 @@ void XFormsMenubar::MenuCallback(FL_OBJECT * ob, long button)
 
                // If the action value is too low, then it is not a
                // valid action, but something else.
-               if (choice >= action_offset + 1) {
-                       view->getLyXFunc().dispatch(choice - action_offset, true);
+               if (choice >= action_offset) {
+                       view->getLyXFunc().dispatch(funcs[choice - action_offset], true);
                } else {
                        lyxerr[Debug::GUI]
                                << "MenuCallback: ignoring bogus action "