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"
61 extern FD_form_screen * fd_form_screen;
62 extern BufferList bufferlist;
64 // I would really prefere to see most or all of these 'extern's disappear.
65 // Their commands should be called through LyXFunc (IMO). (Lgb)
67 extern void MenuLayoutSave();
68 extern void ShowCredits();
69 extern void ShowCopyright();
70 extern void show_symbols_form(LyXFunc *);
71 extern void LaTeXOptions(BufferView *);
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);
459 void Menus::ScreenOptions()
461 static int ow = -1, oh;
463 // this is not very nice....
464 fl_set_input(fd_form_screen->input_roman,
465 lyxrc.roman_font_name.c_str());
466 fl_set_input(fd_form_screen->input_sans,
467 lyxrc.sans_font_name.c_str());
468 fl_set_input(fd_form_screen->input_typewriter,
469 lyxrc.typewriter_font_name.c_str());
470 fl_set_input(fd_form_screen->input_font_norm,
471 lyxrc.font_norm.c_str());
473 sprintf(tmpstring, "%d", lyxrc.zoom);
474 fl_set_input(fd_form_screen->intinput_size, tmpstring);
475 if (fd_form_screen->form_screen->visible) {
476 fl_raise_form(fd_form_screen->form_screen);
478 fl_show_form(fd_form_screen->form_screen,
479 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
480 _("Screen Options"));
482 ow = fd_form_screen->form_screen->w;
483 oh = fd_form_screen->form_screen->h;
485 fl_set_form_minsize(fd_form_screen->form_screen, ow, oh);
491 // Here comes all the menu callbacks.
494 void Menus::ShowFileMenu(FL_OBJECT * ob, long)
496 Menus * men = static_cast<Menus*>(ob->u_vdata);
498 // Regarding the pseudo-menu-button:
499 // ok, ok this is a hack. It would be better to use the menus of the
500 // xforms 0.8 library. but then all popups have to be defined all the
501 // time, code rewriting would be necessary and contex-depending menus
502 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
503 // course it would be more proper (and little faster). So if anybody
504 // likes to do the cleanup, just do it. Matthias
506 // set the pseudo menu-button
507 fl_set_object_boxtype(ob, FL_UP_BOX);
508 fl_set_button(ob, 0);
509 fl_redraw_object(ob);
511 Buffer * tmpbuffer = men->_view->buffer();
512 LyXFunc * tmpfunc = men->_view->getLyXFunc();
514 bool LinuxDoc = tmpbuffer->isLinuxDoc();
515 bool DocBook = tmpbuffer->isDocBook();
516 bool Literate = tmpbuffer->isLiterate();
520 int SubFileImport = fl_defpup(FL_ObjWin(ob),
523 "|Ascii Text as Lines...%x31"
524 "|Ascii Text as Paragraphs%x32"
528 fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
529 fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
530 fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
531 fl_setpup_shortcut(SubFileImport, 33, scex(_("FIM|Nn#n#N")));
532 fl_setpup_shortcut(SubFileImport, 34, scex(_("FIM|Dd#d#D")));
536 // remember to make this handle linuxdoc too.
537 // and now docbook also.
538 int SubFileExport = 0;
539 if (!LinuxDoc && !DocBook)
540 SubFileExport= fl_defpup(FL_ObjWin(ob),
544 "|as PostScript...%x42"
545 "|as Ascii Text...%x43"
549 SubFileExport= fl_defpup(FL_ObjWin(ob),
551 "|as LinuxDoc...%x40"
553 "|as PostScript...%x42"
554 "|as Ascii Text...%x43"
557 SubFileExport= fl_defpup(FL_ObjWin(ob),
561 "|as PostScript...%x42"
562 "|as Ascii Text...%x43"
565 fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
566 fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
567 fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
568 fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
569 fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
571 if (!LinuxDoc && !DocBook) {
572 fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
575 int FileMenu = fl_defpup(FL_ObjWin(ob),
577 "|New from template..."
591 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
592 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
593 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
594 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Cc#c#C")));
595 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|Ss#s#S")));
596 fl_setpup_shortcut(FileMenu, 6, scex(_("FM|Aa#a#A")));
597 fl_setpup_shortcut(FileMenu, 7, scex(_("FM|Rr#r#R")));
598 fl_setpup_shortcut(FileMenu, 8, scex(_("FM|dD#d#D")));
599 fl_setpup_shortcut(FileMenu, 9, scex(_("FM|wW#w#W")));
600 fl_setpup_shortcut(FileMenu, 10, scex(_("FM|vV#v#V")));
601 fl_setpup_shortcut(FileMenu, 11, scex(_("FM|Uu#u#U")));
602 fl_setpup_shortcut(FileMenu, 12, scex(_("FM|Bb#b#B")));
603 fl_setpup_shortcut(FileMenu, 13, scex(_("FM|Pp#p#P")));
604 fl_setpup_shortcut(FileMenu, 14, scex(_("FM|Ff#f#F")));
606 // These commands are disabled when the corresponding programs
607 // are not installed. I simply grey them out, since I do not
608 // want to change their number (JMarc)
609 bool hasLaTeX = lyxrc.latex_command != "none";
611 if (!hasLaTeX || lyxrc.view_dvi_command == "none")
612 fl_setpup_mode(FileMenu, 8, FL_PUP_GREY);
614 if (!hasLaTeX || lyxrc.view_ps_command == "none")
615 fl_setpup_mode(FileMenu, 9, FL_PUP_GREY);
618 fl_setpup_mode(FileMenu, 10, FL_PUP_GREY);
619 fl_setpup_mode(FileMenu, 11, FL_PUP_GREY);
622 if (lyxrc.literate_command == "none" || ! Literate)
623 fl_setpup_mode(FileMenu, 12, FL_PUP_GREY);
625 if (!hasLaTeX || lyxrc.print_command == "none")
626 fl_setpup_mode(FileMenu, 13, FL_PUP_GREY);
628 if (!hasLaTeX || lyxrc.fax_command == "none")
629 fl_setpup_mode(FileMenu, 14, FL_PUP_GREY);
631 bool hasReLyX = lyxrc.relyx_command != "none";
633 // Disable import LaTeX and Noweb
634 fl_setpup_mode(SubFileImport, 30, FL_PUP_GREY);
635 fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
638 if ( lyxrc.linuxdoc_to_lyx_command == "none")
639 fl_setpup_mode(SubFileImport, 34, FL_PUP_GREY);
642 // Disable export dvi and export postscript
643 fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
644 fl_setpup_mode(SubFileExport, 42, FL_PUP_GREY);
647 if ((!LinuxDoc && !DocBook && lyxrc.html_command == "none") ||
648 ( LinuxDoc && lyxrc.linuxdoc_to_html_command == "none") ||
649 ( DocBook && lyxrc.docbook_to_html_command == "none")) {
650 // Disable export HTML
651 fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
654 // xgettext:no-c-format
655 fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
656 // xgettext:no-c-format
657 fl_addtopup(FileMenu, _("|Export%m%l"), SubFileExport);
658 // xgettext:no-c-format
659 fl_addtopup(FileMenu, _("|Exit%l"));
660 fl_setpup_shortcut(FileMenu, 15, scex(_("FM|Ii#i#I")));
661 fl_setpup_shortcut(FileMenu, 16, scex(_("FM|Ee#e#E")));
662 fl_setpup_shortcut(FileMenu, 17, scex(_("FM|xX#x#X")));
664 // make the lastfiles menu
666 for (LastFiles::const_iterator cit = lastfiles->begin();
667 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
668 string tmp = tostr(ii);
669 string tmp2 = tmp + "#" + tmp;
670 tmp += ". " + MakeDisplayPath((*cit), 30);
671 fl_addtopup(FileMenu, tmp.c_str());
672 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
677 men->_view->getForm()->x + ob->x,
678 men->_view->getForm()->y + ob->y + ob->h + 10);
679 int choice = fl_dopup(FileMenu);
682 // set the pseudo menu-button back
683 fl_set_object_boxtype(ob, FL_FLAT_BOX);
684 fl_redraw_object(ob);
687 case -1: case 0: // we won't do anything
689 case 1: tmpfunc->Dispatch(LFUN_MENUNEW); break;
690 case 2: tmpfunc->Dispatch(LFUN_MENUNEWTMPLT); break;
691 case 3: tmpfunc->Dispatch(LFUN_MENUOPEN); break;
692 case 4: tmpfunc->Dispatch(LFUN_CLOSEBUFFER); break;
693 case 5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
694 case 6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
695 case 7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
696 case 8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
697 case 9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
698 case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
699 case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
700 case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
701 case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
702 case 14: tmpfunc->Dispatch(LFUN_FAX); break;
703 case 15: // import menu
704 case 30: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
706 case 31: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
708 case 32: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
710 case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
712 case 34: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
714 case 16: // export menu
716 if (!LinuxDoc && !DocBook)
717 tmpfunc->Dispatch(LFUN_EXPORT, "latex");
719 tmpfunc->Dispatch(LFUN_EXPORT, "linuxdoc");
721 tmpfunc->Dispatch(LFUN_EXPORT, "docbook");
723 case 41: tmpfunc->Dispatch(LFUN_EXPORT, "dvi");
725 case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
727 case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
730 if (!LinuxDoc && !DocBook)
731 tmpfunc->Dispatch(LFUN_EXPORT, "html");
733 tmpfunc->Dispatch(LFUN_EXPORT, "html-linuxdoc");
735 tmpfunc->Dispatch(LFUN_EXPORT, "html-docbook");
737 case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
739 case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
741 case 18: // The first item with lastfiles.
745 .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));
912 if (men->currentView()->available() &&
913 men->currentView()->text->cursor.par->table &&
914 !tmpbuffer->isReadonly()){
915 LyXTable *table = men->currentView()->text->cursor.par->table;
917 fl_addtopup(SubEditTable, _("Table%t"));
919 if (table->IsMultiColumn(men->currentView()->text->
920 NumberOfCell(men->currentView()->
924 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
926 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
927 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
929 if (table->TopLine(men->currentView()->text->
930 NumberOfCell(men->currentView()->
932 men->currentView()->text->
934 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
936 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
937 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
939 if (table->BottomLine(men->currentView()->text->
940 NumberOfCell(men->currentView()->
944 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
946 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
947 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
949 if (table->LeftLine(men->currentView()->text->
950 NumberOfCell(men->currentView()->
954 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
956 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
957 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
959 if (table->RightLine(men->currentView()->text->
960 NumberOfCell(men->currentView()->
964 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
966 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
967 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
970 table->GetAlignment(men->currentView()->text->
971 NumberOfCell(men->currentView()->
975 if (align == LYX_ALIGN_LEFT)
976 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
978 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
979 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
981 if (align == LYX_ALIGN_RIGHT)
982 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
984 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
985 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
987 if (align == LYX_ALIGN_CENTER)
988 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
990 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
991 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
993 // xgettext:no-c-format
994 fl_addtopup(SubEditTable, _("|Append Row%x32"));
995 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
996 // xgettext:no-c-format
997 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
998 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
999 // xgettext:no-c-format
1000 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
1001 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
1002 // xgettext:no-c-format
1003 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
1004 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
1005 // xgettext:no-c-format
1006 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
1007 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
1008 } else if (men->currentView()->the_locking_inset &&
1009 (men->currentView()->the_locking_inset->LyxCode() ==
1010 Inset::TABULAR_CODE) &&
1011 !tmpbuffer->isReadonly()) {
1012 InsetTabular * inset = static_cast<InsetTabular *>(men->currentView()->the_locking_inset);
1013 LyXTabular * table = inset->tabular;
1015 fl_addtopup(SubEditTable, _("Table%t"));
1017 if (table->IsMultiColumn(inset->GetActCell()))
1018 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
1020 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
1021 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
1023 if (table->TopLine(inset->GetActCell()))
1024 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
1026 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
1027 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
1029 if (table->BottomLine(inset->GetActCell()))
1030 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
1032 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
1033 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
1035 if (table->LeftLine(inset->GetActCell()))
1036 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
1038 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
1039 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
1041 if (table->RightLine(inset->GetActCell()))
1042 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
1044 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
1045 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
1047 int align = table->GetAlignment(inset->GetActCell());
1048 if (align == LYX_ALIGN_LEFT)
1049 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
1051 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
1052 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
1054 if (align == LYX_ALIGN_RIGHT)
1055 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
1057 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
1058 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
1060 if (align == LYX_ALIGN_CENTER)
1061 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
1063 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
1064 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
1066 // xgettext:no-c-format
1067 fl_addtopup(SubEditTable, _("|Append Row%x32"));
1068 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
1069 // xgettext:no-c-format
1070 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
1071 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
1072 // xgettext:no-c-format
1073 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
1074 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
1075 // xgettext:no-c-format
1076 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
1077 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
1078 // xgettext:no-c-format
1079 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
1080 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
1082 fl_addtopup(SubEditTable, _("Table%t"));
1083 // xgettext:no-c-format
1084 fl_addtopup(SubEditTable, _("|Insert table%x31"));
1085 fl_setpup_shortcut(SubEditTable, 31, scex(_("EMT|Ii#i#I")));
1088 int SubVersionControl = fl_newpup(FL_ObjWin(ob));
1089 fl_addtopup(SubVersionControl, _("Version Control%t"));
1090 if (tmpbuffer->lyxvc.inUse()) {
1091 // xgettext:no-c-format
1092 fl_addtopup(SubVersionControl, _("|Register%d%x51"));
1093 if (tmpbuffer->isReadonly()) {
1094 // signifies that the file is not checked out
1095 // xgettext:no-c-format
1096 fl_addtopup(SubVersionControl, _("|Check In Changes%d%x52"));
1097 // xgettext:no-c-format
1098 fl_addtopup(SubVersionControl, _("|Check Out for Edit%x53"));
1100 // signifies that the file is checked out
1101 // xgettext:no-c-format
1102 fl_addtopup(SubVersionControl, _("|Check In Changes%x52"));
1103 // xgettext:no-c-format
1104 fl_addtopup(SubVersionControl, _("|Check Out for Edit%d%x53"));
1106 // xgettext:no-c-format
1107 fl_addtopup(SubVersionControl, _("|Revert to last version%x54"));
1108 // xgettext:no-c-format
1109 fl_addtopup(SubVersionControl, _("|Undo last check in%x55"));
1110 // xgettext:no-c-format
1111 fl_addtopup(SubVersionControl, _("|Show History%x56"));
1113 // xgettext:no-c-format
1114 fl_addtopup(SubVersionControl, _("|Register%x51"));
1116 // the shortcuts are not good.
1117 fl_setpup_shortcut(SubVersionControl, 51, scex(_("EMV|Rr#r#R")));
1118 fl_setpup_shortcut(SubVersionControl, 52, scex(_("EMV|Ii#i#I")));
1119 fl_setpup_shortcut(SubVersionControl, 53, scex(_("EMV|Oo#o#O")));
1120 fl_setpup_shortcut(SubVersionControl, 54, scex(_("EMV|lL#l#l")));
1121 fl_setpup_shortcut(SubVersionControl, 55, scex(_("EMV|Uu#u#U")));
1122 fl_setpup_shortcut(SubVersionControl, 56, scex(_("EMV|Hh#h#H")));
1124 int EditMenu= fl_defpup(FL_ObjWin(ob),
1130 "|Find & Replace..."
1133 "|Floats & Insets%m"
1137 "|Table of Contents..."
1138 "|List of Figures..."
1139 "|List of Tables..."
1140 "|List of Algorithms...%l"
1141 "|Version Control%m%l"
1142 "|View LaTeX log file%l"
1143 "|Paste Primary Selection as Lines"
1144 "|Paste Primary Selection as Paragraphs"),
1145 SubEditFloats, SubEditTable, SubVersionControl);
1147 fl_setpup_shortcut(EditMenu, 1, scex(_("EM|Uu#u#U")));
1148 fl_setpup_shortcut(EditMenu, 2, scex(_("EM|Rr#r#R")));
1149 fl_setpup_shortcut(EditMenu, 3, scex(_("EM|Cc#c#C")));
1150 fl_setpup_shortcut(EditMenu, 4, scex(_("EM|oO#o#O")));
1151 fl_setpup_shortcut(EditMenu, 5, scex(_("EM|Pp#p#P")));
1152 fl_setpup_shortcut(EditMenu, 6, scex(_("EM|Ff#f#F")));
1153 fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
1154 fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
1155 fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
1156 //fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
1157 fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
1158 fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
1159 fl_setpup_shortcut(EditMenu, 13, scex(_("EM|Tt#t#T")));
1160 //fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Ff#f#F")));
1161 //fl_setpup_shortcut(EditMenu, 15, scex(_("EM|bB#b#B")));
1162 //fl_setpup_shortcut(EditMenu, 16, scex(_("EM|mM#m#M")));
1163 fl_setpup_shortcut(EditMenu, 17, scex(_("EM|Vv#v#V")));
1164 fl_setpup_shortcut(EditMenu, 18, scex(_("EM|wW#w#W")));
1165 fl_setpup_shortcut(EditMenu, 19, scex(_("EM|Ll#l#L")));
1166 fl_setpup_shortcut(EditMenu, 20, scex(_("EM|gG#g#G")));
1168 // disable unavailable entries.
1169 if(tmpbuffer->undostack.empty())
1170 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1171 if(tmpbuffer->redostack.empty())
1172 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1173 if(lyxrc.isp_command == "none")
1174 fl_setpup_mode(EditMenu, 11, FL_PUP_GREY);
1175 if(lyxrc.chktex_command == "none")
1176 fl_setpup_mode(EditMenu, 12, FL_PUP_GREY);
1178 if (tmpbuffer->isReadonly()) {
1179 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1180 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1181 fl_setpup_mode(EditMenu, 3, FL_PUP_GREY);
1182 fl_setpup_mode(EditMenu, 5, FL_PUP_GREY);
1183 fl_setpup_mode(EditMenu, 19, FL_PUP_GREY);
1184 fl_setpup_mode(EditMenu, 20, FL_PUP_GREY);
1187 fl_setpup_position(men->_view->getForm()->x + ob->x,
1188 men->_view->getForm()->y + ob->y +
1190 int choice = fl_dopup(EditMenu);
1193 // set the pseudo menu-button back
1194 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1195 fl_redraw_object(ob);
1198 case 1: tmpfunc->Dispatch(LFUN_UNDO); break;
1199 case 2: tmpfunc->Dispatch(LFUN_REDO); break;
1200 case 3: tmpfunc->Dispatch(LFUN_CUT); break;
1201 case 4: tmpfunc->Dispatch(LFUN_COPY); break;
1202 case 5: tmpfunc->Dispatch(LFUN_PASTE); break;
1203 case 6: tmpfunc->Dispatch(LFUN_MENUSEARCH); break;
1204 case 7: tmpfunc->Dispatch(LFUN_GOTOERROR); break;
1205 case 8: tmpfunc->Dispatch(LFUN_GOTONOTE); break;
1206 case 9: // floats & insets
1210 case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
1211 case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
1212 case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
1213 case 14: tmpfunc->Dispatch(LFUN_LOFVIEW); break;
1214 case 15: tmpfunc->Dispatch(LFUN_LOTVIEW); break;
1215 case 16: tmpfunc->Dispatch(LFUN_LOAVIEW); break;
1216 case 17: // version control
1218 case 18: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
1219 case 19: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
1220 case 20: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
1222 // floats & insets sub-menu
1223 case 21: men->currentView()->toggleFloat(); break;
1224 case 22: tmpfunc->Dispatch(LFUN_MELT); break;
1225 case 23: men->currentView()->allFloats(1, 0); break;
1226 case 24: men->currentView()->allFloats(0, 0); break;
1227 case 25: men->currentView()->allFloats(1, 1); break;
1228 case 26: men->currentView()->allFloats(0, 1); break;
1229 case 27: tmpfunc->Dispatch(LFUN_REMOVEERRORS); break;
1231 case 31: tmpfunc->Dispatch(LFUN_TABLE); break;
1232 // this is really temporary. We need new function in keybind.C
1233 // These should set the minibuffer, too.
1234 case 32: case 33: case 34:
1235 case 35: case 36: case 37:
1236 case 38: case 39: case 40:
1237 case 41: case 42: case 43:
1239 if (men->currentView()->available()) {
1240 men->currentView()->hideCursor();
1241 if (!men->currentView()->text->selection){
1242 men->currentView()->beforeChange();
1243 men->currentView()->update(-2);
1245 if (men->currentView()->the_locking_inset &&
1246 (men->currentView()->the_locking_inset->LyxCode()
1247 == Inset::TABULAR_CODE)) {
1248 InsetTabular * inset =
1249 static_cast<InsetTabular *>
1250 (men->currentView()->the_locking_inset);
1251 inset->TabularFeatures(men->currentView(), choice - 32);
1253 men->currentView()->text->
1254 TableFeatures(choice - 32);
1255 men->currentView()->update(1);
1259 // version control sub-menu
1260 case 51: // register
1261 tmpfunc->Dispatch(LFUN_VC_REGISTER);
1263 case 52: // check in
1264 tmpfunc->Dispatch(LFUN_VC_CHECKIN);
1266 case 53: // check out
1267 tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
1269 case 54: // revert to last
1270 tmpfunc->Dispatch(LFUN_VC_REVERT);
1272 case 55: // undo last
1273 tmpfunc->Dispatch(LFUN_VC_UNDO);
1275 case 56: // show history
1276 tmpfunc->Dispatch(LFUN_VC_HISTORY);
1280 fl_freepup(EditMenu);
1281 fl_freepup(SubEditFloats);
1282 fl_freepup(SubEditTable);
1283 fl_freepup(SubVersionControl);
1286 vector<int>::size_type const max_number_of_menus = 32;
1287 unsigned int const max_number_of_items = 25;
1289 string Limit_string_length(string const & str) {
1290 string::size_type const max_item_length = 45;
1292 if (str.size() > max_item_length)
1293 return str.substr(0, max_item_length-3) + "...";
1298 void Add_to_toc_menu(vector<Buffer::TocItem> const & toclist,
1299 unsigned int from, unsigned int to, int depth,
1300 int menu, vector<int> & menus, FL_OBJECT * ob)
1302 if (to - from <= max_number_of_items) {
1303 for (unsigned int i = from; i < to; ++i) {
1304 string entry(4 * max(0, toclist[i].depth - depth),' ');
1305 entry += toclist[i].str;
1306 entry = Limit_string_length(entry);
1307 entry += "%x" + tostr(i + 1);
1308 fl_addtopup(menu, entry.c_str());
1311 unsigned int pos = from;
1312 unsigned int count = 0;
1315 if (count > max_number_of_items) {
1316 fl_addtopup(menu, ". . .%d");
1319 unsigned int new_pos = pos+1;
1320 while (new_pos < to &&
1321 toclist[new_pos].depth > depth)
1324 string entry(4 * max(0, toclist[pos].depth - depth), ' ');
1325 entry += toclist[pos].str;
1326 entry = Limit_string_length(entry);
1328 if (new_pos == pos + 1) {
1330 entry += tostr(pos + 1);
1331 fl_addtopup(menu, entry.c_str());
1332 } else if (menus.size() < max_number_of_menus) {
1333 int menu2 = fl_newpup(FL_ObjWin(ob));
1334 menus.push_back(menu2);
1335 Add_to_toc_menu(toclist, pos, new_pos,
1336 depth + 1, menu2, menus,ob);
1338 fl_addtopup(menu, entry.c_str(), menu2);
1341 fl_addtopup(menu, entry.c_str());
1348 int const BIG_NUM = 1048576;
1350 void Menus::ShowTocMenu(FL_OBJECT * ob, long)
1352 Menus * men = static_cast<Menus*>(ob->u_vdata);
1355 // set the pseudo menu-button
1356 fl_set_object_boxtype(ob, FL_UP_BOX);
1357 fl_set_button(ob, 0);
1358 fl_redraw_object(ob);
1360 int TocMenu = fl_newpup(FL_ObjWin(ob));
1361 menus.push_back(TocMenu);
1362 vector<vector<Buffer::TocItem> > toclist =
1363 men->currentView()->buffer()->getTocList();
1365 //xgettext:no-c-format
1366 static char const * MenuNames[3] = { N_("List of Figures%m"),
1367 //xgettext:no-c-format
1368 N_("List of Tables%m"),
1369 //xgettext:no-c-format
1370 N_("List of Algorithms%m") };
1372 int max_nonempty = 0;
1373 for (int j = 1; j <= 3; ++j)
1374 if (!toclist[j].empty())
1377 for (int j = 1; j <= 3; ++j)
1378 if (!toclist[j].empty()) {
1379 int menu2 = fl_newpup(FL_ObjWin(ob));
1380 menus.push_back(menu2);
1381 for (unsigned int i = 0; i < toclist[j].size(); ++i) {
1382 if (i > max_number_of_items) {
1383 fl_addtopup(menu2, ". . .%d");
1386 string entry = Limit_string_length(toclist[j][i].str);
1387 entry += "%x" + tostr(i+1+j*BIG_NUM);
1388 fl_addtopup(menu2, entry.c_str());
1390 if (j == max_nonempty) {
1391 string tmp = _(MenuNames[j-1]);
1393 fl_addtopup(TocMenu, tmp.c_str(), menu2);
1395 fl_addtopup(TocMenu, _(MenuNames[j-1]), menu2);
1398 Add_to_toc_menu(toclist[0], 0, toclist[0].size(), 0,
1399 TocMenu, menus, ob);
1402 men->_view->getForm()->x + ob->x,
1403 men->_view->getForm()->y + ob->y + ob->h + 10);
1404 int choice = fl_dopup(TocMenu);
1407 // set the pseudo menu-button back
1408 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1409 fl_redraw_object(ob);
1411 men->_view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
1412 else if (choice > 0) {
1413 int type = choice / BIG_NUM;
1414 int num = (choice % BIG_NUM) - 1;
1415 BufferView *bv = men->currentView();
1417 bv->text->SetCursor(toclist[type][num].par, 0);
1418 bv->text->sel_cursor = bv->text->cursor;
1421 for (unsigned int i = 0; i < menus.size(); ++i)
1422 fl_freepup(menus[i]);
1425 void Add_to_refs_menu(vector<string> const & label_list, int offset,
1426 int menu, vector<int> & menus, FL_OBJECT * ob)
1428 typedef vector<string>::size_type size_type;
1429 size_type const max_number_of_items = 25;
1430 size_type const max_number_of_items2 = 20;
1431 string::size_type const max_item_length = 40;
1432 string::size_type const max_item_length2 = 20;
1434 if (label_list.size() <= max_number_of_items)
1435 for (size_type i = 0; i < label_list.size(); ++i) {
1436 string entry = label_list[i];
1437 if (entry.size() > max_item_length)
1438 entry = entry.substr(0, max_item_length-1) + "$";
1439 entry += "%x" + tostr(i+offset);
1440 fl_addtopup(menu, entry.c_str());
1443 size_type count = 0;
1444 for (size_type i = 0; i < label_list.size();
1445 i += max_number_of_items2) {
1447 if (count > max_number_of_items) {
1448 fl_addtopup(menu, ". . .%d");
1451 size_type j = min(label_list.size(),
1452 i+max_number_of_items2);
1455 if (label_list[i].size() > max_item_length2)
1456 entry += label_list[i].substr(0, max_item_length2-1) + "$";
1458 entry += label_list[i];
1460 if (label_list[j-1].size() > max_item_length2)
1461 entry += label_list[j-1].substr(0, max_item_length2-1) + "$";
1463 entry += label_list[j-1];
1465 if (menus.size() < max_number_of_menus) {
1466 int menu2 = fl_newpup(FL_ObjWin(ob));
1467 menus.push_back(menu2);
1468 for (size_type k = i; k < j; ++k) {
1469 string entry2 = label_list[k];
1470 if (entry2.size() > max_item_length)
1471 entry2 = entry2.substr(0, max_item_length-1) + "$";
1472 entry2 += "%x" + tostr(k+offset);
1473 fl_addtopup(menu2, entry2.c_str());
1476 fl_addtopup(menu, entry.c_str(), menu2);
1479 fl_addtopup(menu, entry.c_str());
1485 void Menus::ShowRefsMenu(FL_OBJECT * ob, long)
1489 Menus * men = static_cast<Menus*>(ob->u_vdata);
1491 // set the pseudo menu-button
1492 fl_set_object_boxtype(ob, FL_UP_BOX);
1493 fl_set_button(ob, 0);
1494 fl_redraw_object(ob);
1496 int RefsMenu = fl_newpup(FL_ObjWin(ob));
1497 menus.push_back(RefsMenu);
1498 Buffer * buffer = men->currentView()->buffer();
1499 vector<string> label_list = buffer->getLabelList();
1500 sort(label_list.begin(), label_list.end());
1502 //xgettext:no-c-format
1503 static char const * MenuNames[6] = { N_("Insert Reference%m"),
1504 //xgettext:no-c-format
1505 N_("Insert Page Number%m"),
1506 //xgettext:no-c-format
1507 N_("Insert vref%m"),
1508 //xgettext:no-c-format
1509 N_("Insert vpageref%m"),
1510 //xgettext:no-c-format
1511 N_("Insert Pretty Ref%m"),
1512 //xgettext:no-c-format
1513 N_("Goto Reference%m") };
1515 for (int j = 0; j < 6; ++j) {
1516 if (menus.size() < max_number_of_menus) {
1517 int menu2 = fl_newpup(FL_ObjWin(ob));
1518 menus.push_back(menu2);
1519 Add_to_refs_menu(label_list, (j+1)*BIG_NUM, menu2, menus, ob);
1520 fl_addtopup(RefsMenu, _(MenuNames[j]), menu2);
1522 string tmp = _(MenuNames[j]);
1524 fl_addtopup(RefsMenu, tmp.c_str());
1527 fl_addtopup(RefsMenu, _("Go Back"));
1529 bool empty = label_list.empty();
1530 bool sgml = buffer->isSGML();
1531 bool readonly = buffer->isReadonly();
1534 fl_setpup_mode(RefsMenu, 6, FL_PUP_GREY);
1535 if (empty || readonly) {
1536 fl_setpup_mode(RefsMenu, 1, FL_PUP_GREY);
1537 fl_setpup_mode(RefsMenu, 2, FL_PUP_GREY);
1539 if (empty || readonly || sgml) {
1540 fl_setpup_mode(RefsMenu, 3, FL_PUP_GREY);
1541 fl_setpup_mode(RefsMenu, 4, FL_PUP_GREY);
1542 fl_setpup_mode(RefsMenu, 5, FL_PUP_GREY);
1544 if (men->currentView()->NoSavedPositions())
1545 fl_setpup_mode(RefsMenu, 7, FL_PUP_GREY);
1548 men->_view->getForm()->x + ob->x,
1549 men->_view->getForm()->y + ob->y + ob->h + 10);
1550 int choice = fl_dopup(RefsMenu);
1553 // set the pseudo menu-button back
1554 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1555 fl_redraw_object(ob);
1558 men->_view->getLyXFunc()->Dispatch(LFUN_REFBACK);
1559 else if (choice >= BIG_NUM) {
1560 int type = (choice / BIG_NUM) - 1;
1561 int num = choice % BIG_NUM;
1563 men->_view->getLyXFunc()->Dispatch(LFUN_REFGOTO,
1564 label_list[num].c_str());
1566 static string const commands[5]
1567 = { "\\ref", "\\pageref", "\\vref", "\\vpageref",
1569 string t = commands[type] + "{" + label_list[num] + "}";
1570 men->currentView()->insertInset(new InsetRef(t, buffer));
1574 for (unsigned int i = 0; i < menus.size(); ++i)
1575 fl_freepup(menus[i]);
1579 void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
1581 Menus * men = static_cast<Menus*>(ob->u_vdata);
1583 if (!men->currentView()->available())
1586 // set the pseudo menu-button
1587 fl_set_object_boxtype(ob, FL_UP_BOX);
1588 fl_set_button(ob, 0);
1589 fl_redraw_object(ob);
1591 Buffer * tmpbuffer = men->_view->buffer();
1592 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1594 int LayoutMenu = fl_newpup(FL_ObjWin(ob));
1595 fl_addtopup(LayoutMenu, _("Character..."
1601 "|Emphasize Style%b"
1605 "|Change Environment Depth"
1606 "|LaTeX Preamble..."
1607 "|Start of Appendix%l"
1608 "|Save layout as default"));
1609 fl_setpup_shortcut(LayoutMenu, 1, scex(_("LM|Cc#c#C")));
1610 fl_setpup_shortcut(LayoutMenu, 2, scex(_("LM|Pp#p#P")));
1611 fl_setpup_shortcut(LayoutMenu, 3, scex(_("LM|Dd#d#D")));
1612 fl_setpup_shortcut(LayoutMenu, 4, scex(_("LM|aA#a#A")));
1613 fl_setpup_shortcut(LayoutMenu, 5, scex(_("LM|eE#e#E")));
1614 fl_setpup_shortcut(LayoutMenu, 6, scex(_("LM|Qq#q#Q")));
1615 fl_setpup_shortcut(LayoutMenu, 7, scex(_("LM|mM#m#M")));
1616 fl_setpup_shortcut(LayoutMenu, 8, scex(_("LM|Nn#n#N")));
1617 fl_setpup_shortcut(LayoutMenu, 9, scex(_("LM|Bb#b#B")));
1618 fl_setpup_shortcut(LayoutMenu, 10, scex(_("LM|Tt#t#T")));
1619 fl_setpup_shortcut(LayoutMenu, 11, scex(_("LM|vV#v#V")));
1620 fl_setpup_shortcut(LayoutMenu, 12, scex(_("LM|Ll#l#L")));
1621 fl_setpup_shortcut(LayoutMenu, 13, scex(_("LM|xX#x#X")));
1622 fl_setpup_shortcut(LayoutMenu, 14, scex(_("LM|Ss#s#S")));
1624 // Set values of checkboxes according to font
1625 LyXFont font = men->currentView()->text->real_current_font;
1626 if (font.emph() == LyXFont::ON)
1627 fl_setpup_mode(LayoutMenu, 7, FL_PUP_CHECK);
1628 if (font.noun() == LyXFont::ON)
1629 fl_setpup_mode(LayoutMenu, 8, FL_PUP_CHECK);
1630 if (font.series() == LyXFont::BOLD_SERIES)
1631 fl_setpup_mode(LayoutMenu, 9, FL_PUP_CHECK);
1632 if (font.latex() == LyXFont::ON)
1633 fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
1635 // Grey out unavailable entries
1636 if (!men->currentView()->text->cursor.par->table)
1637 fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
1639 if (tmpbuffer->isReadonly()) {
1640 fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
1641 fl_setpup_mode(LayoutMenu, 6, FL_PUP_GREY);
1642 fl_setpup_mode(LayoutMenu, 11, FL_PUP_GREY);
1646 men->_view->getForm()->x + ob->x,
1647 men->_view->getForm()->y + ob->y + ob->h + 10);
1648 int choice = fl_dopup(LayoutMenu);
1651 // set the pseudo menu-button back
1652 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1653 fl_redraw_object(ob);
1656 case 1: tmpfunc->Dispatch(LFUN_LAYOUT_CHARACTER); break;
1657 case 2: tmpfunc->Dispatch(LFUN_LAYOUT_PARAGRAPH); break;
1658 case 3: tmpfunc->Dispatch(LFUN_LAYOUT_DOCUMENT); break;
1659 case 4: tmpfunc->Dispatch(LFUN_LAYOUT_PAPER); break;
1660 case 5: tmpfunc->Dispatch(LFUN_LAYOUT_TABLE, "true"); break;
1661 case 6: tmpfunc->Dispatch(LFUN_LAYOUT_QUOTES); break;
1662 case 7: tmpfunc->Dispatch(LFUN_EMPH); break;
1663 case 8: tmpfunc->Dispatch(LFUN_NOUN); break;
1664 case 9: tmpfunc->Dispatch(LFUN_BOLD); break;
1665 case 10: tmpfunc->Dispatch(LFUN_TEX); break;
1666 case 11: tmpfunc->Dispatch(LFUN_DEPTH_PLUS); break;
1667 case 12: tmpfunc->Dispatch(LFUN_LAYOUT_PREAMBLE); break;
1668 case 13: tmpfunc->Dispatch(LFUN_APPENDIX); break;
1669 case 14: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;
1671 fl_freepup(LayoutMenu);
1675 void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
1677 Menus * men = static_cast<Menus*>(ob->u_vdata);
1679 // set the pseudo menu-button
1680 fl_set_object_boxtype(ob, FL_UP_BOX);
1681 fl_set_button(ob, 0);
1682 fl_redraw_object(ob);
1684 Buffer * tmpbuffer = men->_view->buffer();
1685 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1687 int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
1688 _("Import ASCII file%t"
1690 "|As Paragraphs%x42"));
1692 fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
1693 fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
1695 int SubInsertTableList= fl_defpup(FL_ObjWin(ob),
1697 "|Table of Contents%x21"
1698 "|List of Figures%x22"
1699 "|List of Tables%x23"
1700 "|List of Algorithms%x24"
1702 "|BibTeX Reference%x26"));
1704 fl_setpup_shortcut(SubInsertTableList, 21, scex(_("IMT|Cc#c#C")));
1705 fl_setpup_shortcut(SubInsertTableList, 22, scex(_("IMT|Ff#f#F")));
1706 fl_setpup_shortcut(SubInsertTableList, 23, scex(_("IMT|Tt#t#T")));
1707 fl_setpup_shortcut(SubInsertTableList, 24, scex(_("IMT|Aa#a#A")));
1708 fl_setpup_shortcut(SubInsertTableList, 25, scex(_("IMT|Ii#i#I")));
1709 fl_setpup_shortcut(SubInsertTableList, 26, scex(_("IMT|Bb#b#B")));
1711 int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
1715 "|Wide Figure Float%x73"
1716 "|Wide Table Float%l%x74"
1717 "|Algorithm Float%x75"));
1719 fl_setpup_shortcut(SubInsertFloatList, 71, scex(_("IMF|gG#g#G")));
1720 fl_setpup_shortcut(SubInsertFloatList, 72, scex(_("IMF|Tt#t#T")));
1721 fl_setpup_shortcut(SubInsertFloatList, 73, scex(_("IMF|Ww#w#W")));
1722 fl_setpup_shortcut(SubInsertFloatList, 74, scex(_("IMF|iI#i#I")));
1723 fl_setpup_shortcut(SubInsertFloatList, 75, scex(_("IMF|Aa#a#A")));
1725 int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
1726 _("Special Character%t"
1728 "|Hyphenation Point%x32"
1729 "|Protected Blank%x33"
1731 "|Ellipsis (...)%x35"
1732 "|End of sentence period%x36"
1733 "|Ordinary Quote (\")%x37"
1734 "|Menu Separator %x38"));
1736 fl_setpup_shortcut(SubInsertSpecial, 31, scex(_("IMS|Hh#h#H")));
1737 fl_setpup_shortcut(SubInsertSpecial, 32, scex(_("IMS|Pp#p#P")));
1738 fl_setpup_shortcut(SubInsertSpecial, 33, scex(_("IMS|Bb#b#B")));
1739 fl_setpup_shortcut(SubInsertSpecial, 34, scex(_("IMS|Ll#l#L")));
1740 fl_setpup_shortcut(SubInsertSpecial, 35, scex(_("IMS|iI#i#I")));
1741 fl_setpup_shortcut(SubInsertSpecial, 36, scex(_("IMS|Ee#e#E")));
1742 fl_setpup_shortcut(SubInsertSpecial, 37, scex(_("IMS|Qq#q#Q")));
1743 fl_setpup_shortcut(SubInsertSpecial, 38, scex(_("IMS|Mm#m#M")));
1745 int InsertMenu = fl_defpup(FL_ObjWin(ob),
1749 "|Import ASCII File%m"
1750 "|Insert LyX File...%l"
1755 "|Special Character%m%l"
1758 "|Cross-Reference..."
1759 "|Citation Reference..."
1761 "|Index entry of last word"),
1767 fl_setpup_shortcut(InsertMenu, 1, scex(_("IM|gG#g#G")));
1768 fl_setpup_shortcut(InsertMenu, 2, scex(_("IM|bB#b#B")));
1769 fl_setpup_shortcut(InsertMenu, 3, scex(_("IM|cC#c#C")));
1770 fl_setpup_shortcut(InsertMenu, 4, scex(_("IM|Aa#a#A")));
1771 fl_setpup_shortcut(InsertMenu, 5, scex(_("IM|Xx#x#X")));
1772 fl_setpup_shortcut(InsertMenu, 6, scex(_("IM|Ff#f#F")));
1773 fl_setpup_shortcut(InsertMenu, 7, scex(_("IM|Mm#m#M")));
1774 fl_setpup_shortcut(InsertMenu, 8, scex(_("IM|oO#o#O")));
1775 fl_setpup_shortcut(InsertMenu, 9, scex(_("IM|Tt#t#T")));
1776 fl_setpup_shortcut(InsertMenu, 10, scex(_("IM|Ss#s#S")));
1777 fl_setpup_shortcut(InsertMenu, 11, scex(_("IM|Nn#n#N")));
1778 fl_setpup_shortcut(InsertMenu, 12, scex(_("IM|Ll#l#L")));
1779 fl_setpup_shortcut(InsertMenu, 13, scex(_("IM|rR#r#R")));
1780 fl_setpup_shortcut(InsertMenu, 14, scex(_("IM|iI#i#I")));
1781 fl_setpup_shortcut(InsertMenu, 15, scex(_("IM|dD#d#D")));
1782 fl_setpup_shortcut(InsertMenu, 16, scex(_("IM|wW#w#W")));
1784 fl_addtopup(InsertMenu, _("|URL..."));
1785 fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|Uu#u#U")));
1787 if (tmpbuffer->isReadonly()) {
1788 for (int ii = 1; ii <= 16; ++ii)
1789 fl_setpup_mode(InsertMenu, ii, FL_PUP_GREY);
1790 fl_setpup_mode(InsertMenu, 17, FL_PUP_GREY);
1794 men->_view->getForm()->x + ob->x,
1795 men->_view->getForm()->y + ob->y + ob->h + 10);
1797 int choice = fl_dopup(InsertMenu);
1800 // set the pseudo menu-button back
1801 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1802 fl_redraw_object(ob);
1804 if (men->currentView()->available()){
1805 men->currentView()->hideCursor();
1807 case 1: tmpfunc->Dispatch(LFUN_FIGURE); break;
1808 case 2: tmpfunc->Dispatch(LFUN_TABLE); break;
1809 case 3: tmpfunc->Dispatch(LFUN_CHILDINSERT); break;
1810 case 4: // Insert ASCII file submenu
1812 case 5: tmpfunc->Dispatch(LFUN_FILE_INSERT); break;
1813 case 41: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "line"); break;
1814 case 42: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "paragraph"); break;
1818 case 6: tmpfunc->Dispatch(LFUN_FOOTMELT); break
1820 case 7: tmpfunc->Dispatch(LFUN_MARGINMELT); break;
1822 case 8: // Float sub-menu
1824 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure");
1827 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table");
1830 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig");
1833 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab");
1836 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm");
1839 case 9: // Table/List submenu
1841 case 21: tmpfunc->Dispatch(LFUN_TOC_INSERT); break;
1842 case 22: tmpfunc->Dispatch(LFUN_LOF_INSERT); break;
1843 case 23: tmpfunc->Dispatch(LFUN_LOT_INSERT); break;
1844 case 24: tmpfunc->Dispatch(LFUN_LOA_INSERT); break;
1845 case 25: tmpfunc->Dispatch(LFUN_INDEX_PRINT); break;
1846 case 26: tmpfunc->Dispatch(LFUN_INSERT_BIBTEX); break;
1848 case 10: // Special Character submenu
1850 case 31: tmpfunc->Dispatch(LFUN_HFILL); break;
1851 case 32: tmpfunc->Dispatch(LFUN_HYPHENATION); break;
1852 case 33: tmpfunc->Dispatch(LFUN_PROTECTEDSPACE); break;
1853 case 34: tmpfunc->Dispatch(LFUN_BREAKLINE); break;
1854 case 35: tmpfunc->Dispatch(LFUN_LDOTS); break;
1855 case 36: tmpfunc->Dispatch(LFUN_END_OF_SENTENCE); break;
1856 case 37: tmpfunc->Dispatch(LFUN_QUOTE); break;
1857 case 38: tmpfunc->Dispatch(LFUN_MENU_SEPARATOR); break;
1859 case 11: tmpfunc->Dispatch(LFUN_INSERT_NOTE); break;
1860 case 12: tmpfunc->Dispatch(LFUN_INSERT_LABEL); break;
1861 case 13: tmpfunc->Dispatch(LFUN_INSERT_REF); break;
1862 case 14: tmpfunc->Dispatch(LFUN_INSERT_CITATION); break;
1863 case 15: tmpfunc->Dispatch(LFUN_INDEX_INSERT); break;
1864 case 16: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break;
1865 case 17: tmpfunc->Dispatch(LFUN_URL); break;
1868 fl_freepup(InsertMenu);
1869 fl_freepup(SubInsertAscii);
1870 fl_freepup(SubInsertTableList);
1871 fl_freepup(SubInsertFloatList);
1872 fl_freepup(SubInsertSpecial);
1876 void Menus::ShowMathMenu(FL_OBJECT * ob, long)
1878 extern void math_insert_symbol(char const * s);
1880 Menus * men = static_cast<Menus*>(ob->u_vdata);
1882 // set the pseudo menu-button
1883 fl_set_object_boxtype(ob, FL_UP_BOX);
1884 fl_set_button(ob, 0);
1885 fl_redraw_object(ob);
1887 Buffer * tmpbuffer = men->_view->buffer();
1888 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1890 int MathMenu = fl_defpup(FL_ObjWin(ob),
1901 fl_setpup_shortcut(MathMenu, 1, scex(_("MM|Ff#f#F")));
1902 fl_setpup_shortcut(MathMenu, 2, scex(_("MM|Ss#s#S")));
1903 fl_setpup_shortcut(MathMenu, 3, scex(_("MM|Ee#e#E")));
1904 fl_setpup_shortcut(MathMenu, 4, scex(_("MM|xX#x#X")));
1905 fl_setpup_shortcut(MathMenu, 5, scex(_("MM|uU#u#U")));
1906 fl_setpup_shortcut(MathMenu, 6, scex(_("MM|Ii#i#I")));
1907 fl_setpup_shortcut(MathMenu, 7, scex(_("MM|Mm#m#M")));
1908 fl_setpup_shortcut(MathMenu, 8, scex(_("MM|Dd#d#D")));
1909 fl_setpup_shortcut(MathMenu, 9, scex(_("MM|Pp#p#P")));
1911 if (tmpbuffer->isReadonly())
1912 for (int ii = 1; ii <= 9; ++ii)
1913 fl_setpup_mode(MathMenu, ii, FL_PUP_GREY);
1917 men->_view->getForm()->x + ob->x,
1918 men->_view->getForm()->y + ob->y + ob->h + 10);
1919 int choice = fl_dopup(MathMenu);
1922 // set the pseudo menu-button back
1923 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1924 fl_redraw_object(ob);
1926 if (men->currentView()->available()) {
1929 tmpfunc->Dispatch(LFUN_INSERT_MATH, "frac");
1932 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
1934 case 3: /* Exponent */
1935 tmpfunc->Dispatch(LFUN_INSERT_MATH, "^");
1938 tmpfunc->Dispatch(LFUN_INSERT_MATH, "_");
1941 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sum");
1944 tmpfunc->Dispatch(LFUN_INSERT_MATH, "int");
1947 tmpfunc->Dispatch(LFUN_MATH_MODE);
1950 tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
1953 show_symbols_form(tmpfunc);
1956 men->currentView()->update(0);
1958 fl_freepup(MathMenu);
1962 void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
1964 Menus * men = static_cast<Menus*>(ob->u_vdata);
1966 // set the pseudo menu-button
1967 fl_set_object_boxtype(ob, FL_UP_BOX);
1968 fl_set_button(ob, 0);
1969 fl_redraw_object(ob);
1971 //Buffer *tmpbuffer = men->_view->currentBuffer();
1972 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1974 int OptionsMenu = fl_defpup(FL_ObjWin(ob),
1976 "|Spellchecker Options..."
1981 fl_setpup_shortcut(OptionsMenu, 1, scex(_("OM|Ff#f#F")));
1982 fl_setpup_shortcut(OptionsMenu, 2, scex(_("OM|Ss#s#S")));
1983 fl_setpup_shortcut(OptionsMenu, 3, scex(_("OM|Kk#k#K")));
1984 fl_setpup_shortcut(OptionsMenu, 4, scex(_("OM|Ll#l#L")));
1985 fl_setpup_shortcut(OptionsMenu, 5, scex(_("OM|Rr#r#R")));
1987 if(lyxrc.isp_command == "none")
1988 fl_setpup_mode(OptionsMenu, 2, FL_PUP_GREY);
1991 men->_view->getForm()->x + ob->x,
1992 men->_view->getForm()->y + ob->y + ob->h + 10);
1993 int choice = fl_dopup(OptionsMenu);
1996 // set the pseudo menu-button back
1997 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1998 fl_redraw_object(ob);
2000 case 1: men->ScreenOptions(); break;
2001 case 2: SpellCheckerOptions(); break;
2002 case 3: men->_view->getIntl()->MenuKeymap(); break;
2003 case 4: LaTeXOptions(men->_view->view()); break;
2004 case 5: tmpfunc->Dispatch(LFUN_RECONFIGURE); break;
2007 fl_freepup(OptionsMenu);
2011 void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
2013 Menus * men = static_cast<Menus*>(ob->u_vdata);
2015 // set the pseudo menu-button
2016 fl_set_object_boxtype(ob, FL_UP_BOX);
2017 fl_set_button(ob, 0);
2018 fl_redraw_object(ob);
2020 int BufferMenu = fl_newpup(FL_ObjWin(ob));
2021 vector<string> namevec = bufferlist.getFileNames();
2022 if (namevec.size() != 0) {
2023 for (vector<string>::const_iterator cit = namevec.begin();
2024 cit != namevec.end(); ++cit) {
2025 string relbuf = MakeDisplayPath((*cit), 30);
2026 fl_addtopup(BufferMenu, relbuf.c_str());
2029 fl_addtopup(BufferMenu, _("No Documents Open!%t"));
2033 men->_view->getForm()->x + ob->x,
2034 men->_view->getForm()->y + ob->y + ob->h + 10);
2035 int choice = fl_dopup(BufferMenu);
2038 // set the pseudo menu-button back
2039 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2040 fl_redraw_object(ob);
2041 if (choice > 0) men->handleBufferMenu(choice - 1);
2043 fl_freepup(BufferMenu);
2048 char const * doc_files [] = {"Intro", "Tutorial",
2049 "UserGuide", "Extended",
2050 "Customization", "Reference",
2052 "BUGS", "LaTeXConfig"};
2054 void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
2056 Menus * men = static_cast<Menus*>(ob->u_vdata);
2058 // set the pseudo menu-button
2059 fl_set_object_boxtype(ob, FL_UP_BOX);
2060 fl_set_button(ob, 0);
2061 fl_redraw_object(ob);
2063 int HelpMenu = fl_defpup(FL_ObjWin(ob),
2067 "|Extended Features"
2071 "|Table of Contents"
2073 "|LaTeX Configuration%l"
2074 "|Copyright and Warranty..."
2078 fl_setpup_shortcut(HelpMenu, 1, scex(_("HM|Ii#I#i")));
2079 fl_setpup_shortcut(HelpMenu, 2, scex(_("HM|Tt#T#t")));
2080 fl_setpup_shortcut(HelpMenu, 3, scex(_("HM|Uu#U#u")));
2081 fl_setpup_shortcut(HelpMenu, 4, scex(_("HM|xX#x#X")));
2082 fl_setpup_shortcut(HelpMenu, 5, scex(_("HM|Cc#C#c")));
2083 fl_setpup_shortcut(HelpMenu, 6, scex(_("HM|Rr#R#r")));
2084 fl_setpup_shortcut(HelpMenu, 7, scex(_("HM|Ff#F#f")));
2085 fl_setpup_shortcut(HelpMenu, 8, scex(_("HM|aA#a#A")));
2086 fl_setpup_shortcut(HelpMenu, 9, scex(_("HM|Kk#K#k")));
2087 fl_setpup_shortcut(HelpMenu, 10, scex(_("HM|Ll#L#l")));
2088 fl_setpup_shortcut(HelpMenu, 11, scex(_("HM|oO#o#O")));
2089 fl_setpup_shortcut(HelpMenu, 12, scex(_("HM|eE#e#E")));
2090 fl_setpup_shortcut(HelpMenu, 13, scex(_("HM|Vv#v#V")));
2093 men->_view->getForm()->x + ob->x,
2094 men->_view->getForm()->y + ob->y + ob->h + 10);
2095 int choice = fl_dopup(HelpMenu);
2098 // set the pseudo menu-button back
2099 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2100 fl_redraw_object(ob);
2103 case 1: case 2: case 3: case 4: case 5:
2104 case 6: case 7: case 8: case 9: case 10:
2105 ProhibitInput(men->currentView());
2106 men->MenuDocu(doc_files[choice - 1]);
2107 AllowInput(men->currentView());
2109 case 11: ShowCopyright(); break;
2110 case 12: ShowCredits(); break;
2112 ProhibitInput(men->currentView());
2113 fl_show_message((string(_("LyX Version ")) + LYX_VERSION
2114 + _(" of ") + LYX_RELEASE).c_str(),
2115 (_("Library directory: ")
2116 + MakeDisplayPath(system_lyxdir)).c_str(),
2117 (_("User directory: ")
2118 + MakeDisplayPath(user_lyxdir)).c_str());
2119 AllowInput(men->currentView());
2122 fl_freepup(HelpMenu);
2126 void Menus::MenuDocu(string const & docname)
2128 string fname = i18nLibFileSearch("doc", docname, "lyx");
2129 if (fname.empty()) {
2130 WriteAlert(_("Error!"),
2131 _("Could not find requested Documentation file"),
2135 _view->getMiniBuffer()->Set(_("Opening help file"),
2136 MakeDisplayPath(fname), "...");
2137 currentView()->buffer(bufferlist.loadLyXFile(fname, false));
2139 if (docname == "Reference")
2140 _view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
2144 void Menus::handleBufferMenu(int choice)
2146 currentView()->buffer(bufferlist.getBuffer(choice));