]> git.lyx.org Git - features.git/commitdiff
change Timeout to use signals some changes because of this
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 21 Jun 2000 12:41:18 +0000 (12:41 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 21 Jun 2000 12:41:18 +0000 (12:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@825 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
ChangeLog
src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/LyXView.C
src/LyXView.h
src/Timeout.C
src/Timeout.h
src/WorkArea.C
src/WorkArea.h
src/insets/Makefile.am
src/insets/figinset.C
src/mathed/Makefile.am

index d6ed026a4ebf829e20d2932cd5a56b89351f79df..c5d31555d43d9395c789cb98d65511162854c01a 100644 (file)
--- a/ChangeLog
+++ b/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
index e1a72466a66283132143ed775c2186a578867369..4fb7f0eb6dafdfcd9e0905912bfcc4e271498360 100644 (file)
@@ -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();
index 91033dbc6c201f1f1788626d69c9d143cca36726..e714c63d33f5b1b199ab62c41fb326d3eb9019d9 100644 (file)
@@ -205,9 +205,6 @@ public:
        /// A callback for the slider in the scrollbar.
        void scrollCB(double);
 
-       ///
-       static void cursorToggleCB(void * ob);
-
        ///
        void setState();
 
index 1229b15e022053f74dce176670a5084f36a8a5e4..6f9ecaffa3fee42f8b6789b21c8466eaad52dab8 100644 (file)
 #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();
index 5f855c2e613edef8bc192f41719d97fe9b05ab3c..e7db7acae9d5d0849946ffad9440e802a5d565ed 100644 (file)
@@ -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);
        ///
index 7c2c426bf24300c885de71600cda121390e58d26..4a1c93f5519408c0175eab6c731da62ab0835f5d 100644 (file)
@@ -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);
 }
index e8c99e22cb669163b12463bb5d4f1528714a6a9f..5fab87d125d46d90059c00ccdb8a44c3ae381f95 100644 (file)
@@ -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
index fc0a8c50454fd57194fb57b62e63352ef6c9d7aa..4005c83884b8f6b0cc5ed4957818a4001b5ce167 100644 (file)
@@ -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;
 }
index fb6797116af007ba64f668842392ba8a990be21e..7afefc3f33d5d581b46fdfeab3e80a991e4dadfd 100644 (file)
@@ -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
index b20ec6b298ad23503b079e0315f2b40211787a60..d261fed5400b3f7fedff231a750828a2a8875223 100644 (file)
@@ -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);
index b57f3e713dc218ae9d37844dabe291c94f8489ce..651b2a033c96c45d7a8e9620e019845083d80bfa 100644 (file)
 
 #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);
index f8555a96cc4a7e843f32fe9ce0be0bfe758b0da8..3c098202bb7973b9c72c3a90c6dfff089140ac5b 100644 (file)
@@ -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 \
index 1b66a0fc15ba836a7f2636a837b6f22dbd3d6581..546a92c80edcd46510321c604e9e049467ae79a5 100644 (file)
@@ -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();
 
index 1f14e9ce62e2bf51e8b55c6860d3b9e4dd2cc029..78cfe28e454c535bac20edf328d5f30f3338c436 100644 (file)
@@ -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 \