3 * ==================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team.
10 * ==================================================
13 /* This file contains all the menu and submenu declarations.
14 The call backs are in lyx_cb.C */
18 * XFORMS can handle 10 (more with the new xforms, but not unlimited)
19 * popups at the same time
20 * so when you are finished looking at a pup free it (fl_freepup)
26 #pragma implementation
36 #include "spellchecker.h"
37 #include "support/filetools.h"
39 #include "lastfiles.h"
40 #include "bufferlist.h"
41 #include "lyx_gui_misc.h"
42 #include "minibuffer.h"
50 #include "bufferview_funcs.h"
51 #include "insets/insetref.h"
52 #include "insets/insettabular.h"
55 #include "frontends/Dialogs.h"
63 extern BufferList bufferlist;
65 // I would really prefere to see most or all of these 'extern's disappear.
66 // Their commands should be called through LyXFunc (IMO). (Lgb)
68 extern void MenuLayoutSave();
69 extern void ShowCredits();
71 // A bunch of wrappers
73 extern "C" void C_Menus_ShowFileMenu(FL_OBJECT * ob, long data)
75 Menus::ShowFileMenu(ob, data);
78 extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT * ob, long data)
80 Menus::ShowFileMenu2(ob, data);
83 extern "C" void C_Menus_ShowEditMenu(FL_OBJECT * ob, long data)
85 Menus::ShowEditMenu(ob, data);
88 extern "C" void C_Menus_ShowTocMenu(FL_OBJECT * ob, long data)
90 Menus::ShowTocMenu(ob, data);
93 extern "C" void C_Menus_ShowRefsMenu(FL_OBJECT * ob, long data)
95 Menus::ShowRefsMenu(ob, data);
98 extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT * ob, long data)
100 Menus::ShowLayoutMenu(ob, data);
103 extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT * ob, long data)
105 Menus::ShowInsertMenu(ob, data);
108 extern "C" void C_Menus_ShowMathMenu(FL_OBJECT * ob, long data)
110 Menus::ShowMathMenu(ob, data);
113 extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT * ob, long data)
115 Menus::ShowOptionsMenu(ob, data);
118 extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT * ob, long data)
120 Menus::ShowBufferMenu(ob, data);
123 extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT * ob, long data)
125 Menus::ShowHelpMenu(ob, data);
129 Menus::Menus(LyXView * view, int air)
133 // deactivate the menu accelerators
134 fl_set_object_shortcut(menu_file, "", 1);
135 fl_set_object_shortcut(menu_file2, "", 1);
136 fl_set_object_shortcut(menu_edit, "", 1);
137 fl_set_object_shortcut(menu_toc, "", 1);
138 fl_set_object_shortcut(menu_refs, "", 1);
139 fl_set_object_shortcut(menu_layout, "", 1);
140 fl_set_object_shortcut(menu_math, "", 1);
141 fl_set_object_shortcut(menu_insert, "", 1);
142 fl_set_object_shortcut(menu_options, "", 1);
143 fl_set_object_shortcut(menu_options2, "", 1);
144 fl_set_object_shortcut(menu_buffer, "", 1);
145 fl_set_object_shortcut(menu_help, "", 1);
146 fl_set_object_shortcut(menu_help2, "", 1);
152 BufferView * Menus::currentView()
154 return _view->view();
158 void Menus::showMenus()
160 fl_hide_object(menu_grp2);
161 fl_show_object(menu_grp1);
165 void Menus::hideMenus()
167 fl_hide_object(menu_grp1);
168 fl_show_object(menu_grp2);
172 void Menus::openByName(string const & menuName)
173 /* Opens the visible menu of given name, or simply does nothing
174 when the name is not known. NOTE THE EXTREMELY STUPID
175 IMPLEMENTATION! :-) There are probably hundred ways to do
176 this better, for instance, by scanning the menu objects and
177 testing for the given name. I leave this as an exercise for an
178 experienced GG (GUI Guy/Girl). RVDK_PATCH_5. */
180 if (menu_file->visible) {
181 if (menuName == _("File"))
182 ShowFileMenu(menu_file, 0);
183 else if (menuName == _("Edit"))
184 ShowEditMenu(menu_edit, 0);
185 else if (menuName == _("TOC"))
186 ShowTocMenu(menu_toc, 0);
187 else if (menuName == _("Refs"))
188 ShowRefsMenu(menu_refs, 0);
189 else if (menuName == _("Layout"))
190 ShowLayoutMenu(menu_layout, 0);
191 else if (menuName == _("Insert"))
192 ShowInsertMenu(menu_insert, 0);
193 else if (menuName == _("Math"))
194 ShowMathMenu(menu_math, 0);
195 else if (menuName == _("Options"))
196 ShowOptionsMenu(menu_options, 0);
197 else if (menuName == _("Documents"))
198 ShowBufferMenu(menu_buffer, 0);
199 else if (menuName == _("Help"))
200 ShowHelpMenu(menu_help, 0);
201 else lyxerr << "The menu '" << menuName
202 << "' is not available." << endl;
204 if (menuName == _("File"))
205 ShowFileMenu2(menu_file2, 0);
206 else if (menuName == _("Options"))
207 ShowOptionsMenu(menu_options2, 0);
208 else if (menuName == _("Help"))
209 ShowHelpMenu(menu_help2, 0);
210 else lyxerr << "The menu '" << menuName
211 << "' is not available." << endl;
216 void Menus::create_menus(int air)
218 FL_FORM * form = _view->getForm();
220 // Here I'd really like to see code like:
224 const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
225 const int mheight = 30;
226 const int mbheight= 22;
227 // where to place the menubar?
228 const int yloc = (mheight - mbheight)/2; //air + bw;
229 const int mbadd = 20; // menu button add (to width)
233 obj = fl_add_frame(FL_UP_FRAME, 0, 0, form->w, mheight, "");
234 fl_set_object_resize(obj, FL_RESIZE_ALL);
235 fl_set_object_gravity(obj, NorthWestGravity, NorthEastGravity);
237 menu_grp1 = fl_bgn_group();
241 fl_add_button(FL_TOUCH_BUTTON,
243 fl_get_string_width(FL_BOLD_STYLE,
246 strlen(_("File"))) + mbadd,
247 mbheight, _("File"));
248 moffset += obj->w + air;
249 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
250 fl_set_object_callback(obj, C_Menus_ShowFileMenu, 0);
255 fl_add_button(FL_TOUCH_BUTTON,
257 fl_get_string_width(FL_BOLD_STYLE,
260 strlen(_("Edit"))) + mbadd,
261 mbheight, _("Edit"));
262 moffset += obj->w + air;
263 fl_set_object_shortcut(obj, scex(_("MB|#E")), 1);
264 fl_set_object_callback(obj, C_Menus_ShowEditMenu, 0);
269 fl_add_button(FL_TOUCH_BUTTON,
271 fl_get_string_width(FL_BOLD_STYLE,
274 strlen(_("TOC"))) + mbadd,
276 moffset += obj->w + air;
277 fl_set_object_shortcut(obj, scex(_("MB|#T")), 1);
278 fl_set_object_callback(obj, C_Menus_ShowTocMenu, 0);
283 fl_add_button(FL_TOUCH_BUTTON,
285 fl_get_string_width(FL_BOLD_STYLE,
288 strlen(_("Refs"))) + mbadd,
289 mbheight, _("Refs"));
290 moffset += obj->w + air;
291 fl_set_object_shortcut(obj, scex(_("MB|#R")), 1);
292 fl_set_object_callback(obj, C_Menus_ShowRefsMenu, 0);
295 // Layout menu button
297 fl_add_button(FL_TOUCH_BUTTON,
299 fl_get_string_width(FL_BOLD_STYLE,
302 strlen(_("Layout"))) + mbadd,
303 mbheight, _("Layout"));
304 moffset += obj->w + air;
305 fl_set_object_shortcut(obj, scex(_("MB|#L")), 1);
306 fl_set_object_callback(obj, C_Menus_ShowLayoutMenu, 0);
309 // Insert menu button button
311 fl_add_button(FL_TOUCH_BUTTON,
313 fl_get_string_width(FL_BOLD_STYLE,
316 strlen(_("Insert"))) + mbadd,
317 mbheight, _("Insert"));
318 moffset += obj->w + air;
319 fl_set_object_shortcut(obj, scex(_("MB|#I")), 1);
320 fl_set_object_callback(obj, C_Menus_ShowInsertMenu, 0);
325 fl_add_button(FL_TOUCH_BUTTON,
327 fl_get_string_width(FL_BOLD_STYLE,
330 strlen(_("Math"))) + mbadd,
331 mbheight, _("Math"));
332 moffset += obj->w + air;
333 fl_set_object_shortcut(obj, scex(_("MB|#M")), 1);
334 fl_set_object_callback(obj, C_Menus_ShowMathMenu, 0);
337 // Options menu button
339 fl_add_button(FL_TOUCH_BUTTON,
341 fl_get_string_width(FL_BOLD_STYLE,
344 strlen(_("Options"))) + mbadd,
345 mbheight, _("Options"));
346 moffset += obj->w + air;
347 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
348 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
351 // Documents menu button
353 fl_add_button(FL_TOUCH_BUTTON,
355 fl_get_string_width(FL_BOLD_STYLE,
358 strlen(_("Documents"))) + mbadd,
359 mbheight, _("Documents"));
360 moffset += obj->w + air;
361 fl_set_object_shortcut(obj, scex(_("MB|#D")), 1);
362 fl_set_object_callback(obj, C_Menus_ShowBufferMenu, 0);
367 fl_add_button(FL_TOUCH_BUTTON,
369 fl_get_string_width(FL_BOLD_STYLE,
372 strlen(_("Help"))) + mbadd,
373 mbheight, _("Help"));
374 moffset += obj->w + air;
375 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
376 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
381 // Set the menu buttons atrributes.
382 // Due to a bug in xforms we cant do this only an the group.
383 obj = menu_grp1->next;
385 fl_set_object_boxtype(obj, FL_FLAT_BOX);
386 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
387 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
388 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
389 fl_set_object_resize(obj, FL_RESIZE_ALL);
390 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
392 } while (obj != 0 && obj->objclass != FL_END_GROUP);
396 menu_grp2 = fl_bgn_group();
400 fl_add_button(FL_TOUCH_BUTTON,
402 fl_get_string_width(FL_BOLD_STYLE,
405 strlen(_("File"))) + mbadd,
406 mbheight, _("File"));
407 moffset += obj->w + air;
408 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
409 fl_set_object_callback(obj, C_Menus_ShowFileMenu2, 0);
412 // Options menu button
413 menu_options2 = obj =
414 fl_add_button(FL_TOUCH_BUTTON,
416 fl_get_string_width(FL_BOLD_STYLE,
419 strlen(_("Options"))) +mbadd,
420 mbheight, _("Options"));
421 moffset += obj->w + air;
422 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
423 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
428 fl_add_button(FL_TOUCH_BUTTON,
430 fl_get_string_width(FL_BOLD_STYLE,
433 strlen(_("Help"))) + mbadd,
434 mbheight, _("Help"));
435 moffset += obj->w + air;
436 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
437 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
442 // Set the menu buttons atrributes.
443 // Due to a bug in xforms we cant do this only an the group.
444 obj = menu_grp2->next;
446 fl_set_object_boxtype(obj, FL_FLAT_BOX);
447 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
448 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
449 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
450 fl_set_object_resize(obj, FL_RESIZE_ALL);
451 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
453 } while (obj != 0 && obj->objclass != FL_END_GROUP);
458 // Here comes all the menu callbacks.
461 void Menus::ShowFileMenu(FL_OBJECT * ob, long)
463 Menus * men = static_cast<Menus*>(ob->u_vdata);
465 // Regarding the pseudo-menu-button:
466 // ok, ok this is a hack. It would be better to use the menus of the
467 // xforms 0.8 library. but then all popups have to be defined all the
468 // time, code rewriting would be necessary and contex-depending menus
469 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
470 // course it would be more proper (and little faster). So if anybody
471 // likes to do the cleanup, just do it. Matthias
473 // set the pseudo menu-button
474 fl_set_object_boxtype(ob, FL_UP_BOX);
475 fl_set_button(ob, 0);
476 fl_redraw_object(ob);
478 Buffer * tmpbuffer = men->_view->buffer();
479 LyXFunc * tmpfunc = men->_view->getLyXFunc();
481 bool LinuxDoc = tmpbuffer->isLinuxDoc();
482 bool DocBook = tmpbuffer->isDocBook();
483 bool Literate = tmpbuffer->isLiterate();
487 int SubFileImport = fl_defpup(FL_ObjWin(ob),
490 "|Ascii Text as Lines...%x31"
491 "|Ascii Text as Paragraphs%x32"
495 fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
496 fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
497 fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
498 fl_setpup_shortcut(SubFileImport, 33, scex(_("FIM|Nn#n#N")));
499 fl_setpup_shortcut(SubFileImport, 34, scex(_("FIM|Dd#d#D")));
503 // remember to make this handle linuxdoc too.
504 // and now docbook also.
505 int SubFileExport = 0;
506 if (!LinuxDoc && !DocBook)
507 SubFileExport= fl_defpup(FL_ObjWin(ob),
511 "|as PostScript...%x42"
512 "|as Ascii Text...%x43"
516 SubFileExport= fl_defpup(FL_ObjWin(ob),
518 "|as LinuxDoc...%x40"
520 "|as PostScript...%x42"
521 "|as Ascii Text...%x43"
524 SubFileExport= fl_defpup(FL_ObjWin(ob),
528 "|as PostScript...%x42"
529 "|as Ascii Text...%x43"
532 fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
533 fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
534 fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
535 fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
536 fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
538 if (!LinuxDoc && !DocBook) {
539 fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
542 int FileMenu = fl_defpup(FL_ObjWin(ob),
544 "|New from template..."
558 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
559 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
560 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
561 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Cc#c#C")));
562 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|Ss#s#S")));
563 fl_setpup_shortcut(FileMenu, 6, scex(_("FM|Aa#a#A")));
564 fl_setpup_shortcut(FileMenu, 7, scex(_("FM|Rr#r#R")));
565 fl_setpup_shortcut(FileMenu, 8, scex(_("FM|dD#d#D")));
566 fl_setpup_shortcut(FileMenu, 9, scex(_("FM|wW#w#W")));
567 fl_setpup_shortcut(FileMenu, 10, scex(_("FM|vV#v#V")));
568 fl_setpup_shortcut(FileMenu, 11, scex(_("FM|Uu#u#U")));
569 fl_setpup_shortcut(FileMenu, 12, scex(_("FM|Bb#b#B")));
570 fl_setpup_shortcut(FileMenu, 13, scex(_("FM|Pp#p#P")));
571 fl_setpup_shortcut(FileMenu, 14, scex(_("FM|Ff#f#F")));
573 // These commands are disabled when the corresponding programs
574 // are not installed. I simply grey them out, since I do not
575 // want to change their number (JMarc)
576 bool hasLaTeX = lyxrc.latex_command != "none";
578 if (!hasLaTeX || lyxrc.view_dvi_command == "none")
579 fl_setpup_mode(FileMenu, 8, FL_PUP_GREY);
581 if (!hasLaTeX || lyxrc.view_ps_command == "none")
582 fl_setpup_mode(FileMenu, 9, FL_PUP_GREY);
585 fl_setpup_mode(FileMenu, 10, FL_PUP_GREY);
586 fl_setpup_mode(FileMenu, 11, FL_PUP_GREY);
589 if (lyxrc.literate_command == "none" || ! Literate)
590 fl_setpup_mode(FileMenu, 12, FL_PUP_GREY);
592 if (!hasLaTeX || lyxrc.print_command == "none")
593 fl_setpup_mode(FileMenu, 13, FL_PUP_GREY);
595 if (!hasLaTeX || lyxrc.fax_command == "none")
596 fl_setpup_mode(FileMenu, 14, FL_PUP_GREY);
598 bool hasReLyX = lyxrc.relyx_command != "none";
600 // Disable import LaTeX and Noweb
601 fl_setpup_mode(SubFileImport, 30, FL_PUP_GREY);
602 fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
605 if ( lyxrc.linuxdoc_to_lyx_command == "none")
606 fl_setpup_mode(SubFileImport, 34, FL_PUP_GREY);
609 // Disable export dvi and export postscript
610 fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
611 fl_setpup_mode(SubFileExport, 42, FL_PUP_GREY);
614 if ((!LinuxDoc && !DocBook && lyxrc.html_command == "none") ||
615 ( LinuxDoc && lyxrc.linuxdoc_to_html_command == "none") ||
616 ( DocBook && lyxrc.docbook_to_html_command == "none")) {
617 // Disable export HTML
618 fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
621 // xgettext:no-c-format
622 fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
623 // xgettext:no-c-format
624 fl_addtopup(FileMenu, _("|Export%m%l"), SubFileExport);
625 // xgettext:no-c-format
626 fl_addtopup(FileMenu, _("|Exit%l"));
627 fl_setpup_shortcut(FileMenu, 15, scex(_("FM|Ii#i#I")));
628 fl_setpup_shortcut(FileMenu, 16, scex(_("FM|Ee#e#E")));
629 fl_setpup_shortcut(FileMenu, 17, scex(_("FM|xX#x#X")));
631 // make the lastfiles menu
633 for (LastFiles::const_iterator cit = lastfiles->begin();
634 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
635 string tmp = tostr(ii);
636 string tmp2 = tmp + "#" + tmp;
637 tmp += ". " + MakeDisplayPath((*cit), 30);
638 fl_addtopup(FileMenu, tmp.c_str());
639 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
644 men->_view->getForm()->x + ob->x,
645 men->_view->getForm()->y + ob->y + ob->h + 10);
646 int choice = fl_dopup(FileMenu);
649 // set the pseudo menu-button back
650 fl_set_object_boxtype(ob, FL_FLAT_BOX);
651 fl_redraw_object(ob);
654 case -1: case 0: // we won't do anything
656 case 1: tmpfunc->Dispatch(LFUN_MENUNEW); break;
657 case 2: tmpfunc->Dispatch(LFUN_MENUNEWTMPLT); break;
658 case 3: tmpfunc->Dispatch(LFUN_MENUOPEN); break;
659 case 4: tmpfunc->Dispatch(LFUN_CLOSEBUFFER); break;
660 case 5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
661 case 6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
662 case 7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
663 case 8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
664 case 9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
665 case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
666 case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
667 case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
668 case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
669 case 14: tmpfunc->Dispatch(LFUN_FAX); break;
670 case 15: // import menu
671 case 30: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
673 case 31: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
675 case 32: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
677 case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
679 case 34: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
681 case 16: // export menu
683 if (!LinuxDoc && !DocBook)
684 tmpfunc->Dispatch(LFUN_EXPORT, "latex");
686 tmpfunc->Dispatch(LFUN_EXPORT, "linuxdoc");
688 tmpfunc->Dispatch(LFUN_EXPORT, "docbook");
690 case 41: tmpfunc->Dispatch(LFUN_EXPORT, "dvi");
692 case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
694 case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
696 case 44: tmpfunc->Dispatch(LFUN_EXPORT, "html");
698 case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
700 case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
702 case 18: // The first item with lastfiles.
706 .loadLyXFile((*lastfiles)[choice - 18]));
709 fl_freepup(SubFileImport);
710 fl_freepup(SubFileExport);
711 fl_freepup(FileMenu);
713 AllowInput(men->currentView());
717 void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
719 Menus * men = static_cast<Menus*>(ob->u_vdata);
721 // Regarding the pseudo-menu-button:
722 // ok, ok this is a hack. It would be better to use the menus of the
723 // xforms 0.8 library. but then all popups have to be defined all the
724 // time, code rewriting would be necessary and contex-depending menus
725 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
726 // course it would be more proper (and little faster). So if anybody
727 // likes to do the cleanup, just do it. Matthias
729 // set the pseudo menu-button
730 fl_set_object_boxtype(ob, FL_UP_BOX);
731 fl_set_button(ob, 0);
732 fl_redraw_object(ob);
734 LyXFunc * tmpfunc = men->_view->getLyXFunc();
738 int SubFileImport = fl_defpup(FL_ObjWin(ob),
741 "|Ascii Text as Lines...%x16"
742 "|Ascii Text as Paragraphs...%x17"
744 "|LinuxDoc...%x19"));
746 fl_setpup_shortcut(SubFileImport, 15, scex(_("FIM|Ll#l#L")));
747 fl_setpup_shortcut(SubFileImport, 16, scex(_("FIM|Aa#a#A")));
748 fl_setpup_shortcut(SubFileImport, 17, scex(_("FIM|Pp#p#P")));
749 fl_setpup_shortcut(SubFileImport, 18, scex(_("FIM|Nn#n#N")));
750 fl_setpup_shortcut(SubFileImport, 19, scex(_("FIM|Dd#d#D")));
752 bool hasReLyX = lyxrc.relyx_command != "none";
754 // Disable import LaTeX and Noweb
755 fl_setpup_mode(SubFileImport, 15, FL_PUP_GREY);
756 fl_setpup_mode(SubFileImport, 18, FL_PUP_GREY);
759 if ( lyxrc.linuxdoc_to_lyx_command == "none")
760 fl_setpup_mode(SubFileImport, 19, FL_PUP_GREY);
762 // This can be done cleaner later.
763 int FileMenu = fl_defpup(FL_ObjWin(ob),
765 "|New from template..."
768 "|Exit%l"), SubFileImport);
770 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
771 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
772 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
773 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Ii#i#I")));
774 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|xX#x#X")));
776 // make the lastfiles menu
778 for (LastFiles::const_iterator cit = lastfiles->begin();
779 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
780 string tmp = tostr(ii);
781 string tmp2 = tmp + "#" + tmp;
782 tmp += ". " + MakeDisplayPath((*cit), 30);
783 fl_addtopup(FileMenu, tmp.c_str());
784 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
789 men->_view->getForm()->x + ob->x,
790 men->_view->getForm()->y + ob->y + ob->h + 10);
791 int choice = fl_dopup(FileMenu);
794 // set the pseudo menu-button back
795 fl_set_object_boxtype(ob, FL_FLAT_BOX);
796 fl_redraw_object(ob);
799 case -1: case 0: // we won't do anything
802 tmpfunc->Dispatch(LFUN_MENUNEW);
805 tmpfunc->Dispatch(LFUN_MENUNEWTMPLT);
808 tmpfunc->Dispatch(LFUN_MENUOPEN);
810 case 4: // import menu
811 case 15: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
813 case 16: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
815 case 17: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
817 case 18: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
819 case 19: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
822 tmpfunc->Dispatch(LFUN_QUIT);
825 case 6: // The first item with lastfiles.
829 .loadLyXFile((*lastfiles)[choice - 6]));
833 fl_freepup(SubFileImport);
834 fl_freepup(FileMenu);
835 AllowInput(men->currentView());
840 void Menus::ShowEditMenu(FL_OBJECT * ob, long)
842 Menus * men = static_cast<Menus*>(ob->u_vdata);
844 // set the pseudo menu-button
845 fl_set_object_boxtype(ob, FL_UP_BOX);
846 fl_set_button(ob, 0);
847 fl_redraw_object(ob);
849 Buffer * tmpbuffer = men->_view->buffer();
850 LyXFunc * tmpfunc = men->_view->getLyXFunc();
852 // Floats & Insets submenu
853 int SubEditFloats= fl_defpup(FL_ObjWin(ob),
854 _("Floats & Insets%t"
857 "|Open All Footnotes/Margin Notes%x23"
858 "|Close All Footnotes/Margin Notes%x24"
859 "|Open All Figures/Tables%x25"
860 "|Close All Figures/Tables%x26%l"
861 "|Remove all Error Boxes%x27"));
863 fl_setpup_shortcut(SubEditFloats, 21, scex(_("EMF|Oo#o#O")));
864 fl_setpup_shortcut(SubEditFloats, 22, scex(_("EMF|Mm#m#M")));
865 fl_setpup_shortcut(SubEditFloats, 23, scex(_("EMF|Aa#a#A")));
866 fl_setpup_shortcut(SubEditFloats, 24, scex(_("EMF|Cc#c#C")));
867 fl_setpup_shortcut(SubEditFloats, 25, scex(_("EMF|Ff#f#F")));
868 fl_setpup_shortcut(SubEditFloats, 26, scex(_("EMF|Tt#t#T")));
869 fl_setpup_shortcut(SubEditFloats, 27, scex(_("EMF|Rr#r#R")));
872 int SubEditTable = fl_newpup(FL_ObjWin(ob));
874 if (men->currentView()->available() &&
875 men->currentView()->text->cursor.par()->table &&
876 !tmpbuffer->isReadonly()){
877 LyXTable * table = men->currentView()->text->cursor.par()->table;
879 fl_addtopup(SubEditTable, _("Table%t"));
881 if (table->IsMultiColumn(men->currentView()->text->
882 NumberOfCell(men->currentView()->
885 text->cursor.pos())))
886 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
888 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
889 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
891 if (table->TopLine(men->currentView()->text->
892 NumberOfCell(men->currentView()->
894 men->currentView()->text->
896 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
898 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
899 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
901 if (table->BottomLine(men->currentView()->text->
902 NumberOfCell(men->currentView()->
905 text->cursor.pos())))
906 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
908 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
909 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
911 if (table->LeftLine(men->currentView()->text->
912 NumberOfCell(men->currentView()->
915 text->cursor.pos())))
916 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
918 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
919 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
921 if (table->RightLine(men->currentView()->text->
922 NumberOfCell(men->currentView()->
925 text->cursor.pos())))
926 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
928 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
929 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
932 table->GetAlignment(men->currentView()->text->
933 NumberOfCell(men->currentView()->
936 text->cursor.pos()));
937 if (align == LYX_ALIGN_LEFT)
938 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
940 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
941 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
943 if (align == LYX_ALIGN_RIGHT)
944 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
946 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
947 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
949 if (align == LYX_ALIGN_CENTER)
950 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
952 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
953 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
955 // xgettext:no-c-format
956 fl_addtopup(SubEditTable, _("|Append Row%x32"));
957 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
958 // xgettext:no-c-format
959 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
960 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
961 // xgettext:no-c-format
962 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
963 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
964 // xgettext:no-c-format
965 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
966 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
967 // xgettext:no-c-format
968 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
969 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
972 if (men->currentView()->the_locking_inset &&
973 (men->currentView()->the_locking_inset->LyxCode() ==
974 Inset::TABULAR_CODE) &&
975 !tmpbuffer->isReadonly()) {
976 InsetTabular * inset = static_cast<InsetTabular *>(men->currentView()->the_locking_inset);
977 LyXTabular * table = inset->tabular;
979 fl_addtopup(SubEditTable, _("Table%t"));
981 if (table->IsMultiColumn(inset->GetActCell()))
982 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
984 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
985 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
987 if (table->TopLine(inset->GetActCell()))
988 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
990 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
991 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
993 if (table->BottomLine(inset->GetActCell()))
994 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
996 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
997 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
999 if (table->LeftLine(inset->GetActCell()))
1000 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
1002 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
1003 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
1005 if (table->RightLine(inset->GetActCell()))
1006 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
1008 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
1009 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
1011 int align = table->GetAlignment(inset->GetActCell());
1012 if (align == LYX_ALIGN_LEFT)
1013 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
1015 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
1016 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
1018 if (align == LYX_ALIGN_RIGHT)
1019 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
1021 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
1022 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
1024 if (align == LYX_ALIGN_CENTER)
1025 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
1027 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
1028 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
1030 // xgettext:no-c-format
1031 fl_addtopup(SubEditTable, _("|Append Row%x32"));
1032 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
1033 // xgettext:no-c-format
1034 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
1035 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
1036 // xgettext:no-c-format
1037 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
1038 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
1039 // xgettext:no-c-format
1040 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
1041 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
1042 // xgettext:no-c-format
1043 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
1044 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
1046 fl_addtopup(SubEditTable, _("Table%t"));
1047 // xgettext:no-c-format
1048 fl_addtopup(SubEditTable, _("|Insert table%x31"));
1049 fl_setpup_shortcut(SubEditTable, 31, scex(_("EMT|Ii#i#I")));
1052 int SubVersionControl = fl_newpup(FL_ObjWin(ob));
1053 fl_addtopup(SubVersionControl, _("Version Control%t"));
1054 if (tmpbuffer->lyxvc.inUse()) {
1055 // xgettext:no-c-format
1056 fl_addtopup(SubVersionControl, _("|Register%d%x51"));
1057 if (tmpbuffer->isReadonly()) {
1058 // signifies that the file is not checked out
1059 // xgettext:no-c-format
1060 fl_addtopup(SubVersionControl, _("|Check In Changes%d%x52"));
1061 // xgettext:no-c-format
1062 fl_addtopup(SubVersionControl, _("|Check Out for Edit%x53"));
1064 // signifies that the file is checked out
1065 // xgettext:no-c-format
1066 fl_addtopup(SubVersionControl, _("|Check In Changes%x52"));
1067 // xgettext:no-c-format
1068 fl_addtopup(SubVersionControl, _("|Check Out for Edit%d%x53"));
1070 // xgettext:no-c-format
1071 fl_addtopup(SubVersionControl, _("|Revert to last version%x54"));
1072 // xgettext:no-c-format
1073 fl_addtopup(SubVersionControl, _("|Undo last check in%x55"));
1074 // xgettext:no-c-format
1075 fl_addtopup(SubVersionControl, _("|Show History%x56"));
1077 // xgettext:no-c-format
1078 fl_addtopup(SubVersionControl, _("|Register%x51"));
1080 // the shortcuts are not good.
1081 fl_setpup_shortcut(SubVersionControl, 51, scex(_("EMV|Rr#r#R")));
1082 fl_setpup_shortcut(SubVersionControl, 52, scex(_("EMV|Ii#i#I")));
1083 fl_setpup_shortcut(SubVersionControl, 53, scex(_("EMV|Oo#o#O")));
1084 fl_setpup_shortcut(SubVersionControl, 54, scex(_("EMV|lL#l#l")));
1085 fl_setpup_shortcut(SubVersionControl, 55, scex(_("EMV|Uu#u#U")));
1086 fl_setpup_shortcut(SubVersionControl, 56, scex(_("EMV|Hh#h#H")));
1088 int EditMenu= fl_defpup(FL_ObjWin(ob),
1094 "|Find & Replace..."
1097 "|Floats & Insets%m"
1101 "|Table of Contents..."
1102 "|List of Figures..."
1103 "|List of Tables..."
1104 "|List of Algorithms...%l"
1105 "|Version Control%m%l"
1106 "|View LaTeX log file%l"
1107 "|Paste Primary Selection as Lines"
1108 "|Paste Primary Selection as Paragraphs"),
1109 SubEditFloats, SubEditTable, SubVersionControl);
1111 fl_setpup_shortcut(EditMenu, 1, scex(_("EM|Uu#u#U")));
1112 fl_setpup_shortcut(EditMenu, 2, scex(_("EM|Rr#r#R")));
1113 fl_setpup_shortcut(EditMenu, 3, scex(_("EM|Cc#c#C")));
1114 fl_setpup_shortcut(EditMenu, 4, scex(_("EM|oO#o#O")));
1115 fl_setpup_shortcut(EditMenu, 5, scex(_("EM|Pp#p#P")));
1116 fl_setpup_shortcut(EditMenu, 6, scex(_("EM|Ff#f#F")));
1117 fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
1118 fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
1119 fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
1120 //fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
1121 fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
1122 fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
1123 fl_setpup_shortcut(EditMenu, 13, scex(_("EM|Tt#t#T")));
1124 //fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Ff#f#F")));
1125 //fl_setpup_shortcut(EditMenu, 15, scex(_("EM|bB#b#B")));
1126 //fl_setpup_shortcut(EditMenu, 16, scex(_("EM|mM#m#M")));
1127 fl_setpup_shortcut(EditMenu, 17, scex(_("EM|Vv#v#V")));
1128 fl_setpup_shortcut(EditMenu, 18, scex(_("EM|wW#w#W")));
1129 fl_setpup_shortcut(EditMenu, 19, scex(_("EM|Ll#l#L")));
1130 fl_setpup_shortcut(EditMenu, 20, scex(_("EM|gG#g#G")));
1132 // disable unavailable entries.
1133 if(tmpbuffer->undostack.empty())
1134 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1135 if(tmpbuffer->redostack.empty())
1136 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1137 if(lyxrc.isp_command == "none")
1138 fl_setpup_mode(EditMenu, 11, FL_PUP_GREY);
1139 if(lyxrc.chktex_command == "none")
1140 fl_setpup_mode(EditMenu, 12, FL_PUP_GREY);
1142 if (tmpbuffer->isReadonly()) {
1143 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1144 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1145 fl_setpup_mode(EditMenu, 3, FL_PUP_GREY);
1146 fl_setpup_mode(EditMenu, 5, FL_PUP_GREY);
1147 fl_setpup_mode(EditMenu, 19, FL_PUP_GREY);
1148 fl_setpup_mode(EditMenu, 20, FL_PUP_GREY);
1151 fl_setpup_position(men->_view->getForm()->x + ob->x,
1152 men->_view->getForm()->y + ob->y +
1154 int choice = fl_dopup(EditMenu);
1157 // set the pseudo menu-button back
1158 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1159 fl_redraw_object(ob);
1162 case 1: tmpfunc->Dispatch(LFUN_UNDO); break;
1163 case 2: tmpfunc->Dispatch(LFUN_REDO); break;
1164 case 3: tmpfunc->Dispatch(LFUN_CUT); break;
1165 case 4: tmpfunc->Dispatch(LFUN_COPY); break;
1166 case 5: tmpfunc->Dispatch(LFUN_PASTE); break;
1167 case 6: tmpfunc->Dispatch(LFUN_MENUSEARCH); break;
1168 case 7: tmpfunc->Dispatch(LFUN_GOTOERROR); break;
1169 case 8: tmpfunc->Dispatch(LFUN_GOTONOTE); break;
1170 case 9: // floats & insets
1174 case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
1175 case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
1176 case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
1177 case 14: tmpfunc->Dispatch(LFUN_LOFVIEW); break;
1178 case 15: tmpfunc->Dispatch(LFUN_LOTVIEW); break;
1179 case 16: tmpfunc->Dispatch(LFUN_LOAVIEW); break;
1180 case 17: // version control
1182 case 18: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
1183 case 19: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
1184 case 20: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
1187 // floats & insets sub-menu
1188 case 21: men->currentView()->toggleFloat(); break;
1189 case 22: tmpfunc->Dispatch(LFUN_MELT); break;
1190 case 23: men->currentView()->allFloats(1, 0); break;
1191 case 24: men->currentView()->allFloats(0, 0); break;
1192 case 25: men->currentView()->allFloats(1, 1); break;
1193 case 26: men->currentView()->allFloats(0, 1); break;
1194 case 27: tmpfunc->Dispatch(LFUN_REMOVEERRORS); break;
1196 case 31: tmpfunc->Dispatch(LFUN_DIALOG_TABULAR_INSERT); break;
1197 // this is really temporary. We need new function in keybind.C
1198 // These should set the minibuffer, too.
1199 case 32: case 33: case 34:
1200 case 35: case 36: case 37:
1201 case 38: case 39: case 40:
1202 case 41: case 42: case 43:
1204 if (men->currentView()->available()) {
1205 men->currentView()->hideCursor();
1206 if (!men->currentView()->text->selection){
1207 men->currentView()->beforeChange();
1208 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR);
1210 if (men->currentView()->the_locking_inset &&
1211 (men->currentView()->the_locking_inset->LyxCode()
1212 == Inset::TABULAR_CODE)) {
1213 InsetTabular * inset =
1214 static_cast<InsetTabular *>
1215 (men->currentView()->the_locking_inset);
1216 inset->TabularFeatures(men->currentView(), choice - 32);
1220 men->currentView()->text->
1221 TableFeatures(men->currentView(), choice - 32);
1222 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
1227 // version control sub-menu
1228 case 51: // register
1229 tmpfunc->Dispatch(LFUN_VC_REGISTER);
1231 case 52: // check in
1232 tmpfunc->Dispatch(LFUN_VC_CHECKIN);
1234 case 53: // check out
1235 tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
1237 case 54: // revert to last
1238 tmpfunc->Dispatch(LFUN_VC_REVERT);
1240 case 55: // undo last
1241 tmpfunc->Dispatch(LFUN_VC_UNDO);
1243 case 56: // show history
1244 tmpfunc->Dispatch(LFUN_VC_HISTORY);
1248 fl_freepup(EditMenu);
1249 fl_freepup(SubEditFloats);
1250 fl_freepup(SubEditTable);
1251 fl_freepup(SubVersionControl);
1254 vector<int>::size_type const max_number_of_menus = 32;
1255 unsigned int const max_number_of_items = 25;
1257 string Limit_string_length(string const & str) {
1258 string::size_type const max_item_length = 45;
1260 if (str.size() > max_item_length)
1261 return str.substr(0, max_item_length-3) + "...";
1266 void Add_to_toc_menu(vector<Buffer::TocItem> const & toclist,
1267 unsigned int from, unsigned int to, int depth,
1268 int menu, vector<int> & menus, FL_OBJECT * ob)
1270 if (to - from <= max_number_of_items) {
1271 for (unsigned int i = from; i < to; ++i) {
1272 string entry(4 * max(0, toclist[i].depth - depth),' ');
1273 entry += toclist[i].str;
1274 entry = Limit_string_length(entry);
1275 entry += "%x" + tostr(i + 1);
1276 fl_addtopup(menu, entry.c_str());
1279 unsigned int pos = from;
1280 unsigned int count = 0;
1283 if (count > max_number_of_items) {
1284 fl_addtopup(menu, ". . .%d");
1287 unsigned int new_pos = pos+1;
1288 while (new_pos < to &&
1289 toclist[new_pos].depth > depth)
1292 string entry(4 * max(0, toclist[pos].depth - depth), ' ');
1293 entry += toclist[pos].str;
1294 entry = Limit_string_length(entry);
1296 if (new_pos == pos + 1) {
1298 entry += tostr(pos + 1);
1299 fl_addtopup(menu, entry.c_str());
1300 } else if (menus.size() < max_number_of_menus) {
1301 int menu2 = fl_newpup(FL_ObjWin(ob));
1302 menus.push_back(menu2);
1303 Add_to_toc_menu(toclist, pos, new_pos,
1304 depth + 1, menu2, menus,ob);
1306 fl_addtopup(menu, entry.c_str(), menu2);
1309 fl_addtopup(menu, entry.c_str());
1316 int const BIG_NUM = 1048576;
1318 void Menus::ShowTocMenu(FL_OBJECT * ob, long)
1320 Menus * men = static_cast<Menus*>(ob->u_vdata);
1323 // set the pseudo menu-button
1324 fl_set_object_boxtype(ob, FL_UP_BOX);
1325 fl_set_button(ob, 0);
1326 fl_redraw_object(ob);
1328 int TocMenu = fl_newpup(FL_ObjWin(ob));
1329 menus.push_back(TocMenu);
1330 vector<vector<Buffer::TocItem> > toclist =
1331 men->currentView()->buffer()->getTocList();
1333 //xgettext:no-c-format
1334 static char const * MenuNames[3] = { N_("List of Figures%m"),
1335 //xgettext:no-c-format
1336 N_("List of Tables%m"),
1337 //xgettext:no-c-format
1338 N_("List of Algorithms%m") };
1340 int max_nonempty = 0;
1341 for (int j = 1; j <= 3; ++j)
1342 if (!toclist[j].empty())
1345 for (int j = 1; j <= 3; ++j)
1346 if (!toclist[j].empty()) {
1347 int menu2 = fl_newpup(FL_ObjWin(ob));
1348 menus.push_back(menu2);
1349 for (unsigned int i = 0; i < toclist[j].size(); ++i) {
1350 if (i > max_number_of_items) {
1351 fl_addtopup(menu2, ". . .%d");
1354 string entry = Limit_string_length(toclist[j][i].str);
1355 entry += "%x" + tostr(i+1+j*BIG_NUM);
1356 fl_addtopup(menu2, entry.c_str());
1358 if (j == max_nonempty) {
1359 string tmp = _(MenuNames[j-1]);
1361 fl_addtopup(TocMenu, tmp.c_str(), menu2);
1363 fl_addtopup(TocMenu, _(MenuNames[j-1]), menu2);
1366 Add_to_toc_menu(toclist[0], 0, toclist[0].size(), 0,
1367 TocMenu, menus, ob);
1370 men->_view->getForm()->x + ob->x,
1371 men->_view->getForm()->y + ob->y + ob->h + 10);
1372 int choice = fl_dopup(TocMenu);
1375 // set the pseudo menu-button back
1376 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1377 fl_redraw_object(ob);
1379 men->_view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
1380 else if (choice > 0) {
1381 int type = choice / BIG_NUM;
1382 int num = (choice % BIG_NUM) - 1;
1383 BufferView *bv = men->currentView();
1385 bv->text->SetCursor(bv, toclist[type][num].par, 0);
1386 bv->text->sel_cursor = bv->text->cursor;
1387 bv->update(BufferView::SELECT|BufferView::FITCUR);
1389 for (unsigned int i = 0; i < menus.size(); ++i)
1390 fl_freepup(menus[i]);
1393 void Add_to_refs_menu(vector<string> const & label_list, int offset,
1394 int menu, vector<int> & menus, FL_OBJECT * ob)
1396 typedef vector<string>::size_type size_type;
1397 size_type const max_number_of_items = 25;
1398 size_type const max_number_of_items2 = 20;
1399 string::size_type const max_item_length = 40;
1400 string::size_type const max_item_length2 = 20;
1402 if (label_list.size() <= max_number_of_items)
1403 for (size_type i = 0; i < label_list.size(); ++i) {
1404 string entry = label_list[i];
1405 if (entry.size() > max_item_length)
1406 entry = entry.substr(0, max_item_length-1) + "$";
1407 entry += "%x" + tostr(i+offset);
1408 fl_addtopup(menu, entry.c_str());
1411 size_type count = 0;
1412 for (size_type i = 0; i < label_list.size();
1413 i += max_number_of_items2) {
1415 if (count > max_number_of_items) {
1416 fl_addtopup(menu, ". . .%d");
1419 size_type j = min(label_list.size(),
1420 i+max_number_of_items2);
1423 if (label_list[i].size() > max_item_length2)
1424 entry += label_list[i].substr(0, max_item_length2-1) + "$";
1426 entry += label_list[i];
1428 if (label_list[j-1].size() > max_item_length2)
1429 entry += label_list[j-1].substr(0, max_item_length2-1) + "$";
1431 entry += label_list[j-1];
1433 if (menus.size() < max_number_of_menus) {
1434 int menu2 = fl_newpup(FL_ObjWin(ob));
1435 menus.push_back(menu2);
1436 for (size_type k = i; k < j; ++k) {
1437 string entry2 = label_list[k];
1438 if (entry2.size() > max_item_length)
1439 entry2 = entry2.substr(0, max_item_length-1) + "$";
1440 entry2 += "%x" + tostr(k+offset);
1441 fl_addtopup(menu2, entry2.c_str());
1444 fl_addtopup(menu, entry.c_str(), menu2);
1447 fl_addtopup(menu, entry.c_str());
1453 void Menus::ShowRefsMenu(FL_OBJECT * ob, long)
1457 Menus * men = static_cast<Menus*>(ob->u_vdata);
1459 // set the pseudo menu-button
1460 fl_set_object_boxtype(ob, FL_UP_BOX);
1461 fl_set_button(ob, 0);
1462 fl_redraw_object(ob);
1464 int RefsMenu = fl_newpup(FL_ObjWin(ob));
1465 menus.push_back(RefsMenu);
1466 Buffer * buffer = men->currentView()->buffer();
1467 vector<string> label_list = buffer->getLabelList();
1468 sort(label_list.begin(), label_list.end());
1470 //xgettext:no-c-format
1471 static char const * MenuNames[6] = { N_("Insert Reference%m"),
1472 //xgettext:no-c-format
1473 N_("Insert Page Number%m"),
1474 //xgettext:no-c-format
1475 N_("Insert vref%m"),
1476 //xgettext:no-c-format
1477 N_("Insert vpageref%m"),
1478 //xgettext:no-c-format
1479 N_("Insert Pretty Ref%m"),
1480 //xgettext:no-c-format
1481 N_("Goto Reference%m") };
1483 for (int j = 0; j < 6; ++j) {
1484 if (menus.size() < max_number_of_menus) {
1485 int menu2 = fl_newpup(FL_ObjWin(ob));
1486 menus.push_back(menu2);
1487 Add_to_refs_menu(label_list, (j+1)*BIG_NUM, menu2, menus, ob);
1488 fl_addtopup(RefsMenu, _(MenuNames[j]), menu2);
1490 string tmp = _(MenuNames[j]);
1492 fl_addtopup(RefsMenu, tmp.c_str());
1495 fl_addtopup(RefsMenu, _("Go Back"));
1497 bool empty = label_list.empty();
1498 bool sgml = buffer->isSGML();
1499 bool readonly = buffer->isReadonly();
1502 fl_setpup_mode(RefsMenu, 6, FL_PUP_GREY);
1503 if (empty || readonly) {
1504 fl_setpup_mode(RefsMenu, 1, FL_PUP_GREY);
1505 fl_setpup_mode(RefsMenu, 2, FL_PUP_GREY);
1507 if (empty || readonly || sgml) {
1508 fl_setpup_mode(RefsMenu, 3, FL_PUP_GREY);
1509 fl_setpup_mode(RefsMenu, 4, FL_PUP_GREY);
1510 fl_setpup_mode(RefsMenu, 5, FL_PUP_GREY);
1512 if (men->currentView()->NoSavedPositions())
1513 fl_setpup_mode(RefsMenu, 7, FL_PUP_GREY);
1516 men->_view->getForm()->x + ob->x,
1517 men->_view->getForm()->y + ob->y + ob->h + 10);
1518 int choice = fl_dopup(RefsMenu);
1521 // set the pseudo menu-button back
1522 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1523 fl_redraw_object(ob);
1526 men->_view->getLyXFunc()->Dispatch(LFUN_REF_BACK);
1527 else if (choice >= BIG_NUM) {
1528 int type = (choice / BIG_NUM) - 1;
1529 int num = choice % BIG_NUM;
1531 men->_view->getLyXFunc()->Dispatch(LFUN_REF_GOTO,
1532 label_list[num].c_str());
1534 static string const cmdname[5]
1535 = { "ref", "pageref", "vref", "vpageref", "prettyref"};
1536 InsetCommandParams p( cmdname[type] );
1537 p.setContents( label_list[num] );
1538 men->currentView()->insertInset(new InsetRef(p));
1542 for (unsigned int i = 0; i < menus.size(); ++i)
1543 fl_freepup(menus[i]);
1547 void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
1549 Menus * men = static_cast<Menus*>(ob->u_vdata);
1551 if (!men->currentView()->available())
1554 // set the pseudo menu-button
1555 fl_set_object_boxtype(ob, FL_UP_BOX);
1556 fl_set_button(ob, 0);
1557 fl_redraw_object(ob);
1559 Buffer * tmpbuffer = men->_view->buffer();
1560 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1562 int LayoutMenu = fl_newpup(FL_ObjWin(ob));
1563 fl_addtopup(LayoutMenu, _("Character..."
1569 "|Emphasize Style%b"
1573 "|Change Environment Depth"
1574 "|LaTeX Preamble..."
1575 "|Start of Appendix%l"
1576 "|Save layout as default"));
1577 fl_setpup_shortcut(LayoutMenu, 1, scex(_("LM|Cc#c#C")));
1578 fl_setpup_shortcut(LayoutMenu, 2, scex(_("LM|Pp#p#P")));
1579 fl_setpup_shortcut(LayoutMenu, 3, scex(_("LM|Dd#d#D")));
1580 fl_setpup_shortcut(LayoutMenu, 4, scex(_("LM|aA#a#A")));
1581 fl_setpup_shortcut(LayoutMenu, 5, scex(_("LM|eE#e#E")));
1582 fl_setpup_shortcut(LayoutMenu, 6, scex(_("LM|Qq#q#Q")));
1583 fl_setpup_shortcut(LayoutMenu, 7, scex(_("LM|mM#m#M")));
1584 fl_setpup_shortcut(LayoutMenu, 8, scex(_("LM|Nn#n#N")));
1585 fl_setpup_shortcut(LayoutMenu, 9, scex(_("LM|Bb#b#B")));
1586 fl_setpup_shortcut(LayoutMenu, 10, scex(_("LM|Tt#t#T")));
1587 fl_setpup_shortcut(LayoutMenu, 11, scex(_("LM|vV#v#V")));
1588 fl_setpup_shortcut(LayoutMenu, 12, scex(_("LM|Ll#l#L")));
1589 fl_setpup_shortcut(LayoutMenu, 13, scex(_("LM|xX#x#X")));
1590 fl_setpup_shortcut(LayoutMenu, 14, scex(_("LM|Ss#s#S")));
1592 // Set values of checkboxes according to font
1593 LyXFont font = men->currentView()->text->real_current_font;
1594 if (font.emph() == LyXFont::ON)
1595 fl_setpup_mode(LayoutMenu, 7, FL_PUP_CHECK);
1596 if (font.noun() == LyXFont::ON)
1597 fl_setpup_mode(LayoutMenu, 8, FL_PUP_CHECK);
1598 if (font.series() == LyXFont::BOLD_SERIES)
1599 fl_setpup_mode(LayoutMenu, 9, FL_PUP_CHECK);
1600 if (font.latex() == LyXFont::ON)
1601 fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
1603 // Grey out unavailable entries
1605 if (!men->currentView()->text->cursor.par()->table)
1606 fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
1608 if (tmpbuffer->isReadonly()) {
1609 fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
1610 fl_setpup_mode(LayoutMenu, 6, FL_PUP_GREY);
1611 fl_setpup_mode(LayoutMenu, 11, FL_PUP_GREY);
1615 men->_view->getForm()->x + ob->x,
1616 men->_view->getForm()->y + ob->y + ob->h + 10);
1617 int choice = fl_dopup(LayoutMenu);
1620 // set the pseudo menu-button back
1621 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1622 fl_redraw_object(ob);
1625 case 1: tmpfunc->Dispatch(LFUN_LAYOUT_CHARACTER); break;
1626 case 2: tmpfunc->Dispatch(LFUN_LAYOUT_PARAGRAPH); break;
1627 case 3: tmpfunc->Dispatch(LFUN_LAYOUT_DOCUMENT); break;
1628 case 4: tmpfunc->Dispatch(LFUN_LAYOUT_PAPER); break;
1629 case 5: tmpfunc->Dispatch(LFUN_LAYOUT_TABLE, "true"); break;
1630 case 6: tmpfunc->Dispatch(LFUN_LAYOUT_QUOTES); break;
1631 case 7: tmpfunc->Dispatch(LFUN_EMPH); break;
1632 case 8: tmpfunc->Dispatch(LFUN_NOUN); break;
1633 case 9: tmpfunc->Dispatch(LFUN_BOLD); break;
1634 case 10: tmpfunc->Dispatch(LFUN_TEX); break;
1635 case 11: tmpfunc->Dispatch(LFUN_DEPTH_PLUS); break;
1636 case 12: tmpfunc->Dispatch(LFUN_LAYOUT_PREAMBLE); break;
1637 case 13: tmpfunc->Dispatch(LFUN_APPENDIX); break;
1638 case 14: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;
1640 fl_freepup(LayoutMenu);
1644 void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
1646 Menus * men = static_cast<Menus*>(ob->u_vdata);
1648 // set the pseudo menu-button
1649 fl_set_object_boxtype(ob, FL_UP_BOX);
1650 fl_set_button(ob, 0);
1651 fl_redraw_object(ob);
1653 Buffer * tmpbuffer = men->_view->buffer();
1654 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1656 int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
1657 _("Import ASCII file%t"
1659 "|As Paragraphs%x42"));
1661 fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
1662 fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
1664 int SubInsertTableList= fl_defpup(FL_ObjWin(ob),
1666 "|Table of Contents%x21"
1667 "|List of Figures%x22"
1668 "|List of Tables%x23"
1669 "|List of Algorithms%x24"
1671 "|BibTeX Reference%x26"));
1673 fl_setpup_shortcut(SubInsertTableList, 21, scex(_("IMT|Cc#c#C")));
1674 fl_setpup_shortcut(SubInsertTableList, 22, scex(_("IMT|Ff#f#F")));
1675 fl_setpup_shortcut(SubInsertTableList, 23, scex(_("IMT|Tt#t#T")));
1676 fl_setpup_shortcut(SubInsertTableList, 24, scex(_("IMT|Aa#a#A")));
1677 fl_setpup_shortcut(SubInsertTableList, 25, scex(_("IMT|Ii#i#I")));
1678 fl_setpup_shortcut(SubInsertTableList, 26, scex(_("IMT|Bb#b#B")));
1680 int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
1684 "|Wide Figure Float%x73"
1685 "|Wide Table Float%l%x74"
1686 "|Algorithm Float%x75"));
1688 fl_setpup_shortcut(SubInsertFloatList, 71, scex(_("IMF|gG#g#G")));
1689 fl_setpup_shortcut(SubInsertFloatList, 72, scex(_("IMF|Tt#t#T")));
1690 fl_setpup_shortcut(SubInsertFloatList, 73, scex(_("IMF|Ww#w#W")));
1691 fl_setpup_shortcut(SubInsertFloatList, 74, scex(_("IMF|iI#i#I")));
1692 fl_setpup_shortcut(SubInsertFloatList, 75, scex(_("IMF|Aa#a#A")));
1694 int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
1695 _("Special Character%t"
1697 "|Hyphenation Point%x32"
1698 "|Protected Blank%x33"
1700 "|Ellipsis (...)%x35"
1701 "|End of sentence period%x36"
1702 "|Ordinary Quote (\")%x37"
1703 "|Menu Separator %x38"));
1705 fl_setpup_shortcut(SubInsertSpecial, 31, scex(_("IMS|Hh#h#H")));
1706 fl_setpup_shortcut(SubInsertSpecial, 32, scex(_("IMS|Pp#p#P")));
1707 fl_setpup_shortcut(SubInsertSpecial, 33, scex(_("IMS|Bb#b#B")));
1708 fl_setpup_shortcut(SubInsertSpecial, 34, scex(_("IMS|Ll#l#L")));
1709 fl_setpup_shortcut(SubInsertSpecial, 35, scex(_("IMS|iI#i#I")));
1710 fl_setpup_shortcut(SubInsertSpecial, 36, scex(_("IMS|Ee#e#E")));
1711 fl_setpup_shortcut(SubInsertSpecial, 37, scex(_("IMS|Qq#q#Q")));
1712 fl_setpup_shortcut(SubInsertSpecial, 38, scex(_("IMS|Mm#m#M")));
1714 int InsertMenu = fl_defpup(FL_ObjWin(ob),
1718 "|Import ASCII File%m"
1719 "|Insert LyX File..."
1720 "|Insert external material...%l"
1725 "|Special Character%m%l"
1728 "|Cross-Reference..."
1729 "|Citation Reference..."
1731 "|Index entry of last word"),
1737 fl_setpup_shortcut(InsertMenu, 1, scex(_("IM|gG#g#G")));
1738 fl_setpup_shortcut(InsertMenu, 2, scex(_("IM|bB#b#B")));
1739 fl_setpup_shortcut(InsertMenu, 3, scex(_("IM|cC#c#C")));
1740 fl_setpup_shortcut(InsertMenu, 4, scex(_("IM|Aa#a#A")));
1741 fl_setpup_shortcut(InsertMenu, 5, scex(_("IM|Xx#x#X")));
1742 fl_setpup_shortcut(InsertMenu, 6, scex(_("IM|Ee#e#E")));
1743 fl_setpup_shortcut(InsertMenu, 7, scex(_("IM|Ff#f#F")));
1744 fl_setpup_shortcut(InsertMenu, 8, scex(_("IM|Mm#m#M")));
1745 fl_setpup_shortcut(InsertMenu, 9, scex(_("IM|oO#o#O")));
1746 fl_setpup_shortcut(InsertMenu, 10, scex(_("IM|Tt#t#T")));
1747 fl_setpup_shortcut(InsertMenu, 11, scex(_("IM|Ss#s#S")));
1748 fl_setpup_shortcut(InsertMenu, 12, scex(_("IM|Nn#n#N")));
1749 fl_setpup_shortcut(InsertMenu, 13, scex(_("IM|Ll#l#L")));
1750 fl_setpup_shortcut(InsertMenu, 14, scex(_("IM|rR#r#R")));
1751 fl_setpup_shortcut(InsertMenu, 15, scex(_("IM|iI#i#I")));
1752 fl_setpup_shortcut(InsertMenu, 16, scex(_("IM|dD#d#D")));
1753 fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|wW#w#W")));
1755 fl_addtopup(InsertMenu, _("|URL..."));
1756 fl_setpup_shortcut(InsertMenu, 18, scex(_("IM|Uu#u#U")));
1758 if (tmpbuffer->isReadonly()) {
1759 for (int ii = 1; ii <= 17; ++ii)
1760 fl_setpup_mode(InsertMenu, ii, FL_PUP_GREY);
1761 fl_setpup_mode(InsertMenu, 18, FL_PUP_GREY);
1765 men->_view->getForm()->x + ob->x,
1766 men->_view->getForm()->y + ob->y + ob->h + 10);
1768 int choice = fl_dopup(InsertMenu);
1771 // set the pseudo menu-button back
1772 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1773 fl_redraw_object(ob);
1775 if (men->currentView()->available()){
1776 men->currentView()->hideCursor();
1778 case 1: tmpfunc->Dispatch(LFUN_FIGURE); break;
1779 case 2: tmpfunc->Dispatch(LFUN_DIALOG_TABULAR_INSERT); break;
1780 case 3: tmpfunc->Dispatch(LFUN_CHILDINSERT); break;
1781 case 4: // Insert ASCII file submenu
1783 case 5: tmpfunc->Dispatch(LFUN_FILE_INSERT); break;
1784 case 41: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "line"); break;
1785 case 42: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "paragraph"); break;
1789 case 6: tmpfunc->Dispatch(LFUN_INSET_EXTERNAL); break;
1793 tmpfunc->Dispatch(LFUN_FOOTMELT); break;
1795 tmpfunc->Dispatch(LFUN_INSET_FOOTNOTE);
1800 tmpfunc->Dispatch(LFUN_MARGINMELT); break;
1802 tmpfunc->Dispatch(LFUN_INSET_MARGINAL);
1806 case 9: // Float sub-menu
1809 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure");
1812 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "figure");
1817 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table");
1820 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "table");
1825 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig");
1828 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "figure");
1833 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab");
1836 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "table");
1841 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm");
1844 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "algorithm");
1847 case 10: // Table/List submenu
1849 case 21: tmpfunc->Dispatch(LFUN_TOC_INSERT); break;
1850 case 22: tmpfunc->Dispatch(LFUN_LOF_INSERT); break;
1851 case 23: tmpfunc->Dispatch(LFUN_LOT_INSERT); break;
1852 case 24: tmpfunc->Dispatch(LFUN_LOA_INSERT); break;
1853 case 25: tmpfunc->Dispatch(LFUN_INDEX_PRINT); break;
1854 case 26: tmpfunc->Dispatch(LFUN_INSERT_BIBTEX); break;
1856 case 11: // Special Character submenu
1858 case 31: tmpfunc->Dispatch(LFUN_HFILL); break;
1859 case 32: tmpfunc->Dispatch(LFUN_HYPHENATION); break;
1860 case 33: tmpfunc->Dispatch(LFUN_PROTECTEDSPACE); break;
1861 case 34: tmpfunc->Dispatch(LFUN_BREAKLINE); break;
1862 case 35: tmpfunc->Dispatch(LFUN_LDOTS); break;
1863 case 36: tmpfunc->Dispatch(LFUN_END_OF_SENTENCE); break;
1864 case 37: tmpfunc->Dispatch(LFUN_QUOTE); break;
1865 case 38: tmpfunc->Dispatch(LFUN_MENU_SEPARATOR); break;
1867 case 12: tmpfunc->Dispatch(LFUN_INSERT_NOTE); break;
1868 case 13: tmpfunc->Dispatch(LFUN_INSERT_LABEL); break;
1869 case 14: tmpfunc->Dispatch(LFUN_REF_CREATE); break;
1870 case 15: tmpfunc->Dispatch(LFUN_CITATION_CREATE); break;
1871 case 16: tmpfunc->Dispatch(LFUN_INDEX_CREATE); break;
1872 case 17: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break;
1873 case 18: tmpfunc->Dispatch(LFUN_URL); break;
1876 fl_freepup(InsertMenu);
1877 fl_freepup(SubInsertAscii);
1878 fl_freepup(SubInsertTableList);
1879 fl_freepup(SubInsertFloatList);
1880 fl_freepup(SubInsertSpecial);
1884 void Menus::ShowMathMenu(FL_OBJECT * ob, long)
1886 extern void math_insert_symbol(char const * s);
1888 Menus * men = static_cast<Menus*>(ob->u_vdata);
1890 // set the pseudo menu-button
1891 fl_set_object_boxtype(ob, FL_UP_BOX);
1892 fl_set_button(ob, 0);
1893 fl_redraw_object(ob);
1895 Buffer * tmpbuffer = men->_view->buffer();
1896 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1898 int MathMenu = fl_defpup(FL_ObjWin(ob),
1909 fl_setpup_shortcut(MathMenu, 1, scex(_("MM|Ff#f#F")));
1910 fl_setpup_shortcut(MathMenu, 2, scex(_("MM|Ss#s#S")));
1911 fl_setpup_shortcut(MathMenu, 3, scex(_("MM|Ee#e#E")));
1912 fl_setpup_shortcut(MathMenu, 4, scex(_("MM|xX#x#X")));
1913 fl_setpup_shortcut(MathMenu, 5, scex(_("MM|uU#u#U")));
1914 fl_setpup_shortcut(MathMenu, 6, scex(_("MM|Ii#i#I")));
1915 fl_setpup_shortcut(MathMenu, 7, scex(_("MM|Mm#m#M")));
1916 fl_setpup_shortcut(MathMenu, 8, scex(_("MM|Dd#d#D")));
1917 fl_setpup_shortcut(MathMenu, 9, scex(_("MM|Pp#p#P")));
1919 if (tmpbuffer->isReadonly())
1920 for (int ii = 1; ii <= 9; ++ii)
1921 fl_setpup_mode(MathMenu, ii, FL_PUP_GREY);
1925 men->_view->getForm()->x + ob->x,
1926 men->_view->getForm()->y + ob->y + ob->h + 10);
1927 int choice = fl_dopup(MathMenu);
1930 // set the pseudo menu-button back
1931 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1932 fl_redraw_object(ob);
1934 if (men->currentView()->available()) {
1937 tmpfunc->Dispatch(LFUN_INSERT_MATH, "frac");
1940 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
1942 case 3: /* Exponent */
1943 tmpfunc->Dispatch(LFUN_INSERT_MATH, "^");
1946 tmpfunc->Dispatch(LFUN_INSERT_MATH, "_");
1949 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sum");
1952 tmpfunc->Dispatch(LFUN_INSERT_MATH, "int");
1955 tmpfunc->Dispatch(LFUN_MATH_MODE);
1958 tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
1961 tmpfunc->Dispatch(LFUN_MATH_PANEL);
1964 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR);
1966 fl_freepup(MathMenu);
1970 void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
1972 Menus * men = static_cast<Menus*>(ob->u_vdata);
1974 // set the pseudo menu-button
1975 fl_set_object_boxtype(ob, FL_UP_BOX);
1976 fl_set_button(ob, 0);
1977 fl_redraw_object(ob);
1979 //Buffer *tmpbuffer = men->_view->currentBuffer();
1980 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1982 int OptionsMenu = fl_defpup(FL_ObjWin(ob),
1983 _("|Spellchecker Options..."
1988 fl_setpup_shortcut(OptionsMenu, 1, scex(_("OM|Ss#s#S")));
1989 fl_setpup_shortcut(OptionsMenu, 2, scex(_("OM|Kk#k#K")));
1990 fl_setpup_shortcut(OptionsMenu, 3, scex(_("OM|Rr#r#R")));
1991 fl_setpup_shortcut(OptionsMenu, 4, scex(_("OM|Pp#p#P")));
1993 if(lyxrc.isp_command == "none")
1994 fl_setpup_mode(OptionsMenu, 2, FL_PUP_GREY);
1997 men->_view->getForm()->x + ob->x,
1998 men->_view->getForm()->y + ob->y + ob->h + 10);
1999 int choice = fl_dopup(OptionsMenu);
2002 // set the pseudo menu-button back
2003 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2004 fl_redraw_object(ob);
2006 case 1: SpellCheckerOptions(); break;
2007 case 2: men->_view->getIntl()->MenuKeymap(); break;
2008 case 3: tmpfunc->Dispatch(LFUN_RECONFIGURE); break;
2009 case 4: men->_view->getDialogs()->showPreferences(); break;
2012 fl_freepup(OptionsMenu);
2016 void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
2018 Menus * men = static_cast<Menus*>(ob->u_vdata);
2020 // set the pseudo menu-button
2021 fl_set_object_boxtype(ob, FL_UP_BOX);
2022 fl_set_button(ob, 0);
2023 fl_redraw_object(ob);
2025 int BufferMenu = fl_newpup(FL_ObjWin(ob));
2026 vector<string> namevec = bufferlist.getFileNames();
2027 if (namevec.size() != 0) {
2028 for (vector<string>::const_iterator cit = namevec.begin();
2029 cit != namevec.end(); ++cit) {
2030 string relbuf = MakeDisplayPath((*cit), 30);
2031 fl_addtopup(BufferMenu, relbuf.c_str());
2034 fl_addtopup(BufferMenu, _("No Documents Open!%t"));
2038 men->_view->getForm()->x + ob->x,
2039 men->_view->getForm()->y + ob->y + ob->h + 10);
2040 int choice = fl_dopup(BufferMenu);
2043 // set the pseudo menu-button back
2044 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2045 fl_redraw_object(ob);
2046 if (choice > 0) men->handleBufferMenu(choice - 1);
2048 fl_freepup(BufferMenu);
2053 char const * doc_files [] = {"Intro", "Tutorial",
2054 "UserGuide", "Extended",
2055 "Customization", "Reference",
2057 "BUGS", "LyXConfig"};
2059 void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
2061 Menus * men = static_cast<Menus*>(ob->u_vdata);
2062 LyXFunc * tmpfunc = men->_view->getLyXFunc();
2064 // set the pseudo menu-button
2065 fl_set_object_boxtype(ob, FL_UP_BOX);
2066 fl_set_button(ob, 0);
2067 fl_redraw_object(ob);
2069 int HelpMenu = fl_defpup(FL_ObjWin(ob),
2073 "|Extended Features"
2077 "|Table of Contents"
2079 "|LaTeX Configuration%l"
2080 "|Copyright and Warranty..."
2084 fl_setpup_shortcut(HelpMenu, 1, scex(_("HM|Ii#I#i")));
2085 fl_setpup_shortcut(HelpMenu, 2, scex(_("HM|Tt#T#t")));
2086 fl_setpup_shortcut(HelpMenu, 3, scex(_("HM|Uu#U#u")));
2087 fl_setpup_shortcut(HelpMenu, 4, scex(_("HM|xX#x#X")));
2088 fl_setpup_shortcut(HelpMenu, 5, scex(_("HM|Cc#C#c")));
2089 fl_setpup_shortcut(HelpMenu, 6, scex(_("HM|Rr#R#r")));
2090 fl_setpup_shortcut(HelpMenu, 7, scex(_("HM|Ff#F#f")));
2091 fl_setpup_shortcut(HelpMenu, 8, scex(_("HM|aA#a#A")));
2092 fl_setpup_shortcut(HelpMenu, 9, scex(_("HM|Kk#K#k")));
2093 fl_setpup_shortcut(HelpMenu, 10, scex(_("HM|Ll#L#l")));
2094 fl_setpup_shortcut(HelpMenu, 11, scex(_("HM|oO#o#O")));
2095 fl_setpup_shortcut(HelpMenu, 12, scex(_("HM|eE#e#E")));
2096 fl_setpup_shortcut(HelpMenu, 13, scex(_("HM|Vv#v#V")));
2099 men->_view->getForm()->x + ob->x,
2100 men->_view->getForm()->y + ob->y + ob->h + 10);
2101 int choice = fl_dopup(HelpMenu);
2104 // set the pseudo menu-button back
2105 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2106 fl_redraw_object(ob);
2109 case 1: case 2: case 3: case 4: case 5:
2110 case 6: case 7: case 8: case 9: case 10:
2111 ProhibitInput(men->currentView());
2112 men->MenuDocu(doc_files[choice - 1]);
2113 AllowInput(men->currentView());
2115 case 11: tmpfunc->Dispatch(LFUN_HELP_COPYRIGHT); break;
2116 case 12: ShowCredits(); break;
2118 ProhibitInput(men->currentView());
2119 fl_show_message((string(_("LyX Version ")) + LYX_VERSION
2120 + _(" of ") + LYX_RELEASE).c_str(),
2121 (_("Library directory: ")
2122 + MakeDisplayPath(system_lyxdir)).c_str(),
2123 (_("User directory: ")
2124 + MakeDisplayPath(user_lyxdir)).c_str());
2125 AllowInput(men->currentView());
2128 fl_freepup(HelpMenu);
2132 void Menus::MenuDocu(string const & docname)
2134 string fname = i18nLibFileSearch("doc", docname, "lyx");
2135 if (fname.empty()) {
2136 WriteAlert(_("Error!"),
2137 _("Could not find requested Documentation file"),
2141 _view->getMiniBuffer()->Set(_("Opening help file"),
2142 MakeDisplayPath(fname), "...");
2143 currentView()->buffer(bufferlist.loadLyXFile(fname, false));
2145 if (docname == "Reference")
2146 _view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
2150 void Menus::handleBufferMenu(int choice)
2152 currentView()->buffer(bufferlist.getBuffer(choice));