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