]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/Menubar_pimpl.C
func_status cleanup from Martin; fix small configure bug
[lyx.git] / src / frontends / xforms / Menubar_pimpl.C
index 878b73f41d3bbd06f2df29e5ad8e31fa4d7358e9..81b1c3ebb01fe78c14729ddc36ae26b3e2c96ad9 100644 (file)
@@ -43,6 +43,7 @@ namespace {
 
 // Some constants
 int const MENU_LABEL_SIZE = FL_NORMAL_SIZE;
+int const MENU_LABEL_STYLE = FL_BOLD_STYLE;
 int const mheight = 30;
 int const mbheight= 22;
 // where to place the menubar?
@@ -62,7 +63,7 @@ int const action_offset = 1000;
 inline
 int string_width(string const & str) 
 {
-       return fl_get_string_widthTAB(FL_NORMAL_STYLE, MENU_LABEL_SIZE,
+       return fl_get_string_widthTAB(MENU_LABEL_STYLE, MENU_LABEL_SIZE,
                                      str.c_str(),
                                      static_cast<int>(str.length()));
 }
@@ -70,9 +71,16 @@ int string_width(string const & str)
 } // namespace anon
 
 
-//Defined later, used in makeMenubar().
-extern "C"
-void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button);
+extern "C" {
+
+       //Defined later, used in makeMenubar().
+       static
+       void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button)
+       {
+               Menubar::Pimpl::MenuCallback(ob, button);
+       }
+       
+}
 
 
 Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb) 
@@ -127,7 +135,7 @@ void Menubar::Pimpl::makeMenubar(Menu const & menu)
                fl_set_object_boxtype(obj, FL_FLAT_BOX);
                fl_set_object_color(obj, FL_MCOL, FL_MCOL);
                fl_set_object_lsize(obj, MENU_LABEL_SIZE);
-               fl_set_object_lstyle(obj, FL_NORMAL_STYLE);
+               fl_set_object_lstyle(obj, MENU_LABEL_STYLE);
                fl_set_object_resize(obj, FL_RESIZE_ALL);
                fl_set_object_gravity(obj, NorthWestGravity, 
                                      NorthWestGravity);
@@ -231,7 +239,6 @@ string const fixlabel(string const & str)
 #endif
 }
 
-} // namespace anon
 
 
 void add_toc2(int menu, string const & extra_label,
@@ -318,6 +325,7 @@ void add_toc2(int menu, string const & extra_label,
        }
 }
 
+} // namespace anon
 
 void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
                             vector<int> & smn, Window win)
@@ -330,10 +338,21 @@ void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
                if (cit->first == "TOC") continue;
 
                // All the rest is for floats
-               int menu2 = get_new_submenu(smn, win);
+               int menu_first_sub = get_new_submenu(smn, win);
+               int menu_current = menu_first_sub;
                Buffer::SingleList::const_iterator ccit = cit->second.begin();
                Buffer::SingleList::const_iterator eend = cit->second.end();
+               size_type count = 0;
                for (; ccit != eend; ++ccit) {
+                       ++count;
+                       if (count > max_number_of_items) {
+                               int menu_tmp = get_new_submenu(smn, win);
+                               string label = _("More");
+                               label += "...%m";
+                               fl_addtopup(menu_current, label.c_str(), menu_tmp);
+                               count = 1;
+                               menu_current = menu_tmp;
+                       }
                        int const action =
                                lyxaction
                                .getPseudoAction(LFUN_GOTO_PARAGRAPH,
@@ -341,10 +360,10 @@ void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
                        string label = fixlabel(ccit->str);
                        label = limit_string_length(label);
                        label += "%x" + tostr(action + action_offset);
-                       fl_addtopup(menu2, label.c_str());
+                       fl_addtopup(menu_current, label.c_str());
                }
                string const m = floatList[cit->first]->second.name() + "%m";
-               fl_addtopup(menu, m.c_str(), menu2);
+               fl_addtopup(menu, m.c_str(), menu_first_sub);
        }
        
        
@@ -407,8 +426,7 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
                if (i->kind() == MenuItem::Separator)
                        *last = "%l";
                else if (!i->optional() ||
-                        !(view->getLyXFunc()->getStatus(i->action()) 
-                          & func_status::Disabled))
+                        !(view->getLyXFunc()->getStatus(i->action()).disabled()))
                        last = it;
 
        it = extra_labels.begin();
@@ -418,12 +436,12 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
 
                switch (item.kind()) {
                case MenuItem::Command: {
-                       func_status::value_type flag = 
+                       FuncStatus flag = 
                                view->getLyXFunc()->getStatus(item.action()); 
 
                        // handle optional entries.
                        if (item.optional() 
-                           && (flag & func_status::Disabled)) {
+                           && (flag.disabled())) {
                                lyxerr[Debug::GUI] 
                                        << "Skipping optional item " 
                                        << item.label() << endl; 
@@ -432,7 +450,7 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
 
                        // Get the keys bound to this action, but keep only the
                        // first one later
-                       string const accel = toplevel_keymap->findbinding(item.action());
+                       string const accel = toplevel_keymap->findbinding(kb_action(item.action()));
                        // Build the menu label from all the info
                        string label = item.label();
 
@@ -449,12 +467,11 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
                        
                        // Modify the entry using the function status
                        string pupmode;
-                       if (flag & (func_status::Disabled 
-                                   | func_status::Unknown))
+                       if (flag.disabled() || flag.unknown())
                                pupmode += "%i";
-                       if (flag & func_status::ToggleOn)
+                       if (flag.onoff(true))
                                pupmode += "%B";
-                       if (flag & func_status::ToggleOff)
+                       if (flag.onoff(false))
                                pupmode += "%b";
                        label += pupmode;
 
@@ -523,13 +540,6 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
 }
 
 
-extern "C"
-void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button)
-{
-       Menubar::Pimpl::MenuCallback(ob, button);
-}
-
-
 void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
 {
        ItemInfo * iteminfo = static_cast<ItemInfo *>(ob->u_vdata);
@@ -541,12 +551,6 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
        LyXView * view = iteminfo->pimpl_->owner_;
        MenuItem const * item = iteminfo->item_.get();
 
-       /* get the splash out of the way. It would be nicer
-        * to only have this code at the start, but xforms
-        * makes it too ugly to do
-        */
-       view->getDialogs()->destroySplash();
        if (button == 1) {
                // set the pseudo menu-button
                fl_set_object_boxtype(ob, FL_DOWN_BOX);