mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
the Timeout patch
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1456 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9e41aa715e
commit
f490ae76ab
@ -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
|
||||
|
@ -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<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 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<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();
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "UpdateInset.h"
|
||||
#include "Timeout.h"
|
||||
#include "frontends/Timeout.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
|
@ -1,3 +1,13 @@
|
||||
2001-02-07 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* 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 <dekelts@tau.ac.il>
|
||||
|
||||
* lyxrc.C (read): Update converters data-structures.
|
||||
|
@ -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"
|
||||
|
||||
|
@ -73,8 +73,6 @@ lyx_SOURCES = \
|
||||
Spacing.h \
|
||||
TextCache.C \
|
||||
TextCache.h \
|
||||
Timeout.C \
|
||||
Timeout.h \
|
||||
ToolbarDefaults.C \
|
||||
ToolbarDefaults.h \
|
||||
UpdateInset.C \
|
||||
|
@ -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;
|
||||
}
|
@ -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
|
@ -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------------------------------*/
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,3 +1,13 @@
|
||||
2001-02-07 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* 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 <moz@compsoc.man.ac.uk>
|
||||
|
||||
* ButtonPolicies.C:
|
||||
|
@ -20,6 +20,8 @@ libfrontends_la_SOURCES=\
|
||||
Liason.h \
|
||||
Menubar.C \
|
||||
Menubar.h \
|
||||
Timeout.C \
|
||||
Timeout.h \
|
||||
Toolbar.C \
|
||||
Toolbar.h
|
||||
|
||||
|
76
src/frontends/Timeout.C
Normal file
76
src/frontends/Timeout.C
Normal file
@ -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 <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;
|
||||
}
|
69
src/frontends/Timeout.h
Normal file
69
src/frontends/Timeout.h
Normal file
@ -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 <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
|
@ -1,3 +1,9 @@
|
||||
2001-02-07 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Timeout_pimpl.h:
|
||||
* Timeout_pimpl.C:
|
||||
* Makefile.am: add Timeout_pimpl
|
||||
|
||||
2001-01-26 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* dlg/lengthentry.C: Move the '#include <config.h>' to the top
|
||||
|
@ -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 \
|
||||
|
51
src/frontends/kde/Timeout_pimpl.C
Normal file
51
src/frontends/kde/Timeout_pimpl.C
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* \file Timeout_pimpl.C
|
||||
* Copyright 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();
|
||||
}
|
50
src/frontends/kde/Timeout_pimpl.h
Normal file
50
src/frontends/kde/Timeout_pimpl.h
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* \file Timeout_pimpl.h
|
||||
* Copyright 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
|
@ -1,3 +1,9 @@
|
||||
2001-02-07 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Makefile.am:
|
||||
* Timeout_pimpl.h:
|
||||
* Timeout_pimpl.C: add Timeout implementation
|
||||
|
||||
2001-02-06 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* form_browser.h:
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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 \
|
||||
|
60
src/frontends/xforms/Timeout_pimpl.C
Normal file
60
src/frontends/xforms/Timeout_pimpl.C
Normal file
@ -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 <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;
|
||||
}
|
||||
}
|
44
src/frontends/xforms/Timeout_pimpl.h
Normal file
44
src/frontends/xforms/Timeout_pimpl.h
Normal file
@ -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 <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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user