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