X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmenus.C;h=fa9a78cde90e60a807fae8b2b57af930ebab3a05;hb=a858be7332e331e0244e4dba7b0931b6072ffd3d;hp=904cbe6112fc8efde1c134c9cbb1998a89429c13;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=lyx.git diff --git a/src/menus.C b/src/menus.C index 904cbe6112..fa9a78cde9 100644 --- a/src/menus.C +++ b/src/menus.C @@ -4,8 +4,8 @@ * * LyX, The Document Processor * - * Copyright (C) 1995 Matthias Ettrich - * Copyright (C) 1995-1998 The LyX Team. + * Copyright 1995 Matthias Ettrich + * Copyright 1995-1999 The LyX Team. * * ================================================== */ @@ -33,7 +33,7 @@ #include "lyx_main.h" #include "lyxfunc.h" #include "spellchecker.h" -#include "filetools.h" +#include "support/filetools.h" #include "LyXView.h" #include "lastfiles.h" #include "bufferlist.h" @@ -41,17 +41,11 @@ #include "minibuffer.h" #include "lyxscreen.h" #include "intl.h" -#include "error.h" +#include "debug.h" #include "lyxrc.h" #include "lyxtext.h" #include "gettext.h" -// $Id: menus.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $ - -#if !defined(lint) && !defined(WITH_WARNINGS) -static char vcid[] = "$Id: menus.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $"; -#endif /* lint */ - extern FD_form_screen *fd_form_screen; extern BufferList bufferlist; @@ -70,6 +64,54 @@ extern void ToggleFloat(); extern void AllFloats(char flag, char figmar); extern void LaTeXOptions(); +// A bunch of wrappers + +extern "C" void C_Menus_ShowFileMenu(FL_OBJECT *ob, long data) +{ + Menus::ShowFileMenu(ob, data); +} + +extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT *ob, long data) +{ + Menus::ShowFileMenu2(ob, data); +} + +extern "C" void C_Menus_ShowEditMenu(FL_OBJECT *ob, long data) +{ + Menus::ShowEditMenu(ob, data); +} + +extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT *ob, long data) +{ + Menus::ShowLayoutMenu(ob, data); +} + +extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT *ob, long data) +{ + Menus::ShowInsertMenu(ob, data); +} + +extern "C" void C_Menus_ShowMathMenu(FL_OBJECT *ob, long data) +{ + Menus::ShowMathMenu(ob, data); +} + +extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT *ob, long data) +{ + Menus::ShowOptionsMenu(ob, data); +} + +extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT *ob, long data) +{ + Menus::ShowBufferMenu(ob, data); +} + +extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT *ob, long data) +{ + Menus::ShowHelpMenu(ob, data); +} + + Menus::Menus(LyXView *view,int air) : _view(view) { @@ -110,7 +152,7 @@ void Menus::hideMenus() } -void Menus::openByName(LString const &menuName) +void Menus::openByName(string const &menuName) /* Opens the visible menu of given name, or simply does nothing when the name is not known. NOTE THE EXTREMELY STUPID IMPLEMENTATION! :-) There are probably hundred ways to do @@ -127,12 +169,14 @@ void Menus::openByName(LString const &menuName) else if (menuName == _("Options")) ShowOptionsMenu(menu_options, 0); else if (menuName == _("Documents")) ShowBufferMenu(menu_buffer, 0); else if (menuName == _("Help")) ShowHelpMenu(menu_help, 0); - else lyxerr.print("The menu '" + menuName + "' is not available."); + else lyxerr << "The menu '" << menuName + << "' is not available." << endl; } else { if (menuName == _("File")) ShowFileMenu2(menu_file2, 0); else if (menuName == _("Options")) ShowOptionsMenu(menu_options2, 0); else if (menuName == _("Help")) ShowHelpMenu(menu_help2, 0); - else lyxerr.print("The menu '" + menuName + "' is not available."); + else lyxerr << "The menu '" << menuName + << "' is not available." << endl; } } @@ -171,7 +215,7 @@ void Menus::create_menus(int air) mbheight,_("File")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#F")), 1); - fl_set_object_callback(obj,ShowFileMenu, 0); + fl_set_object_callback(obj,C_Menus_ShowFileMenu, 0); obj->u_ldata = (long)this; // Edit menu button @@ -185,7 +229,7 @@ void Menus::create_menus(int air) mbheight,_("Edit")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#E")),1); - fl_set_object_callback(obj,ShowEditMenu,0); + fl_set_object_callback(obj,C_Menus_ShowEditMenu,0); obj->u_ldata = (long) this; // Layout menu button @@ -199,7 +243,7 @@ void Menus::create_menus(int air) mbheight,_("Layout")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#L")), 1); - fl_set_object_callback(obj,ShowLayoutMenu,0); + fl_set_object_callback(obj,C_Menus_ShowLayoutMenu,0); obj->u_ldata = (long) this; // Insert menu button button @@ -213,7 +257,7 @@ void Menus::create_menus(int air) mbheight,_("Insert")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#I")), 1); - fl_set_object_callback(obj,ShowInsertMenu,0); + fl_set_object_callback(obj,C_Menus_ShowInsertMenu,0); obj->u_ldata = (long) this; // Math menu button @@ -227,7 +271,7 @@ void Menus::create_menus(int air) mbheight,_("Math")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#M")), 1); - fl_set_object_callback(obj,ShowMathMenu,0); + fl_set_object_callback(obj,C_Menus_ShowMathMenu,0); obj->u_ldata = (long) this; // Options menu button @@ -241,7 +285,7 @@ void Menus::create_menus(int air) mbheight,_("Options")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#O")), 1); - fl_set_object_callback(obj,ShowOptionsMenu, 0); + fl_set_object_callback(obj,C_Menus_ShowOptionsMenu, 0); obj->u_ldata = (long) this; // Documents menu button @@ -255,7 +299,7 @@ void Menus::create_menus(int air) mbheight,_("Documents")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#D")), 1); - fl_set_object_callback(obj,ShowBufferMenu,0); + fl_set_object_callback(obj,C_Menus_ShowBufferMenu,0); obj->u_ldata = (long) this; // Help menu button @@ -269,7 +313,7 @@ void Menus::create_menus(int air) mbheight,_("Help")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#H")), 1); - fl_set_object_callback(obj,ShowHelpMenu,0); + fl_set_object_callback(obj,C_Menus_ShowHelpMenu,0); obj->u_ldata = (long) this; fl_end_group(); @@ -302,7 +346,7 @@ void Menus::create_menus(int air) mbheight,_("File")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#F")), 1); - fl_set_object_callback(obj,ShowFileMenu2, 0); + fl_set_object_callback(obj,C_Menus_ShowFileMenu2, 0); obj->u_ldata = (long)this; // Options menu button @@ -316,7 +360,7 @@ void Menus::create_menus(int air) mbheight,_("Options")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#O")), 1); - fl_set_object_callback(obj,ShowOptionsMenu, 0); + fl_set_object_callback(obj,C_Menus_ShowOptionsMenu, 0); obj->u_ldata = (long) this; // Help menu button @@ -330,7 +374,7 @@ void Menus::create_menus(int air) mbheight,_("Help")); moffset += obj->w + air; fl_set_object_shortcut(obj, scex(_("MB|#H")), 1); - fl_set_object_callback(obj,ShowHelpMenu,0); + fl_set_object_callback(obj,C_Menus_ShowHelpMenu,0); obj->u_ldata = (long) this; fl_end_group(); @@ -352,6 +396,8 @@ void Menus::create_menus(int air) void Menus::ScreenOptions() { + static int ow = -1, oh; + // this is not very nice.... fl_set_input(fd_form_screen->input_roman, lyxrc->roman_font_name.c_str()); @@ -370,6 +416,11 @@ void Menus::ScreenOptions() fl_show_form(fd_form_screen->form_screen, FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, _("Screen Options")); + if (ow < 0) { + ow = fd_form_screen->form_screen->w; + oh = fd_form_screen->form_screen->h; + } + fl_set_form_minsize(fd_form_screen->form_screen, ow, oh); } } @@ -419,7 +470,7 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long) // remember to make this handle linuxdoc too. // and now docbook also. - int SubFileExport; + int SubFileExport = 0; if (!LinuxDoc && !DocBook) SubFileExport=fl_defpup(FL_ObjWin(ob), _("Export%t" @@ -427,7 +478,8 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long) "|as DVI...%x41" "|as PostScript...%x42" "|as Ascii Text...%x43" - "|Custom...%x44")); + "|as HTML...%x44" + "|Custom...%x45")); else if(LinuxDoc) SubFileExport=fl_defpup(FL_ObjWin(ob), _("Export%t" @@ -447,7 +499,10 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long) fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D"))); fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P"))); fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T"))); - fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|mM#m#M"))); + if (!LinuxDoc && !DocBook) { + fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H"))); + fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M"))); + } int FileMenu = fl_defpup(FL_ObjWin(ob), _("New..." @@ -529,16 +584,16 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long) // make the lastfiles menu LastFiles_Iter liter(*lastfiles); // :-) - LString filname; + string filname; int ii = 1; while( ii < 10 && !(filname = liter()).empty() ) { - LString tmp; - LString tmp2; - LString relbuf = MakeDisplayPath(filname,30); - tmp += ii; + string tmp; + string tmp2; + string relbuf = MakeDisplayPath(filname,30); + tmp += tostr(ii); tmp2 = tmp; tmp += ". " + relbuf; - tmp2 += LString('#') + ii; + tmp2 += string("#") + tostr(ii); fl_addtopup(FileMenu, tmp.c_str()); fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str()); ii++; @@ -596,7 +651,9 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long) break; case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii"); break; - case 44: tmpfunc->Dispatch(LFUN_EXPORT, "custom"); + case 44: tmpfunc->Dispatch(LFUN_EXPORT, "html"); + break; + case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom"); break; case 17: tmpfunc->Dispatch(LFUN_QUIT); break; // Lastfiles: @@ -667,16 +724,16 @@ void Menus::ShowFileMenu2(FL_OBJECT *ob, long) // make the lastfiles menu LastFiles_Iter liter(*lastfiles); // :-) - LString filname; + string filname; int ii = 1; while( ii < 10 && !(filname = liter()).empty() ) { - LString tmp; - LString tmp2; - LString relbuf = MakeDisplayPath(filname,30); - tmp += ii; + string tmp; + string tmp2; + string relbuf = MakeDisplayPath(filname,30); + tmp += tostr(ii); tmp2 = tmp; tmp += ". " + relbuf; - tmp2 += LString('#') + ii; + tmp2 += string("#") + tostr(ii); fl_addtopup(FileMenu, tmp.c_str()); fl_setpup_shortcut(FileMenu, 6 - 1 + ii, tmp2.c_str()); ii++; @@ -946,9 +1003,9 @@ void Menus::ShowEditMenu(FL_OBJECT *ob, long) fl_setpup_shortcut(EditMenu, 17, scex(_("EM|gG#g#G"))); // disable unavailable entries. - if(tmpbuffer->undostack.Top() == NULL) + if(tmpbuffer->undostack.Top() == 0) fl_setpup_mode(EditMenu, 1, FL_PUP_GREY); - if(tmpbuffer->redostack.Top() == NULL) + if(tmpbuffer->redostack.Top() == 0) fl_setpup_mode(EditMenu, 2, FL_PUP_GREY); if(lyxrc->isp_command == "none") fl_setpup_mode(EditMenu, 11, FL_PUP_GREY); @@ -1593,7 +1650,7 @@ void Menus::ShowHelpMenu(FL_OBJECT *ob, long) case 10: ShowCredits(); break; case 11: ProhibitInput(); - fl_show_message((LString(_("LyX Version ")) + LYX_VERSION + fl_show_message((string(_("LyX Version ")) + LYX_VERSION + _(" of ") + LYX_RELEASE).c_str(), (_("Library directory: ") + MakeDisplayPath(system_lyxdir)).c_str(), @@ -1606,9 +1663,9 @@ void Menus::ShowHelpMenu(FL_OBJECT *ob, long) } -void Menus::MenuDocu(LString const &docname) +void Menus::MenuDocu(string const &docname) { - LString fname = i18nLibFileSearch("doc", docname, "lyx"); + string fname = i18nLibFileSearch("doc", docname, "lyx"); _view->getMiniBuffer()->Set(_("Opening help file"), MakeDisplayPath(fname),"..."); currentView()->setBuffer(bufferlist.loadLyXFile(fname,false));