]> git.lyx.org Git - lyx.git/blob - src/menus.C
the figinsetpatch some lyxrc changes, read the ChangeLog
[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 "version.h"
31 #include "lyxfont.h"
32 #include "lyx_main.h"
33 #include "lyxfunc.h"
34 #include "spellchecker.h"
35 #include "support/filetools.h"
36 #include "LyXView.h"
37 #include "lastfiles.h"
38 #include "bufferlist.h"
39 #include "lyx_gui_misc.h"
40 #include "minibuffer.h"
41 #include "intl.h"
42 #include "debug.h"
43 #include "lyxrc.h"
44 #include "lyxtext.h"
45 #include "gettext.h"
46 #include "layout.h"
47
48 extern FD_form_screen * fd_form_screen;
49 extern BufferList bufferlist;
50
51 // I would really prefere to see most or all of these 'extern's disappear.
52 // Their commands should be called through LyXFunc (IMO). (Lgb)
53
54 extern void MenuLayoutSave();
55 extern void ShowCredits();
56 extern void ShowCopyright();
57 extern void show_symbols_form(LyXFunc *);
58 extern void ProhibitInput();
59 extern void AllowInput();
60 extern void LaTeXOptions(BufferView *);
61
62 // A bunch of wrappers
63
64 extern "C" void C_Menus_ShowFileMenu(FL_OBJECT * ob, long data)
65 {
66         Menus::ShowFileMenu(ob, data);
67 }
68
69 extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT * ob, long data)
70 {
71         Menus::ShowFileMenu2(ob, data);
72 }
73
74 extern "C" void C_Menus_ShowEditMenu(FL_OBJECT * ob, long data)
75 {
76         Menus::ShowEditMenu(ob, data);
77 }
78
79 extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT * ob, long data)
80 {
81         Menus::ShowLayoutMenu(ob, data);
82 }
83
84 extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT * ob, long data)
85 {
86         Menus::ShowInsertMenu(ob, data);
87 }
88
89 extern "C" void C_Menus_ShowMathMenu(FL_OBJECT * ob, long data)
90 {
91         Menus::ShowMathMenu(ob, data);
92 }
93
94 extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT * ob, long data)
95 {
96         Menus::ShowOptionsMenu(ob, data);
97 }
98
99 extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT * ob, long data)
100 {
101         Menus::ShowBufferMenu(ob, data);
102 }
103
104 extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT * ob, long data)
105 {
106         Menus::ShowHelpMenu(ob, data);
107 }
108
109
110 Menus::Menus(LyXView * view, int air)
111         : _view(view)
112 {       
113         create_menus(air);
114         // deactivate the menu accelerators
115         fl_set_object_shortcut(menu_file, "", 1);
116         fl_set_object_shortcut(menu_file2, "", 1);
117         fl_set_object_shortcut(menu_edit, "", 1);
118         fl_set_object_shortcut(menu_layout, "", 1);
119         fl_set_object_shortcut(menu_math, "", 1);
120         fl_set_object_shortcut(menu_insert, "", 1);
121         fl_set_object_shortcut(menu_options, "", 1);
122         fl_set_object_shortcut(menu_options2, "", 1);
123         fl_set_object_shortcut(menu_buffer, "", 1);
124         fl_set_object_shortcut(menu_help, "", 1);
125         fl_set_object_shortcut(menu_help2, "", 1);
126         hideMenus();
127 }
128
129
130 inline
131 BufferView * Menus::currentView() 
132 {
133         return _view->view(); 
134 }
135
136
137 void Menus::showMenus()
138 {
139         fl_hide_object(menu_grp2);
140         fl_show_object(menu_grp1);
141 }
142
143
144 void Menus::hideMenus()
145 {
146         fl_hide_object(menu_grp1);
147         fl_show_object(menu_grp2);
148 }
149
150
151 void Menus::openByName(string const & menuName)
152         /* Opens the visible menu of given name, or simply does nothing
153            when the name is not known. NOTE THE EXTREMELY STUPID
154            IMPLEMENTATION! :-) There are probably hundred ways to do
155            this better, for instance, by scanning the menu objects and
156            testing for the given name. I leave this as an exercise for an
157            experienced GG (GUI Guy/Girl). RVDK_PATCH_5. */
158 {
159         if (menu_file->visible) {
160                 if (menuName == _("File"))
161                         ShowFileMenu(menu_file, 0);
162                 else if (menuName == _("Edit"))
163                         ShowEditMenu(menu_edit, 0);
164                 else if (menuName == _("Layout"))
165                         ShowLayoutMenu(menu_layout, 0);
166                 else if (menuName == _("Insert"))
167                         ShowInsertMenu(menu_insert, 0);
168                 else if (menuName == _("Math"))
169                         ShowMathMenu(menu_math, 0);
170                 else if (menuName == _("Options"))
171                         ShowOptionsMenu(menu_options, 0);
172                 else if (menuName == _("Documents"))
173                         ShowBufferMenu(menu_buffer, 0);
174                 else if (menuName == _("Help"))
175                         ShowHelpMenu(menu_help, 0);
176                 else lyxerr << "The menu '" << menuName
177                             << "' is not available." << endl;
178         } else {
179                 if (menuName == _("File"))
180                         ShowFileMenu2(menu_file2, 0);
181                 else if (menuName == _("Options"))
182                         ShowOptionsMenu(menu_options2, 0);
183                 else if (menuName == _("Help"))
184                         ShowHelpMenu(menu_help2, 0);
185                 else lyxerr << "The menu '" << menuName
186                             << "' is not available." << endl;
187         }
188 }
189
190
191 void Menus::create_menus(int air)
192 {
193         FL_FORM * form = _view->getForm(); 
194
195         // Here I'd really like to see code like:
196         // addMenuBar();
197         FL_OBJECT * obj;
198
199         const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
200         const int mheight = 30;
201         const int mbheight= 22;
202         // where to place the menubar?
203         const int yloc = (mheight - mbheight)/2; //air + bw;
204         const int mbadd = 20; // menu button add (to width)
205         int moffset = 0;
206
207         // menubar frame
208         obj = fl_add_frame(FL_UP_FRAME, 0, 0, form->w, mheight, "");
209         fl_set_object_resize(obj, FL_RESIZE_ALL);
210         fl_set_object_gravity(obj, NorthWestGravity, NorthEastGravity);
211
212         menu_grp1 = fl_bgn_group();
213         
214         // File menu button
215         menu_file = obj = 
216                 fl_add_button(FL_TOUCH_BUTTON,
217                               air+moffset, yloc,
218                               fl_get_string_width(FL_BOLD_STYLE,
219                                                   MENU_LABEL_SIZE,
220                                                   _("File"),
221                                                   strlen(_("File"))) + mbadd,
222                               mbheight, _("File"));
223         moffset += obj->w + air;
224         fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
225         fl_set_object_callback(obj, C_Menus_ShowFileMenu, 0);
226         obj->u_vdata = this;
227         
228         // Edit menu button
229         menu_edit = obj = 
230                 fl_add_button(FL_TOUCH_BUTTON,
231                               moffset, yloc,
232                               fl_get_string_width(FL_BOLD_STYLE,
233                                                   MENU_LABEL_SIZE,
234                                                   _("Edit"),
235                                                   strlen(_("Edit"))) + mbadd,
236                               mbheight, _("Edit"));
237         moffset += obj->w + air;
238         fl_set_object_shortcut(obj, scex(_("MB|#E")), 1);
239         fl_set_object_callback(obj, C_Menus_ShowEditMenu, 0);
240         obj->u_vdata = this;
241         
242         // Layout menu button
243         menu_layout = obj = 
244                 fl_add_button(FL_TOUCH_BUTTON,
245                               moffset, yloc,
246                               fl_get_string_width(FL_BOLD_STYLE,
247                                                   MENU_LABEL_SIZE,
248                                                   _("Layout"),
249                                                   strlen(_("Layout"))) + mbadd,
250                               mbheight, _("Layout"));
251         moffset += obj->w + air;
252         fl_set_object_shortcut(obj, scex(_("MB|#L")), 1);
253         fl_set_object_callback(obj, C_Menus_ShowLayoutMenu, 0);
254         obj->u_vdata = this;
255         
256         // Insert menu button button
257         menu_insert = obj = 
258                 fl_add_button(FL_TOUCH_BUTTON,
259                               moffset, yloc,
260                               fl_get_string_width(FL_BOLD_STYLE,
261                                                   MENU_LABEL_SIZE,
262                                                   _("Insert"),
263                                                   strlen(_("Insert"))) + mbadd,
264                               mbheight, _("Insert"));
265         moffset += obj->w + air;
266         fl_set_object_shortcut(obj, scex(_("MB|#I")), 1);
267         fl_set_object_callback(obj, C_Menus_ShowInsertMenu, 0);
268         obj->u_vdata = this;
269         
270         // Math menu button
271         menu_math = obj = 
272                 fl_add_button(FL_TOUCH_BUTTON,
273                               moffset, yloc,
274                               fl_get_string_width(FL_BOLD_STYLE,
275                                                   MENU_LABEL_SIZE,
276                                                   _("Math"),
277                                                   strlen(_("Math"))) + mbadd,
278                               mbheight, _("Math"));
279         moffset += obj->w + air;
280         fl_set_object_shortcut(obj, scex(_("MB|#M")), 1);
281         fl_set_object_callback(obj, C_Menus_ShowMathMenu, 0);
282         obj->u_vdata = this;
283         
284         // Options menu button
285         menu_options = obj = 
286                 fl_add_button(FL_TOUCH_BUTTON,
287                               moffset, yloc,
288                               fl_get_string_width(FL_BOLD_STYLE,
289                                                   MENU_LABEL_SIZE,
290                                                   _("Options"),
291                                                   strlen(_("Options"))) + mbadd,
292                               mbheight, _("Options"));
293         moffset += obj->w + air;
294         fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
295         fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
296         obj->u_vdata = this;
297
298         // Documents menu button
299         menu_buffer = obj = 
300                 fl_add_button(FL_TOUCH_BUTTON,
301                               moffset, yloc,
302                               fl_get_string_width(FL_BOLD_STYLE,
303                                                   MENU_LABEL_SIZE,
304                                                   _("Documents"),
305                                                   strlen(_("Documents"))) + mbadd,
306                               mbheight, _("Documents"));
307         moffset += obj->w + air;
308         fl_set_object_shortcut(obj, scex(_("MB|#D")), 1);
309         fl_set_object_callback(obj, C_Menus_ShowBufferMenu, 0);
310         obj->u_vdata = this;
311         
312         // Help menu button
313         menu_help = obj = 
314                 fl_add_button(FL_TOUCH_BUTTON,
315                               moffset, yloc,
316                               fl_get_string_width(FL_BOLD_STYLE,
317                                                   MENU_LABEL_SIZE,
318                                                   _("Help"),
319                                                   strlen(_("Help"))) + mbadd,
320                               mbheight, _("Help"));
321         moffset += obj->w + air;
322         fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
323         fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
324         obj->u_vdata = this;
325         
326         fl_end_group();
327
328         // Set the menu buttons atrributes.
329         // Due to a bug in xforms we cant do this only an the group.
330         obj = menu_grp1->next;
331         do {
332                 fl_set_object_boxtype(obj, FL_FLAT_BOX);
333                 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
334                 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
335                 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
336                 fl_set_object_resize(obj, FL_RESIZE_ALL);
337                 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
338                 obj= obj->next;
339         } while (obj != 0 && obj->objclass != FL_END_GROUP);
340
341         // group 2
342         moffset = 0;
343         menu_grp2 = fl_bgn_group();
344         
345         // File menu button
346         menu_file2 = obj = 
347                 fl_add_button(FL_TOUCH_BUTTON,
348                               air+moffset, yloc,
349                               fl_get_string_width(FL_BOLD_STYLE,
350                                                   MENU_LABEL_SIZE,
351                                                   _("File"),
352                                                   strlen(_("File"))) + mbadd,
353                               mbheight, _("File"));
354         moffset += obj->w + air;
355         fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
356         fl_set_object_callback(obj, C_Menus_ShowFileMenu2, 0);
357         obj->u_vdata = this;
358         
359         // Options menu button
360         menu_options2 = obj = 
361                 fl_add_button(FL_TOUCH_BUTTON,
362                               moffset, yloc,
363                               fl_get_string_width(FL_BOLD_STYLE,
364                                                   MENU_LABEL_SIZE,
365                                                   _("Options"),
366                                                   strlen(_("Options"))) +mbadd,
367                               mbheight, _("Options"));
368         moffset += obj->w + air;
369         fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
370         fl_set_object_callback(obj, C_Menus_ShowOptionsMenu, 0);
371         obj->u_vdata = this;
372
373         // Help menu button
374         menu_help2 = obj = 
375                 fl_add_button(FL_TOUCH_BUTTON,
376                               moffset, yloc,
377                               fl_get_string_width(FL_BOLD_STYLE,
378                                                   MENU_LABEL_SIZE,
379                                                   _("Help"),
380                                                   strlen(_("Help"))) + mbadd,
381                               mbheight, _("Help"));
382         moffset += obj->w + air;
383         fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
384         fl_set_object_callback(obj, C_Menus_ShowHelpMenu, 0);
385         obj->u_vdata = this;
386         
387         fl_end_group();
388
389         // Set the menu buttons atrributes.
390         // Due to a bug in xforms we cant do this only an the group.
391         obj = menu_grp2->next;
392         do {
393                 fl_set_object_boxtype(obj, FL_FLAT_BOX);
394                 fl_set_object_color(obj, FL_MCOL, FL_MCOL);
395                 fl_set_object_lsize(obj, MENU_LABEL_SIZE);
396                 fl_set_object_lstyle(obj, FL_BOLD_STYLE);
397                 fl_set_object_resize(obj, FL_RESIZE_ALL);
398                 fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
399                 obj= obj->next;
400         } while (obj != 0 && obj->objclass != FL_END_GROUP);
401 }
402
403
404 void Menus::ScreenOptions()
405 {
406         static int ow = -1, oh;
407
408         // this is not very nice....
409         fl_set_input(fd_form_screen->input_roman, 
410                      lyxrc.roman_font_name.c_str());
411         fl_set_input(fd_form_screen->input_sans, 
412                      lyxrc.sans_font_name.c_str());
413         fl_set_input(fd_form_screen->input_typewriter,
414                      lyxrc.typewriter_font_name.c_str());
415         fl_set_input(fd_form_screen->input_font_norm, 
416                      lyxrc.font_norm.c_str());
417         char tmpstring[10];
418         sprintf(tmpstring, "%d", lyxrc.zoom);
419         fl_set_input(fd_form_screen->intinput_size, tmpstring);
420         if (fd_form_screen->form_screen->visible) {
421                 fl_raise_form(fd_form_screen->form_screen);
422         } else {
423                 fl_show_form(fd_form_screen->form_screen,
424                              FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
425                              _("Screen Options"));
426                 if (ow < 0) {
427                         ow = fd_form_screen->form_screen->w;
428                         oh = fd_form_screen->form_screen->h;
429                 }
430                 fl_set_form_minsize(fd_form_screen->form_screen, ow, oh);
431         }
432 }
433
434
435 //
436 // Here comes all the menu callbacks.
437 //
438
439 void Menus::ShowFileMenu(FL_OBJECT * ob, long)
440 {
441         Menus * men = static_cast<Menus*>(ob->u_vdata);
442
443         // Regarding the pseudo-menu-button:
444         // ok, ok this is a hack. It would be better to use the menus of the
445         // xforms 0.8 library. but then all popups have to be defined all the
446         // time, code rewriting would be necessary and contex-depending menus
447         // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
448         // course it would be more proper (and little faster). So if anybody
449         // likes to do the cleanup, just do it. Matthias
450
451         // set the pseudo menu-button
452         fl_set_object_boxtype(ob, FL_UP_BOX);
453         fl_set_button(ob, 0);
454         fl_redraw_object(ob);
455
456         Buffer * tmpbuffer = men->_view->buffer();
457         LyXFunc * tmpfunc = men->_view->getLyXFunc();
458
459         bool LinuxDoc = tmpbuffer->isLinuxDoc();
460         bool DocBook  = tmpbuffer->isDocBook();
461         bool Literate = tmpbuffer->isLiterate();
462
463         // Import sub-menu
464
465         int SubFileImport = fl_defpup(FL_ObjWin(ob),
466                                       _("Import%t"
467                                         "|LaTeX...%x30"
468                                         "|Ascii Text as Lines...%x31"
469                                         "|Ascii Text as Paragraphs%x32"
470                                         "|Noweb%x33"));
471         
472         fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
473         fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
474         fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
475         fl_setpup_shortcut(SubFileImport, 33, scex(_("FIM|Nn#n#N")));
476
477         // Export sub-menu
478
479         // remember to make this handle linuxdoc too.
480         // and now docbook also.
481         int SubFileExport = 0;
482         if (!LinuxDoc && !DocBook)
483                 SubFileExport= fl_defpup(FL_ObjWin(ob),
484                                          _("Export%t"
485                                            "|as LaTeX...%x40"
486                                            "|as DVI...%x41"
487                                            "|as PostScript...%x42"
488                                            "|as Ascii Text...%x43"
489                                            "|as HTML...%x44"
490                                            "|Custom...%x45"));
491         else if(LinuxDoc)
492                 SubFileExport= fl_defpup(FL_ObjWin(ob),
493                                          _("Export%t"
494                                            "|as LinuxDoc...%x40"
495                                            "|as DVI...%x41"
496                                            "|as PostScript...%x42"
497                                            "|as Ascii Text...%x43"));
498         else if(DocBook)
499                 SubFileExport= fl_defpup(FL_ObjWin(ob),
500                                          _("Export%t"
501                                            "|as DocBook...%x40"
502                                            "|as DVI...%x41"
503                                            "|as PostScript...%x42"
504                                            "|as Ascii Text...%x43"));
505
506         fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
507         fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
508         fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
509         fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
510         if (!LinuxDoc && !DocBook) {
511                 fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
512                 fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
513         }
514         
515         int FileMenu = fl_defpup(FL_ObjWin(ob),
516                                  _("New..."
517                                    "|New from template..."
518                                    "|Open...%l"
519                                    "|Close"
520                                    "|Save"
521                                    "|Save As..."
522                                    "|Revert to saved%l"
523                                    "|View dvi"
524                                    "|View PostScript"
525                                    "|Update dvi"
526                                    "|Update PostScript"
527                                    "|Build program%l"
528                                    "|Print..."
529                                    "|Fax..."));
530
531         fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
532         fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
533         fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
534         fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Cc#c#C")));
535         fl_setpup_shortcut(FileMenu, 5, scex(_("FM|Ss#s#S")));
536         fl_setpup_shortcut(FileMenu, 6, scex(_("FM|Aa#a#A")));
537         fl_setpup_shortcut(FileMenu, 7, scex(_("FM|Rr#r#R")));
538         fl_setpup_shortcut(FileMenu, 8, scex(_("FM|dD#d#D")));
539         fl_setpup_shortcut(FileMenu, 9, scex(_("FM|wW#w#W")));
540         fl_setpup_shortcut(FileMenu, 10, scex(_("FM|vV#v#V")));
541         fl_setpup_shortcut(FileMenu, 11, scex(_("FM|Uu#u#U")));
542         fl_setpup_shortcut(FileMenu, 12, scex(_("FM|Bb#b#B")));
543         fl_setpup_shortcut(FileMenu, 13, scex(_("FM|Pp#p#P")));
544         fl_setpup_shortcut(FileMenu, 14, scex(_("FM|Ff#f#F")));
545
546         // These commands are disabled when the corresponding programs
547         // are not installed. I simply grey them out, since I do not
548         // want to change their number (JMarc)
549         bool hasLaTeX = lyxrc.latex_command != "none";
550
551         if (!hasLaTeX || lyxrc.view_dvi_command == "none") 
552                 fl_setpup_mode(FileMenu, 8, FL_PUP_GREY);
553         
554         if (!hasLaTeX || lyxrc.view_ps_command == "none") 
555                 fl_setpup_mode(FileMenu, 9, FL_PUP_GREY);
556         
557         if (!hasLaTeX) {
558                 fl_setpup_mode(FileMenu, 10, FL_PUP_GREY);
559                 fl_setpup_mode(FileMenu, 11, FL_PUP_GREY);
560         } 
561
562         if (lyxrc.literate_command == "none" || ! Literate) 
563                 fl_setpup_mode(FileMenu, 12, FL_PUP_GREY);
564
565         if (!hasLaTeX || lyxrc.print_command == "none") 
566                 fl_setpup_mode(FileMenu, 13, FL_PUP_GREY);
567
568         if (!hasLaTeX || lyxrc.fax_command == "none") 
569                 fl_setpup_mode(FileMenu, 14, FL_PUP_GREY);
570
571         bool hasReLyX = lyxrc.relyx_command != "none";
572         if (!hasReLyX) {
573                 // Disable import LaTeX and Noweb
574                 fl_setpup_mode(SubFileImport, 30, FL_PUP_GREY);
575                 fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
576         }
577
578         if (!hasLaTeX) {
579                 // Disable export dvi and export postscript
580                 fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
581                 fl_setpup_mode(SubFileExport, 42, FL_PUP_GREY);
582         }
583
584         if (lyxrc.html_command == "none") {
585                 // Disable export HTML
586                 fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
587         }
588
589         // xgettext:no-c-format
590         fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
591         // xgettext:no-c-format
592         fl_addtopup(FileMenu, _("|Export%m%l"), SubFileExport);
593         // xgettext:no-c-format
594         fl_addtopup(FileMenu, _("|Exit%l"));
595         fl_setpup_shortcut(FileMenu, 15, scex(_("FM|Ii#i#I")));
596         fl_setpup_shortcut(FileMenu, 16, scex(_("FM|Ee#e#E")));
597         fl_setpup_shortcut(FileMenu, 17, scex(_("FM|xX#x#X")));
598
599         // make the lastfiles menu
600         int ii = 1;
601         for (LastFiles::Files::const_iterator cit = lastfiles->begin();
602              cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
603                 string tmp = tostr(ii);
604                 string tmp2 = tmp + "#" + tmp;;
605                 tmp += ". " + MakeDisplayPath((*cit), 30);
606                 fl_addtopup(FileMenu, tmp.c_str());
607                 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
608         }
609
610         // place popup
611         fl_setpup_position(
612                 men->_view->getForm()->x + ob->x,
613                 men->_view->getForm()->y + ob->y + ob->h + 10);   
614         int choice = fl_dopup(FileMenu);
615         XFlush(fl_display);
616
617         // set the pseudo menu-button back
618         fl_set_object_boxtype(ob, FL_FLAT_BOX);
619         fl_redraw_object(ob);
620
621         switch (choice) {
622         case -1: case 0: // we won't do anything
623                 break;
624         case  1: tmpfunc->Dispatch(LFUN_MENUNEW); break;
625         case  2: tmpfunc->Dispatch(LFUN_MENUNEWTMPLT); break;
626         case  3: tmpfunc->Dispatch(LFUN_MENUOPEN); break;
627         case  4: tmpfunc->Dispatch(LFUN_CLOSEBUFFER); break;
628         case  5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
629         case  6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
630         case  7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
631         case  8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
632         case  9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
633         case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
634         case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
635         case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
636         case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
637         case 14: tmpfunc->Dispatch(LFUN_FAX); break;
638         case 15: // import menu
639         case 30: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
640                 break;
641         case 31: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
642                 break;
643         case 32: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
644                 break;
645         case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
646                 break;
647         case 16: // export menu
648         case 40:
649                 if (!LinuxDoc && !DocBook)
650                         tmpfunc->Dispatch(LFUN_EXPORT, "latex");
651                 else if(LinuxDoc)
652                         tmpfunc->Dispatch(LFUN_EXPORT, "linuxdoc");
653                 else
654                         tmpfunc->Dispatch(LFUN_EXPORT, "docbook");
655                 break;
656         case 41: tmpfunc->Dispatch(LFUN_EXPORT, "dvi");
657                 break;
658         case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
659                 break;
660         case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
661                 break;
662         case 44: tmpfunc->Dispatch(LFUN_EXPORT, "html");
663                 break;
664         case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom"); 
665                 break;
666         case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
667                 // Lastfiles:
668         case 18: // The first item with lastfiles.
669         default:
670                 men->currentView()
671                         ->buffer(bufferlist
672                                  .loadLyXFile((*lastfiles)[choice - 18]));
673                 break;
674         }
675         fl_freepup(SubFileImport);
676         fl_freepup(SubFileExport);
677         fl_freepup(FileMenu);
678
679         AllowInput();
680 }
681
682
683 void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
684 {
685         Menus * men = static_cast<Menus*>(ob->u_vdata);
686
687         // Regarding the pseudo-menu-button:
688         // ok, ok this is a hack. It would be better to use the menus of the
689         // xforms 0.8 library. but then all popups have to be defined all the
690         // time, code rewriting would be necessary and contex-depending menus
691         // (i.e. the linux-doc-sgml stuff) are a bit more complicated. But of
692         // course it would be more proper (and little faster). So if anybody
693         // likes to do the cleanup, just do it. Matthias
694
695         // set the pseudo menu-button
696         fl_set_object_boxtype(ob, FL_UP_BOX);
697         fl_set_button(ob, 0);
698         fl_redraw_object(ob);
699
700         LyXFunc * tmpfunc = men->_view->getLyXFunc();
701
702         // Import sub-menu
703         
704         int SubFileImport = fl_defpup(FL_ObjWin(ob),
705                                       _("Import%t"
706                                         "|LaTeX...%x15"
707                                         "|Ascii Text as Lines...%x16"
708                                         "|Ascii Text as Paragraphs...%x17"
709                                         "|Noweb...%x18"));
710         
711         fl_setpup_shortcut(SubFileImport, 15, scex(_("FIM|Ll#l#L")));
712         fl_setpup_shortcut(SubFileImport, 16, scex(_("FIM|Aa#a#A")));
713         fl_setpup_shortcut(SubFileImport, 17, scex(_("FIM|Pp#p#P")));
714         fl_setpup_shortcut(SubFileImport, 18, scex(_("FIM|Nn#n#N")));
715
716         bool hasReLyX = lyxrc.relyx_command != "none";
717         if (!hasReLyX) {
718                 // Disable import LaTeX and Noweb
719                 fl_setpup_mode(SubFileImport, 15, FL_PUP_GREY);
720                 fl_setpup_mode(SubFileImport, 18, FL_PUP_GREY);
721         }
722
723         // This can be done cleaner later.
724         int FileMenu = fl_defpup(FL_ObjWin(ob), 
725                                  _("New..."
726                                    "|New from template..."
727                                    "|Open...%l"
728                                    "|Import%m%l"
729                                    "|Exit%l"), SubFileImport);
730         
731         fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
732         fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
733         fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
734         fl_setpup_shortcut(FileMenu, 4, scex(_("FM|Ii#i#I")));
735         fl_setpup_shortcut(FileMenu, 5, scex(_("FM|xX#x#X")));
736         
737         // make the lastfiles menu
738         int ii = 1;
739         for (LastFiles::Files::const_iterator cit = lastfiles->begin();
740              cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
741                 string tmp = tostr(ii);
742                 string tmp2 = tmp + "#" + tmp;;
743                 tmp += ". " + MakeDisplayPath((*cit), 30);
744                 fl_addtopup(FileMenu, tmp.c_str());
745                 fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
746         }
747
748         // place popup
749         fl_setpup_position(
750                 men->_view->getForm()->x + ob->x,
751                 men->_view->getForm()->y + ob->y + ob->h + 10);   
752         int choice = fl_dopup(FileMenu);
753         XFlush(fl_display);
754
755         // set the pseudo menu-button back
756         fl_set_object_boxtype(ob, FL_FLAT_BOX);
757         fl_redraw_object(ob);
758
759         switch (choice) {
760         case -1: case 0: // we won't do anything
761                 break;
762         case 1:
763                 tmpfunc->Dispatch(LFUN_MENUNEW);
764                 break;
765         case 2:
766                 tmpfunc->Dispatch(LFUN_MENUNEWTMPLT);
767                 break;
768         case 3:
769                 tmpfunc->Dispatch(LFUN_MENUOPEN);
770                 break;
771         case 4: // import menu
772         case 15: tmpfunc->Dispatch(LFUN_IMPORT, "latex");
773                 break;
774         case 16: tmpfunc->Dispatch(LFUN_IMPORT, "ascii");
775                 break;
776         case 17: tmpfunc->Dispatch(LFUN_IMPORT, "asciiparagraph");
777                 break;
778         case 18: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
779                 break;
780         case 5:
781                 tmpfunc->Dispatch(LFUN_QUIT);
782                 break;
783                 // Lastfiles:
784         case 6: // The first item with lastfiles.
785         default:
786                 men->currentView()
787                         ->buffer(bufferlist
788                                  .loadLyXFile((*lastfiles)[choice - 6]));
789                 break;
790         }
791
792         fl_freepup(SubFileImport);
793         fl_freepup(FileMenu);
794         AllowInput();
795         return;
796 }
797
798
799 void Menus::ShowEditMenu(FL_OBJECT * ob, long)
800 {
801         Menus * men = static_cast<Menus*>(ob->u_vdata);
802         
803         // set the pseudo menu-button
804         fl_set_object_boxtype(ob, FL_UP_BOX);
805         fl_set_button(ob, 0);
806         fl_redraw_object(ob);
807
808         Buffer * tmpbuffer = men->_view->buffer();
809         LyXFunc * tmpfunc = men->_view->getLyXFunc();
810
811         // Floats & Insets submenu
812         int SubEditFloats= fl_defpup(FL_ObjWin(ob),
813                                      _("Floats & Insets%t"
814                                        "|Open/Close%x21"
815                                        "|Melt%x22"
816                                        "|Open All Footnotes/Margin Notes%x23"
817                                        "|Close All Footnotes/Margin Notes%x24"
818                                        "|Open All Figures/Tables%x25"
819                                        "|Close All Figures/Tables%x26%l"
820                                        "|Remove all Error Boxes%x27"));
821         
822         fl_setpup_shortcut(SubEditFloats, 21, scex(_("EMF|Oo#o#O")));
823         fl_setpup_shortcut(SubEditFloats, 22, scex(_("EMF|Mm#m#M")));
824         fl_setpup_shortcut(SubEditFloats, 23, scex(_("EMF|Aa#a#A")));
825         fl_setpup_shortcut(SubEditFloats, 24, scex(_("EMF|Cc#c#C")));
826         fl_setpup_shortcut(SubEditFloats, 25, scex(_("EMF|Ff#f#F")));
827         fl_setpup_shortcut(SubEditFloats, 26, scex(_("EMF|Tt#t#T")));
828         fl_setpup_shortcut(SubEditFloats, 27, scex(_("EMF|Rr#r#R")));
829
830         // Table submenu
831         int SubEditTable = fl_newpup(FL_ObjWin(ob));
832         if (men->currentView()->available() && 
833             men->currentView()->text->cursor.par->table &&
834             !tmpbuffer->isReadonly()){
835
836                 fl_addtopup(SubEditTable, _("Table%t"));
837
838                 if (men->currentView()->text->cursor.par->table->
839                     IsMultiColumn(men->currentView()->text->
840                                   NumberOfCell(men->currentView()->
841                                                text->cursor.par, 
842                                                men->currentView()->
843                                                text->cursor.pos)))
844                         fl_addtopup(SubEditTable, _("|Multicolumn%B%x44%l"));
845                 else
846                         fl_addtopup(SubEditTable, _("|Multicolumn%b%x44%l"));
847                 fl_setpup_shortcut(SubEditTable, 44, scex(_("EMT|Mm#m#M")));
848      
849                 if (men->currentView()->text->cursor.par->table->
850                     TopLine(men->currentView()->text->
851                             NumberOfCell(men->currentView()->
852                                          text->cursor.par, 
853                                          men->currentView()->text->
854                                          cursor.pos)))
855                         fl_addtopup(SubEditTable, _("|Line Top%B%x36"));
856                 else
857                         fl_addtopup(SubEditTable, _("|Line Top%b%x36"));
858                 fl_setpup_shortcut(SubEditTable, 36, scex(_("EMT|Tt#t#T")));
859      
860                 if (men->currentView()->text->cursor.par->table->
861                     BottomLine(men->currentView()->text->
862                                NumberOfCell(men->currentView()->
863                                             text->cursor.par, 
864                                             men->currentView()->
865                                             text->cursor.pos)))
866                         fl_addtopup(SubEditTable, _("|Line Bottom%B%x37"));
867                 else
868                         fl_addtopup(SubEditTable, _("|Line Bottom%b%x37"));
869                 fl_setpup_shortcut(SubEditTable, 37, scex(_("EMT|Bb#b#B")));
870
871                 if (men->currentView()->text->cursor.par->table->
872                     LeftLine(men->currentView()->text->
873                              NumberOfCell(men->currentView()->
874                                           text->cursor.par, 
875                                           men->currentView()->
876                                           text->cursor.pos)))
877                         fl_addtopup(SubEditTable, _("|Line Left%B%x38"));
878                 else
879                         fl_addtopup(SubEditTable, _("|Line Left%b%x38"));
880                 fl_setpup_shortcut(SubEditTable, 38, scex(_("EMT|Ll#l#L")));
881
882                 if (men->currentView()->text->cursor.par->table->
883                     RightLine(men->currentView()->text->
884                               NumberOfCell(men->currentView()->
885                                            text->cursor.par, 
886                                            men->currentView()->
887                                            text->cursor.pos)))
888                         fl_addtopup(SubEditTable, _("|Line Right%B%x39%l"));
889                 else
890                         fl_addtopup(SubEditTable, _("|Line Right%b%x39%l"));
891                 fl_setpup_shortcut(SubEditTable, 39, scex(_("EMT|Rr#r#R")));
892
893                 int align = men->currentView()->text->cursor.par->
894                         table->GetAlignment(men->currentView()->text->
895                                             NumberOfCell(men->currentView()->
896                                                          text->cursor.par, 
897                                                          men->currentView()->
898                                                          text->cursor.pos));
899                 if (align == LYX_ALIGN_LEFT)
900                         fl_addtopup(SubEditTable, _("|Align Left%R%x40"));
901                 else
902                         fl_addtopup(SubEditTable, _("|Align Left%r%x40"));
903                 fl_setpup_shortcut(SubEditTable, 40, scex(_("EMT|eE#e#E")));
904
905                 if (align == LYX_ALIGN_RIGHT)
906                         fl_addtopup(SubEditTable, _("|Align Right%R%x41"));
907                 else
908                         fl_addtopup(SubEditTable, _("|Align Right%r%x41"));
909                 fl_setpup_shortcut(SubEditTable, 41, scex(_("EMT|iI#i#I")));
910
911                 if (align == LYX_ALIGN_CENTER)
912                         fl_addtopup(SubEditTable, _("|Align Center%R%x42%l"));
913                 else
914                         fl_addtopup(SubEditTable, _("|Align Center%r%x42%l"));
915                 fl_setpup_shortcut(SubEditTable, 42, scex(_("EMT|Cc#c#C")));
916
917                 // xgettext:no-c-format
918                 fl_addtopup(SubEditTable, _("|Append Row%x32"));
919                 fl_setpup_shortcut(SubEditTable, 32, scex(_("EMT|oO#o#O")));
920                 // xgettext:no-c-format
921                 fl_addtopup(SubEditTable, _("|Append Column%x33%l"));
922                 fl_setpup_shortcut(SubEditTable, 33, scex(_("EMT|uU#u#U")));
923                 // xgettext:no-c-format
924                 fl_addtopup(SubEditTable, _("|Delete Row%x34"));
925                 fl_setpup_shortcut(SubEditTable, 34, scex(_("EMT|wW#w#W")));
926                 // xgettext:no-c-format
927                 fl_addtopup(SubEditTable, _("|Delete Column%x35%l"));
928                 fl_setpup_shortcut(SubEditTable, 35, scex(_("EMT|nN#n#N")));
929                 // xgettext:no-c-format
930                 fl_addtopup(SubEditTable, _("|Delete Table%x43"));
931                 fl_setpup_shortcut(SubEditTable, 43, scex(_("EMT|Dd#d#D")));
932         }
933         else {
934                 fl_addtopup(SubEditTable, _("Table%t"));
935                 // xgettext:no-c-format
936                 fl_addtopup(SubEditTable, _("|Insert table%x31"));
937                 fl_setpup_shortcut(SubEditTable, 31, scex(_("EMT|Ii#i#I")));
938         }
939
940         int SubVersionControl =         fl_newpup(FL_ObjWin(ob));
941         fl_addtopup(SubVersionControl, _("Version Control%t"));
942         if (tmpbuffer->lyxvc.inUse()) {
943                 // xgettext:no-c-format
944                 fl_addtopup(SubVersionControl, _("|Register%d%x51"));
945                 if (tmpbuffer->isReadonly()) {
946                         // signifies that the file is not checked out
947                         // xgettext:no-c-format
948                         fl_addtopup(SubVersionControl, _("|Check In Changes%d%x52"));
949                         // xgettext:no-c-format
950                         fl_addtopup(SubVersionControl, _("|Check Out for Edit%x53"));
951                 } else {
952                         // signifies that the file is checked out
953                         // xgettext:no-c-format
954                         fl_addtopup(SubVersionControl, _("|Check In Changes%x52"));
955                         // xgettext:no-c-format
956                         fl_addtopup(SubVersionControl, _("|Check Out for Edit%d%x53"));
957                 }
958                 // xgettext:no-c-format
959                 fl_addtopup(SubVersionControl, _("|Revert to last version%x54"));
960                 // xgettext:no-c-format
961                 fl_addtopup(SubVersionControl, _("|Undo last check in%x55"));
962                 // xgettext:no-c-format
963                 fl_addtopup(SubVersionControl, _("|Show History%x56"));
964         } else {
965                 // xgettext:no-c-format
966                 fl_addtopup(SubVersionControl, _("|Register%x51"));
967         }
968         // the shortcuts are not good.
969         fl_setpup_shortcut(SubVersionControl, 51, scex(_("EMV|Rr#r#R")));
970         fl_setpup_shortcut(SubVersionControl, 52, scex(_("EMV|Ii#i#I")));
971         fl_setpup_shortcut(SubVersionControl, 53, scex(_("EMV|Oo#o#O")));
972         fl_setpup_shortcut(SubVersionControl, 54, scex(_("EMV|lL#l#l")));
973         fl_setpup_shortcut(SubVersionControl, 55, scex(_("EMV|Uu#u#U")));
974         fl_setpup_shortcut(SubVersionControl, 56, scex(_("EMV|Hh#h#H")));
975
976         int EditMenu= fl_defpup(FL_ObjWin(ob),
977                                 _("Undo"
978                                   "|Redo %l"
979                                   "|Cut"
980                                   "|Copy"
981                                   "|Paste%l"
982                                   "|Find & Replace..."
983                                   "|Go to Error"
984                                   "|Go to Note"
985                                   "|Floats & Insets%m"
986                                   "|Table%m"
987                                   "|Spellchecker...."
988                                   "|Check TeX"
989                                   "|Table of Contents...%l"
990                                   "|Version Control%m%l"
991                                   "|View LaTeX log file%l"
992                                   "|Paste Primary Selection as Lines"
993                                   "|Paste Primary Selection as Paragraphs"),
994                                 SubEditFloats, SubEditTable, SubVersionControl);
995
996         fl_setpup_shortcut(EditMenu, 1, scex(_("EM|Uu#u#U")));
997         fl_setpup_shortcut(EditMenu, 2, scex(_("EM|Rr#r#R")));
998         fl_setpup_shortcut(EditMenu, 3, scex(_("EM|Cc#c#C")));
999         fl_setpup_shortcut(EditMenu, 4, scex(_("EM|oO#o#O")));
1000         fl_setpup_shortcut(EditMenu, 5, scex(_("EM|Pp#p#P")));
1001         fl_setpup_shortcut(EditMenu, 6, scex(_("EM|Ff#f#F")));
1002         fl_setpup_shortcut(EditMenu, 7, scex(_("EM|Ee#e#E")));
1003         fl_setpup_shortcut(EditMenu, 8, scex(_("EM|Nn#n#N")));
1004         fl_setpup_shortcut(EditMenu, 9, scex(_("EM|Ii#i#I")));
1005         fl_setpup_shortcut(EditMenu, 10, scex(_("EM|Tt#t#T")));
1006         fl_setpup_shortcut(EditMenu, 11, scex(_("EM|Ss#s#S")));
1007         fl_setpup_shortcut(EditMenu, 12, scex(_("EM|hH#h#H")));
1008         fl_setpup_shortcut(EditMenu, 13, scex(_("EM|aA#a#A")));
1009         fl_setpup_shortcut(EditMenu, 14, scex(_("EM|Vv#v#V")));
1010         fl_setpup_shortcut(EditMenu, 15, scex(_("EM|wW#w#W")));
1011         fl_setpup_shortcut(EditMenu, 16, scex(_("EM|Ll#l#L")));
1012         fl_setpup_shortcut(EditMenu, 17, scex(_("EM|gG#g#G")));
1013       
1014         // disable unavailable entries.
1015         if(tmpbuffer->undostack.empty())
1016                 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY);
1017         if(tmpbuffer->redostack.empty())
1018                 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY);
1019         if(lyxrc.isp_command == "none") 
1020                 fl_setpup_mode(EditMenu, 11, FL_PUP_GREY);
1021         if(lyxrc.chktex_command == "none") 
1022                 fl_setpup_mode(EditMenu, 12, FL_PUP_GREY);
1023
1024         if (tmpbuffer->isReadonly()) {
1025                 fl_setpup_mode(EditMenu, 1, FL_PUP_GREY); 
1026                 fl_setpup_mode(EditMenu, 2, FL_PUP_GREY); 
1027                 fl_setpup_mode(EditMenu, 3, FL_PUP_GREY); 
1028                 fl_setpup_mode(EditMenu, 5, FL_PUP_GREY); 
1029                 fl_setpup_mode(EditMenu, 16, FL_PUP_GREY); 
1030                 fl_setpup_mode(EditMenu, 17, FL_PUP_GREY);
1031         }
1032         
1033         fl_setpup_position(men->_view->getForm()->x + ob->x,
1034                            men->_view->getForm()->y + ob->y +
1035                            ob->h + 10);   
1036         int choice = fl_dopup(EditMenu);
1037         XFlush(fl_display);
1038    
1039         // set the pseudo menu-button back
1040         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1041         fl_redraw_object(ob);
1042
1043         switch (choice) {
1044         case  1: tmpfunc->Dispatch(LFUN_UNDO); break;
1045         case  2: tmpfunc->Dispatch(LFUN_REDO); break;
1046         case  3: tmpfunc->Dispatch(LFUN_CUT); break;
1047         case  4: tmpfunc->Dispatch(LFUN_COPY); break;
1048         case  5: tmpfunc->Dispatch(LFUN_PASTE); break;
1049         case  6: tmpfunc->Dispatch(LFUN_MENUSEARCH); break;
1050         case  7: tmpfunc->Dispatch(LFUN_GOTOERROR); break;
1051         case  8: tmpfunc->Dispatch(LFUN_GOTONOTE); break;
1052         case  9: // floats & insets
1053                 break;
1054         case 10:// table 
1055                 break;
1056         case 11: tmpfunc->Dispatch(LFUN_SPELLCHECK); break;
1057         case 12: tmpfunc->Dispatch(LFUN_RUNCHKTEX); break;
1058         case 13: tmpfunc->Dispatch(LFUN_TOCVIEW); break;
1059         case 14: // version control
1060                 break;
1061         case 15: tmpfunc->Dispatch(LFUN_LATEX_LOG); break;
1062         case 16: tmpfunc->Dispatch(LFUN_PASTESELECTION, "line"); break;
1063         case 17: tmpfunc->Dispatch(LFUN_PASTESELECTION, "paragraph"); break;
1064
1065                 // floats & insets sub-menu
1066         case 21: men->currentView()->toggleFloat(); break;
1067         case 22: tmpfunc->Dispatch(LFUN_MELT); break;
1068         case 23: men->currentView()->allFloats(1, 0); break;
1069         case 24: men->currentView()->allFloats(0, 0); break;
1070         case 25: men->currentView()->allFloats(1, 1); break;
1071         case 26: men->currentView()->allFloats(0, 1); break;
1072         case 27: tmpfunc->Dispatch(LFUN_REMOVEERRORS); break;
1073
1074         case 31: tmpfunc->Dispatch(LFUN_TABLE); break;
1075                 // this is really temporary. We need new function in keybind.C
1076                 // These should set the minibuffer, too.
1077         case 32: case 33: case 34:
1078         case 35: case 36: case 37:
1079         case 38: case 39: case 40: 
1080         case 41: case 42: case 43:
1081         case 44: 
1082                 if (men->currentView()->available()) {
1083                         men->currentView()->hideCursor();
1084                         if (!men->currentView()->text->selection){
1085                                 men->currentView()->beforeChange(); 
1086                                 men->currentView()->update(-2);
1087                         }
1088                         men->currentView()->text->
1089                                 TableFeatures(choice - 32);
1090                         men->currentView()->update(1);
1091                 }
1092                 break;
1093                 // version control sub-menu
1094         case 51: // register
1095                 tmpfunc->Dispatch(LFUN_VC_REGISTER);
1096                 break;
1097         case 52: // check in
1098                 tmpfunc->Dispatch(LFUN_VC_CHECKIN);
1099                 break;
1100         case 53: // check out
1101                 tmpfunc->Dispatch(LFUN_VC_CHECKOUT);
1102                 break;
1103         case 54: // revert to last
1104                 tmpfunc->Dispatch(LFUN_VC_REVERT);
1105                 break;
1106         case 55: // undo last
1107                 tmpfunc->Dispatch(LFUN_VC_UNDO);
1108                 break;
1109         case 56: // show history
1110                 tmpfunc->Dispatch(LFUN_VC_HISTORY);
1111                 break;
1112         }
1113
1114         fl_freepup(EditMenu);
1115         fl_freepup(SubEditFloats);
1116         fl_freepup(SubEditTable);
1117         fl_freepup(SubVersionControl);
1118 }
1119
1120
1121 void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
1122 {
1123         Menus * men = static_cast<Menus*>(ob->u_vdata);
1124
1125         if (!men->currentView()->available())
1126                 return;
1127         
1128         // set the pseudo menu-button
1129         fl_set_object_boxtype(ob, FL_UP_BOX);
1130         fl_set_button(ob, 0);
1131         fl_redraw_object(ob);
1132    
1133         Buffer * tmpbuffer = men->_view->buffer();
1134         LyXFunc * tmpfunc = men->_view->getLyXFunc();
1135
1136         int LayoutMenu = fl_newpup(FL_ObjWin(ob));
1137         fl_addtopup(LayoutMenu, _("Character..."
1138                                   "|Paragraph..."
1139                                   "|Document..."
1140                                   "|Paper..."
1141                                   "|Table..."
1142                                   "|Quotes...%l"
1143                                   "|Emphasize Style%b"
1144                                   "|Noun Style%b"
1145                                   "|Bold Style%b"
1146                                   "|TeX Style%b"
1147                                   "|Change Environment Depth"
1148                                   "|LaTeX Preamble...%l"
1149                                   "|Save layout as default"));
1150         fl_setpup_shortcut(LayoutMenu, 1, scex(_("LM|Cc#c#C")));
1151         fl_setpup_shortcut(LayoutMenu, 2, scex(_("LM|Pp#p#P")));
1152         fl_setpup_shortcut(LayoutMenu, 3, scex(_("LM|Dd#d#D")));
1153         fl_setpup_shortcut(LayoutMenu, 4, scex(_("LM|aA#a#A")));
1154         fl_setpup_shortcut(LayoutMenu, 5, scex(_("LM|eE#e#E")));
1155         fl_setpup_shortcut(LayoutMenu, 6, scex(_("LM|Qq#q#Q")));
1156         fl_setpup_shortcut(LayoutMenu, 7, scex(_("LM|mM#m#M")));
1157         fl_setpup_shortcut(LayoutMenu, 8, scex(_("LM|Nn#n#N")));
1158         fl_setpup_shortcut(LayoutMenu, 9, scex(_("LM|Bb#b#B")));
1159         fl_setpup_shortcut(LayoutMenu, 10, scex(_("LM|Tt#t#T")));
1160         fl_setpup_shortcut(LayoutMenu, 11, scex(_("LM|vV#v#V")));
1161         fl_setpup_shortcut(LayoutMenu, 12, scex(_("LM|Ll#l#L")));
1162         fl_setpup_shortcut(LayoutMenu, 13, scex(_("LM|Ss#s#S")));
1163
1164         // Set values of checkboxes according to font
1165         LyXFont font = men->currentView()->text->real_current_font;
1166         if (font.emph() == LyXFont::ON)
1167                 fl_setpup_mode(LayoutMenu, 7, FL_PUP_CHECK);
1168         if (font.noun() == LyXFont::ON)
1169                 fl_setpup_mode(LayoutMenu, 8, FL_PUP_CHECK);
1170         if (font.series() == LyXFont::BOLD_SERIES)
1171                 fl_setpup_mode(LayoutMenu, 9, FL_PUP_CHECK);
1172         if (font.latex() == LyXFont::ON)
1173                 fl_setpup_mode(LayoutMenu, 10, FL_PUP_CHECK);
1174            
1175         // Grey out unavailable entries
1176         if (!men->currentView()->text->cursor.par->table)
1177                 fl_setpup_mode(LayoutMenu, 5, FL_PUP_GREY);
1178
1179         if (tmpbuffer->isReadonly()) {
1180                 fl_setpup_mode(LayoutMenu, 1, FL_PUP_GREY);
1181                 fl_setpup_mode(LayoutMenu, 6, FL_PUP_GREY);
1182                 fl_setpup_mode(LayoutMenu, 11, FL_PUP_GREY);
1183         }
1184
1185         fl_setpup_position(
1186                 men->_view->getForm()->x + ob->x,
1187                 men->_view->getForm()->y + ob->y + ob->h + 10);
1188         int choice = fl_dopup(LayoutMenu);
1189         XFlush(fl_display);
1190
1191         // set the pseudo menu-button back
1192         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1193         fl_redraw_object(ob);
1194
1195         switch (choice) {
1196         case 1:  tmpfunc->Dispatch(LFUN_LAYOUT_CHARACTER); break;
1197         case 2:  tmpfunc->Dispatch(LFUN_LAYOUT_PARAGRAPH); break;
1198         case 3:  tmpfunc->Dispatch(LFUN_LAYOUT_DOCUMENT);  break;
1199         case 4:  tmpfunc->Dispatch(LFUN_LAYOUT_PAPER); break;
1200         case 5:  tmpfunc->Dispatch(LFUN_LAYOUT_TABLE, "true"); break;
1201         case 6:  tmpfunc->Dispatch(LFUN_LAYOUT_QUOTES); break;
1202         case 7:  tmpfunc->Dispatch(LFUN_EMPH); break;
1203         case 8:  tmpfunc->Dispatch(LFUN_NOUN); break;
1204         case 9:  tmpfunc->Dispatch(LFUN_BOLD); break;
1205         case 10: tmpfunc->Dispatch(LFUN_TEX); break;
1206         case 11: tmpfunc->Dispatch(LFUN_DEPTH_PLUS); break;
1207         case 12: tmpfunc->Dispatch(LFUN_LAYOUT_PREAMBLE); break;
1208         case 13: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;
1209         }
1210         fl_freepup(LayoutMenu); 
1211 }
1212
1213
1214 void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
1215 {
1216         Menus * men = static_cast<Menus*>(ob->u_vdata);
1217         
1218         // set the pseudo menu-button
1219         fl_set_object_boxtype(ob, FL_UP_BOX);
1220         fl_set_button(ob, 0);
1221         fl_redraw_object(ob);
1222  
1223         Buffer * tmpbuffer = men->_view->buffer();
1224         LyXFunc * tmpfunc = men->_view->getLyXFunc();
1225
1226         int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
1227                                        _("Import ASCII file%t"
1228                                          "|As Lines%x41"
1229                                          "|As Paragraphs%x42"));
1230         
1231         fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
1232         fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
1233
1234         int SubInsertTableList= fl_defpup(FL_ObjWin(ob),
1235                                           _("Lists & TOC%t"
1236                                             "|Table of Contents%x21"
1237                                             "|List of Figures%x22"
1238                                             "|List of Tables%x23"
1239                                             "|List of Algorithms%x24"
1240                                             "|Index List%x25"
1241                                             "|BibTeX Reference%x26"));
1242         
1243         fl_setpup_shortcut(SubInsertTableList, 21, scex(_("IMT|Cc#c#C")));
1244         fl_setpup_shortcut(SubInsertTableList, 22, scex(_("IMT|Ff#f#F")));
1245         fl_setpup_shortcut(SubInsertTableList, 23, scex(_("IMT|Tt#t#T")));
1246         fl_setpup_shortcut(SubInsertTableList, 24, scex(_("IMT|Aa#a#A")));
1247         fl_setpup_shortcut(SubInsertTableList, 25, scex(_("IMT|Ii#i#I")));
1248         fl_setpup_shortcut(SubInsertTableList, 26, scex(_("IMT|Bb#b#B")));
1249
1250         int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
1251                                            _("Floats%t"
1252                                              "|Figure Float%x71"
1253                                              "|Table Float%x72"
1254                                              "|Wide Figure Float%x73"
1255                                              "|Wide Table Float%l%x74"
1256                                              "|Algorithm Float%x75"));
1257         
1258         fl_setpup_shortcut(SubInsertFloatList, 71, scex(_("IMF|gG#g#G")));
1259         fl_setpup_shortcut(SubInsertFloatList, 72, scex(_("IMF|Tt#t#T")));
1260         fl_setpup_shortcut(SubInsertFloatList, 73, scex(_("IMF|Ww#w#W")));
1261         fl_setpup_shortcut(SubInsertFloatList, 74, scex(_("IMF|iI#i#I")));
1262         fl_setpup_shortcut(SubInsertFloatList, 75, scex(_("IMF|Aa#a#A")));
1263         
1264         int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
1265                                          _("Special Character%t"
1266                                            "|HFill%x31"
1267                                            "|Hyphenation Point%x32"
1268                                            "|Protected Blank%x33"
1269                                            "|Linebreak%x34"
1270                                            "|Ellipsis (...)%x35"
1271                                            "|End of sentence period%x36"
1272                                            "|Ordinary Quote (\")%x37"
1273                                            "|Menu Separator %x38"));
1274
1275         fl_setpup_shortcut(SubInsertSpecial, 31, scex(_("IMS|Hh#h#H")));
1276         fl_setpup_shortcut(SubInsertSpecial, 32, scex(_("IMS|Pp#p#P")));
1277         fl_setpup_shortcut(SubInsertSpecial, 33, scex(_("IMS|Bb#b#B")));
1278         fl_setpup_shortcut(SubInsertSpecial, 34, scex(_("IMS|Ll#l#L")));
1279         fl_setpup_shortcut(SubInsertSpecial, 35, scex(_("IMS|iI#i#I")));
1280         fl_setpup_shortcut(SubInsertSpecial, 36, scex(_("IMS|Ee#e#E")));
1281         fl_setpup_shortcut(SubInsertSpecial, 37, scex(_("IMS|Qq#q#Q")));
1282         fl_setpup_shortcut(SubInsertSpecial, 38, scex(_("IMS|Mm#m#M")));
1283         
1284         int InsertMenu = fl_defpup(FL_ObjWin(ob),
1285                                    _("Figure..."
1286                                      "|Table...%l"
1287                                      "|Include File..." 
1288                                      "|Import ASCII File%m"
1289                                      "|Insert LyX File...%l"
1290                                      "|Footnote"
1291                                      "|Margin Note"
1292                                      "|Floats%m%l"      
1293                                      "|Lists & TOC%m%l"
1294                                      "|Special Character%m%l"
1295                                      "|Note..."
1296                                      "|Label..."
1297                                      "|Cross-Reference..."
1298                                      "|Citation Reference..."
1299                                      "|Index entry..."
1300                                      "|Index entry of last word"),
1301                                    SubInsertAscii,
1302                                    SubInsertFloatList,  
1303                                    SubInsertTableList,
1304                                    SubInsertSpecial);
1305
1306         fl_setpup_shortcut(InsertMenu, 1, scex(_("IM|gG#g#G")));
1307         fl_setpup_shortcut(InsertMenu, 2, scex(_("IM|bB#b#B")));
1308         fl_setpup_shortcut(InsertMenu, 3, scex(_("IM|cC#c#C")));
1309         fl_setpup_shortcut(InsertMenu, 4, scex(_("IM|Aa#a#A")));
1310         fl_setpup_shortcut(InsertMenu, 5, scex(_("IM|Xx#x#X")));
1311         fl_setpup_shortcut(InsertMenu, 6, scex(_("IM|Ff#f#F")));
1312         fl_setpup_shortcut(InsertMenu, 7, scex(_("IM|Mm#m#M")));
1313         fl_setpup_shortcut(InsertMenu, 8, scex(_("IM|oO#o#O")));
1314         fl_setpup_shortcut(InsertMenu, 9, scex(_("IM|Tt#t#T")));
1315         fl_setpup_shortcut(InsertMenu, 10, scex(_("IM|Ss#s#S")));
1316         fl_setpup_shortcut(InsertMenu, 11, scex(_("IM|Nn#n#N")));
1317         fl_setpup_shortcut(InsertMenu, 12, scex(_("IM|Ll#l#L")));
1318         fl_setpup_shortcut(InsertMenu, 13, scex(_("IM|rR#r#R")));     
1319         fl_setpup_shortcut(InsertMenu, 14, scex(_("IM|iI#i#I")));
1320         fl_setpup_shortcut(InsertMenu, 15, scex(_("IM|dD#d#D")));
1321         fl_setpup_shortcut(InsertMenu, 16, scex(_("IM|wW#w#W")));
1322
1323         fl_addtopup(InsertMenu, _("|URL..."));
1324         fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|Uu#u#U")));
1325
1326         if (tmpbuffer->isReadonly()) {
1327                 for (int ii = 1; ii <= 16; ++ii)
1328                         fl_setpup_mode(InsertMenu, ii, FL_PUP_GREY);
1329                 fl_setpup_mode(InsertMenu, 17, FL_PUP_GREY);
1330         }
1331
1332         fl_setpup_position(
1333                 men->_view->getForm()->x + ob->x,
1334                 men->_view->getForm()->y + ob->y + ob->h + 10);
1335    
1336         int choice = fl_dopup(InsertMenu);
1337         XFlush(fl_display);
1338
1339         // set the pseudo menu-button back
1340         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1341         fl_redraw_object(ob);
1342
1343         if (men->currentView()->available()){
1344                 men->currentView()->hideCursor();
1345                 switch (choice) {
1346                 case 1: tmpfunc->Dispatch(LFUN_FIGURE); break;
1347                 case 2: tmpfunc->Dispatch(LFUN_TABLE); break;
1348                 case 3: tmpfunc->Dispatch(LFUN_CHILDINSERT); break;
1349                 case 4: // Insert ASCII file submenu
1350                         break;
1351                 case 5: tmpfunc->Dispatch(LFUN_FILE_INSERT); break;
1352                 case 41: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "line"); break;
1353                 case 42: tmpfunc->Dispatch(LFUN_FILE_INSERT_ASCII, "paragraph"); break;
1354                 case 43: 
1355                         break;
1356
1357                 case 6: tmpfunc->Dispatch(LFUN_FOOTMELT); break
1358                                                                   ;
1359                 case 7: tmpfunc->Dispatch(LFUN_MARGINMELT); break;
1360   
1361                 case 8: // Float sub-menu
1362                 case 71:
1363                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "figure");
1364                         break;
1365                 case 72:
1366                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "table");
1367                         break;
1368                 case 73:
1369                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-fig");
1370                         break;
1371                 case 74:
1372                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "wide-tab");
1373                         break;
1374                 case 75:
1375                         tmpfunc->Dispatch(LFUN_INSERTFOOTNOTE, "algorithm");
1376                         break;
1377
1378                 case 9: // Table/List submenu
1379                         break;
1380                 case 21: tmpfunc->Dispatch(LFUN_TOC_INSERT); break;
1381                 case 22: tmpfunc->Dispatch(LFUN_LOF_INSERT); break;
1382                 case 23: tmpfunc->Dispatch(LFUN_LOT_INSERT); break;
1383                 case 24: tmpfunc->Dispatch(LFUN_LOA_INSERT); break;
1384                 case 25: tmpfunc->Dispatch(LFUN_INDEX_PRINT); break;
1385                 case 26: tmpfunc->Dispatch(LFUN_INSERT_BIBTEX); break;
1386
1387                 case 10: // Special Character submenu
1388                         break;
1389                 case 31: tmpfunc->Dispatch(LFUN_HFILL); break;
1390                 case 32: tmpfunc->Dispatch(LFUN_HYPHENATION); break;
1391                 case 33: tmpfunc->Dispatch(LFUN_PROTECTEDSPACE); break; 
1392                 case 34: tmpfunc->Dispatch(LFUN_BREAKLINE); break; 
1393                 case 35: tmpfunc->Dispatch(LFUN_LDOTS); break;
1394                 case 36: tmpfunc->Dispatch(LFUN_END_OF_SENTENCE); break;
1395                 case 37: tmpfunc->Dispatch(LFUN_QUOTE); break;
1396                 case 38: tmpfunc->Dispatch(LFUN_MENU_SEPARATOR); break;
1397
1398                 case 11: tmpfunc->Dispatch(LFUN_INSERT_NOTE); break;
1399                 case 12: tmpfunc->Dispatch(LFUN_INSERT_LABEL); break;
1400                 case 13: tmpfunc->Dispatch(LFUN_INSERT_REF); break;
1401                 case 14: tmpfunc->Dispatch(LFUN_INSERT_CITATION); break;
1402                 case 15: tmpfunc->Dispatch(LFUN_INDEX_INSERT); break;
1403                 case 16: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break;
1404                 case 17: tmpfunc->Dispatch(LFUN_URL); break;
1405                 }
1406         }
1407         fl_freepup(InsertMenu);
1408         fl_freepup(SubInsertAscii);
1409         fl_freepup(SubInsertTableList);
1410         fl_freepup(SubInsertFloatList);
1411         fl_freepup(SubInsertSpecial);
1412 }
1413
1414
1415 void Menus::ShowMathMenu(FL_OBJECT * ob, long)
1416 {
1417         extern void math_insert_symbol(char const * s);
1418
1419         Menus * men = static_cast<Menus*>(ob->u_vdata);
1420
1421         // set the pseudo menu-button
1422         fl_set_object_boxtype(ob, FL_UP_BOX);
1423         fl_set_button(ob, 0);
1424         fl_redraw_object(ob);
1425
1426         Buffer * tmpbuffer = men->_view->buffer();
1427         LyXFunc * tmpfunc = men->_view->getLyXFunc();
1428
1429         int MathMenu = fl_defpup(FL_ObjWin(ob), 
1430                                  _("Fraction"
1431                                    "|Square root"
1432                                    "|Exponent"
1433                                    "|Index"
1434                                    "|Sum"
1435                                    "|Integral%l"
1436                                    "|Math mode"
1437                                    "|Display%l"
1438                                    "|Math Panel..."));
1439
1440         fl_setpup_shortcut(MathMenu, 1, scex(_("MM|Ff#f#F")));
1441         fl_setpup_shortcut(MathMenu, 2, scex(_("MM|Ss#s#S")));
1442         fl_setpup_shortcut(MathMenu, 3, scex(_("MM|Ee#e#E")));
1443         fl_setpup_shortcut(MathMenu, 4, scex(_("MM|xX#x#X")));
1444         fl_setpup_shortcut(MathMenu, 5, scex(_("MM|uU#u#U")));
1445         fl_setpup_shortcut(MathMenu, 6, scex(_("MM|Ii#i#I")));
1446         fl_setpup_shortcut(MathMenu, 7, scex(_("MM|Mm#m#M")));
1447         fl_setpup_shortcut(MathMenu, 8, scex(_("MM|Dd#d#D")));
1448         fl_setpup_shortcut(MathMenu, 9, scex(_("MM|Pp#p#P")));
1449
1450         if (tmpbuffer->isReadonly()) 
1451                 for (int ii = 1; ii <= 9; ++ii)
1452                         fl_setpup_mode(MathMenu, ii, FL_PUP_GREY);
1453
1454
1455         fl_setpup_position(
1456                 men->_view->getForm()->x + ob->x,
1457                 men->_view->getForm()->y + ob->y + ob->h + 10);   
1458         int choice = fl_dopup(MathMenu);  
1459         XFlush(fl_display);
1460
1461         // set the pseudo menu-button back
1462         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1463         fl_redraw_object(ob);
1464
1465         if (men->currentView()->available())  {
1466                 switch (choice) {
1467                 case 1: /* frac */
1468                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "frac");
1469                         break;
1470                 case 2: /* sqrt */
1471                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
1472                         break;
1473                 case 3: /* Exponent */ 
1474                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "^");
1475                         break;
1476                 case 4: /* Index */
1477                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "_");
1478                         break;
1479                 case 5: /* sum */ 
1480                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "sum");
1481                         break;
1482                 case 6: /* int */
1483                         tmpfunc->Dispatch(LFUN_INSERT_MATH, "int");
1484                         break;
1485                 case 7:
1486                         tmpfunc->Dispatch(LFUN_MATH_MODE);
1487                         break;
1488                 case 8:
1489                         tmpfunc->Dispatch(LFUN_MATH_DISPLAY);
1490                         break;
1491                 case 9: /* Panel */
1492                         show_symbols_form(tmpfunc);
1493                         break;
1494                 }
1495                 men->currentView()->update(0);
1496         } 
1497         fl_freepup(MathMenu);
1498 }
1499
1500
1501 void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
1502 {
1503         Menus * men = static_cast<Menus*>(ob->u_vdata);
1504
1505         // set the pseudo menu-button
1506         fl_set_object_boxtype(ob, FL_UP_BOX);
1507         fl_set_button(ob, 0);
1508         fl_redraw_object(ob);
1509
1510         //Buffer *tmpbuffer = men->_view->currentBuffer();
1511         LyXFunc * tmpfunc = men->_view->getLyXFunc();
1512
1513         int OptionsMenu = fl_defpup(FL_ObjWin(ob),
1514                                     _("Screen Fonts..."
1515                                       "|Spellchecker Options..."
1516                                       "|Keyboard..."
1517                                       "|LaTeX...%l"
1518                                       "|Reconfigure" ));
1519
1520         fl_setpup_shortcut(OptionsMenu, 1, scex(_("OM|Ff#f#F")));
1521         fl_setpup_shortcut(OptionsMenu, 2, scex(_("OM|Ss#s#S")));
1522         fl_setpup_shortcut(OptionsMenu, 3, scex(_("OM|Kk#k#K")));
1523         fl_setpup_shortcut(OptionsMenu, 4, scex(_("OM|Ll#l#L")));
1524         fl_setpup_shortcut(OptionsMenu, 5, scex(_("OM|Rr#r#R")));
1525
1526         if(lyxrc.isp_command == "none") 
1527                 fl_setpup_mode(OptionsMenu, 2, FL_PUP_GREY);
1528
1529         fl_setpup_position(
1530                 men->_view->getForm()->x + ob->x,
1531                 men->_view->getForm()->y + ob->y + ob->h + 10);   
1532         int choice = fl_dopup(OptionsMenu);
1533         XFlush(fl_display);
1534
1535         // set the pseudo menu-button back
1536         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1537         fl_redraw_object(ob);
1538         switch (choice){
1539         case 1: men->ScreenOptions(); break;
1540         case 2: SpellCheckerOptions(); break;      
1541         case 3: men->_view->getIntl()->MenuKeymap(); break;
1542         case 4: LaTeXOptions(men->_view->view()); break;
1543         case 5: tmpfunc->Dispatch(LFUN_RECONFIGURE); break;
1544         default: break;
1545         }   
1546         fl_freepup(OptionsMenu);
1547 }
1548
1549
1550 void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
1551 {
1552         Menus * men = static_cast<Menus*>(ob->u_vdata);
1553         
1554         // set the pseudo menu-button
1555         fl_set_object_boxtype(ob, FL_UP_BOX);
1556         fl_set_button(ob, 0);
1557         fl_redraw_object(ob);
1558    
1559         int BufferMenu = fl_newpup(FL_ObjWin(ob));
1560         vector<string> namevec = bufferlist.getFileNames();
1561         if (namevec.size() != 0) {
1562                 for (vector<string>::const_iterator cit = namevec.begin();
1563                      cit != namevec.end(); ++cit) {
1564                         string relbuf = MakeDisplayPath((*cit), 30);
1565                         fl_addtopup(BufferMenu, relbuf.c_str());
1566                 }
1567         } else {
1568                 fl_addtopup(BufferMenu, _("No Documents Open!%t"));
1569         }
1570    
1571         fl_setpup_position(
1572                 men->_view->getForm()->x + ob->x,
1573                 men->_view->getForm()->y + ob->y + ob->h + 10);   
1574         int choice = fl_dopup(BufferMenu);
1575         XFlush(fl_display);
1576
1577         // set the pseudo menu-button back
1578         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1579         fl_redraw_object(ob);
1580         if (choice > 0) men->handleBufferMenu(choice - 1);
1581    
1582         fl_freepup(BufferMenu);
1583 }
1584
1585
1586 static
1587 char const * doc_files [] = {"Intro", "Tutorial", 
1588                              "UserGuide", "Extended",
1589                              "Customization", "Reference",
1590                              "BUGS", "LaTeXConfig"}; 
1591
1592 void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
1593 {
1594         Menus * men = static_cast<Menus*>(ob->u_vdata);
1595
1596         // set the pseudo menu-button
1597         fl_set_object_boxtype(ob, FL_UP_BOX);
1598         fl_set_button(ob, 0);
1599         fl_redraw_object(ob);
1600    
1601         int HelpMenu = fl_defpup(FL_ObjWin(ob),
1602                                  _("Introduction"
1603                                    "|Tutorial"
1604                                    "|User's Guide"
1605                                    "|Extended Features"
1606                                    "|Customization"
1607                                    "|Reference Manual"
1608                                    "|Known Bugs"
1609                                    "|LaTeX Configuration%l"
1610                                    "|Copyright and Warranty..."
1611                                    "|Credits..."
1612                                    "|Version..."));
1613    
1614         fl_setpup_shortcut(HelpMenu,  1, scex(_("HM|Ii#I#i")));
1615         fl_setpup_shortcut(HelpMenu,  2, scex(_("HM|Tt#T#t")));
1616         fl_setpup_shortcut(HelpMenu,  3, scex(_("HM|Uu#U#u")));
1617         fl_setpup_shortcut(HelpMenu,  4, scex(_("HM|xX#x#X")));
1618         fl_setpup_shortcut(HelpMenu,  5, scex(_("HM|Cc#C#c")));
1619         fl_setpup_shortcut(HelpMenu,  6, scex(_("HM|Rr#R#r")));
1620         fl_setpup_shortcut(HelpMenu,  7, scex(_("HM|Kk#K#k")));
1621         fl_setpup_shortcut(HelpMenu,  8, scex(_("HM|Ll#L#l")));
1622         fl_setpup_shortcut(HelpMenu,  9, scex(_("HM|oO#o#O")));
1623         fl_setpup_shortcut(HelpMenu, 10, scex(_("HM|eE#e#E")));
1624         fl_setpup_shortcut(HelpMenu, 11, scex(_("HM|Vv#v#V")));
1625
1626         fl_setpup_position(
1627                 men->_view->getForm()->x + ob->x,
1628                 men->_view->getForm()->y + ob->y + ob->h + 10);   
1629         int choice = fl_dopup(HelpMenu);
1630         XFlush(fl_display);
1631
1632         // set the pseudo menu-button back
1633         fl_set_object_boxtype(ob, FL_FLAT_BOX);
1634         fl_redraw_object(ob);
1635
1636         switch (choice) {
1637         case 1: case 2: case 3: case 4: case 5: 
1638         case 6: case 7: case 8:
1639                 ProhibitInput();
1640                 men->MenuDocu(doc_files[choice - 1]);
1641                 AllowInput();
1642                 break;
1643         case 9: ShowCopyright(); break;
1644         case 10: ShowCredits(); break;
1645         case 11:
1646                 ProhibitInput();
1647                 fl_show_message((string(_("LyX Version ")) + LYX_VERSION 
1648                                  + _(" of ") + LYX_RELEASE).c_str(),
1649                                 (_("Library directory: ")
1650                                  + MakeDisplayPath(system_lyxdir)).c_str(),
1651                                 (_("User directory: ") 
1652                                  + MakeDisplayPath(user_lyxdir)).c_str());
1653                 AllowInput();
1654                 break;
1655         }
1656         fl_freepup(HelpMenu);
1657 }
1658
1659
1660 void Menus::MenuDocu(string const & docname) 
1661 {
1662         string fname = i18nLibFileSearch("doc", docname, "lyx");
1663         if (fname.empty()) {
1664                 WriteAlert(_("Error!"),
1665                            _("Could not find requested Documentation file"),
1666                            fname);
1667                 return;
1668         }
1669         _view->getMiniBuffer()->Set(_("Opening help file"),
1670                                     MakeDisplayPath(fname), "...");
1671         currentView()->buffer(bufferlist.loadLyXFile(fname, false));
1672
1673         if (docname == "Reference")
1674                 _view->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
1675 }
1676
1677
1678 void Menus::handleBufferMenu(int choice)
1679 {
1680         currentView()->buffer(bufferlist.getBuffer(choice));
1681 }