From f490ae76abc44001313dfe65e0729b964ea4f76b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 7 Feb 2001 16:44:49 +0000 Subject: [PATCH] the Timeout patch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1456 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 1 + src/BufferView_pimpl.C | 138 ++++++++++----------------- src/BufferView_pimpl.h | 2 +- src/ChangeLog | 10 ++ src/LyXView.h | 2 +- src/Makefile.am | 2 - src/Timeout.C | 95 ------------------ src/Timeout.h | 69 -------------- src/frontends/ButtonPolicies.C | 19 ---- src/frontends/ButtonPolicies.h | 26 ----- src/frontends/ChangeLog | 10 ++ src/frontends/Makefile.am | 2 + src/frontends/Timeout.C | 76 +++++++++++++++ src/frontends/Timeout.h | 69 ++++++++++++++ src/frontends/kde/ChangeLog | 6 ++ src/frontends/kde/Makefile.am | 2 + src/frontends/kde/Timeout_pimpl.C | 51 ++++++++++ src/frontends/kde/Timeout_pimpl.h | 50 ++++++++++ src/frontends/xforms/ChangeLog | 6 ++ src/frontends/xforms/FormBrowser.C | 2 +- src/frontends/xforms/Makefile.am | 2 + src/frontends/xforms/Timeout_pimpl.C | 60 ++++++++++++ src/frontends/xforms/Timeout_pimpl.h | 44 +++++++++ src/minibuffer.h | 2 +- 24 files changed, 441 insertions(+), 305 deletions(-) delete mode 100644 src/Timeout.C delete mode 100644 src/Timeout.h create mode 100644 src/frontends/Timeout.C create mode 100644 src/frontends/Timeout.h create mode 100644 src/frontends/kde/Timeout_pimpl.C create mode 100644 src/frontends/kde/Timeout_pimpl.h create mode 100644 src/frontends/xforms/Timeout_pimpl.C create mode 100644 src/frontends/xforms/Timeout_pimpl.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 850b606346..debe726c64 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,6 +12,7 @@ src/credits_form.C src/CutAndPaste.C src/debug.C src/exporter.C +src/ext_l10n.h src/filedlg.C src/FontLoader.C src/form1.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 139665ed90..5162dc6110 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -33,7 +33,6 @@ using SigC::slot; using std::pair; using std::endl; -using std::vector; using std::make_pair; using std::min; @@ -207,7 +206,6 @@ void BufferView::Pimpl::resize(int xpos, int ypos, int width, int height) void BufferView::Pimpl::resize() { - // This will resize the buffer. (Asger) if (buffer_) resizeCurrentBuffer(); } @@ -222,8 +220,8 @@ void BufferView::Pimpl::redraw() bool BufferView::Pimpl::fitCursor(LyXText * text) { - Assert(screen_); // it is a programming error to call fitCursor - // without a valid screen. + Assert(screen_); + bool ret = screen_->FitCursor(text, bv_); if (ret) updateScrollbar(); @@ -393,7 +391,7 @@ void BufferView::Pimpl::updateScrollbar() // Callback for scrollbar slider void BufferView::Pimpl::scrollCB(double value) { - if (buffer_ == 0) return; + if (!buffer_) return; current_scrollbar_value = long(value); if (current_scrollbar_value < 0) @@ -404,30 +402,29 @@ void BufferView::Pimpl::scrollCB(double value) screen_->Draw(bv_->text, bv_, current_scrollbar_value); - if (lyxrc.cursor_follows_scrollbar) { - LyXText * vbt = bv_->text; - int height = vbt->DefaultHeight(); - - if (vbt->cursor.y() < static_cast((bv_->text->first + height))) { - vbt->SetCursorFromCoordinates(bv_, 0, - bv_->text->first + - height); - } else if (vbt->cursor.y() > - static_cast((bv_->text->first+workarea_->height()-height))) - { - vbt->SetCursorFromCoordinates(bv_, 0, - bv_->text->first + - workarea_->height() - - height); - } + if (!lyxrc.cursor_follows_scrollbar) { + waitForX(); + return; } + + LyXText * vbt = bv_->text; + + int const height = vbt->DefaultHeight(); + int const first = static_cast((bv_->text->first + height)); + int const last = static_cast((bv_->text->first + workarea_->height() - height)); + + if (vbt->cursor.y() < first) + vbt->SetCursorFromCoordinates(bv_, 0, first); + else if (vbt->cursor.y() > last) + vbt->SetCursorFromCoordinates(bv_, 0, last); + waitForX(); } int BufferView::Pimpl::scrollUp(long time) { - if (buffer_ == 0) return 0; + if (!buffer_) return 0; if (!screen_) return 0; double value = workarea_->getScrollbarValue(); @@ -455,7 +452,7 @@ int BufferView::Pimpl::scrollUp(long time) int BufferView::Pimpl::scrollDown(long time) { - if (buffer_ == 0) return 0; + if (!buffer_) return 0; if (!screen_) return 0; double value= workarea_->getScrollbarValue(); @@ -495,7 +492,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state) if (!(state & Button1MotionMask)) return; - if (buffer_ == 0 || !screen_) return; + if (!buffer_ || !screen_) return; // Check for inset locking if (bv_->theLockingInset()) { @@ -514,22 +511,22 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state) return; } - /* The selection possible is needed, that only motion events are + /* The test for not selection possible is needed, that only motion events are * used, where the bottom press event was on the drawing area too */ - if (selection_possible) { - screen_->HideCursor(); + if (!selection_possible) + return; + + screen_->HideCursor(); - bv_->text->SetCursorFromCoordinates(bv_, x, y + bv_->text->first); + bv_->text->SetCursorFromCoordinates(bv_, x, y + bv_->text->first); - if (!bv_->text->selection) - update(BufferView::UPDATE); // Maybe an empty line was deleted + if (!bv_->text->selection) + update(BufferView::UPDATE); // Maybe an empty line was deleted - bv_->text->SetSelection(); - screen_->ToggleToggle(bv_->text, bv_); - fitCursor(bv_->text); - screen_->ShowCursor(bv_->text, bv_); - } - return; + bv_->text->SetSelection(); + screen_->ToggleToggle(bv_->text, bv_); + fitCursor(bv_->text); + screen_->ShowCursor(bv_->text, bv_); } @@ -540,7 +537,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, last_click_x = -1; last_click_y = -1; - if (buffer_ == 0 || !screen_) return; + if (!buffer_ || !screen_) return; Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos, button); @@ -694,7 +691,7 @@ void BufferView::Pimpl::leaveView() void BufferView::Pimpl::workAreaButtonRelease(int x, int y, unsigned int button) { - if (buffer_ == 0 || screen_ == 0) return; + if (!buffer_ || !screen_) return; // If we hit an inset, we have the inset coordinates in these // and inset_hit points to the inset. If we do not hit an @@ -720,7 +717,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, owner_->showState(); // Did we hit an editable inset? - if (inset_hit != 0) { + if (inset_hit) { // Inset like error, notes and figures selection_possible = false; @@ -916,12 +913,6 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y, void BufferView::Pimpl::workAreaExpose() { - // this is a hack to ensure that we only call this through - // BufferView::redraw(). - //if (!lgb_hack) { - // redraw(); - //} - static int work_area_width = 0; static unsigned int work_area_height = 0; @@ -1048,50 +1039,22 @@ void BufferView::Pimpl::cursorToggle() // Quite a nice place for asyncron Inset updating, isn't it? // Actually no! This is run even if no buffer exist... so (Lgb) if (!buffer_) { - goto set_timer_and_return; - } - - // NOTE: - // On my quest to solve the gs render hangups I am now - // disabling the SIGHUP completely, and will do a wait - // now and then instead. If the guess that xforms somehow - // destroys something is true, this is likely (hopefully) - // to solve the problem...at least I hope so. Lgb - - // ...Ok this seems to work...at least it does not make things - // worse so far. However I still see gs processes that hangs. - // I would really like to know _why_ they are hanging. Anyway - // the solution without the SIGCHLD handler seems to be easier - // to debug. - - // When attaching gdb to a a running gs that hangs it shows - // that it is waiting for input(?) Is it possible for us to - // provide that input somehow? Or figure what it is expecing - // to read? - - // One solution is to, after some time, look if there are some - // old gs processes still running and if there are: kill them - // and re render. - - // Another solution is to provide the user an option to rerender - // a picture. This would, for the picture in question, check if - // there is a gs running for it, if so kill it, and start a new - // rendering process. - - // these comments posted to lyx@via - { - int status = 1; - int pid = waitpid(static_cast(0), &status, WNOHANG); - if (pid == -1) // error find out what is wrong - ; // ignore it for now. - else if (pid > 0) - sigchldhandler(pid, &status); + cursor_timeout.restart(); + return; } + + int status = 1; + int pid = waitpid(static_cast(0), &status, WNOHANG); + if (pid == -1) // error find out what is wrong + ; // ignore it for now. + else if (pid > 0) + sigchldhandler(pid, &status); updatelist.update(bv_); if (!screen_) { - goto set_timer_and_return; + cursor_timeout.restart(); + return; } if (!bv_->theLockingInset()) { @@ -1100,9 +1063,7 @@ void BufferView::Pimpl::cursorToggle() bv_->theLockingInset()->ToggleInsetCursor(bv_); } - set_timer_and_return: cursor_timeout.restart(); - return; } @@ -1168,9 +1129,6 @@ void BufferView::Pimpl::beforeChange() { toggleSelection(); bv_->text->ClearSelection(); - - // CHECK - //owner_->update_timeout.stop(); } @@ -1338,7 +1296,7 @@ void BufferView::Pimpl::center() void BufferView::Pimpl::pasteClipboard(bool asPara) { - if (buffer_ == 0) return; + if (!buffer_) return; screen_->HideCursor(); bv_->beforeChange(); diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index d51bf0f129..c6cc70a2d4 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -5,7 +5,7 @@ #include "BufferView.h" #include "UpdateInset.h" -#include "Timeout.h" +#include "frontends/Timeout.h" #ifdef __GNUG__ #pragma interface diff --git a/src/ChangeLog b/src/ChangeLog index 48caa0ff21..b6cb3d8c40 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2001-02-07 John Levon + + * BufferView_pimpl.C: housekeeping + * BufferView_pimpl.h: + * LyXView.h: + * Makefile.am: + * Timeout.C: + * Timeout.h: + * minibuffer.h: move Timeout GUI-I + 2001-02-07 Dekel Tsur * lyxrc.C (read): Update converters data-structures. diff --git a/src/LyXView.h b/src/LyXView.h index 8017453af5..e4d4746b2b 100644 --- a/src/LyXView.h +++ b/src/LyXView.h @@ -20,7 +20,7 @@ #include FORMS_H_LOCATION #include "LString.h" -#include "Timeout.h" +#include "frontends/Timeout.h" #include #include "layout.h" diff --git a/src/Makefile.am b/src/Makefile.am index 1d0c8447fe..25c670dcb7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -73,8 +73,6 @@ lyx_SOURCES = \ Spacing.h \ TextCache.C \ TextCache.h \ - Timeout.C \ - Timeout.h \ ToolbarDefaults.C \ ToolbarDefaults.h \ UpdateInset.C \ diff --git a/src/Timeout.C b/src/Timeout.C deleted file mode 100644 index 5bce1c404b..0000000000 --- a/src/Timeout.C +++ /dev/null @@ -1,95 +0,0 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2000 The LyX Team. - * - * ====================================================== */ - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#include FORMS_H_LOCATION - -#include "Timeout.h" -#include "debug.h" - -using std::endl; - -extern "C" { - static - void C_intern_timeout_cb(int, void * data) - { - Timeout * to = static_cast(data); - to->emit(); - } -} - - -Timeout::Timeout() - : type(ONETIME), timeout_ms(0), timeout_id(-1) -{} - - -Timeout::Timeout(unsigned int msec, Type t) - : type(t), timeout_ms(msec), timeout_id(-1) -{} - - -Timeout::~Timeout() -{ - stop(); -} - - -void Timeout::restart() -{ - stop(); - start(); -} - - -void Timeout::start() -{ - if (timeout_id != -1) - lyxerr << "Timeout::start: already running!" << endl; - timeout_id = fl_add_timeout(timeout_ms, - C_intern_timeout_cb, this); -} - - -void Timeout::stop() -{ - if (timeout_id != -1) { - fl_remove_timeout(timeout_id); - timeout_id = -1; - } -} - - -void Timeout::emit() -{ - timeout_id = -1; - timeout.emit(); - if (type == CONTINOUS) - start(); -} - - -Timeout & Timeout::setType(Type t) -{ - type = t; - return *this; -} - - -Timeout & Timeout::setTimeout(unsigned int msec) -{ - timeout_ms = msec; - return *this; -} diff --git a/src/Timeout.h b/src/Timeout.h deleted file mode 100644 index 9cecc49d7a..0000000000 --- a/src/Timeout.h +++ /dev/null @@ -1,69 +0,0 @@ -// -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2000 The LyX Team. - * - * ====================================================== */ - -#ifndef TIMEOUT_H -#define TIMEOUT_H - -#include - -#ifdef __GNUG__ -#pragma interface -#endif - -#include - -#ifdef SIGC_CXX_NAMESPACES -using SigC::Signal0; -#endif - -/** This class executes the callback when the timeout expires. - This class currently uses a regular callback, later it will use - signals and slots to provide the same. -*/ -class Timeout { -public: - /// - enum Type { - /// - ONETIME, - /// - CONTINOUS - }; - /// - Timeout(); - /// - Timeout(unsigned int msec, Type = ONETIME); - /// - ~Timeout(); - /// - void start(); - /// - void stop(); - /// - void restart(); - /// - Signal0 timeout; - /// - void emit(); - /// - Timeout & setType(Type t); - /// - Timeout & setTimeout(unsigned int msec); -private: - /// - Type type; - /// - unsigned int timeout_ms; - /// - int timeout_id; -}; - -#endif diff --git a/src/frontends/ButtonPolicies.C b/src/frontends/ButtonPolicies.C index 3598dcc206..bde5f93816 100644 --- a/src/frontends/ButtonPolicies.C +++ b/src/frontends/ButtonPolicies.C @@ -118,25 +118,6 @@ void PreferencesPolicy::input(SMInput input) } -/*-------------------------------OkViewPolicy------------------------------*/ - - -OkViewPolicy::OkViewPolicy() - : state_(INITIAL), - outputs_(INVALID + 1, ButtonPolicy::ALL_BUTTONS), - state_machine_(INVALID + 1, - StateArray(int(SMI_TOTAL), ButtonPolicy::BOGUS)) -{ -} - - - -void OkViewPolicy::input(SMInput) -{ - state_ = VALID; -} - - /*-------------------------------OkCancelPolicy------------------------------*/ diff --git a/src/frontends/ButtonPolicies.h b/src/frontends/ButtonPolicies.h index 56755f433b..2bbcbb4cd4 100644 --- a/src/frontends/ButtonPolicies.h +++ b/src/frontends/ButtonPolicies.h @@ -216,32 +216,6 @@ private: StateMachine state_machine_; }; -/** OK button policy for dialogs that can't mutate the document, - and are always valid - */ -class OkViewPolicy : public ButtonPolicy { -public: - /// - OkViewPolicy(); - /// Trigger a transition with this input - virtual void input(SMInput); - /// activation status - virtual bool buttonStatus(Button button) const { - return button & outputs_[state_]; - } - /// are we in a read-only state ? - virtual bool isReadOnly() const { - return false; - } -private: - /// current state - State state_; - /// which buttons are active - StateOutputs outputs_; - /// - StateMachine state_machine_; -}; - /** Ok and Cancel buttons for dialogs where read-only operation is blocked. The state machine design for this policy allows changes to occur within the dialog while a file is read-only -- the okay button is disabled until diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index d096f4ed6c..5ee907d7ba 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,13 @@ +2001-02-07 John Levon + + * ButtonPolicies.C: + * ButtonPolicies.h: and remove OkViewPolicy, + it's a duplicate of IgnorantPolicy + + * Makefile.am: + * Timeout.C: + * Timeout.h: add GUI-I Timeout class + 2001-02-06 John Levon * ButtonPolicies.C: diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index 01b6473711..841350c66c 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -20,6 +20,8 @@ libfrontends_la_SOURCES=\ Liason.h \ Menubar.C \ Menubar.h \ + Timeout.C \ + Timeout.h \ Toolbar.C \ Toolbar.h diff --git a/src/frontends/Timeout.C b/src/frontends/Timeout.C new file mode 100644 index 0000000000..960e834ddf --- /dev/null +++ b/src/frontends/Timeout.C @@ -0,0 +1,76 @@ +/** + * \file Timeout.C + * Copyright 2001 LyX Team + * Read COPYING + * + * \author Lars Gullik Bjønnes + * \author John Levon + */ +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#include "Timeout.h" +#include "debug.h" + +#include "Timeout_pimpl.h" + +Timeout::Timeout() + : type(ONETIME), timeout_ms(0) +{ + pimpl_ = new Pimpl(this); +} + + +Timeout::Timeout(unsigned int msec, Type t) + : type(t), timeout_ms(msec) +{ + pimpl_ = new Pimpl(this); +} + + +Timeout::~Timeout() +{ + pimpl_->stop(); + delete pimpl_; +} + + +void Timeout::start() +{ + pimpl_->start(); +} + +void Timeout::stop() +{ + pimpl_->stop(); +} + +void Timeout::restart() +{ + pimpl_->stop(); + pimpl_->start(); +} + +void Timeout::emit() +{ + pimpl_->reset(); + timeout.emit(); + if (type == CONTINUOUS) + pimpl_->start(); +} + +Timeout & Timeout::setType(Type t) +{ + type = t; + return * this; +} + + +Timeout & Timeout::setTimeout(unsigned int msec) +{ + timeout_ms = msec; + return * this; +} diff --git a/src/frontends/Timeout.h b/src/frontends/Timeout.h new file mode 100644 index 0000000000..717096f83e --- /dev/null +++ b/src/frontends/Timeout.h @@ -0,0 +1,69 @@ +/** + * \file Timeout.h + * Copyright 2001 LyX Team + * Read COPYING + * + * \author Lars Gullik Bjønnes + * \author John Levon + */ +#ifndef TIMEOUT_H +#define TIMEOUT_H + +#include + +#ifdef __GNUG__ +#pragma interface +#endif + +#include + +#ifdef SIGC_CXX_NAMESPACES +using SigC::Signal0; +#endif + +/** + * This class executes the callback when the timeout expires. + */ +class Timeout { +public: + /// + enum Type { + /// one-shot timer + ONETIME, + /// repeating + CONTINUOUS + }; + /// + Timeout(); + /// + Timeout(unsigned int msec, Type = ONETIME); + /// + ~Timeout(); + /// start the timer + void start(); + /// stop the timer + void stop(); + /// restart the timer + void restart(); + /// signal emitted on timer expiry + Signal0 timeout; + /// emit the signal + void emit(); + /// set the timer type + Timeout & setType(Type t); + /// set the timeout value + Timeout & setTimeout(unsigned int msec); + +private: + struct Pimpl; + friend struct Pimpl; + /// implementation + Pimpl * pimpl_; + + /// one-shot or repeating + Type type; + /// timeout value in milliseconds + unsigned int timeout_ms; +}; + +#endif diff --git a/src/frontends/kde/ChangeLog b/src/frontends/kde/ChangeLog index 6634b776d5..478e2db474 100644 --- a/src/frontends/kde/ChangeLog +++ b/src/frontends/kde/ChangeLog @@ -1,3 +1,9 @@ +2001-02-07 John Levon + + * Timeout_pimpl.h: + * Timeout_pimpl.C: + * Makefile.am: add Timeout_pimpl + 2001-01-26 Dekel Tsur * dlg/lengthentry.C: Move the '#include ' to the top diff --git a/src/frontends/kde/Makefile.am b/src/frontends/kde/Makefile.am index 7c88997fff..c1870e8568 100644 --- a/src/frontends/kde/Makefile.am +++ b/src/frontends/kde/Makefile.am @@ -40,6 +40,8 @@ libkde_la_SOURCES = \ Dialogs.C \ GUIRunTime.C \ QtLyXView.h \ + Timeout_pimpl.C \ + Timeout_pimpl.h \ FormCitation.C \ FormCitation.h \ FormCopyright.C \ diff --git a/src/frontends/kde/Timeout_pimpl.C b/src/frontends/kde/Timeout_pimpl.C new file mode 100644 index 0000000000..d3a7de5114 --- /dev/null +++ b/src/frontends/kde/Timeout_pimpl.C @@ -0,0 +1,51 @@ +/** + * \file Timeout_pimpl.C + * Copyright 2001 LyX Team + * Read COPYING + * + * \author John Levon + */ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#include "Timeout_pimpl.h" +#include "debug.h" + +using std::endl; + +Timeout::Pimpl::Pimpl(Timeout * owner) + : owner_(owner), timeout_id(-1) +{ +} + + +void Timeout::Pimpl::timerEvent(QTimerEvent *) +{ + owner_->emit(); +} + + +void Timeout::Pimpl::reset() +{ + killTimers(); + timeout_id = -1; +} + + +void Timeout::Pimpl::start() +{ + if (timeout_id != -1) + lyxerr << "Timeout::start: already running!" << endl; + timeout_id = startTimer(owner_->timeout_ms); +} + + +void Timeout::Pimpl::stop() +{ + if (timeout_id != -1) + reset(); +} diff --git a/src/frontends/kde/Timeout_pimpl.h b/src/frontends/kde/Timeout_pimpl.h new file mode 100644 index 0000000000..3f3261d79f --- /dev/null +++ b/src/frontends/kde/Timeout_pimpl.h @@ -0,0 +1,50 @@ +/** + * \file Timeout_pimpl.h + * Copyright 2001 LyX Team + * Read COPYING + * + * \author John Levon + */ +#ifndef TIMEOUTPIMPL_H +#define TIMEOUTPIMPL_H + +#include + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "frontends/Timeout.h" + +#include + +#include +// stupid Qt +#undef emit + +/** + * This class executes the callback when the timeout expires + * using Qt mechanisms + */ +struct Timeout::Pimpl : QObject { +public: + /// + Pimpl(Timeout *owner_); + /// start the timer + void start(); + /// stop the timer + void stop(); + /// reset + void reset(); + +protected: + /// slot + virtual void timerEvent(QTimerEvent *); +private: + /// the owning timer + Timeout * owner_; + /// xforms id + int timeout_id; +}; + +#endif diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 016b5c09de..8d49e1fe8a 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,9 @@ +2001-02-07 John Levon + + * Makefile.am: + * Timeout_pimpl.h: + * Timeout_pimpl.C: add Timeout implementation + 2001-02-06 John Levon * form_browser.h: diff --git a/src/frontends/xforms/FormBrowser.C b/src/frontends/xforms/FormBrowser.C index 96b35f9b13..45bd2ede00 100644 --- a/src/frontends/xforms/FormBrowser.C +++ b/src/frontends/xforms/FormBrowser.C @@ -24,7 +24,7 @@ using SigC::slot; #endif FormBrowser::FormBrowser(LyXView * lv, Dialogs * d, const string & name) - : FormBaseBD(lv, d, name, new OkViewPolicy), + : FormBaseBD(lv, d, name, new IgnorantPolicy), dialog_(0) { } diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index 0ada31c4f4..db785d5bd6 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -92,6 +92,8 @@ libxforms_la_SOURCES = \ Menubar_pimpl.h \ RadioButtonGroup.C \ RadioButtonGroup.h \ + Timeout_pimpl.C \ + Timeout_pimpl.h \ Toolbar_pimpl.C \ Toolbar_pimpl.h \ xform_helpers.C \ diff --git a/src/frontends/xforms/Timeout_pimpl.C b/src/frontends/xforms/Timeout_pimpl.C new file mode 100644 index 0000000000..3232c982ac --- /dev/null +++ b/src/frontends/xforms/Timeout_pimpl.C @@ -0,0 +1,60 @@ +/** + * \file Timeout_pimpl.C + * Copyright 2001 LyX Team + * Read COPYING + * + * \author Lars Gullik Bjønnes + * \author John Levon + */ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#include FORMS_H_LOCATION + +#include "Timeout_pimpl.h" +#include "debug.h" + +using std::endl; + +extern "C" { + static + void C_intern_timeout_cb(int, void * data) + { + Timeout * to = static_cast(data); + to->emit(); + } +} + + +Timeout::Pimpl::Pimpl(Timeout * owner) + : owner_(owner), timeout_id(-1) +{ +} + + +void Timeout::Pimpl::reset() +{ + timeout_id = -1; +} + + +void Timeout::Pimpl::start() +{ + if (timeout_id != -1) + lyxerr << "Timeout::start: already running!" << endl; + timeout_id = fl_add_timeout(owner_->timeout_ms, + C_intern_timeout_cb, owner_); +} + + +void Timeout::Pimpl::stop() +{ + if (timeout_id != -1) { + fl_remove_timeout(timeout_id); + timeout_id = -1; + } +} diff --git a/src/frontends/xforms/Timeout_pimpl.h b/src/frontends/xforms/Timeout_pimpl.h new file mode 100644 index 0000000000..a6efbab180 --- /dev/null +++ b/src/frontends/xforms/Timeout_pimpl.h @@ -0,0 +1,44 @@ +/** + * \file Timeout_pimpl.h + * Copyright 2001 LyX Team + * Read COPYING + * + * \author Lars Gullik Bjønnes + * \author John Levon + */ +#ifndef TIMEOUTPIMPL_H +#define TIMEOUTPIMPL_H + +#include + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "frontends/Timeout.h" + +#include + +/** + * This class executes the callback when the timeout expires + * using XForms mechanisms + */ +struct Timeout::Pimpl { +public: + /// + Pimpl(Timeout * owner_); + /// start the timer + void start(); + /// stop the timer + void stop(); + /// reset + void reset(); + +private: + /// the owning timer + Timeout * owner_; + /// xforms id + int timeout_id; +}; + +#endif diff --git a/src/minibuffer.h b/src/minibuffer.h index 9bdf1c4600..2fa8b168c0 100644 --- a/src/minibuffer.h +++ b/src/minibuffer.h @@ -5,7 +5,7 @@ #include FORMS_H_LOCATION #include "LString.h" #include "gettext.h" -#include "Timeout.h" +#include "frontends/Timeout.h" #ifdef __GNUG__ #pragma interface -- 2.39.5