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();
72 // A bunch of wrappers
74 extern "C" void C_Menus_ShowFileMenu(FL_OBJECT * ob, long data)
76 Menus::ShowFileMenu(ob, data);
79 extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT * ob, long data)
81 Menus::ShowFileMenu2(ob, data);
84 extern "C" void C_Menus_ShowEditMenu(FL_OBJECT * ob, long data)
86 Menus::ShowEditMenu(ob, data);
89 extern "C" void C_Menus_ShowTocMenu(FL_OBJECT * ob, long data)
91 Menus::ShowTocMenu(ob, data);
94 extern "C" void C_Menus_ShowRefsMenu(FL_OBJECT * ob, long data)
96 Menus::ShowRefsMenu(ob, data);
99 extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT * ob, long data)
101 Menus::ShowLayoutMenu(ob, data);
104 extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT * ob, long data)
106 Menus::ShowInsertMenu(ob, data);
109 extern "C" void C_Menus_ShowMathMenu(FL_OBJECT * ob, long data)
111 Menus::ShowMathMenu(ob, data);
114 extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT * ob, long data)
116 Menus::ShowOptionsMenu(ob, data);
119 extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT * ob, long data)
121 Menus::ShowBufferMenu(ob, data);
124 extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT * ob, long data)
126 Menus::ShowHelpMenu(ob, data);
130 Menus::Menus(LyXView * view, int air)
134 // deactivate the menu accelerators
135 fl_set_object_shortcut(menu_file, "", 1);
136 fl_set_object_shortcut(menu_file2, "", 1);
137 fl_set_object_shortcut(menu_edit, "", 1);
138 fl_set_object_shortcut(menu_toc, "", 1);
139 fl_set_object_shortcut(menu_refs, "", 1);
140 fl_set_object_shortcut(menu_layout, "", 1);
141 fl_set_object_shortcut(menu_math, "", 1);
142 fl_set_object_shortcut(menu_insert, "", 1);
143 fl_set_object_shortcut(menu_options, "", 1);
144 fl_set_object_shortcut(menu_options2, "", 1);
145 fl_set_object_shortcut(menu_buffer, "", 1);
146 fl_set_object_shortcut(menu_help, "", 1);
147 fl_set_object_shortcut(menu_help2, "", 1);
153 BufferView * Menus::currentView()
155 return _view->view();
159 void Menus::showMenus()
161 fl_hide_object(menu_grp2);
162 fl_show_object(menu_grp1);
166 void Menus::hideMenus()
168 fl_hide_object(menu_grp1);
169 fl_show_object(menu_grp2);
173 void Menus::openByName(string const & menuName)
174 /* Opens the visible menu of given name, or simply does nothing
175 when the name is not known. NOTE THE EXTREMELY STUPID
176 IMPLEMENTATION! :-) There are probably hundred ways to do
177 this better, for instance, by scanning the menu objects and
178 testing for the given name. I leave this as an exercise for an
179 experienced GG (GUI Guy/Girl). RVDK_PATCH_5. */
181 if (menu_file->visible) {
182 if (menuName == _("File"))
183 ShowFileMenu(menu_file, 0);
184 else if (menuName == _("Edit"))
185 ShowEditMenu(menu_edit, 0);
186 else if (menuName == _("TOC"))
187 ShowTocMenu(menu_toc, 0);
188 else if (menuName == _("Refs"))
189 ShowRefsMenu(menu_refs, 0);
190 else if (menuName == _("Layout"))
191 ShowLayoutMenu(menu_layout, 0);
192 else if (menuName == _("Insert"))
193 ShowInsertMenu(menu_insert, 0);
194 else if (menuName == _("Math"))
195 ShowMathMenu(menu_math, 0);
196 else if (menuName == _("Options"))
197 ShowOptionsMenu(menu_options, 0);
198 else if (menuName == _("Documents"))
199 ShowBufferMenu(menu_buffer, 0);
200 else if (menuName == _("Help"))
201 ShowHelpMenu(menu_help, 0);
202 else lyxerr << "The menu '" << menuName
203 << "' is not available." << endl;
205 if (menuName == _("File"))
206 ShowFileMenu2(menu_file2, 0);
207 else if (menuName == _("Options"))
208 ShowOptionsMenu(menu_options2, 0);
209 else if (menuName == _("Help"))
210 ShowHelpMenu(menu_help2, 0);
211 else lyxerr << "The menu '" << menuName
212 << "' is not available." << endl;
217 void Menus::create_menus(int air)
219 FL_FORM * form = _view->getForm();
221 // Here I'd really like to see code like:
225 const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
226 const int mheight = 30;
227 const int mbheight= 22;
228 // where to place the menubar?
229 const int yloc = (mheight - mbheight)/2; //air + bw;
230 const int mbadd = 20; // menu button add (to width)
234 obj = fl_add_frame(FL_UP_FRAME, 0, 0, form->w, mheight, "");
235 fl_set_object_resize(obj, FL_RESIZE_ALL);
236 fl_set_object_gravity(obj, NorthWestGravity, NorthEastGravity);
238 menu_grp1 = fl_bgn_group();
242 fl_add_button(FL_TOUCH_BUTTON,
244 fl_get_string_width(FL_BOLD_STYLE,
247 strlen(_("File"))) + mbadd,
248 mbheight, _("File"));
249 moffset += obj->w + air;
250 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
251 fl_set_object_callback(obj, C_Menus_ShowFileMenu, 0);
256 fl_add_button(FL_TOUCH_BUTTON,
258 fl_get_string_width(FL_BOLD_STYLE,
261 strlen(_("Edit"))) + mbadd,
262 mbheight, _("Edit"));
263 moffset += obj->w + air;
264 fl_set_object_shortcut(obj, scex(_("MB|#E")), 1);
265 fl_set_object_callback(obj, C_Menus_ShowEditMenu, 0);
270 fl_add_button(FL_TOUCH_BUTTON,
272 fl_get_string_width(FL_BOLD_STYLE,
275 strlen(_("TOC"))) + mbadd,
277 moffset += obj->w + air;
278 fl_set_object_shortcut(obj, scex(_("MB|#T")), 1);
279 fl_set_object_callback(obj, C_Menus_ShowTocMenu, 0);
284 fl_add_button(FL_TOUCH_BUTTON,
286 fl_get_string_width(FL_BOLD_STYLE,
289 strlen(_("Refs"))) + mbadd,
290 mbheight, _("Refs"));
291 moffset += obj->w + air;
292 fl_set_object_shortcut(obj, scex(_("MB|#R")), 1);
293 fl_set_object_callback(obj, C_Menus_ShowRefsMenu, 0);
296 // Layout menu button
298 fl_add_button(FL_TOUCH_BUTTON,
300 fl_get_string_width(FL_BOLD_STYLE,
303 strlen(_("Layout"))) + mbadd,
304 mbheight, _("Layout"));
305 moffset += obj->w + air;
306 fl_set_object_shortcut(obj, scex(_("MB|#L")), 1);
307 fl_set_object_callback(obj, C_Menus_ShowLayoutMenu, 0);
310 // Insert menu button button
312 fl_add_button(FL_TOUCH_BUTTON,
314 fl_get_string_width(FL_BOLD_STYLE,
317 strlen(_("Insert"))) + mbadd,
318 mbheight, _("Insert"));
319 moffset += obj->w + air;
320 fl_set_object_shortcut(obj, scex(_("MB|#I")), 1);
321 fl_set_object_callback(obj, C_Menus_ShowInsertMenu, 0);
326 fl_add_button(FL_TOUCH_BUTTON,
328 fl_get_string_width(FL_BOLD_STYLE,
331 strlen(_("Math"))) + mbadd,
332 mbheight, _("Math"));
333 moffset += obj->w + air;
334 fl_set_object_shortcut(obj, scex(_("MB|#M")), 1);
335 fl_set_object_callback(obj, C_Menus_ShowMathMenu, 0);
338 // Options menu button
340 fl_add_button(FL_TOUCH_BUTTON,
342 fl_get_string_width(FL_BOLD_STYLE,
345 strlen(_("Options"))) + mbadd,
346 mbheight, _("Options"));
347 moffset += obj->w + air;
348 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
349 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
352 // Documents menu button
354 fl_add_button(FL_TOUCH_BUTTON,
356 fl_get_string_width(FL_BOLD_STYLE,
359 strlen(_("Documents"))) + mbadd,
360 mbheight, _("Documents"));
361 moffset += obj->w + air;
362 fl_set_object_shortcut(obj, scex(_("MB|#D")), 1);
363 fl_set_object_callback(obj, C_Menus_ShowBufferMenu, 0);
368 fl_add_button(FL_TOUCH_BUTTON,
370 fl_get_string_width(FL_BOLD_STYLE,
373 strlen(_("Help"))) + mbadd,
374 mbheight, _("Help"));
375 moffset += obj->w + air;
376 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
377 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
382 // Set the menu buttons atrributes.
383 // Due to a bug in xforms we cant do this only an the group.
384 obj = menu_grp1->next;
386 fl_set_object_boxtype(obj, FL_FLAT_BOX);
387 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
388 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
389 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
390 fl_set_object_resize(obj, FL_RESIZE_ALL);
391 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
393 } while (obj != 0 && obj->objclass != FL_END_GROUP);
397 menu_grp2 = fl_bgn_group();
401 fl_add_button(FL_TOUCH_BUTTON,
403 fl_get_string_width(FL_BOLD_STYLE,
406 strlen(_("File"))) + mbadd,
407 mbheight, _("File"));
408 moffset += obj->w + air;
409 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
410 fl_set_object_callback(obj, C_Menus_ShowFileMenu2, 0);
413 // Options menu button
414 menu_options2 = obj =
415 fl_add_button(FL_TOUCH_BUTTON,
417 fl_get_string_width(FL_BOLD_STYLE,
420 strlen(_("Options"))) +mbadd,
421 mbheight, _("Options"));
422 moffset += obj->w + air;
423 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
424 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
429 fl_add_button(FL_TOUCH_BUTTON,
431 fl_get_string_width(FL_BOLD_STYLE,
434 strlen(_("Help"))) + mbadd,
435 mbheight, _("Help"));
436 moffset += obj->w + air;
437 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
438 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
443 // Set the menu buttons atrributes.
444 // Due to a bug in xforms we cant do this only an the group.
445 obj = menu_grp2->next;
447 fl_set_object_boxtype(obj, FL_FLAT_BOX);
448 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
449 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
450 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
451 fl_set_object_resize(obj, FL_RESIZE_ALL);
452 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
454 } while (obj != 0 && obj->objclass != FL_END_GROUP);
458 void Menus::ScreenOptions()
460 static int ow = -1, oh;
462 // this is not very nice....
463 fl_set_input(fd_form_screen->input_roman,
464 lyxrc.roman_font_name.c_str());
465 fl_set_input(fd_form_screen->input_sans,
466 lyxrc.sans_font_name.c_str());
467 fl_set_input(fd_form_screen->input_typewriter,
468 lyxrc.typewriter_font_name.c_str());
469 fl_set_input(fd_form_screen->input_font_norm,
470 lyxrc.font_norm.c_str());
472 sprintf(tmpstring, "%d", lyxrc.zoom);
473 fl_set_input(fd_form_screen->intinput_size, tmpstring);
474 if (fd_form_screen->form_screen->visible) {
475 fl_raise_form(fd_form_screen->form_screen);
477 fl_show_form(fd_form_screen->form_screen,
478 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
479 _("Screen Options"));
481 ow = fd_form_screen->form_screen->w;
482 oh = fd_form_screen->form_screen->h;
484 fl_set_form_minsize(fd_form_screen->form_screen, ow, oh);
490 // Here comes all the menu callbacks.
493 void Menus::ShowFileMenu(FL_OBJECT * ob, long)
495 Menus * men = static_cast<Menus*>(ob->u_vdata);
497 // Regarding the pseudo-menu-button:
498 // ok, ok this is a hack. It would be better to use the menus of the
499 // xforms 0.8 library. but then all popups have to be defined all the
500 // time, code rewriting would be necessary and contex-depending menus
501 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
502 // course it would be more proper (and little faster). So if anybody
503 // likes to do the cleanup, just do it. Matthias
505 // set the pseudo menu-button
506 fl_set_object_boxtype(ob, FL_UP_BOX);
507 fl_set_button(ob, 0);
508 fl_redraw_object(ob);
510 Buffer * tmpbuffer = men->_view->buffer();
511 LyXFunc * tmpfunc = men->_view->getLyXFunc();
513 bool LinuxDoc = tmpbuffer->isLinuxDoc();
514 bool DocBook = tmpbuffer->isDocBook();
515 bool Literate = tmpbuffer->isLiterate();
519 int SubFileImport = fl_defpup(FL_ObjWin(ob),
522 "|Ascii Text as Lines...%x31"
523 "|Ascii Text as Paragraphs%x32"
527 fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
528 fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
529 fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
530 fl_setpup_shortcut(SubFileImport, 33, scex(_("FIM|Nn#n#N")));
531 fl_setpup_shortcut(SubFileImport, 34, scex(_("FIM|Dd#d#D")));
535 // remember to make this handle linuxdoc too.
536 // and now docbook also.
537 int SubFileExport = 0;
538 if (!LinuxDoc && !DocBook)
539 SubFileExport= fl_defpup(FL_ObjWin(ob),
543 "|as PostScript...%x42"
544 "|as Ascii Text...%x43"
548 SubFileExport= fl_defpup(FL_ObjWin(ob),
550 "|as LinuxDoc...%x40"
552 "|as PostScript...%x42"
553 "|as Ascii Text...%x43"
556 SubFileExport= fl_defpup(FL_ObjWin(ob),
560 "|as PostScript...%x42"
561 "|as Ascii Text...%x43"
564 fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
565 fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
566 fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
567 fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
568 fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
570 if (!LinuxDoc && !DocBook) {
571 fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
574 int FileMenu = fl_defpup(FL_ObjWin(ob),
576 "|New from template..."
590 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
591 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
592 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
593 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Cc#c#C")));
594 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|Ss#s#S")));
595 fl_setpup_shortcut(FileMenu, 6, scex(_("FM|Aa#a#A")));
596 fl_setpup_shortcut(FileMenu, 7, scex(_("FM|Rr#r#R")));
597 fl_setpup_shortcut(FileMenu, 8, scex(_("FM|dD#d#D")));
598 fl_setpup_shortcut(FileMenu, 9, scex(_("FM|wW#w#W")));
599 fl_setpup_shortcut(FileMenu, 10, scex(_("FM|vV#v#V")));
600 fl_setpup_shortcut(FileMenu, 11, scex(_("FM|Uu#u#U")));
601 fl_setpup_shortcut(FileMenu, 12, scex(_("FM|Bb#b#B")));
602 fl_setpup_shortcut(FileMenu, 13, scex(_("FM|Pp#p#P")));
603 fl_setpup_shortcut(FileMenu, 14, scex(_("FM|Ff#f#F")));
605 // These commands are disabled when the corresponding programs
606 // are not installed. I simply grey them out, since I do not
607 // want to change their number (JMarc)
608 bool hasLaTeX = lyxrc.latex_command != "none";
610 if (!hasLaTeX || lyxrc.view_dvi_command == "none")
611 fl_setpup_mode(FileMenu, 8, FL_PUP_GREY);
613 if (!hasLaTeX || lyxrc.view_ps_command == "none")
614 fl_setpup_mode(FileMenu, 9, FL_PUP_GREY);
617 fl_setpup_mode(FileMenu, 10, FL_PUP_GREY);
618 fl_setpup_mode(FileMenu, 11, FL_PUP_GREY);
621 if (lyxrc.literate_command == "none" || ! Literate)
622 fl_setpup_mode(FileMenu, 12, FL_PUP_GREY);
624 if (!hasLaTeX || lyxrc.print_command == "none")
625 fl_setpup_mode(FileMenu, 13, FL_PUP_GREY);
627 if (!hasLaTeX || lyxrc.fax_command == "none")
628 fl_setpup_mode(FileMenu, 14, FL_PUP_GREY);
630 bool hasReLyX = lyxrc.relyx_command != "none";
632 // Disable import LaTeX and Noweb
633 fl_setpup_mode(SubFileImport, 30, FL_PUP_GREY);
634 fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
637 if ( lyxrc.linuxdoc_to_lyx_command == "none")
638 fl_setpup_mode(SubFileImport, 34, FL_PUP_GREY);
641 // Disable export dvi and export postscript
642 fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
643 fl_setpup_mode(SubFileExport, 42, FL_PUP_GREY);
646 if ((!LinuxDoc && !DocBook && lyxrc.html_command == "none") ||
647 ( LinuxDoc && lyxrc.linuxdoc_to_html_command == "none") ||
648 ( DocBook && lyxrc.docbook_to_html_command == "none")) {
649 // Disable export HTML
650 fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
653 // xgettext:no-c-format
654 fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
655 // xgettext:no-c-format
656 fl_addtopup(FileMenu, _("|Export%m%l"), SubFileExport);
657 // xgettext:no-c-format
658 fl_addtopup(FileMenu, _("|Exit%l"));
659 fl_setpup_shortcut(FileMenu, 15, scex(_("FM|Ii#i#I")));
660 fl_setpup_shortcut(FileMenu, 16, scex(_("FM|Ee#e#E")));
661 fl_setpup_shortcut(FileMenu, 17, scex(_("FM|xX#x#X")));
663 // make the lastfiles menu
665 for (LastFiles::const_iterator cit = lastfiles->begin();
666 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
667 string tmp = tostr(ii);
668 string tmp2 = tmp + "#" + tmp;
669 tmp += ". " + MakeDisplayPath((*cit), 30);
670 fl_addtopup(FileMenu, tmp.c_str());
671 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
676 men->_view->getForm()->x + ob->x,
677 men->_view->getForm()->y + ob->y + ob->h + 10);
678 int choice = fl_dopup(FileMenu);
681 // set the pseudo menu-button back
682 fl_set_object_boxtype(ob, FL_FLAT_BOX);
683 fl_redraw_object(ob);
686 case -1: case 0: // we won't do anything
688 case 1: tmpfunc->Dispatch(LFUN_MENUNEW); break;
689 case 2: tmpfunc->Dispatch(LFUN_MENUNEWTMPLT); break;
690 case 3: tmpfunc->Dispatch(LFUN_MENUOPEN); break;
691 case 4: tmpfunc->Dispatch(LFUN_CLOSEBUFFER); break;
692 case 5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
693 case 6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
694 case 7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
695 case 8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
696 case 9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
697 case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
698 case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
699 case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
700 case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
701 case 14: tmpfunc->Dispatch(LFUN_FAX); break;
702 case 15: // import menu
703 case 30: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
705 case 31: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
707 case 32: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
709 case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
711 case 34: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
713 case 16: // export menu
715 if (!LinuxDoc && !DocBook)
716 tmpfunc->Dispatch(LFUN_EXPORT, "latex");
718 tmpfunc->Dispatch(LFUN_EXPORT, "linuxdoc");
720 tmpfunc->Dispatch(LFUN_EXPORT, "docbook");
722 case 41: tmpfunc->Dispatch(LFUN_EXPORT, "dvi");
724 case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
726 case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
729 if (!LinuxDoc && !DocBook)
730 tmpfunc->Dispatch(LFUN_EXPORT, "html");
732 tmpfunc->Dispatch(LFUN_EXPORT, "html-linuxdoc");
734 tmpfunc->Dispatch(LFUN_EXPORT, "html-docbook");
736 case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
738 case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
740 case 18: // The first item with lastfiles.
744 .loadLyXFile((*lastfiles)[choice - 18]));
747 fl_freepup(SubFileImport);
748 fl_freepup(SubFileExport);
749 fl_freepup(FileMenu);
751 AllowInput(men->currentView());
755 void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
757 Menus * men = static_cast<Menus*>(ob->u_vdata);
759 // Regarding the pseudo-menu-button:
760 // ok, ok this is a hack. It would be better to use the menus of the
761 // xforms 0.8 library. but then all popups have to be defined all the
762 // time, code rewriting would be necessary and contex-depending menus
763 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
764 // course it would be more proper (and little faster). So if anybody
765 // likes to do the cleanup, just do it. Matthias
767 // set the pseudo menu-button
768 fl_set_object_boxtype(ob, FL_UP_BOX);
769 fl_set_button(ob, 0);
770 fl_redraw_object(ob);
772 LyXFunc * tmpfunc = men->_view->getLyXFunc();
776 int SubFileImport = fl_defpup(FL_ObjWin(ob),
779 "|Ascii Text as Lines...%x16"
780 "|Ascii Text as Paragraphs...%x17"
782 "|LinuxDoc...%x19"));
784 fl_setpup_shortcut(SubFileImport, 15, scex(_("FIM|Ll#l#L")));
785 fl_setpup_shortcut(SubFileImport, 16, scex(_("FIM|Aa#a#A")));
786 fl_setpup_shortcut(SubFileImport, 17, scex(_("FIM|Pp#p#P")));
787 fl_setpup_shortcut(SubFileImport, 18, scex(_("FIM|Nn#n#N")));
788 fl_setpup_shortcut(SubFileImport, 19, scex(_("FIM|Dd#d#D")));
790 bool hasReLyX = lyxrc.relyx_command != "none";
792 // Disable import LaTeX and Noweb
793 fl_setpup_mode(SubFileImport, 15, FL_PUP_GREY);
794 fl_setpup_mode(SubFileImport, 18, FL_PUP_GREY);
797 if ( lyxrc.linuxdoc_to_lyx_command == "none")
798 fl_setpup_mode(SubFileImport, 19, FL_PUP_GREY);
800 // This can be done cleaner later.
801 int FileMenu = fl_defpup(FL_ObjWin(ob),
803 "|New from template..."
806 "|Exit%l"), SubFileImport);
808 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
809 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
810 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
811 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Ii#i#I")));
812 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|xX#x#X")));
814 // make the lastfiles menu
816 for (LastFiles::const_iterator cit = lastfiles->begin();
817 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
818 string tmp = tostr(ii);
819 string tmp2 = tmp + "#" + tmp;
820 tmp += ". " + MakeDisplayPath((*cit), 30);
821 fl_addtopup(FileMenu, tmp.c_str());
822 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
827 men->_view->getForm()->x + ob->x,
828 men->_view->getForm()->y + ob->y + ob->h + 10);
829 int choice = fl_dopup(FileMenu);
832 // set the pseudo menu-button back
833 fl_set_object_boxtype(ob, FL_FLAT_BOX);
834 fl_redraw_object(ob);
837 case -1: case 0: // we won't do anything
840 tmpfunc->Dispatch(LFUN_MENUNEW);
843 tmpfunc->Dispatch(LFUN_MENUNEWTMPLT);
846 tmpfunc->Dispatch(LFUN_MENUOPEN);
848 case 4: // import menu
849 case 15: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
851 case 16: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
853 case 17: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
855 case 18: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
857 case 19: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
860 tmpfunc->Dispatch(LFUN_QUIT);
863 case 6: // The first item with lastfiles.
867 .loadLyXFile((*lastfiles)[choice - 6]));
871 fl_freepup(SubFileImport);
872 fl_freepup(FileMenu);
873 AllowInput(men->currentView());
878 void Menus::ShowEditMenu(FL_OBJECT * ob, long)
880 Menus * men = static_cast<Menus*>(ob->u_vdata);
882 // set the pseudo menu-button
883 fl_set_object_boxtype(ob, FL_UP_BOX);
884 fl_set_button(ob, 0);
885 fl_redraw_object(ob);
887 Buffer * tmpbuffer = men->_view->buffer();
888 LyXFunc * tmpfunc = men->_view->getLyXFunc();
890 // Floats & Insets submenu
891 int SubEditFloats= fl_defpup(FL_ObjWin(ob),
892 _("Floats & Insets%t"
895 "|Open All Footnotes/Margin Notes%x23"
896 "|Close All Footnotes/Margin Notes%x24"
897 "|Open All Figures/Tables%x25"
898 "|Close All Figures/Tables%x26%l"
899 "|Remove all Error Boxes%x27"));
901 fl_setpup_shortcut(SubEditFloats, 21, scex(_("EMF|Oo#o#O")));
902 fl_setpup_shortcut(SubEditFloats, 22, scex(_("EMF|Mm#m#M")));
903 fl_setpup_shortcut(SubEditFloats, 23, scex(_("EMF|Aa#a#A")));
904 fl_setpup_shortcut(SubEditFloats, 24, scex(_("EMF|Cc#c#C")));
905 fl_setpup_shortcut(SubEditFloats, 25, scex(_("EMF|Ff#f#F")));
906 fl_setpup_shortcut(SubEditFloats, 26, scex(_("EMF|Tt#t#T")));
907 fl_setpup_shortcut(SubEditFloats, 27, scex(_("EMF|Rr#r#R")));
910 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()->
923 text->cursor.pos())))
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()->
943 text->cursor.pos())))
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()->
953 text->cursor.pos())))
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()->
963 text->cursor.pos())))
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()->
974 text->cursor.pos()));
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")));
1010 if (men->currentView()->the_locking_inset &&
1011 (men->currentView()->the_locking_inset->LyxCode() ==
1012 Inset::TABULAR_CODE) &&
1013 !tmpbuffer->isReadonly()) {
1014 InsetTabular * inset = static_cast<InsetTabular *>(men->currentView()->the_locking_inset);
1015 LyXTabular * table = inset->tabular;
1017 fl_addtopup(SubEditTable, _("Table%t"));
1019 if (table->IsMultiColumn(inset->GetActCell()))
1020 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
1022 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
1023 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
1025 if (table->TopLine(inset->GetActCell()))
1026 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
1028 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
1029 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
1031 if (table->BottomLine(inset->GetActCell()))
1032 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
1034 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
1035 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
1037 if (table->LeftLine(inset->GetActCell()))
1038 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
1040 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
1041 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
1043 if (table->RightLine(inset->GetActCell()))
1044 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
1046 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
1047 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
1049 int align = table->GetAlignment(inset->GetActCell());
1050 if (align == LYX_ALIGN_LEFT)
1051 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
1053 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
1054 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
1056 if (align == LYX_ALIGN_RIGHT)
1057 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
1059 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
1060 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
1062 if (align == LYX_ALIGN_CENTER)
1063 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
1065 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
1066 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
1068 // xgettext:no-c-format
1069 fl_addtopup(SubEditTable, _("|Append Row%x32"));
1070 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
1071 // xgettext:no-c-format
1072 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
1073 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
1074 // xgettext:no-c-format
1075 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
1076 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
1077 // xgettext:no-c-format
1078 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
1079 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
1080 // xgettext:no-c-format
1081 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
1082 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
1084 fl_addtopup(SubEditTable, _("Table%t"));
1085 // xgettext:no-c-format
1086 fl_addtopup(SubEditTable, _("|Insert table%x31"));
1087 fl_setpup_shortcut(SubEditTable, 31, scex(_("EMT|Ii#i#I")));
1090 int SubVersionControl = fl_newpup(FL_ObjWin(ob));
1091 fl_addtopup(SubVersionControl, _("Version Control%t"));
1092 if (tmpbuffer->lyxvc.inUse()) {
1093 // xgettext:no-c-format
1094 fl_addtopup(SubVersionControl, _("|Register%d%x51"));
1095 if (tmpbuffer->isReadonly()) {
1096 // signifies that the file is not checked out
1097 // xgettext:no-c-format
1098 fl_addtopup(SubVersionControl, _("|Check In Changes%d%x52"));
1099 // xgettext:no-c-format
1100 fl_addtopup(SubVersionControl, _("|Check Out for Edit%x53"));
1102 // signifies that the file is checked out
1103 // xgettext:no-c-format
1104 fl_addtopup(SubVersionControl, _("|Check In Changes%x52"));
1105 // xgettext:no-c-format
1106 fl_addtopup(SubVersionControl, _("|Check Out for Edit%d%x53"));
1108 // xgettext:no-c-format
1109 fl_addtopup(SubVersionControl, _("|Revert to last version%x54"));
1110 // xgettext:no-c-format
1111 fl_addtopup(SubVersionControl, _("|Undo last check in%x55"));
1112 // xgettext:no-c-format
1113 fl_addtopup(SubVersionControl, _("|Show History%x56"));
1115 // xgettext:no-c-format
1116 fl_addtopup(SubVersionControl, _("|Register%x51"));
1118 // the shortcuts are not good.
1119 fl_setpup_shortcut(SubVersionControl, 51, scex(_("EMV|Rr#r#R")));
1120 fl_setpup_shortcut(SubVersionControl, 52, scex(_("EMV|Ii#i#I")));
1121 fl_setpup_shortcut(SubVersionControl, 53, scex(_("EMV|Oo#o#O")));
1122 fl_setpup_shortcut(SubVersionControl, 54, scex(_("EMV|lL#l#l")));
1123 fl_setpup_shortcut(SubVersionControl, 55, scex(_("EMV|Uu#u#U")));
1124 fl_setpup_shortcut(SubVersionControl, 56, scex(_("EMV|Hh#h#H")));
1126 int EditMenu= fl_defpup(FL_ObjWin(ob),
1132 "|Find & Replace..."
1135 "|Floats & Insets%m"
1139 "|Table of Contents..."
1140 "|List of Figures..."
1141 "|List of Tables..."
1142 "|List of Algorithms...%l"
1143 "|Version Control%m%l"
1144 "|View LaTeX log file%l"
1145 "|Paste Primary Selection as Lines"
1146 "|Paste Primary Selection as Paragraphs"),
1147 SubEditFloats, SubEditTable, SubVersionControl);
1149 fl_setpup_shortcut(EditMenu, 1, scex(_("EM|Uu#u#U")));
1150 fl_setpup_shortcut(EditMenu, 2, scex(_("EM|Rr#r#R")));
1151 fl_setpup_shortcut(EditMenu, 3, scex(_("EM|Cc#c#C")));
1152 fl_setpup_shortcut(EditMenu, 4, scex(_("EM|oO#o#O")));
1153 fl_setpup_shortcut(EditMenu, 5, scex(_("EM|Pp#p#P")));
1154 fl_setpup_shortcut(EditMenu, 6, scex(_("EM|Ff#f#F")));
1155 fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
1156 fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
1157 fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
1158 //fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
1159 fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
1160 fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
1161 fl_setpup_shortcut(EditMenu, 13, scex(_("EM|Tt#t#T")));
1162 //fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Ff#f#F")));
1163 //fl_setpup_shortcut(EditMenu, 15, scex(_("EM|bB#b#B")));
1164 //fl_setpup_shortcut(EditMenu, 16, scex(_("EM|mM#m#M")));
1165 fl_setpup_shortcut(EditMenu, 17, scex(_("EM|Vv#v#V")));
1166 fl_setpup_shortcut(EditMenu, 18, scex(_("EM|wW#w#W")));
1167 fl_setpup_shortcut(EditMenu, 19, scex(_("EM|Ll#l#L")));
1168 fl_setpup_shortcut(EditMenu, 20, scex(_("EM|gG#g#G")));
1170 // disable unavailable entries.
1171 if(tmpbuffer->undostack.empty())
1172 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1173 if(tmpbuffer->redostack.empty())
1174 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1175 if(lyxrc.isp_command == "none")
1176 fl_setpup_mode(EditMenu, 11, FL_PUP_GREY);
1177 if(lyxrc.chktex_command == "none")
1178 fl_setpup_mode(EditMenu, 12, FL_PUP_GREY);
1180 if (tmpbuffer->isReadonly()) {
1181 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1182 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1183 fl_setpup_mode(EditMenu, 3, FL_PUP_GREY);
1184 fl_setpup_mode(EditMenu, 5, FL_PUP_GREY);
1185 fl_setpup_mode(EditMenu, 19, FL_PUP_GREY);
1186 fl_setpup_mode(EditMenu, 20, FL_PUP_GREY);
1189 fl_setpup_position(men->_view->getForm()->x + ob->x,
1190 men->_view->getForm()->y + ob->y +
1192 int choice = fl_dopup(EditMenu);
1195 // set the pseudo menu-button back
1196 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1197 fl_redraw_object(ob);
1200 case 1: tmpfunc->Dispatch(LFUN_UNDO); break;
1201 case 2: tmpfunc->Dispatch(LFUN_REDO); break;
1202 case 3: tmpfunc->Dispatch(LFUN_CUT); break;
1203 case 4: tmpfunc->Dispatch(LFUN_COPY); break;
1204 case 5: tmpfunc->Dispatch(LFUN_PASTE); break;
1205 case 6: tmpfunc->Dispatch(LFUN_MENUSEARCH); break;
1206 case 7: tmpfunc->Dispatch(LFUN_GOTOERROR); break;
1207 case 8: tmpfunc->Dispatch(LFUN_GOTONOTE); break;
1208 case 9: // floats & insets
1212 case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
1213 case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
1214 case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
1215 case 14: tmpfunc->Dispatch(LFUN_LOFVIEW); break;
1216 case 15: tmpfunc->Dispatch(LFUN_LOTVIEW); break;
1217 case 16: tmpfunc->Dispatch(LFUN_LOAVIEW); break;
1218 case 17: // version control
1220 case 18: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
1221 case 19: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
1222 case 20: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
1225 // floats & insets sub-menu
1226 case 21: men->currentView()->toggleFloat(); break;
1227 case 22: tmpfunc->Dispatch(LFUN_MELT); break;
1228 case 23: men->currentView()->allFloats(1, 0); break;
1229 case 24: men->currentView()->allFloats(0, 0); break;
1230 case 25: men->currentView()->allFloats(1, 1); break;
1231 case 26: men->currentView()->allFloats(0, 1); break;
1232 case 27: tmpfunc->Dispatch(LFUN_REMOVEERRORS); break;
1234 case 31: tmpfunc->Dispatch(LFUN_TABLE); break;
1235 // this is really temporary. We need new function in keybind.C
1236 // These should set the minibuffer, too.
1237 case 32: case 33: case 34:
1238 case 35: case 36: case 37:
1239 case 38: case 39: case 40:
1240 case 41: case 42: case 43:
1242 if (men->currentView()->available()) {
1243 men->currentView()->hideCursor();
1244 if (!men->currentView()->text->selection){
1245 men->currentView()->beforeChange();
1246 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR);
1248 if (men->currentView()->the_locking_inset &&
1249 (men->currentView()->the_locking_inset->LyxCode()
1250 == Inset::TABULAR_CODE)) {
1251 InsetTabular * inset =
1252 static_cast<InsetTabular *>
1253 (men->currentView()->the_locking_inset);
1254 inset->TabularFeatures(men->currentView(), choice - 32);
1258 men->currentView()->text->
1259 TableFeatures(men->currentView(), choice - 32);
1260 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
1265 // version control sub-menu
1266 case 51: // register
1267 tmpfunc->Dispatch(LFUN_VC_REGISTER);
1269 case 52: // check in
1270 tmpfunc->Dispatch(LFUN_VC_CHECKIN);
1272 case 53: // check out
1273 tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
1275 case 54: // revert to last
1276 tmpfunc->Dispatch(LFUN_VC_REVERT);
1278 case 55: // undo last
1279 tmpfunc->Dispatch(LFUN_VC_UNDO);
1281 case 56: // show history
1282 tmpfunc->Dispatch(LFUN_VC_HISTORY);
1286 fl_freepup(EditMenu);
1287 fl_freepup(SubEditFloats);
1288 fl_freepup(SubEditTable);
1289 fl_freepup(SubVersionControl);
1292 vector<int>::size_type const max_number_of_menus = 32;
1293 unsigned int const max_number_of_items = 25;
1295 string Limit_string_length(string const & str) {
1296 string::size_type const max_item_length = 45;
1298 if (str.size() > max_item_length)
1299 return str.substr(0, max_item_length-3) + "...";
1304 void Add_to_toc_menu(vector<Buffer::TocItem> const & toclist,
1305 unsigned int from, unsigned int to, int depth,
1306 int menu, vector<int> & menus, FL_OBJECT * ob)
1308 if (to - from <= max_number_of_items) {
1309 for (unsigned int i = from; i < to; ++i) {
1310 string entry(4 * max(0, toclist[i].depth - depth),' ');
1311 entry += toclist[i].str;
1312 entry = Limit_string_length(entry);
1313 entry += "%x" + tostr(i + 1);
1314 fl_addtopup(menu, entry.c_str());
1317 unsigned int pos = from;
1318 unsigned int count = 0;
1321 if (count > max_number_of_items) {
1322 fl_addtopup(menu, ". . .%d");
1325 unsigned int new_pos = pos+1;
1326 while (new_pos < to &&
1327 toclist[new_pos].depth > depth)
1330 string entry(4 * max(0, toclist[pos].depth - depth), ' ');
1331 entry += toclist[pos].str;
1332 entry = Limit_string_length(entry);
1334 if (new_pos == pos + 1) {
1336 entry += tostr(pos + 1);
1337 fl_addtopup(menu, entry.c_str());
1338 } else if (menus.size() < max_number_of_menus) {
1339 int menu2 = fl_newpup(FL_ObjWin(ob));
1340 menus.push_back(menu2);
1341 Add_to_toc_menu(toclist, pos, new_pos,
1342 depth + 1, menu2, menus,ob);
1344 fl_addtopup(menu, entry.c_str(), menu2);
1347 fl_addtopup(menu, entry.c_str());
1354 int const BIG_NUM = 1048576;
1356 void Menus::ShowTocMenu(FL_OBJECT * ob, long)
1358 Menus * men = static_cast<Menus*>(ob->u_vdata);
1361 // set the pseudo menu-button
1362 fl_set_object_boxtype(ob, FL_UP_BOX);
1363 fl_set_button(ob, 0);
1364 fl_redraw_object(ob);
1366 int TocMenu = fl_newpup(FL_ObjWin(ob));
1367 menus.push_back(TocMenu);
1368 vector<vector<Buffer::TocItem> > toclist =
1369 men->currentView()->buffer()->getTocList();
1371 //xgettext:no-c-format
1372 static char const * MenuNames[3] = { N_("List of Figures%m"),
1373 //xgettext:no-c-format
1374 N_("List of Tables%m"),
1375 //xgettext:no-c-format
1376 N_("List of Algorithms%m") };
1378 int max_nonempty = 0;
1379 for (int j = 1; j <= 3; ++j)
1380 if (!toclist[j].empty())
1383 for (int j = 1; j <= 3; ++j)
1384 if (!toclist[j].empty()) {
1385 int menu2 = fl_newpup(FL_ObjWin(ob));
1386 menus.push_back(menu2);
1387 for (unsigned int i = 0; i < toclist[j].size(); ++i) {
1388 if (i > max_number_of_items) {
1389 fl_addtopup(menu2, ". . .%d");
1392 string entry = Limit_string_length(toclist[j][i].str);
1393 entry += "%x" + tostr(i+1+j*BIG_NUM);
1394 fl_addtopup(menu2, entry.c_str());
1396 if (j == max_nonempty) {
1397 string tmp = _(MenuNames[j-1]);
1399 fl_addtopup(TocMenu, tmp.c_str(), menu2);
1401 fl_addtopup(TocMenu, _(MenuNames[j-1]), menu2);
1404 Add_to_toc_menu(toclist[0], 0, toclist[0].size(), 0,
1405 TocMenu, menus, ob);
1408 men->_view->getForm()->x + ob->x,
1409 men->_view->getForm()->y + ob->y + ob->h + 10);
1410 int choice = fl_dopup(TocMenu);
1413 // set the pseudo menu-button back
1414 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1415 fl_redraw_object(ob);
1417 men->_view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
1418 else if (choice > 0) {
1419 int type = choice / BIG_NUM;
1420 int num = (choice % BIG_NUM) - 1;
1421 BufferView *bv = men->currentView();
1423 bv->text->SetCursor(bv, toclist[type][num].par, 0);
1424 bv->text->sel_cursor = bv->text->cursor;
1425 bv->update(BufferView::SELECT|BufferView::FITCUR);
1427 for (unsigned int i = 0; i < menus.size(); ++i)
1428 fl_freepup(menus[i]);
1431 void Add_to_refs_menu(vector<string> const & label_list, int offset,
1432 int menu, vector<int> & menus, FL_OBJECT * ob)
1434 typedef vector<string>::size_type size_type;
1435 size_type const max_number_of_items = 25;
1436 size_type const max_number_of_items2 = 20;
1437 string::size_type const max_item_length = 40;
1438 string::size_type const max_item_length2 = 20;
1440 if (label_list.size() <= max_number_of_items)
1441 for (size_type i = 0; i < label_list.size(); ++i) {
1442 string entry = label_list[i];
1443 if (entry.size() > max_item_length)
1444 entry = entry.substr(0, max_item_length-1) + "$";
1445 entry += "%x" + tostr(i+offset);
1446 fl_addtopup(menu, entry.c_str());
1449 size_type count = 0;
1450 for (size_type i = 0; i < label_list.size();
1451 i += max_number_of_items2) {
1453 if (count > max_number_of_items) {
1454 fl_addtopup(menu, ". . .%d");
1457 size_type j = min(label_list.size(),
1458 i+max_number_of_items2);
1461 if (label_list[i].size() > max_item_length2)
1462 entry += label_list[i].substr(0, max_item_length2-1) + "$";
1464 entry += label_list[i];
1466 if (label_list[j-1].size() > max_item_length2)
1467 entry += label_list[j-1].substr(0, max_item_length2-1) + "$";
1469 entry += label_list[j-1];
1471 if (menus.size() < max_number_of_menus) {
1472 int menu2 = fl_newpup(FL_ObjWin(ob));
1473 menus.push_back(menu2);
1474 for (size_type k = i; k < j; ++k) {
1475 string entry2 = label_list[k];
1476 if (entry2.size() > max_item_length)
1477 entry2 = entry2.substr(0, max_item_length-1) + "$";
1478 entry2 += "%x" + tostr(k+offset);
1479 fl_addtopup(menu2, entry2.c_str());
1482 fl_addtopup(menu, entry.c_str(), menu2);
1485 fl_addtopup(menu, entry.c_str());
1491 void Menus::ShowRefsMenu(FL_OBJECT * ob, long)
1495 Menus * men = static_cast<Menus*>(ob->u_vdata);
1497 // set the pseudo menu-button
1498 fl_set_object_boxtype(ob, FL_UP_BOX);
1499 fl_set_button(ob, 0);
1500 fl_redraw_object(ob);
1502 int RefsMenu = fl_newpup(FL_ObjWin(ob));
1503 menus.push_back(RefsMenu);
1504 Buffer * buffer = men->currentView()->buffer();
1505 vector<string> label_list = buffer->getLabelList();
1506 sort(label_list.begin(), label_list.end());
1508 //xgettext:no-c-format
1509 static char const * MenuNames[6] = { N_("Insert Reference%m"),
1510 //xgettext:no-c-format
1511 N_("Insert Page Number%m"),
1512 //xgettext:no-c-format
1513 N_("Insert vref%m"),
1514 //xgettext:no-c-format
1515 N_("Insert vpageref%m"),
1516 //xgettext:no-c-format
1517 N_("Insert Pretty Ref%m"),
1518 //xgettext:no-c-format
1519 N_("Goto Reference%m") };
1521 for (int j = 0; j < 6; ++j) {
1522 if (menus.size() < max_number_of_menus) {
1523 int menu2 = fl_newpup(FL_ObjWin(ob));
1524 menus.push_back(menu2);
1525 Add_to_refs_menu(label_list, (j+1)*BIG_NUM, menu2, menus, ob);
1526 fl_addtopup(RefsMenu, _(MenuNames[j]), menu2);
1528 string tmp = _(MenuNames[j]);
1530 fl_addtopup(RefsMenu, tmp.c_str());
1533 fl_addtopup(RefsMenu, _("Go Back"));
1535 bool empty = label_list.empty();
1536 bool sgml = buffer->isSGML();
1537 bool readonly = buffer->isReadonly();
1540 fl_setpup_mode(RefsMenu, 6, FL_PUP_GREY);
1541 if (empty || readonly) {
1542 fl_setpup_mode(RefsMenu, 1, FL_PUP_GREY);
1543 fl_setpup_mode(RefsMenu, 2, FL_PUP_GREY);
1545 if (empty || readonly || sgml) {
1546 fl_setpup_mode(RefsMenu, 3, FL_PUP_GREY);
1547 fl_setpup_mode(RefsMenu, 4, FL_PUP_GREY);
1548 fl_setpup_mode(RefsMenu, 5, FL_PUP_GREY);
1550 if (men->currentView()->NoSavedPositions())
1551 fl_setpup_mode(RefsMenu, 7, FL_PUP_GREY);
1554 men->_view->getForm()->x + ob->x,
1555 men->_view->getForm()->y + ob->y + ob->h + 10);
1556 int choice = fl_dopup(RefsMenu);
1559 // set the pseudo menu-button back
1560 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1561 fl_redraw_object(ob);
1564 men->_view->getLyXFunc()->Dispatch(LFUN_REFBACK);
1565 else if (choice >= BIG_NUM) {
1566 int type = (choice / BIG_NUM) - 1;
1567 int num = choice % BIG_NUM;
1569 men->_view->getLyXFunc()->Dispatch(LFUN_REFGOTO,
1570 label_list[num].c_str());
1572 static string const commands[5]
1573 = { "\\ref", "\\pageref", "\\vref", "\\vpageref",
1575 string t = commands[type] + "{" + label_list[num] + "}";
1576 men->currentView()->insertInset(new InsetRef(t, buffer));
1580 for (unsigned int i = 0; i < menus.size(); ++i)
1581 fl_freepup(menus[i]);
1585 void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
1587 Menus * men = static_cast<Menus*>(ob->u_vdata);
1589 if (!men->currentView()->available())
1592 // set the pseudo menu-button
1593 fl_set_object_boxtype(ob, FL_UP_BOX);
1594 fl_set_button(ob, 0);
1595 fl_redraw_object(ob);
1597 Buffer * tmpbuffer = men->_view->buffer();
1598 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1600 int LayoutMenu = fl_newpup(FL_ObjWin(ob));
1601 fl_addtopup(LayoutMenu, _("Character..."
1607 "|Emphasize Style%b"
1611 "|Change Environment Depth"
1612 "|LaTeX Preamble..."
1613 "|Start of Appendix%l"
1614 "|Save layout as default"));
1615 fl_setpup_shortcut(LayoutMenu, 1, scex(_("LM|Cc#c#C")));
1616 fl_setpup_shortcut(LayoutMenu, 2, scex(_("LM|Pp#p#P")));
1617 fl_setpup_shortcut(LayoutMenu, 3, scex(_("LM|Dd#d#D")));
1618 fl_setpup_shortcut(LayoutMenu, 4, scex(_("LM|aA#a#A")));
1619 fl_setpup_shortcut(LayoutMenu, 5, scex(_("LM|eE#e#E")));
1620 fl_setpup_shortcut(LayoutMenu, 6, scex(_("LM|Qq#q#Q")));
1621 fl_setpup_shortcut(LayoutMenu, 7, scex(_("LM|mM#m#M")));
1622 fl_setpup_shortcut(LayoutMenu, 8, scex(_("LM|Nn#n#N")));
1623 fl_setpup_shortcut(LayoutMenu, 9, scex(_("LM|Bb#b#B")));
1624 fl_setpup_shortcut(LayoutMenu, 10, scex(_("LM|Tt#t#T")));
1625 fl_setpup_shortcut(LayoutMenu, 11, scex(_("LM|vV#v#V")));
1626 fl_setpup_shortcut(LayoutMenu, 12, scex(_("LM|Ll#l#L")));
1627 fl_setpup_shortcut(LayoutMenu, 13, scex(_("LM|xX#x#X")));
1628 fl_setpup_shortcut(LayoutMenu, 14, scex(_("LM|Ss#s#S")));
1630 // Set values of checkboxes according to font
1631 LyXFont font = men->currentView()->text->real_current_font;
1632 if (font.emph() == LyXFont::ON)
1633 fl_setpup_mode(LayoutMenu, 7, FL_PUP_CHECK);
1634 if (font.noun() == LyXFont::ON)
1635 fl_setpup_mode(LayoutMenu, 8, FL_PUP_CHECK);
1636 if (font.series() == LyXFont::BOLD_SERIES)
1637 fl_setpup_mode(LayoutMenu, 9, FL_PUP_CHECK);
1638 if (font.latex() == LyXFont::ON)
1639 fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
1641 // Grey out unavailable entries
1643 if (!men->currentView()->text->cursor.par()->table)
1644 fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
1646 if (tmpbuffer->isReadonly()) {
1647 fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
1648 fl_setpup_mode(LayoutMenu, 6, FL_PUP_GREY);
1649 fl_setpup_mode(LayoutMenu, 11, FL_PUP_GREY);
1653 men->_view->getForm()->x + ob->x,
1654 men->_view->getForm()->y + ob->y + ob->h + 10);
1655 int choice = fl_dopup(LayoutMenu);
1658 // set the pseudo menu-button back
1659 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1660 fl_redraw_object(ob);
1663 case 1: tmpfunc->Dispatch(LFUN_LAYOUT_CHARACTER); break;
1664 case 2: tmpfunc->Dispatch(LFUN_LAYOUT_PARAGRAPH); break;
1665 case 3: tmpfunc->Dispatch(LFUN_LAYOUT_DOCUMENT); break;
1666 case 4: tmpfunc->Dispatch(LFUN_LAYOUT_PAPER); break;
1667 case 5: tmpfunc->Dispatch(LFUN_LAYOUT_TABLE, "true"); break;
1668 case 6: tmpfunc->Dispatch(LFUN_LAYOUT_QUOTES); break;
1669 case 7: tmpfunc->Dispatch(LFUN_EMPH); break;
1670 case 8: tmpfunc->Dispatch(LFUN_NOUN); break;
1671 case 9: tmpfunc->Dispatch(LFUN_BOLD); break;
1672 case 10: tmpfunc->Dispatch(LFUN_TEX); break;
1673 case 11: tmpfunc->Dispatch(LFUN_DEPTH_PLUS); break;
1674 case 12: tmpfunc->Dispatch(LFUN_LAYOUT_PREAMBLE); break;
1675 case 13: tmpfunc->Dispatch(LFUN_APPENDIX); break;
1676 case 14: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;
1678 fl_freepup(LayoutMenu);
1682 void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
1684 Menus * men = static_cast<Menus*>(ob->u_vdata);
1686 // set the pseudo menu-button
1687 fl_set_object_boxtype(ob, FL_UP_BOX);
1688 fl_set_button(ob, 0);
1689 fl_redraw_object(ob);
1691 Buffer * tmpbuffer = men->_view->buffer();
1692 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1694 int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
1695 _("Import ASCII file%t"
1697 "|As Paragraphs%x42"));
1699 fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
1700 fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
1702 int SubInsertTableList= fl_defpup(FL_ObjWin(ob),
1704 "|Table of Contents%x21"
1705 "|List of Figures%x22"
1706 "|List of Tables%x23"
1707 "|List of Algorithms%x24"
1709 "|BibTeX Reference%x26"));
1711 fl_setpup_shortcut(SubInsertTableList, 21, scex(_("IMT|Cc#c#C")));
1712 fl_setpup_shortcut(SubInsertTableList, 22, scex(_("IMT|Ff#f#F")));
1713 fl_setpup_shortcut(SubInsertTableList, 23, scex(_("IMT|Tt#t#T")));
1714 fl_setpup_shortcut(SubInsertTableList, 24, scex(_("IMT|Aa#a#A")));
1715 fl_setpup_shortcut(SubInsertTableList, 25, scex(_("IMT|Ii#i#I")));
1716 fl_setpup_shortcut(SubInsertTableList, 26, scex(_("IMT|Bb#b#B")));
1718 int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
1722 "|Wide Figure Float%x73"
1723 "|Wide Table Float%l%x74"
1724 "|Algorithm Float%x75"));
1726 fl_setpup_shortcut(SubInsertFloatList, 71, scex(_("IMF|gG#g#G")));
1727 fl_setpup_shortcut(SubInsertFloatList, 72, scex(_("IMF|Tt#t#T")));
1728 fl_setpup_shortcut(SubInsertFloatList, 73, scex(_("IMF|Ww#w#W")));
1729 fl_setpup_shortcut(SubInsertFloatList, 74, scex(_("IMF|iI#i#I")));
1730 fl_setpup_shortcut(SubInsertFloatList, 75, scex(_("IMF|Aa#a#A")));
1732 int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
1733 _("Special Character%t"
1735 "|Hyphenation Point%x32"
1736 "|Protected Blank%x33"
1738 "|Ellipsis (...)%x35"
1739 "|End of sentence period%x36"
1740 "|Ordinary Quote (\")%x37"
1741 "|Menu Separator %x38"));
1743 fl_setpup_shortcut(SubInsertSpecial, 31, scex(_("IMS|Hh#h#H")));
1744 fl_setpup_shortcut(SubInsertSpecial, 32, scex(_("IMS|Pp#p#P")));
1745 fl_setpup_shortcut(SubInsertSpecial, 33, scex(_("IMS|Bb#b#B")));
1746 fl_setpup_shortcut(SubInsertSpecial, 34, scex(_("IMS|Ll#l#L")));
1747 fl_setpup_shortcut(SubInsertSpecial, 35, scex(_("IMS|iI#i#I")));
1748 fl_setpup_shortcut(SubInsertSpecial, 36, scex(_("IMS|Ee#e#E")));
1749 fl_setpup_shortcut(SubInsertSpecial, 37, scex(_("IMS|Qq#q#Q")));
1750 fl_setpup_shortcut(SubInsertSpecial, 38, scex(_("IMS|Mm#m#M")));
1752 int InsertMenu = fl_defpup(FL_ObjWin(ob),
1756 "|Import ASCII File%m"
1757 "|Insert LyX File..."
1758 "|Insert external material...%l"
1763 "|Special Character%m%l"
1766 "|Cross-Reference..."
1767 "|Citation Reference..."
1769 "|Index entry of last word"),
1775 fl_setpup_shortcut(InsertMenu, 1, scex(_("IM|gG#g#G")));
1776 fl_setpup_shortcut(InsertMenu, 2, scex(_("IM|bB#b#B")));
1777 fl_setpup_shortcut(InsertMenu, 3, scex(_("IM|cC#c#C")));
1778 fl_setpup_shortcut(InsertMenu, 4, scex(_("IM|Aa#a#A")));
1779 fl_setpup_shortcut(InsertMenu, 5, scex(_("IM|Xx#x#X")));
1780 fl_setpup_shortcut(InsertMenu, 6, scex(_("IM|Ee#e#E")));
1781 fl_setpup_shortcut(InsertMenu, 7, scex(_("IM|Ff#f#F")));
1782 fl_setpup_shortcut(InsertMenu, 8, scex(_("IM|Mm#m#M")));
1783 fl_setpup_shortcut(InsertMenu, 9, scex(_("IM|oO#o#O")));
1784 fl_setpup_shortcut(InsertMenu, 10, scex(_("IM|Tt#t#T")));
1785 fl_setpup_shortcut(InsertMenu, 11, scex(_("IM|Ss#s#S")));
1786 fl_setpup_shortcut(InsertMenu, 12, scex(_("IM|Nn#n#N")));
1787 fl_setpup_shortcut(InsertMenu, 13, scex(_("IM|Ll#l#L")));
1788 fl_setpup_shortcut(InsertMenu, 14, scex(_("IM|rR#r#R")));
1789 fl_setpup_shortcut(InsertMenu, 15, scex(_("IM|iI#i#I")));
1790 fl_setpup_shortcut(InsertMenu, 16, scex(_("IM|dD#d#D")));
1791 fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|wW#w#W")));
1793 fl_addtopup(InsertMenu, _("|URL..."));
1794 fl_setpup_shortcut(InsertMenu, 18, scex(_("IM|Uu#u#U")));
1796 if (tmpbuffer->isReadonly()) {
1797 for (int ii = 1; ii <= 17; ++ii)
1798 fl_setpup_mode(InsertMenu, ii, FL_PUP_GREY);
1799 fl_setpup_mode(InsertMenu, 18, FL_PUP_GREY);
1803 men->_view->getForm()->x + ob->x,
1804 men->_view->getForm()->y + ob->y + ob->h + 10);
1806 int choice = fl_dopup(InsertMenu);
1809 // set the pseudo menu-button back
1810 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1811 fl_redraw_object(ob);
1813 if (men->currentView()->available()){
1814 men->currentView()->hideCursor();
1816 case 1: tmpfunc->Dispatch(LFUN_FIGURE); break;
1817 case 2: tmpfunc->Dispatch(LFUN_TABLE); break;
1818 case 3: tmpfunc->Dispatch(LFUN_CHILDINSERT); break;
1819 case 4: // Insert ASCII file submenu
1821 case 5: tmpfunc->Dispatch(LFUN_FILE_INSERT); break;
1822 case 41: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "line"); break;
1823 case 42: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "paragraph"); break;
1827 case 6: tmpfunc->Dispatch(LFUN_INSET_EXTERNAL); break;
1831 tmpfunc->Dispatch(LFUN_FOOTMELT); break;
1833 tmpfunc->Dispatch(LFUN_INSET_FOOTNOTE);
1838 tmpfunc->Dispatch(LFUN_MARGINMELT); break;
1840 tmpfunc->Dispatch(LFUN_INSET_MARGINAL);
1844 case 9: // Float sub-menu
1847 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure");
1850 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "figure");
1855 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table");
1858 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "table");
1863 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig");
1866 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "figure");
1871 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab");
1874 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "table");
1879 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm");
1882 tmpfunc->Dispatch(LFUN_INSET_FLOAT, "algorithm");
1885 case 10: // Table/List submenu
1887 case 21: tmpfunc->Dispatch(LFUN_TOC_INSERT); break;
1888 case 22: tmpfunc->Dispatch(LFUN_LOF_INSERT); break;
1889 case 23: tmpfunc->Dispatch(LFUN_LOT_INSERT); break;
1890 case 24: tmpfunc->Dispatch(LFUN_LOA_INSERT); break;
1891 case 25: tmpfunc->Dispatch(LFUN_INDEX_PRINT); break;
1892 case 26: tmpfunc->Dispatch(LFUN_INSERT_BIBTEX); break;
1894 case 11: // Special Character submenu
1896 case 31: tmpfunc->Dispatch(LFUN_HFILL); break;
1897 case 32: tmpfunc->Dispatch(LFUN_HYPHENATION); break;
1898 case 33: tmpfunc->Dispatch(LFUN_PROTECTEDSPACE); break;
1899 case 34: tmpfunc->Dispatch(LFUN_BREAKLINE); break;
1900 case 35: tmpfunc->Dispatch(LFUN_LDOTS); break;
1901 case 36: tmpfunc->Dispatch(LFUN_END_OF_SENTENCE); break;
1902 case 37: tmpfunc->Dispatch(LFUN_QUOTE); break;
1903 case 38: tmpfunc->Dispatch(LFUN_MENU_SEPARATOR); break;
1905 case 12: tmpfunc->Dispatch(LFUN_INSERT_NOTE); break;
1906 case 13: tmpfunc->Dispatch(LFUN_INSERT_LABEL); break;
1907 case 14: tmpfunc->Dispatch(LFUN_INSERT_REF); break;
1908 case 15: tmpfunc->Dispatch(LFUN_CREATE_CITATION); break;
1909 case 16: tmpfunc->Dispatch(LFUN_INDEX_INSERT); break;
1910 case 17: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break;
1911 case 18: tmpfunc->Dispatch(LFUN_URL); break;
1914 fl_freepup(InsertMenu);
1915 fl_freepup(SubInsertAscii);
1916 fl_freepup(SubInsertTableList);
1917 fl_freepup(SubInsertFloatList);
1918 fl_freepup(SubInsertSpecial);
1922 void Menus::ShowMathMenu(FL_OBJECT * ob, long)
1924 extern void math_insert_symbol(char const * s);
1926 Menus * men = static_cast<Menus*>(ob->u_vdata);
1928 // set the pseudo menu-button
1929 fl_set_object_boxtype(ob, FL_UP_BOX);
1930 fl_set_button(ob, 0);
1931 fl_redraw_object(ob);
1933 Buffer * tmpbuffer = men->_view->buffer();
1934 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1936 int MathMenu = fl_defpup(FL_ObjWin(ob),
1947 fl_setpup_shortcut(MathMenu, 1, scex(_("MM|Ff#f#F")));
1948 fl_setpup_shortcut(MathMenu, 2, scex(_("MM|Ss#s#S")));
1949 fl_setpup_shortcut(MathMenu, 3, scex(_("MM|Ee#e#E")));
1950 fl_setpup_shortcut(MathMenu, 4, scex(_("MM|xX#x#X")));
1951 fl_setpup_shortcut(MathMenu, 5, scex(_("MM|uU#u#U")));
1952 fl_setpup_shortcut(MathMenu, 6, scex(_("MM|Ii#i#I")));
1953 fl_setpup_shortcut(MathMenu, 7, scex(_("MM|Mm#m#M")));
1954 fl_setpup_shortcut(MathMenu, 8, scex(_("MM|Dd#d#D")));
1955 fl_setpup_shortcut(MathMenu, 9, scex(_("MM|Pp#p#P")));
1957 if (tmpbuffer->isReadonly())
1958 for (int ii = 1; ii <= 9; ++ii)
1959 fl_setpup_mode(MathMenu, ii, FL_PUP_GREY);
1963 men->_view->getForm()->x + ob->x,
1964 men->_view->getForm()->y + ob->y + ob->h + 10);
1965 int choice = fl_dopup(MathMenu);
1968 // set the pseudo menu-button back
1969 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1970 fl_redraw_object(ob);
1972 if (men->currentView()->available()) {
1975 tmpfunc->Dispatch(LFUN_INSERT_MATH, "frac");
1978 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
1980 case 3: /* Exponent */
1981 tmpfunc->Dispatch(LFUN_INSERT_MATH, "^");
1984 tmpfunc->Dispatch(LFUN_INSERT_MATH, "_");
1987 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sum");
1990 tmpfunc->Dispatch(LFUN_INSERT_MATH, "int");
1993 tmpfunc->Dispatch(LFUN_MATH_MODE);
1996 tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
1999 tmpfunc->Dispatch(LFUN_MATH_PANEL);
2002 men->currentView()->update(BufferView::SELECT|BufferView::FITCUR);
2004 fl_freepup(MathMenu);
2008 void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
2010 Menus * men = static_cast<Menus*>(ob->u_vdata);
2012 // set the pseudo menu-button
2013 fl_set_object_boxtype(ob, FL_UP_BOX);
2014 fl_set_button(ob, 0);
2015 fl_redraw_object(ob);
2017 //Buffer *tmpbuffer = men->_view->currentBuffer();
2018 LyXFunc * tmpfunc = men->_view->getLyXFunc();
2020 int OptionsMenu = fl_defpup(FL_ObjWin(ob),
2022 "|Spellchecker Options..."
2027 fl_setpup_shortcut(OptionsMenu, 1, scex(_("OM|Ff#f#F")));
2028 fl_setpup_shortcut(OptionsMenu, 2, scex(_("OM|Ss#s#S")));
2029 fl_setpup_shortcut(OptionsMenu, 3, scex(_("OM|Kk#k#K")));
2030 fl_setpup_shortcut(OptionsMenu, 4, scex(_("OM|Rr#r#R")));
2031 fl_setpup_shortcut(OptionsMenu, 5, scex(_("OM|Pp#p#P")));
2033 if(lyxrc.isp_command == "none")
2034 fl_setpup_mode(OptionsMenu, 2, FL_PUP_GREY);
2037 men->_view->getForm()->x + ob->x,
2038 men->_view->getForm()->y + ob->y + ob->h + 10);
2039 int choice = fl_dopup(OptionsMenu);
2042 // set the pseudo menu-button back
2043 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2044 fl_redraw_object(ob);
2046 case 1: men->ScreenOptions(); break;
2047 case 2: SpellCheckerOptions(); break;
2048 case 3: men->_view->getIntl()->MenuKeymap(); break;
2049 case 4: tmpfunc->Dispatch(LFUN_RECONFIGURE); break;
2050 case 5: men->_view->getDialogs()->showPreferences(); break;
2053 fl_freepup(OptionsMenu);
2057 void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
2059 Menus * men = static_cast<Menus*>(ob->u_vdata);
2061 // set the pseudo menu-button
2062 fl_set_object_boxtype(ob, FL_UP_BOX);
2063 fl_set_button(ob, 0);
2064 fl_redraw_object(ob);
2066 int BufferMenu = fl_newpup(FL_ObjWin(ob));
2067 vector<string> namevec = bufferlist.getFileNames();
2068 if (namevec.size() != 0) {
2069 for (vector<string>::const_iterator cit = namevec.begin();
2070 cit != namevec.end(); ++cit) {
2071 string relbuf = MakeDisplayPath((*cit), 30);
2072 fl_addtopup(BufferMenu, relbuf.c_str());
2075 fl_addtopup(BufferMenu, _("No Documents Open!%t"));
2079 men->_view->getForm()->x + ob->x,
2080 men->_view->getForm()->y + ob->y + ob->h + 10);
2081 int choice = fl_dopup(BufferMenu);
2084 // set the pseudo menu-button back
2085 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2086 fl_redraw_object(ob);
2087 if (choice > 0) men->handleBufferMenu(choice - 1);
2089 fl_freepup(BufferMenu);
2094 char const * doc_files [] = {"Intro", "Tutorial",
2095 "UserGuide", "Extended",
2096 "Customization", "Reference",
2098 "BUGS", "LyXConfig"};
2100 void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
2102 Menus * men = static_cast<Menus*>(ob->u_vdata);
2103 LyXFunc * tmpfunc = men->_view->getLyXFunc();
2105 // set the pseudo menu-button
2106 fl_set_object_boxtype(ob, FL_UP_BOX);
2107 fl_set_button(ob, 0);
2108 fl_redraw_object(ob);
2110 int HelpMenu = fl_defpup(FL_ObjWin(ob),
2114 "|Extended Features"
2118 "|Table of Contents"
2120 "|LaTeX Configuration%l"
2121 "|Copyright and Warranty..."
2125 fl_setpup_shortcut(HelpMenu, 1, scex(_("HM|Ii#I#i")));
2126 fl_setpup_shortcut(HelpMenu, 2, scex(_("HM|Tt#T#t")));
2127 fl_setpup_shortcut(HelpMenu, 3, scex(_("HM|Uu#U#u")));
2128 fl_setpup_shortcut(HelpMenu, 4, scex(_("HM|xX#x#X")));
2129 fl_setpup_shortcut(HelpMenu, 5, scex(_("HM|Cc#C#c")));
2130 fl_setpup_shortcut(HelpMenu, 6, scex(_("HM|Rr#R#r")));
2131 fl_setpup_shortcut(HelpMenu, 7, scex(_("HM|Ff#F#f")));
2132 fl_setpup_shortcut(HelpMenu, 8, scex(_("HM|aA#a#A")));
2133 fl_setpup_shortcut(HelpMenu, 9, scex(_("HM|Kk#K#k")));
2134 fl_setpup_shortcut(HelpMenu, 10, scex(_("HM|Ll#L#l")));
2135 fl_setpup_shortcut(HelpMenu, 11, scex(_("HM|oO#o#O")));
2136 fl_setpup_shortcut(HelpMenu, 12, scex(_("HM|eE#e#E")));
2137 fl_setpup_shortcut(HelpMenu, 13, scex(_("HM|Vv#v#V")));
2140 men->_view->getForm()->x + ob->x,
2141 men->_view->getForm()->y + ob->y + ob->h + 10);
2142 int choice = fl_dopup(HelpMenu);
2145 // set the pseudo menu-button back
2146 fl_set_object_boxtype(ob, FL_FLAT_BOX);
2147 fl_redraw_object(ob);
2150 case 1: case 2: case 3: case 4: case 5:
2151 case 6: case 7: case 8: case 9: case 10:
2152 ProhibitInput(men->currentView());
2153 men->MenuDocu(doc_files[choice - 1]);
2154 AllowInput(men->currentView());
2156 case 11: tmpfunc->Dispatch(LFUN_HELP_COPYRIGHT); break;
2157 case 12: ShowCredits(); break;
2159 ProhibitInput(men->currentView());
2160 fl_show_message((string(_("LyX Version ")) + LYX_VERSION
2161 + _(" of ") + LYX_RELEASE).c_str(),
2162 (_("Library directory: ")
2163 + MakeDisplayPath(system_lyxdir)).c_str(),
2164 (_("User directory: ")
2165 + MakeDisplayPath(user_lyxdir)).c_str());
2166 AllowInput(men->currentView());
2169 fl_freepup(HelpMenu);
2173 void Menus::MenuDocu(string const & docname)
2175 string fname = i18nLibFileSearch("doc", docname, "lyx");
2176 if (fname.empty()) {
2177 WriteAlert(_("Error!"),
2178 _("Could not find requested Documentation file"),
2182 _view->getMiniBuffer()->Set(_("Opening help file"),
2183 MakeDisplayPath(fname), "...");
2184 currentView()->buffer(bufferlist.loadLyXFile(fname, false));
2186 if (docname == "Reference")
2187 _view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
2191 void Menus::handleBufferMenu(int choice)
2193 currentView()->buffer(bufferlist.getBuffer(choice));