]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_gui.C
citation patch from Angus
[lyx.git] / src / lyx_gui.C
index 72399342ced842f4e4356c94701acf0b420faf6b..d9385d076bd4e1161cc6bb93c48fa2117188ccc9 100644 (file)
 #pragma implementation
 #endif
 
-#ifdef KDEGUI
-#    include <kapp.h>
-#endif
-
-#ifdef GTKGUI
-#    include <gnome--/main.h>
-#endif
-
 #include <fcntl.h>
 #include "lyx_gui.h"
 #include FORMS_H_LOCATION
@@ -47,6 +39,7 @@
 #include "bufferlist.h"
 #include "language.h"
 #include "ColorHandler.h"
+#include "frontends/GUIRunTime.h"
 
 using std::endl;
 
@@ -90,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
@@ -108,7 +102,7 @@ extern "C" int LyX_XErrHandler(Display * display, XErrorEvent * xeev)
 
 
 LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
-  : _owner(owner), lyxViews(0)
+       : _owner(owner), lyxViews(0)
 {
        gui = GUI;
        if (!gui)
@@ -120,12 +114,12 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
        fl_initialize(argc, argv, "LyX", cmdopt, num_res);
        fl_get_app_resources(res, num_res);
 
-       static const int geometryBitmask = XParseGeometry( geometry,
-                                                           &xpos,
-                                                           &ypos,
-                                                           (unsigned int *) &width,
-                                                           (unsigned int *) &height
-                                                         );
+       static const int geometryBitmask =
+               XParseGeometry( geometry,
+                               &xpos,
+                               &ypos,
+                               reinterpret_cast<unsigned int *>(&width),
+                               reinterpret_cast<unsigned int *>(&height));
 
        Display * display = fl_get_display();
        if (!display) {
@@ -380,6 +374,16 @@ void LyXGUI::create_forms()
        fl_end_form();
        lyxerr[Debug::INIT] << "Initializing form_character...done" << endl;
 
+       // build up the combox entries
+       combo_language2->addto(_("No change"));
+       combo_language2->addto(_("Reset"));
+       for(Languages::const_iterator cit = languages.begin();
+           cit != languages.end(); ++cit) {
+               combo_language2->addto((*cit).second.lang().c_str());
+       }
+       combo_language2->select_text(_("No change"));
+
+#ifdef USE_OLD_DOCUMENT_LAYOUT
        // the document form
        fd_form_document = create_form_form_document();
        fl_set_form_atclose(fd_form_document->form_document,
@@ -402,14 +406,10 @@ void LyXGUI::create_forms()
 
        // "default" is not part of the languages array any more.
        combo_language->addto("default");
-       combo_language2->addto(_("No change"));
-       combo_language2->addto(_("Reset"));
        for(Languages::const_iterator cit = languages.begin();
            cit != languages.end(); ++cit) {
                combo_language->addto((*cit).second.lang().c_str());
-               combo_language2->addto((*cit).second.lang().c_str());
        }
-       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");
@@ -469,7 +469,9 @@ void LyXGUI::create_forms()
        fl_set_input_return(fd_form_paper->input_foot_skip,
                            FL_RETURN_ALWAYS);
        lyxerr[Debug::INIT] << "Initializing form_paper...done" << endl;
+#endif
 
+#ifndef NEW_TABULAR
         // the table_options form
        fd_form_table_options = create_form_form_table_options();
        fl_set_form_atclose(fd_form_table_options->form_table_options,
@@ -486,7 +488,9 @@ void LyXGUI::create_forms()
        fl_set_input_return(fd_form_table_extra->input_special_multialign,
                            FL_RETURN_ALWAYS);
        lyxerr[Debug::INIT] << "Initializing form_table_extra...done" << endl;
+#endif
 
+#ifdef USE_OLD_DOCUMENT_LAYOUT
        // the quotes form
        fd_form_quotes = create_form_form_quotes();
        fl_set_form_atclose(fd_form_quotes->form_quotes,
@@ -495,6 +499,7 @@ void LyXGUI::create_forms()
        // Maybe if people use a font other than latin1... (JMarc)
        fl_addto_choice(fd_form_quotes->choice_quotes_language,
                        _(" ``text'' | ''text'' | ,,text`` | ,,text'' | «text» | »text« "));
+#endif
 
        // the preamble form
        fd_form_preamble = create_form_form_preamble();
@@ -533,7 +538,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
@@ -561,28 +566,10 @@ 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;
-
-       // XForms specific
-       XEvent ev;
+       if (!gui) return;
 
-       while (!finished) {
-#ifdef KDEGUI
-               kapp->processEvents();
-#endif
-#ifdef GTKGUI
-               Gnome::Main::instance()->iteration(FALSE);
-#endif
-               
-               if (fl_check_forms() == FL_EVENT) {
-                       lyxerr << "LyX: This shouldn't happen..." << endl;
-                       fl_XNextEvent(&ev);
-               }
-       }
+       GUIRunTime::runTime();
 }
 
 
@@ -591,6 +578,7 @@ void LyXGUI::regBuf(Buffer * b)
        lyxViews->view()->buffer(b);
 }
 
+
 LyXView * LyXGUI::getLyXView() const
 {
        return lyxViews;