diff options
Diffstat (limited to 'Handlers.c')
-rw-r--r-- | Handlers.c | 302 |
1 files changed, 151 insertions, 151 deletions
@@ -33,7 +33,7 @@ from The Open Group. #include <X11/IntrinsicP.h> #include <X11/StringDefs.h> #include "BitmapP.h" - + #include <stdio.h> #include <math.h> @@ -52,10 +52,10 @@ from The Open Group. (InBitmapY(BW, y) == (square_y))) -static void -DragOnePointHandler(Widget w, - XtPointer client_data, - XEvent *event, +static void +DragOnePointHandler(Widget w, + XtPointer client_data, + XEvent *event, Boolean *cont) /* ARGSUSED */ { BWStatus *status = (BWStatus *)client_data; @@ -65,7 +65,7 @@ DragOnePointHandler(Widget w, fprintf(stderr, "D1PH "); switch (event->type) { - + case ButtonPress: if (event->xbutton.state != status->state) return; if (!QuerySet(status->at_x, status->at_y)) { @@ -80,7 +80,7 @@ DragOnePointHandler(Widget w, status->at_x, status->at_y, status->value); } break; - + case ButtonRelease: if (QuerySet(status->at_x, status->at_y)) { status->value = Value(BW, event->xbutton.button); @@ -89,7 +89,7 @@ DragOnePointHandler(Widget w, status->at_y = InBitmapY(BW, event->xbutton.y); status->success = status->draw ? True : False; /* SUPPRESS 701 */ - BWTerminateRequest(w, TRUE); + BWTerminateRequest(w, TRUE); } break; @@ -109,56 +109,56 @@ DragOnePointHandler(Widget w, } } -void -DragOnePointEngage(Widget w, - BWStatus *status, - XtPointer draw, +void +DragOnePointEngage(Widget w, + BWStatus *status, + XtPointer draw, int *state) { - + status->at_x = NotSet; status->at_y = NotSet; status->draw = draw; status->success = False; status->state = *state; - + XtAddEventHandler(w, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, FALSE, DragOnePointHandler, (XtPointer)status); } /* ARGSUSED */ -void -DragOnePointTerminate(Widget w, - BWStatus *status, +void +DragOnePointTerminate(Widget w, + BWStatus *status, XtPointer draw) { - + if (status->success) { BWChangeNotify(w); BWSetChanged(w); } - + XtRemoveEventHandler(w, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, FALSE, DragOnePointHandler, (XtPointer)status); - + } -void -OnePointHandler(Widget w, - XtPointer client_data, - XEvent *event, +void +OnePointHandler(Widget w, + XtPointer client_data, + XEvent *event, Boolean *cont) /* ARGSUSED */ { BWStatus *status = (BWStatus *)client_data; BitmapWidget BW = (BitmapWidget) w; - + if (DEBUG) fprintf(stderr, "1PH "); switch (event->type) { - + case Expose: if (QuerySet(status->at_x, status->at_y)) { BWClip(w, event->xexpose.x, event->xexpose.y, @@ -166,11 +166,11 @@ OnePointHandler(Widget w, if (status->draw) (*(DrawOnePointProc)status->draw)(w, status->at_x, status->at_y, Highlight); - + BWUnclip(w); } break; - + case ButtonPress: if (event->xbutton.state != status->state) return; if (!QuerySet(status->at_x, status->at_y)) { @@ -183,23 +183,23 @@ OnePointHandler(Widget w, status->at_x, status->at_y, Highlight); } break; - + case ButtonRelease: if (QuerySet(status->at_x, status->at_y)) { if (status->draw) (*(DrawOnePointProc)status->draw)(w, status->at_x, status->at_y, Highlight); - + status->value = Value(BW, event->xbutton.button); status->btime = event->xbutton.time; status->at_x = InBitmapX(BW, event->xbutton.x); status->at_y = InBitmapY(BW, event->xbutton.y); status->success = True; - + BWTerminateRequest(w, TRUE); } break; - + case MotionNotify: if (QuerySet(status->at_x, status->at_y)) { if (!QueryInSquare(BW, event->xmotion.x, event->xmotion.y, @@ -213,15 +213,15 @@ OnePointHandler(Widget w, (*(DrawOnePointProc)status->draw)(w, status->at_x, status->at_y, Highlight); } - } + } break; } } -void -OnePointEngage(Widget w, - BWStatus *status, - XtPointer draw, +void +OnePointEngage(Widget w, + BWStatus *status, + XtPointer draw, int *state) { status->at_x = NotSet; @@ -231,16 +231,16 @@ OnePointEngage(Widget w, status->state = *state; XtAddEventHandler(w, - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask, FALSE, OnePointHandler, (XtPointer)status); } #if 0 -void -OnePointImmediateEngage(Widget w, - BWStatus *status, - XtPointer draw, +void +OnePointImmediateEngage(Widget w, + BWStatus *status, + XtPointer draw, int *state) { status->at_x = 0; @@ -248,24 +248,24 @@ OnePointImmediateEngage(Widget w, status->draw = draw; status->success = False; status->state = *state; - + if (status->draw) (*(DrawOnePointProc)status->draw)(w, status->at_x, status->at_y, Highlight); - + XtAddEventHandler(w, - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask, FALSE, OnePointHandler, (XtPointer)status); } #endif -void -OnePointTerminate(Widget w, - BWStatus *status, +void +OnePointTerminate(Widget w, + BWStatus *status, XtPointer draw) { - + if (status->success && draw) { BWStoreToBuffer(w); (*(DrawOnePointProc)draw)(w, @@ -273,25 +273,25 @@ OnePointTerminate(Widget w, status->value); BWChangeNotify(w); BWSetChanged(w); - } + } else if (QuerySet(status->at_x, status->at_y)) if (status->draw) (*(DrawOnePointProc)status->draw)(w, status->at_x, status->at_y, Highlight); - + XtRemoveEventHandler(w, - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask, FALSE, OnePointHandler, (XtPointer)status); } -void -OnePointTerminateTransparent(Widget w, - BWStatus *status, +void +OnePointTerminateTransparent(Widget w, + BWStatus *status, XtPointer draw) { - + if (status->success && draw) (*(DrawOnePointProc)draw)(w, status->at_x, status->at_y, @@ -301,41 +301,41 @@ OnePointTerminateTransparent(Widget w, if (status->draw) (*(DrawOnePointProc)status->draw)(w, status->at_x, status->at_y, Highlight); - + XtRemoveEventHandler(w, - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask, FALSE, OnePointHandler, (XtPointer)status); - + } -void -TwoPointsHandler(Widget w, - XtPointer client_data, - XEvent *event, +void +TwoPointsHandler(Widget w, + XtPointer client_data, + XEvent *event, Boolean *cont) /* ARGSUSED */ { BitmapWidget BW = (BitmapWidget) w; BWStatus *status = (BWStatus *)client_data; if (DEBUG) fprintf(stderr, "2PH "); - + switch (event->type) { - + case Expose: - if (QuerySet(status->from_x, status->from_y) && + if (QuerySet(status->from_x, status->from_y) && QuerySet(status->to_x, status->to_y)) { BWClip(w, event->xexpose.x, event->xexpose.y, event->xexpose.width, event->xexpose.height); if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, Highlight); BWUnclip(w); } break; - + case ButtonPress: if (event->xbutton.state != status->state) return; if (!QuerySet(status->from_x, status->from_y)) { @@ -347,27 +347,27 @@ TwoPointsHandler(Widget w, status->to_y = InBitmapY(BW, event->xbutton.y); if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, Highlight); } break; - + case ButtonRelease: if (QuerySet(status->from_x, status->from_y)) { if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, Highlight); status->value = Value(BW, event->xbutton.button); - status->btime = event->xbutton.time; + status->btime = event->xbutton.time; status->to_x = InBitmapX(BW, event->xbutton.x); status->to_y = InBitmapY(BW, event->xbutton.y); status->success = True; - + BWTerminateRequest(w, TRUE); } break; - + case MotionNotify: if (QuerySet(status->from_x, status->from_y)) { if (QuerySet(status->to_x, status->to_y)) { @@ -375,13 +375,13 @@ TwoPointsHandler(Widget w, status->to_x, status->to_y)) { if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, Highlight); status->to_x = InBitmapX(BW, event->xmotion.x); status->to_y = InBitmapY(BW, event->xmotion.y); if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, Highlight); } } @@ -390,7 +390,7 @@ TwoPointsHandler(Widget w, status->to_y = InBitmapY(BW, event->xmotion.y); if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, Highlight); } } @@ -398,13 +398,13 @@ TwoPointsHandler(Widget w, } } -void -TwoPointsEngage(Widget w, - BWStatus *status, - XtPointer draw, +void +TwoPointsEngage(Widget w, + BWStatus *status, + XtPointer draw, int *state) { - + status->from_x = NotSet; status->from_y = NotSet; status->to_x = NotSet; @@ -414,17 +414,17 @@ TwoPointsEngage(Widget w, status->state = *state; XtAddEventHandler(w, - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask, FALSE, TwoPointsHandler, (XtPointer)status); } -void -TwoPointsTerminate(Widget w, - BWStatus *status, +void +TwoPointsTerminate(Widget w, + BWStatus *status, XtPointer draw) { - + if (status->success && draw) { BWStoreToBuffer(w); (*(DrawTwoPointProc)draw)(w, @@ -435,126 +435,126 @@ TwoPointsTerminate(Widget w, BWSetChanged(w); } else - if (QuerySet(status->from_x, status->from_y) && + if (QuerySet(status->from_x, status->from_y) && QuerySet(status->to_x, status->to_y)) if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, Highlight); - + XtRemoveEventHandler(w, - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask, FALSE, TwoPointsHandler, (XtPointer)status); } -void -TwoPointsTerminateTransparent(Widget w, - BWStatus *status, +void +TwoPointsTerminateTransparent(Widget w, + BWStatus *status, XtPointer draw) { - + if (status->success && draw) (*(DrawTwoPointProc)draw)(w, status->from_x, status->from_y, status->to_x, status->to_y, status->value); else - if (QuerySet(status->from_x, status->from_y) && + if (QuerySet(status->from_x, status->from_y) && QuerySet(status->to_x, status->to_y)) if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, Highlight); - + XtRemoveEventHandler(w, - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask, FALSE, TwoPointsHandler, (XtPointer)status); } -void -TwoPointsTerminateTimed(Widget w, - BWStatus *status, +void +TwoPointsTerminateTimed(Widget w, + BWStatus *status, XtPointer draw) { - + if (status->success && draw) (*(DrawTwoPointProc)draw)(w, status->from_x, status->from_y, status->to_x, status->to_y, status->btime); else - if (QuerySet(status->from_x, status->from_y) && + if (QuerySet(status->from_x, status->from_y) && QuerySet(status->to_x, status->to_y)) if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, Highlight); - + XtRemoveEventHandler(w, - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask, FALSE, TwoPointsHandler, (XtPointer)status); } /* ARGSUSED */ -void -Interface(Widget w, - BWStatus *status, +void +Interface(Widget w, + BWStatus *status, XtPointer action) { (*(InterfaceProc)action)(w); } -void -Paste(Widget w, - Position at_x, - Position at_y, +void +Paste(Widget w, + Position at_x, + Position at_y, int value) { BitmapWidget BW = (BitmapWidget) w; BWStatus *my_status; BWRequest request; - my_status = (BWStatus *) + my_status = (BWStatus *) BW->bitmap.request_stack[BW->bitmap.current].status; my_status->draw = NULL; request = (BWRequest) BW->bitmap.request_stack[BW->bitmap.current].request->terminate_client_data; - + BWTerminateRequest(w, FALSE); - + if ((at_x == max(BW->bitmap.mark.from_x, min(at_x, BW->bitmap.mark.to_x))) && (at_y == max(BW->bitmap.mark.from_y, min(at_y, BW->bitmap.mark.to_y)))) { - + BWStatus *status; - + if (DEBUG) fprintf(stderr, "Prepaste request: %s\n", request); - + BWEngageRequest(w, request, False, (char *)&(my_status->state), sizeof(int)); - - status = (BWStatus *) + + status = (BWStatus *) BW->bitmap.request_stack[BW->bitmap.current].status; - + status->at_x = at_x; status->at_y = at_y; status->value = value; - (*(DrawOnePointProc)status->draw) (w, at_x, at_y, Highlight); + (*(DrawOnePointProc)status->draw) (w, at_x, at_y, Highlight); } else { BWStatus *status; - + BWEngageRequest(w, MarkRequest, False, (char *)&(my_status->state), sizeof(int)); - - status = (BWStatus *) + + status = (BWStatus *) BW->bitmap.request_stack[BW->bitmap.current].status; - + status->from_x = status->to_x = at_x; status->from_y = status->to_y = at_y; status->value = value; @@ -563,10 +563,10 @@ Paste(Widget w, } -void -DragTwoPointsHandler(Widget w, - XtPointer client_data, - XEvent *event, +void +DragTwoPointsHandler(Widget w, + XtPointer client_data, + XEvent *event, Boolean *cont) /* ARGSUSED */ { BitmapWidget BW = (BitmapWidget) w; @@ -576,7 +576,7 @@ DragTwoPointsHandler(Widget w, fprintf(stderr, "D2PH "); switch (event->type) { - + case ButtonPress: if (event->xbutton.state != status->state) return; if (!QuerySet(status->from_x, status->from_y)) { @@ -590,25 +590,25 @@ DragTwoPointsHandler(Widget w, status->success = status->draw ? True : False; if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, status->value); } break; - + case ButtonRelease: if (QuerySet(status->from_x, status->from_y)) { status->value = Value(BW, event->xbutton.button); - status->btime = event->xbutton.time; + status->btime = event->xbutton.time; status->from_x = status->to_x; status->from_y = status->to_y; status->to_x = InBitmapX(BW, event->xbutton.x); status->to_y = InBitmapY(BW, event->xbutton.y); status->success = True; - + BWTerminateRequest(w, TRUE); } break; - + case MotionNotify: if (QuerySet(status->from_x, status->from_y)) { if (QuerySet(status->to_x, status->to_y)) { @@ -620,7 +620,7 @@ DragTwoPointsHandler(Widget w, status->to_y = InBitmapY(BW, event->xmotion.y); if (status->draw) (*(DrawTwoPointProc)status->draw)(w, - status->from_x, status->from_y, + status->from_x, status->from_y, status->to_x, status->to_y, status->value); } } @@ -629,13 +629,13 @@ DragTwoPointsHandler(Widget w, } } -void -DragTwoPointsEngage(Widget w, - BWStatus *status, - XtPointer draw, +void +DragTwoPointsEngage(Widget w, + BWStatus *status, + XtPointer draw, int *state) { - + status->from_x = NotSet; status->from_y = NotSet; status->to_x = NotSet; @@ -649,15 +649,15 @@ DragTwoPointsEngage(Widget w, FALSE, DragTwoPointsHandler, (XtPointer)status); } -void -DragTwoPointsTerminate(Widget w, - BWStatus *status, +void +DragTwoPointsTerminate(Widget w, + BWStatus *status, XtPointer draw) { - + if (status->success && draw) { - if ((status->from_x != status->to_x) - || + if ((status->from_x != status->to_x) + || (status->from_y != status->to_y)) (*(DrawTwoPointProc)draw)(w, status->from_x, status->from_y, @@ -666,7 +666,7 @@ DragTwoPointsTerminate(Widget w, BWChangeNotify(w); BWSetChanged(w); } - + XtRemoveEventHandler(w, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, FALSE, DragTwoPointsHandler, (XtPointer)status); |