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
34 #include "spellchecker.h"
35 #include "support/filetools.h"
37 #include "lastfiles.h"
38 #include "bufferlist.h"
39 #include "lyx_gui_misc.h"
40 #include "minibuffer.h"
51 extern FD_form_screen * fd_form_screen;
52 extern BufferList bufferlist;
54 // I would really prefere to see most or all of these 'extern's disappear.
55 // Their commands should be called through LyXFunc (IMO). (Lgb)
57 extern void MenuLayoutSave();
58 extern void ShowCredits();
59 extern void ShowCopyright();
60 extern void show_symbols_form(LyXFunc *);
61 extern void ProhibitInput();
62 extern void AllowInput();
63 extern void LaTeXOptions(BufferView *);
65 // A bunch of wrappers
67 extern "C" void C_Menus_ShowFileMenu(FL_OBJECT * ob, long data)
69 Menus::ShowFileMenu(ob, data);
72 extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT * ob, long data)
74 Menus::ShowFileMenu2(ob, data);
77 extern "C" void C_Menus_ShowEditMenu(FL_OBJECT * ob, long data)
79 Menus::ShowEditMenu(ob, data);
82 extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT * ob, long data)
84 Menus::ShowLayoutMenu(ob, data);
87 extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT * ob, long data)
89 Menus::ShowInsertMenu(ob, data);
92 extern "C" void C_Menus_ShowMathMenu(FL_OBJECT * ob, long data)
94 Menus::ShowMathMenu(ob, data);
97 extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT * ob, long data)
99 Menus::ShowOptionsMenu(ob, data);
102 extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT * ob, long data)
104 Menus::ShowBufferMenu(ob, data);
107 extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT * ob, long data)
109 Menus::ShowHelpMenu(ob, data);
113 Menus::Menus(LyXView * view, int air)
117 // deactivate the menu accelerators
118 fl_set_object_shortcut(menu_file, "", 1);
119 fl_set_object_shortcut(menu_file2, "", 1);
120 fl_set_object_shortcut(menu_edit, "", 1);
121 fl_set_object_shortcut(menu_layout, "", 1);
122 fl_set_object_shortcut(menu_math, "", 1);
123 fl_set_object_shortcut(menu_insert, "", 1);
124 fl_set_object_shortcut(menu_options, "", 1);
125 fl_set_object_shortcut(menu_options2, "", 1);
126 fl_set_object_shortcut(menu_buffer, "", 1);
127 fl_set_object_shortcut(menu_help, "", 1);
128 fl_set_object_shortcut(menu_help2, "", 1);
134 BufferView * Menus::currentView()
136 return _view->view();
140 void Menus::showMenus()
142 fl_hide_object(menu_grp2);
143 fl_show_object(menu_grp1);
147 void Menus::hideMenus()
149 fl_hide_object(menu_grp1);
150 fl_show_object(menu_grp2);
154 void Menus::openByName(string const & menuName)
155 /* Opens the visible menu of given name, or simply does nothing
156 when the name is not known. NOTE THE EXTREMELY STUPID
157 IMPLEMENTATION! :-) There are probably hundred ways to do
158 this better, for instance, by scanning the menu objects and
159 testing for the given name. I leave this as an exercise for an
160 experienced GG (GUI Guy/Girl). RVDK_PATCH_5. */
162 if (menu_file->visible) {
163 if (menuName == _("File"))
164 ShowFileMenu(menu_file, 0);
165 else if (menuName == _("Edit"))
166 ShowEditMenu(menu_edit, 0);
167 else if (menuName == _("Layout"))
168 ShowLayoutMenu(menu_layout, 0);
169 else if (menuName == _("Insert"))
170 ShowInsertMenu(menu_insert, 0);
171 else if (menuName == _("Math"))
172 ShowMathMenu(menu_math, 0);
173 else if (menuName == _("Options"))
174 ShowOptionsMenu(menu_options, 0);
175 else if (menuName == _("Documents"))
176 ShowBufferMenu(menu_buffer, 0);
177 else if (menuName == _("Help"))
178 ShowHelpMenu(menu_help, 0);
179 else lyxerr << "The menu '" << menuName
180 << "' is not available." << endl;
182 if (menuName == _("File"))
183 ShowFileMenu2(menu_file2, 0);
184 else if (menuName == _("Options"))
185 ShowOptionsMenu(menu_options2, 0);
186 else if (menuName == _("Help"))
187 ShowHelpMenu(menu_help2, 0);
188 else lyxerr << "The menu '" << menuName
189 << "' is not available." << endl;
194 void Menus::create_menus(int air)
196 FL_FORM * form = _view->getForm();
198 // Here I'd really like to see code like:
202 const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
203 const int mheight = 30;
204 const int mbheight= 22;
205 // where to place the menubar?
206 const int yloc = (mheight - mbheight)/2; //air + bw;
207 const int mbadd = 20; // menu button add (to width)
211 obj = fl_add_frame(FL_UP_FRAME, 0, 0, form->w, mheight, "");
212 fl_set_object_resize(obj, FL_RESIZE_ALL);
213 fl_set_object_gravity(obj, NorthWestGravity, NorthEastGravity);
215 menu_grp1 = fl_bgn_group();
219 fl_add_button(FL_TOUCH_BUTTON,
221 fl_get_string_width(FL_BOLD_STYLE,
224 strlen(_("File"))) + mbadd,
225 mbheight, _("File"));
226 moffset += obj->w + air;
227 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
228 fl_set_object_callback(obj, C_Menus_ShowFileMenu, 0);
233 fl_add_button(FL_TOUCH_BUTTON,
235 fl_get_string_width(FL_BOLD_STYLE,
238 strlen(_("Edit"))) + mbadd,
239 mbheight, _("Edit"));
240 moffset += obj->w + air;
241 fl_set_object_shortcut(obj, scex(_("MB|#E")), 1);
242 fl_set_object_callback(obj, C_Menus_ShowEditMenu, 0);
245 // Layout menu button
247 fl_add_button(FL_TOUCH_BUTTON,
249 fl_get_string_width(FL_BOLD_STYLE,
252 strlen(_("Layout"))) + mbadd,
253 mbheight, _("Layout"));
254 moffset += obj->w + air;
255 fl_set_object_shortcut(obj, scex(_("MB|#L")), 1);
256 fl_set_object_callback(obj, C_Menus_ShowLayoutMenu, 0);
259 // Insert menu button button
261 fl_add_button(FL_TOUCH_BUTTON,
263 fl_get_string_width(FL_BOLD_STYLE,
266 strlen(_("Insert"))) + mbadd,
267 mbheight, _("Insert"));
268 moffset += obj->w + air;
269 fl_set_object_shortcut(obj, scex(_("MB|#I")), 1);
270 fl_set_object_callback(obj, C_Menus_ShowInsertMenu, 0);
275 fl_add_button(FL_TOUCH_BUTTON,
277 fl_get_string_width(FL_BOLD_STYLE,
280 strlen(_("Math"))) + mbadd,
281 mbheight, _("Math"));
282 moffset += obj->w + air;
283 fl_set_object_shortcut(obj, scex(_("MB|#M")), 1);
284 fl_set_object_callback(obj, C_Menus_ShowMathMenu, 0);
287 // Options menu button
289 fl_add_button(FL_TOUCH_BUTTON,
291 fl_get_string_width(FL_BOLD_STYLE,
294 strlen(_("Options"))) + mbadd,
295 mbheight, _("Options"));
296 moffset += obj->w + air;
297 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
298 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
301 // Documents menu button
303 fl_add_button(FL_TOUCH_BUTTON,
305 fl_get_string_width(FL_BOLD_STYLE,
308 strlen(_("Documents"))) + mbadd,
309 mbheight, _("Documents"));
310 moffset += obj->w + air;
311 fl_set_object_shortcut(obj, scex(_("MB|#D")), 1);
312 fl_set_object_callback(obj, C_Menus_ShowBufferMenu, 0);
317 fl_add_button(FL_TOUCH_BUTTON,
319 fl_get_string_width(FL_BOLD_STYLE,
322 strlen(_("Help"))) + mbadd,
323 mbheight, _("Help"));
324 moffset += obj->w + air;
325 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
326 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
331 // Set the menu buttons atrributes.
332 // Due to a bug in xforms we cant do this only an the group.
333 obj = menu_grp1->next;
335 fl_set_object_boxtype(obj, FL_FLAT_BOX);
336 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
337 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
338 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
339 fl_set_object_resize(obj, FL_RESIZE_ALL);
340 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
342 } while (obj != 0 && obj->objclass != FL_END_GROUP);
346 menu_grp2 = fl_bgn_group();
350 fl_add_button(FL_TOUCH_BUTTON,
352 fl_get_string_width(FL_BOLD_STYLE,
355 strlen(_("File"))) + mbadd,
356 mbheight, _("File"));
357 moffset += obj->w + air;
358 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
359 fl_set_object_callback(obj, C_Menus_ShowFileMenu2, 0);
362 // Options menu button
363 menu_options2 = obj =
364 fl_add_button(FL_TOUCH_BUTTON,
366 fl_get_string_width(FL_BOLD_STYLE,
369 strlen(_("Options"))) +mbadd,
370 mbheight, _("Options"));
371 moffset += obj->w + air;
372 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
373 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
378 fl_add_button(FL_TOUCH_BUTTON,
380 fl_get_string_width(FL_BOLD_STYLE,
383 strlen(_("Help"))) + mbadd,
384 mbheight, _("Help"));
385 moffset += obj->w + air;
386 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
387 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
392 // Set the menu buttons atrributes.
393 // Due to a bug in xforms we cant do this only an the group.
394 obj = menu_grp2->next;
396 fl_set_object_boxtype(obj, FL_FLAT_BOX);
397 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
398 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
399 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
400 fl_set_object_resize(obj, FL_RESIZE_ALL);
401 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
403 } while (obj != 0 && obj->objclass != FL_END_GROUP);
407 void Menus::ScreenOptions()
409 static int ow = -1, oh;
411 // this is not very nice....
412 fl_set_input(fd_form_screen->input_roman,
413 lyxrc.roman_font_name.c_str());
414 fl_set_input(fd_form_screen->input_sans,
415 lyxrc.sans_font_name.c_str());
416 fl_set_input(fd_form_screen->input_typewriter,
417 lyxrc.typewriter_font_name.c_str());
418 fl_set_input(fd_form_screen->input_font_norm,
419 lyxrc.font_norm.c_str());
421 sprintf(tmpstring, "%d", lyxrc.zoom);
422 fl_set_input(fd_form_screen->intinput_size, tmpstring);
423 if (fd_form_screen->form_screen->visible) {
424 fl_raise_form(fd_form_screen->form_screen);
426 fl_show_form(fd_form_screen->form_screen,
427 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
428 _("Screen Options"));
430 ow = fd_form_screen->form_screen->w;
431 oh = fd_form_screen->form_screen->h;
433 fl_set_form_minsize(fd_form_screen->form_screen, ow, oh);
439 // Here comes all the menu callbacks.
442 void Menus::ShowFileMenu(FL_OBJECT * ob, long)
444 Menus * men = static_cast<Menus*>(ob->u_vdata);
446 // Regarding the pseudo-menu-button:
447 // ok, ok this is a hack. It would be better to use the menus of the
448 // xforms 0.8 library. but then all popups have to be defined all the
449 // time, code rewriting would be necessary and contex-depending menus
450 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
451 // course it would be more proper (and little faster). So if anybody
452 // likes to do the cleanup, just do it. Matthias
454 // set the pseudo menu-button
455 fl_set_object_boxtype(ob, FL_UP_BOX);
456 fl_set_button(ob, 0);
457 fl_redraw_object(ob);
459 Buffer * tmpbuffer = men->_view->buffer();
460 LyXFunc * tmpfunc = men->_view->getLyXFunc();
462 bool LinuxDoc = tmpbuffer->isLinuxDoc();
463 bool DocBook = tmpbuffer->isDocBook();
464 bool Literate = tmpbuffer->isLiterate();
468 int SubFileImport = fl_defpup(FL_ObjWin(ob),
471 "|Ascii Text as Lines...%x31"
472 "|Ascii Text as Paragraphs%x32"
476 fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
477 fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
478 fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
479 fl_setpup_shortcut(SubFileImport, 33, scex(_("FIM|Nn#n#N")));
480 fl_setpup_shortcut(SubFileImport, 34, scex(_("FIM|Dd#d#D")));
484 // remember to make this handle linuxdoc too.
485 // and now docbook also.
486 int SubFileExport = 0;
487 if (!LinuxDoc && !DocBook)
488 SubFileExport= fl_defpup(FL_ObjWin(ob),
492 "|as PostScript...%x42"
493 "|as Ascii Text...%x43"
497 SubFileExport= fl_defpup(FL_ObjWin(ob),
499 "|as LinuxDoc...%x40"
501 "|as PostScript...%x42"
502 "|as Ascii Text...%x43"
505 SubFileExport= fl_defpup(FL_ObjWin(ob),
509 "|as PostScript...%x42"
510 "|as Ascii Text...%x43"
513 fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
514 fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
515 fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
516 fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
517 fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
519 if (!LinuxDoc && !DocBook) {
520 fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
523 int FileMenu = fl_defpup(FL_ObjWin(ob),
525 "|New from template..."
539 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
540 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
541 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
542 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Cc#c#C")));
543 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|Ss#s#S")));
544 fl_setpup_shortcut(FileMenu, 6, scex(_("FM|Aa#a#A")));
545 fl_setpup_shortcut(FileMenu, 7, scex(_("FM|Rr#r#R")));
546 fl_setpup_shortcut(FileMenu, 8, scex(_("FM|dD#d#D")));
547 fl_setpup_shortcut(FileMenu, 9, scex(_("FM|wW#w#W")));
548 fl_setpup_shortcut(FileMenu, 10, scex(_("FM|vV#v#V")));
549 fl_setpup_shortcut(FileMenu, 11, scex(_("FM|Uu#u#U")));
550 fl_setpup_shortcut(FileMenu, 12, scex(_("FM|Bb#b#B")));
551 fl_setpup_shortcut(FileMenu, 13, scex(_("FM|Pp#p#P")));
552 fl_setpup_shortcut(FileMenu, 14, scex(_("FM|Ff#f#F")));
554 // These commands are disabled when the corresponding programs
555 // are not installed. I simply grey them out, since I do not
556 // want to change their number (JMarc)
557 bool hasLaTeX = lyxrc.latex_command != "none";
559 if (!hasLaTeX || lyxrc.view_dvi_command == "none")
560 fl_setpup_mode(FileMenu, 8, FL_PUP_GREY);
562 if (!hasLaTeX || lyxrc.view_ps_command == "none")
563 fl_setpup_mode(FileMenu, 9, FL_PUP_GREY);
566 fl_setpup_mode(FileMenu, 10, FL_PUP_GREY);
567 fl_setpup_mode(FileMenu, 11, FL_PUP_GREY);
570 if (lyxrc.literate_command == "none" || ! Literate)
571 fl_setpup_mode(FileMenu, 12, FL_PUP_GREY);
573 if (!hasLaTeX || lyxrc.print_command == "none")
574 fl_setpup_mode(FileMenu, 13, FL_PUP_GREY);
576 if (!hasLaTeX || lyxrc.fax_command == "none")
577 fl_setpup_mode(FileMenu, 14, FL_PUP_GREY);
579 bool hasReLyX = lyxrc.relyx_command != "none";
581 // Disable import LaTeX and Noweb
582 fl_setpup_mode(SubFileImport, 30, FL_PUP_GREY);
583 fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
586 if ( lyxrc.linuxdoc_to_lyx_command == "none")
587 fl_setpup_mode(SubFileImport, 34, FL_PUP_GREY);
590 // Disable export dvi and export postscript
591 fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
592 fl_setpup_mode(SubFileExport, 42, FL_PUP_GREY);
595 if ((!LinuxDoc && !DocBook && lyxrc.html_command == "none") ||
596 ( LinuxDoc && lyxrc.linuxdoc_to_html_command == "none") ||
597 ( DocBook && lyxrc.docbook_to_html_command == "none")) {
598 // Disable export HTML
599 fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
602 // xgettext:no-c-format
603 fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
604 // xgettext:no-c-format
605 fl_addtopup(FileMenu, _("|Export%m%l"), SubFileExport);
606 // xgettext:no-c-format
607 fl_addtopup(FileMenu, _("|Exit%l"));
608 fl_setpup_shortcut(FileMenu, 15, scex(_("FM|Ii#i#I")));
609 fl_setpup_shortcut(FileMenu, 16, scex(_("FM|Ee#e#E")));
610 fl_setpup_shortcut(FileMenu, 17, scex(_("FM|xX#x#X")));
612 // make the lastfiles menu
614 for (LastFiles::Files::const_iterator cit = lastfiles->begin();
615 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
616 string tmp = tostr(ii);
617 string tmp2 = tmp + "#" + tmp;;
618 tmp += ". " + MakeDisplayPath((*cit), 30);
619 fl_addtopup(FileMenu, tmp.c_str());
620 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
625 men->_view->getForm()->x + ob->x,
626 men->_view->getForm()->y + ob->y + ob->h + 10);
627 int choice = fl_dopup(FileMenu);
630 // set the pseudo menu-button back
631 fl_set_object_boxtype(ob, FL_FLAT_BOX);
632 fl_redraw_object(ob);
635 case -1: case 0: // we won't do anything
637 case 1: tmpfunc->Dispatch(LFUN_MENUNEW); break;
638 case 2: tmpfunc->Dispatch(LFUN_MENUNEWTMPLT); break;
639 case 3: tmpfunc->Dispatch(LFUN_MENUOPEN); break;
640 case 4: tmpfunc->Dispatch(LFUN_CLOSEBUFFER); break;
641 case 5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
642 case 6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
643 case 7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
644 case 8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
645 case 9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
646 case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
647 case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
648 case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
649 case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
650 case 14: tmpfunc->Dispatch(LFUN_FAX); break;
651 case 15: // import menu
652 case 30: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
654 case 31: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
656 case 32: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
658 case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
660 case 34: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
662 case 16: // export menu
664 if (!LinuxDoc && !DocBook)
665 tmpfunc->Dispatch(LFUN_EXPORT, "latex");
667 tmpfunc->Dispatch(LFUN_EXPORT, "linuxdoc");
669 tmpfunc->Dispatch(LFUN_EXPORT, "docbook");
671 case 41: tmpfunc->Dispatch(LFUN_EXPORT, "dvi");
673 case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
675 case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
678 if (!LinuxDoc && !DocBook)
679 tmpfunc->Dispatch(LFUN_EXPORT, "html");
681 tmpfunc->Dispatch(LFUN_EXPORT, "html-linuxdoc");
683 tmpfunc->Dispatch(LFUN_EXPORT, "html-docbook");
685 case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
687 case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
689 case 18: // The first item with lastfiles.
693 .loadLyXFile((*lastfiles)[choice - 18]));
696 fl_freepup(SubFileImport);
697 fl_freepup(SubFileExport);
698 fl_freepup(FileMenu);
704 void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
706 Menus * men = static_cast<Menus*>(ob->u_vdata);
708 // Regarding the pseudo-menu-button:
709 // ok, ok this is a hack. It would be better to use the menus of the
710 // xforms 0.8 library. but then all popups have to be defined all the
711 // time, code rewriting would be necessary and contex-depending menus
712 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
713 // course it would be more proper (and little faster). So if anybody
714 // likes to do the cleanup, just do it. Matthias
716 // set the pseudo menu-button
717 fl_set_object_boxtype(ob, FL_UP_BOX);
718 fl_set_button(ob, 0);
719 fl_redraw_object(ob);
721 LyXFunc * tmpfunc = men->_view->getLyXFunc();
725 int SubFileImport = fl_defpup(FL_ObjWin(ob),
728 "|Ascii Text as Lines...%x16"
729 "|Ascii Text as Paragraphs...%x17"
731 "|LinuxDoc...%x19"));
733 fl_setpup_shortcut(SubFileImport, 15, scex(_("FIM|Ll#l#L")));
734 fl_setpup_shortcut(SubFileImport, 16, scex(_("FIM|Aa#a#A")));
735 fl_setpup_shortcut(SubFileImport, 17, scex(_("FIM|Pp#p#P")));
736 fl_setpup_shortcut(SubFileImport, 18, scex(_("FIM|Nn#n#N")));
737 fl_setpup_shortcut(SubFileImport, 19, scex(_("FIM|Dd#d#D")));
739 bool hasReLyX = lyxrc.relyx_command != "none";
741 // Disable import LaTeX and Noweb
742 fl_setpup_mode(SubFileImport, 15, FL_PUP_GREY);
743 fl_setpup_mode(SubFileImport, 18, FL_PUP_GREY);
746 if ( lyxrc.linuxdoc_to_lyx_command == "none")
747 fl_setpup_mode(SubFileImport, 19, FL_PUP_GREY);
749 // This can be done cleaner later.
750 int FileMenu = fl_defpup(FL_ObjWin(ob),
752 "|New from template..."
755 "|Exit%l"), SubFileImport);
757 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
758 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
759 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
760 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Ii#i#I")));
761 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|xX#x#X")));
763 // make the lastfiles menu
765 for (LastFiles::Files::const_iterator cit = lastfiles->begin();
766 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
767 string tmp = tostr(ii);
768 string tmp2 = tmp + "#" + tmp;;
769 tmp += ". " + MakeDisplayPath((*cit), 30);
770 fl_addtopup(FileMenu, tmp.c_str());
771 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
776 men->_view->getForm()->x + ob->x,
777 men->_view->getForm()->y + ob->y + ob->h + 10);
778 int choice = fl_dopup(FileMenu);
781 // set the pseudo menu-button back
782 fl_set_object_boxtype(ob, FL_FLAT_BOX);
783 fl_redraw_object(ob);
786 case -1: case 0: // we won't do anything
789 tmpfunc->Dispatch(LFUN_MENUNEW);
792 tmpfunc->Dispatch(LFUN_MENUNEWTMPLT);
795 tmpfunc->Dispatch(LFUN_MENUOPEN);
797 case 4: // import menu
798 case 15: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
800 case 16: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
802 case 17: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
804 case 18: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
806 case 19: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
809 tmpfunc->Dispatch(LFUN_QUIT);
812 case 6: // The first item with lastfiles.
816 .loadLyXFile((*lastfiles)[choice - 6]));
820 fl_freepup(SubFileImport);
821 fl_freepup(FileMenu);
827 void Menus::ShowEditMenu(FL_OBJECT * ob, long)
829 Menus * men = static_cast<Menus*>(ob->u_vdata);
831 // set the pseudo menu-button
832 fl_set_object_boxtype(ob, FL_UP_BOX);
833 fl_set_button(ob, 0);
834 fl_redraw_object(ob);
836 Buffer * tmpbuffer = men->_view->buffer();
837 LyXFunc * tmpfunc = men->_view->getLyXFunc();
839 // Floats & Insets submenu
840 int SubEditFloats= fl_defpup(FL_ObjWin(ob),
841 _("Floats & Insets%t"
844 "|Open All Footnotes/Margin Notes%x23"
845 "|Close All Footnotes/Margin Notes%x24"
846 "|Open All Figures/Tables%x25"
847 "|Close All Figures/Tables%x26%l"
848 "|Remove all Error Boxes%x27"));
850 fl_setpup_shortcut(SubEditFloats, 21, scex(_("EMF|Oo#o#O")));
851 fl_setpup_shortcut(SubEditFloats, 22, scex(_("EMF|Mm#m#M")));
852 fl_setpup_shortcut(SubEditFloats, 23, scex(_("EMF|Aa#a#A")));
853 fl_setpup_shortcut(SubEditFloats, 24, scex(_("EMF|Cc#c#C")));
854 fl_setpup_shortcut(SubEditFloats, 25, scex(_("EMF|Ff#f#F")));
855 fl_setpup_shortcut(SubEditFloats, 26, scex(_("EMF|Tt#t#T")));
856 fl_setpup_shortcut(SubEditFloats, 27, scex(_("EMF|Rr#r#R")));
859 int SubEditTable = fl_newpup(FL_ObjWin(ob));
860 if (men->currentView()->available() &&
861 men->currentView()->text->cursor.par->table &&
862 !tmpbuffer->isReadonly()){
864 fl_addtopup(SubEditTable, _("Table%t"));
866 if (men->currentView()->text->cursor.par->table->
867 IsMultiColumn(men->currentView()->text->
868 NumberOfCell(men->currentView()->
872 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
874 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
875 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
877 if (men->currentView()->text->cursor.par->table->
878 TopLine(men->currentView()->text->
879 NumberOfCell(men->currentView()->
881 men->currentView()->text->
883 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
885 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
886 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
888 if (men->currentView()->text->cursor.par->table->
889 BottomLine(men->currentView()->text->
890 NumberOfCell(men->currentView()->
894 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
896 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
897 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
899 if (men->currentView()->text->cursor.par->table->
900 LeftLine(men->currentView()->text->
901 NumberOfCell(men->currentView()->
905 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
907 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
908 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
910 if (men->currentView()->text->cursor.par->table->
911 RightLine(men->currentView()->text->
912 NumberOfCell(men->currentView()->
916 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
918 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
919 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
921 int align = men->currentView()->text->cursor.par->
922 table->GetAlignment(men->currentView()->text->
923 NumberOfCell(men->currentView()->
927 if (align == LYX_ALIGN_LEFT)
928 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
930 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
931 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
933 if (align == LYX_ALIGN_RIGHT)
934 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
936 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
937 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
939 if (align == LYX_ALIGN_CENTER)
940 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
942 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
943 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
945 // xgettext:no-c-format
946 fl_addtopup(SubEditTable, _("|Append Row%x32"));
947 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
948 // xgettext:no-c-format
949 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
950 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
951 // xgettext:no-c-format
952 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
953 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
954 // xgettext:no-c-format
955 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
956 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
957 // xgettext:no-c-format
958 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
959 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
962 fl_addtopup(SubEditTable, _("Table%t"));
963 // xgettext:no-c-format
964 fl_addtopup(SubEditTable, _("|Insert table%x31"));
965 fl_setpup_shortcut(SubEditTable, 31, scex(_("EMT|Ii#i#I")));
968 int SubVersionControl = fl_newpup(FL_ObjWin(ob));
969 fl_addtopup(SubVersionControl, _("Version Control%t"));
970 if (tmpbuffer->lyxvc.inUse()) {
971 // xgettext:no-c-format
972 fl_addtopup(SubVersionControl, _("|Register%d%x51"));
973 if (tmpbuffer->isReadonly()) {
974 // signifies that the file is not checked out
975 // xgettext:no-c-format
976 fl_addtopup(SubVersionControl, _("|Check In Changes%d%x52"));
977 // xgettext:no-c-format
978 fl_addtopup(SubVersionControl, _("|Check Out for Edit%x53"));
980 // signifies that the file is checked out
981 // xgettext:no-c-format
982 fl_addtopup(SubVersionControl, _("|Check In Changes%x52"));
983 // xgettext:no-c-format
984 fl_addtopup(SubVersionControl, _("|Check Out for Edit%d%x53"));
986 // xgettext:no-c-format
987 fl_addtopup(SubVersionControl, _("|Revert to last version%x54"));
988 // xgettext:no-c-format
989 fl_addtopup(SubVersionControl, _("|Undo last check in%x55"));
990 // xgettext:no-c-format
991 fl_addtopup(SubVersionControl, _("|Show History%x56"));
993 // xgettext:no-c-format
994 fl_addtopup(SubVersionControl, _("|Register%x51"));
996 // the shortcuts are not good.
997 fl_setpup_shortcut(SubVersionControl, 51, scex(_("EMV|Rr#r#R")));
998 fl_setpup_shortcut(SubVersionControl, 52, scex(_("EMV|Ii#i#I")));
999 fl_setpup_shortcut(SubVersionControl, 53, scex(_("EMV|Oo#o#O")));
1000 fl_setpup_shortcut(SubVersionControl, 54, scex(_("EMV|lL#l#l")));
1001 fl_setpup_shortcut(SubVersionControl, 55, scex(_("EMV|Uu#u#U")));
1002 fl_setpup_shortcut(SubVersionControl, 56, scex(_("EMV|Hh#h#H")));
1004 int EditMenu= fl_defpup(FL_ObjWin(ob),
1010 "|Find & Replace..."
1013 "|Floats & Insets%m"
1017 "|Table of Contents...%l"
1018 "|Version Control%m%l"
1019 "|View LaTeX log file%l"
1020 "|Paste Primary Selection as Lines"
1021 "|Paste Primary Selection as Paragraphs"),
1022 SubEditFloats, SubEditTable, SubVersionControl);
1024 fl_setpup_shortcut(EditMenu, 1, scex(_("EM|Uu#u#U")));
1025 fl_setpup_shortcut(EditMenu, 2, scex(_("EM|Rr#r#R")));
1026 fl_setpup_shortcut(EditMenu, 3, scex(_("EM|Cc#c#C")));
1027 fl_setpup_shortcut(EditMenu, 4, scex(_("EM|oO#o#O")));
1028 fl_setpup_shortcut(EditMenu, 5, scex(_("EM|Pp#p#P")));
1029 fl_setpup_shortcut(EditMenu, 6, scex(_("EM|Ff#f#F")));
1030 fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
1031 fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
1032 fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
1033 fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
1034 fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
1035 fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
1036 fl_setpup_shortcut(EditMenu, 13, scex(_("EM|aA#a#A")));
1037 fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Vv#v#V")));
1038 fl_setpup_shortcut(EditMenu, 15, scex(_("EM|wW#w#W")));
1039 fl_setpup_shortcut(EditMenu, 16, scex(_("EM|Ll#l#L")));
1040 fl_setpup_shortcut(EditMenu, 17, scex(_("EM|gG#g#G")));
1042 // disable unavailable entries.
1043 if(tmpbuffer->undostack.empty())
1044 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1045 if(tmpbuffer->redostack.empty())
1046 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1047 if(lyxrc.isp_command == "none")
1048 fl_setpup_mode(EditMenu, 11, FL_PUP_GREY);
1049 if(lyxrc.chktex_command == "none")
1050 fl_setpup_mode(EditMenu, 12, FL_PUP_GREY);
1052 if (tmpbuffer->isReadonly()) {
1053 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1054 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1055 fl_setpup_mode(EditMenu, 3, FL_PUP_GREY);
1056 fl_setpup_mode(EditMenu, 5, FL_PUP_GREY);
1057 fl_setpup_mode(EditMenu, 16, FL_PUP_GREY);
1058 fl_setpup_mode(EditMenu, 17, FL_PUP_GREY);
1061 fl_setpup_position(men->_view->getForm()->x + ob->x,
1062 men->_view->getForm()->y + ob->y +
1064 int choice = fl_dopup(EditMenu);
1067 // set the pseudo menu-button back
1068 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1069 fl_redraw_object(ob);
1072 case 1: tmpfunc->Dispatch(LFUN_UNDO); break;
1073 case 2: tmpfunc->Dispatch(LFUN_REDO); break;
1074 case 3: tmpfunc->Dispatch(LFUN_CUT); break;
1075 case 4: tmpfunc->Dispatch(LFUN_COPY); break;
1076 case 5: tmpfunc->Dispatch(LFUN_PASTE); break;
1077 case 6: tmpfunc->Dispatch(LFUN_MENUSEARCH); break;
1078 case 7: tmpfunc->Dispatch(LFUN_GOTOERROR); break;
1079 case 8: tmpfunc->Dispatch(LFUN_GOTONOTE); break;
1080 case 9: // floats & insets
1084 case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
1085 case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
1086 case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
1087 case 14: // version control
1089 case 15: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
1090 case 16: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
1091 case 17: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
1093 // floats & insets sub-menu
1094 case 21: men->currentView()->toggleFloat(); break;
1095 case 22: tmpfunc->Dispatch(LFUN_MELT); break;
1096 case 23: men->currentView()->allFloats(1, 0); break;
1097 case 24: men->currentView()->allFloats(0, 0); break;
1098 case 25: men->currentView()->allFloats(1, 1); break;
1099 case 26: men->currentView()->allFloats(0, 1); break;
1100 case 27: tmpfunc->Dispatch(LFUN_REMOVEERRORS); break;
1102 case 31: tmpfunc->Dispatch(LFUN_TABLE); break;
1103 // this is really temporary. We need new function in keybind.C
1104 // These should set the minibuffer, too.
1105 case 32: case 33: case 34:
1106 case 35: case 36: case 37:
1107 case 38: case 39: case 40:
1108 case 41: case 42: case 43:
1110 if (men->currentView()->available()) {
1111 men->currentView()->hideCursor();
1112 if (!men->currentView()->text->selection){
1113 men->currentView()->beforeChange();
1114 men->currentView()->update(-2);
1116 men->currentView()->text->
1117 TableFeatures(choice - 32);
1118 men->currentView()->update(1);
1121 // version control sub-menu
1122 case 51: // register
1123 tmpfunc->Dispatch(LFUN_VC_REGISTER);
1125 case 52: // check in
1126 tmpfunc->Dispatch(LFUN_VC_CHECKIN);
1128 case 53: // check out
1129 tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
1131 case 54: // revert to last
1132 tmpfunc->Dispatch(LFUN_VC_REVERT);
1134 case 55: // undo last
1135 tmpfunc->Dispatch(LFUN_VC_UNDO);
1137 case 56: // show history
1138 tmpfunc->Dispatch(LFUN_VC_HISTORY);
1142 fl_freepup(EditMenu);
1143 fl_freepup(SubEditFloats);
1144 fl_freepup(SubEditTable);
1145 fl_freepup(SubVersionControl);
1149 void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
1151 Menus * men = static_cast<Menus*>(ob->u_vdata);
1153 if (!men->currentView()->available())
1156 // set the pseudo menu-button
1157 fl_set_object_boxtype(ob, FL_UP_BOX);
1158 fl_set_button(ob, 0);
1159 fl_redraw_object(ob);
1161 Buffer * tmpbuffer = men->_view->buffer();
1162 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1164 int LayoutMenu = fl_newpup(FL_ObjWin(ob));
1165 fl_addtopup(LayoutMenu, _("Character..."
1171 "|Emphasize Style%b"
1175 "|Change Environment Depth"
1176 "|LaTeX Preamble...%l"
1177 "|Save layout as default"));
1178 fl_setpup_shortcut(LayoutMenu, 1, scex(_("LM|Cc#c#C")));
1179 fl_setpup_shortcut(LayoutMenu, 2, scex(_("LM|Pp#p#P")));
1180 fl_setpup_shortcut(LayoutMenu, 3, scex(_("LM|Dd#d#D")));
1181 fl_setpup_shortcut(LayoutMenu, 4, scex(_("LM|aA#a#A")));
1182 fl_setpup_shortcut(LayoutMenu, 5, scex(_("LM|eE#e#E")));
1183 fl_setpup_shortcut(LayoutMenu, 6, scex(_("LM|Qq#q#Q")));
1184 fl_setpup_shortcut(LayoutMenu, 7, scex(_("LM|mM#m#M")));
1185 fl_setpup_shortcut(LayoutMenu, 8, scex(_("LM|Nn#n#N")));
1186 fl_setpup_shortcut(LayoutMenu, 9, scex(_("LM|Bb#b#B")));
1187 fl_setpup_shortcut(LayoutMenu, 10, scex(_("LM|Tt#t#T")));
1188 fl_setpup_shortcut(LayoutMenu, 11, scex(_("LM|vV#v#V")));
1189 fl_setpup_shortcut(LayoutMenu, 12, scex(_("LM|Ll#l#L")));
1190 fl_setpup_shortcut(LayoutMenu, 13, scex(_("LM|Ss#s#S")));
1192 // Set values of checkboxes according to font
1193 LyXFont font = men->currentView()->text->real_current_font;
1194 if (font.emph() == LyXFont::ON)
1195 fl_setpup_mode(LayoutMenu, 7, FL_PUP_CHECK);
1196 if (font.noun() == LyXFont::ON)
1197 fl_setpup_mode(LayoutMenu, 8, FL_PUP_CHECK);
1198 if (font.series() == LyXFont::BOLD_SERIES)
1199 fl_setpup_mode(LayoutMenu, 9, FL_PUP_CHECK);
1200 if (font.latex() == LyXFont::ON)
1201 fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
1203 // Grey out unavailable entries
1204 if (!men->currentView()->text->cursor.par->table)
1205 fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
1207 if (tmpbuffer->isReadonly()) {
1208 fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
1209 fl_setpup_mode(LayoutMenu, 6, FL_PUP_GREY);
1210 fl_setpup_mode(LayoutMenu, 11, FL_PUP_GREY);
1214 men->_view->getForm()->x + ob->x,
1215 men->_view->getForm()->y + ob->y + ob->h + 10);
1216 int choice = fl_dopup(LayoutMenu);
1219 // set the pseudo menu-button back
1220 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1221 fl_redraw_object(ob);
1224 case 1: tmpfunc->Dispatch(LFUN_LAYOUT_CHARACTER); break;
1225 case 2: tmpfunc->Dispatch(LFUN_LAYOUT_PARAGRAPH); break;
1226 case 3: tmpfunc->Dispatch(LFUN_LAYOUT_DOCUMENT); break;
1227 case 4: tmpfunc->Dispatch(LFUN_LAYOUT_PAPER); break;
1228 case 5: tmpfunc->Dispatch(LFUN_LAYOUT_TABLE, "true"); break;
1229 case 6: tmpfunc->Dispatch(LFUN_LAYOUT_QUOTES); break;
1230 case 7: tmpfunc->Dispatch(LFUN_EMPH); break;
1231 case 8: tmpfunc->Dispatch(LFUN_NOUN); break;
1232 case 9: tmpfunc->Dispatch(LFUN_BOLD); break;
1233 case 10: tmpfunc->Dispatch(LFUN_TEX); break;
1234 case 11: tmpfunc->Dispatch(LFUN_DEPTH_PLUS); break;
1235 case 12: tmpfunc->Dispatch(LFUN_LAYOUT_PREAMBLE); break;
1236 case 13: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;
1238 fl_freepup(LayoutMenu);
1242 void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
1244 Menus * men = static_cast<Menus*>(ob->u_vdata);
1246 // set the pseudo menu-button
1247 fl_set_object_boxtype(ob, FL_UP_BOX);
1248 fl_set_button(ob, 0);
1249 fl_redraw_object(ob);
1251 Buffer * tmpbuffer = men->_view->buffer();
1252 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1254 int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
1255 _("Import ASCII file%t"
1257 "|As Paragraphs%x42"));
1259 fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
1260 fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
1262 int SubInsertTableList= fl_defpup(FL_ObjWin(ob),
1264 "|Table of Contents%x21"
1265 "|List of Figures%x22"
1266 "|List of Tables%x23"
1267 "|List of Algorithms%x24"
1269 "|BibTeX Reference%x26"));
1271 fl_setpup_shortcut(SubInsertTableList, 21, scex(_("IMT|Cc#c#C")));
1272 fl_setpup_shortcut(SubInsertTableList, 22, scex(_("IMT|Ff#f#F")));
1273 fl_setpup_shortcut(SubInsertTableList, 23, scex(_("IMT|Tt#t#T")));
1274 fl_setpup_shortcut(SubInsertTableList, 24, scex(_("IMT|Aa#a#A")));
1275 fl_setpup_shortcut(SubInsertTableList, 25, scex(_("IMT|Ii#i#I")));
1276 fl_setpup_shortcut(SubInsertTableList, 26, scex(_("IMT|Bb#b#B")));
1278 int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
1282 "|Wide Figure Float%x73"
1283 "|Wide Table Float%l%x74"
1284 "|Algorithm Float%x75"));
1286 fl_setpup_shortcut(SubInsertFloatList, 71, scex(_("IMF|gG#g#G")));
1287 fl_setpup_shortcut(SubInsertFloatList, 72, scex(_("IMF|Tt#t#T")));
1288 fl_setpup_shortcut(SubInsertFloatList, 73, scex(_("IMF|Ww#w#W")));
1289 fl_setpup_shortcut(SubInsertFloatList, 74, scex(_("IMF|iI#i#I")));
1290 fl_setpup_shortcut(SubInsertFloatList, 75, scex(_("IMF|Aa#a#A")));
1292 int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
1293 _("Special Character%t"
1295 "|Hyphenation Point%x32"
1296 "|Protected Blank%x33"
1298 "|Ellipsis (...)%x35"
1299 "|End of sentence period%x36"
1300 "|Ordinary Quote (\")%x37"
1301 "|Menu Separator %x38"));
1303 fl_setpup_shortcut(SubInsertSpecial, 31, scex(_("IMS|Hh#h#H")));
1304 fl_setpup_shortcut(SubInsertSpecial, 32, scex(_("IMS|Pp#p#P")));
1305 fl_setpup_shortcut(SubInsertSpecial, 33, scex(_("IMS|Bb#b#B")));
1306 fl_setpup_shortcut(SubInsertSpecial, 34, scex(_("IMS|Ll#l#L")));
1307 fl_setpup_shortcut(SubInsertSpecial, 35, scex(_("IMS|iI#i#I")));
1308 fl_setpup_shortcut(SubInsertSpecial, 36, scex(_("IMS|Ee#e#E")));
1309 fl_setpup_shortcut(SubInsertSpecial, 37, scex(_("IMS|Qq#q#Q")));
1310 fl_setpup_shortcut(SubInsertSpecial, 38, scex(_("IMS|Mm#m#M")));
1312 int InsertMenu = fl_defpup(FL_ObjWin(ob),
1316 "|Import ASCII File%m"
1317 "|Insert LyX File...%l"
1322 "|Special Character%m%l"
1325 "|Cross-Reference..."
1326 "|Citation Reference..."
1328 "|Index entry of last word"),
1334 fl_setpup_shortcut(InsertMenu, 1, scex(_("IM|gG#g#G")));
1335 fl_setpup_shortcut(InsertMenu, 2, scex(_("IM|bB#b#B")));
1336 fl_setpup_shortcut(InsertMenu, 3, scex(_("IM|cC#c#C")));
1337 fl_setpup_shortcut(InsertMenu, 4, scex(_("IM|Aa#a#A")));
1338 fl_setpup_shortcut(InsertMenu, 5, scex(_("IM|Xx#x#X")));
1339 fl_setpup_shortcut(InsertMenu, 6, scex(_("IM|Ff#f#F")));
1340 fl_setpup_shortcut(InsertMenu, 7, scex(_("IM|Mm#m#M")));
1341 fl_setpup_shortcut(InsertMenu, 8, scex(_("IM|oO#o#O")));
1342 fl_setpup_shortcut(InsertMenu, 9, scex(_("IM|Tt#t#T")));
1343 fl_setpup_shortcut(InsertMenu, 10, scex(_("IM|Ss#s#S")));
1344 fl_setpup_shortcut(InsertMenu, 11, scex(_("IM|Nn#n#N")));
1345 fl_setpup_shortcut(InsertMenu, 12, scex(_("IM|Ll#l#L")));
1346 fl_setpup_shortcut(InsertMenu, 13, scex(_("IM|rR#r#R")));
1347 fl_setpup_shortcut(InsertMenu, 14, scex(_("IM|iI#i#I")));
1348 fl_setpup_shortcut(InsertMenu, 15, scex(_("IM|dD#d#D")));
1349 fl_setpup_shortcut(InsertMenu, 16, scex(_("IM|wW#w#W")));
1351 fl_addtopup(InsertMenu, _("|URL..."));
1352 fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|Uu#u#U")));
1354 if (tmpbuffer->isReadonly()) {
1355 for (int ii = 1; ii <= 16; ++ii)
1356 fl_setpup_mode(InsertMenu, ii, FL_PUP_GREY);
1357 fl_setpup_mode(InsertMenu, 17, FL_PUP_GREY);
1361 men->_view->getForm()->x + ob->x,
1362 men->_view->getForm()->y + ob->y + ob->h + 10);
1364 int choice = fl_dopup(InsertMenu);
1367 // set the pseudo menu-button back
1368 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1369 fl_redraw_object(ob);
1371 if (men->currentView()->available()){
1372 men->currentView()->hideCursor();
1374 case 1: tmpfunc->Dispatch(LFUN_FIGURE); break;
1375 case 2: tmpfunc->Dispatch(LFUN_TABLE); break;
1376 case 3: tmpfunc->Dispatch(LFUN_CHILDINSERT); break;
1377 case 4: // Insert ASCII file submenu
1379 case 5: tmpfunc->Dispatch(LFUN_FILE_INSERT); break;
1380 case 41: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "line"); break;
1381 case 42: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "paragraph"); break;
1385 case 6: tmpfunc->Dispatch(LFUN_FOOTMELT); break
1387 case 7: tmpfunc->Dispatch(LFUN_MARGINMELT); break;
1389 case 8: // Float sub-menu
1391 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure");
1394 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table");
1397 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig");
1400 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab");
1403 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm");
1406 case 9: // Table/List submenu
1408 case 21: tmpfunc->Dispatch(LFUN_TOC_INSERT); break;
1409 case 22: tmpfunc->Dispatch(LFUN_LOF_INSERT); break;
1410 case 23: tmpfunc->Dispatch(LFUN_LOT_INSERT); break;
1411 case 24: tmpfunc->Dispatch(LFUN_LOA_INSERT); break;
1412 case 25: tmpfunc->Dispatch(LFUN_INDEX_PRINT); break;
1413 case 26: tmpfunc->Dispatch(LFUN_INSERT_BIBTEX); break;
1415 case 10: // Special Character submenu
1417 case 31: tmpfunc->Dispatch(LFUN_HFILL); break;
1418 case 32: tmpfunc->Dispatch(LFUN_HYPHENATION); break;
1419 case 33: tmpfunc->Dispatch(LFUN_PROTECTEDSPACE); break;
1420 case 34: tmpfunc->Dispatch(LFUN_BREAKLINE); break;
1421 case 35: tmpfunc->Dispatch(LFUN_LDOTS); break;
1422 case 36: tmpfunc->Dispatch(LFUN_END_OF_SENTENCE); break;
1423 case 37: tmpfunc->Dispatch(LFUN_QUOTE); break;
1424 case 38: tmpfunc->Dispatch(LFUN_MENU_SEPARATOR); break;
1426 case 11: tmpfunc->Dispatch(LFUN_INSERT_NOTE); break;
1427 case 12: tmpfunc->Dispatch(LFUN_INSERT_LABEL); break;
1428 case 13: tmpfunc->Dispatch(LFUN_INSERT_REF); break;
1429 case 14: tmpfunc->Dispatch(LFUN_INSERT_CITATION); break;
1430 case 15: tmpfunc->Dispatch(LFUN_INDEX_INSERT); break;
1431 case 16: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break;
1432 case 17: tmpfunc->Dispatch(LFUN_URL); break;
1435 fl_freepup(InsertMenu);
1436 fl_freepup(SubInsertAscii);
1437 fl_freepup(SubInsertTableList);
1438 fl_freepup(SubInsertFloatList);
1439 fl_freepup(SubInsertSpecial);
1443 void Menus::ShowMathMenu(FL_OBJECT * ob, long)
1445 extern void math_insert_symbol(char const * s);
1447 Menus * men = static_cast<Menus*>(ob->u_vdata);
1449 // set the pseudo menu-button
1450 fl_set_object_boxtype(ob, FL_UP_BOX);
1451 fl_set_button(ob, 0);
1452 fl_redraw_object(ob);
1454 Buffer * tmpbuffer = men->_view->buffer();
1455 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1457 int MathMenu = fl_defpup(FL_ObjWin(ob),
1468 fl_setpup_shortcut(MathMenu, 1, scex(_("MM|Ff#f#F")));
1469 fl_setpup_shortcut(MathMenu, 2, scex(_("MM|Ss#s#S")));
1470 fl_setpup_shortcut(MathMenu, 3, scex(_("MM|Ee#e#E")));
1471 fl_setpup_shortcut(MathMenu, 4, scex(_("MM|xX#x#X")));
1472 fl_setpup_shortcut(MathMenu, 5, scex(_("MM|uU#u#U")));
1473 fl_setpup_shortcut(MathMenu, 6, scex(_("MM|Ii#i#I")));
1474 fl_setpup_shortcut(MathMenu, 7, scex(_("MM|Mm#m#M")));
1475 fl_setpup_shortcut(MathMenu, 8, scex(_("MM|Dd#d#D")));
1476 fl_setpup_shortcut(MathMenu, 9, scex(_("MM|Pp#p#P")));
1478 if (tmpbuffer->isReadonly())
1479 for (int ii = 1; ii <= 9; ++ii)
1480 fl_setpup_mode(MathMenu, ii, FL_PUP_GREY);
1484 men->_view->getForm()->x + ob->x,
1485 men->_view->getForm()->y + ob->y + ob->h + 10);
1486 int choice = fl_dopup(MathMenu);
1489 // set the pseudo menu-button back
1490 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1491 fl_redraw_object(ob);
1493 if (men->currentView()->available()) {
1496 tmpfunc->Dispatch(LFUN_INSERT_MATH, "frac");
1499 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
1501 case 3: /* Exponent */
1502 tmpfunc->Dispatch(LFUN_INSERT_MATH, "^");
1505 tmpfunc->Dispatch(LFUN_INSERT_MATH, "_");
1508 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sum");
1511 tmpfunc->Dispatch(LFUN_INSERT_MATH, "int");
1514 tmpfunc->Dispatch(LFUN_MATH_MODE);
1517 tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
1520 show_symbols_form(tmpfunc);
1523 men->currentView()->update(0);
1525 fl_freepup(MathMenu);
1529 void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
1531 Menus * men = static_cast<Menus*>(ob->u_vdata);
1533 // set the pseudo menu-button
1534 fl_set_object_boxtype(ob, FL_UP_BOX);
1535 fl_set_button(ob, 0);
1536 fl_redraw_object(ob);
1538 //Buffer *tmpbuffer = men->_view->currentBuffer();
1539 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1541 int OptionsMenu = fl_defpup(FL_ObjWin(ob),
1543 "|Spellchecker Options..."
1548 fl_setpup_shortcut(OptionsMenu, 1, scex(_("OM|Ff#f#F")));
1549 fl_setpup_shortcut(OptionsMenu, 2, scex(_("OM|Ss#s#S")));
1550 fl_setpup_shortcut(OptionsMenu, 3, scex(_("OM|Kk#k#K")));
1551 fl_setpup_shortcut(OptionsMenu, 4, scex(_("OM|Ll#l#L")));
1552 fl_setpup_shortcut(OptionsMenu, 5, scex(_("OM|Rr#r#R")));
1554 if(lyxrc.isp_command == "none")
1555 fl_setpup_mode(OptionsMenu, 2, FL_PUP_GREY);
1558 men->_view->getForm()->x + ob->x,
1559 men->_view->getForm()->y + ob->y + ob->h + 10);
1560 int choice = fl_dopup(OptionsMenu);
1563 // set the pseudo menu-button back
1564 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1565 fl_redraw_object(ob);
1567 case 1: men->ScreenOptions(); break;
1568 case 2: SpellCheckerOptions(); break;
1569 case 3: men->_view->getIntl()->MenuKeymap(); break;
1570 case 4: LaTeXOptions(men->_view->view()); break;
1571 case 5: tmpfunc->Dispatch(LFUN_RECONFIGURE); break;
1574 fl_freepup(OptionsMenu);
1578 void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
1580 Menus * men = static_cast<Menus*>(ob->u_vdata);
1582 // set the pseudo menu-button
1583 fl_set_object_boxtype(ob, FL_UP_BOX);
1584 fl_set_button(ob, 0);
1585 fl_redraw_object(ob);
1587 int BufferMenu = fl_newpup(FL_ObjWin(ob));
1588 vector<string> namevec = bufferlist.getFileNames();
1589 if (namevec.size() != 0) {
1590 for (vector<string>::const_iterator cit = namevec.begin();
1591 cit != namevec.end(); ++cit) {
1592 string relbuf = MakeDisplayPath((*cit), 30);
1593 fl_addtopup(BufferMenu, relbuf.c_str());
1596 fl_addtopup(BufferMenu, _("No Documents Open!%t"));
1600 men->_view->getForm()->x + ob->x,
1601 men->_view->getForm()->y + ob->y + ob->h + 10);
1602 int choice = fl_dopup(BufferMenu);
1605 // set the pseudo menu-button back
1606 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1607 fl_redraw_object(ob);
1608 if (choice > 0) men->handleBufferMenu(choice - 1);
1610 fl_freepup(BufferMenu);
1615 char const * doc_files [] = {"Intro", "Tutorial",
1616 "UserGuide", "Extended",
1617 "Customization", "Reference",
1618 "BUGS", "LaTeXConfig"};
1620 void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
1622 Menus * men = static_cast<Menus*>(ob->u_vdata);
1624 // set the pseudo menu-button
1625 fl_set_object_boxtype(ob, FL_UP_BOX);
1626 fl_set_button(ob, 0);
1627 fl_redraw_object(ob);
1629 int HelpMenu = fl_defpup(FL_ObjWin(ob),
1633 "|Extended Features"
1637 "|LaTeX Configuration%l"
1638 "|Copyright and Warranty..."
1642 fl_setpup_shortcut(HelpMenu, 1, scex(_("HM|Ii#I#i")));
1643 fl_setpup_shortcut(HelpMenu, 2, scex(_("HM|Tt#T#t")));
1644 fl_setpup_shortcut(HelpMenu, 3, scex(_("HM|Uu#U#u")));
1645 fl_setpup_shortcut(HelpMenu, 4, scex(_("HM|xX#x#X")));
1646 fl_setpup_shortcut(HelpMenu, 5, scex(_("HM|Cc#C#c")));
1647 fl_setpup_shortcut(HelpMenu, 6, scex(_("HM|Rr#R#r")));
1648 fl_setpup_shortcut(HelpMenu, 7, scex(_("HM|Kk#K#k")));
1649 fl_setpup_shortcut(HelpMenu, 8, scex(_("HM|Ll#L#l")));
1650 fl_setpup_shortcut(HelpMenu, 9, scex(_("HM|oO#o#O")));
1651 fl_setpup_shortcut(HelpMenu, 10, scex(_("HM|eE#e#E")));
1652 fl_setpup_shortcut(HelpMenu, 11, scex(_("HM|Vv#v#V")));
1655 men->_view->getForm()->x + ob->x,
1656 men->_view->getForm()->y + ob->y + ob->h + 10);
1657 int choice = fl_dopup(HelpMenu);
1660 // set the pseudo menu-button back
1661 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1662 fl_redraw_object(ob);
1665 case 1: case 2: case 3: case 4: case 5:
1666 case 6: case 7: case 8:
1668 men->MenuDocu(doc_files[choice - 1]);
1671 case 9: ShowCopyright(); break;
1672 case 10: ShowCredits(); break;
1675 fl_show_message((string(_("LyX Version ")) + LYX_VERSION
1676 + _(" of ") + LYX_RELEASE).c_str(),
1677 (_("Library directory: ")
1678 + MakeDisplayPath(system_lyxdir)).c_str(),
1679 (_("User directory: ")
1680 + MakeDisplayPath(user_lyxdir)).c_str());
1684 fl_freepup(HelpMenu);
1688 void Menus::MenuDocu(string const & docname)
1690 string fname = i18nLibFileSearch("doc", docname, "lyx");
1691 if (fname.empty()) {
1692 WriteAlert(_("Error!"),
1693 _("Could not find requested Documentation file"),
1697 _view->getMiniBuffer()->Set(_("Opening help file"),
1698 MakeDisplayPath(fname), "...");
1699 currentView()->buffer(bufferlist.loadLyXFile(fname, false));
1701 if (docname == "Reference")
1702 _view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
1706 void Menus::handleBufferMenu(int choice)
1708 currentView()->buffer(bufferlist.getBuffer(choice));