3 * ==================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 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
35 #include "spellchecker.h"
36 #include "support/filetools.h"
38 #include "lastfiles.h"
39 #include "bufferlist.h"
40 #include "lyx_gui_misc.h"
41 #include "minibuffer.h"
42 #include "lyxscreen.h"
50 extern FD_form_screen * fd_form_screen;
51 extern BufferList bufferlist;
53 // I would really prefere to see most or all of these 'extern's disappear.
54 // Their commands should be called through LyXFunc (IMO). (Lgb)
56 extern void MenuLayoutSave();
57 extern void ShowCredits();
58 extern void ShowCopyright();
59 extern void show_symbols_form(LyXFunc *);
60 extern void ProhibitInput();
61 extern void AllowInput();
62 extern void LaTeXOptions();
64 // A bunch of wrappers
66 extern "C" void C_Menus_ShowFileMenu(FL_OBJECT * ob, long data)
68 Menus::ShowFileMenu(ob, data);
71 extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT * ob, long data)
73 Menus::ShowFileMenu2(ob, data);
76 extern "C" void C_Menus_ShowEditMenu(FL_OBJECT * ob, long data)
78 Menus::ShowEditMenu(ob, data);
81 extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT * ob, long data)
83 Menus::ShowLayoutMenu(ob, data);
86 extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT * ob, long data)
88 Menus::ShowInsertMenu(ob, data);
91 extern "C" void C_Menus_ShowMathMenu(FL_OBJECT * ob, long data)
93 Menus::ShowMathMenu(ob, data);
96 extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT * ob, long data)
98 Menus::ShowOptionsMenu(ob, data);
101 extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT * ob, long data)
103 Menus::ShowBufferMenu(ob, data);
106 extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT * ob, long data)
108 Menus::ShowHelpMenu(ob, data);
112 Menus::Menus(LyXView * view, int air)
116 // deactivate the menu accelerators
117 fl_set_object_shortcut(menu_file, "", 1);
118 fl_set_object_shortcut(menu_file2, "", 1);
119 fl_set_object_shortcut(menu_edit, "", 1);
120 fl_set_object_shortcut(menu_layout, "", 1);
121 fl_set_object_shortcut(menu_math, "", 1);
122 fl_set_object_shortcut(menu_insert, "", 1);
123 fl_set_object_shortcut(menu_options, "", 1);
124 fl_set_object_shortcut(menu_options2, "", 1);
125 fl_set_object_shortcut(menu_buffer, "", 1);
126 fl_set_object_shortcut(menu_help, "", 1);
127 fl_set_object_shortcut(menu_help2, "", 1);
132 inline BufferView * Menus::currentView()
134 return _view->view();
138 void Menus::showMenus()
140 fl_hide_object(menu_grp2);
141 fl_show_object(menu_grp1);
145 void Menus::hideMenus()
147 fl_hide_object(menu_grp1);
148 fl_show_object(menu_grp2);
152 void Menus::openByName(string const & menuName)
153 /* Opens the visible menu of given name, or simply does nothing
154 when the name is not known. NOTE THE EXTREMELY STUPID
155 IMPLEMENTATION! :-) There are probably hundred ways to do
156 this better, for instance, by scanning the menu objects and
157 testing for the given name. I leave this as an exercise for an
158 experienced GG (GUI Guy/Girl). RVDK_PATCH_5. */
160 if (menu_file->visible) {
161 if (menuName == _("File"))
162 ShowFileMenu(menu_file, 0);
163 else if (menuName == _("Edit"))
164 ShowEditMenu(menu_edit, 0);
165 else if (menuName == _("Layout"))
166 ShowLayoutMenu(menu_layout, 0);
167 else if (menuName == _("Insert"))
168 ShowInsertMenu(menu_insert, 0);
169 else if (menuName == _("Math"))
170 ShowMathMenu(menu_math, 0);
171 else if (menuName == _("Options"))
172 ShowOptionsMenu(menu_options, 0);
173 else if (menuName == _("Documents"))
174 ShowBufferMenu(menu_buffer, 0);
175 else if (menuName == _("Help"))
176 ShowHelpMenu(menu_help, 0);
177 else lyxerr << "The menu '" << menuName
178 << "' is not available." << endl;
180 if (menuName == _("File"))
181 ShowFileMenu2(menu_file2, 0);
182 else if (menuName == _("Options"))
183 ShowOptionsMenu(menu_options2, 0);
184 else if (menuName == _("Help"))
185 ShowHelpMenu(menu_help2, 0);
186 else lyxerr << "The menu '" << menuName
187 << "' is not available." << endl;
192 void Menus::create_menus(int air)
194 FL_FORM * form = _view->getForm();
196 // Here I'd really like to see code like:
200 const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
201 const int mheight = 30;
202 const int mbheight= 22;
203 // where to place the menubar?
204 const int yloc = (mheight - mbheight)/2; //air + bw;
205 const int mbadd = 20; // menu button add (to width)
209 obj = fl_add_frame(FL_UP_FRAME, 0, 0, form->w, mheight, "");
210 fl_set_object_resize(obj, FL_RESIZE_ALL);
211 fl_set_object_gravity(obj, NorthWestGravity, NorthEastGravity);
213 menu_grp1 = fl_bgn_group();
217 fl_add_button(FL_TOUCH_BUTTON,
219 fl_get_string_width(FL_BOLD_STYLE,
222 strlen(_("File"))) + mbadd,
223 mbheight, _("File"));
224 moffset += obj->w + air;
225 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
226 fl_set_object_callback(obj, C_Menus_ShowFileMenu, 0);
231 fl_add_button(FL_TOUCH_BUTTON,
233 fl_get_string_width(FL_BOLD_STYLE,
236 strlen(_("Edit"))) + mbadd,
237 mbheight, _("Edit"));
238 moffset += obj->w + air;
239 fl_set_object_shortcut(obj, scex(_("MB|#E")), 1);
240 fl_set_object_callback(obj, C_Menus_ShowEditMenu, 0);
243 // Layout menu button
245 fl_add_button(FL_TOUCH_BUTTON,
247 fl_get_string_width(FL_BOLD_STYLE,
250 strlen(_("Layout"))) + mbadd,
251 mbheight, _("Layout"));
252 moffset += obj->w + air;
253 fl_set_object_shortcut(obj, scex(_("MB|#L")), 1);
254 fl_set_object_callback(obj, C_Menus_ShowLayoutMenu, 0);
257 // Insert menu button button
259 fl_add_button(FL_TOUCH_BUTTON,
261 fl_get_string_width(FL_BOLD_STYLE,
264 strlen(_("Insert"))) + mbadd,
265 mbheight, _("Insert"));
266 moffset += obj->w + air;
267 fl_set_object_shortcut(obj, scex(_("MB|#I")), 1);
268 fl_set_object_callback(obj, C_Menus_ShowInsertMenu, 0);
273 fl_add_button(FL_TOUCH_BUTTON,
275 fl_get_string_width(FL_BOLD_STYLE,
278 strlen(_("Math"))) + mbadd,
279 mbheight, _("Math"));
280 moffset += obj->w + air;
281 fl_set_object_shortcut(obj, scex(_("MB|#M")), 1);
282 fl_set_object_callback(obj, C_Menus_ShowMathMenu, 0);
285 // Options menu button
287 fl_add_button(FL_TOUCH_BUTTON,
289 fl_get_string_width(FL_BOLD_STYLE,
292 strlen(_("Options"))) + mbadd,
293 mbheight, _("Options"));
294 moffset += obj->w + air;
295 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
296 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
299 // Documents menu button
301 fl_add_button(FL_TOUCH_BUTTON,
303 fl_get_string_width(FL_BOLD_STYLE,
306 strlen(_("Documents"))) + mbadd,
307 mbheight, _("Documents"));
308 moffset += obj->w + air;
309 fl_set_object_shortcut(obj, scex(_("MB|#D")), 1);
310 fl_set_object_callback(obj, C_Menus_ShowBufferMenu, 0);
315 fl_add_button(FL_TOUCH_BUTTON,
317 fl_get_string_width(FL_BOLD_STYLE,
320 strlen(_("Help"))) + mbadd,
321 mbheight, _("Help"));
322 moffset += obj->w + air;
323 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
324 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
329 // Set the menu buttons atrributes.
330 // Due to a bug in xforms we cant do this only an the group.
331 obj = menu_grp1->next;
333 fl_set_object_boxtype(obj, FL_FLAT_BOX);
334 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
335 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
336 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
337 fl_set_object_resize(obj, FL_RESIZE_ALL);
338 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
340 } while (obj != 0 && obj->objclass != FL_END_GROUP);
344 menu_grp2 = fl_bgn_group();
348 fl_add_button(FL_TOUCH_BUTTON,
350 fl_get_string_width(FL_BOLD_STYLE,
353 strlen(_("File"))) + mbadd,
354 mbheight, _("File"));
355 moffset += obj->w + air;
356 fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
357 fl_set_object_callback(obj, C_Menus_ShowFileMenu2, 0);
360 // Options menu button
361 menu_options2 = obj =
362 fl_add_button(FL_TOUCH_BUTTON,
364 fl_get_string_width(FL_BOLD_STYLE,
367 strlen(_("Options"))) +mbadd,
368 mbheight, _("Options"));
369 moffset += obj->w + air;
370 fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
371 fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
376 fl_add_button(FL_TOUCH_BUTTON,
378 fl_get_string_width(FL_BOLD_STYLE,
381 strlen(_("Help"))) + mbadd,
382 mbheight, _("Help"));
383 moffset += obj->w + air;
384 fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
385 fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
390 // Set the menu buttons atrributes.
391 // Due to a bug in xforms we cant do this only an the group.
392 obj = menu_grp2->next;
394 fl_set_object_boxtype(obj, FL_FLAT_BOX);
395 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
396 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
397 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
398 fl_set_object_resize(obj, FL_RESIZE_ALL);
399 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
401 } while (obj != 0 && obj->objclass != FL_END_GROUP);
405 void Menus::ScreenOptions()
407 static int ow = -1, oh;
409 // this is not very nice....
410 fl_set_input(fd_form_screen->input_roman,
411 lyxrc->roman_font_name.c_str());
412 fl_set_input(fd_form_screen->input_sans,
413 lyxrc->sans_font_name.c_str());
414 fl_set_input(fd_form_screen->input_typewriter,
415 lyxrc->typewriter_font_name.c_str());
416 fl_set_input(fd_form_screen->input_font_norm,
417 lyxrc->font_norm.c_str());
419 sprintf(tmpstring, "%d", lyxrc->zoom);
420 fl_set_input(fd_form_screen->intinput_size, tmpstring);
421 if (fd_form_screen->form_screen->visible) {
422 fl_raise_form(fd_form_screen->form_screen);
424 fl_show_form(fd_form_screen->form_screen,
425 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
426 _("Screen Options"));
428 ow = fd_form_screen->form_screen->w;
429 oh = fd_form_screen->form_screen->h;
431 fl_set_form_minsize(fd_form_screen->form_screen, ow, oh);
437 // Here comes all the menu callbacks.
440 void Menus::ShowFileMenu(FL_OBJECT * ob, long)
442 Menus * men = static_cast<Menus*>(ob->u_vdata);
444 // Regarding the pseudo-menu-button:
445 // ok, ok this is a hack. It would be better to use the menus of the
446 // xforms 0.8 library. but then all popups have to be defined all the
447 // time, code rewriting would be necessary and contex-depending menus
448 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
449 // course it would be more proper (and little faster). So if anybody
450 // likes to do the cleanup, just do it. Matthias
452 // set the pseudo menu-button
453 fl_set_object_boxtype(ob, FL_UP_BOX);
454 fl_set_button(ob, 0);
455 fl_redraw_object(ob);
457 Buffer * tmpbuffer = men->_view->buffer();
458 LyXFunc * tmpfunc = men->_view->getLyXFunc();
460 bool LinuxDoc = tmpbuffer->isLinuxDoc();
461 bool DocBook = tmpbuffer->isDocBook();
462 bool Literate = tmpbuffer->isLiterate();
466 int SubFileImport = fl_defpup(FL_ObjWin(ob),
469 "|Ascii Text as Lines...%x31"
470 "|Ascii Text as Paragraphs%x32"
473 fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
474 fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
475 fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
476 fl_setpup_shortcut(SubFileImport, 33, scex(_("FIM|Nn#n#N")));
480 // remember to make this handle linuxdoc too.
481 // and now docbook also.
482 int SubFileExport = 0;
483 if (!LinuxDoc && !DocBook)
484 SubFileExport= fl_defpup(FL_ObjWin(ob),
488 "|as PostScript...%x42"
489 "|as Ascii Text...%x43"
493 SubFileExport= fl_defpup(FL_ObjWin(ob),
495 "|as LinuxDoc...%x40"
497 "|as PostScript...%x42"
498 "|as Ascii Text...%x43"));
500 SubFileExport= fl_defpup(FL_ObjWin(ob),
504 "|as PostScript...%x42"
505 "|as Ascii Text...%x43"));
507 fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
508 fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
509 fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
510 fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
511 if (!LinuxDoc && !DocBook) {
512 fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
513 fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
516 int FileMenu = fl_defpup(FL_ObjWin(ob),
518 "|New from template..."
532 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
533 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
534 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
535 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Cc#c#C")));
536 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|Ss#s#S")));
537 fl_setpup_shortcut(FileMenu, 6, scex(_("FM|Aa#a#A")));
538 fl_setpup_shortcut(FileMenu, 7, scex(_("FM|Rr#r#R")));
539 fl_setpup_shortcut(FileMenu, 8, scex(_("FM|dD#d#D")));
540 fl_setpup_shortcut(FileMenu, 9, scex(_("FM|wW#w#W")));
541 fl_setpup_shortcut(FileMenu, 10, scex(_("FM|vV#v#V")));
542 fl_setpup_shortcut(FileMenu, 11, scex(_("FM|Uu#u#U")));
543 fl_setpup_shortcut(FileMenu, 12, scex(_("FM|Bb#b#B")));
544 fl_setpup_shortcut(FileMenu, 13, scex(_("FM|Pp#p#P")));
545 fl_setpup_shortcut(FileMenu, 14, scex(_("FM|Ff#f#F")));
547 // These commands are disabled when the corresponding programs
548 // are not installed. I simply grey them out, since I do not
549 // want to change their number (JMarc)
550 bool hasLaTeX = lyxrc->latex_command != "none";
552 if (!hasLaTeX || lyxrc->view_dvi_command == "none")
553 fl_setpup_mode(FileMenu, 8, FL_PUP_GREY);
555 if (!hasLaTeX || lyxrc->view_ps_command == "none")
556 fl_setpup_mode(FileMenu, 9, FL_PUP_GREY);
559 fl_setpup_mode(FileMenu, 10, FL_PUP_GREY);
560 fl_setpup_mode(FileMenu, 11, FL_PUP_GREY);
563 if (lyxrc->literate_command == "none" || ! Literate)
564 fl_setpup_mode(FileMenu, 12, FL_PUP_GREY);
566 if (!hasLaTeX || lyxrc->print_command == "none")
567 fl_setpup_mode(FileMenu, 13, FL_PUP_GREY);
569 if (!hasLaTeX || lyxrc->fax_command == "none")
570 fl_setpup_mode(FileMenu, 14, FL_PUP_GREY);
572 bool hasReLyX = lyxrc->relyx_command != "none";
574 // Disable import LaTeX and Noweb
575 fl_setpup_mode(SubFileImport, 30, FL_PUP_GREY);
576 fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
580 // Disable export dvi and export postscript
581 fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
582 fl_setpup_mode(SubFileExport, 42, FL_PUP_GREY);
585 if (lyxrc->html_command == "none") {
586 // Disable export HTML
587 fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
590 // xgettext:no-c-format
591 fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
592 // xgettext:no-c-format
593 fl_addtopup(FileMenu, _("|Export%m%l"), SubFileExport);
594 // xgettext:no-c-format
595 fl_addtopup(FileMenu, _("|Exit%l"));
596 fl_setpup_shortcut(FileMenu, 15, scex(_("FM|Ii#i#I")));
597 fl_setpup_shortcut(FileMenu, 16, scex(_("FM|Ee#e#E")));
598 fl_setpup_shortcut(FileMenu, 17, scex(_("FM|xX#x#X")));
600 // make the lastfiles menu
602 for (LastFiles::Files::const_iterator cit = lastfiles->begin();
603 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
604 string tmp = tostr(ii);
605 string tmp2 = tmp + "#" + tmp;;
606 tmp += ". " + MakeDisplayPath((*cit), 30);
607 fl_addtopup(FileMenu, tmp.c_str());
608 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
613 men->_view->getForm()->x + ob->x,
614 men->_view->getForm()->y + ob->y + ob->h + 10);
615 int choice = fl_dopup(FileMenu);
618 // set the pseudo menu-button back
619 fl_set_object_boxtype(ob, FL_FLAT_BOX);
620 fl_redraw_object(ob);
623 case -1: case 0: // we won't do anything
625 case 1: tmpfunc->Dispatch(LFUN_MENUNEW); break;
626 case 2: tmpfunc->Dispatch(LFUN_MENUNEWTMPLT); break;
627 case 3: tmpfunc->Dispatch(LFUN_MENUOPEN); break;
628 case 4: tmpfunc->Dispatch(LFUN_CLOSEBUFFER); break;
629 case 5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
630 case 6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
631 case 7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
632 case 8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
633 case 9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
634 case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
635 case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
636 case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
637 case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
638 case 14: tmpfunc->Dispatch(LFUN_FAX); break;
639 case 15: // import menu
640 case 30: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
642 case 31: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
644 case 32: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
646 case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
648 case 16: // export menu
650 if (!LinuxDoc && !DocBook)
651 tmpfunc->Dispatch(LFUN_EXPORT, "latex");
653 tmpfunc->Dispatch(LFUN_EXPORT, "linuxdoc");
655 tmpfunc->Dispatch(LFUN_EXPORT, "docbook");
657 case 41: tmpfunc->Dispatch(LFUN_EXPORT, "dvi");
659 case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
661 case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
663 case 44: tmpfunc->Dispatch(LFUN_EXPORT, "html");
665 case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
667 case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
669 case 18: // The first item with lastfiles.
673 .loadLyXFile((*lastfiles)[choice - 18]));
676 fl_freepup(SubFileImport);
677 fl_freepup(SubFileExport);
678 fl_freepup(FileMenu);
684 void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
686 Menus * men = static_cast<Menus*>(ob->u_vdata);
688 // Regarding the pseudo-menu-button:
689 // ok, ok this is a hack. It would be better to use the menus of the
690 // xforms 0.8 library. but then all popups have to be defined all the
691 // time, code rewriting would be necessary and contex-depending menus
692 // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
693 // course it would be more proper (and little faster). So if anybody
694 // likes to do the cleanup, just do it. Matthias
696 // set the pseudo menu-button
697 fl_set_object_boxtype(ob, FL_UP_BOX);
698 fl_set_button(ob, 0);
699 fl_redraw_object(ob);
701 LyXFunc * tmpfunc = men->_view->getLyXFunc();
705 int SubFileImport = fl_defpup(FL_ObjWin(ob),
708 "|Ascii Text as Lines...%x16"
709 "|Ascii Text as Paragraphs...%x17"
712 fl_setpup_shortcut(SubFileImport, 15, scex(_("FIM|Ll#l#L")));
713 fl_setpup_shortcut(SubFileImport, 16, scex(_("FIM|Aa#a#A")));
714 fl_setpup_shortcut(SubFileImport, 17, scex(_("FIM|Pp#p#P")));
715 fl_setpup_shortcut(SubFileImport, 18, scex(_("FIM|Nn#n#N")));
717 bool hasReLyX = lyxrc->relyx_command != "none";
719 // Disable import LaTeX and Noweb
720 fl_setpup_mode(SubFileImport, 15, FL_PUP_GREY);
721 fl_setpup_mode(SubFileImport, 18, FL_PUP_GREY);
724 // This can be done cleaner later.
725 int FileMenu = fl_defpup(FL_ObjWin(ob),
727 "|New from template..."
730 "|Exit%l"), SubFileImport);
732 fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
733 fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
734 fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
735 fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Ii#i#I")));
736 fl_setpup_shortcut(FileMenu, 5, scex(_("FM|xX#x#X")));
738 // make the lastfiles menu
740 for (LastFiles::Files::const_iterator cit = lastfiles->begin();
741 cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
742 string tmp = tostr(ii);
743 string tmp2 = tmp + "#" + tmp;;
744 tmp += ". " + MakeDisplayPath((*cit), 30);
745 fl_addtopup(FileMenu, tmp.c_str());
746 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
751 men->_view->getForm()->x + ob->x,
752 men->_view->getForm()->y + ob->y + ob->h + 10);
753 int choice = fl_dopup(FileMenu);
756 // set the pseudo menu-button back
757 fl_set_object_boxtype(ob, FL_FLAT_BOX);
758 fl_redraw_object(ob);
761 case -1: case 0: // we won't do anything
764 tmpfunc->Dispatch(LFUN_MENUNEW);
767 tmpfunc->Dispatch(LFUN_MENUNEWTMPLT);
770 tmpfunc->Dispatch(LFUN_MENUOPEN);
772 case 4: // import menu
773 case 15: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
775 case 16: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
777 case 17: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
779 case 18: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
782 tmpfunc->Dispatch(LFUN_QUIT);
785 case 6: // The first item with lastfiles.
789 .loadLyXFile((*lastfiles)[choice - 6]));
793 fl_freepup(SubFileImport);
794 fl_freepup(FileMenu);
800 void Menus::ShowEditMenu(FL_OBJECT * ob, long)
802 Menus * men = static_cast<Menus*>(ob->u_vdata);
804 // set the pseudo menu-button
805 fl_set_object_boxtype(ob, FL_UP_BOX);
806 fl_set_button(ob, 0);
807 fl_redraw_object(ob);
809 Buffer * tmpbuffer = men->_view->buffer();
810 LyXFunc * tmpfunc = men->_view->getLyXFunc();
812 // Floats & Insets submenu
813 int SubEditFloats= fl_defpup(FL_ObjWin(ob),
814 _("Floats & Insets%t"
817 "|Open All Footnotes/Margin Notes%x23"
818 "|Close All Footnotes/Margin Notes%x24"
819 "|Open All Figures/Tables%x25"
820 "|Close All Figures/Tables%x26%l"
821 "|Remove all Error Boxes%x27"));
823 fl_setpup_shortcut(SubEditFloats, 21, scex(_("EMF|Oo#o#O")));
824 fl_setpup_shortcut(SubEditFloats, 22, scex(_("EMF|Mm#m#M")));
825 fl_setpup_shortcut(SubEditFloats, 23, scex(_("EMF|Aa#a#A")));
826 fl_setpup_shortcut(SubEditFloats, 24, scex(_("EMF|Cc#c#C")));
827 fl_setpup_shortcut(SubEditFloats, 25, scex(_("EMF|Ff#f#F")));
828 fl_setpup_shortcut(SubEditFloats, 26, scex(_("EMF|Tt#t#T")));
829 fl_setpup_shortcut(SubEditFloats, 27, scex(_("EMF|Rr#r#R")));
832 int SubEditTable = fl_newpup(FL_ObjWin(ob));
833 if (men->currentView()->available() &&
834 men->currentView()->text->cursor.par->table &&
835 !tmpbuffer->isReadonly()){
837 fl_addtopup(SubEditTable, _("Table%t"));
839 if (men->currentView()->text->cursor.par->table->
840 IsMultiColumn(men->currentView()->text->
841 NumberOfCell(men->currentView()->
845 fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
847 fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
848 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
850 if (men->currentView()->text->cursor.par->table->
851 TopLine(men->currentView()->text->
852 NumberOfCell(men->currentView()->
854 men->currentView()->text->
856 fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
858 fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
859 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
861 if (men->currentView()->text->cursor.par->table->
862 BottomLine(men->currentView()->text->
863 NumberOfCell(men->currentView()->
867 fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
869 fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
870 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
872 if (men->currentView()->text->cursor.par->table->
873 LeftLine(men->currentView()->text->
874 NumberOfCell(men->currentView()->
878 fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
880 fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
881 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
883 if (men->currentView()->text->cursor.par->table->
884 RightLine(men->currentView()->text->
885 NumberOfCell(men->currentView()->
889 fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
891 fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
892 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
894 int align = men->currentView()->text->cursor.par->
895 table->GetAlignment(men->currentView()->text->
896 NumberOfCell(men->currentView()->
900 if (align == LYX_ALIGN_LEFT)
901 fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
903 fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
904 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
906 if (align == LYX_ALIGN_RIGHT)
907 fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
909 fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
910 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
912 if (align == LYX_ALIGN_CENTER)
913 fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
915 fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
916 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
918 // xgettext:no-c-format
919 fl_addtopup(SubEditTable, _("|Append Row%x32"));
920 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
921 // xgettext:no-c-format
922 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
923 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
924 // xgettext:no-c-format
925 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
926 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
927 // xgettext:no-c-format
928 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
929 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
930 // xgettext:no-c-format
931 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
932 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
935 fl_addtopup(SubEditTable, _("Table%t"));
936 // xgettext:no-c-format
937 fl_addtopup(SubEditTable, _("|Insert table%x31"));
938 fl_setpup_shortcut(SubEditTable, 31, scex(_("EMT|Ii#i#I")));
941 int SubVersionControl = fl_newpup(FL_ObjWin(ob));
942 fl_addtopup(SubVersionControl, _("Version Control%t"));
943 if (tmpbuffer->lyxvc.inUse()) {
944 // xgettext:no-c-format
945 fl_addtopup(SubVersionControl, _("|Register%d%x51"));
946 if (tmpbuffer->isReadonly()) {
947 // signifies that the file is not checked out
948 // xgettext:no-c-format
949 fl_addtopup(SubVersionControl, _("|Check In Changes%d%x52"));
950 // xgettext:no-c-format
951 fl_addtopup(SubVersionControl, _("|Check Out for Edit%x53"));
953 // signifies that the file is checked out
954 // xgettext:no-c-format
955 fl_addtopup(SubVersionControl, _("|Check In Changes%x52"));
956 // xgettext:no-c-format
957 fl_addtopup(SubVersionControl, _("|Check Out for Edit%d%x53"));
959 // xgettext:no-c-format
960 fl_addtopup(SubVersionControl, _("|Revert to last version%x54"));
961 // xgettext:no-c-format
962 fl_addtopup(SubVersionControl, _("|Undo last check in%x55"));
963 // xgettext:no-c-format
964 fl_addtopup(SubVersionControl, _("|Show History%x56"));
966 // xgettext:no-c-format
967 fl_addtopup(SubVersionControl, _("|Register%x51"));
969 // the shortcuts are not good.
970 fl_setpup_shortcut(SubVersionControl, 51, scex(_("EMV|Rr#r#R")));
971 fl_setpup_shortcut(SubVersionControl, 52, scex(_("EMV|Ii#i#I")));
972 fl_setpup_shortcut(SubVersionControl, 53, scex(_("EMV|Oo#o#O")));
973 fl_setpup_shortcut(SubVersionControl, 54, scex(_("EMV|lL#l#l")));
974 fl_setpup_shortcut(SubVersionControl, 55, scex(_("EMV|Uu#u#U")));
975 fl_setpup_shortcut(SubVersionControl, 56, scex(_("EMV|Hh#h#H")));
977 int EditMenu= fl_defpup(FL_ObjWin(ob),
990 "|Table of Contents...%l"
991 "|Version Control%m%l"
992 "|View LaTeX log file%l"
993 "|Paste Primary Selection as Lines"
994 "|Paste Primary Selection as Paragraphs"),
995 SubEditFloats, SubEditTable, SubVersionControl);
997 fl_setpup_shortcut(EditMenu, 1, scex(_("EM|Uu#u#U")));
998 fl_setpup_shortcut(EditMenu, 2, scex(_("EM|Rr#r#R")));
999 fl_setpup_shortcut(EditMenu, 3, scex(_("EM|Cc#c#C")));
1000 fl_setpup_shortcut(EditMenu, 4, scex(_("EM|oO#o#O")));
1001 fl_setpup_shortcut(EditMenu, 5, scex(_("EM|Pp#p#P")));
1002 fl_setpup_shortcut(EditMenu, 6, scex(_("EM|Ff#f#F")));
1003 fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
1004 fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
1005 fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
1006 fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
1007 fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
1008 fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
1009 fl_setpup_shortcut(EditMenu, 13, scex(_("EM|aA#a#A")));
1010 fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Vv#v#V")));
1011 fl_setpup_shortcut(EditMenu, 15, scex(_("EM|wW#w#W")));
1012 fl_setpup_shortcut(EditMenu, 16, scex(_("EM|Ll#l#L")));
1013 fl_setpup_shortcut(EditMenu, 17, scex(_("EM|gG#g#G")));
1015 // disable unavailable entries.
1016 if(tmpbuffer->undostack.empty())
1017 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1018 if(tmpbuffer->redostack.empty())
1019 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1020 if(lyxrc->isp_command == "none")
1021 fl_setpup_mode(EditMenu, 11, FL_PUP_GREY);
1022 if(lyxrc->chktex_command == "none")
1023 fl_setpup_mode(EditMenu, 12, FL_PUP_GREY);
1025 if (tmpbuffer->isReadonly()) {
1026 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1027 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1028 fl_setpup_mode(EditMenu, 3, FL_PUP_GREY);
1029 fl_setpup_mode(EditMenu, 5, FL_PUP_GREY);
1030 fl_setpup_mode(EditMenu, 16, FL_PUP_GREY);
1031 fl_setpup_mode(EditMenu, 17, FL_PUP_GREY);
1034 fl_setpup_position(men->_view->getForm()->x + ob->x,
1035 men->_view->getForm()->y + ob->y +
1037 int choice = fl_dopup(EditMenu);
1040 // set the pseudo menu-button back
1041 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1042 fl_redraw_object(ob);
1045 case 1: tmpfunc->Dispatch(LFUN_UNDO); break;
1046 case 2: tmpfunc->Dispatch(LFUN_REDO); break;
1047 case 3: tmpfunc->Dispatch(LFUN_CUT); break;
1048 case 4: tmpfunc->Dispatch(LFUN_COPY); break;
1049 case 5: tmpfunc->Dispatch(LFUN_PASTE); break;
1050 case 6: tmpfunc->Dispatch(LFUN_MENUSEARCH); break;
1051 case 7: tmpfunc->Dispatch(LFUN_GOTOERROR); break;
1052 case 8: tmpfunc->Dispatch(LFUN_GOTONOTE); break;
1053 case 9: // floats & insets
1057 case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
1058 case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
1059 case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
1060 case 14: // version control
1062 case 15: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
1063 case 16: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
1064 case 17: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
1066 // floats & insets sub-menu
1067 case 21: men->currentView()->toggleFloat(); break;
1068 case 22: tmpfunc->Dispatch(LFUN_MELT); break;
1069 case 23: men->currentView()->allFloats(1, 0); break;
1070 case 24: men->currentView()->allFloats(0, 0); break;
1071 case 25: men->currentView()->allFloats(1, 1); break;
1072 case 26: men->currentView()->allFloats(0, 1); break;
1073 case 27: tmpfunc->Dispatch(LFUN_REMOVEERRORS); break;
1075 case 31: tmpfunc->Dispatch(LFUN_TABLE); break;
1076 // this is really temporary. We need new function in keybind.C
1077 // These should set the minibuffer, too.
1078 case 32: case 33: case 34:
1079 case 35: case 36: case 37:
1080 case 38: case 39: case 40:
1081 case 41: case 42: case 43:
1083 if (men->currentView()->available()){
1084 men->currentView()->getScreen()->HideCursor();
1085 if (!men->currentView()->text->selection){
1086 men->currentView()->beforeChange();
1087 men->currentView()->update(-2);
1089 men->currentView()->text->
1090 TableFeatures(choice - 32);
1091 men->currentView()->update(1);
1094 // version control sub-menu
1095 case 51: // register
1096 tmpfunc->Dispatch(LFUN_VC_REGISTER);
1098 case 52: // check in
1099 tmpfunc->Dispatch(LFUN_VC_CHECKIN);
1101 case 53: // check out
1102 tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
1104 case 54: // revert to last
1105 tmpfunc->Dispatch(LFUN_VC_REVERT);
1107 case 55: // undo last
1108 tmpfunc->Dispatch(LFUN_VC_UNDO);
1110 case 56: // show history
1111 tmpfunc->Dispatch(LFUN_VC_HISTORY);
1115 fl_freepup(EditMenu);
1116 fl_freepup(SubEditFloats);
1117 fl_freepup(SubEditTable);
1118 fl_freepup(SubVersionControl);
1122 void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
1124 Menus * men = static_cast<Menus*>(ob->u_vdata);
1126 if (!men->currentView()->available())
1129 // set the pseudo menu-button
1130 fl_set_object_boxtype(ob, FL_UP_BOX);
1131 fl_set_button(ob, 0);
1132 fl_redraw_object(ob);
1134 Buffer * tmpbuffer = men->_view->buffer();
1135 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1137 int LayoutMenu = fl_newpup(FL_ObjWin(ob));
1138 fl_addtopup(LayoutMenu, _("Character..."
1144 "|Emphasize Style%b"
1148 "|Change Environment Depth"
1149 "|LaTeX Preamble...%l"
1150 "|Save layout as default"));
1151 fl_setpup_shortcut(LayoutMenu, 1, scex(_("LM|Cc#c#C")));
1152 fl_setpup_shortcut(LayoutMenu, 2, scex(_("LM|Pp#p#P")));
1153 fl_setpup_shortcut(LayoutMenu, 3, scex(_("LM|Dd#d#D")));
1154 fl_setpup_shortcut(LayoutMenu, 4, scex(_("LM|aA#a#A")));
1155 fl_setpup_shortcut(LayoutMenu, 5, scex(_("LM|eE#e#E")));
1156 fl_setpup_shortcut(LayoutMenu, 6, scex(_("LM|Qq#q#Q")));
1157 fl_setpup_shortcut(LayoutMenu, 7, scex(_("LM|mM#m#M")));
1158 fl_setpup_shortcut(LayoutMenu, 8, scex(_("LM|Nn#n#N")));
1159 fl_setpup_shortcut(LayoutMenu, 9, scex(_("LM|Bb#b#B")));
1160 fl_setpup_shortcut(LayoutMenu, 10, scex(_("LM|Tt#t#T")));
1161 fl_setpup_shortcut(LayoutMenu, 11, scex(_("LM|vV#v#V")));
1162 fl_setpup_shortcut(LayoutMenu, 12, scex(_("LM|Ll#l#L")));
1163 fl_setpup_shortcut(LayoutMenu, 13, scex(_("LM|Ss#s#S")));
1165 // Set values of checkboxes according to font
1166 LyXFont font = men->currentView()->text->real_current_font;
1167 if (font.emph() == LyXFont::ON)
1168 fl_setpup_mode(LayoutMenu, 7, FL_PUP_CHECK);
1169 if (font.noun() == LyXFont::ON)
1170 fl_setpup_mode(LayoutMenu, 8, FL_PUP_CHECK);
1171 if (font.series() == LyXFont::BOLD_SERIES)
1172 fl_setpup_mode(LayoutMenu, 9, FL_PUP_CHECK);
1173 if (font.latex() == LyXFont::ON)
1174 fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
1176 // Grey out unavailable entries
1177 if (!men->currentView()->text->cursor.par->table)
1178 fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
1180 if (tmpbuffer->isReadonly()) {
1181 fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
1182 fl_setpup_mode(LayoutMenu, 6, FL_PUP_GREY);
1183 fl_setpup_mode(LayoutMenu, 11, FL_PUP_GREY);
1187 men->_view->getForm()->x + ob->x,
1188 men->_view->getForm()->y + ob->y + ob->h + 10);
1189 int choice = fl_dopup(LayoutMenu);
1192 // set the pseudo menu-button back
1193 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1194 fl_redraw_object(ob);
1197 case 1: tmpfunc->Dispatch(LFUN_LAYOUT_CHARACTER); break;
1198 case 2: tmpfunc->Dispatch(LFUN_LAYOUT_PARAGRAPH); break;
1199 case 3: tmpfunc->Dispatch(LFUN_LAYOUT_DOCUMENT); break;
1200 case 4: tmpfunc->Dispatch(LFUN_LAYOUT_PAPER); break;
1201 case 5: tmpfunc->Dispatch(LFUN_LAYOUT_TABLE, "true"); break;
1202 case 6: tmpfunc->Dispatch(LFUN_LAYOUT_QUOTES); break;
1203 case 7: tmpfunc->Dispatch(LFUN_EMPH); break;
1204 case 8: tmpfunc->Dispatch(LFUN_NOUN); break;
1205 case 9: tmpfunc->Dispatch(LFUN_BOLD); break;
1206 case 10: tmpfunc->Dispatch(LFUN_TEX); break;
1207 case 11: tmpfunc->Dispatch(LFUN_DEPTH_PLUS); break;
1208 case 12: tmpfunc->Dispatch(LFUN_LAYOUT_PREAMBLE); break;
1209 case 13: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;
1211 fl_freepup(LayoutMenu);
1215 void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
1217 Menus * men = static_cast<Menus*>(ob->u_vdata);
1219 // set the pseudo menu-button
1220 fl_set_object_boxtype(ob, FL_UP_BOX);
1221 fl_set_button(ob, 0);
1222 fl_redraw_object(ob);
1224 Buffer * tmpbuffer = men->_view->buffer();
1225 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1227 int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
1228 _("Import ASCII file%t"
1230 "|As Paragraphs%x42"));
1232 fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
1233 fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
1235 int SubInsertTableList= fl_defpup(FL_ObjWin(ob),
1237 "|Table of Contents%x21"
1238 "|List of Figures%x22"
1239 "|List of Tables%x23"
1240 "|List of Algorithms%x24"
1242 "|BibTeX Reference%x26"));
1244 fl_setpup_shortcut(SubInsertTableList, 21, scex(_("IMT|Cc#c#C")));
1245 fl_setpup_shortcut(SubInsertTableList, 22, scex(_("IMT|Ff#f#F")));
1246 fl_setpup_shortcut(SubInsertTableList, 23, scex(_("IMT|Tt#t#T")));
1247 fl_setpup_shortcut(SubInsertTableList, 24, scex(_("IMT|Aa#a#A")));
1248 fl_setpup_shortcut(SubInsertTableList, 25, scex(_("IMT|Ii#i#I")));
1249 fl_setpup_shortcut(SubInsertTableList, 26, scex(_("IMT|Bb#b#B")));
1251 int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
1255 "|Wide Figure Float%x73"
1256 "|Wide Table Float%l%x74"
1257 "|Algorithm Float%x75"));
1259 fl_setpup_shortcut(SubInsertFloatList, 71, scex(_("IMF|gG#g#G")));
1260 fl_setpup_shortcut(SubInsertFloatList, 72, scex(_("IMF|Tt#t#T")));
1261 fl_setpup_shortcut(SubInsertFloatList, 73, scex(_("IMF|Ww#w#W")));
1262 fl_setpup_shortcut(SubInsertFloatList, 74, scex(_("IMF|iI#i#I")));
1263 fl_setpup_shortcut(SubInsertFloatList, 75, scex(_("IMF|Aa#a#A")));
1265 int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
1266 _("Special Character%t"
1268 "|Hyphenation Point%x32"
1269 "|Protected Blank%x33"
1271 "|Ellipsis (...)%x35"
1272 "|End of sentence period%x36"
1273 "|Ordinary Quote (\")%x37"
1274 "|Menu Separator %x38"));
1276 fl_setpup_shortcut(SubInsertSpecial, 31, scex(_("IMS|Hh#h#H")));
1277 fl_setpup_shortcut(SubInsertSpecial, 32, scex(_("IMS|Pp#p#P")));
1278 fl_setpup_shortcut(SubInsertSpecial, 33, scex(_("IMS|Bb#b#B")));
1279 fl_setpup_shortcut(SubInsertSpecial, 34, scex(_("IMS|Ll#l#L")));
1280 fl_setpup_shortcut(SubInsertSpecial, 35, scex(_("IMS|iI#i#I")));
1281 fl_setpup_shortcut(SubInsertSpecial, 36, scex(_("IMS|Ee#e#E")));
1282 fl_setpup_shortcut(SubInsertSpecial, 37, scex(_("IMS|Qq#q#Q")));
1283 fl_setpup_shortcut(SubInsertSpecial, 38, scex(_("IMS|Mm#m#M")));
1285 int InsertMenu = fl_defpup(FL_ObjWin(ob),
1289 "|Import ASCII File%m"
1290 "|Insert LyX File...%l"
1295 "|Special Character%m%l"
1298 "|Cross-Reference..."
1299 "|Citation Reference..."
1301 "|Index entry of last word"),
1307 fl_setpup_shortcut(InsertMenu, 1, scex(_("IM|gG#g#G")));
1308 fl_setpup_shortcut(InsertMenu, 2, scex(_("IM|bB#b#B")));
1309 fl_setpup_shortcut(InsertMenu, 3, scex(_("IM|cC#c#C")));
1310 fl_setpup_shortcut(InsertMenu, 4, scex(_("IM|Aa#a#A")));
1311 fl_setpup_shortcut(InsertMenu, 5, scex(_("IM|Xx#x#X")));
1312 fl_setpup_shortcut(InsertMenu, 6, scex(_("IM|Ff#f#F")));
1313 fl_setpup_shortcut(InsertMenu, 7, scex(_("IM|Mm#m#M")));
1314 fl_setpup_shortcut(InsertMenu, 8, scex(_("IM|oO#o#O")));
1315 fl_setpup_shortcut(InsertMenu, 9, scex(_("IM|Tt#t#T")));
1316 fl_setpup_shortcut(InsertMenu, 10, scex(_("IM|Ss#s#S")));
1317 fl_setpup_shortcut(InsertMenu, 11, scex(_("IM|Nn#n#N")));
1318 fl_setpup_shortcut(InsertMenu, 12, scex(_("IM|Ll#l#L")));
1319 fl_setpup_shortcut(InsertMenu, 13, scex(_("IM|rR#r#R")));
1320 fl_setpup_shortcut(InsertMenu, 14, scex(_("IM|iI#i#I")));
1321 fl_setpup_shortcut(InsertMenu, 15, scex(_("IM|dD#d#D")));
1322 fl_setpup_shortcut(InsertMenu, 16, scex(_("IM|wW#w#W")));
1324 fl_addtopup(InsertMenu, _("|URL..."));
1325 fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|Uu#u#U")));
1327 if (tmpbuffer->isReadonly()) {
1328 for (int ii = 1; ii <= 16; ii++)
1329 fl_setpup_mode(InsertMenu, ii, FL_PUP_GREY);
1330 fl_setpup_mode(InsertMenu, 17, FL_PUP_GREY);
1334 men->_view->getForm()->x + ob->x,
1335 men->_view->getForm()->y + ob->y + ob->h + 10);
1337 int choice = fl_dopup(InsertMenu);
1340 // set the pseudo menu-button back
1341 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1342 fl_redraw_object(ob);
1344 if (men->currentView()->available()){
1345 men->currentView()->getScreen()->HideCursor();
1347 case 1: tmpfunc->Dispatch(LFUN_FIGURE); break;
1348 case 2: tmpfunc->Dispatch(LFUN_TABLE); break;
1349 case 3: tmpfunc->Dispatch(LFUN_CHILDINSERT); break;
1350 case 4: // Insert ASCII file submenu
1352 case 5: tmpfunc->Dispatch(LFUN_FILE_INSERT); break;
1353 case 41: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "line"); break;
1354 case 42: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "paragraph"); break;
1358 case 6: tmpfunc->Dispatch(LFUN_FOOTMELT); break
1360 case 7: tmpfunc->Dispatch(LFUN_MARGINMELT); break;
1362 case 8: // Float sub-menu
1364 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure");
1367 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table");
1370 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig");
1373 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab");
1376 tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm");
1379 case 9: // Table/List submenu
1381 case 21: tmpfunc->Dispatch(LFUN_TOC_INSERT); break;
1382 case 22: tmpfunc->Dispatch(LFUN_LOF_INSERT); break;
1383 case 23: tmpfunc->Dispatch(LFUN_LOT_INSERT); break;
1384 case 24: tmpfunc->Dispatch(LFUN_LOA_INSERT); break;
1385 case 25: tmpfunc->Dispatch(LFUN_INDEX_PRINT); break;
1386 case 26: tmpfunc->Dispatch(LFUN_INSERT_BIBTEX); break;
1388 case 10: // Special Character submenu
1390 case 31: tmpfunc->Dispatch(LFUN_HFILL); break;
1391 case 32: tmpfunc->Dispatch(LFUN_HYPHENATION); break;
1392 case 33: tmpfunc->Dispatch(LFUN_PROTECTEDSPACE); break;
1393 case 34: tmpfunc->Dispatch(LFUN_BREAKLINE); break;
1394 case 35: tmpfunc->Dispatch(LFUN_LDOTS); break;
1395 case 36: tmpfunc->Dispatch(LFUN_END_OF_SENTENCE); break;
1396 case 37: tmpfunc->Dispatch(LFUN_QUOTE); break;
1397 case 38: tmpfunc->Dispatch(LFUN_MENU_SEPARATOR); break;
1399 case 11: tmpfunc->Dispatch(LFUN_INSERT_NOTE); break;
1400 case 12: tmpfunc->Dispatch(LFUN_INSERT_LABEL); break;
1401 case 13: tmpfunc->Dispatch(LFUN_INSERT_REF); break;
1402 case 14: tmpfunc->Dispatch(LFUN_INSERT_CITATION); break;
1403 case 15: tmpfunc->Dispatch(LFUN_INDEX_INSERT); break;
1404 case 16: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break;
1405 case 17: tmpfunc->Dispatch(LFUN_URL); break;
1408 fl_freepup(InsertMenu);
1409 fl_freepup(SubInsertAscii);
1410 fl_freepup(SubInsertTableList);
1411 fl_freepup(SubInsertFloatList);
1412 fl_freepup(SubInsertSpecial);
1416 void Menus::ShowMathMenu(FL_OBJECT * ob, long)
1418 extern void math_insert_symbol(char const * s);
1420 Menus * men = static_cast<Menus*>(ob->u_vdata);
1422 // set the pseudo menu-button
1423 fl_set_object_boxtype(ob, FL_UP_BOX);
1424 fl_set_button(ob, 0);
1425 fl_redraw_object(ob);
1427 Buffer * tmpbuffer = men->_view->buffer();
1428 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1430 int MathMenu = fl_defpup(FL_ObjWin(ob),
1441 fl_setpup_shortcut(MathMenu, 1, scex(_("MM|Ff#f#F")));
1442 fl_setpup_shortcut(MathMenu, 2, scex(_("MM|Ss#s#S")));
1443 fl_setpup_shortcut(MathMenu, 3, scex(_("MM|Ee#e#E")));
1444 fl_setpup_shortcut(MathMenu, 4, scex(_("MM|xX#x#X")));
1445 fl_setpup_shortcut(MathMenu, 5, scex(_("MM|uU#u#U")));
1446 fl_setpup_shortcut(MathMenu, 6, scex(_("MM|Ii#i#I")));
1447 fl_setpup_shortcut(MathMenu, 7, scex(_("MM|Mm#m#M")));
1448 fl_setpup_shortcut(MathMenu, 8, scex(_("MM|Dd#d#D")));
1449 fl_setpup_shortcut(MathMenu, 9, scex(_("MM|Pp#p#P")));
1451 if (tmpbuffer->isReadonly())
1452 for (int ii = 1; ii <= 9; ii++)
1453 fl_setpup_mode(MathMenu, ii, FL_PUP_GREY);
1457 men->_view->getForm()->x + ob->x,
1458 men->_view->getForm()->y + ob->y + ob->h + 10);
1459 int choice = fl_dopup(MathMenu);
1462 // set the pseudo menu-button back
1463 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1464 fl_redraw_object(ob);
1466 if (men->currentView()->available()) {
1469 tmpfunc->Dispatch(LFUN_INSERT_MATH, "frac");
1472 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
1474 case 3: /* Exponent */
1475 tmpfunc->Dispatch(LFUN_INSERT_MATH, "^");
1478 tmpfunc->Dispatch(LFUN_INSERT_MATH, "_");
1481 tmpfunc->Dispatch(LFUN_INSERT_MATH, "sum");
1484 tmpfunc->Dispatch(LFUN_INSERT_MATH, "int");
1487 tmpfunc->Dispatch(LFUN_MATH_MODE);
1490 tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
1493 show_symbols_form(tmpfunc);
1496 men->currentView()->update(0);
1498 fl_freepup(MathMenu);
1502 void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
1504 Menus * men = static_cast<Menus*>(ob->u_vdata);
1506 // set the pseudo menu-button
1507 fl_set_object_boxtype(ob, FL_UP_BOX);
1508 fl_set_button(ob, 0);
1509 fl_redraw_object(ob);
1511 //Buffer *tmpbuffer = men->_view->currentBuffer();
1512 LyXFunc * tmpfunc = men->_view->getLyXFunc();
1514 int OptionsMenu = fl_defpup(FL_ObjWin(ob),
1516 "|Spellchecker Options..."
1521 fl_setpup_shortcut(OptionsMenu, 1, scex(_("OM|Ff#f#F")));
1522 fl_setpup_shortcut(OptionsMenu, 2, scex(_("OM|Ss#s#S")));
1523 fl_setpup_shortcut(OptionsMenu, 3, scex(_("OM|Kk#k#K")));
1524 fl_setpup_shortcut(OptionsMenu, 4, scex(_("OM|Ll#l#L")));
1525 fl_setpup_shortcut(OptionsMenu, 5, scex(_("OM|Rr#r#R")));
1527 if(lyxrc->isp_command == "none")
1528 fl_setpup_mode(OptionsMenu, 2, FL_PUP_GREY);
1531 men->_view->getForm()->x + ob->x,
1532 men->_view->getForm()->y + ob->y + ob->h + 10);
1533 int choice = fl_dopup(OptionsMenu);
1536 // set the pseudo menu-button back
1537 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1538 fl_redraw_object(ob);
1540 case 1: men->ScreenOptions(); break;
1541 case 2: SpellCheckerOptions(); break;
1542 case 3: men->_view->getIntl()->MenuKeymap(); break;
1543 case 4: LaTeXOptions(); break;
1544 case 5: tmpfunc->Dispatch(LFUN_RECONFIGURE); break;
1547 fl_freepup(OptionsMenu);
1551 void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
1553 Menus * men = static_cast<Menus*>(ob->u_vdata);
1555 // set the pseudo menu-button
1556 fl_set_object_boxtype(ob, FL_UP_BOX);
1557 fl_set_button(ob, 0);
1558 fl_redraw_object(ob);
1560 int BufferMenu = fl_newpup(FL_ObjWin(ob));
1561 bufferlist.makePup(BufferMenu);
1564 men->_view->getForm()->x + ob->x,
1565 men->_view->getForm()->y + ob->y + ob->h + 10);
1566 int choice = fl_dopup(BufferMenu);
1569 // set the pseudo menu-button back
1570 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1571 fl_redraw_object(ob);
1572 if (choice > 0) men->handleBufferMenu(choice - 1);
1574 fl_freepup(BufferMenu);
1579 char const * doc_files [] = {"Intro", "Tutorial",
1580 "UserGuide", "Extended",
1581 "Customization", "Reference",
1582 "BUGS", "LaTeXConfig"};
1584 void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
1586 Menus * men = static_cast<Menus*>(ob->u_vdata);
1588 // set the pseudo menu-button
1589 fl_set_object_boxtype(ob, FL_UP_BOX);
1590 fl_set_button(ob, 0);
1591 fl_redraw_object(ob);
1593 int HelpMenu = fl_defpup(FL_ObjWin(ob),
1597 "|Extended Features"
1601 "|LaTeX Configuration%l"
1602 "|Copyright and Warranty..."
1606 fl_setpup_shortcut(HelpMenu, 1, scex(_("HM|Ii#I#i")));
1607 fl_setpup_shortcut(HelpMenu, 2, scex(_("HM|Tt#T#t")));
1608 fl_setpup_shortcut(HelpMenu, 3, scex(_("HM|Uu#U#u")));
1609 fl_setpup_shortcut(HelpMenu, 4, scex(_("HM|xX#x#X")));
1610 fl_setpup_shortcut(HelpMenu, 5, scex(_("HM|Cc#C#c")));
1611 fl_setpup_shortcut(HelpMenu, 6, scex(_("HM|Rr#R#r")));
1612 fl_setpup_shortcut(HelpMenu, 7, scex(_("HM|Kk#K#k")));
1613 fl_setpup_shortcut(HelpMenu, 8, scex(_("HM|Ll#L#l")));
1614 fl_setpup_shortcut(HelpMenu, 9, scex(_("HM|oO#o#O")));
1615 fl_setpup_shortcut(HelpMenu, 10, scex(_("HM|eE#e#E")));
1616 fl_setpup_shortcut(HelpMenu, 11, scex(_("HM|Vv#v#V")));
1619 men->_view->getForm()->x + ob->x,
1620 men->_view->getForm()->y + ob->y + ob->h + 10);
1621 int choice = fl_dopup(HelpMenu);
1624 // set the pseudo menu-button back
1625 fl_set_object_boxtype(ob, FL_FLAT_BOX);
1626 fl_redraw_object(ob);
1629 case 1: case 2: case 3: case 4: case 5:
1630 case 6: case 7: case 8:
1632 men->MenuDocu(doc_files[choice - 1]);
1635 case 9: ShowCopyright(); break;
1636 case 10: ShowCredits(); break;
1639 fl_show_message((string(_("LyX Version ")) + LYX_VERSION
1640 + _(" of ") + LYX_RELEASE).c_str(),
1641 (_("Library directory: ")
1642 + MakeDisplayPath(system_lyxdir)).c_str(),
1643 (_("User directory: ")
1644 + MakeDisplayPath(user_lyxdir)).c_str());
1648 fl_freepup(HelpMenu);
1652 void Menus::MenuDocu(string const & docname)
1654 string fname = i18nLibFileSearch("doc", docname, "lyx");
1655 _view->getMiniBuffer()->Set(_("Opening help file"),
1656 MakeDisplayPath(fname), "...");
1657 currentView()->buffer(bufferlist.loadLyXFile(fname, false));
1659 if (docname == "Reference")
1660 _view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
1664 void Menus::handleBufferMenu(int choice)
1666 currentView()->buffer(bufferlist.getBuffer(choice));