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 FD_form_screen * fd_form_screen;
64 extern BufferList bufferlist;
66 // I would really prefere to see most or all of these 'extern's disappear.
67 // Their commands should be called through LyXFunc (IMO). (Lgb)
69 extern void MenuLayoutSave();
70 extern void ShowCredits();
71 extern void show_symbols_form(LyXFunc *);
72 extern void LaTeXOptions(BufferView *);
74 // A bunch of wrappers
76 extern "C" void C_Menus_ShowFileMenu(FL_OBJECT * ob, long data)
78 Menus::ShowFileMenu(ob, data);
81 extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT * ob, long data)
83 Menus::ShowFileMenu2(ob, data);
86 extern "C" void C_Menus_ShowEditMenu(FL_OBJECT * ob, long data)
88 Menus::ShowEditMenu(ob, data);
91 extern "C" void C_Menus_ShowTocMenu(FL_OBJECT * ob, long data)
93 Menus::ShowTocMenu(ob, data);
96 extern "C" void C_Menus_ShowRefsMenu(FL_OBJECT * ob, long data)
98 Menus::ShowRefsMenu(ob, data);
101 extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT * ob, long data)
103 Menus::ShowLayoutMenu(ob, data);
106 extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT * ob, long data)
108 Menus::ShowInsertMenu(ob, data);
111 extern "C" void C_Menus_ShowMathMenu(FL_OBJECT * ob, long data)
113 Menus::ShowMathMenu(ob, data);
116 extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT * ob, long data)
118 Menus::ShowOptionsMenu(ob, data);
121 extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT * ob, long data)
123 Menus::ShowBufferMenu(ob, data);
126 extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT * ob, long data)
128 Menus::ShowHelpMenu(ob, data);
132 Menus::Menus(LyXView * view, int air)
136 // deactivate the menu accelerators
137 fl_set_object_shortcut(menu_file, "", 1);
138 fl_set_object_shortcut(menu_file2, "", 1);
139 fl_set_object_shortcut(menu_edit, "", 1);
140 fl_set_object_shortcut(menu_toc, "", 1);
141 fl_set_object_shortcut(menu_refs, "", 1);
142 fl_set_object_shortcut(menu_layout, "", 1);
143 fl_set_object_shortcut(menu_math, "", 1);
144 fl_set_object_shortcut(menu_insert, "", 1);
145 fl_set_object_shortcut(menu_options, "", 1);
146 fl_set_object_shortcut(menu_options2, "", 1);
147 fl_set_object_shortcut(menu_buffer, "", 1);
148 fl_set_object_shortcut(menu_help, "", 1);
149 fl_set_object_shortcut(menu_help2, "", 1);
155 BufferView * Menus::currentView()
157 return _view->view();
161 void Menus::showMenus()
163 fl_hide_object(menu_grp2);
164 fl_show_object(menu_grp1);
168 void Menus::hideMenus()
170 fl_hide_object(menu_grp1);
171 fl_show_object(menu_grp2);
175 void Menus::openByName(string const & menuName)
176 /* Opens the visible menu of given name, or simply does nothing
177 when the name is not known. NOTE THE EXTREMELY STUPID
178 IMPLEMENTATION! :-) There are probably hundred ways to do
179 this better, for instance, by scanning the menu objects and
180 testing for the given name. I leave this as an exercise for an
181 experienced GG (GUI Guy/Girl). RVDK_PATCH_5. */
183 if (menu_file->visible) {
184 if (menuName == _("File"))
185 ShowFileMenu(menu_file, 0);
186 else if (menuName == _("Edit"))
187 ShowEditMenu(menu_edit, 0);
188 else if (menuName == _("TOC"))
189 ShowTocMenu(menu_toc, 0);
190 else if (menuName == _("Refs"))
191 ShowRefsMenu(menu_refs, 0);
192 else if (menuName == _("Layout"))
193 ShowLayoutMenu(menu_layout, 0);
194 else if (menuName == _("Insert"))
195 ShowInsertMenu(menu_insert, 0);
196 else if (menuName == _("Math"))
197 ShowMathMenu(menu_math, 0);
198 else if (menuName == _("Options"))
199 ShowOptionsMenu(menu_options, 0);
200 else if (menuName == _("Documents"))
201 ShowBufferMenu(menu_buffer, 0);
202 else if (menuName == _("Help"))
203 ShowHelpMenu(menu_help, 0);
204 else lyxerr << "The menu '" << menuName
205 << "' is not available." << endl;
207 if (menuName == _("File"))
208 ShowFileMenu2(menu_file2, 0);
209 else if (menuName == _("Options"))
210 ShowOptionsMenu(menu_options2, 0);
211 else if (menuName == _("Help"))
212 ShowHelpMenu(menu_help2, 0);
213 else lyxerr << "The menu '" << menuName
214 << "' is not available." << endl;
219 void Menus::create_menus(int air)
221 FL_FORM * form = _view->getForm();
223 // Here I'd really like to see code like:
227 const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
228 const int mheight = 30;
229 const int mbheight= 22;
230 // where to place the menubar?
231 const int yloc = (mheight - mbheight)/2; //air + bw;
232 const int mbadd = 20; // menu button add (to width)
236 obj = fl_add_frame(FL_UP_FRAME, 0, 0, form->w, mheight, "");
237 fl_set_object_resize(obj, FL_RESIZE_ALL);
238 fl_set_object_gravity(obj, NorthWestGravity, NorthEastGravity);
240 menu_grp1 = fl_bgn_group();
244 fl_add_button(FL_TOUCH_BUTTON,
246 fl_get_string_width(FL_BOLD_STYLE,
249 strlen(_("File"))) + mbadd,
250 mbheight, _("File"));
251 moffset += obj->w + air;
252 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
253 fl_set_object_callback(obj, C_Menus_ShowFileMenu, 0);
258 fl_add_button(FL_TOUCH_BUTTON,
260 fl_get_string_width(FL_BOLD_STYLE,
263 strlen(_("Edit"))) + mbadd,
264 mbheight, _("Edit"));
265 moffset += obj->w + air;
266 fl_set_object_shortcut(obj, scex(_("MB|#E")), 1);
267 fl_set_object_callback(obj, C_Menus_ShowEditMenu, 0);
272 fl_add_button(FL_TOUCH_BUTTON,
274 fl_get_string_width(FL_BOLD_STYLE,
277 strlen(_("TOC"))) + mbadd,
279 moffset += obj->w + air;
280 fl_set_object_shortcut(obj, scex(_("MB|#T")), 1);
281 fl_set_object_callback(obj, C_Menus_ShowTocMenu, 0);
286 fl_add_button(FL_TOUCH_BUTTON,
288 fl_get_string_width(FL_BOLD_STYLE,
291 strlen(_("Refs"))) + mbadd,
292 mbheight, _("Refs"));
293 moffset += obj->w + air;
294 fl_set_object_shortcut(obj, scex(_("MB|#R")), 1);
295 fl_set_object_callback(obj, C_Menus_ShowRefsMenu, 0);
298 // Layout menu button
300 fl_add_button(FL_TOUCH_BUTTON,
302 fl_get_string_width(FL_BOLD_STYLE,
305 strlen(_("Layout"))) + mbadd,
306 mbheight, _("Layout"));
307 moffset += obj->w + air;
308 fl_set_object_shortcut(obj, scex(_("MB|#L")), 1);
309 fl_set_object_callback(obj, C_Menus_ShowLayoutMenu, 0);
312 // Insert menu button button
314 fl_add_button(FL_TOUCH_BUTTON,
316 fl_get_string_width(FL_BOLD_STYLE,
319 strlen(_("Insert"))) + mbadd,
320 mbheight, _("Insert"));
321 moffset += obj->w + air;
322 fl_set_object_shortcut(obj, scex(_("MB|#I")), 1);
323 fl_set_object_callback(obj, C_Menus_ShowInsertMenu, 0);
328 fl_add_button(FL_TOUCH_BUTTON,
330 fl_get_string_width(FL_BOLD_STYLE,
333 strlen(_("Math"))) + mbadd,
334 mbheight, _("Math"));
335 moffset += obj->w + air;
336 fl_set_object_shortcut(obj, scex(_("MB|#M")), 1);
337 fl_set_object_callback(obj, C_Menus_ShowMathMenu, 0);
340 // Options menu button
342 fl_add_button(FL_TOUCH_BUTTON,
344 fl_get_string_width(FL_BOLD_STYLE,
347 strlen(_("Options"))) + mbadd,
348 mbheight, _("Options"));
349 moffset += obj->w + air;
350 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
351 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
354 // Documents menu button
356 fl_add_button(FL_TOUCH_BUTTON,
358 fl_get_string_width(FL_BOLD_STYLE,
361 strlen(_("Documents"))) + mbadd,
362 mbheight, _("Documents"));
363 moffset += obj->w + air;
364 fl_set_object_shortcut(obj, scex(_("MB|#D")), 1);
365 fl_set_object_callback(obj, C_Menus_ShowBufferMenu, 0);
370 fl_add_button(FL_TOUCH_BUTTON,
372 fl_get_string_width(FL_BOLD_STYLE,
375 strlen(_("Help"))) + mbadd,
376 mbheight, _("Help"));
377 moffset += obj->w + air;
378 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
379 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
384 // Set the menu buttons atrributes.
385 // Due to a bug in xforms we cant do this only an the group.
386 obj = menu_grp1->next;
388 fl_set_object_boxtype(obj, FL_FLAT_BOX);
389 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
390 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
391 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
392 fl_set_object_resize(obj, FL_RESIZE_ALL);
393 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
395 } while (obj != 0 && obj->objclass != FL_END_GROUP);
399 menu_grp2 = fl_bgn_group();
403 fl_add_button(FL_TOUCH_BUTTON,
405 fl_get_string_width(FL_BOLD_STYLE,
408 strlen(_("File"))) + mbadd,
409 mbheight, _("File"));
410 moffset += obj->w + air;
411 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
412 fl_set_object_callback(obj, C_Menus_ShowFileMenu2, 0);
415 // Options menu button
416 menu_options2 = obj =
417 fl_add_button(FL_TOUCH_BUTTON,
419 fl_get_string_width(FL_BOLD_STYLE,
422 strlen(_("Options"))) +mbadd,
423 mbheight, _("Options"));
424 moffset += obj->w + air;
425 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
426 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
431 fl_add_button(FL_TOUCH_BUTTON,
433 fl_get_string_width(FL_BOLD_STYLE,
436 strlen(_("Help"))) + mbadd,
437 mbheight, _("Help"));
438 moffset += obj->w + air;
439 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
440 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
445 // Set the menu buttons atrributes.
446 // Due to a bug in xforms we cant do this only an the group.
447 obj = menu_grp2->next;
449 fl_set_object_boxtype(obj, FL_FLAT_BOX);
450 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
451 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
452 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
453 fl_set_object_resize(obj, FL_RESIZE_ALL);
454 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
456 } while (obj != 0 && obj->objclass != FL_END_GROUP);
460 void Menus::ScreenOptions()
462 static int ow = -1, oh;
464 // this is not very nice....
465 fl_set_input(fd_form_screen->input_roman,
466 lyxrc.roman_font_name.c_str());
467 fl_set_input(fd_form_screen->input_sans,
468 lyxrc.sans_font_name.c_str());
469 fl_set_input(fd_form_screen->input_typewriter,
470 lyxrc.typewriter_font_name.c_str());
471 fl_set_input(fd_form_screen->input_font_norm,
472 lyxrc.font_norm.c_str());
474 sprintf(tmpstring, "%d", lyxrc.zoom);
475 fl_set_input(fd_form_screen->intinput_size, tmpstring);
476 if (fd_form_screen->form_screen->visible) {
477 fl_raise_form(fd_form_screen->form_screen);
479 fl_show_form(fd_form_screen->form_screen,
480 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
481 _("Screen Options"));
483 ow = fd_form_screen->form_screen->w;
484 oh = fd_form_screen->form_screen->h;
486 fl_set_form_minsize(fd_form_screen->form_screen, ow, oh);
492 // Here comes all the menu callbacks.
495 void Menus::ShowFileMenu(FL_OBJECT * ob, long)
497 Menus * men = static_cast<Menus*>(ob->u_vdata);
499 // Regarding the pseudo-menu-button:
500 // ok, ok this is a hack. It would be better to use the menus of the
501 // xforms 0.8 library. but then all popups have to be defined all the
502 // time, code rewriting would be necessary and contex-depending menus
503 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
504 // course it would be more proper (and little faster). So if anybody
505 // likes to do the cleanup, just do it. Matthias
507 // set the pseudo menu-button
508 fl_set_object_boxtype(ob, FL_UP_BOX);
509 fl_set_button(ob, 0);
510 fl_redraw_object(ob);
512 Buffer * tmpbuffer = men->_view->buffer();
513 LyXFunc * tmpfunc = men->_view->getLyXFunc();
515 bool LinuxDoc = tmpbuffer->isLinuxDoc();
516 bool DocBook = tmpbuffer->isDocBook();
517 bool Literate = tmpbuffer->isLiterate();
521 int SubFileImport = fl_defpup(FL_ObjWin(ob),
524 "|Ascii Text as Lines...%x31"
525 "|Ascii Text as Paragraphs%x32"
529 fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
530 fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
531 fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
532 fl_setpup_shortcut(SubFileImport, 33, scex(_("FIM|Nn#n#N")));
533 fl_setpup_shortcut(SubFileImport, 34, scex(_("FIM|Dd#d#D")));
537 // remember to make this handle linuxdoc too.
538 // and now docbook also.
539 int SubFileExport = 0;
540 if (!LinuxDoc && !DocBook)
541 SubFileExport= fl_defpup(FL_ObjWin(ob),
545 "|as PostScript...%x42"
546 "|as Ascii Text...%x43"
550 SubFileExport= fl_defpup(FL_ObjWin(ob),
552 "|as LinuxDoc...%x40"
554 "|as PostScript...%x42"
555 "|as Ascii Text...%x43"
558 SubFileExport= fl_defpup(FL_ObjWin(ob),
562 "|as PostScript...%x42"
563 "|as Ascii Text...%x43"
566 fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
567 fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
568 fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
569 fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
570 fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
572 if (!LinuxDoc && !DocBook) {
573 fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
576 int FileMenu = fl_defpup(FL_ObjWin(ob),
578 "|New from template..."
592 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
593 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
594 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
595 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Cc#c#C")));
596 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|Ss#s#S")));
597 fl_setpup_shortcut(FileMenu, 6, scex(_("FM|Aa#a#A")));
598 fl_setpup_shortcut(FileMenu, 7, scex(_("FM|Rr#r#R")));
599 fl_setpup_shortcut(FileMenu, 8, scex(_("FM|dD#d#D")));
600 fl_setpup_shortcut(FileMenu, 9, scex(_("FM|wW#w#W")));
601 fl_setpup_shortcut(FileMenu, 10, scex(_("FM|vV#v#V")));
602 fl_setpup_shortcut(FileMenu, 11, scex(_("FM|Uu#u#U")));
603 fl_setpup_shortcut(FileMenu, 12, scex(_("FM|Bb#b#B")));
604 fl_setpup_shortcut(FileMenu, 13, scex(_("FM|Pp#p#P")));
605 fl_setpup_shortcut(FileMenu, 14, scex(_("FM|Ff#f#F")));
607 // These commands are disabled when the corresponding programs
608 // are not installed. I simply grey them out, since I do not
609 // want to change their number (JMarc)
610 bool hasLaTeX = lyxrc.latex_command != "none";
612 if (!hasLaTeX || lyxrc.view_dvi_command == "none")
613 fl_setpup_mode(FileMenu, 8, FL_PUP_GREY);
615 if (!hasLaTeX || lyxrc.view_ps_command == "none")
616 fl_setpup_mode(FileMenu, 9, FL_PUP_GREY);
619 fl_setpup_mode(FileMenu, 10, FL_PUP_GREY);
620 fl_setpup_mode(FileMenu, 11, FL_PUP_GREY);
623 if (lyxrc.literate_command == "none" || ! Literate)
624 fl_setpup_mode(FileMenu, 12, FL_PUP_GREY);
626 if (!hasLaTeX || lyxrc.print_command == "none")
627 fl_setpup_mode(FileMenu, 13, FL_PUP_GREY);
629 if (!hasLaTeX || lyxrc.fax_command == "none")
630 fl_setpup_mode(FileMenu, 14, FL_PUP_GREY);
632 bool hasReLyX = lyxrc.relyx_command != "none";
634 // Disable import LaTeX and Noweb
635 fl_setpup_mode(SubFileImport, 30, FL_PUP_GREY);
636 fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
639 if ( lyxrc.linuxdoc_to_lyx_command == "none")
640 fl_setpup_mode(SubFileImport, 34, FL_PUP_GREY);
643 // Disable export dvi and export postscript
644 fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
645 fl_setpup_mode(SubFileExport, 42, FL_PUP_GREY);
648 if ((!LinuxDoc && !DocBook && lyxrc.html_command == "none") ||
649 ( LinuxDoc && lyxrc.linuxdoc_to_html_command == "none") ||
650 ( DocBook && lyxrc.docbook_to_html_command == "none")) {
651 // Disable export HTML
652 fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
655 // xgettext:no-c-format
656 fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
657 // xgettext:no-c-format
658 fl_addtopup(FileMenu, _("|Export%m%l"), SubFileExport);
659 // xgettext:no-c-format
660 fl_addtopup(FileMenu, _("|Exit%l"));
661 fl_setpup_shortcut(FileMenu, 15, scex(_("FM|Ii#i#I")));
662 fl_setpup_shortcut(FileMenu, 16, scex(_("FM|Ee#e#E")));
663 fl_setpup_shortcut(FileMenu, 17, scex(_("FM|xX#x#X")));
665 // make the lastfiles menu
667 for (LastFiles::const_iterator cit = lastfiles->begin();
668 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
669 string tmp = tostr(ii);
670 string tmp2 = tmp + "#" + tmp;
671 tmp += ". " + MakeDisplayPath((*cit), 30);
672 fl_addtopup(FileMenu, tmp.c_str());
673 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
678 men->_view->getForm()->x + ob->x,
679 men->_view->getForm()->y + ob->y + ob->h + 10);
680 int choice = fl_dopup(FileMenu);
683 // set the pseudo menu-button back
684 fl_set_object_boxtype(ob, FL_FLAT_BOX);
685 fl_redraw_object(ob);
688 case -1: case 0: // we won't do anything
690 case 1: tmpfunc->Dispatch(LFUN_MENUNEW); break;
691 case 2: tmpfunc->Dispatch(LFUN_MENUNEWTMPLT); break;
692 case 3: tmpfunc->Dispatch(LFUN_MENUOPEN); break;
693 case 4: tmpfunc->Dispatch(LFUN_CLOSEBUFFER); break;
694 case 5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
695 case 6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
696 case 7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
697 case 8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
698 case 9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
699 case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
700 case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
701 case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
702 case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
703 case 14: tmpfunc->Dispatch(LFUN_FAX); break;
704 case 15: // import menu
705 case 30: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
707 case 31: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
709 case 32: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
711 case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
713 case 34: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
715 case 16: // export menu
717 if (!LinuxDoc && !DocBook)
718 tmpfunc->Dispatch(LFUN_EXPORT, "latex");
720 tmpfunc->Dispatch(LFUN_EXPORT, "linuxdoc");
722 tmpfunc->Dispatch(LFUN_EXPORT, "docbook");
724 case 41: tmpfunc->Dispatch(LFUN_EXPORT, "dvi");
726 case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
728 case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
731 if (!LinuxDoc && !DocBook)
732 tmpfunc->Dispatch(LFUN_EXPORT, "html");
734 tmpfunc->Dispatch(LFUN_EXPORT, "html-linuxdoc");
736 tmpfunc->Dispatch(LFUN_EXPORT, "html-docbook");
738 case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
740 case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
742 case 18: // The first item with lastfiles.
746 .loadLyXFile((*lastfiles)[choice - 18]));
749 fl_freepup(SubFileImport);
750 fl_freepup(SubFileExport);
751 fl_freepup(FileMenu);
753 AllowInput(men->currentView());
757 void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
759 Menus * men = static_cast<Menus*>(ob->u_vdata);
761 // Regarding the pseudo-menu-button:
762 // ok, ok this is a hack. It would be better to use the menus of the
763 // xforms 0.8 library. but then all popups have to be defined all the
764 // time, code rewriting would be necessary and contex-depending menus
765 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
766 // course it would be more proper (and little faster). So if anybody
767 // likes to do the cleanup, just do it. Matthias
769 // set the pseudo menu-button
770 fl_set_object_boxtype(ob, FL_UP_BOX);
771 fl_set_button(ob, 0);
772 fl_redraw_object(ob);
774 LyXFunc * tmpfunc = men->_view->getLyXFunc();
778 int SubFileImport = fl_defpup(FL_ObjWin(ob),
781 "|Ascii Text as Lines...%x16"
782 "|Ascii Text as Paragraphs...%x17"
784 "|LinuxDoc...%x19"));
786 fl_setpup_shortcut(SubFileImport, 15, scex(_("FIM|Ll#l#L")));
787 fl_setpup_shortcut(SubFileImport, 16, scex(_("FIM|Aa#a#A")));
788 fl_setpup_shortcut(SubFileImport, 17, scex(_("FIM|Pp#p#P")));
789 fl_setpup_shortcut(SubFileImport, 18, scex(_("FIM|Nn#n#N")));
790 fl_setpup_shortcut(SubFileImport, 19, scex(_("FIM|Dd#d#D")));
792 bool hasReLyX = lyxrc.relyx_command != "none";
794 // Disable import LaTeX and Noweb
795 fl_setpup_mode(SubFileImport, 15, FL_PUP_GREY);
796 fl_setpup_mode(SubFileImport, 18, FL_PUP_GREY);
799 if ( lyxrc.linuxdoc_to_lyx_command == "none")
800 fl_setpup_mode(SubFileImport, 19, FL_PUP_GREY);
802 // This can be done cleaner later.
803 int FileMenu = fl_defpup(FL_ObjWin(ob),
805 "|New from template..."
808 "|Exit%l"), SubFileImport);
810 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
811 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
812 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
813 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Ii#i#I")));
814 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|xX#x#X")));
816 // make the lastfiles menu
818 for (LastFiles::const_iterator cit = lastfiles->begin();
819 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
820 string tmp = tostr(ii);
821 string tmp2 = tmp + "#" + tmp;
822 tmp += ". " + MakeDisplayPath((*cit), 30);
823 fl_addtopup(FileMenu, tmp.c_str());
824 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
829 men->_view->getForm()->x + ob->x,
830 men->_view->getForm()->y + ob->y + ob->h + 10);
831 int choice = fl_dopup(FileMenu);
834 // set the pseudo menu-button back
835 fl_set_object_boxtype(ob, FL_FLAT_BOX);
836 fl_redraw_object(ob);
839 case -1: case 0: // we won't do anything
842 tmpfunc->Dispatch(LFUN_MENUNEW);
845 tmpfunc->Dispatch(LFUN_MENUNEWTMPLT);
848 tmpfunc->Dispatch(LFUN_MENUOPEN);
850 case 4: // import menu
851 case 15: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
853 case 16: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
855 case 17: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
857 case 18: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
859 case 19: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
862 tmpfunc->Dispatch(LFUN_QUIT);
865 case 6: // The first item with lastfiles.
869 .loadLyXFile((*lastfiles)[choice - 6]));
873 fl_freepup(SubFileImport);
874 fl_freepup(FileMenu);
875 AllowInput(men->currentView());
880 void Menus::ShowEditMenu(FL_OBJECT * ob, long)
882 Menus * men = static_cast<Menus*>(ob->u_vdata);
884 // set the pseudo menu-button
885 fl_set_object_boxtype(ob, FL_UP_BOX);
886 fl_set_button(ob, 0);
887 fl_redraw_object(ob);
889 Buffer * tmpbuffer = men->_view->buffer();
890 LyXFunc * tmpfunc = men->_view->getLyXFunc();
892 // Floats & Insets submenu
893 int SubEditFloats= fl_defpup(FL_ObjWin(ob),
894 _("Floats & Insets%t"
897 "|Open All Footnotes/Margin Notes%x23"
898 "|Close All Footnotes/Margin Notes%x24"
899 "|Open All Figures/Tables%x25"
900 "|Close All Figures/Tables%x26%l"
901 "|Remove all Error Boxes%x27"));
903 fl_setpup_shortcut(SubEditFloats, 21, scex(_("EMF|Oo#o#O")));
904 fl_setpup_shortcut(SubEditFloats, 22, scex(_("EMF|Mm#m#M")));
905 fl_setpup_shortcut(SubEditFloats, 23, scex(_("EMF|Aa#a#A")));
906 fl_setpup_shortcut(SubEditFloats, 24, scex(_("EMF|Cc#c#C")));
907 fl_setpup_shortcut(SubEditFloats, 25, scex(_("EMF|Ff#f#F")));
908 fl_setpup_shortcut(SubEditFloats, 26, scex(_("EMF|Tt#t#T")));
909 fl_setpup_shortcut(SubEditFloats, 27, scex(_("EMF|Rr#r#R")));
912 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")));
1009 } else if (men->currentView()->the_locking_inset &&
1010 (men->currentView()->the_locking_inset->LyxCode() ==
1011 Inset::TABULAR_CODE) &&
1012 !tmpbuffer->isReadonly()) {
1013 InsetTabular * inset = static_cast<InsetTabular *>(men->currentView()->the_locking_inset);
1014 LyXTabular * table = inset->tabular;
1016 fl_addtopup(SubEditTable, _("Table%t"));
1018 if (table->IsMultiColumn(inset->GetActCell()))
1019 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
1021 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
1022 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
1024 if (table->TopLine(inset->GetActCell()))
1025 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
1027 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
1028 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
1030 if (table->BottomLine(inset->GetActCell()))
1031 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
1033 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
1034 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
1036 if (table->LeftLine(inset->GetActCell()))
1037 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
1039 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
1040 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
1042 if (table->RightLine(inset->GetActCell()))
1043 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
1045 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
1046 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
1048 int align = table->GetAlignment(inset->GetActCell());
1049 if (align == LYX_ALIGN_LEFT)
1050 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
1052 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
1053 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
1055 if (align == LYX_ALIGN_RIGHT)
1056 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
1058 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
1059 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
1061 if (align == LYX_ALIGN_CENTER)
1062 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
1064 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
1065 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
1067 // xgettext:no-c-format
1068 fl_addtopup(SubEditTable, _("|Append Row%x32"));
1069 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
1070 // xgettext:no-c-format
1071 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
1072 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
1073 // xgettext:no-c-format
1074 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
1075 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
1076 // xgettext:no-c-format
1077 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
1078 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
1079 // xgettext:no-c-format
1080 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
1081 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
1083 fl_addtopup(SubEditTable, _("Table%t"));
1084 // xgettext:no-c-format
1085 fl_addtopup(SubEditTable, _("|Insert table%x31"));
1086 fl_setpup_shortcut(SubEditTable, 31, scex(_("EMT|Ii#i#I")));
1089 int SubVersionControl = fl_newpup(FL_ObjWin(ob));
1090 fl_addtopup(SubVersionControl, _("Version Control%t"));
1091 if (tmpbuffer->lyxvc.inUse()) {
1092 // xgettext:no-c-format
1093 fl_addtopup(SubVersionControl, _("|Register%d%x51"));
1094 if (tmpbuffer->isReadonly()) {
1095 // signifies that the file is not checked out
1096 // xgettext:no-c-format
1097 fl_addtopup(SubVersionControl, _("|Check In Changes%d%x52"));
1098 // xgettext:no-c-format
1099 fl_addtopup(SubVersionControl, _("|Check Out for Edit%x53"));
1101 // signifies that the file is checked out
1102 // xgettext:no-c-format
1103 fl_addtopup(SubVersionControl, _("|Check In Changes%x52"));
1104 // xgettext:no-c-format
1105 fl_addtopup(SubVersionControl, _("|Check Out for Edit%d%x53"));
1107 // xgettext:no-c-format
1108 fl_addtopup(SubVersionControl, _("|Revert to last version%x54"));
1109 // xgettext:no-c-format
1110 fl_addtopup(SubVersionControl, _("|Undo last check in%x55"));
1111 // xgettext:no-c-format
1112 fl_addtopup(SubVersionControl, _("|Show History%x56"));
1114 // xgettext:no-c-format
1115 fl_addtopup(SubVersionControl, _("|Register%x51"));
1117 // the shortcuts are not good.
1118 fl_setpup_shortcut(SubVersionControl, 51, scex(_("EMV|Rr#r#R")));
1119 fl_setpup_shortcut(SubVersionControl, 52, scex(_("EMV|Ii#i#I")));
1120 fl_setpup_shortcut(SubVersionControl, 53, scex(_("EMV|Oo#o#O")));
1121 fl_setpup_shortcut(SubVersionControl, 54, scex(_("EMV|lL#l#l")));
1122 fl_setpup_shortcut(SubVersionControl, 55, scex(_("EMV|Uu#u#U")));
1123 fl_setpup_shortcut(SubVersionControl, 56, scex(_("EMV|Hh#h#H")));
1125 int EditMenu= fl_defpup(FL_ObjWin(ob),
1131 "|Find & Replace..."
1134 "|Floats & Insets%m"
1138 "|Table of Contents..."
1139 "|List of Figures..."
1140 "|List of Tables..."
1141 "|List of Algorithms...%l"
1142 "|Version Control%m%l"
1143 "|View LaTeX log file%l"
1144 "|Paste Primary Selection as Lines"
1145 "|Paste Primary Selection as Paragraphs"),
1146 SubEditFloats, SubEditTable, SubVersionControl);
1148 fl_setpup_shortcut(EditMenu, 1, scex(_("EM|Uu#u#U")));
1149 fl_setpup_shortcut(EditMenu, 2, scex(_("EM|Rr#r#R")));
1150 fl_setpup_shortcut(EditMenu, 3, scex(_("EM|Cc#c#C")));
1151 fl_setpup_shortcut(EditMenu, 4, scex(_("EM|oO#o#O")));
1152 fl_setpup_shortcut(EditMenu, 5, scex(_("EM|Pp#p#P")));
1153 fl_setpup_shortcut(EditMenu, 6, scex(_("EM|Ff#f#F")));
1154 fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
1155 fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
1156 fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
1157 //fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
1158 fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
1159 fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
1160 fl_setpup_shortcut(EditMenu, 13, scex(_("EM|Tt#t#T")));
1161 //fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Ff#f#F")));
1162 //fl_setpup_shortcut(EditMenu, 15, scex(_("EM|bB#b#B")));
1163 //fl_setpup_shortcut(EditMenu, 16, scex(_("EM|mM#m#M")));
1164 fl_setpup_shortcut(EditMenu, 17, scex(_("EM|Vv#v#V")));
1165 fl_setpup_shortcut(EditMenu, 18, scex(_("EM|wW#w#W")));
1166 fl_setpup_shortcut(EditMenu, 19, scex(_("EM|Ll#l#L")));
1167 fl_setpup_shortcut(EditMenu, 20, scex(_("EM|gG#g#G")));
1169 // disable unavailable entries.
1170 if(tmpbuffer->undostack.empty())
1171 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1172 if(tmpbuffer->redostack.empty())
1173 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1174 if(lyxrc.isp_command == "none")
1175 fl_setpup_mode(EditMenu, 11, FL_PUP_GREY);
1176 if(lyxrc.chktex_command == "none")
1177 fl_setpup_mode(EditMenu, 12, FL_PUP_GREY);
1179 if (tmpbuffer->isReadonly()) {
1180 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1181 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1182 fl_setpup_mode(EditMenu, 3, FL_PUP_GREY);
1183 fl_setpup_mode(EditMenu, 5, FL_PUP_GREY);
1184 fl_setpup_mode(EditMenu, 19, FL_PUP_GREY);
1185 fl_setpup_mode(EditMenu, 20, FL_PUP_GREY);
1188 fl_setpup_position(men->_view->getForm()->x + ob->x,
1189 men->_view->getForm()->y + ob->y +
1191 int choice = fl_dopup(EditMenu);
1194 // set the pseudo menu-button back
1195 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1196 fl_redraw_object(ob);
1199 case 1: tmpfunc->Dispatch(LFUN_UNDO); break;
1200 case 2: tmpfunc->Dispatch(LFUN_REDO); break;
1201 case 3: tmpfunc->Dispatch(LFUN_CUT); break;
1202 case 4: tmpfunc->Dispatch(LFUN_COPY); break;
1203 case 5: tmpfunc->Dispatch(LFUN_PASTE); break;
1204 case 6: tmpfunc->Dispatch(LFUN_MENUSEARCH); break;
1205 case 7: tmpfunc->Dispatch(LFUN_GOTOERROR); break;
1206 case 8: tmpfunc->Dispatch(LFUN_GOTONOTE); break;
1207 case 9: // floats & insets
1211 case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
1212 case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
1213 case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
1214 case 14: tmpfunc->Dispatch(LFUN_LOFVIEW); break;
1215 case 15: tmpfunc->Dispatch(LFUN_LOTVIEW); break;
1216 case 16: tmpfunc->Dispatch(LFUN_LOAVIEW); break;
1217 case 17: // version control
1219 case 18: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
1220 case 19: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
1221 case 20: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
1223 // floats & insets sub-menu
1224 case 21: men->currentView()->toggleFloat(); break;
1225 case 22: tmpfunc->Dispatch(LFUN_MELT); break;
1226 case 23: men->currentView()->allFloats(1, 0); break;
1227 case 24: men->currentView()->allFloats(0, 0); break;
1228 case 25: men->currentView()->allFloats(1, 1); break;
1229 case 26: men->currentView()->allFloats(0, 1); break;
1230 case 27: tmpfunc->Dispatch(LFUN_REMOVEERRORS); break;
1232 case 31: tmpfunc->Dispatch(LFUN_TABLE); break;
1233 // this is really temporary. We need new function in keybind.C
1234 // These should set the minibuffer, too.
1235 case 32: case 33: case 34:
1236 case 35: case 36: case 37:
1237 case 38: case 39: case 40:
1238 case 41: case 42: case 43:
1240 if (men->currentView()->available()) {
1241 men->currentView()->hideCursor();
1242 if (!men->currentView()->text->selection){
1243 men->currentView()->beforeChange();
1244 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR);
1246 if (men->currentView()->the_locking_inset &&
1247 (men->currentView()->the_locking_inset->LyxCode()
1248 == Inset::TABULAR_CODE)) {
1249 InsetTabular * inset =
1250 static_cast<InsetTabular *>
1251 (men->currentView()->the_locking_inset);
1252 inset->TabularFeatures(men->currentView(), choice - 32);
1254 men->currentView()->text->
1255 TableFeatures(men->currentView(), choice - 32);
1256 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
1260 // version control sub-menu
1261 case 51: // register
1262 tmpfunc->Dispatch(LFUN_VC_REGISTER);
1264 case 52: // check in
1265 tmpfunc->Dispatch(LFUN_VC_CHECKIN);
1267 case 53: // check out
1268 tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
1270 case 54: // revert to last
1271 tmpfunc->Dispatch(LFUN_VC_REVERT);
1273 case 55: // undo last
1274 tmpfunc->Dispatch(LFUN_VC_UNDO);
1276 case 56: // show history
1277 tmpfunc->Dispatch(LFUN_VC_HISTORY);
1281 fl_freepup(EditMenu);
1282 fl_freepup(SubEditFloats);
1283 fl_freepup(SubEditTable);
1284 fl_freepup(SubVersionControl);
1287 vector<int>::size_type const max_number_of_menus = 32;
1288 unsigned int const max_number_of_items = 25;
1290 string Limit_string_length(string const & str) {
1291 string::size_type const max_item_length = 45;
1293 if (str.size() > max_item_length)
1294 return str.substr(0, max_item_length-3) + "...";
1299 void Add_to_toc_menu(vector<Buffer::TocItem> const & toclist,
1300 unsigned int from, unsigned int to, int depth,
1301 int menu, vector<int> & menus, FL_OBJECT * ob)
1303 if (to - from <= max_number_of_items) {
1304 for (unsigned int i = from; i < to; ++i) {
1305 string entry(4 * max(0, toclist[i].depth - depth),' ');
1306 entry += toclist[i].str;
1307 entry = Limit_string_length(entry);
1308 entry += "%x" + tostr(i + 1);
1309 fl_addtopup(menu, entry.c_str());
1312 unsigned int pos = from;
1313 unsigned int count = 0;
1316 if (count > max_number_of_items) {
1317 fl_addtopup(menu, ". . .%d");
1320 unsigned int new_pos = pos+1;
1321 while (new_pos < to &&
1322 toclist[new_pos].depth > depth)
1325 string entry(4 * max(0, toclist[pos].depth - depth), ' ');
1326 entry += toclist[pos].str;
1327 entry = Limit_string_length(entry);
1329 if (new_pos == pos + 1) {
1331 entry += tostr(pos + 1);
1332 fl_addtopup(menu, entry.c_str());
1333 } else if (menus.size() < max_number_of_menus) {
1334 int menu2 = fl_newpup(FL_ObjWin(ob));
1335 menus.push_back(menu2);
1336 Add_to_toc_menu(toclist, pos, new_pos,
1337 depth + 1, menu2, menus,ob);
1339 fl_addtopup(menu, entry.c_str(), menu2);
1342 fl_addtopup(menu, entry.c_str());
1349 int const BIG_NUM = 1048576;
1351 void Menus::ShowTocMenu(FL_OBJECT * ob, long)
1353 Menus * men = static_cast<Menus*>(ob->u_vdata);
1356 // set the pseudo menu-button
1357 fl_set_object_boxtype(ob, FL_UP_BOX);
1358 fl_set_button(ob, 0);
1359 fl_redraw_object(ob);
1361 int TocMenu = fl_newpup(FL_ObjWin(ob));
1362 menus.push_back(TocMenu);
1363 vector<vector<Buffer::TocItem> > toclist =
1364 men->currentView()->buffer()->getTocList();
1366 //xgettext:no-c-format
1367 static char const * MenuNames[3] = { N_("List of Figures%m"),
1368 //xgettext:no-c-format
1369 N_("List of Tables%m"),
1370 //xgettext:no-c-format
1371 N_("List of Algorithms%m") };
1373 int max_nonempty = 0;
1374 for (int j = 1; j <= 3; ++j)
1375 if (!toclist[j].empty())
1378 for (int j = 1; j <= 3; ++j)
1379 if (!toclist[j].empty()) {
1380 int menu2 = fl_newpup(FL_ObjWin(ob));
1381 menus.push_back(menu2);
1382 for (unsigned int i = 0; i < toclist[j].size(); ++i) {
1383 if (i > max_number_of_items) {
1384 fl_addtopup(menu2, ". . .%d");
1387 string entry = Limit_string_length(toclist[j][i].str);
1388 entry += "%x" + tostr(i+1+j*BIG_NUM);
1389 fl_addtopup(menu2, entry.c_str());
1391 if (j == max_nonempty) {
1392 string tmp = _(MenuNames[j-1]);
1394 fl_addtopup(TocMenu, tmp.c_str(), menu2);
1396 fl_addtopup(TocMenu, _(MenuNames[j-1]), menu2);
1399 Add_to_toc_menu(toclist[0], 0, toclist[0].size(), 0,
1400 TocMenu, menus, ob);
1403 men->_view->getForm()->x + ob->x,
1404 men->_view->getForm()->y + ob->y + ob->h + 10);
1405 int choice = fl_dopup(TocMenu);
1408 // set the pseudo menu-button back
1409 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1410 fl_redraw_object(ob);
1412 men->_view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
1413 else if (choice > 0) {
1414 int type = choice / BIG_NUM;
1415 int num = (choice % BIG_NUM) - 1;
1416 BufferView *bv = men->currentView();
1418 bv->text->SetCursor(bv, toclist[type][num].par, 0);
1419 bv->text->sel_cursor = bv->text->cursor;
1420 bv->update(BufferView::SELECT|BufferView::FITCUR);
1422 for (unsigned int i = 0; i < menus.size(); ++i)
1423 fl_freepup(menus[i]);
1426 void Add_to_refs_menu(vector<string> const & label_list, int offset,
1427 int menu, vector<int> & menus, FL_OBJECT * ob)
1429 typedef vector<string>::size_type size_type;
1430 size_type const max_number_of_items = 25;
1431 size_type const max_number_of_items2 = 20;
1432 string::size_type const max_item_length = 40;
1433 string::size_type const max_item_length2 = 20;
1435 if (label_list.size() <= max_number_of_items)
1436 for (size_type i = 0; i < label_list.size(); ++i) {
1437 string entry = label_list[i];
1438 if (entry.size() > max_item_length)
1439 entry = entry.substr(0, max_item_length-1) + "$";
1440 entry += "%x" + tostr(i+offset);
1441 fl_addtopup(menu, entry.c_str());
1444 size_type count = 0;
1445 for (size_type i = 0; i < label_list.size();
1446 i += max_number_of_items2) {
1448 if (count > max_number_of_items) {
1449 fl_addtopup(menu, ". . .%d");
1452 size_type j = min(label_list.size(),
1453 i+max_number_of_items2);
1456 if (label_list[i].size() > max_item_length2)
1457 entry += label_list[i].substr(0, max_item_length2-1) + "$";
1459 entry += label_list[i];
1461 if (label_list[j-1].size() > max_item_length2)
1462 entry += label_list[j-1].substr(0, max_item_length2-1) + "$";
1464 entry += label_list[j-1];
1466 if (menus.size() < max_number_of_menus) {
1467 int menu2 = fl_newpup(FL_ObjWin(ob));
1468 menus.push_back(menu2);
1469 for (size_type k = i; k < j; ++k) {
1470 string entry2 = label_list[k];
1471 if (entry2.size() > max_item_length)
1472 entry2 = entry2.substr(0, max_item_length-1) + "$";
1473 entry2 += "%x" + tostr(k+offset);
1474 fl_addtopup(menu2, entry2.c_str());
1477 fl_addtopup(menu, entry.c_str(), menu2);
1480 fl_addtopup(menu, entry.c_str());
1486 void Menus::ShowRefsMenu(FL_OBJECT * ob, long)
1490 Menus * men = static_cast<Menus*>(ob->u_vdata);
1492 // set the pseudo menu-button
1493 fl_set_object_boxtype(ob, FL_UP_BOX);
1494 fl_set_button(ob, 0);
1495 fl_redraw_object(ob);
1497 int RefsMenu = fl_newpup(FL_ObjWin(ob));
1498 menus.push_back(RefsMenu);
1499 Buffer * buffer = men->currentView()->buffer();
1500 vector<string> label_list = buffer->getLabelList();
1501 sort(label_list.begin(), label_list.end());
1503 //xgettext:no-c-format
1504 static char const * MenuNames[6] = { N_("Insert Reference%m"),
1505 //xgettext:no-c-format
1506 N_("Insert Page Number%m"),
1507 //xgettext:no-c-format
1508 N_("Insert vref%m"),
1509 //xgettext:no-c-format
1510 N_("Insert vpageref%m"),
1511 //xgettext:no-c-format
1512 N_("Insert Pretty Ref%m"),
1513 //xgettext:no-c-format
1514 N_("Goto Reference%m") };
1516 for (int j = 0; j < 6; ++j) {
1517 if (menus.size() < max_number_of_menus) {
1518 int menu2 = fl_newpup(FL_ObjWin(ob));
1519 menus.push_back(menu2);
1520 Add_to_refs_menu(label_list, (j+1)*BIG_NUM, menu2, menus, ob);
1521 fl_addtopup(RefsMenu, _(MenuNames[j]), menu2);
1523 string tmp = _(MenuNames[j]);
1525 fl_addtopup(RefsMenu, tmp.c_str());
1528 fl_addtopup(RefsMenu, _("Go Back"));
1530 bool empty = label_list.empty();
1531 bool sgml = buffer->isSGML();
1532 bool readonly = buffer->isReadonly();
1535 fl_setpup_mode(RefsMenu, 6, FL_PUP_GREY);
1536 if (empty || readonly) {
1537 fl_setpup_mode(RefsMenu, 1, FL_PUP_GREY);
1538 fl_setpup_mode(RefsMenu, 2, FL_PUP_GREY);
1540 if (empty || readonly || sgml) {
1541 fl_setpup_mode(RefsMenu, 3, FL_PUP_GREY);
1542 fl_setpup_mode(RefsMenu, 4, FL_PUP_GREY);
1543 fl_setpup_mode(RefsMenu, 5, FL_PUP_GREY);
1545 if (men->currentView()->NoSavedPositions())
1546 fl_setpup_mode(RefsMenu, 7, FL_PUP_GREY);
1549 men->_view->getForm()->x + ob->x,
1550 men->_view->getForm()->y + ob->y + ob->h + 10);
1551 int choice = fl_dopup(RefsMenu);
1554 // set the pseudo menu-button back
1555 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1556 fl_redraw_object(ob);
1559 men->_view->getLyXFunc()->Dispatch(LFUN_REFBACK);
1560 else if (choice >= BIG_NUM) {
1561 int type = (choice / BIG_NUM) - 1;
1562 int num = choice % BIG_NUM;
1564 men->_view->getLyXFunc()->Dispatch(LFUN_REFGOTO,
1565 label_list[num].c_str());
1567 static string const commands[5]
1568 = { "\\ref", "\\pageref", "\\vref", "\\vpageref",
1570 string t = commands[type] + "{" + label_list[num] + "}";
1571 men->currentView()->insertInset(new InsetRef(t, buffer));
1575 for (unsigned int i = 0; i < menus.size(); ++i)
1576 fl_freepup(menus[i]);
1580 void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
1582 Menus * men = static_cast<Menus*>(ob->u_vdata);
1584 if (!men->currentView()->available())
1587 // set the pseudo menu-button
1588 fl_set_object_boxtype(ob, FL_UP_BOX);
1589 fl_set_button(ob, 0);
1590 fl_redraw_object(ob);
1592 Buffer * tmpbuffer = men->_view->buffer();
1593 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1595 int LayoutMenu = fl_newpup(FL_ObjWin(ob));
1596 fl_addtopup(LayoutMenu, _("Character..."
1602 "|Emphasize Style%b"
1606 "|Change Environment Depth"
1607 "|LaTeX Preamble..."
1608 "|Start of Appendix%l"
1609 "|Save layout as default"));
1610 fl_setpup_shortcut(LayoutMenu, 1, scex(_("LM|Cc#c#C")));
1611 fl_setpup_shortcut(LayoutMenu, 2, scex(_("LM|Pp#p#P")));
1612 fl_setpup_shortcut(LayoutMenu, 3, scex(_("LM|Dd#d#D")));
1613 fl_setpup_shortcut(LayoutMenu, 4, scex(_("LM|aA#a#A")));
1614 fl_setpup_shortcut(LayoutMenu, 5, scex(_("LM|eE#e#E")));
1615 fl_setpup_shortcut(LayoutMenu, 6, scex(_("LM|Qq#q#Q")));
1616 fl_setpup_shortcut(LayoutMenu, 7, scex(_("LM|mM#m#M")));
1617 fl_setpup_shortcut(LayoutMenu, 8, scex(_("LM|Nn#n#N")));
1618 fl_setpup_shortcut(LayoutMenu, 9, scex(_("LM|Bb#b#B")));
1619 fl_setpup_shortcut(LayoutMenu, 10, scex(_("LM|Tt#t#T")));
1620 fl_setpup_shortcut(LayoutMenu, 11, scex(_("LM|vV#v#V")));
1621 fl_setpup_shortcut(LayoutMenu, 12, scex(_("LM|Ll#l#L")));
1622 fl_setpup_shortcut(LayoutMenu, 13, scex(_("LM|xX#x#X")));
1623 fl_setpup_shortcut(LayoutMenu, 14, scex(_("LM|Ss#s#S")));
1625 // Set values of checkboxes according to font
1626 LyXFont font = men->currentView()->text->real_current_font;
1627 if (font.emph() == LyXFont::ON)
1628 fl_setpup_mode(LayoutMenu, 7, FL_PUP_CHECK);
1629 if (font.noun() == LyXFont::ON)
1630 fl_setpup_mode(LayoutMenu, 8, FL_PUP_CHECK);
1631 if (font.series() == LyXFont::BOLD_SERIES)
1632 fl_setpup_mode(LayoutMenu, 9, FL_PUP_CHECK);
1633 if (font.latex() == LyXFont::ON)
1634 fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
1636 // Grey out unavailable entries
1637 if (!men->currentView()->text->cursor.par()->table)
1638 fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
1640 if (tmpbuffer->isReadonly()) {
1641 fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
1642 fl_setpup_mode(LayoutMenu, 6, FL_PUP_GREY);
1643 fl_setpup_mode(LayoutMenu, 11, FL_PUP_GREY);
1647 men->_view->getForm()->x + ob->x,
1648 men->_view->getForm()->y + ob->y + ob->h + 10);
1649 int choice = fl_dopup(LayoutMenu);
1652 // set the pseudo menu-button back
1653 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1654 fl_redraw_object(ob);
1657 case 1: tmpfunc->Dispatch(LFUN_LAYOUT_CHARACTER); break;
1658 case 2: tmpfunc->Dispatch(LFUN_LAYOUT_PARAGRAPH); break;
1659 case 3: tmpfunc->Dispatch(LFUN_LAYOUT_DOCUMENT); break;
1660 case 4: tmpfunc->Dispatch(LFUN_LAYOUT_PAPER); break;
1661 case 5: tmpfunc->Dispatch(LFUN_LAYOUT_TABLE, "true"); break;
1662 case 6: tmpfunc->Dispatch(LFUN_LAYOUT_QUOTES); break;
1663 case 7: tmpfunc->Dispatch(LFUN_EMPH); break;
1664 case 8: tmpfunc->Dispatch(LFUN_NOUN); break;
1665 case 9: tmpfunc->Dispatch(LFUN_BOLD); break;
1666 case 10: tmpfunc->Dispatch(LFUN_TEX); break;
1667 case 11: tmpfunc->Dispatch(LFUN_DEPTH_PLUS); break;
1668 case 12: tmpfunc->Dispatch(LFUN_LAYOUT_PREAMBLE); break;
1669 case 13: tmpfunc->Dispatch(LFUN_APPENDIX); break;
1670 case 14: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;
1672 fl_freepup(LayoutMenu);
1676 void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
1678 Menus * men = static_cast<Menus*>(ob->u_vdata);
1680 // set the pseudo menu-button
1681 fl_set_object_boxtype(ob, FL_UP_BOX);
1682 fl_set_button(ob, 0);
1683 fl_redraw_object(ob);
1685 Buffer * tmpbuffer = men->_view->buffer();
1686 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1688 int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
1689 _("Import ASCII file%t"
1691 "|As Paragraphs%x42"));
1693 fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
1694 fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
1696 int SubInsertTableList= fl_defpup(FL_ObjWin(ob),
1698 "|Table of Contents%x21"
1699 "|List of Figures%x22"
1700 "|List of Tables%x23"
1701 "|List of Algorithms%x24"
1703 "|BibTeX Reference%x26"));
1705 fl_setpup_shortcut(SubInsertTableList, 21, scex(_("IMT|Cc#c#C")));
1706 fl_setpup_shortcut(SubInsertTableList, 22, scex(_("IMT|Ff#f#F")));
1707 fl_setpup_shortcut(SubInsertTableList, 23, scex(_("IMT|Tt#t#T")));
1708 fl_setpup_shortcut(SubInsertTableList, 24, scex(_("IMT|Aa#a#A")));
1709 fl_setpup_shortcut(SubInsertTableList, 25, scex(_("IMT|Ii#i#I")));
1710 fl_setpup_shortcut(SubInsertTableList, 26, scex(_("IMT|Bb#b#B")));
1712 int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
1716 "|Wide Figure Float%x73"
1717 "|Wide Table Float%l%x74"
1718 "|Algorithm Float%x75"));
1720 fl_setpup_shortcut(SubInsertFloatList, 71, scex(_("IMF|gG#g#G")));
1721 fl_setpup_shortcut(SubInsertFloatList, 72, scex(_("IMF|Tt#t#T")));
1722 fl_setpup_shortcut(SubInsertFloatList, 73, scex(_("IMF|Ww#w#W")));
1723 fl_setpup_shortcut(SubInsertFloatList, 74, scex(_("IMF|iI#i#I")));
1724 fl_setpup_shortcut(SubInsertFloatList, 75, scex(_("IMF|Aa#a#A")));
1726 int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
1727 _("Special Character%t"
1729 "|Hyphenation Point%x32"
1730 "|Protected Blank%x33"
1732 "|Ellipsis (...)%x35"
1733 "|End of sentence period%x36"
1734 "|Ordinary Quote (\")%x37"
1735 "|Menu Separator %x38"));
1737 fl_setpup_shortcut(SubInsertSpecial, 31, scex(_("IMS|Hh#h#H")));
1738 fl_setpup_shortcut(SubInsertSpecial, 32, scex(_("IMS|Pp#p#P")));
1739 fl_setpup_shortcut(SubInsertSpecial, 33, scex(_("IMS|Bb#b#B")));
1740 fl_setpup_shortcut(SubInsertSpecial, 34, scex(_("IMS|Ll#l#L")));
1741 fl_setpup_shortcut(SubInsertSpecial, 35, scex(_("IMS|iI#i#I")));
1742 fl_setpup_shortcut(SubInsertSpecial, 36, scex(_("IMS|Ee#e#E")));
1743 fl_setpup_shortcut(SubInsertSpecial, 37, scex(_("IMS|Qq#q#Q")));
1744 fl_setpup_shortcut(SubInsertSpecial, 38, scex(_("IMS|Mm#m#M")));
1746 int InsertMenu = fl_defpup(FL_ObjWin(ob),
1750 "|Import ASCII File%m"
1751 "|Insert LyX File..."
1752 "|Insert external material...%l"
1757 "|Special Character%m%l"
1760 "|Cross-Reference..."
1761 "|Citation Reference..."
1763 "|Index entry of last word"),
1769 fl_setpup_shortcut(InsertMenu, 1, scex(_("IM|gG#g#G")));
1770 fl_setpup_shortcut(InsertMenu, 2, scex(_("IM|bB#b#B")));
1771 fl_setpup_shortcut(InsertMenu, 3, scex(_("IM|cC#c#C")));
1772 fl_setpup_shortcut(InsertMenu, 4, scex(_("IM|Aa#a#A")));
1773 fl_setpup_shortcut(InsertMenu, 5, scex(_("IM|Xx#x#X")));
1774 fl_setpup_shortcut(InsertMenu, 6, scex(_("IM|Ee#e#E")));
1775 fl_setpup_shortcut(InsertMenu, 7, scex(_("IM|Ff#f#F")));
1776 fl_setpup_shortcut(InsertMenu, 8, scex(_("IM|Mm#m#M")));
1777 fl_setpup_shortcut(InsertMenu, 9, scex(_("IM|oO#o#O")));
1778 fl_setpup_shortcut(InsertMenu, 10, scex(_("IM|Tt#t#T")));
1779 fl_setpup_shortcut(InsertMenu, 11, scex(_("IM|Ss#s#S")));
1780 fl_setpup_shortcut(InsertMenu, 12, scex(_("IM|Nn#n#N")));
1781 fl_setpup_shortcut(InsertMenu, 13, scex(_("IM|Ll#l#L")));
1782 fl_setpup_shortcut(InsertMenu, 14, scex(_("IM|rR#r#R")));
1783 fl_setpup_shortcut(InsertMenu, 15, scex(_("IM|iI#i#I")));
1784 fl_setpup_shortcut(InsertMenu, 16, scex(_("IM|dD#d#D")));
1785 fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|wW#w#W")));
1787 fl_addtopup(InsertMenu, _("|URL..."));
1788 fl_setpup_shortcut(InsertMenu, 18, scex(_("IM|Uu#u#U")));
1790 if (tmpbuffer->isReadonly()) {
1791 for (int ii = 1; ii <= 17; ++ii)
1792 fl_setpup_mode(InsertMenu, ii, FL_PUP_GREY);
1793 fl_setpup_mode(InsertMenu, 18, FL_PUP_GREY);
1797 men->_view->getForm()->x + ob->x,
1798 men->_view->getForm()->y + ob->y + ob->h + 10);
1800 int choice = fl_dopup(InsertMenu);
1803 // set the pseudo menu-button back
1804 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1805 fl_redraw_object(ob);
1807 if (men->currentView()->available()){
1808 men->currentView()->hideCursor();
1810 case 1: tmpfunc->Dispatch(LFUN_FIGURE); break;
1811 case 2: tmpfunc->Dispatch(LFUN_TABLE); break;
1812 case 3: tmpfunc->Dispatch(LFUN_CHILDINSERT); break;
1813 case 4: // Insert ASCII file submenu
1815 case 5: tmpfunc->Dispatch(LFUN_FILE_INSERT); break;
1816 case 41: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "line"); break;
1817 case 42: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "paragraph"); break;
1821 case 6: tmpfunc->Dispatch(LFUN_INSET_EXTERNAL); break;
1823 case 7: tmpfunc->Dispatch(LFUN_FOOTMELT); break
1825 case 8: tmpfunc->Dispatch(LFUN_MARGINMELT); break;
1827 case 9: // Float sub-menu
1829 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure");
1832 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table");
1835 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig");
1838 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab");
1841 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm");
1844 case 10: // Table/List submenu
1846 case 21: tmpfunc->Dispatch(LFUN_TOC_INSERT); break;
1847 case 22: tmpfunc->Dispatch(LFUN_LOF_INSERT); break;
1848 case 23: tmpfunc->Dispatch(LFUN_LOT_INSERT); break;
1849 case 24: tmpfunc->Dispatch(LFUN_LOA_INSERT); break;
1850 case 25: tmpfunc->Dispatch(LFUN_INDEX_PRINT); break;
1851 case 26: tmpfunc->Dispatch(LFUN_INSERT_BIBTEX); break;
1853 case 11: // Special Character submenu
1855 case 31: tmpfunc->Dispatch(LFUN_HFILL); break;
1856 case 32: tmpfunc->Dispatch(LFUN_HYPHENATION); break;
1857 case 33: tmpfunc->Dispatch(LFUN_PROTECTEDSPACE); break;
1858 case 34: tmpfunc->Dispatch(LFUN_BREAKLINE); break;
1859 case 35: tmpfunc->Dispatch(LFUN_LDOTS); break;
1860 case 36: tmpfunc->Dispatch(LFUN_END_OF_SENTENCE); break;
1861 case 37: tmpfunc->Dispatch(LFUN_QUOTE); break;
1862 case 38: tmpfunc->Dispatch(LFUN_MENU_SEPARATOR); break;
1864 case 12: tmpfunc->Dispatch(LFUN_INSERT_NOTE); break;
1865 case 13: tmpfunc->Dispatch(LFUN_INSERT_LABEL); break;
1866 case 14: tmpfunc->Dispatch(LFUN_INSERT_REF); break;
1867 case 15: tmpfunc->Dispatch(LFUN_CREATE_CITATION); break;
1868 case 16: tmpfunc->Dispatch(LFUN_INDEX_INSERT); break;
1869 case 17: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break;
1870 case 18: tmpfunc->Dispatch(LFUN_URL); break;
1873 fl_freepup(InsertMenu);
1874 fl_freepup(SubInsertAscii);
1875 fl_freepup(SubInsertTableList);
1876 fl_freepup(SubInsertFloatList);
1877 fl_freepup(SubInsertSpecial);
1881 void Menus::ShowMathMenu(FL_OBJECT * ob, long)
1883 extern void math_insert_symbol(char const * s);
1885 Menus * men = static_cast<Menus*>(ob->u_vdata);
1887 // set the pseudo menu-button
1888 fl_set_object_boxtype(ob, FL_UP_BOX);
1889 fl_set_button(ob, 0);
1890 fl_redraw_object(ob);
1892 Buffer * tmpbuffer = men->_view->buffer();
1893 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1895 int MathMenu = fl_defpup(FL_ObjWin(ob),
1906 fl_setpup_shortcut(MathMenu, 1, scex(_("MM|Ff#f#F")));
1907 fl_setpup_shortcut(MathMenu, 2, scex(_("MM|Ss#s#S")));
1908 fl_setpup_shortcut(MathMenu, 3, scex(_("MM|Ee#e#E")));
1909 fl_setpup_shortcut(MathMenu, 4, scex(_("MM|xX#x#X")));
1910 fl_setpup_shortcut(MathMenu, 5, scex(_("MM|uU#u#U")));
1911 fl_setpup_shortcut(MathMenu, 6, scex(_("MM|Ii#i#I")));
1912 fl_setpup_shortcut(MathMenu, 7, scex(_("MM|Mm#m#M")));
1913 fl_setpup_shortcut(MathMenu, 8, scex(_("MM|Dd#d#D")));
1914 fl_setpup_shortcut(MathMenu, 9, scex(_("MM|Pp#p#P")));
1916 if (tmpbuffer->isReadonly())
1917 for (int ii = 1; ii <= 9; ++ii)
1918 fl_setpup_mode(MathMenu, ii, FL_PUP_GREY);
1922 men->_view->getForm()->x + ob->x,
1923 men->_view->getForm()->y + ob->y + ob->h + 10);
1924 int choice = fl_dopup(MathMenu);
1927 // set the pseudo menu-button back
1928 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1929 fl_redraw_object(ob);
1931 if (men->currentView()->available()) {
1934 tmpfunc->Dispatch(LFUN_INSERT_MATH, "frac");
1937 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
1939 case 3: /* Exponent */
1940 tmpfunc->Dispatch(LFUN_INSERT_MATH, "^");
1943 tmpfunc->Dispatch(LFUN_INSERT_MATH, "_");
1946 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sum");
1949 tmpfunc->Dispatch(LFUN_INSERT_MATH, "int");
1952 tmpfunc->Dispatch(LFUN_MATH_MODE);
1955 tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
1958 show_symbols_form(tmpfunc);
1961 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR);
1963 fl_freepup(MathMenu);
1967 void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
1969 Menus * men = static_cast<Menus*>(ob->u_vdata);
1971 // set the pseudo menu-button
1972 fl_set_object_boxtype(ob, FL_UP_BOX);
1973 fl_set_button(ob, 0);
1974 fl_redraw_object(ob);
1976 //Buffer *tmpbuffer = men->_view->currentBuffer();
1977 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1979 int OptionsMenu = fl_defpup(FL_ObjWin(ob),
1981 "|Spellchecker Options..."
1987 fl_setpup_shortcut(OptionsMenu, 1, scex(_("OM|Ff#f#F")));
1988 fl_setpup_shortcut(OptionsMenu, 2, scex(_("OM|Ss#s#S")));
1989 fl_setpup_shortcut(OptionsMenu, 3, scex(_("OM|Kk#k#K")));
1990 fl_setpup_shortcut(OptionsMenu, 4, scex(_("OM|Ll#l#L")));
1991 fl_setpup_shortcut(OptionsMenu, 5, scex(_("OM|Rr#r#R")));
1992 fl_setpup_shortcut(OptionsMenu, 6, scex(_("OM|Pp#p#P")));
1994 if(lyxrc.isp_command == "none")
1995 fl_setpup_mode(OptionsMenu, 2, FL_PUP_GREY);
1998 men->_view->getForm()->x + ob->x,
1999 men->_view->getForm()->y + ob->y + ob->h + 10);
2000 int choice = fl_dopup(OptionsMenu);
2003 // set the pseudo menu-button back
2004 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2005 fl_redraw_object(ob);
2007 case 1: men->ScreenOptions(); break;
2008 case 2: SpellCheckerOptions(); break;
2009 case 3: men->_view->getIntl()->MenuKeymap(); break;
2010 case 4: LaTeXOptions(men->_view->view()); break;
2011 case 5: tmpfunc->Dispatch(LFUN_RECONFIGURE); break;
2012 case 6: men->_view->getDialogs()->showPreferences(); break;
2015 fl_freepup(OptionsMenu);
2019 void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
2021 Menus * men = static_cast<Menus*>(ob->u_vdata);
2023 // set the pseudo menu-button
2024 fl_set_object_boxtype(ob, FL_UP_BOX);
2025 fl_set_button(ob, 0);
2026 fl_redraw_object(ob);
2028 int BufferMenu = fl_newpup(FL_ObjWin(ob));
2029 vector<string> namevec = bufferlist.getFileNames();
2030 if (namevec.size() != 0) {
2031 for (vector<string>::const_iterator cit = namevec.begin();
2032 cit != namevec.end(); ++cit) {
2033 string relbuf = MakeDisplayPath((*cit), 30);
2034 fl_addtopup(BufferMenu, relbuf.c_str());
2037 fl_addtopup(BufferMenu, _("No Documents Open!%t"));
2041 men->_view->getForm()->x + ob->x,
2042 men->_view->getForm()->y + ob->y + ob->h + 10);
2043 int choice = fl_dopup(BufferMenu);
2046 // set the pseudo menu-button back
2047 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2048 fl_redraw_object(ob);
2049 if (choice > 0) men->handleBufferMenu(choice - 1);
2051 fl_freepup(BufferMenu);
2056 char const * doc_files [] = {"Intro", "Tutorial",
2057 "UserGuide", "Extended",
2058 "Customization", "Reference",
2060 "BUGS", "LyXConfig"};
2062 void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
2064 Menus * men = static_cast<Menus*>(ob->u_vdata);
2065 LyXFunc * tmpfunc = men->_view->getLyXFunc();
2067 // set the pseudo menu-button
2068 fl_set_object_boxtype(ob, FL_UP_BOX);
2069 fl_set_button(ob, 0);
2070 fl_redraw_object(ob);
2072 int HelpMenu = fl_defpup(FL_ObjWin(ob),
2076 "|Extended Features"
2080 "|Table of Contents"
2082 "|LaTeX Configuration%l"
2083 "|Copyright and Warranty..."
2087 fl_setpup_shortcut(HelpMenu, 1, scex(_("HM|Ii#I#i")));
2088 fl_setpup_shortcut(HelpMenu, 2, scex(_("HM|Tt#T#t")));
2089 fl_setpup_shortcut(HelpMenu, 3, scex(_("HM|Uu#U#u")));
2090 fl_setpup_shortcut(HelpMenu, 4, scex(_("HM|xX#x#X")));
2091 fl_setpup_shortcut(HelpMenu, 5, scex(_("HM|Cc#C#c")));
2092 fl_setpup_shortcut(HelpMenu, 6, scex(_("HM|Rr#R#r")));
2093 fl_setpup_shortcut(HelpMenu, 7, scex(_("HM|Ff#F#f")));
2094 fl_setpup_shortcut(HelpMenu, 8, scex(_("HM|aA#a#A")));
2095 fl_setpup_shortcut(HelpMenu, 9, scex(_("HM|Kk#K#k")));
2096 fl_setpup_shortcut(HelpMenu, 10, scex(_("HM|Ll#L#l")));
2097 fl_setpup_shortcut(HelpMenu, 11, scex(_("HM|oO#o#O")));
2098 fl_setpup_shortcut(HelpMenu, 12, scex(_("HM|eE#e#E")));
2099 fl_setpup_shortcut(HelpMenu, 13, scex(_("HM|Vv#v#V")));
2102 men->_view->getForm()->x + ob->x,
2103 men->_view->getForm()->y + ob->y + ob->h + 10);
2104 int choice = fl_dopup(HelpMenu);
2107 // set the pseudo menu-button back
2108 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2109 fl_redraw_object(ob);
2112 case 1: case 2: case 3: case 4: case 5:
2113 case 6: case 7: case 8: case 9: case 10:
2114 ProhibitInput(men->currentView());
2115 men->MenuDocu(doc_files[choice - 1]);
2116 AllowInput(men->currentView());
2118 case 11: tmpfunc->Dispatch(LFUN_HELP_COPYRIGHT); break;
2119 case 12: ShowCredits(); break;
2121 ProhibitInput(men->currentView());
2122 fl_show_message((string(_("LyX Version ")) + LYX_VERSION
2123 + _(" of ") + LYX_RELEASE).c_str(),
2124 (_("Library directory: ")
2125 + MakeDisplayPath(system_lyxdir)).c_str(),
2126 (_("User directory: ")
2127 + MakeDisplayPath(user_lyxdir)).c_str());
2128 AllowInput(men->currentView());
2131 fl_freepup(HelpMenu);
2135 void Menus::MenuDocu(string const & docname)
2137 string fname = i18nLibFileSearch("doc", docname, "lyx");
2138 if (fname.empty()) {
2139 WriteAlert(_("Error!"),
2140 _("Could not find requested Documentation file"),
2144 _view->getMiniBuffer()->Set(_("Opening help file"),
2145 MakeDisplayPath(fname), "...");
2146 currentView()->buffer(bufferlist.loadLyXFile(fname, false));
2148 if (docname == "Reference")
2149 _view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
2153 void Menus::handleBufferMenu(int choice)
2155 currentView()->buffer(bufferlist.getBuffer(choice));