On Tue, Sep 12, 2000 at 12:55:38PM -0700, Jonathan Lim wrote:
> On Mon Sep 11 12:51:11 2000, Nico.Schmidt@xxxxxxxxxx wrote:
> >
> > Hi,
> > I have added some lines of code to the ThumbWheel widget to support wheel
> > events which are mapped to Button 4 & 5. It's kind of static in this sense
> > but it's a first shot and just nice :-). Anyone interested ?
> >
> > patch inventor/libSoXt/src/viewers/Sgm/ThumbWheel.c thumbwheel.patch
>
> Looks reasonable, but as I thought about the possibility of adding a resource
> to specify the number that user_pixels changes by (rather than the hardcoded
> 10), I noticed that it would require changing the SgThumbWheelPart structure.
> I'm wondering if this will cause compatibility problems (doesn't seem like it
> would, because the application only sees it as a generic Widget type).
>
>
Good idea, let's try it :
Index: ThumbWheel.c
===================================================================
RCS file: /cvs/inventor/libSoXt/src/viewers/Sgm/ThumbWheel.c,v
retrieving revision 1.2
diff -r1.2 ThumbWheel.c
185a186,194
> {
> SgNwheelDelta,
> SgCwheelDelta,
> XmRInt,
> sizeof(int),
> OFFSET(thumbWheel.wheel_delta),
> XmRImmediate,
> (XtPointer)10,
> },
340a350,351
> <Btn4Down>: PageUp() \n\
> <Btn5Down>: PageDown() \n\
363a375,376
> {"Btn4Down", PageUp},
> {"Btn5Down", PageDown},
467a481
>
957a972
>
1250c1265,1288
< /* fprintf(stderr, "PageUp\n");*/
---
> SgThumbWheelWidget thumb = (SgThumbWheelWidget) wid;
> XMotionEvent *xmotion = (XMotionEvent *)event;
> int old_value = thumb->thumbWheel.value;
> int new_value;
> int decrement = thumb->thumbWheel.wheel_delta;
>
> thumb->thumbWheel.user_pixels -= decrement;
> new_value = ConvertPixelsToUserUnits(thumb, thumb->thumbWheel.user_pixels);
> thumb->thumbWheel.value = new_value;
>
> /*
> * Change the current pixmap to reflect "spinning" the wheel.
> */
> if( new_value != old_value) {
> SetCurrentPixmap(thumb, (new_value > old_value));
> Redisplay((Widget)thumb, NULL, NULL);
> }
>
> /*
> * Issue the dragCallback with the new value, if changed.
> */
> if (new_value != old_value) {
> IssueCallback(thumb, XmCR_DRAG, thumb->thumbWheel.value, event);
> }
1260c1298,1321
< /* fprintf(stderr, "PageDown\n");*/
---
> SgThumbWheelWidget thumb = (SgThumbWheelWidget) wid;
> XMotionEvent *xmotion = (XMotionEvent *)event;
> int old_value = thumb->thumbWheel.value;
> int new_value;
> int increment = thumb->thumbWheel.wheel_delta;
>
> thumb->thumbWheel.user_pixels += increment;
> new_value = ConvertPixelsToUserUnits(thumb, thumb->thumbWheel.user_pixels);
> thumb->thumbWheel.value = new_value;
>
> /*
> * Change the current pixmap to reflect "spinning" the wheel.
> */
> if( new_value != old_value) {
> SetCurrentPixmap(thumb, (new_value > old_value));
> Redisplay((Widget)thumb, NULL, NULL);
> }
>
> /*
> * Issue the dragCallback with the new value, if changed.
> */
> if (new_value != old_value) {
> IssueCallback(thumb, XmCR_DRAG, thumb->thumbWheel.value, event);
> }
Index: ThumbWheel.h
===================================================================
RCS file: /cvs/inventor/libSoXt/src/viewers/Sgm/ThumbWheel.h,v
retrieving revision 1.1.1.1
diff -r1.1.1.1 ThumbWheel.h
73a74,76
> #ifndef SgNwheelDelta
> #define SgNwheelDelta "wheelDelta"
> #endif
99a103,105
> #endif
> #ifndef SgCwheelDelta
> #define SgCwheelDelta "wheelDelta"
Index: ThumbWheelP.h
===================================================================
RCS file: /cvs/inventor/libSoXt/src/viewers/Sgm/ThumbWheelP.h,v
retrieving revision 1.1.1.1
diff -r1.1.1.1 ThumbWheelP.h
118a119,120
> int wheel_delta;
>
--
Nico Schmidt IPK/IWF eMail : nico.schmidt@xxxxxxxxxx
Sekr. PTZ 4, Pascalstr. 8-9 Phone : +49-30-39006342
D-10587 Berlin
|