Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wheelmouse.cc File Reference
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <Xm/Xm.h>
#include <Xm/ScrollBar.h>
Include dependency graph for wheelmouse.cc:

Go to the source code of this file.

Functions

static void mouseScroll (Widget, XtPointer client_data, XEvent *event)
 
void xmAddMouseEventHandler (Widget w)
 

Function Documentation

static void mouseScroll ( Widget  ,
XtPointer  client_data,
XEvent *  event 
)
static

Definition at line 57 of file wheelmouse.cc.

58 {
59  Widget sb = (Widget)client_data;
60  int value_return = 0;
61  int slider_size_return = 0;
62  int increment_return = 0;
63  int page_increment_return = 0;
64  int count;
65  int step;
66 
67  /* get a few value regarding the scrollbar conf. */
68  XmScrollBarGetValues (sb, &value_return, &slider_size_return,
69  &increment_return, &page_increment_return);
70 
71  /* calculate the step wide according to the pressed keys */
72  if ( event->xbutton.state & ShiftMask )
73  {
74  step = 1;
75  }
76  else if ( event->xbutton.state & ControlMask )
77  {
78  step = page_increment_return;
79  }
80  else
81  {
82  step = page_increment_return >> 1;
83  }
84 
85  if ( event->xbutton.button == Button4 )
86  {
87  value_return -= step;
88  if ( value_return < 0 )
89  value_return = 0;
90  }
91  else if ( event->xbutton.button == Button5 )
92  {
93  /* and the max value for increment */
94  XtVaGetValues(sb, XmNmaximum, &count, NULL);
95  value_return += step;
96  if ( value_return > count - slider_size_return )
97  value_return = count - slider_size_return;
98  }
99 
100  /* finally perform scrolling with the calculated step */
101  if ( event->xbutton.button == Button4 ||
102  event->xbutton.button == Button5 )
103  {
104  XmScrollBarSetValues (sb, value_return, slider_size_return,
105  increment_return, page_increment_return, True);
106  }
107 }

Here is the caller graph for this function:

void xmAddMouseEventHandler ( Widget  w)

Definition at line 125 of file wheelmouse.cc.

126 {
127  Widget wid;
128 
129  /* we need to pass the scrollbar widget to the handler */
130  XtVaGetValues(XtParent(w),XmNverticalScrollBar, &wid, NULL);
131 
132  /* handler for the scrolledList/ScrolledText */
133  XtAddEventHandler(w, ButtonReleaseMask, False,
134  (XtEventHandler) mouseScroll, wid);
135  /* and for the scrollbar itself */
136  XtAddEventHandler(wid, ButtonReleaseMask, False,
137  (XtEventHandler) mouseScroll, wid);
138 }
static void mouseScroll(Widget, XtPointer client_data, XEvent *event)
Definition: wheelmouse.cc:57

Here is the call graph for this function: