mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
change Timeout to use signals some changes because of this
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@825 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
12e7bf34f4
commit
105116682d
20
ChangeLog
20
ChangeLog
@ -1,3 +1,23 @@
|
||||
2000-06-21 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/Timeout.[Ch]: Change to use signals instead of callbacks.
|
||||
* src/LyXView.h (struct FD_form_main): remove, LyXView inherits
|
||||
from SigC::Object
|
||||
(form_main_): remove
|
||||
|
||||
* src/LyXView.C (LyXView_AutosaveTimerCB): remove
|
||||
(create_form_form_main): remove FD_form_main stuff, connect to
|
||||
autosave_timeout signal
|
||||
|
||||
* src/LyXView.[Ch] (getMainForm): remove
|
||||
(UpdateTimerCB): remove
|
||||
* src/BufferView_pimpl.h: inherit from SigC::Object
|
||||
|
||||
* src/BufferView_pimpl.C (Pimpl): connect to cursor_timeout with
|
||||
signal instead of callback
|
||||
|
||||
* src/BufferView.[Ch] (cursorToggleCB): remove
|
||||
|
||||
2000-06-20 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/BufferView_pimpl.C: changes because of the one below
|
||||
|
@ -185,14 +185,6 @@ void BufferView::workAreaExpose()
|
||||
}
|
||||
|
||||
|
||||
// // Callback for cursor timer
|
||||
void BufferView::cursorToggleCB(void * ob)
|
||||
{
|
||||
BufferView * view = static_cast<BufferView*>(ob);
|
||||
view->pimpl_->cursorToggle();
|
||||
}
|
||||
|
||||
|
||||
void BufferView::cursorPrevious()
|
||||
{
|
||||
pimpl_->cursorPrevious();
|
||||
|
@ -205,9 +205,6 @@ public:
|
||||
/// A callback for the slider in the scrollbar.
|
||||
void scrollCB(double);
|
||||
|
||||
///
|
||||
static void cursorToggleCB(void * ob);
|
||||
|
||||
///
|
||||
void setState();
|
||||
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include "support/LAssert.h"
|
||||
#include "frontends/Dialogs.h"
|
||||
|
||||
#ifdef SIGC_CXX_NAMESPACES
|
||||
using SigC::slot;
|
||||
#endif
|
||||
|
||||
using std::pair;
|
||||
using std::endl;
|
||||
using std::vector;
|
||||
@ -74,7 +78,8 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
|
||||
workarea_ = new WorkArea(bv_, xpos, ypos, width, height);
|
||||
screen_ = 0;
|
||||
|
||||
cursor_timeout.callback(BufferView::cursorToggleCB, bv_);
|
||||
cursor_timeout.timeout.connect(slot(this,
|
||||
&BufferView::Pimpl::cursorToggle));
|
||||
current_scrollbar_value = 0;
|
||||
cursor_timeout.start();
|
||||
workarea_->setFocus();
|
||||
@ -320,7 +325,7 @@ void BufferView::Pimpl::updateScreen()
|
||||
{
|
||||
// Regenerate the screen.
|
||||
delete screen_;
|
||||
screen_ = new LyXScreen(*workarea_); //, bv_->text);
|
||||
screen_ = new LyXScreen(*workarea_);
|
||||
}
|
||||
|
||||
|
||||
@ -1271,6 +1276,7 @@ void BufferView::Pimpl::restorePosition()
|
||||
update(BufferView::SELECT|BufferView::FITCUR);
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::Pimpl::NoSavedPositions()
|
||||
{
|
||||
return backstack.empty();
|
||||
|
@ -16,7 +16,7 @@ class LyXView;
|
||||
class WorkArea;
|
||||
class LyXScreen;
|
||||
|
||||
struct BufferView::Pimpl {
|
||||
struct BufferView::Pimpl : public SigC::Object {
|
||||
Pimpl(BufferView * i, LyXView * o,
|
||||
int xpos, int ypos, int width, int height);
|
||||
///
|
||||
|
@ -56,7 +56,6 @@ using SigC::slot;
|
||||
#endif
|
||||
|
||||
LyXView::LyXView(int width, int height)
|
||||
// : update_timeout(300)
|
||||
{
|
||||
create_form_form_main(width, height);
|
||||
fl_set_form_atclose(form_, C_LyXView_atCloseMainFormCB, 0);
|
||||
@ -106,12 +105,6 @@ BufferView * LyXView::view() const
|
||||
}
|
||||
|
||||
|
||||
FD_form_main * LyXView::getMainForm() const
|
||||
{
|
||||
return form_main_;
|
||||
}
|
||||
|
||||
|
||||
FL_FORM * LyXView::getForm() const
|
||||
{
|
||||
return form_;
|
||||
@ -157,14 +150,6 @@ void LyXView::AutoSave()
|
||||
}
|
||||
|
||||
|
||||
// Wrapper for the above
|
||||
static
|
||||
void LyXView_AutosaveTimerCB(void * ob)
|
||||
{
|
||||
LyXView * view = static_cast<LyXView*>(ob);
|
||||
view->AutoSave();
|
||||
}
|
||||
|
||||
/// Reset autosave timer
|
||||
void LyXView::resetAutosaveTimer()
|
||||
{
|
||||
@ -211,14 +196,9 @@ void LyXView::create_form_form_main(int width, int height)
|
||||
* are presented (and rightly so) in GUI popups. Asger.
|
||||
*/
|
||||
{
|
||||
FD_form_main * fdui = static_cast<FD_form_main *>
|
||||
(fl_calloc(1, sizeof(FD_form_main)));
|
||||
|
||||
form_main_ = fdui;
|
||||
|
||||
// the main form
|
||||
form_ = fdui->form_main = fl_bgn_form(FL_NO_BOX, width, height);
|
||||
fdui->form_main->u_vdata = this;
|
||||
form_ = fl_bgn_form(FL_NO_BOX, width, height);
|
||||
form_->u_vdata = this;
|
||||
FL_OBJECT * obj = fl_add_box(FL_FLAT_BOX, 0, 0, width, height, "");
|
||||
fl_set_object_color(obj, FL_MCOL, FL_MCOL);
|
||||
|
||||
@ -263,8 +243,8 @@ void LyXView::create_form_form_main(int width, int height)
|
||||
// TIMERS
|
||||
//
|
||||
|
||||
autosave_timeout.callback(LyXView_AutosaveTimerCB, this);
|
||||
|
||||
autosave_timeout.timeout.connect(slot(this, &LyXView::AutoSave));
|
||||
|
||||
//
|
||||
// Misc
|
||||
//
|
||||
@ -280,16 +260,17 @@ void LyXView::create_form_form_main(int width, int height)
|
||||
0,
|
||||
0,
|
||||
0); // this leaks
|
||||
fl_set_form_icon(fdui->form_main, lyx_p, lyx_mask);
|
||||
fl_set_form_icon(form_, lyx_p, lyx_mask);
|
||||
|
||||
// set min size
|
||||
fl_set_form_minsize(fdui->form_main, 50, 50);
|
||||
fl_set_form_minsize(form_, 50, 50);
|
||||
|
||||
fl_end_form();
|
||||
}
|
||||
|
||||
|
||||
extern "C" int C_LyXView_KeyPressMask_raw_callback(FL_FORM * fl, void * xev);
|
||||
extern "C"
|
||||
int C_LyXView_KeyPressMask_raw_callback(FL_FORM * fl, void * xev);
|
||||
|
||||
void LyXView::init()
|
||||
{
|
||||
@ -299,13 +280,10 @@ void LyXView::init()
|
||||
UpdateDocumentClassChoice();
|
||||
|
||||
// Start autosave timer
|
||||
if (lyxrc.autosave)
|
||||
#if 0
|
||||
fl_set_timer(form_main_->timer_autosave, lyxrc.autosave);
|
||||
#else
|
||||
autosave_timeout.setTimeout(lyxrc.autosave * 1000);
|
||||
autosave_timeout.start();
|
||||
#endif
|
||||
if (lyxrc.autosave) {
|
||||
autosave_timeout.setTimeout(lyxrc.autosave * 1000);
|
||||
autosave_timeout.start();
|
||||
}
|
||||
|
||||
// Install the raw callback for keyboard events
|
||||
fl_register_raw_callback(form_,
|
||||
@ -338,7 +316,8 @@ void LyXView::updateLayoutChoice()
|
||||
if (toolbar->combox->empty() ||
|
||||
(last_textclass != int(buffer()->params.textclass))) {
|
||||
toolbar->combox->clear();
|
||||
LyXTextClass const & tc = textclasslist.TextClass(buffer()->params.textclass);
|
||||
LyXTextClass const & tc =
|
||||
textclasslist.TextClass(buffer()->params.textclass);
|
||||
for (LyXTextClass::const_iterator cit = tc.begin();
|
||||
cit != tc.end(); ++cit) {
|
||||
if ((*cit).obsoleted_by().empty())
|
||||
@ -352,7 +331,8 @@ void LyXView::updateLayoutChoice()
|
||||
// we need to do this.
|
||||
toolbar->combox->Redraw();
|
||||
|
||||
LyXTextClass::size_type layout = bufferview->text->cursor.par()->GetLayout();
|
||||
LyXTextClass::size_type layout =
|
||||
bufferview->text->cursor.par()->GetLayout();
|
||||
|
||||
if (layout != current_layout){
|
||||
toolbar->combox->select(layout + 1);
|
||||
@ -431,7 +411,8 @@ int LyXView::KeyPressMask_raw_callback(FL_FORM * fl, void * xev)
|
||||
|
||||
|
||||
// wrapper for the above
|
||||
extern "C" int C_LyXView_KeyPressMask_raw_callback(FL_FORM * fl, void * xev)
|
||||
extern "C"
|
||||
int C_LyXView_KeyPressMask_raw_callback(FL_FORM * fl, void * xev)
|
||||
{
|
||||
return LyXView::KeyPressMask_raw_callback(fl, xev);
|
||||
}
|
||||
|
@ -29,19 +29,13 @@ class Menus;
|
||||
class BufferView;
|
||||
class Dialogs;
|
||||
|
||||
///
|
||||
struct FD_form_main {
|
||||
///
|
||||
FL_FORM * form_main;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
This class is the form containing the view of the buffer. The actual buffer
|
||||
view is supposed (at least IMHO) to be another class, that shows its output
|
||||
in one or more LyXView's.
|
||||
*/
|
||||
class LyXView {
|
||||
class LyXView : public SigC::Object {
|
||||
public:
|
||||
/// constructor
|
||||
LyXView(int w, int h);
|
||||
@ -67,9 +61,6 @@ public:
|
||||
///
|
||||
BufferView * view() const;
|
||||
|
||||
/// returns a pointer to the main form.
|
||||
FD_form_main * getMainForm() const;
|
||||
|
||||
/// returns a pointer to the form.
|
||||
FL_FORM * getForm() const;
|
||||
|
||||
@ -129,16 +120,12 @@ public:
|
||||
static int atCloseMainFormCB(FL_FORM *, void *);
|
||||
/// A callback
|
||||
void AutoSave();
|
||||
/// A callback
|
||||
static void UpdateTimerCB(void *);
|
||||
private:
|
||||
///
|
||||
Timeout autosave_timeout;
|
||||
/// makes the main form.
|
||||
void create_form_form_main(int width, int height);
|
||||
/// A pointer to the form.
|
||||
FD_form_main * form_main_;
|
||||
/// A pointer to the form.
|
||||
FL_FORM * form_;
|
||||
/** The last textclass layout list in the layout choice selector
|
||||
This should probably be moved to the toolbar, but for now it's
|
||||
|
@ -12,19 +12,19 @@ extern "C" {
|
||||
void C_intern_timeout_cb(int, void * data)
|
||||
{
|
||||
Timeout * to = static_cast<Timeout*>(data);
|
||||
to->callback();
|
||||
to->emit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Timeout::Timeout()
|
||||
: type(ONETIME), timeout(0), timeout_id(-1),
|
||||
callback_(0), data_(0) {}
|
||||
: type(ONETIME), timeout_ms(0), timeout_id(-1)
|
||||
{}
|
||||
|
||||
|
||||
Timeout::Timeout(int msec, Type t)
|
||||
: type(t), timeout(msec), timeout_id(-1),
|
||||
callback_(0), data_(0) {}
|
||||
: type(t), timeout_ms(msec), timeout_id(-1)
|
||||
{}
|
||||
|
||||
|
||||
Timeout::~Timeout()
|
||||
@ -44,7 +44,7 @@ void Timeout::start()
|
||||
{
|
||||
if (timeout_id != -1)
|
||||
lyxerr << "Timeout::start: already running!" << endl;
|
||||
timeout_id = fl_add_timeout(timeout,
|
||||
timeout_id = fl_add_timeout(timeout_ms,
|
||||
C_intern_timeout_cb, this);
|
||||
}
|
||||
|
||||
@ -58,18 +58,10 @@ void Timeout::stop()
|
||||
}
|
||||
|
||||
|
||||
void Timeout::callback(TimeoutCallback cb, void * data)
|
||||
{
|
||||
callback_ = cb;
|
||||
data_ = data;
|
||||
}
|
||||
|
||||
|
||||
void Timeout::callback()
|
||||
void Timeout::emit()
|
||||
{
|
||||
timeout_id = -1;
|
||||
if (callback_)
|
||||
callback_(data_);
|
||||
timeout.emit();
|
||||
if (type == CONTINOUS)
|
||||
start();
|
||||
}
|
||||
@ -83,5 +75,5 @@ void Timeout::setType(Type t)
|
||||
|
||||
void Timeout::setTimeout(int msec)
|
||||
{
|
||||
timeout = msec;
|
||||
timeout_ms = msec;
|
||||
}
|
||||
|
@ -2,15 +2,18 @@
|
||||
#ifndef TIMEOUT_H
|
||||
#define TIMEOUT_H
|
||||
|
||||
#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:
|
||||
///
|
||||
typedef void (*TimeoutCallback)(void *);
|
||||
|
||||
///
|
||||
enum Type {
|
||||
ONETIME,
|
||||
@ -29,9 +32,9 @@ public:
|
||||
///
|
||||
void restart();
|
||||
///
|
||||
void callback(TimeoutCallback cb, void * data);
|
||||
Signal0<void> timeout;
|
||||
///
|
||||
void callback();
|
||||
void emit();
|
||||
///
|
||||
void setType(Type t);
|
||||
///
|
||||
@ -40,13 +43,9 @@ private:
|
||||
///
|
||||
Type type;
|
||||
///
|
||||
int timeout;
|
||||
int timeout_ms;
|
||||
///
|
||||
int timeout_id;
|
||||
///
|
||||
TimeoutCallback callback_;
|
||||
///
|
||||
void * data_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -273,7 +273,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
||||
|
||||
if (!area) return 1;
|
||||
|
||||
switch (event){
|
||||
switch (event){
|
||||
case FL_DRAW:
|
||||
if (!area->work_area ||
|
||||
!area->work_area->form->visible)
|
||||
@ -281,6 +281,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
||||
lyxerr.debug() << "Workarea event: DRAW" << endl;
|
||||
area->createPixmap(area->workWidth(), area->height());
|
||||
Lgb_bug_find_hack = true;
|
||||
//workAreaExpose();
|
||||
area->owner_->workAreaExpose();
|
||||
Lgb_bug_find_hack = false;
|
||||
break;
|
||||
@ -288,6 +289,10 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
||||
if (!ev) break;
|
||||
// Should really have used xbutton.state
|
||||
lyxerr.debug() << "Workarea event: PUSH" << endl;
|
||||
//workAreaButtonPress(ev->xbutton.x - ob->x,
|
||||
// ev->xbutton.y - ob->y,
|
||||
// ev->xbutton.button);
|
||||
|
||||
area->owner_->workAreaButtonPress(ev->xbutton.x - ob->x,
|
||||
ev->xbutton.y - ob->y,
|
||||
ev->xbutton.button);
|
||||
@ -296,6 +301,9 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
||||
if (!ev) break;
|
||||
// Should really have used xbutton.state
|
||||
lyxerr.debug() << "Workarea event: RELEASE" << endl;
|
||||
//workAreaButtonRelease(ev->xbutton.x - ob->x,
|
||||
// ev->xbutton.y - ob->y,
|
||||
// ev->xbutton.button);
|
||||
area->owner_->workAreaButtonRelease(ev->xbutton.x - ob->x,
|
||||
ev->xbutton.y - ob->y,
|
||||
ev->xbutton.button);
|
||||
@ -307,6 +315,10 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
||||
fl_get_scrollbar_value(area->scrollbar) != scrollbar_value_old
|
||||
) {
|
||||
lyxerr.debug() << "Workarea event: MOUSE" << endl;
|
||||
//workAreaMotionNotify(ev->xmotion.x - ob->x,
|
||||
// ev->xmotion.y - ob->y,
|
||||
// ev->xbutton.state);
|
||||
|
||||
area->owner_->workAreaMotionNotify(ev->xmotion.x - ob->x,
|
||||
ev->xmotion.y - ob->y,
|
||||
ev->xbutton.state);
|
||||
@ -316,21 +328,28 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
||||
// case FL_KEYBOARD: WorkAreaKeyPress(ob, 0,0,0,ev,0); break;
|
||||
case FL_FOCUS:
|
||||
lyxerr.debug() << "Workarea event: FOCUS" << endl;
|
||||
//workAreaFocus();
|
||||
break;
|
||||
case FL_UNFOCUS:
|
||||
lyxerr.debug() << "Workarea event: UNFOCUS" << endl;
|
||||
//workAreaUnfocus();
|
||||
break;
|
||||
case FL_ENTER:
|
||||
lyxerr.debug() << "Workarea event: ENTER" << endl;
|
||||
//workAreaEnter();
|
||||
area->owner_->enterView();
|
||||
break;
|
||||
case FL_LEAVE:
|
||||
lyxerr.debug() << "Workarea event: LEAVE" << endl;
|
||||
//workAreaLeave();
|
||||
area->owner_->leaveView();
|
||||
break;
|
||||
case FL_DBLCLICK:
|
||||
if (!ev) break;
|
||||
lyxerr.debug() << "Workarea event: DBLCLICK" << endl;
|
||||
//workAreaDoubleClick(ev->xbutton.x - ob->x,
|
||||
// ev->xbutton.y - ob->y,
|
||||
// ev->xbutton.button);
|
||||
area->owner_->doubleClick(ev->xbutton.x - ob->x,
|
||||
ev->xbutton.y - ob->y,
|
||||
ev->xbutton.button);
|
||||
@ -338,6 +357,9 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
||||
case FL_TRPLCLICK:
|
||||
if (!ev) break;
|
||||
lyxerr.debug() << "Workarea event: TRPLCLICK" << endl;
|
||||
//workAreaTripleClick(ev->xbutton.x - ob->x,
|
||||
// ev->xbutton.y - ob->y,
|
||||
// ev->xbutton.button);
|
||||
area->owner_->tripleClick(ev->xbutton.x - ob->x,
|
||||
ev->xbutton.y - ob->y,
|
||||
ev->xbutton.button);
|
||||
|
@ -18,9 +18,16 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
//#include <sigc++/signal_system.h>
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
#include "Painter.h"
|
||||
|
||||
//#ifdef SIGC_CXX_NAMESPACES
|
||||
//using SigC::Signal0;
|
||||
//using SigC::Signal3;
|
||||
//#endif
|
||||
|
||||
class BufferView;
|
||||
|
||||
|
||||
@ -98,6 +105,27 @@ public:
|
||||
///
|
||||
BufferView * owner() const { return owner_; }
|
||||
|
||||
// Signals
|
||||
///
|
||||
//Signal0<void> workAreaExpose;
|
||||
///
|
||||
//Signal3<void, int, int, unsigned int> workAreaButtonPress;
|
||||
///
|
||||
//Signal3<void, int, int, unsigned int> workAreaButtonRelease;
|
||||
///
|
||||
//Signal3<void, int, int, unsigned int> workAreaMotionNotify;
|
||||
///
|
||||
//Signal0<void> workAreaFocus;
|
||||
///
|
||||
//Signal0<void> workAreaUnfocus;
|
||||
///
|
||||
//Signal0<void> workAreaEnter;
|
||||
///
|
||||
//Signal0<void> workAreaLeave;
|
||||
///
|
||||
//Signal3<void, int, int, unsigned int> workAreaDoubleClick;
|
||||
///
|
||||
//Signal3<void, int, int, unsigned int> workAreaTripleClick;
|
||||
private:
|
||||
///
|
||||
void createPixmap(int, int);
|
||||
|
@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
|
||||
noinst_LTLIBRARIES = libinsets.la
|
||||
LIBS =
|
||||
ETAGS_ARGS = --lang=c++
|
||||
INCLUDES = -I${srcdir}/../
|
||||
INCLUDES = -I${srcdir}/../ $(SIGC_CFLAGS)
|
||||
|
||||
libinsets_la_SOURCES = \
|
||||
BoundingBox.h \
|
||||
|
@ -405,7 +405,7 @@ void InitFigures()
|
||||
if (lyxrc.use_gui) {
|
||||
fl_add_canvas_handler(figinset_canvas, ClientMessage,
|
||||
GhostscriptMsg,
|
||||
current_view->owner()->getMainForm());
|
||||
current_view->owner()->getForm());
|
||||
|
||||
local_gc_copy = createGC();
|
||||
|
||||
|
@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
|
||||
noinst_LTLIBRARIES = libmathed.la
|
||||
LIBS=
|
||||
ETAGS_ARGS = --lang=c++
|
||||
INCLUDES = -I${top_srcdir}/images -I${srcdir}/../
|
||||
INCLUDES = -I${top_srcdir}/images -I${srcdir}/../ $(SIGC_CFLAGS)
|
||||
|
||||
libmathed_la_SOURCES = array.h \
|
||||
formula.C \
|
||||
|
Loading…
Reference in New Issue
Block a user