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"
56 #include "frontends/Dialogs.h"
65 extern BufferList bufferlist;
67 // I would really prefere to see most or all of these 'extern's disappear.
68 // Their commands should be called through LyXFunc (IMO). (Lgb)
70 extern void MenuLayoutSave();
71 extern void ShowCredits();
73 // A bunch of wrappers
75 extern "C" void C_Menus_ShowFileMenu(FL_OBJECT * ob, long data)
77 Menus::ShowFileMenu(ob, data);
80 extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT * ob, long data)
82 Menus::ShowFileMenu2(ob, data);
85 extern "C" void C_Menus_ShowEditMenu(FL_OBJECT * ob, long data)
87 Menus::ShowEditMenu(ob, data);
90 extern "C" void C_Menus_ShowTocMenu(FL_OBJECT * ob, long data)
92 Menus::ShowTocMenu(ob, data);
95 extern "C" void C_Menus_ShowRefsMenu(FL_OBJECT * ob, long data)
97 Menus::ShowRefsMenu(ob, data);
100 extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT * ob, long data)
102 Menus::ShowLayoutMenu(ob, data);
105 extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT * ob, long data)
107 Menus::ShowInsertMenu(ob, data);
110 extern "C" void C_Menus_ShowMathMenu(FL_OBJECT * ob, long data)
112 Menus::ShowMathMenu(ob, data);
115 extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT * ob, long data)
117 Menus::ShowOptionsMenu(ob, data);
120 extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT * ob, long data)
122 Menus::ShowBufferMenu(ob, data);
125 extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT * ob, long data)
127 Menus::ShowHelpMenu(ob, data);
131 Menus::Menus(LyXView * view, int air)
135 // deactivate the menu accelerators
136 fl_set_object_shortcut(menu_file, "", 1);
137 fl_set_object_shortcut(menu_file2, "", 1);
138 fl_set_object_shortcut(menu_edit, "", 1);
139 fl_set_object_shortcut(menu_toc, "", 1);
140 fl_set_object_shortcut(menu_refs, "", 1);
141 fl_set_object_shortcut(menu_layout, "", 1);
142 fl_set_object_shortcut(menu_math, "", 1);
143 fl_set_object_shortcut(menu_insert, "", 1);
144 fl_set_object_shortcut(menu_options, "", 1);
145 fl_set_object_shortcut(menu_options2, "", 1);
146 fl_set_object_shortcut(menu_buffer, "", 1);
147 fl_set_object_shortcut(menu_help, "", 1);
148 fl_set_object_shortcut(menu_help2, "", 1);
154 BufferView * Menus::currentView()
156 return _view->view();
160 void Menus::showMenus()
162 fl_hide_object(menu_grp2);
163 fl_show_object(menu_grp1);
167 void Menus::hideMenus()
169 fl_hide_object(menu_grp1);
170 fl_show_object(menu_grp2);
174 void Menus::openByName(string const & menuName)
175 /* Opens the visible menu of given name, or simply does nothing
176 when the name is not known. NOTE THE EXTREMELY STUPID
177 IMPLEMENTATION! :-) There are probably hundred ways to do
178 this better, for instance, by scanning the menu objects and
179 testing for the given name. I leave this as an exercise for an
180 experienced GG (GUI Guy/Girl). RVDK_PATCH_5. */
182 if (menu_file->visible) {
183 if (menuName == _("File"))
184 ShowFileMenu(menu_file, 0);
185 else if (menuName == _("Edit"))
186 ShowEditMenu(menu_edit, 0);
187 else if (menuName == _("TOC"))
188 ShowTocMenu(menu_toc, 0);
189 else if (menuName == _("Refs"))
190 ShowRefsMenu(menu_refs, 0);
191 else if (menuName == _("Layout"))
192 ShowLayoutMenu(menu_layout, 0);
193 else if (menuName == _("Insert"))
194 ShowInsertMenu(menu_insert, 0);
195 else if (menuName == _("Math"))
196 ShowMathMenu(menu_math, 0);
197 else if (menuName == _("Options"))
198 ShowOptionsMenu(menu_options, 0);
199 else if (menuName == _("Documents"))
200 ShowBufferMenu(menu_buffer, 0);
201 else if (menuName == _("Help"))
202 ShowHelpMenu(menu_help, 0);
203 else lyxerr << "The menu '" << menuName
204 << "' is not available." << endl;
206 if (menuName == _("File"))
207 ShowFileMenu2(menu_file2, 0);
208 else if (menuName == _("Options"))
209 ShowOptionsMenu(menu_options2, 0);
210 else if (menuName == _("Help"))
211 ShowHelpMenu(menu_help2, 0);
212 else lyxerr << "The menu '" << menuName
213 << "' is not available." << endl;
218 void Menus::create_menus(int air)
220 FL_FORM * form = _view->getForm();
222 // Here I'd really like to see code like:
226 const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
227 const int mheight = 30;
228 const int mbheight= 22;
229 // where to place the menubar?
230 const int yloc = (mheight - mbheight)/2; //air + bw;
231 const int mbadd = 20; // menu button add (to width)
235 obj = fl_add_frame(FL_UP_FRAME, 0, 0, form->w, mheight, "");
236 fl_set_object_resize(obj, FL_RESIZE_ALL);
237 fl_set_object_gravity(obj, NorthWestGravity, NorthEastGravity);
239 menu_grp1 = fl_bgn_group();
243 fl_add_button(FL_TOUCH_BUTTON,
245 fl_get_string_width(FL_BOLD_STYLE,
248 strlen(_("File"))) + mbadd,
249 mbheight, _("File"));
250 moffset += obj->w + air;
251 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
252 fl_set_object_callback(obj, C_Menus_ShowFileMenu, 0);
257 fl_add_button(FL_TOUCH_BUTTON,
259 fl_get_string_width(FL_BOLD_STYLE,
262 strlen(_("Edit"))) + mbadd,
263 mbheight, _("Edit"));
264 moffset += obj->w + air;
265 fl_set_object_shortcut(obj, scex(_("MB|#E")), 1);
266 fl_set_object_callback(obj, C_Menus_ShowEditMenu, 0);
271 fl_add_button(FL_TOUCH_BUTTON,
273 fl_get_string_width(FL_BOLD_STYLE,
276 strlen(_("TOC"))) + mbadd,
278 moffset += obj->w + air;
279 fl_set_object_shortcut(obj, scex(_("MB|#T")), 1);
280 fl_set_object_callback(obj, C_Menus_ShowTocMenu, 0);
285 fl_add_button(FL_TOUCH_BUTTON,
287 fl_get_string_width(FL_BOLD_STYLE,
290 strlen(_("Refs"))) + mbadd,
291 mbheight, _("Refs"));
292 moffset += obj->w + air;
293 fl_set_object_shortcut(obj, scex(_("MB|#R")), 1);
294 fl_set_object_callback(obj, C_Menus_ShowRefsMenu, 0);
297 // Layout menu button
299 fl_add_button(FL_TOUCH_BUTTON,
301 fl_get_string_width(FL_BOLD_STYLE,
304 strlen(_("Layout"))) + mbadd,
305 mbheight, _("Layout"));
306 moffset += obj->w + air;
307 fl_set_object_shortcut(obj, scex(_("MB|#L")), 1);
308 fl_set_object_callback(obj, C_Menus_ShowLayoutMenu, 0);
311 // Insert menu button button
313 fl_add_button(FL_TOUCH_BUTTON,
315 fl_get_string_width(FL_BOLD_STYLE,
318 strlen(_("Insert"))) + mbadd,
319 mbheight, _("Insert"));
320 moffset += obj->w + air;
321 fl_set_object_shortcut(obj, scex(_("MB|#I")), 1);
322 fl_set_object_callback(obj, C_Menus_ShowInsertMenu, 0);
327 fl_add_button(FL_TOUCH_BUTTON,
329 fl_get_string_width(FL_BOLD_STYLE,
332 strlen(_("Math"))) + mbadd,
333 mbheight, _("Math"));
334 moffset += obj->w + air;
335 fl_set_object_shortcut(obj, scex(_("MB|#M")), 1);
336 fl_set_object_callback(obj, C_Menus_ShowMathMenu, 0);
339 // Options menu button
341 fl_add_button(FL_TOUCH_BUTTON,
343 fl_get_string_width(FL_BOLD_STYLE,
346 strlen(_("Options"))) + mbadd,
347 mbheight, _("Options"));
348 moffset += obj->w + air;
349 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
350 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
353 // Documents menu button
355 fl_add_button(FL_TOUCH_BUTTON,
357 fl_get_string_width(FL_BOLD_STYLE,
360 strlen(_("Documents"))) + mbadd,
361 mbheight, _("Documents"));
362 moffset += obj->w + air;
363 fl_set_object_shortcut(obj, scex(_("MB|#D")), 1);
364 fl_set_object_callback(obj, C_Menus_ShowBufferMenu, 0);
369 fl_add_button(FL_TOUCH_BUTTON,
371 fl_get_string_width(FL_BOLD_STYLE,
374 strlen(_("Help"))) + mbadd,
375 mbheight, _("Help"));
376 moffset += obj->w + air;
377 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
378 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
383 // Set the menu buttons atrributes.
384 // Due to a bug in xforms we cant do this only an the group.
385 obj = menu_grp1->next;
387 fl_set_object_boxtype(obj, FL_FLAT_BOX);
388 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
389 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
390 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
391 fl_set_object_resize(obj, FL_RESIZE_ALL);
392 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
394 } while (obj != 0 && obj->objclass != FL_END_GROUP);
398 menu_grp2 = fl_bgn_group();
402 fl_add_button(FL_TOUCH_BUTTON,
404 fl_get_string_width(FL_BOLD_STYLE,
407 strlen(_("File"))) + mbadd,
408 mbheight, _("File"));
409 moffset += obj->w + air;
410 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
411 fl_set_object_callback(obj, C_Menus_ShowFileMenu2, 0);
414 // Options menu button
415 menu_options2 = obj =
416 fl_add_button(FL_TOUCH_BUTTON,
418 fl_get_string_width(FL_BOLD_STYLE,
421 strlen(_("Options"))) +mbadd,
422 mbheight, _("Options"));
423 moffset += obj->w + air;
424 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
425 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
430 fl_add_button(FL_TOUCH_BUTTON,
432 fl_get_string_width(FL_BOLD_STYLE,
435 strlen(_("Help"))) + mbadd,
436 mbheight, _("Help"));
437 moffset += obj->w + air;
438 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
439 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
444 // Set the menu buttons atrributes.
445 // Due to a bug in xforms we cant do this only an the group.
446 obj = menu_grp2->next;
448 fl_set_object_boxtype(obj, FL_FLAT_BOX);
449 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
450 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
451 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
452 fl_set_object_resize(obj, FL_RESIZE_ALL);
453 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
455 } while (obj != 0 && obj->objclass != FL_END_GROUP);
460 // Here comes all the menu callbacks.
463 void Menus::ShowFileMenu(FL_OBJECT * ob, long)
465 Menus * men = static_cast<Menus*>(ob->u_vdata);
467 // Regarding the pseudo-menu-button:
468 // ok, ok this is a hack. It would be better to use the menus of the
469 // xforms 0.8 library. but then all popups have to be defined all the
470 // time, code rewriting would be necessary and contex-depending menus
471 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
472 // course it would be more proper (and little faster). So if anybody
473 // likes to do the cleanup, just do it. Matthias
475 // set the pseudo menu-button
476 fl_set_object_boxtype(ob, FL_UP_BOX);
477 fl_set_button(ob, 0);
478 fl_redraw_object(ob);
480 Buffer * tmpbuffer = men->_view->buffer();
481 LyXFunc * tmpfunc = men->_view->getLyXFunc();
483 bool LinuxDoc = tmpbuffer->isLinuxDoc();
484 bool DocBook = tmpbuffer->isDocBook();
485 bool Literate = tmpbuffer->isLiterate();
489 int SubFileImport = fl_defpup(FL_ObjWin(ob),
492 "|Ascii Text as Lines...%x31"
493 "|Ascii Text as Paragraphs%x32"
497 fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
498 fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
499 fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
500 fl_setpup_shortcut(SubFileImport, 33, scex(_("FIM|Nn#n#N")));
501 fl_setpup_shortcut(SubFileImport, 34, scex(_("FIM|Dd#d#D")));
505 int SubFileExport = fl_defpup(FL_ObjWin(ob),
507 vector<pair<string,string> > formats =
508 Exporter::GetExportableFormats(tmpbuffer);
509 for (vector<pair<string,string> >::size_type i = 0;
510 i < formats.size(); ++i) {
511 string entry = _("as ")
513 + "%x" + tostr(1000+i);
514 fl_addtopup(SubFileExport, entry.c_str());
517 // remember to make this handle linuxdoc too.
518 // and now docbook also.
520 int SubFileExport = 0;
521 if (!LinuxDoc && !DocBook)
522 SubFileExport= fl_defpup(FL_ObjWin(ob),
526 "|as PostScript...%x42"
527 "|as Ascii Text...%x43"
531 SubFileExport= fl_defpup(FL_ObjWin(ob),
533 "|as LinuxDoc...%x40"
535 "|as PostScript...%x42"
536 "|as Ascii Text...%x43"
539 SubFileExport= fl_defpup(FL_ObjWin(ob),
543 "|as PostScript...%x42"
544 "|as Ascii Text...%x43"
546 fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
547 fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
548 fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
549 fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
550 fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
552 if (!LinuxDoc && !DocBook) {
553 fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
557 int FileMenu = fl_defpup(FL_ObjWin(ob),
559 "|New from template..."
573 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
574 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
575 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
576 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Cc#c#C")));
577 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|Ss#s#S")));
578 fl_setpup_shortcut(FileMenu, 6, scex(_("FM|Aa#a#A")));
579 fl_setpup_shortcut(FileMenu, 7, scex(_("FM|Rr#r#R")));
580 fl_setpup_shortcut(FileMenu, 8, scex(_("FM|dD#d#D")));
581 fl_setpup_shortcut(FileMenu, 9, scex(_("FM|wW#w#W")));
582 fl_setpup_shortcut(FileMenu, 10, scex(_("FM|vV#v#V")));
583 fl_setpup_shortcut(FileMenu, 11, scex(_("FM|Uu#u#U")));
584 fl_setpup_shortcut(FileMenu, 12, scex(_("FM|Bb#b#B")));
585 fl_setpup_shortcut(FileMenu, 13, scex(_("FM|Pp#p#P")));
586 fl_setpup_shortcut(FileMenu, 14, scex(_("FM|Ff#f#F")));
588 // These commands are disabled when the corresponding programs
589 // are not installed. I simply grey them out, since I do not
590 // want to change their number (JMarc)
591 bool hasLaTeX = lyxrc.latex_command != "none";
593 if (!hasLaTeX || lyxrc.view_dvi_command == "none")
594 fl_setpup_mode(FileMenu, 8, FL_PUP_GREY);
596 if (!hasLaTeX || lyxrc.view_ps_command == "none")
597 fl_setpup_mode(FileMenu, 9, FL_PUP_GREY);
600 fl_setpup_mode(FileMenu, 10, FL_PUP_GREY);
601 fl_setpup_mode(FileMenu, 11, FL_PUP_GREY);
604 if (lyxrc.literate_command == "none" || ! Literate)
605 fl_setpup_mode(FileMenu, 12, FL_PUP_GREY);
607 if (!hasLaTeX || lyxrc.print_command == "none")
608 fl_setpup_mode(FileMenu, 13, FL_PUP_GREY);
610 if (!hasLaTeX || lyxrc.fax_command == "none")
611 fl_setpup_mode(FileMenu, 14, FL_PUP_GREY);
613 bool hasReLyX = lyxrc.relyx_command != "none";
615 // Disable import LaTeX and Noweb
616 fl_setpup_mode(SubFileImport, 30, FL_PUP_GREY);
617 fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
620 if ( lyxrc.linuxdoc_to_lyx_command == "none")
621 fl_setpup_mode(SubFileImport, 34, FL_PUP_GREY);
625 // Disable export dvi and export postscript
626 fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
627 fl_setpup_mode(SubFileExport, 42, FL_PUP_GREY);
630 if ((!LinuxDoc && !DocBook && lyxrc.html_command == "none") ||
631 ( LinuxDoc && lyxrc.linuxdoc_to_html_command == "none") ||
632 ( DocBook && lyxrc.docbook_to_html_command == "none")) {
633 // Disable export HTML
634 fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
638 // xgettext:no-c-format
639 fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
640 // xgettext:no-c-format
641 fl_addtopup(FileMenu, _("|Export%m%l"), SubFileExport);
642 // xgettext:no-c-format
643 fl_addtopup(FileMenu, _("|Exit%l"));
644 fl_setpup_shortcut(FileMenu, 15, scex(_("FM|Ii#i#I")));
645 fl_setpup_shortcut(FileMenu, 16, scex(_("FM|Ee#e#E")));
646 fl_setpup_shortcut(FileMenu, 17, scex(_("FM|xX#x#X")));
648 // make the lastfiles menu
650 for (LastFiles::const_iterator cit = lastfiles->begin();
651 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
652 string tmp = tostr(ii);
653 string tmp2 = tmp + "#" + tmp;
654 tmp += ". " + MakeDisplayPath((*cit), 30);
655 fl_addtopup(FileMenu, tmp.c_str());
656 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
661 men->_view->getForm()->x + ob->x,
662 men->_view->getForm()->y + ob->y + ob->h + 10);
663 int choice = fl_dopup(FileMenu);
666 // set the pseudo menu-button back
667 fl_set_object_boxtype(ob, FL_FLAT_BOX);
668 fl_redraw_object(ob);
671 case -1: case 0: // we won't do anything
673 case 1: tmpfunc->Dispatch(LFUN_MENUNEW); break;
674 case 2: tmpfunc->Dispatch(LFUN_MENUNEWTMPLT); break;
675 case 3: tmpfunc->Dispatch(LFUN_MENUOPEN); break;
676 case 4: tmpfunc->Dispatch(LFUN_CLOSEBUFFER); break;
677 case 5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
678 case 6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
679 case 7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
681 case 8: tmpfunc->Dispatch(LFUN_PREVIEW, "dvi"); break;
682 case 9: tmpfunc->Dispatch(LFUN_PREVIEW, "ps"); break;
683 case 10: tmpfunc->Dispatch(LFUN_UPDATE, "dvi"); break;
684 case 11: tmpfunc->Dispatch(LFUN_UPDATE, "ps"); break;
686 case 8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
687 case 9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
688 case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
689 case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
691 case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
692 case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
693 case 14: tmpfunc->Dispatch(LFUN_FAX); break;
694 case 15: // import menu
695 case 30: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
697 case 31: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
699 case 32: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
701 case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
703 case 34: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
707 tmpfunc->Dispatch(LFUN_QUIT);
711 tmpfunc->Dispatch(LFUN_EXPORT,
712 formats[choice-1000].first.c_str());
716 .loadLyXFile((*lastfiles)[choice - 18]));
719 case 16: // export menu
721 if (!LinuxDoc && !DocBook)
722 tmpfunc->Dispatch(LFUN_EXPORT, "latex");
724 tmpfunc->Dispatch(LFUN_EXPORT, "linuxdoc");
726 tmpfunc->Dispatch(LFUN_EXPORT, "docbook");
728 case 41: tmpfunc->Dispatch(LFUN_EXPORT, "dvi");
730 case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
732 case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
734 case 44: tmpfunc->Dispatch(LFUN_EXPORT, "html");
736 case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
738 case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
740 case 18: // The first item with lastfiles.
744 .loadLyXFile((*lastfiles)[choice - 18]));
748 fl_freepup(SubFileImport);
749 fl_freepup(SubFileExport);
750 fl_freepup(FileMenu);
752 AllowInput(men->currentView());
756 void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
758 Menus * men = static_cast<Menus*>(ob->u_vdata);
760 // Regarding the pseudo-menu-button:
761 // ok, ok this is a hack. It would be better to use the menus of the
762 // xforms 0.8 library. but then all popups have to be defined all the
763 // time, code rewriting would be necessary and contex-depending menus
764 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
765 // course it would be more proper (and little faster). So if anybody
766 // likes to do the cleanup, just do it. Matthias
768 // set the pseudo menu-button
769 fl_set_object_boxtype(ob, FL_UP_BOX);
770 fl_set_button(ob, 0);
771 fl_redraw_object(ob);
773 LyXFunc * tmpfunc = men->_view->getLyXFunc();
777 int SubFileImport = fl_defpup(FL_ObjWin(ob),
780 "|Ascii Text as Lines...%x16"
781 "|Ascii Text as Paragraphs...%x17"
783 "|LinuxDoc...%x19"));
785 fl_setpup_shortcut(SubFileImport, 15, scex(_("FIM|Ll#l#L")));
786 fl_setpup_shortcut(SubFileImport, 16, scex(_("FIM|Aa#a#A")));
787 fl_setpup_shortcut(SubFileImport, 17, scex(_("FIM|Pp#p#P")));
788 fl_setpup_shortcut(SubFileImport, 18, scex(_("FIM|Nn#n#N")));
789 fl_setpup_shortcut(SubFileImport, 19, scex(_("FIM|Dd#d#D")));
791 bool hasReLyX = lyxrc.relyx_command != "none";
793 // Disable import LaTeX and Noweb
794 fl_setpup_mode(SubFileImport, 15, FL_PUP_GREY);
795 fl_setpup_mode(SubFileImport, 18, FL_PUP_GREY);
798 if ( lyxrc.linuxdoc_to_lyx_command == "none")
799 fl_setpup_mode(SubFileImport, 19, FL_PUP_GREY);
801 // This can be done cleaner later.
802 int FileMenu = fl_defpup(FL_ObjWin(ob),
804 "|New from template..."
807 "|Exit%l"), SubFileImport);
809 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
810 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
811 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
812 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Ii#i#I")));
813 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|xX#x#X")));
815 // make the lastfiles menu
817 for (LastFiles::const_iterator cit = lastfiles->begin();
818 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
819 string tmp = tostr(ii);
820 string tmp2 = tmp + "#" + tmp;
821 tmp += ". " + MakeDisplayPath((*cit), 30);
822 fl_addtopup(FileMenu, tmp.c_str());
823 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
828 men->_view->getForm()->x + ob->x,
829 men->_view->getForm()->y + ob->y + ob->h + 10);
830 int choice = fl_dopup(FileMenu);
833 // set the pseudo menu-button back
834 fl_set_object_boxtype(ob, FL_FLAT_BOX);
835 fl_redraw_object(ob);
838 case -1: case 0: // we won't do anything
841 tmpfunc->Dispatch(LFUN_MENUNEW);
844 tmpfunc->Dispatch(LFUN_MENUNEWTMPLT);
847 tmpfunc->Dispatch(LFUN_MENUOPEN);
849 case 4: // import menu
850 case 15: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
852 case 16: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
854 case 17: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
856 case 18: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
858 case 19: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
861 tmpfunc->Dispatch(LFUN_QUIT);
864 case 6: // The first item with lastfiles.
868 .loadLyXFile((*lastfiles)[choice - 6]));
872 fl_freepup(SubFileImport);
873 fl_freepup(FileMenu);
874 AllowInput(men->currentView());
879 void Menus::ShowEditMenu(FL_OBJECT * ob, long)
881 Menus * men = static_cast<Menus*>(ob->u_vdata);
883 // set the pseudo menu-button
884 fl_set_object_boxtype(ob, FL_UP_BOX);
885 fl_set_button(ob, 0);
886 fl_redraw_object(ob);
888 Buffer * tmpbuffer = men->_view->buffer();
889 LyXFunc * tmpfunc = men->_view->getLyXFunc();
891 // Floats & Insets submenu
892 int SubEditFloats= fl_defpup(FL_ObjWin(ob),
893 _("Floats & Insets%t"
896 "|Open All Footnotes/Margin Notes%x23"
897 "|Close All Footnotes/Margin Notes%x24"
898 "|Open All Figures/Tables%x25"
899 "|Close All Figures/Tables%x26%l"
900 "|Remove all Error Boxes%x27"));
902 fl_setpup_shortcut(SubEditFloats, 21, scex(_("EMF|Oo#o#O")));
903 fl_setpup_shortcut(SubEditFloats, 22, scex(_("EMF|Mm#m#M")));
904 fl_setpup_shortcut(SubEditFloats, 23, scex(_("EMF|Aa#a#A")));
905 fl_setpup_shortcut(SubEditFloats, 24, scex(_("EMF|Cc#c#C")));
906 fl_setpup_shortcut(SubEditFloats, 25, scex(_("EMF|Ff#f#F")));
907 fl_setpup_shortcut(SubEditFloats, 26, scex(_("EMF|Tt#t#T")));
908 fl_setpup_shortcut(SubEditFloats, 27, scex(_("EMF|Rr#r#R")));
911 int SubEditTable = fl_newpup(FL_ObjWin(ob));
913 if (men->currentView()->available() &&
914 men->currentView()->text->cursor.par()->table &&
915 !tmpbuffer->isReadonly()){
916 LyXTable * table = men->currentView()->text->cursor.par()->table;
918 fl_addtopup(SubEditTable, _("Table%t"));
920 if (table->IsMultiColumn(men->currentView()->text->
921 NumberOfCell(men->currentView()->
924 text->cursor.pos())))
925 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
927 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
928 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
930 if (table->TopLine(men->currentView()->text->
931 NumberOfCell(men->currentView()->
933 men->currentView()->text->
935 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
937 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
938 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
940 if (table->BottomLine(men->currentView()->text->
941 NumberOfCell(men->currentView()->
944 text->cursor.pos())))
945 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
947 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
948 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
950 if (table->LeftLine(men->currentView()->text->
951 NumberOfCell(men->currentView()->
954 text->cursor.pos())))
955 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
957 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
958 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
960 if (table->RightLine(men->currentView()->text->
961 NumberOfCell(men->currentView()->
964 text->cursor.pos())))
965 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
967 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
968 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
971 table->GetAlignment(men->currentView()->text->
972 NumberOfCell(men->currentView()->
975 text->cursor.pos()));
976 if (align == LYX_ALIGN_LEFT)
977 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
979 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
980 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
982 if (align == LYX_ALIGN_RIGHT)
983 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
985 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
986 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
988 if (align == LYX_ALIGN_CENTER)
989 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
991 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
992 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
994 // xgettext:no-c-format
995 fl_addtopup(SubEditTable, _("|Append Row%x32"));
996 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
997 // xgettext:no-c-format
998 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
999 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
1000 // xgettext:no-c-format
1001 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
1002 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
1003 // xgettext:no-c-format
1004 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
1005 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
1006 // xgettext:no-c-format
1007 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
1008 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
1011 if (men->currentView()->the_locking_inset &&
1012 (men->currentView()->the_locking_inset->LyxCode() ==
1013 Inset::TABULAR_CODE) &&
1014 !tmpbuffer->isReadonly()) {
1015 InsetTabular * inset = static_cast<InsetTabular *>(men->currentView()->the_locking_inset);
1016 LyXTabular * table = inset->tabular;
1018 fl_addtopup(SubEditTable, _("Table%t"));
1020 if (table->IsMultiColumn(inset->GetActCell()))
1021 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
1023 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
1024 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
1026 if (table->TopLine(inset->GetActCell()))
1027 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
1029 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
1030 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
1032 if (table->BottomLine(inset->GetActCell()))
1033 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
1035 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
1036 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
1038 if (table->LeftLine(inset->GetActCell()))
1039 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
1041 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
1042 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
1044 if (table->RightLine(inset->GetActCell()))
1045 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
1047 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
1048 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
1050 int align = table->GetAlignment(inset->GetActCell());
1051 if (align == LYX_ALIGN_LEFT)
1052 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
1054 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
1055 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
1057 if (align == LYX_ALIGN_RIGHT)
1058 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
1060 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
1061 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
1063 if (align == LYX_ALIGN_CENTER)
1064 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
1066 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
1067 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
1069 // xgettext:no-c-format
1070 fl_addtopup(SubEditTable, _("|Append Row%x32"));
1071 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
1072 // xgettext:no-c-format
1073 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
1074 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
1075 // xgettext:no-c-format
1076 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
1077 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
1078 // xgettext:no-c-format
1079 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
1080 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
1081 // xgettext:no-c-format
1082 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
1083 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
1085 fl_addtopup(SubEditTable, _("Table%t"));
1086 // xgettext:no-c-format
1087 fl_addtopup(SubEditTable, _("|Insert table%x31"));
1088 fl_setpup_shortcut(SubEditTable, 31, scex(_("EMT|Ii#i#I")));
1091 int SubVersionControl = fl_newpup(FL_ObjWin(ob));
1092 fl_addtopup(SubVersionControl, _("Version Control%t"));
1093 if (tmpbuffer->lyxvc.inUse()) {
1094 // xgettext:no-c-format
1095 fl_addtopup(SubVersionControl, _("|Register%d%x51"));
1096 if (tmpbuffer->isReadonly()) {
1097 // signifies that the file is not checked out
1098 // xgettext:no-c-format
1099 fl_addtopup(SubVersionControl, _("|Check In Changes%d%x52"));
1100 // xgettext:no-c-format
1101 fl_addtopup(SubVersionControl, _("|Check Out for Edit%x53"));
1103 // signifies that the file is checked out
1104 // xgettext:no-c-format
1105 fl_addtopup(SubVersionControl, _("|Check In Changes%x52"));
1106 // xgettext:no-c-format
1107 fl_addtopup(SubVersionControl, _("|Check Out for Edit%d%x53"));
1109 // xgettext:no-c-format
1110 fl_addtopup(SubVersionControl, _("|Revert to last version%x54"));
1111 // xgettext:no-c-format
1112 fl_addtopup(SubVersionControl, _("|Undo last check in%x55"));
1113 // xgettext:no-c-format
1114 fl_addtopup(SubVersionControl, _("|Show History%x56"));
1116 // xgettext:no-c-format
1117 fl_addtopup(SubVersionControl, _("|Register%x51"));
1119 // the shortcuts are not good.
1120 fl_setpup_shortcut(SubVersionControl, 51, scex(_("EMV|Rr#r#R")));
1121 fl_setpup_shortcut(SubVersionControl, 52, scex(_("EMV|Ii#i#I")));
1122 fl_setpup_shortcut(SubVersionControl, 53, scex(_("EMV|Oo#o#O")));
1123 fl_setpup_shortcut(SubVersionControl, 54, scex(_("EMV|lL#l#l")));
1124 fl_setpup_shortcut(SubVersionControl, 55, scex(_("EMV|Uu#u#U")));
1125 fl_setpup_shortcut(SubVersionControl, 56, scex(_("EMV|Hh#h#H")));
1127 int EditMenu= fl_defpup(FL_ObjWin(ob),
1133 "|Find & Replace..."
1136 "|Floats & Insets%m"
1140 "|Table of Contents..."
1141 "|List of Figures..."
1142 "|List of Tables..."
1143 "|List of Algorithms...%l"
1144 "|Version Control%m%l"
1145 "|View LaTeX log file%l"
1146 "|Paste Primary Selection as Lines"
1147 "|Paste Primary Selection as Paragraphs"),
1148 SubEditFloats, SubEditTable, SubVersionControl);
1150 fl_setpup_shortcut(EditMenu, 1, scex(_("EM|Uu#u#U")));
1151 fl_setpup_shortcut(EditMenu, 2, scex(_("EM|Rr#r#R")));
1152 fl_setpup_shortcut(EditMenu, 3, scex(_("EM|Cc#c#C")));
1153 fl_setpup_shortcut(EditMenu, 4, scex(_("EM|oO#o#O")));
1154 fl_setpup_shortcut(EditMenu, 5, scex(_("EM|Pp#p#P")));
1155 fl_setpup_shortcut(EditMenu, 6, scex(_("EM|Ff#f#F")));
1156 fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
1157 fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
1158 fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
1159 //fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
1160 fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
1161 fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
1162 fl_setpup_shortcut(EditMenu, 13, scex(_("EM|Tt#t#T")));
1163 //fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Ff#f#F")));
1164 //fl_setpup_shortcut(EditMenu, 15, scex(_("EM|bB#b#B")));
1165 //fl_setpup_shortcut(EditMenu, 16, scex(_("EM|mM#m#M")));
1166 fl_setpup_shortcut(EditMenu, 17, scex(_("EM|Vv#v#V")));
1167 fl_setpup_shortcut(EditMenu, 18, scex(_("EM|wW#w#W")));
1168 fl_setpup_shortcut(EditMenu, 19, scex(_("EM|Ll#l#L")));
1169 fl_setpup_shortcut(EditMenu, 20, scex(_("EM|gG#g#G")));
1171 // disable unavailable entries.
1172 if(tmpbuffer->undostack.empty())
1173 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1174 if(tmpbuffer->redostack.empty())
1175 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1176 if(lyxrc.isp_command == "none")
1177 fl_setpup_mode(EditMenu, 11, FL_PUP_GREY);
1178 if(lyxrc.chktex_command == "none")
1179 fl_setpup_mode(EditMenu, 12, FL_PUP_GREY);
1181 if (tmpbuffer->isReadonly()) {
1182 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1183 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1184 fl_setpup_mode(EditMenu, 3, FL_PUP_GREY);
1185 fl_setpup_mode(EditMenu, 5, FL_PUP_GREY);
1186 fl_setpup_mode(EditMenu, 19, FL_PUP_GREY);
1187 fl_setpup_mode(EditMenu, 20, FL_PUP_GREY);
1190 fl_setpup_position(men->_view->getForm()->x + ob->x,
1191 men->_view->getForm()->y + ob->y +
1193 int choice = fl_dopup(EditMenu);
1196 // set the pseudo menu-button back
1197 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1198 fl_redraw_object(ob);
1201 case 1: tmpfunc->Dispatch(LFUN_UNDO); break;
1202 case 2: tmpfunc->Dispatch(LFUN_REDO); break;
1203 case 3: tmpfunc->Dispatch(LFUN_CUT); break;
1204 case 4: tmpfunc->Dispatch(LFUN_COPY); break;
1205 case 5: tmpfunc->Dispatch(LFUN_PASTE); break;
1206 case 6: tmpfunc->Dispatch(LFUN_MENUSEARCH); break;
1207 case 7: tmpfunc->Dispatch(LFUN_GOTOERROR); break;
1208 case 8: tmpfunc->Dispatch(LFUN_GOTONOTE); break;
1209 case 9: // floats & insets
1213 case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
1214 case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
1215 case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
1216 case 14: tmpfunc->Dispatch(LFUN_LOFVIEW); break;
1217 case 15: tmpfunc->Dispatch(LFUN_LOTVIEW); break;
1218 case 16: tmpfunc->Dispatch(LFUN_LOAVIEW); break;
1219 case 17: // version control
1221 case 18: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
1222 case 19: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
1223 case 20: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
1226 // floats & insets sub-menu
1227 case 21: men->currentView()->toggleFloat(); break;
1228 case 22: tmpfunc->Dispatch(LFUN_MELT); break;
1229 case 23: men->currentView()->allFloats(1, 0); break;
1230 case 24: men->currentView()->allFloats(0, 0); break;
1231 case 25: men->currentView()->allFloats(1, 1); break;
1232 case 26: men->currentView()->allFloats(0, 1); break;
1233 case 27: tmpfunc->Dispatch(LFUN_REMOVEERRORS); break;
1235 case 31: tmpfunc->Dispatch(LFUN_DIALOG_TABULAR_INSERT); break;
1236 // this is really temporary. We need new function in keybind.C
1237 // These should set the minibuffer, too.
1238 case 32: case 33: case 34:
1239 case 35: case 36: case 37:
1240 case 38: case 39: case 40:
1241 case 41: case 42: case 43:
1243 if (men->currentView()->available()) {
1244 men->currentView()->hideCursor();
1245 if (!men->currentView()->text->selection){
1246 men->currentView()->beforeChange();
1247 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR);
1249 if (men->currentView()->the_locking_inset &&
1250 (men->currentView()->the_locking_inset->LyxCode()
1251 == Inset::TABULAR_CODE)) {
1252 InsetTabular * inset =
1253 static_cast<InsetTabular *>
1254 (men->currentView()->the_locking_inset);
1255 inset->TabularFeatures(men->currentView(), choice - 32);
1259 men->currentView()->text->
1260 TableFeatures(men->currentView(), choice - 32);
1261 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
1266 // version control sub-menu
1267 case 51: // register
1268 tmpfunc->Dispatch(LFUN_VC_REGISTER);
1270 case 52: // check in
1271 tmpfunc->Dispatch(LFUN_VC_CHECKIN);
1273 case 53: // check out
1274 tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
1276 case 54: // revert to last
1277 tmpfunc->Dispatch(LFUN_VC_REVERT);
1279 case 55: // undo last
1280 tmpfunc->Dispatch(LFUN_VC_UNDO);
1282 case 56: // show history
1283 tmpfunc->Dispatch(LFUN_VC_HISTORY);
1287 fl_freepup(EditMenu);
1288 fl_freepup(SubEditFloats);
1289 fl_freepup(SubEditTable);
1290 fl_freepup(SubVersionControl);
1293 vector<int>::size_type const max_number_of_menus = 32;
1294 unsigned int const max_number_of_items = 25;
1296 string Limit_string_length(string const & str) {
1297 string::size_type const max_item_length = 45;
1299 if (str.size() > max_item_length)
1300 return str.substr(0, max_item_length-3) + "...";
1305 void Add_to_toc_menu(vector<Buffer::TocItem> const & toclist,
1306 unsigned int from, unsigned int to, int depth,
1307 int menu, vector<int> & menus, FL_OBJECT * ob)
1309 if (to - from <= max_number_of_items) {
1310 for (unsigned int i = from; i < to; ++i) {
1311 string entry(4 * max(0, toclist[i].depth - depth),' ');
1312 entry += toclist[i].str;
1313 entry = Limit_string_length(entry);
1314 entry += "%x" + tostr(i + 1);
1315 fl_addtopup(menu, entry.c_str());
1318 unsigned int pos = from;
1319 unsigned int count = 0;
1322 if (count > max_number_of_items) {
1323 fl_addtopup(menu, ". . .%d");
1326 unsigned int new_pos = pos+1;
1327 while (new_pos < to &&
1328 toclist[new_pos].depth > depth)
1331 string entry(4 * max(0, toclist[pos].depth - depth), ' ');
1332 entry += toclist[pos].str;
1333 entry = Limit_string_length(entry);
1335 if (new_pos == pos + 1) {
1337 entry += tostr(pos + 1);
1338 fl_addtopup(menu, entry.c_str());
1339 } else if (menus.size() < max_number_of_menus) {
1340 int menu2 = fl_newpup(FL_ObjWin(ob));
1341 menus.push_back(menu2);
1342 Add_to_toc_menu(toclist, pos, new_pos,
1343 depth + 1, menu2, menus,ob);
1345 fl_addtopup(menu, entry.c_str(), menu2);
1348 fl_addtopup(menu, entry.c_str());
1355 int const BIG_NUM = 1048576;
1357 void Menus::ShowTocMenu(FL_OBJECT * ob, long)
1359 Menus * men = static_cast<Menus*>(ob->u_vdata);
1362 // set the pseudo menu-button
1363 fl_set_object_boxtype(ob, FL_UP_BOX);
1364 fl_set_button(ob, 0);
1365 fl_redraw_object(ob);
1367 int TocMenu = fl_newpup(FL_ObjWin(ob));
1368 menus.push_back(TocMenu);
1369 vector<vector<Buffer::TocItem> > toclist =
1370 men->currentView()->buffer()->getTocList();
1372 //xgettext:no-c-format
1373 static char const * MenuNames[3] = { N_("List of Figures%m"),
1374 //xgettext:no-c-format
1375 N_("List of Tables%m"),
1376 //xgettext:no-c-format
1377 N_("List of Algorithms%m") };
1379 int max_nonempty = 0;
1380 for (int j = 1; j <= 3; ++j)
1381 if (!toclist[j].empty())
1384 for (int j = 1; j <= 3; ++j)
1385 if (!toclist[j].empty()) {
1386 int menu2 = fl_newpup(FL_ObjWin(ob));
1387 menus.push_back(menu2);
1388 for (unsigned int i = 0; i < toclist[j].size(); ++i) {
1389 if (i > max_number_of_items) {
1390 fl_addtopup(menu2, ". . .%d");
1393 string entry = Limit_string_length(toclist[j][i].str);
1394 entry += "%x" + tostr(i+1+j*BIG_NUM);
1395 fl_addtopup(menu2, entry.c_str());
1397 if (j == max_nonempty) {
1398 string tmp = _(MenuNames[j-1]);
1400 fl_addtopup(TocMenu, tmp.c_str(), menu2);
1402 fl_addtopup(TocMenu, _(MenuNames[j-1]), menu2);
1405 Add_to_toc_menu(toclist[0], 0, toclist[0].size(), 0,
1406 TocMenu, menus, ob);
1409 men->_view->getForm()->x + ob->x,
1410 men->_view->getForm()->y + ob->y + ob->h + 10);
1411 int choice = fl_dopup(TocMenu);
1414 // set the pseudo menu-button back
1415 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1416 fl_redraw_object(ob);
1418 men->_view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
1419 else if (choice > 0) {
1420 int type = choice / BIG_NUM;
1421 int num = (choice % BIG_NUM) - 1;
1422 BufferView *bv = men->currentView();
1424 bv->text->SetCursor(bv, toclist[type][num].par, 0);
1425 bv->text->sel_cursor = bv->text->cursor;
1426 bv->update(BufferView::SELECT|BufferView::FITCUR);
1428 for (unsigned int i = 0; i < menus.size(); ++i)
1429 fl_freepup(menus[i]);
1432 void Add_to_refs_menu(vector<string> const & label_list, int offset,
1433 int menu, vector<int> & menus, FL_OBJECT * ob)
1435 typedef vector<string>::size_type size_type;
1436 size_type const max_number_of_items = 25;
1437 size_type const max_number_of_items2 = 20;
1438 string::size_type const max_item_length = 40;
1439 string::size_type const max_item_length2 = 20;
1441 if (label_list.size() <= max_number_of_items)
1442 for (size_type i = 0; i < label_list.size(); ++i) {
1443 string entry = label_list[i];
1444 if (entry.size() > max_item_length)
1445 entry = entry.substr(0, max_item_length-1) + "$";
1446 entry += "%x" + tostr(i+offset);
1447 fl_addtopup(menu, entry.c_str());
1450 size_type count = 0;
1451 for (size_type i = 0; i < label_list.size();
1452 i += max_number_of_items2) {
1454 if (count > max_number_of_items) {
1455 fl_addtopup(menu, ". . .%d");
1458 size_type j = min(label_list.size(),
1459 i+max_number_of_items2);
1462 if (label_list[i].size() > max_item_length2)
1463 entry += label_list[i].substr(0, max_item_length2-1) + "$";
1465 entry += label_list[i];
1467 if (label_list[j-1].size() > max_item_length2)
1468 entry += label_list[j-1].substr(0, max_item_length2-1) + "$";
1470 entry += label_list[j-1];
1472 if (menus.size() < max_number_of_menus) {
1473 int menu2 = fl_newpup(FL_ObjWin(ob));
1474 menus.push_back(menu2);
1475 for (size_type k = i; k < j; ++k) {
1476 string entry2 = label_list[k];
1477 if (entry2.size() > max_item_length)
1478 entry2 = entry2.substr(0, max_item_length-1) + "$";
1479 entry2 += "%x" + tostr(k+offset);
1480 fl_addtopup(menu2, entry2.c_str());
1483 fl_addtopup(menu, entry.c_str(), menu2);
1486 fl_addtopup(menu, entry.c_str());
1492 void Menus::ShowRefsMenu(FL_OBJECT * ob, long)
1496 Menus * men = static_cast<Menus*>(ob->u_vdata);
1498 // set the pseudo menu-button
1499 fl_set_object_boxtype(ob, FL_UP_BOX);
1500 fl_set_button(ob, 0);
1501 fl_redraw_object(ob);
1503 int RefsMenu = fl_newpup(FL_ObjWin(ob));
1504 menus.push_back(RefsMenu);
1505 Buffer * buffer = men->currentView()->buffer();
1506 vector<string> label_list = buffer->getLabelList();
1507 sort(label_list.begin(), label_list.end());
1509 //xgettext:no-c-format
1510 static char const * MenuNames[6] = { N_("Insert Reference%m"),
1511 //xgettext:no-c-format
1512 N_("Insert Page Number%m"),
1513 //xgettext:no-c-format
1514 N_("Insert vref%m"),
1515 //xgettext:no-c-format
1516 N_("Insert vpageref%m"),
1517 //xgettext:no-c-format
1518 N_("Insert Pretty Ref%m"),
1519 //xgettext:no-c-format
1520 N_("Goto Reference%m") };
1522 for (int j = 0; j < 6; ++j) {
1523 if (menus.size() < max_number_of_menus) {
1524 int menu2 = fl_newpup(FL_ObjWin(ob));
1525 menus.push_back(menu2);
1526 Add_to_refs_menu(label_list, (j+1)*BIG_NUM, menu2, menus, ob);
1527 fl_addtopup(RefsMenu, _(MenuNames[j]), menu2);
1529 string tmp = _(MenuNames[j]);
1531 fl_addtopup(RefsMenu, tmp.c_str());
1534 fl_addtopup(RefsMenu, _("Go Back"));
1536 bool empty = label_list.empty();
1537 bool sgml = buffer->isSGML();
1538 bool readonly = buffer->isReadonly();
1541 fl_setpup_mode(RefsMenu, 6, FL_PUP_GREY);
1542 if (empty || readonly) {
1543 fl_setpup_mode(RefsMenu, 1, FL_PUP_GREY);
1544 fl_setpup_mode(RefsMenu, 2, FL_PUP_GREY);
1546 if (empty || readonly || sgml) {
1547 fl_setpup_mode(RefsMenu, 3, FL_PUP_GREY);
1548 fl_setpup_mode(RefsMenu, 4, FL_PUP_GREY);
1549 fl_setpup_mode(RefsMenu, 5, FL_PUP_GREY);
1551 if (men->currentView()->NoSavedPositions())
1552 fl_setpup_mode(RefsMenu, 7, FL_PUP_GREY);
1555 men->_view->getForm()->x + ob->x,
1556 men->_view->getForm()->y + ob->y + ob->h + 10);
1557 int choice = fl_dopup(RefsMenu);
1560 // set the pseudo menu-button back
1561 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1562 fl_redraw_object(ob);
1565 men->_view->getLyXFunc()->Dispatch(LFUN_REF_BACK);
1566 else if (choice >= BIG_NUM) {
1567 int type = (choice / BIG_NUM) - 1;
1568 int num = choice % BIG_NUM;
1570 men->_view->getLyXFunc()->Dispatch(LFUN_REF_GOTO,
1571 label_list[num].c_str());
1573 static string const cmdname[5]
1574 = { "ref", "pageref", "vref", "vpageref", "prettyref"};
1575 InsetCommandParams p( cmdname[type] );
1576 p.setContents( label_list[num] );
1577 men->currentView()->insertInset(new InsetRef(p));
1581 for (unsigned int i = 0; i < menus.size(); ++i)
1582 fl_freepup(menus[i]);
1586 void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
1588 Menus * men = static_cast<Menus*>(ob->u_vdata);
1590 if (!men->currentView()->available())
1593 // set the pseudo menu-button
1594 fl_set_object_boxtype(ob, FL_UP_BOX);
1595 fl_set_button(ob, 0);
1596 fl_redraw_object(ob);
1598 Buffer * tmpbuffer = men->_view->buffer();
1599 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1601 int LayoutMenu = fl_newpup(FL_ObjWin(ob));
1602 fl_addtopup(LayoutMenu, _("Character..."
1608 "|Emphasize Style%b"
1612 "|Change Environment Depth"
1613 "|LaTeX Preamble..."
1614 "|Start of Appendix%l"
1615 "|Save layout as default"));
1616 fl_setpup_shortcut(LayoutMenu, 1, scex(_("LM|Cc#c#C")));
1617 fl_setpup_shortcut(LayoutMenu, 2, scex(_("LM|Pp#p#P")));
1618 fl_setpup_shortcut(LayoutMenu, 3, scex(_("LM|Dd#d#D")));
1619 fl_setpup_shortcut(LayoutMenu, 4, scex(_("LM|aA#a#A")));
1620 fl_setpup_shortcut(LayoutMenu, 5, scex(_("LM|eE#e#E")));
1621 fl_setpup_shortcut(LayoutMenu, 6, scex(_("LM|Qq#q#Q")));
1622 fl_setpup_shortcut(LayoutMenu, 7, scex(_("LM|mM#m#M")));
1623 fl_setpup_shortcut(LayoutMenu, 8, scex(_("LM|Nn#n#N")));
1624 fl_setpup_shortcut(LayoutMenu, 9, scex(_("LM|Bb#b#B")));
1625 fl_setpup_shortcut(LayoutMenu, 10, scex(_("LM|Tt#t#T")));
1626 fl_setpup_shortcut(LayoutMenu, 11, scex(_("LM|vV#v#V")));
1627 fl_setpup_shortcut(LayoutMenu, 12, scex(_("LM|Ll#l#L")));
1628 fl_setpup_shortcut(LayoutMenu, 13, scex(_("LM|xX#x#X")));
1629 fl_setpup_shortcut(LayoutMenu, 14, scex(_("LM|Ss#s#S")));
1631 // Set values of checkboxes according to font
1632 LyXFont font = men->currentView()->text->real_current_font;
1633 if (font.emph() == LyXFont::ON)
1634 fl_setpup_mode(LayoutMenu, 7, FL_PUP_CHECK);
1635 if (font.noun() == LyXFont::ON)
1636 fl_setpup_mode(LayoutMenu, 8, FL_PUP_CHECK);
1637 if (font.series() == LyXFont::BOLD_SERIES)
1638 fl_setpup_mode(LayoutMenu, 9, FL_PUP_CHECK);
1639 if (font.latex() == LyXFont::ON)
1640 fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
1642 // Grey out unavailable entries
1644 if (!men->currentView()->text->cursor.par()->table)
1645 fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
1647 if (tmpbuffer->isReadonly()) {
1648 fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
1649 fl_setpup_mode(LayoutMenu, 6, FL_PUP_GREY);
1650 fl_setpup_mode(LayoutMenu, 11, FL_PUP_GREY);
1654 men->_view->getForm()->x + ob->x,
1655 men->_view->getForm()->y + ob->y + ob->h + 10);
1656 int choice = fl_dopup(LayoutMenu);
1659 // set the pseudo menu-button back
1660 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1661 fl_redraw_object(ob);
1664 case 1: tmpfunc->Dispatch(LFUN_LAYOUT_CHARACTER); break;
1665 case 2: tmpfunc->Dispatch(LFUN_LAYOUT_PARAGRAPH); break;
1666 case 3: tmpfunc->Dispatch(LFUN_LAYOUT_DOCUMENT); break;
1667 case 4: tmpfunc->Dispatch(LFUN_LAYOUT_PAPER); break;
1668 case 5: tmpfunc->Dispatch(LFUN_LAYOUT_TABLE, "true"); break;
1669 case 6: tmpfunc->Dispatch(LFUN_LAYOUT_QUOTES); break;
1670 case 7: tmpfunc->Dispatch(LFUN_EMPH); break;
1671 case 8: tmpfunc->Dispatch(LFUN_NOUN); break;
1672 case 9: tmpfunc->Dispatch(LFUN_BOLD); break;
1673 case 10: tmpfunc->Dispatch(LFUN_TEX); break;
1674 case 11: tmpfunc->Dispatch(LFUN_DEPTH_PLUS); break;
1675 case 12: tmpfunc->Dispatch(LFUN_LAYOUT_PREAMBLE); break;
1676 case 13: tmpfunc->Dispatch(LFUN_APPENDIX); break;
1677 case 14: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;
1679 fl_freepup(LayoutMenu);
1683 void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
1685 Menus * men = static_cast<Menus*>(ob->u_vdata);
1687 // set the pseudo menu-button
1688 fl_set_object_boxtype(ob, FL_UP_BOX);
1689 fl_set_button(ob, 0);
1690 fl_redraw_object(ob);
1692 Buffer * tmpbuffer = men->_view->buffer();
1693 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1695 int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
1696 _("Import ASCII file%t"
1698 "|As Paragraphs%x42"));
1700 fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
1701 fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
1703 int SubInsertTableList= fl_defpup(FL_ObjWin(ob),
1705 "|Table of Contents%x21"
1706 "|List of Figures%x22"
1707 "|List of Tables%x23"
1708 "|List of Algorithms%x24"
1710 "|BibTeX Reference%x26"));
1712 fl_setpup_shortcut(SubInsertTableList, 21, scex(_("IMT|Cc#c#C")));
1713 fl_setpup_shortcut(SubInsertTableList, 22, scex(_("IMT|Ff#f#F")));
1714 fl_setpup_shortcut(SubInsertTableList, 23, scex(_("IMT|Tt#t#T")));
1715 fl_setpup_shortcut(SubInsertTableList, 24, scex(_("IMT|Aa#a#A")));
1716 fl_setpup_shortcut(SubInsertTableList, 25, scex(_("IMT|Ii#i#I")));
1717 fl_setpup_shortcut(SubInsertTableList, 26, scex(_("IMT|Bb#b#B")));
1719 int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
1723 "|Wide Figure Float%x73"
1724 "|Wide Table Float%l%x74"
1725 "|Algorithm Float%x75"));
1727 fl_setpup_shortcut(SubInsertFloatList, 71, scex(_("IMF|gG#g#G")));
1728 fl_setpup_shortcut(SubInsertFloatList, 72, scex(_("IMF|Tt#t#T")));
1729 fl_setpup_shortcut(SubInsertFloatList, 73, scex(_("IMF|Ww#w#W")));
1730 fl_setpup_shortcut(SubInsertFloatList, 74, scex(_("IMF|iI#i#I")));
1731 fl_setpup_shortcut(SubInsertFloatList, 75, scex(_("IMF|Aa#a#A")));
1733 int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
1734 _("Special Character%t"
1736 "|Hyphenation Point%x32"
1737 "|Protected Blank%x33"
1739 "|Ellipsis (...)%x35"
1740 "|End of sentence period%x36"
1741 "|Ordinary Quote (\")%x37"
1742 "|Menu Separator %x38"));
1744 fl_setpup_shortcut(SubInsertSpecial, 31, scex(_("IMS|Hh#h#H")));
1745 fl_setpup_shortcut(SubInsertSpecial, 32, scex(_("IMS|Pp#p#P")));
1746 fl_setpup_shortcut(SubInsertSpecial, 33, scex(_("IMS|Bb#b#B")));
1747 fl_setpup_shortcut(SubInsertSpecial, 34, scex(_("IMS|Ll#l#L")));
1748 fl_setpup_shortcut(SubInsertSpecial, 35, scex(_("IMS|iI#i#I")));
1749 fl_setpup_shortcut(SubInsertSpecial, 36, scex(_("IMS|Ee#e#E")));
1750 fl_setpup_shortcut(SubInsertSpecial, 37, scex(_("IMS|Qq#q#Q")));
1751 fl_setpup_shortcut(SubInsertSpecial, 38, scex(_("IMS|Mm#m#M")));
1753 int InsertMenu = fl_defpup(FL_ObjWin(ob),
1757 "|Import ASCII File%m"
1758 "|Insert LyX File..."
1759 "|Insert external material...%l"
1764 "|Special Character%m%l"
1767 "|Cross-Reference..."
1768 "|Citation Reference..."
1770 "|Index entry of last word"),
1776 fl_setpup_shortcut(InsertMenu, 1, scex(_("IM|gG#g#G")));
1777 fl_setpup_shortcut(InsertMenu, 2, scex(_("IM|bB#b#B")));
1778 fl_setpup_shortcut(InsertMenu, 3, scex(_("IM|cC#c#C")));
1779 fl_setpup_shortcut(InsertMenu, 4, scex(_("IM|Aa#a#A")));
1780 fl_setpup_shortcut(InsertMenu, 5, scex(_("IM|Xx#x#X")));
1781 fl_setpup_shortcut(InsertMenu, 6, scex(_("IM|Ee#e#E")));
1782 fl_setpup_shortcut(InsertMenu, 7, scex(_("IM|Ff#f#F")));
1783 fl_setpup_shortcut(InsertMenu, 8, scex(_("IM|Mm#m#M")));
1784 fl_setpup_shortcut(InsertMenu, 9, scex(_("IM|oO#o#O")));
1785 fl_setpup_shortcut(InsertMenu, 10, scex(_("IM|Tt#t#T")));
1786 fl_setpup_shortcut(InsertMenu, 11, scex(_("IM|Ss#s#S")));
1787 fl_setpup_shortcut(InsertMenu, 12, scex(_("IM|Nn#n#N")));
1788 fl_setpup_shortcut(InsertMenu, 13, scex(_("IM|Ll#l#L")));
1789 fl_setpup_shortcut(InsertMenu, 14, scex(_("IM|rR#r#R")));
1790 fl_setpup_shortcut(InsertMenu, 15, scex(_("IM|iI#i#I")));
1791 fl_setpup_shortcut(InsertMenu, 16, scex(_("IM|dD#d#D")));
1792 fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|wW#w#W")));
1794 fl_addtopup(InsertMenu, _("|URL..."));
1795 fl_setpup_shortcut(InsertMenu, 18, scex(_("IM|Uu#u#U")));
1797 if (tmpbuffer->isReadonly()) {
1798 for (int ii = 1; ii <= 17; ++ii)
1799 fl_setpup_mode(InsertMenu, ii, FL_PUP_GREY);
1800 fl_setpup_mode(InsertMenu, 18, FL_PUP_GREY);
1804 men->_view->getForm()->x + ob->x,
1805 men->_view->getForm()->y + ob->y + ob->h + 10);
1807 int choice = fl_dopup(InsertMenu);
1810 // set the pseudo menu-button back
1811 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1812 fl_redraw_object(ob);
1814 if (men->currentView()->available()){
1815 men->currentView()->hideCursor();
1817 case 1: tmpfunc->Dispatch(LFUN_FIGURE); break;
1818 case 2: tmpfunc->Dispatch(LFUN_DIALOG_TABULAR_INSERT); break;
1819 case 3: tmpfunc->Dispatch(LFUN_CHILDINSERT); break;
1820 case 4: // Insert ASCII file submenu
1822 case 5: tmpfunc->Dispatch(LFUN_FILE_INSERT); break;
1823 case 41: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "line"); break;
1824 case 42: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "paragraph"); break;
1828 case 6: tmpfunc->Dispatch(LFUN_INSET_EXTERNAL); break;
1832 tmpfunc->Dispatch(LFUN_FOOTMELT); break;
1834 tmpfunc->Dispatch(LFUN_INSET_FOOTNOTE);
1839 tmpfunc->Dispatch(LFUN_MARGINMELT); break;
1841 tmpfunc->Dispatch(LFUN_INSET_MARGINAL);
1845 case 9: // Float sub-menu
1848 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure");
1851 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "figure");
1856 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table");
1859 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "table");
1864 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig");
1867 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "figure");
1872 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab");
1875 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "table");
1880 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm");
1883 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "algorithm");
1886 case 10: // Table/List submenu
1888 case 21: tmpfunc->Dispatch(LFUN_TOC_INSERT); break;
1889 case 22: tmpfunc->Dispatch(LFUN_LOF_INSERT); break;
1890 case 23: tmpfunc->Dispatch(LFUN_LOT_INSERT); break;
1891 case 24: tmpfunc->Dispatch(LFUN_LOA_INSERT); break;
1892 case 25: tmpfunc->Dispatch(LFUN_INDEX_PRINT); break;
1893 case 26: tmpfunc->Dispatch(LFUN_INSERT_BIBTEX); break;
1895 case 11: // Special Character submenu
1897 case 31: tmpfunc->Dispatch(LFUN_HFILL); break;
1898 case 32: tmpfunc->Dispatch(LFUN_HYPHENATION); break;
1899 case 33: tmpfunc->Dispatch(LFUN_PROTECTEDSPACE); break;
1900 case 34: tmpfunc->Dispatch(LFUN_BREAKLINE); break;
1901 case 35: tmpfunc->Dispatch(LFUN_LDOTS); break;
1902 case 36: tmpfunc->Dispatch(LFUN_END_OF_SENTENCE); break;
1903 case 37: tmpfunc->Dispatch(LFUN_QUOTE); break;
1904 case 38: tmpfunc->Dispatch(LFUN_MENU_SEPARATOR); break;
1906 case 12: tmpfunc->Dispatch(LFUN_INSERT_NOTE); break;
1907 case 13: tmpfunc->Dispatch(LFUN_INSERT_LABEL); break;
1908 case 14: tmpfunc->Dispatch(LFUN_REF_INSERT); break;
1909 case 15: tmpfunc->Dispatch(LFUN_CITATION_CREATE); break;
1910 case 16: tmpfunc->Dispatch(LFUN_INDEX_CREATE); break;
1911 case 17: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break;
1912 case 18: tmpfunc->Dispatch(LFUN_URL); break;
1915 fl_freepup(InsertMenu);
1916 fl_freepup(SubInsertAscii);
1917 fl_freepup(SubInsertTableList);
1918 fl_freepup(SubInsertFloatList);
1919 fl_freepup(SubInsertSpecial);
1923 void Menus::ShowMathMenu(FL_OBJECT * ob, long)
1925 extern void math_insert_symbol(char const * s);
1927 Menus * men = static_cast<Menus*>(ob->u_vdata);
1929 // set the pseudo menu-button
1930 fl_set_object_boxtype(ob, FL_UP_BOX);
1931 fl_set_button(ob, 0);
1932 fl_redraw_object(ob);
1934 Buffer * tmpbuffer = men->_view->buffer();
1935 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1937 int MathMenu = fl_defpup(FL_ObjWin(ob),
1948 fl_setpup_shortcut(MathMenu, 1, scex(_("MM|Ff#f#F")));
1949 fl_setpup_shortcut(MathMenu, 2, scex(_("MM|Ss#s#S")));
1950 fl_setpup_shortcut(MathMenu, 3, scex(_("MM|Ee#e#E")));
1951 fl_setpup_shortcut(MathMenu, 4, scex(_("MM|xX#x#X")));
1952 fl_setpup_shortcut(MathMenu, 5, scex(_("MM|uU#u#U")));
1953 fl_setpup_shortcut(MathMenu, 6, scex(_("MM|Ii#i#I")));
1954 fl_setpup_shortcut(MathMenu, 7, scex(_("MM|Mm#m#M")));
1955 fl_setpup_shortcut(MathMenu, 8, scex(_("MM|Dd#d#D")));
1956 fl_setpup_shortcut(MathMenu, 9, scex(_("MM|Pp#p#P")));
1958 if (tmpbuffer->isReadonly())
1959 for (int ii = 1; ii <= 9; ++ii)
1960 fl_setpup_mode(MathMenu, ii, FL_PUP_GREY);
1964 men->_view->getForm()->x + ob->x,
1965 men->_view->getForm()->y + ob->y + ob->h + 10);
1966 int choice = fl_dopup(MathMenu);
1969 // set the pseudo menu-button back
1970 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1971 fl_redraw_object(ob);
1973 if (men->currentView()->available()) {
1976 tmpfunc->Dispatch(LFUN_INSERT_MATH, "frac");
1979 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
1981 case 3: /* Exponent */
1982 tmpfunc->Dispatch(LFUN_INSERT_MATH, "^");
1985 tmpfunc->Dispatch(LFUN_INSERT_MATH, "_");
1988 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sum");
1991 tmpfunc->Dispatch(LFUN_INSERT_MATH, "int");
1994 tmpfunc->Dispatch(LFUN_MATH_MODE);
1997 tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
2000 tmpfunc->Dispatch(LFUN_MATH_PANEL);
2003 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR);
2005 fl_freepup(MathMenu);
2009 void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
2011 Menus * men = static_cast<Menus*>(ob->u_vdata);
2013 // set the pseudo menu-button
2014 fl_set_object_boxtype(ob, FL_UP_BOX);
2015 fl_set_button(ob, 0);
2016 fl_redraw_object(ob);
2018 //Buffer *tmpbuffer = men->_view->currentBuffer();
2019 LyXFunc * tmpfunc = men->_view->getLyXFunc();
2021 int OptionsMenu = fl_defpup(FL_ObjWin(ob),
2022 _("|Spellchecker Options..."
2027 fl_setpup_shortcut(OptionsMenu, 1, scex(_("OM|Ss#s#S")));
2028 fl_setpup_shortcut(OptionsMenu, 2, scex(_("OM|Kk#k#K")));
2029 fl_setpup_shortcut(OptionsMenu, 3, scex(_("OM|Rr#r#R")));
2030 fl_setpup_shortcut(OptionsMenu, 4, scex(_("OM|Pp#p#P")));
2032 if(lyxrc.isp_command == "none")
2033 fl_setpup_mode(OptionsMenu, 2, FL_PUP_GREY);
2036 men->_view->getForm()->x + ob->x,
2037 men->_view->getForm()->y + ob->y + ob->h + 10);
2038 int choice = fl_dopup(OptionsMenu);
2041 // set the pseudo menu-button back
2042 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2043 fl_redraw_object(ob);
2045 case 1: SpellCheckerOptions(); break;
2046 case 2: men->_view->getIntl()->MenuKeymap(); break;
2047 case 3: tmpfunc->Dispatch(LFUN_RECONFIGURE); break;
2048 case 4: men->_view->getDialogs()->showPreferences(); break;
2051 fl_freepup(OptionsMenu);
2055 void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
2057 Menus * men = static_cast<Menus*>(ob->u_vdata);
2059 // set the pseudo menu-button
2060 fl_set_object_boxtype(ob, FL_UP_BOX);
2061 fl_set_button(ob, 0);
2062 fl_redraw_object(ob);
2064 int BufferMenu = fl_newpup(FL_ObjWin(ob));
2065 vector<string> namevec = bufferlist.getFileNames();
2066 if (namevec.size() != 0) {
2067 for (vector<string>::const_iterator cit = namevec.begin();
2068 cit != namevec.end(); ++cit) {
2069 string relbuf = MakeDisplayPath((*cit), 30);
2070 fl_addtopup(BufferMenu, relbuf.c_str());
2073 fl_addtopup(BufferMenu, _("No Documents Open!%t"));
2077 men->_view->getForm()->x + ob->x,
2078 men->_view->getForm()->y + ob->y + ob->h + 10);
2079 int choice = fl_dopup(BufferMenu);
2082 // set the pseudo menu-button back
2083 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2084 fl_redraw_object(ob);
2085 if (choice > 0) men->handleBufferMenu(choice - 1);
2087 fl_freepup(BufferMenu);
2092 char const * doc_files [] = {"Intro", "Tutorial",
2093 "UserGuide", "Extended",
2094 "Customization", "Reference",
2096 "BUGS", "LyXConfig"};
2098 void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
2100 Menus * men = static_cast<Menus*>(ob->u_vdata);
2101 LyXFunc * tmpfunc = men->_view->getLyXFunc();
2103 // set the pseudo menu-button
2104 fl_set_object_boxtype(ob, FL_UP_BOX);
2105 fl_set_button(ob, 0);
2106 fl_redraw_object(ob);
2108 int HelpMenu = fl_defpup(FL_ObjWin(ob),
2112 "|Extended Features"
2116 "|Table of Contents"
2118 "|LaTeX Configuration%l"
2119 "|Copyright and Warranty..."
2123 fl_setpup_shortcut(HelpMenu, 1, scex(_("HM|Ii#I#i")));
2124 fl_setpup_shortcut(HelpMenu, 2, scex(_("HM|Tt#T#t")));
2125 fl_setpup_shortcut(HelpMenu, 3, scex(_("HM|Uu#U#u")));
2126 fl_setpup_shortcut(HelpMenu, 4, scex(_("HM|xX#x#X")));
2127 fl_setpup_shortcut(HelpMenu, 5, scex(_("HM|Cc#C#c")));
2128 fl_setpup_shortcut(HelpMenu, 6, scex(_("HM|Rr#R#r")));
2129 fl_setpup_shortcut(HelpMenu, 7, scex(_("HM|Ff#F#f")));
2130 fl_setpup_shortcut(HelpMenu, 8, scex(_("HM|aA#a#A")));
2131 fl_setpup_shortcut(HelpMenu, 9, scex(_("HM|Kk#K#k")));
2132 fl_setpup_shortcut(HelpMenu, 10, scex(_("HM|Ll#L#l")));
2133 fl_setpup_shortcut(HelpMenu, 11, scex(_("HM|oO#o#O")));
2134 fl_setpup_shortcut(HelpMenu, 12, scex(_("HM|eE#e#E")));
2135 fl_setpup_shortcut(HelpMenu, 13, scex(_("HM|Vv#v#V")));
2138 men->_view->getForm()->x + ob->x,
2139 men->_view->getForm()->y + ob->y + ob->h + 10);
2140 int choice = fl_dopup(HelpMenu);
2143 // set the pseudo menu-button back
2144 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2145 fl_redraw_object(ob);
2148 case 1: case 2: case 3: case 4: case 5:
2149 case 6: case 7: case 8: case 9: case 10:
2150 ProhibitInput(men->currentView());
2151 men->MenuDocu(doc_files[choice - 1]);
2152 AllowInput(men->currentView());
2154 case 11: tmpfunc->Dispatch(LFUN_HELP_COPYRIGHT); break;
2155 case 12: ShowCredits(); break;
2157 ProhibitInput(men->currentView());
2158 fl_show_message((string(_("LyX Version ")) + LYX_VERSION
2159 + _(" of ") + LYX_RELEASE).c_str(),
2160 (_("Library directory: ")
2161 + MakeDisplayPath(system_lyxdir)).c_str(),
2162 (_("User directory: ")
2163 + MakeDisplayPath(user_lyxdir)).c_str());
2164 AllowInput(men->currentView());
2167 fl_freepup(HelpMenu);
2171 void Menus::MenuDocu(string const & docname)
2173 string fname = i18nLibFileSearch("doc", docname, "lyx");
2174 if (fname.empty()) {
2175 WriteAlert(_("Error!"),
2176 _("Could not find requested Documentation file"),
2180 _view->getMiniBuffer()->Set(_("Opening help file"),
2181 MakeDisplayPath(fname), "...");
2182 currentView()->buffer(bufferlist.loadLyXFile(fname, false));
2184 if (docname == "Reference")
2185 _view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
2189 void Menus::handleBufferMenu(int choice)
2191 currentView()->buffer(bufferlist.getBuffer(choice));