// Some constants
int const MENU_LABEL_SIZE = FL_NORMAL_SIZE;
+int const MENU_LABEL_STYLE = FL_NORMAL_STYLE;
int const mheight = 30;
int const mbheight= 22;
// where to place the menubar?
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()));
}
} // 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)
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);
#endif
}
-} // namespace anon
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)
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,
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);
}
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();
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;
// 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();
// 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;
}
-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);
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);
// 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);
- }
- else {
+ view->getLyXFunc()->verboseDispatch(choice - action_offset, true);
+ } else {
lyxerr[Debug::GUI]
<< "MenuCallback: ignoring bogus action "
<< choice << endl;
}
- }
- else
+ } else {
lyxerr << "Error in MenuCallback" << endl;
+ }
std::for_each(submenus.begin(), submenus.end(), fl_freepup);
// restore tabstop length