+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
}
-// // Callback for cursor timer
-void BufferView::cursorToggleCB(void * ob)
-{
- BufferView * view = static_cast<BufferView*>(ob);
- view->pimpl_->cursorToggle();
-}
-
-
void BufferView::cursorPrevious()
{
pimpl_->cursorPrevious();
/// A callback for the slider in the scrollbar.
void scrollCB(double);
- ///
- static void cursorToggleCB(void * ob);
-
///
void setState();
#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;
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();
{
// Regenerate the screen.
delete screen_;
- screen_ = new LyXScreen(*workarea_); //, bv_->text);
+ screen_ = new LyXScreen(*workarea_);
}
update(BufferView::SELECT|BufferView::FITCUR);
}
+
bool BufferView::Pimpl::NoSavedPositions()
{
return backstack.empty();
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);
///
#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);
}
-FD_form_main * LyXView::getMainForm() const
-{
- return form_main_;
-}
-
-
FL_FORM * LyXView::getForm() const
{
return form_;
}
-// Wrapper for the above
-static
-void LyXView_AutosaveTimerCB(void * ob)
-{
- LyXView * view = static_cast<LyXView*>(ob);
- view->AutoSave();
-}
-
/// Reset autosave timer
void LyXView::resetAutosaveTimer()
{
* 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);
// TIMERS
//
- autosave_timeout.callback(LyXView_AutosaveTimerCB, this);
-
+ autosave_timeout.timeout.connect(slot(this, &LyXView::AutoSave));
+
//
// Misc
//
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()
{
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_,
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())
// 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);
// 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);
}
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);
///
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;
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
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()
{
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);
}
}
-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();
}
void Timeout::setTimeout(int msec)
{
- timeout = msec;
+ timeout_ms = msec;
}
#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,
///
void restart();
///
- void callback(TimeoutCallback cb, void * data);
+ Signal0<void> timeout;
///
- void callback();
+ void emit();
///
void setType(Type t);
///
///
Type type;
///
- int timeout;
+ int timeout_ms;
///
int timeout_id;
- ///
- TimeoutCallback callback_;
- ///
- void * data_;
};
#endif
if (!area) return 1;
- switch (event){
+ switch (event){
case FL_DRAW:
if (!area->work_area ||
!area->work_area->form->visible)
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;
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);
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);
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);
// 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);
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);
#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;
///
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);
noinst_LTLIBRARIES = libinsets.la
LIBS =
ETAGS_ARGS = --lang=c++
-INCLUDES = -I${srcdir}/../
+INCLUDES = -I${srcdir}/../ $(SIGC_CFLAGS)
libinsets_la_SOURCES = \
BoundingBox.h \
if (lyxrc.use_gui) {
fl_add_canvas_handler(figinset_canvas, ClientMessage,
GhostscriptMsg,
- current_view->owner()->getMainForm());
+ current_view->owner()->getForm());
local_gc_copy = createGC();
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 \