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