Hope this one's OK
thanks
john
--
"Beware of bugs in the above code; I have only proved it correct, not tried it."
- Donald Knuth
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.64
diff -u -p -r1.64 BufferView_pimpl.C
--- src/BufferView_pimpl.C 2001/01/29 10:24:16 1.64
+++ src/BufferView_pimpl.C 2001/02/07 15:03:18
@@ -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,
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
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<int>((bv_->text->first + height))) {
- vbt->SetCursorFromCoordinates(bv_, 0,
- bv_->text->first +
- height);
- } else if (vbt->cursor.y() >
-
static_cast<int>((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<int>((bv_->text->first + height));
+ int const last = static_cast<int>((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 tim
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::workAreaMotionNo
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::workAreaMotionNo
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::workAreaButtonPr
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::workAreaButtonRe
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
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<pid_t>(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<pid_t>(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();
Index: src/BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.25
diff -u -p -r1.25 BufferView_pimpl.h
--- src/BufferView_pimpl.h 2001/01/29 17:45:29 1.25
+++ src/BufferView_pimpl.h 2001/02/07 15:03:18
@@ -5,7 +5,7 @@
#include "BufferView.h"
#include "UpdateInset.h"
-#include "Timeout.h"
+#include "frontends/Timeout.h"
#ifdef __GNUG__
#pragma interface
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.37
diff -u -p -r1.37 ChangeLog
--- src/ChangeLog 2001/02/06 17:41:41 1.37
+++ src/ChangeLog 2001/02/07 15:03:18
@@ -1,3 +1,14 @@
+2001-02-07 John Levon <[EMAIL PROTECTED]>
+
+ * BufferView_pimpl.C: housekeeping
+
+ * BufferView_pimpl.h:
+ * LyXView.h:
+ * Makefile.am:
+ * Timeout.C:
+ * Timeout.h:
+ * minibuffer.h: move Timeout GUI-I
+
2001-02-06 John Levon <[EMAIL PROTECTED]>
* Makefile.am: remove LaTeXLog.C, log_form.[Ch]
Index: src/LyXView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXView.h,v
retrieving revision 1.27
diff -u -p -r1.27 LyXView.h
--- src/LyXView.h 2000/11/04 10:00:08 1.27
+++ src/LyXView.h 2001/02/07 15:03:18
@@ -20,7 +20,7 @@
#include FORMS_H_LOCATION
#include "LString.h"
-#include "Timeout.h"
+#include "frontends/Timeout.h"
#include <boost/utility.hpp>
#include "layout.h"
Index: src/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Makefile.am,v
retrieving revision 1.67
diff -u -p -r1.67 Makefile.am
--- src/Makefile.am 2001/02/06 17:41:41 1.67
+++ src/Makefile.am 2001/02/07 15:03:18
@@ -73,8 +73,6 @@ lyx_SOURCES = \
Spacing.h \
TextCache.C \
TextCache.h \
- Timeout.C \
- Timeout.h \
ToolbarDefaults.C \
ToolbarDefaults.h \
UpdateInset.C \
Index: src/Timeout.C
===================================================================
RCS file: Timeout.C
diff -N Timeout.C
--- src/Timeout.C Wed Feb 7 16:03:18 2001
+++ /dev/null Tue May 5 22:32:27 1998
@@ -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 <config.h>
-
-#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<Timeout*>(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;
-}
Index: src/Timeout.h
===================================================================
RCS file: Timeout.h
diff -N Timeout.h
--- src/Timeout.h Wed Feb 7 16:03:18 2001
+++ /dev/null Tue May 5 22:32:27 1998
@@ -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 <config.h>
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <sigc++/signal_system.h>
-
-#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<void> timeout;
- ///
- void emit();
- ///
- Timeout & setType(Type t);
- ///
- Timeout & setTimeout(unsigned int msec);
-private:
- ///
- Type type;
- ///
- unsigned int timeout_ms;
- ///
- int timeout_id;
-};
-
-#endif
Index: src/minibuffer.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/minibuffer.h,v
retrieving revision 1.13
diff -u -p -r1.13 minibuffer.h
--- src/minibuffer.h 2000/10/26 00:07:20 1.13
+++ src/minibuffer.h 2001/02/07 15:03:18
@@ -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
Index: src/frontends/ButtonPolicies.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/ButtonPolicies.C,v
retrieving revision 1.11
diff -u -p -r1.11 ButtonPolicies.C
--- src/frontends/ButtonPolicies.C 2001/02/06 17:41:42 1.11
+++ src/frontends/ButtonPolicies.C 2001/02/07 15:03:18
@@ -118,25 +118,6 @@ void PreferencesPolicy::input(SMInput in
}
-/*-------------------------------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------------------------------*/
Index: src/frontends/ButtonPolicies.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/ButtonPolicies.h,v
retrieving revision 1.13
diff -u -p -r1.13 ButtonPolicies.h
--- src/frontends/ButtonPolicies.h 2001/02/06 17:41:42 1.13
+++ src/frontends/ButtonPolicies.h 2001/02/07 15:03:18
@@ -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
Index: src/frontends/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/ChangeLog,v
retrieving revision 1.3
diff -u -p -r1.3 ChangeLog
--- src/frontends/ChangeLog 2001/02/06 17:41:42 1.3
+++ src/frontends/ChangeLog 2001/02/07 15:03:18
@@ -1,3 +1,13 @@
+2001-02-07 John Levon <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
* ButtonPolicies.C:
Index: src/frontends/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/Makefile.am,v
retrieving revision 1.12
diff -u -p -r1.12 Makefile.am
--- src/frontends/Makefile.am 2001/01/26 10:16:04 1.12
+++ src/frontends/Makefile.am 2001/02/07 15:03:18
@@ -20,6 +20,8 @@ libfrontends_la_SOURCES=\
Liason.h \
Menubar.C \
Menubar.h \
+ Timeout.C \
+ Timeout.h \
Toolbar.C \
Toolbar.h
Index: src/frontends/Timeout.C
===================================================================
RCS file: Timeout.C
diff -N Timeout.C
--- src/frontends/Timeout.C Tue May 5 22:32:27 1998
+++ Timeout.C Wed Feb 7 16:03:18 2001
@@ -0,0 +1,76 @@
+/*
+ * Timeout.C
+ * (C) 2001 LyX Team
+ * Read COPYING
+ *
+ * @author: Lars Gullik Bj�nnes
+ * @author: John Levon
+ */
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#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;
+}
Index: src/frontends/Timeout.h
===================================================================
RCS file: Timeout.h
diff -N Timeout.h
--- src/frontends/Timeout.h Tue May 5 22:32:27 1998
+++ Timeout.h Wed Feb 7 16:03:18 2001
@@ -0,0 +1,69 @@
+/*
+ * Timeout.h
+ * (C) 2001 LyX Team
+ * Read COPYING
+ *
+ * @author: Lars Gullik Bj�nnes
+ * @author: John Levon
+ */
+#ifndef TIMEOUT_H
+#define TIMEOUT_H
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <sigc++/signal_system.h>
+
+#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<void> 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
Index: src/frontends/kde/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/kde/ChangeLog,v
retrieving revision 1.4
diff -u -p -r1.4 ChangeLog
--- src/frontends/kde/ChangeLog 2001/01/26 17:24:09 1.4
+++ src/frontends/kde/ChangeLog 2001/02/07 15:03:18
@@ -1,3 +1,9 @@
+2001-02-07 John Levon <[EMAIL PROTECTED]>
+
+ * Timeout_pimpl.h:
+ * Timeout_pimpl.C:
+ * Makefile.am: add Timeout_pimpl
+
2001-01-26 Dekel Tsur <[EMAIL PROTECTED]>
* dlg/lengthentry.C: Move the '#include <config.h>' to the top
Index: src/frontends/kde/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/kde/Makefile.am,v
retrieving revision 1.21
diff -u -p -r1.21 Makefile.am
--- src/frontends/kde/Makefile.am 2001/01/24 11:43:47 1.21
+++ src/frontends/kde/Makefile.am 2001/02/07 15:03:18
@@ -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 \
Index: src/frontends/kde/Timeout_pimpl.C
===================================================================
RCS file: Timeout_pimpl.C
diff -N Timeout_pimpl.C
--- src/frontends/kde/Timeout_pimpl.C Tue May 5 22:32:27 1998
+++ Timeout_pimpl.C Wed Feb 7 16:03:18 2001
@@ -0,0 +1,48 @@
+/*
+ * Timeout_pimpl.C
+ * (C) 2001 LyX Team
+ * Read COPYING
+ *
+ * @author: John Levon
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#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();
+}
Index: src/frontends/kde/Timeout_pimpl.h
===================================================================
RCS file: Timeout_pimpl.h
diff -N Timeout_pimpl.h
--- src/frontends/kde/Timeout_pimpl.h Tue May 5 22:32:27 1998
+++ Timeout_pimpl.h Wed Feb 7 16:03:18 2001
@@ -0,0 +1,50 @@
+/*
+ * Timeout_pimpl.h
+ * (C) 2001 LyX Team
+ * Read COPYING
+ *
+ * @author: John Levon
+ */
+#ifndef TIMEOUTPIMPL_H
+#define TIMEOUTPIMPL_H
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "frontends/Timeout.h"
+
+#include <sigc++/signal_system.h>
+
+#include <qobject.h>
+// 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
Index: src/frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.10
diff -u -p -r1.10 ChangeLog
--- src/frontends/xforms/ChangeLog 2001/02/06 17:41:42 1.10
+++ src/frontends/xforms/ChangeLog 2001/02/07 15:03:18
@@ -1,3 +1,9 @@
+2001-02-07 John Levon <[EMAIL PROTECTED]>
+
+ * Makefile.am:
+ * Timeout_pimpl.h:
+ * Timeout_pimpl.C: add Timeout implementation
+
2001-02-06 John Levon <[EMAIL PROTECTED]>
* form_browser.h:
Index: src/frontends/xforms/FormBrowser.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormBrowser.C,v
retrieving revision 1.1
diff -u -p -r1.1 FormBrowser.C
--- src/frontends/xforms/FormBrowser.C 2001/02/06 17:41:42 1.1
+++ src/frontends/xforms/FormBrowser.C 2001/02/07 15:03:18
@@ -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)
{
}
Index: src/frontends/xforms/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/Makefile.am,v
retrieving revision 1.26
diff -u -p -r1.26 Makefile.am
--- src/frontends/xforms/Makefile.am 2001/02/06 17:41:42 1.26
+++ src/frontends/xforms/Makefile.am 2001/02/07 15:03:18
@@ -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 \
Index: src/frontends/xforms/Timeout_pimpl.C
===================================================================
RCS file: Timeout_pimpl.C
diff -N Timeout_pimpl.C
--- src/frontends/xforms/Timeout_pimpl.C Tue May 5 22:32:27 1998
+++ Timeout_pimpl.C Wed Feb 7 16:03:18 2001
@@ -0,0 +1,57 @@
+/*
+ * Timeout_pimpl.C
+ * (C) 2001 LyX Team
+ * Read COPYING
+ *
+ * @author: Lars Gullik Bj�nnes
+ * @author: John Levon
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#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<Timeout *>(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;
+ }
+}
Index: src/frontends/xforms/Timeout_pimpl.h
===================================================================
RCS file: Timeout_pimpl.h
diff -N Timeout_pimpl.h
--- src/frontends/xforms/Timeout_pimpl.h Tue May 5 22:32:27 1998
+++ Timeout_pimpl.h Wed Feb 7 16:03:18 2001
@@ -0,0 +1,44 @@
+/*
+ * Timeout_pimpl.h
+ * (C) 2001 LyX Team
+ * Read COPYING
+ *
+ * @author: Lars Gullik Bj�nnes
+ * @author: John Levon
+ */
+#ifndef TIMEOUTPIMPL_H
+#define TIMEOUTPIMPL_H
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "frontends/Timeout.h"
+
+#include <sigc++/signal_system.h>
+
+/**
+ * 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