From 0ed115d608d8b2342c72b77ea8db4143bf16d7d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 16 Aug 2000 23:48:48 +0000 Subject: [PATCH] have a real runTime method for all frontends git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@975 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 19 +++++++++++ src/frontends/GUIRunTime.C | 8 ++++- src/frontends/GUIRunTime.h | 5 ++- src/frontends/gnome/GUIRunTime_pimpl.C | 21 ++++++++---- src/frontends/gnome/GUIRunTime_pimpl.h | 8 ++--- src/frontends/kde/GUIRunTime_pimpl.C | 22 +++++++++---- src/frontends/kde/GUIRunTime_pimpl.h | 14 +++----- src/frontends/xforms/GUIRunTime_pimpl.C | 29 ++++++++++------- src/frontends/xforms/GUIRunTime_pimpl.h | 14 +++----- src/lyx_gui.C | 27 ++++------------ src/text.C | 43 +++++++++---------------- 11 files changed, 112 insertions(+), 98 deletions(-) diff --git a/ChangeLog b/ChangeLog index bbd00a0e3d..699e4884c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2000-08-17 Lars Gullik Bjønnes + + * src/frontends/xforms/GUIRunTime_pimpl.C: constructor and + destructor. Don't definde if you don't need it + (processEvents): made static, non-blocking events processing for + xforms. + (runTime): static method. event loop for xforms + * similar as above for kde and gnome. + + * src/frontends/GUIRunTime.C (GUIRunTime): new Pimpl() is wrong + new Pimpl is correct + (runTime): new method calss the real frontends runtime func. + + * src/lyx_gui.C (runTime): change to use the GUIRunTime::runTime + +2000-08-16 Lars Gullik Bjønnes + + * src/lyx_gui.C (create_forms): fix the "No change" gettext missing + 2000-08-16 Juergen Vigna * src/lyx_gui.C (runTime): added GUII RunTime support. diff --git a/src/frontends/GUIRunTime.C b/src/frontends/GUIRunTime.C index 06a4a81571..e3e6d0a4f4 100644 --- a/src/frontends/GUIRunTime.C +++ b/src/frontends/GUIRunTime.C @@ -21,7 +21,7 @@ GUIRunTime::GUIRunTime() { - pimpl_ = new Pimpl(); + pimpl_ = new Pimpl; } @@ -35,3 +35,9 @@ void GUIRunTime::processEvents() { pimpl_->processEvents(); } + + +void GUIRunTime::runTime() +{ + pimpl_->runTime(); +} diff --git a/src/frontends/GUIRunTime.h b/src/frontends/GUIRunTime.h index 5d37094e64..fcf0289be1 100644 --- a/src/frontends/GUIRunTime.h +++ b/src/frontends/GUIRunTime.h @@ -30,11 +30,14 @@ public: ~GUIRunTime(); /// void processEvents(); - + /// + void runTime(); + struct Pimpl; friend struct Pimpl; private: + /// Pimpl * pimpl_; }; #endif diff --git a/src/frontends/gnome/GUIRunTime_pimpl.C b/src/frontends/gnome/GUIRunTime_pimpl.C index 3f132f8c0f..418b022df9 100644 --- a/src/frontends/gnome/GUIRunTime_pimpl.C +++ b/src/frontends/gnome/GUIRunTime_pimpl.C @@ -20,16 +20,23 @@ using std::endl; -GUIRunTime::Pimpl::Pimpl() -{ -} - -GUIRunTime::Pimpl::~Pimpl() -{ -} +extern bool finised; void GUIRunTime::Pimpl::processEvents() { while(Gnome::Main::instance()->events_pending()) Gnome::Main::instance()->iteration(FALSE); } + + +void GUIRunTime::Pimpl::runTime() +{ + XEvent ev; + while (!finished) { + Pimpl::processEvents(); + if (fl_check_forms() == FL_EVENT) { + lyxerr << "LyX: This shouldn't happen..." << endl; + fl_XNextEvent(&ev); + } + } +} diff --git a/src/frontends/gnome/GUIRunTime_pimpl.h b/src/frontends/gnome/GUIRunTime_pimpl.h index fc9fdd5427..46b976d22d 100644 --- a/src/frontends/gnome/GUIRunTime_pimpl.h +++ b/src/frontends/gnome/GUIRunTime_pimpl.h @@ -25,12 +25,8 @@ struct GUIRunTime::Pimpl { public: /// - Pimpl(); + static void processEvents(); /// - ~Pimpl(); - /// - void processEvents(); - -private: + static void runTime(); }; #endif diff --git a/src/frontends/kde/GUIRunTime_pimpl.C b/src/frontends/kde/GUIRunTime_pimpl.C index 92ad82643c..26b251337b 100644 --- a/src/frontends/kde/GUIRunTime_pimpl.C +++ b/src/frontends/kde/GUIRunTime_pimpl.C @@ -20,15 +20,25 @@ using std::endl; -GUIRunTime::Pimpl::Pimpl() -{ -} +extern bool finished; -GUIRunTime::Pimpl::~Pimpl() -{ -} void GUIRunTime::Pimpl::processEvents() { kapp->processEvents(); } + + +void GUIRunTime::Pimpl::runTime() +{ + // We still use xforms event handler as te main one... + XEvent ev; + while (!finished) { + Pimpl::processEvents(); + if (fl_check_forms() == FL_EVENT) { + lyxerr << "LyX: This shouldn't happen..." << endl; + fl_XNextEvent(&ev); + } + } +} + diff --git a/src/frontends/kde/GUIRunTime_pimpl.h b/src/frontends/kde/GUIRunTime_pimpl.h index fc9fdd5427..3d6d0a296a 100644 --- a/src/frontends/kde/GUIRunTime_pimpl.h +++ b/src/frontends/kde/GUIRunTime_pimpl.h @@ -19,18 +19,14 @@ #include "frontends/GUIRunTime.h" -/* - * The GUI interface for runtime GUI stuff. - */ +/** + The GUI interface for runtime GUI stuff. +*/ struct GUIRunTime::Pimpl { public: /// - Pimpl(); + static void processEvents(); /// - ~Pimpl(); - /// - void processEvents(); - -private: + static void runTime(); }; #endif diff --git a/src/frontends/xforms/GUIRunTime_pimpl.C b/src/frontends/xforms/GUIRunTime_pimpl.C index c35be978ea..71911e8263 100644 --- a/src/frontends/xforms/GUIRunTime_pimpl.C +++ b/src/frontends/xforms/GUIRunTime_pimpl.C @@ -19,25 +19,30 @@ #include "GUIRunTime_pimpl.h" #include "debug.h" -GUIRunTime::Pimpl::Pimpl() -{ -} +using std::endl; + +extern bool finished; -GUIRunTime::Pimpl::~Pimpl() -{ -} void GUIRunTime::Pimpl::processEvents() { -// this is disabled for now as we still need this ALWAYS in lyx_gui -// and if we enable this here we would do it 2 times well why not it -// doesn't really matter, does it? (Jug) -#if 1 XEvent ev; - if (fl_check_forms() == FL_EVENT) { + if (fl_do_forms() == FL_EVENT) { lyxerr << "LyX: This shouldn't happen..." << endl; fl_XNextEvent(&ev); } -#endif } + + +void GUIRunTime::Pimpl::runTime() +{ + XEvent ev; + while (!finished) { + if (fl_check_forms() == FL_EVENT) { + lyxerr << "LyX: This shouldn't appen..." << endl; + fl_XNextEvent(&ev); + } + } +} + diff --git a/src/frontends/xforms/GUIRunTime_pimpl.h b/src/frontends/xforms/GUIRunTime_pimpl.h index fc9fdd5427..3d6d0a296a 100644 --- a/src/frontends/xforms/GUIRunTime_pimpl.h +++ b/src/frontends/xforms/GUIRunTime_pimpl.h @@ -19,18 +19,14 @@ #include "frontends/GUIRunTime.h" -/* - * The GUI interface for runtime GUI stuff. - */ +/** + The GUI interface for runtime GUI stuff. +*/ struct GUIRunTime::Pimpl { public: /// - Pimpl(); + static void processEvents(); /// - ~Pimpl(); - /// - void processEvents(); - -private: + static void runTime(); }; #endif diff --git a/src/lyx_gui.C b/src/lyx_gui.C index 7b83930f41..c44f6a02e1 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -83,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 @@ -402,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"); @@ -526,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 @@ -554,26 +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; GUIRunTime grt; - - // XForms specific - XEvent ev; - - while (!finished) { - grt.processEvents(); - // for now we have to leave this here then if the GUII is - // completed this obviously has to be removed! (Jug) - if (fl_check_forms() == FL_EVENT) { - lyxerr << "LyX: This shouldn't happen..." << endl; - fl_XNextEvent(&ev); - } - } + grt.runTime(); } @@ -582,6 +568,7 @@ void LyXGUI::regBuf(Buffer * b) lyxViews->view()->buffer(b); } + LyXView * LyXGUI::getLyXView() const { return lyxViews; diff --git a/src/text.C b/src/text.C index a18b7b6a10..0783fe9753 100644 --- a/src/text.C +++ b/src/text.C @@ -3899,9 +3899,10 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, LyXParagraph::size_type last = RowLastPrintable(row_ptr); LyXParagraph::size_type vpos, pos; - float x, tmpx; - int y_top, y_bottom; - float fill_separator, fill_hfill, fill_label_hfill; + float x; + float tmpx; + int y_top; + int y_bottom; LyXFont font(LyXFont::ALL_SANE); int maxdesc; @@ -3910,6 +3911,10 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, << row_ptr->height() << endl; return; } + + float fill_separator; + float fill_hfill; + float fill_label_hfill; PrepareToPrint(bview, row_ptr, x, fill_separator, fill_hfill, fill_label_hfill); @@ -3918,44 +3923,32 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, x += x_offset; // clear the area where we want to paint/print - int ww; - ww = bview->workWidth(); + int ww = bview->workWidth(); bool clear_area = true; Inset * inset = 0; if ((last == row_ptr->pos()) && (row_ptr->par()->GetChar(row_ptr->pos()) == LyXParagraph::META_INSET) && - (inset=row_ptr->par()->GetInset(row_ptr->pos()))) - { + (inset = row_ptr->par()->GetInset(row_ptr->pos()))) { clear_area = inset->doClearArea(); } if (cleared) { // we don't need to clear it's already done!!! clear_area = true; } else if (clear_area) { - int w; - if (inset_owner) - w = inset_owner->width(bview, font); - else - w = ww; + int w = (inset_owner ? inset_owner->width(bview, font) : ww); pain.fillRectangle(x_offset, y_offset, w, row_ptr->height()); } else if (inset != 0) { int h = row_ptr->baseline() - inset->ascent(bview, font); if (h > 0) { - int w; - if (inset_owner) - w = inset_owner->width(bview, font); - else - w = ww; + int w = (inset_owner ? + inset_owner->width(bview, font) : ww); pain.fillRectangle(x_offset, y_offset, w, h); } h += inset->ascent(bview, font) + inset->descent(bview, font); if ((row_ptr->height() - h) > 0) { - int w; - if (inset_owner) - w = inset_owner->width(bview, font); - else - w = ww; + int w = (inset_owner ? + inset_owner->width(bview, font) : ww); pain.fillRectangle(x_offset,y_offset+h, w, row_ptr->height()-h); } if (!inset_owner && !inset->display() && !inset->needFullRow()) @@ -3966,11 +3959,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, } if (selection) { - int w; - if (inset_owner) - w = inset_owner->width(bview, font); - else - w = ww; + int w = (inset_owner ? inset_owner->width(bview, font) : ww); /* selection code */ if (bidi_same_direction) { if (sel_start_cursor.row() == row_ptr &&