]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/XWorkArea.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / XWorkArea.C
index 56d9fc7d3af1c32e1b74054baf86a6a7f55264ab..3d66aaf7222bfee7cab58746116e1afefa3a6de6 100644 (file)
@@ -1,10 +1,12 @@
 /**
  * \file XWorkArea.C
- * Copyright 1995-2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author unknown
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon 
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
@@ -18,6 +20,7 @@
 #include "LyXView.h"
 #include "XLyXKeySym.h"
 #include "ColorHandler.h"
+#include "funcrequest.h"
 
 #if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
 #include "lyxlookup.h"
@@ -37,6 +40,7 @@ FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
 using std::endl;
 using std::abs;
 using std::hex;
+using std::dec;
 
 namespace {
 
@@ -269,7 +273,7 @@ void XWorkArea::redraw(int width, int height)
                                       width,
                                       height,
                                       fl_get_visual_depth());
+
        workAreaResize();
 }
 
@@ -326,12 +330,12 @@ void XWorkArea::scroll_cb()
 
 
 int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
-                               FL_Coord, FL_Coord ,
+                               FL_Coord, FL_Coord,
                                int key, void * xev)
 {
        static int x_old = -1;
        static int y_old = -1;
-       static long scrollbar_value_old = -1;
+       static double scrollbar_value_old = -1.0;
 
        XEvent * ev = static_cast<XEvent*>(xev);
        XWorkArea * area = static_cast<XWorkArea*>(ob->u_vdata);
@@ -350,24 +354,27 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
                if (!ev || ev->xbutton.button == 0) break;
                // Should really have used xbutton.state
                lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl;
-               area->workAreaButtonPress(ev->xbutton.x - ob->x,
-                                         ev->xbutton.y - ob->y,
-                                         x_button_state(ev->xbutton.button));
+               area->dispatch(
+                       FuncRequest(LFUN_MOUSE_PRESS, ev->xbutton.x - ob->x,
+                                                       ev->xbutton.y - ob->y,
+                                                       x_button_state(ev->xbutton.button)));
                break;
        case FL_RELEASE:
                if (!ev || ev->xbutton.button == 0) break;
                // Should really have used xbutton.state
                lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl;
-               area->workAreaButtonRelease(ev->xbutton.x - ob->x,
-                                     ev->xbutton.y - ob->y,
-                                     x_button_state(ev->xbutton.button));
+               area->dispatch(
+                       FuncRequest(LFUN_MOUSE_RELEASE, ev->xbutton.x - ob->x,
+                                                       ev->xbutton.y - ob->y,
+                                                       x_button_state(ev->xbutton.button)));
                break;
 #if FL_VERSION < 1 && FL_REVISION < 89
        case FL_MOUSE:
 #else
        case FL_DRAG:
 #endif
-               if (!ev || ! area->scrollbar) break;
+               if (!ev || !area->scrollbar)
+                       break;
                if (ev->xmotion.x != x_old ||
                    ev->xmotion.y != y_old ||
                    fl_get_scrollbar_value(area->scrollbar) != scrollbar_value_old
@@ -376,9 +383,10 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
                        y_old = ev->xmotion.y;
                        scrollbar_value_old = fl_get_scrollbar_value(area->scrollbar);
                        lyxerr[Debug::WORKAREA] << "Workarea event: MOUSE" << endl;
-                       area->workAreaMotionNotify(ev->xmotion.x - ob->x,
-                                            ev->xmotion.y - ob->y,
-                                            x_motion_state(ev->xbutton.state));
+                       area->dispatch(
+                               FuncRequest(LFUN_MOUSE_MOTION, ev->xbutton.x - ob->x,
+                                                               ev->xbutton.y - ob->y,
+                                                               x_button_state(ev->xbutton.button)));
                }
                break;
 #if FL_VERSION < 1 && FL_REVISION < 89
@@ -509,22 +517,26 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
                lyxerr[Debug::WORKAREA] << "Workarea event: LEAVE" << endl;
                break;
        case FL_DBLCLICK:
-               if (!ev) break;
-               lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl;
-               area->workAreaDoubleClick(ev->xbutton.x - ob->x,
-                                         ev->xbutton.y - ob->y,
-                                         x_button_state(ev->xbutton.button));
+               if (ev) {
+                       lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl;
+                       FuncRequest cmd(LFUN_MOUSE_DOUBLE, ev->xbutton.x - ob->x,
+                                                       ev->xbutton.y - ob->y,
+                                                       x_button_state(ev->xbutton.button));
+                       area->dispatch(cmd);
+               }
                break;
        case FL_TRPLCLICK:
-               if (!ev) break;
-               lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl;
-               area->workAreaTripleClick(ev->xbutton.x - ob->x,
-                                         ev->xbutton.y - ob->y,
-                                         x_button_state(ev->xbutton.button));
+               if (ev) {
+                       lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl;
+                       FuncRequest cmd(LFUN_MOUSE_TRIPLE, ev->xbutton.x - ob->x,
+                                                       ev->xbutton.y - ob->y,
+                                                       x_button_state(ev->xbutton.button));
+                       area->dispatch(cmd);
+               }
                break;
        case FL_OTHER:
-               if (!ev) break;
-               lyxerr[Debug::WORKAREA] << "Workarea event: OTHER" << endl;
+               if (ev)
+                       lyxerr[Debug::WORKAREA] << "Workarea event: OTHER" << endl;
                break;
        }