]> git.lyx.org Git - lyx.git/blob - src/menus.C
b65078e1eb07238a66e20e70a8aa4e43dfb2420e
[lyx.git] / src / menus.C
1 /*
2  *  This file is part of
3  * ================================================== 
4  *
5  *       LyX, The Document Processor
6  *
7  *       Copyright 1995 Matthias Ettrich
8  *       Copyright 1995-2000 The LyX Team.
9  *
10  * ================================================== 
11  */
12
13 /* This file contains all the menu and submenu declarations.
14    The call backs are in lyx_cb.C */
15
16 /*
17  * REMEMBER:
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)
21  */
22
23 #include <config.h>
24
25 #ifdef __GNUG__
26 #pragma implementation
27 #endif
28
29 #include "menus.h"
30 #include "lyx_cb.h"
31 #include "version.h"
32 #include "lyxfont.h"
33 #include "lyx_main.h"
34 #include "lyxfunc.h"
35 #include "spellchecker.h"
36 #include "support/filetools.h"
37 #include "LyXView.h"
38 #include "lastfiles.h"
39 #include "bufferlist.h"
40 #include "lyx_gui_misc.h"
41 #include "minibuffer.h"
42 #include "lyxscreen.h"
43 #include "intl.h"
44 #include "debug.h"
45 #include "lyxrc.h"
46 #include "lyxtext.h"
47 #include "gettext.h"
48 #include "layout.h"
49
50 extern FD_form_screen * fd_form_screen;
51 extern BufferList bufferlist;
52
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)
55
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(BufferView *);
63
64 // A bunch of wrappers
65
66 extern "C" void C_Menus_ShowFileMenu(FL_OBJECT * ob, long data)
67 {
68         Menus::ShowFileMenu(ob, data);
69 }
70
71 extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT * ob, long data)
72 {
73         Menus::ShowFileMenu2(ob, data);
74 }
75
76 extern "C" void C_Menus_ShowEditMenu(FL_OBJECT * ob, long data)
77 {
78         Menus::ShowEditMenu(ob, data);
79 }
80
81 extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT * ob, long data)
82 {
83         Menus::ShowLayoutMenu(ob, data);
84 }
85
86 extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT * ob, long data)
87 {
88         Menus::ShowInsertMenu(ob, data);
89 }
90
91 extern "C" void C_Menus_ShowMathMenu(FL_OBJECT * ob, long data)
92 {
93         Menus::ShowMathMenu(ob, data);
94 }
95
96 extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT * ob, long data)
97 {
98         Menus::ShowOptionsMenu(ob, data);
99 }
100
101 extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT * ob, long data)
102 {
103         Menus::ShowBufferMenu(ob, data);
104 }
105
106 extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT * ob, long data)
107 {
108         Menus::ShowHelpMenu(ob, data);
109 }
110
111
112 Menus::Menus(LyXView * view, int air)
113         : _view(view)
114 {       
115         create_menus(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);
128         hideMenus();
129 }
130
131
132 inline BufferView * Menus::currentView() 
133 {
134         return _view->view(); 
135 }
136
137
138 void Menus::showMenus()
139 {
140         fl_hide_object(menu_grp2);
141         fl_show_object(menu_grp1);
142 }
143
144
145 void Menus::hideMenus()
146 {
147         fl_hide_object(menu_grp1);
148         fl_show_object(menu_grp2);
149 }
150
151
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. */
159 {
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;
179         } else {
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;
188         }
189 }
190
191
192 void Menus::create_menus(int air)
193 {
194         FL_FORM * form = _view->getForm(); 
195
196         // Here I'd really like to see code like:
197         // addMenuBar();
198         FL_OBJECT * obj;
199
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)
206         int moffset = 0;
207
208         // menubar frame
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);
212
213         menu_grp1 = fl_bgn_group();
214         
215         // File menu button
216         menu_file = obj = 
217                 fl_add_button(FL_TOUCH_BUTTON,
218                               air+moffset, yloc,
219                               fl_get_string_width(FL_BOLD_STYLE,
220                                                   MENU_LABEL_SIZE,
221                                                   _("File"),
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);
227         obj->u_vdata = this;
228         
229         // Edit menu button
230         menu_edit = obj = 
231                 fl_add_button(FL_TOUCH_BUTTON,
232                               moffset, yloc,
233                               fl_get_string_width(FL_BOLD_STYLE,
234                                                   MENU_LABEL_SIZE,
235                                                   _("Edit"),
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);
241         obj->u_vdata = this;
242         
243         // Layout menu button
244         menu_layout = obj = 
245                 fl_add_button(FL_TOUCH_BUTTON,
246                               moffset, yloc,
247                               fl_get_string_width(FL_BOLD_STYLE,
248                                                   MENU_LABEL_SIZE,
249                                                   _("Layout"),
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);
255         obj->u_vdata = this;
256         
257         // Insert menu button button
258         menu_insert = obj = 
259                 fl_add_button(FL_TOUCH_BUTTON,
260                               moffset, yloc,
261                               fl_get_string_width(FL_BOLD_STYLE,
262                                                   MENU_LABEL_SIZE,
263                                                   _("Insert"),
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);
269         obj->u_vdata = this;
270         
271         // Math menu button
272         menu_math = obj = 
273                 fl_add_button(FL_TOUCH_BUTTON,
274                               moffset, yloc,
275                               fl_get_string_width(FL_BOLD_STYLE,
276                                                   MENU_LABEL_SIZE,
277                                                   _("Math"),
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);
283         obj->u_vdata = this;
284         
285         // Options menu button
286         menu_options = obj = 
287                 fl_add_button(FL_TOUCH_BUTTON,
288                               moffset, yloc,
289                               fl_get_string_width(FL_BOLD_STYLE,
290                                                   MENU_LABEL_SIZE,
291                                                   _("Options"),
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);
297         obj->u_vdata = this;
298
299         // Documents menu button
300         menu_buffer = obj = 
301                 fl_add_button(FL_TOUCH_BUTTON,
302                               moffset, yloc,
303                               fl_get_string_width(FL_BOLD_STYLE,
304                                                   MENU_LABEL_SIZE,
305                                                   _("Documents"),
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);
311         obj->u_vdata = this;
312         
313         // Help menu button
314         menu_help = obj = 
315                 fl_add_button(FL_TOUCH_BUTTON,
316                               moffset, yloc,
317                               fl_get_string_width(FL_BOLD_STYLE,
318                                                   MENU_LABEL_SIZE,
319                                                   _("Help"),
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);
325         obj->u_vdata = this;
326         
327         fl_end_group();
328
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;
332         do {
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);
339                 obj= obj->next;
340         } while (obj != 0 && obj->objclass != FL_END_GROUP);
341
342         // group 2
343         moffset = 0;
344         menu_grp2 = fl_bgn_group();
345         
346         // File menu button
347         menu_file2 = obj = 
348                 fl_add_button(FL_TOUCH_BUTTON,
349                               air+moffset, yloc,
350                               fl_get_string_width(FL_BOLD_STYLE,
351                                                   MENU_LABEL_SIZE,
352                                                   _("File"),
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);
358         obj->u_vdata = this;
359         
360         // Options menu button
361         menu_options2 = obj = 
362                 fl_add_button(FL_TOUCH_BUTTON,
363                               moffset, yloc,
364                               fl_get_string_width(FL_BOLD_STYLE,
365                                                   MENU_LABEL_SIZE,
366                                                   _("Options"),
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);
372         obj->u_vdata = this;
373
374         // Help menu button
375         menu_help2 = obj = 
376                 fl_add_button(FL_TOUCH_BUTTON,
377                               moffset, yloc,
378                               fl_get_string_width(FL_BOLD_STYLE,
379                                                   MENU_LABEL_SIZE,
380                                                   _("Help"),
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);
386         obj->u_vdata = this;
387         
388         fl_end_group();
389
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;
393         do {
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);
400                 obj= obj->next;
401         } while (obj != 0 && obj->objclass != FL_END_GROUP);
402 }
403
404
405 void Menus::ScreenOptions()
406 {
407         static int ow = -1, oh;
408
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());
418         char tmpstring[10];
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);
423         } else {
424                 fl_show_form(fd_form_screen->form_screen,
425                              FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
426                              _("Screen Options"));
427                 if (ow < 0) {
428                         ow = fd_form_screen->form_screen->w;
429                         oh = fd_form_screen->form_screen->h;
430                 }
431                 fl_set_form_minsize(fd_form_screen->form_screen, ow, oh);
432         }
433 }
434
435
436 //
437 // Here comes all the menu callbacks.
438 //
439
440 void Menus::ShowFileMenu(FL_OBJECT * ob, long)
441 {
442         Menus * men = static_cast<Menus*>(ob->u_vdata);
443
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
451
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);
456
457         Buffer * tmpbuffer = men->_view->buffer();
458         LyXFunc * tmpfunc = men->_view->getLyXFunc();
459
460         bool LinuxDoc = tmpbuffer->isLinuxDoc();
461         bool DocBook  = tmpbuffer->isDocBook();
462         bool Literate = tmpbuffer->isLiterate();
463
464         // Import sub-menu
465
466         int SubFileImport = fl_defpup(FL_ObjWin(ob),
467                                       _("Import%t"
468                                         "|LaTeX...%x30"
469                                         "|Ascii Text as Lines...%x31"
470                                         "|Ascii Text as Paragraphs%x32"
471                                         "|Noweb%x33"));
472         
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")));
477
478         // Export sub-menu
479
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),
485                                          _("Export%t"
486                                            "|as LaTeX...%x40"
487                                            "|as DVI...%x41"
488                                            "|as PostScript...%x42"
489                                            "|as Ascii Text...%x43"
490                                            "|as HTML...%x44"
491                                            "|Custom...%x45"));
492         else if(LinuxDoc)
493                 SubFileExport= fl_defpup(FL_ObjWin(ob),
494                                          _("Export%t"
495                                            "|as LinuxDoc...%x40"
496                                            "|as DVI...%x41"
497                                            "|as PostScript...%x42"
498                                            "|as Ascii Text...%x43"));
499         else if(DocBook)
500                 SubFileExport= fl_defpup(FL_ObjWin(ob),
501                                          _("Export%t"
502                                            "|as DocBook...%x40"
503                                            "|as DVI...%x41"
504                                            "|as PostScript...%x42"
505                                            "|as Ascii Text...%x43"));
506
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")));
514         }
515         
516         int FileMenu = fl_defpup(FL_ObjWin(ob),
517                                  _("New..."
518                                    "|New from template..."
519                                    "|Open...%l"
520                                    "|Close"
521                                    "|Save"
522                                    "|Save As..."
523                                    "|Revert to saved%l"
524                                    "|View dvi"
525                                    "|View PostScript"
526                                    "|Update dvi"
527                                    "|Update PostScript"
528                                    "|Build program%l"
529                                    "|Print..."
530                                    "|Fax..."));
531
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")));
546
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";
551
552         if (!hasLaTeX || lyxrc->view_dvi_command == "none") 
553                 fl_setpup_mode(FileMenu, 8, FL_PUP_GREY);
554         
555         if (!hasLaTeX || lyxrc->view_ps_command == "none") 
556                 fl_setpup_mode(FileMenu, 9, FL_PUP_GREY);
557         
558         if (!hasLaTeX) {
559                 fl_setpup_mode(FileMenu, 10, FL_PUP_GREY);
560                 fl_setpup_mode(FileMenu, 11, FL_PUP_GREY);
561         } 
562
563         if (lyxrc->literate_command == "none" || ! Literate) 
564                 fl_setpup_mode(FileMenu, 12, FL_PUP_GREY);
565
566         if (!hasLaTeX || lyxrc->print_command == "none") 
567                 fl_setpup_mode(FileMenu, 13, FL_PUP_GREY);
568
569         if (!hasLaTeX || lyxrc->fax_command == "none") 
570                 fl_setpup_mode(FileMenu, 14, FL_PUP_GREY);
571
572         bool hasReLyX = lyxrc->relyx_command != "none";
573         if (!hasReLyX) {
574                 // Disable import LaTeX and Noweb
575                 fl_setpup_mode(SubFileImport, 30, FL_PUP_GREY);
576                 fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
577         }
578
579         if (!hasLaTeX) {
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);
583         }
584
585         if (lyxrc->html_command == "none") {
586                 // Disable export HTML
587                 fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
588         }
589
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")));
599
600         // make the lastfiles menu
601         int ii = 1;
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());
609         }
610
611         // place popup
612         fl_setpup_position(
613                 men->_view->getForm()->x + ob->x,
614                 men->_view->getForm()->y + ob->y + ob->h + 10);   
615         int choice = fl_dopup(FileMenu);
616         XFlush(fl_display);
617
618         // set the pseudo menu-button back
619         fl_set_object_boxtype(ob, FL_FLAT_BOX);
620         fl_redraw_object(ob);
621
622         switch (choice) {
623         case -1: case 0: // we won't do anything
624                 break;
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");
641                 break;
642         case 31: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
643                 break;
644         case 32: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
645                 break;
646         case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
647                 break;
648         case 16: // export menu
649         case 40:
650                 if (!LinuxDoc && !DocBook)
651                         tmpfunc->Dispatch(LFUN_EXPORT, "latex");
652                 else if(LinuxDoc)
653                         tmpfunc->Dispatch(LFUN_EXPORT, "linuxdoc");
654                 else
655                         tmpfunc->Dispatch(LFUN_EXPORT, "docbook");
656                 break;
657         case 41: tmpfunc->Dispatch(LFUN_EXPORT, "dvi");
658                 break;
659         case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
660                 break;
661         case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
662                 break;
663         case 44: tmpfunc->Dispatch(LFUN_EXPORT, "html");
664                 break;
665         case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom"); 
666                 break;
667         case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
668                 // Lastfiles:
669         case 18: // The first item with lastfiles.
670         default:
671                 men->currentView()
672                         ->buffer(bufferlist
673                                  .loadLyXFile((*lastfiles)[choice - 18]));
674                 break;
675         }
676         fl_freepup(SubFileImport);
677         fl_freepup(SubFileExport);
678         fl_freepup(FileMenu);
679
680         AllowInput();
681 }
682
683
684 void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
685 {
686         Menus * men = static_cast<Menus*>(ob->u_vdata);
687
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
695
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);
700
701         LyXFunc * tmpfunc = men->_view->getLyXFunc();
702
703         // Import sub-menu
704         
705         int SubFileImport = fl_defpup(FL_ObjWin(ob),
706                                       _("Import%t"
707                                         "|LaTeX...%x15"
708                                         "|Ascii Text as Lines...%x16"
709                                         "|Ascii Text as Paragraphs...%x17"
710                                         "|Noweb...%x18"));
711         
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")));
716
717         bool hasReLyX = lyxrc->relyx_command != "none";
718         if (!hasReLyX) {
719                 // Disable import LaTeX and Noweb
720                 fl_setpup_mode(SubFileImport, 15, FL_PUP_GREY);
721                 fl_setpup_mode(SubFileImport, 18, FL_PUP_GREY);
722         }
723
724         // This can be done cleaner later.
725         int FileMenu = fl_defpup(FL_ObjWin(ob), 
726                                  _("New..."
727                                    "|New from template..."
728                                    "|Open...%l"
729                                    "|Import%m%l"
730                                    "|Exit%l"), SubFileImport);
731         
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")));
737         
738         // make the lastfiles menu
739         int ii = 1;
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());
747         }
748
749         // place popup
750         fl_setpup_position(
751                 men->_view->getForm()->x + ob->x,
752                 men->_view->getForm()->y + ob->y + ob->h + 10);   
753         int choice = fl_dopup(FileMenu);
754         XFlush(fl_display);
755
756         // set the pseudo menu-button back
757         fl_set_object_boxtype(ob, FL_FLAT_BOX);
758         fl_redraw_object(ob);
759
760         switch (choice) {
761         case -1: case 0: // we won't do anything
762                 break;
763         case 1:
764                 tmpfunc->Dispatch(LFUN_MENUNEW);
765                 break;
766         case 2:
767                 tmpfunc->Dispatch(LFUN_MENUNEWTMPLT);
768                 break;
769         case 3:
770                 tmpfunc->Dispatch(LFUN_MENUOPEN);
771                 break;
772         case 4: // import menu
773         case 15: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
774                 break;
775         case 16: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
776                 break;
777         case 17: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
778                 break;
779         case 18: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
780                 break;
781         case 5:
782                 tmpfunc->Dispatch(LFUN_QUIT);
783                 break;
784                 // Lastfiles:
785         case 6: // The first item with lastfiles.
786         default:
787                 men->currentView()
788                         ->buffer(bufferlist
789                                  .loadLyXFile((*lastfiles)[choice - 6]));
790                 break;
791         }
792
793         fl_freepup(SubFileImport);
794         fl_freepup(FileMenu);
795         AllowInput();
796         return;
797 }
798
799
800 void Menus::ShowEditMenu(FL_OBJECT * ob, long)
801 {
802         Menus * men = static_cast<Menus*>(ob->u_vdata);
803         
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);
808
809         Buffer * tmpbuffer = men->_view->buffer();
810         LyXFunc * tmpfunc = men->_view->getLyXFunc();
811
812         // Floats & Insets submenu
813         int SubEditFloats= fl_defpup(FL_ObjWin(ob),
814                                      _("Floats & Insets%t"
815                                        "|Open/Close%x21"
816                                        "|Melt%x22"
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"));
822         
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")));
830
831         // Table submenu
832         int SubEditTable = fl_newpup(FL_ObjWin(ob));
833         if (men->currentView()->available() && 
834             men->currentView()->text->cursor.par->table &&
835             !tmpbuffer->isReadonly()){
836
837                 fl_addtopup(SubEditTable, _("Table%t"));
838
839                 if (men->currentView()->text->cursor.par->table->
840                     IsMultiColumn(men->currentView()->text->
841                                   NumberOfCell(men->currentView()->
842                                                text->cursor.par, 
843                                                men->currentView()->
844                                                text->cursor.pos)))
845                         fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
846                 else
847                         fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
848                 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
849      
850                 if (men->currentView()->text->cursor.par->table->
851                     TopLine(men->currentView()->text->
852                             NumberOfCell(men->currentView()->
853                                          text->cursor.par, 
854                                          men->currentView()->text->
855                                          cursor.pos)))
856                         fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
857                 else
858                         fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
859                 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
860      
861                 if (men->currentView()->text->cursor.par->table->
862                     BottomLine(men->currentView()->text->
863                                NumberOfCell(men->currentView()->
864                                             text->cursor.par, 
865                                             men->currentView()->
866                                             text->cursor.pos)))
867                         fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
868                 else
869                         fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
870                 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
871
872                 if (men->currentView()->text->cursor.par->table->
873                     LeftLine(men->currentView()->text->
874                              NumberOfCell(men->currentView()->
875                                           text->cursor.par, 
876                                           men->currentView()->
877                                           text->cursor.pos)))
878                         fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
879                 else
880                         fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
881                 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
882
883                 if (men->currentView()->text->cursor.par->table->
884                     RightLine(men->currentView()->text->
885                               NumberOfCell(men->currentView()->
886                                            text->cursor.par, 
887                                            men->currentView()->
888                                            text->cursor.pos)))
889                         fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
890                 else
891                         fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
892                 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
893
894                 int align = men->currentView()->text->cursor.par->
895                         table->GetAlignment(men->currentView()->text->
896                                             NumberOfCell(men->currentView()->
897                                                          text->cursor.par, 
898                                                          men->currentView()->
899                                                          text->cursor.pos));
900                 if (align == LYX_ALIGN_LEFT)
901                         fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
902                 else
903                         fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
904                 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
905
906                 if (align == LYX_ALIGN_RIGHT)
907                         fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
908                 else
909                         fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
910                 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
911
912                 if (align == LYX_ALIGN_CENTER)
913                         fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
914                 else
915                         fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
916                 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
917
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")));
933         }
934         else {
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")));
939         }
940
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"));
952                 } else {
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"));
958                 }
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"));
965         } else {
966                 // xgettext:no-c-format
967                 fl_addtopup(SubVersionControl, _("|Register%x51"));
968         }
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")));
976
977         int EditMenu= fl_defpup(FL_ObjWin(ob),
978                                 _("Undo"
979                                   "|Redo %l"
980                                   "|Cut"
981                                   "|Copy"
982                                   "|Paste%l"
983                                   "|Find & Replace..."
984                                   "|Go to Error"
985                                   "|Go to Note"
986                                   "|Floats & Insets%m"
987                                   "|Table%m"
988                                   "|Spellchecker...."
989                                   "|Check TeX"
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);
996
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")));
1014       
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);
1024
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);
1032         }
1033         
1034         fl_setpup_position(men->_view->getForm()->x + ob->x,
1035                            men->_view->getForm()->y + ob->y +
1036                            ob->h + 10);   
1037         int choice = fl_dopup(EditMenu);
1038         XFlush(fl_display);
1039    
1040         // set the pseudo menu-button back
1041         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1042         fl_redraw_object(ob);
1043
1044         switch (choice) {
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
1054                 break;
1055         case 10:// table 
1056                 break;
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
1061                 break;
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;
1065
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;
1074
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:
1082         case 44: 
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);
1088                         }
1089                         men->currentView()->text->
1090                                 TableFeatures(choice - 32);
1091                         men->currentView()->update(1);
1092                 }
1093                 break;
1094                 // version control sub-menu
1095         case 51: // register
1096                 tmpfunc->Dispatch(LFUN_VC_REGISTER);
1097                 break;
1098         case 52: // check in
1099                 tmpfunc->Dispatch(LFUN_VC_CHECKIN);
1100                 break;
1101         case 53: // check out
1102                 tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
1103                 break;
1104         case 54: // revert to last
1105                 tmpfunc->Dispatch(LFUN_VC_REVERT);
1106                 break;
1107         case 55: // undo last
1108                 tmpfunc->Dispatch(LFUN_VC_UNDO);
1109                 break;
1110         case 56: // show history
1111                 tmpfunc->Dispatch(LFUN_VC_HISTORY);
1112                 break;
1113         }
1114
1115         fl_freepup(EditMenu);
1116         fl_freepup(SubEditFloats);
1117         fl_freepup(SubEditTable);
1118         fl_freepup(SubVersionControl);
1119 }
1120
1121
1122 void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
1123 {
1124         Menus * men = static_cast<Menus*>(ob->u_vdata);
1125
1126         if (!men->currentView()->available())
1127                 return;
1128         
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);
1133    
1134         Buffer * tmpbuffer = men->_view->buffer();
1135         LyXFunc * tmpfunc = men->_view->getLyXFunc();
1136
1137         int LayoutMenu = fl_newpup(FL_ObjWin(ob));
1138         fl_addtopup(LayoutMenu, _("Character..."
1139                                   "|Paragraph..."
1140                                   "|Document..."
1141                                   "|Paper..."
1142                                   "|Table..."
1143                                   "|Quotes...%l"
1144                                   "|Emphasize Style%b"
1145                                   "|Noun Style%b"
1146                                   "|Bold Style%b"
1147                                   "|TeX 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")));
1164
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);
1175            
1176         // Grey out unavailable entries
1177         if (!men->currentView()->text->cursor.par->table)
1178                 fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
1179
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);
1184         }
1185
1186         fl_setpup_position(
1187                 men->_view->getForm()->x + ob->x,
1188                 men->_view->getForm()->y + ob->y + ob->h + 10);
1189         int choice = fl_dopup(LayoutMenu);
1190         XFlush(fl_display);
1191
1192         // set the pseudo menu-button back
1193         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1194         fl_redraw_object(ob);
1195
1196         switch (choice) {
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;
1210         }
1211         fl_freepup(LayoutMenu); 
1212 }
1213
1214
1215 void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
1216 {
1217         Menus * men = static_cast<Menus*>(ob->u_vdata);
1218         
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);
1223  
1224         Buffer * tmpbuffer = men->_view->buffer();
1225         LyXFunc * tmpfunc = men->_view->getLyXFunc();
1226
1227         int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
1228                                        _("Import ASCII file%t"
1229                                          "|As Lines%x41"
1230                                          "|As Paragraphs%x42"));
1231         
1232         fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
1233         fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
1234
1235         int SubInsertTableList= fl_defpup(FL_ObjWin(ob),
1236                                           _("Lists & TOC%t"
1237                                             "|Table of Contents%x21"
1238                                             "|List of Figures%x22"
1239                                             "|List of Tables%x23"
1240                                             "|List of Algorithms%x24"
1241                                             "|Index List%x25"
1242                                             "|BibTeX Reference%x26"));
1243         
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")));
1250
1251         int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
1252                                            _("Floats%t"
1253                                              "|Figure Float%x71"
1254                                              "|Table Float%x72"
1255                                              "|Wide Figure Float%x73"
1256                                              "|Wide Table Float%l%x74"
1257                                              "|Algorithm Float%x75"));
1258         
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")));
1264         
1265         int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
1266                                          _("Special Character%t"
1267                                            "|HFill%x31"
1268                                            "|Hyphenation Point%x32"
1269                                            "|Protected Blank%x33"
1270                                            "|Linebreak%x34"
1271                                            "|Ellipsis (...)%x35"
1272                                            "|End of sentence period%x36"
1273                                            "|Ordinary Quote (\")%x37"
1274                                            "|Menu Separator %x38"));
1275
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")));
1284         
1285         int InsertMenu = fl_defpup(FL_ObjWin(ob),
1286                                    _("Figure..."
1287                                      "|Table...%l"
1288                                      "|Include File..." 
1289                                      "|Import ASCII File%m"
1290                                      "|Insert LyX File...%l"
1291                                      "|Footnote"
1292                                      "|Margin Note"
1293                                      "|Floats%m%l"      
1294                                      "|Lists & TOC%m%l"
1295                                      "|Special Character%m%l"
1296                                      "|Note..."
1297                                      "|Label..."
1298                                      "|Cross-Reference..."
1299                                      "|Citation Reference..."
1300                                      "|Index entry..."
1301                                      "|Index entry of last word"),
1302                                    SubInsertAscii,
1303                                    SubInsertFloatList,  
1304                                    SubInsertTableList,
1305                                    SubInsertSpecial);
1306
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")));
1323
1324         fl_addtopup(InsertMenu, _("|URL..."));
1325         fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|Uu#u#U")));
1326
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);
1331         }
1332
1333         fl_setpup_position(
1334                 men->_view->getForm()->x + ob->x,
1335                 men->_view->getForm()->y + ob->y + ob->h + 10);
1336    
1337         int choice = fl_dopup(InsertMenu);
1338         XFlush(fl_display);
1339
1340         // set the pseudo menu-button back
1341         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1342         fl_redraw_object(ob);
1343
1344         if (men->currentView()->available()){
1345                 men->currentView()->getScreen()->HideCursor();
1346                 switch (choice) {
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
1351                         break;
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;
1355                 case 43: 
1356                         break;
1357
1358                 case 6: tmpfunc->Dispatch(LFUN_FOOTMELT); break
1359                                                                   ;
1360                 case 7: tmpfunc->Dispatch(LFUN_MARGINMELT); break;
1361   
1362                 case 8: // Float sub-menu
1363                 case 71:
1364                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure");
1365                         break;
1366                 case 72:
1367                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table");
1368                         break;
1369                 case 73:
1370                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig");
1371                         break;
1372                 case 74:
1373                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab");
1374                         break;
1375                 case 75:
1376                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm");
1377                         break;
1378
1379                 case 9: // Table/List submenu
1380                         break;
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;
1387
1388                 case 10: // Special Character submenu
1389                         break;
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;
1398
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;
1406                 }
1407         }
1408         fl_freepup(InsertMenu);
1409         fl_freepup(SubInsertAscii);
1410         fl_freepup(SubInsertTableList);
1411         fl_freepup(SubInsertFloatList);
1412         fl_freepup(SubInsertSpecial);
1413 }
1414
1415
1416 void Menus::ShowMathMenu(FL_OBJECT * ob, long)
1417 {
1418         extern void math_insert_symbol(char const * s);
1419
1420         Menus * men = static_cast<Menus*>(ob->u_vdata);
1421
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);
1426
1427         Buffer * tmpbuffer = men->_view->buffer();
1428         LyXFunc * tmpfunc = men->_view->getLyXFunc();
1429
1430         int MathMenu = fl_defpup(FL_ObjWin(ob), 
1431                                  _("Fraction"
1432                                    "|Square root"
1433                                    "|Exponent"
1434                                    "|Index"
1435                                    "|Sum"
1436                                    "|Integral%l"
1437                                    "|Math mode"
1438                                    "|Display%l"
1439                                    "|Math Panel..."));
1440
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")));
1450
1451         if (tmpbuffer->isReadonly()) 
1452                 for (int ii = 1; ii <= 9; ++ii)
1453                         fl_setpup_mode(MathMenu, ii, FL_PUP_GREY);
1454
1455
1456         fl_setpup_position(
1457                 men->_view->getForm()->x + ob->x,
1458                 men->_view->getForm()->y + ob->y + ob->h + 10);   
1459         int choice = fl_dopup(MathMenu);  
1460         XFlush(fl_display);
1461
1462         // set the pseudo menu-button back
1463         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1464         fl_redraw_object(ob);
1465
1466         if (men->currentView()->available())  {
1467                 switch (choice) {
1468                 case 1: /* frac */
1469                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "frac");
1470                         break;
1471                 case 2: /* sqrt */
1472                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
1473                         break;
1474                 case 3: /* Exponent */ 
1475                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "^");
1476                         break;
1477                 case 4: /* Index */
1478                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "_");
1479                         break;
1480                 case 5: /* sum */ 
1481                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "sum");
1482                         break;
1483                 case 6: /* int */
1484                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "int");
1485                         break;
1486                 case 7:
1487                         tmpfunc->Dispatch(LFUN_MATH_MODE);
1488                         break;
1489                 case 8:
1490                         tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
1491                         break;
1492                 case 9: /* Panel */
1493                         show_symbols_form(tmpfunc);
1494                         break;
1495                 }
1496                 men->currentView()->update(0);
1497         } 
1498         fl_freepup(MathMenu);
1499 }
1500
1501
1502 void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
1503 {
1504         Menus * men = static_cast<Menus*>(ob->u_vdata);
1505
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);
1510
1511         //Buffer *tmpbuffer = men->_view->currentBuffer();
1512         LyXFunc * tmpfunc = men->_view->getLyXFunc();
1513
1514         int OptionsMenu = fl_defpup(FL_ObjWin(ob),
1515                                     _("Screen Fonts..."
1516                                       "|Spellchecker Options..."
1517                                       "|Keyboard..."
1518                                       "|LaTeX...%l"
1519                                       "|Reconfigure" ));
1520
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")));
1526
1527         if(lyxrc->isp_command == "none") 
1528                 fl_setpup_mode(OptionsMenu, 2, FL_PUP_GREY);
1529
1530         fl_setpup_position(
1531                 men->_view->getForm()->x + ob->x,
1532                 men->_view->getForm()->y + ob->y + ob->h + 10);   
1533         int choice = fl_dopup(OptionsMenu);
1534         XFlush(fl_display);
1535
1536         // set the pseudo menu-button back
1537         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1538         fl_redraw_object(ob);
1539         switch (choice){
1540         case 1: men->ScreenOptions(); break;
1541         case 2: SpellCheckerOptions(); break;      
1542         case 3: men->_view->getIntl()->MenuKeymap(); break;
1543         case 4: LaTeXOptions(men->_view->view()); break;
1544         case 5: tmpfunc->Dispatch(LFUN_RECONFIGURE); break;
1545         default: break;
1546         }   
1547         fl_freepup(OptionsMenu);
1548 }
1549
1550
1551 void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
1552 {
1553         Menus * men = static_cast<Menus*>(ob->u_vdata);
1554         
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);
1559    
1560         int BufferMenu = fl_newpup(FL_ObjWin(ob));
1561         vector<string> namevec = bufferlist.getFileNames();
1562         if (namevec.size() != 0) {
1563                 for (vector<string>::const_iterator cit = namevec.begin();
1564                      cit != namevec.end(); ++cit) {
1565                         string relbuf = MakeDisplayPath((*cit), 30);
1566                         fl_addtopup(BufferMenu, relbuf.c_str());
1567                 }
1568         } else {
1569                 fl_addtopup(BufferMenu, _("No Documents Open!%t"));
1570         }
1571    
1572         fl_setpup_position(
1573                 men->_view->getForm()->x + ob->x,
1574                 men->_view->getForm()->y + ob->y + ob->h + 10);   
1575         int choice = fl_dopup(BufferMenu);
1576         XFlush(fl_display);
1577
1578         // set the pseudo menu-button back
1579         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1580         fl_redraw_object(ob);
1581         if (choice > 0) men->handleBufferMenu(choice - 1);
1582    
1583         fl_freepup(BufferMenu);
1584 }
1585
1586
1587 static
1588 char const * doc_files [] = {"Intro", "Tutorial", 
1589                              "UserGuide", "Extended",
1590                              "Customization", "Reference",
1591                              "BUGS", "LaTeXConfig"}; 
1592
1593 void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
1594 {
1595         Menus * men = static_cast<Menus*>(ob->u_vdata);
1596
1597         // set the pseudo menu-button
1598         fl_set_object_boxtype(ob, FL_UP_BOX);
1599         fl_set_button(ob, 0);
1600         fl_redraw_object(ob);
1601    
1602         int HelpMenu = fl_defpup(FL_ObjWin(ob),
1603                                  _("Introduction"
1604                                    "|Tutorial"
1605                                    "|User's Guide"
1606                                    "|Extended Features"
1607                                    "|Customization"
1608                                    "|Reference Manual"
1609                                    "|Known Bugs"
1610                                    "|LaTeX Configuration%l"
1611                                    "|Copyright and Warranty..."
1612                                    "|Credits..."
1613                                    "|Version..."));
1614    
1615         fl_setpup_shortcut(HelpMenu,  1, scex(_("HM|Ii#I#i")));
1616         fl_setpup_shortcut(HelpMenu,  2, scex(_("HM|Tt#T#t")));
1617         fl_setpup_shortcut(HelpMenu,  3, scex(_("HM|Uu#U#u")));
1618         fl_setpup_shortcut(HelpMenu,  4, scex(_("HM|xX#x#X")));
1619         fl_setpup_shortcut(HelpMenu,  5, scex(_("HM|Cc#C#c")));
1620         fl_setpup_shortcut(HelpMenu,  6, scex(_("HM|Rr#R#r")));
1621         fl_setpup_shortcut(HelpMenu,  7, scex(_("HM|Kk#K#k")));
1622         fl_setpup_shortcut(HelpMenu,  8, scex(_("HM|Ll#L#l")));
1623         fl_setpup_shortcut(HelpMenu,  9, scex(_("HM|oO#o#O")));
1624         fl_setpup_shortcut(HelpMenu, 10, scex(_("HM|eE#e#E")));
1625         fl_setpup_shortcut(HelpMenu, 11, scex(_("HM|Vv#v#V")));
1626
1627         fl_setpup_position(
1628                 men->_view->getForm()->x + ob->x,
1629                 men->_view->getForm()->y + ob->y + ob->h + 10);   
1630         int choice = fl_dopup(HelpMenu);
1631         XFlush(fl_display);
1632
1633         // set the pseudo menu-button back
1634         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1635         fl_redraw_object(ob);
1636
1637         switch (choice) {
1638         case 1: case 2: case 3: case 4: case 5: 
1639         case 6: case 7: case 8:
1640                 ProhibitInput();
1641                 men->MenuDocu(doc_files[choice - 1]);
1642                 AllowInput();
1643                 break;
1644         case 9: ShowCopyright(); break;
1645         case 10: ShowCredits(); break;
1646         case 11:
1647                 ProhibitInput();
1648                 fl_show_message((string(_("LyX Version ")) + LYX_VERSION 
1649                                  + _(" of ") + LYX_RELEASE).c_str(),
1650                                 (_("Library directory: ")
1651                                  + MakeDisplayPath(system_lyxdir)).c_str(),
1652                                 (_("User directory: ") 
1653                                  + MakeDisplayPath(user_lyxdir)).c_str());
1654                 AllowInput();
1655                 break;
1656         }
1657         fl_freepup(HelpMenu);
1658 }
1659
1660
1661 void Menus::MenuDocu(string const & docname) 
1662 {
1663         string fname = i18nLibFileSearch("doc", docname, "lyx");
1664         if (fname.empty()) {
1665                 WriteAlert(_("Error!"),
1666                            _("Could not find requested Documentation file"),
1667                            fname);
1668                 return;
1669         }
1670         _view->getMiniBuffer()->Set(_("Opening help file"),
1671                                     MakeDisplayPath(fname), "...");
1672         currentView()->buffer(bufferlist.loadLyXFile(fname, false));
1673
1674         if (docname == "Reference")
1675                 _view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
1676 }
1677
1678
1679 void Menus::handleBufferMenu(int choice)
1680 {
1681         currentView()->buffer(bufferlist.getBuffer(choice));
1682 }