Author: bgbnbigben
Date: 2011-01-25 07:44:40 -0800 (Tue, 25 Jan 2011)
New Revision: 8313
Log:
Added in horizontal scrolling for Linux (STR #1964). Note that this modifies 
the enumerations in fltk/events.h to add WheelUp, WheelDown, WheelLeft and 
WheelRight.
Modified src/TextDisplay.cxx, src/Browser.cxx and src/ScrollGroup.cxx to have 
them work properly with horizontal scrolling.


Modified:
   trunk/fltk/events.h
   trunk/src/Browser.cxx
   trunk/src/ScrollGroup.cxx
   trunk/src/TextDisplay.cxx
   trunk/src/x11/run.cxx

Modified: trunk/fltk/events.h
===================================================================
--- trunk/fltk/events.h 2011-01-25 00:20:49 UTC (rev 8312)
+++ trunk/fltk/events.h 2011-01-25 15:44:40 UTC (rev 8313)
@@ -81,9 +81,13 @@
   buttons on Windows.
 */
 enum {
-  LeftButton   = 1,            /*!< PUSH/RELEASE set event_key to this */
-  MiddleButton = 2,            /*!< PUSH/RELEASE set event_key to this */
-  RightButton  = 3,            /*!< PUSH/RELEASE set event_key to this */
+  LeftButton   = 1,            /*!< PUSH/RELEASE sets event_key to this */
+  MiddleButton = 2,            /*!< PUSH/RELEASE sets event_key to this */
+  RightButton  = 3,            /*!< PUSH/RELEASE sets event_key to this */
+  WheelUp      = 4,            /*!< MOUSEWHEEL sets event_key to this */
+  WheelDown    = 5,            /*!< MOUSEWHEEL sets event_key to this */
+  WheelLeft    = 6,            /*!< MOUSEWHEEL sets event_key to this */
+  WheelRight   = 7,            /*!< MOUSEWHEEL sets event_key to this */
   SpaceKey     = 32,           /*!< Same as ' ' or 32 */
   // 'a'-'z', and all punctuation go here in numerical order
   BackSpaceKey = 0xff08,       /*!< Backspace */

Modified: trunk/src/Browser.cxx
===================================================================
--- trunk/src/Browser.cxx       2011-01-25 00:20:49 UTC (rev 8312)
+++ trunk/src/Browser.cxx       2011-01-25 15:44:40 UTC (rev 8313)
@@ -1475,7 +1475,7 @@
     break;
 
   case MOUSEWHEEL:
-    if (event_dx()) hscrollbar.send(event);
+    if (event_key() == WheelLeft || event_key() == WheelRight) return 
hscrollbar.send(event);
     return scrollbar.send(event);
 #if 0
     int n = event_dy() * Style::wheel_scroll_lines;

Modified: trunk/src/ScrollGroup.cxx
===================================================================
--- trunk/src/ScrollGroup.cxx   2011-01-25 00:20:49 UTC (rev 8312)
+++ trunk/src/ScrollGroup.cxx   2011-01-25 15:44:40 UTC (rev 8313)
@@ -505,8 +505,11 @@
     {
       if ( (scrollbar.visible()||hscrollbar.visible())
            && !fltk::event_state( fltk::ALT ) ) {
-        hscrollbar.send(event);
-        return scrollbar.send(event);
+        if (event_key() == WheelLeft || event_key() == WheelRight) {
+          return hscrollbar.send(event);
+        } else {
+          return scrollbar.send(event);
+       }
       } else {
         return Group::handle( event );
       }

Modified: trunk/src/TextDisplay.cxx
===================================================================
--- trunk/src/TextDisplay.cxx   2011-01-25 00:20:49 UTC (rev 8312)
+++ trunk/src/TextDisplay.cxx   2011-01-25 15:44:40 UTC (rev 8313)
@@ -2231,6 +2231,7 @@
   if (longestvline==0) longestvline = longest_vline();
   int sliderMax = max(longestvline, text_area.w() + horiz_offset_);
   hscrollbar->value(horiz_offset_, text_area.w(), 0, sliderMax);
+  hscrollbar->linesize(3);
   /*if (longestvline < text_area.w()) {
     hscrollbar->deactivate();
   } else {
@@ -3106,7 +3107,11 @@
   }
 
   case MOUSEWHEEL:
-    return vscrollbar->handle(event);
+    if (event_key() == WheelUp || event_key() == WheelDown) {
+      return vscrollbar->handle(event);
+    } else {
+      return hscrollbar->handle(event);
+    }
 
   case FOCUS:
   case UNFOCUS:

Modified: trunk/src/x11/run.cxx
===================================================================
--- trunk/src/x11/run.cxx       2011-01-25 00:20:49 UTC (rev 8312)
+++ trunk/src/x11/run.cxx       2011-01-25 15:44:40 UTC (rev 8313)
@@ -1243,6 +1243,8 @@
 
 static unsigned wheel_up_button = 4;
 static unsigned wheel_down_button = 5;
+static unsigned wheel_left_button = 6;
+static unsigned wheel_right_button = 7;
 
 int fl_actual_keysym;
 
@@ -1515,6 +1517,12 @@
     } else if (n == wheel_down_button) {
       e_dy = +1;
       event = MOUSEWHEEL;
+    } else if (n == wheel_left_button) {
+      e_dx = -1;
+      event = MOUSEWHEEL;
+    } else if (n == wheel_right_button) {
+      e_dx = +1;
+      event = MOUSEWHEEL;
     } else {
       // turn off is_click if enough time or mouse movement has passed:
       if (e_is_click == e_keysym) {
@@ -1545,7 +1553,7 @@
     unsigned n = xevent.xbutton.button;
     e_keysym = n;
     set_event_xy(false);
-    //if (n == wheel_up_button || n == wheel_down_button) break;
+    if (n == wheel_up_button || n == wheel_down_button || n == 
wheel_left_button || n == wheel_right_button) return 1;
     e_state &= ~BUTTON(n);
     event = RELEASE;}
     set_stylus_data();

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to