]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_gui.C
small changes to ButtonController usage
[lyx.git] / src / lyx_gui.C
index 13a86144e6010de841cb000016868f139936b5d9..c44f6a02e16a49fc20f426fb6c351f5d11d7e87f 100644 (file)
 #pragma implementation
 #endif
 
-#ifdef KDEGUI
-#    include <kapp.h>
-#endif
-
 #include <fcntl.h>
 #include "lyx_gui.h"
 #include FORMS_H_LOCATION
+#include "support/filetools.h"
 #include "combox.h"
 #include "lyx.h"
 #include "form1.h"
@@ -29,7 +26,7 @@
 #include "print_form.h"
 #include "tex-strings.h"
 #include "lyx_main.h"
-#include "latexoptions.h"
+#include "log_form.h"
 #include "debug.h"
 #include "version.h"
 #include "LyXView.h"
 #include "bufferlist.h"
 #include "language.h"
 #include "ColorHandler.h"
-
-#ifdef TWO_COLOR_ICONS
-#include "banner_bw.xbm"
-#else
-#include "banner.xpm"
-#endif
+#include "frontends/GUIRunTime.h"
 
 using std::endl;
 
@@ -64,11 +56,7 @@ FD_form_preamble * fd_form_preamble;
 FD_form_table * fd_form_table;
 FD_form_sendto * fd_form_sendto;
 FD_form_figure * fd_form_figure;
-FD_form_screen * fd_form_screen;
-FD_form_toc * fd_form_toc;
-FD_form_ref * fd_form_ref;
-FD_LaTeXOptions * fd_latex_options; // from latexoptions.h
-FD_LaTeXLog * fd_latex_log; // from latexoptions.h
+FD_LaTeXLog * fd_latex_log; // from log_form.h
 Combox * combo_language;
 Combox * combo_language2;
 
@@ -95,7 +83,8 @@ FL_resource res[] =
 };
 
 
-extern "C" int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
+extern "C"
+int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
 {
 //#warning Please see if you can trigger this!
        // emergency save
@@ -142,8 +131,11 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
        XSetErrorHandler(LyX_XErrHandler);
 
        // A width less than 590 pops up an awkward main window
-       if (width < 590) width = 590;
-
+       // The minimal values of width/height (590/400) are defined in
+       // src/lyx.C  
+        if (width < 590) width = 590;
+       if (height < 400) height = 400;
+       
        // If width is not set by geometry, check it against monitor width
        if ( !(geometryBitmask & 4) ) {
                Screen * scr = DefaultScreenOfDisplay(fl_get_display());
@@ -300,39 +292,26 @@ void LyXGUI::create_forms()
        //
 
        // the title form
-       if (lyxrc.show_banner) {
+       string banner_file = LibFileSearch("images", "banner", "xpm");
+       if (lyxrc.show_banner && !banner_file.empty()) {
                fd_form_title = create_form_form_title();
                fl_set_form_dblbuffer(fd_form_title->form_title, 1); // use dbl buffer
                fl_set_form_atclose(fd_form_title->form_title, CancelCloseBoxCB, 0);
                fl_addto_form(fd_form_title->form_title);
-#ifdef TWO_COLOR_ICONS
-               FL_OBJECT *obj = fl_add_bitmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
-               fl_set_bitmapbutton_data(obj, banner_bw_width,
-                                        banner_bw_height, banner_bw_bits);
-               fl_set_object_color(obj, FL_WHITE, FL_BLACK);
-#else
                FL_OBJECT *obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
-               fl_set_pixmapbutton_data(obj, const_cast<char **>(banner));
+               fl_set_pixmapbutton_file(obj, banner_file.c_str());
                
                fl_set_pixmapbutton_focus_outline(obj, 3);
-#endif
                fl_set_button_shortcut(obj, "^M ^[", 1);
                fl_set_object_boxtype(obj, FL_NO_BOX);
                fl_set_object_callback(obj, TimerCB, 0);
                
                obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION);
                fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-#ifdef TWO_COLOR_ICONS
-               fl_set_object_color(obj, FL_WHITE, FL_WHITE);
-               fl_set_object_lcol(obj, FL_BLACK);
-#else
-//       fl_set_object_color(obj, FL_WHITE, FL_WHITE);
-//       fl_set_object_lcol(obj, FL_BLACK);
                fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c);
                fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b);
                fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2);
                fl_set_object_lcol(obj, FL_FREE_COL3);
-#endif
                fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
                fl_set_object_lstyle(obj, FL_BOLD_STYLE);
                fl_end_form();
@@ -424,7 +403,7 @@ void LyXGUI::create_forms()
                combo_language->addto((*cit).second.lang().c_str());
                combo_language2->addto((*cit).second.lang().c_str());
        }
-       combo_language2->select_text("No change");
+       combo_language2->select_text(_("No change"));
 
        // not really necessary, but we can do it anyway.
        fl_addto_choice(fd_form_document->choice_fontsize, "default|10|11|12");
@@ -516,6 +495,7 @@ void LyXGUI::create_forms()
        fl_set_form_atclose(fd_form_preamble->form_preamble,
                            CancelCloseBoxCB, 0);
 
+#ifndef NEW_TABULAR
        // the table form
        fd_form_table = create_form_form_table();
        fl_set_form_atclose(fd_form_table->form_table, CancelCloseBoxCB, 0);
@@ -526,6 +506,7 @@ void LyXGUI::create_forms()
        fl_set_slider_precision(fd_form_table->slider_rows, 0);
        fl_set_slider_precision(fd_form_table->slider_columns, 0);
        lyxerr[Debug::INIT] << "Initializing form_table...done" << endl;
+#endif
 
        // the sendto form
        fd_form_sendto = create_form_form_sendto();
@@ -537,28 +518,6 @@ void LyXGUI::create_forms()
                            CancelCloseBoxCB, 0);
        fl_set_button(fd_form_figure->radio_postscript, 1);
 
-       // the screen form
-       fd_form_screen = create_form_form_screen();
-       fl_set_form_atclose(fd_form_screen->form_screen,
-                           CancelCloseBoxCB, 0);
-
-       // the toc form
-       fd_form_toc = create_form_form_toc();
-       fl_addto_choice(fd_form_toc->toctype,
-                       _(" TOC | LOF | LOT | LOA "));
-       fl_set_form_atclose(fd_form_toc->form_toc, CancelCloseBoxCB, 0);
-
-       // the ref form
-       fd_form_ref = create_form_form_ref();
-       fl_set_form_atclose(fd_form_ref->form_ref, CancelCloseBoxCB, 0);
-       fl_set_form_minsize(fd_form_ref->form_ref, fd_form_ref->form_ref->w,
-                           fd_form_ref->form_ref->h);
-
-       // the latex options form
-       fd_latex_options = create_form_LaTeXOptions();
-       fl_set_form_atclose(fd_latex_options->LaTeXOptions,
-                           CancelCloseBoxCB, 0);
-
        // the latex log form
        fd_latex_log = create_form_LaTeXLog();
        fl_set_form_atclose(fd_latex_log->LaTeXLog,
@@ -568,7 +527,7 @@ void LyXGUI::create_forms()
        int main_placement = FL_PLACE_CENTER | FL_FREE_SIZE;
        int title_placement = FL_PLACE_CENTER;
        // Did we get a valid position?
-       if (xpos>= 0 && ypos>= 0) {
+       if (xpos >= 0 && ypos >= 0) {
                lyxViews->setPosition(xpos, ypos);
                if (lyxrc.show_banner) {
                        // show the title form in the middle of the main form
@@ -596,24 +555,11 @@ void LyXGUI::create_forms()
 
 
 void LyXGUI::runTime()
-       /* This will usually be toolkit (GUI) specific. This is
-        * also usually the XEvent dispatcher of the GUI. */
 {
-       if (!gui)
-               return;
+       if (!gui) return;
 
-       // XForms specific
-       XEvent ev;
-
-       while (!finished) {
-#ifdef KDEGUI
-               kapp->processEvents();
-#endif
-               if (fl_check_forms() == FL_EVENT) {
-                       lyxerr << "LyX: This shouldn't happen..." << endl;
-                       fl_XNextEvent(&ev);
-               }
-       }
+       GUIRunTime grt;
+       grt.runTime();
 }
 
 
@@ -622,6 +568,7 @@ void LyXGUI::regBuf(Buffer * b)
        lyxViews->view()->buffer(b);
 }
 
+
 LyXView * LyXGUI::getLyXView() const
 {
        return lyxViews;