Mercurial > vim
comparison src/gui_at_sb.c @ 18781:79e10adc821d v8.1.2380
patch 8.1.2380: using old C style comments
Commit: https://github.com/vim/vim/commit/306139005c31ea7e6f892dd119beba3c94dcb982
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 1 22:11:18 2019 +0100
patch 8.1.2380: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Dec 2019 22:15:03 +0100 |
parents | 55ccc2d353bd |
children |
comparison
equal
deleted
inserted
replaced
18780:04ce3b8a50ed | 18781:79e10adc821d |
---|---|
54 OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | 54 OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
55 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 55 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
56 | 56 |
57 */ | 57 */ |
58 | 58 |
59 /* ScrollBar.c */ | 59 // ScrollBar.c |
60 /* created by weissman, Mon Jul 7 13:20:03 1986 */ | 60 // created by weissman, Mon Jul 7 13:20:03 1986 |
61 /* converted by swick, Thu Aug 27 1987 */ | 61 // converted by swick, Thu Aug 27 1987 |
62 | 62 |
63 #include "vim.h" | 63 #include "vim.h" |
64 | 64 |
65 #include <X11/IntrinsicP.h> | 65 #include <X11/IntrinsicP.h> |
66 #include <X11/StringDefs.h> | 66 #include <X11/StringDefs.h> |
68 #include <X11/Xaw/XawInit.h> | 68 #include <X11/Xaw/XawInit.h> |
69 #include "gui_at_sb.h" | 69 #include "gui_at_sb.h" |
70 | 70 |
71 #include <X11/Xmu/Drawing.h> | 71 #include <X11/Xmu/Drawing.h> |
72 | 72 |
73 /* Private definitions. */ | 73 // Private definitions. |
74 | 74 |
75 static char defaultTranslations[] = | 75 static char defaultTranslations[] = |
76 "<Btn1Down>: NotifyScroll()\n\ | 76 "<Btn1Down>: NotifyScroll()\n\ |
77 <Btn2Down>: MoveThumb() NotifyThumb()\n\ | 77 <Btn2Down>: MoveThumb() NotifyThumb()\n\ |
78 <Btn3Down>: NotifyScroll()\n\ | 78 <Btn3Down>: NotifyScroll()\n\ |
162 }; | 162 }; |
163 | 163 |
164 | 164 |
165 ScrollbarClassRec vim_scrollbarClassRec = | 165 ScrollbarClassRec vim_scrollbarClassRec = |
166 { | 166 { |
167 { /* core fields */ | 167 { // core fields |
168 /* superclass */ (WidgetClass) &simpleClassRec, | 168 /* superclass */ (WidgetClass) &simpleClassRec, |
169 /* class_name */ "Scrollbar", | 169 /* class_name */ "Scrollbar", |
170 /* size */ sizeof(ScrollbarRec), | 170 /* size */ sizeof(ScrollbarRec), |
171 /* class_initialize */ ClassInitialize, | 171 /* class_initialize */ ClassInitialize, |
172 /* class_part_init */ NULL, | 172 /* class_part_init */ NULL, |
196 /* tm_table */ defaultTranslations, | 196 /* tm_table */ defaultTranslations, |
197 /* query_geometry */ XtInheritQueryGeometry, | 197 /* query_geometry */ XtInheritQueryGeometry, |
198 /* display_accelerator*/ XtInheritDisplayAccelerator, | 198 /* display_accelerator*/ XtInheritDisplayAccelerator, |
199 /* extension */ NULL | 199 /* extension */ NULL |
200 }, | 200 }, |
201 { /* simple fields */ | 201 { // simple fields |
202 /* change_sensitive */ XtInheritChangeSensitive, | 202 /* change_sensitive */ XtInheritChangeSensitive, |
203 #ifndef OLDXAW | 203 #ifndef OLDXAW |
204 /* extension */ NULL | 204 /* extension */ NULL |
205 #endif | 205 #endif |
206 }, | 206 }, |
207 { /* scrollbar fields */ | 207 { // scrollbar fields |
208 /* empty */ 0 | 208 /* empty */ 0 |
209 } | 209 } |
210 }; | 210 }; |
211 | 211 |
212 WidgetClass vim_scrollbarWidgetClass = (WidgetClass)&vim_scrollbarClassRec; | 212 WidgetClass vim_scrollbarWidgetClass = (WidgetClass)&vim_scrollbarClassRec; |
238 Position top, | 238 Position top, |
239 Position bottom, | 239 Position bottom, |
240 int fill, | 240 int fill, |
241 int draw_shadow) | 241 int draw_shadow) |
242 { | 242 { |
243 int tlen = bottom - top; /* length of thumb in pixels */ | 243 int tlen = bottom - top; // length of thumb in pixels |
244 int sw, margin, floor; | 244 int sw, margin, floor; |
245 int lx, ly, lw, lh; | 245 int lx, ly, lw, lh; |
246 | 246 |
247 if (bottom <= 0 || bottom <= top) | 247 if (bottom <= 0 || bottom <= top) |
248 return; | 248 return; |
271 | 271 |
272 if (draw_shadow) | 272 if (draw_shadow) |
273 { | 273 { |
274 if (!(sbw->scrollbar.orientation == XtorientHorizontal)) | 274 if (!(sbw->scrollbar.orientation == XtorientHorizontal)) |
275 { | 275 { |
276 /* Top border */ | 276 // Top border |
277 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 277 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
278 sbw->scrollbar.top_shadow_GC, | 278 sbw->scrollbar.top_shadow_GC, |
279 lx, ly, lx + lw - 1, ly); | 279 lx, ly, lx + lw - 1, ly); |
280 | 280 |
281 /* Bottom border */ | 281 // Bottom border |
282 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 282 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
283 sbw->scrollbar.bot_shadow_GC, | 283 sbw->scrollbar.bot_shadow_GC, |
284 lx, ly + lh - 1, lx + lw - 1, ly + lh - 1); | 284 lx, ly + lh - 1, lx + lw - 1, ly + lh - 1); |
285 } | 285 } |
286 else | 286 else |
287 { | 287 { |
288 /* Left border */ | 288 // Left border |
289 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 289 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
290 sbw->scrollbar.top_shadow_GC, | 290 sbw->scrollbar.top_shadow_GC, |
291 lx, ly, lx, ly + lh - 1); | 291 lx, ly, lx, ly + lh - 1); |
292 | 292 |
293 /* Right border */ | 293 // Right border |
294 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 294 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
295 sbw->scrollbar.bot_shadow_GC, | 295 sbw->scrollbar.bot_shadow_GC, |
296 lx + lw - 1, ly, lx + lw - 1, ly + lh - 1); | 296 lx + lw - 1, ly, lx + lw - 1, ly + lh - 1); |
297 } | 297 } |
298 return; | 298 return; |
304 sbw->scrollbar.gc, | 304 sbw->scrollbar.gc, |
305 lx, ly, (unsigned int) lw, (unsigned int) lh); | 305 lx, ly, (unsigned int) lw, (unsigned int) lh); |
306 | 306 |
307 if (!(sbw->scrollbar.orientation == XtorientHorizontal)) | 307 if (!(sbw->scrollbar.orientation == XtorientHorizontal)) |
308 { | 308 { |
309 /* Left border */ | 309 // Left border |
310 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 310 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
311 sbw->scrollbar.top_shadow_GC, | 311 sbw->scrollbar.top_shadow_GC, |
312 lx, ly, lx, ly + lh - 1); | 312 lx, ly, lx, ly + lh - 1); |
313 | 313 |
314 /* Right border */ | 314 // Right border |
315 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 315 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
316 sbw->scrollbar.bot_shadow_GC, | 316 sbw->scrollbar.bot_shadow_GC, |
317 lx + lw - 1, ly, lx + lw - 1, ly + lh - 1); | 317 lx + lw - 1, ly, lx + lw - 1, ly + lh - 1); |
318 } | 318 } |
319 else | 319 else |
320 { | 320 { |
321 /* Top border */ | 321 // Top border |
322 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 322 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
323 sbw->scrollbar.top_shadow_GC, | 323 sbw->scrollbar.top_shadow_GC, |
324 lx, ly, lx + lw - 1, ly); | 324 lx, ly, lx + lw - 1, ly); |
325 | 325 |
326 /* Bottom border */ | 326 // Bottom border |
327 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 327 XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
328 sbw->scrollbar.bot_shadow_GC, | 328 sbw->scrollbar.bot_shadow_GC, |
329 lx, ly + lh - 1, lx + lw - 1, ly + lh - 1); | 329 lx, ly + lh - 1, lx + lw - 1, ly + lh - 1); |
330 } | 330 } |
331 } | 331 } |
334 XClearArea(XtDisplay((Widget) sbw), XtWindow((Widget) sbw), | 334 XClearArea(XtDisplay((Widget) sbw), XtWindow((Widget) sbw), |
335 lx, ly, (unsigned int) lw, (unsigned int) lh, FALSE); | 335 lx, ly, (unsigned int) lw, (unsigned int) lh, FALSE); |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 /* Paint the thumb in the area specified by sbw->top and | 339 /* |
340 sbw->shown. The old area is erased. The painting and | 340 * Paint the thumb in the area specified by sbw->top and |
341 erasing is done cleverly so that no flickering will occur. | 341 * sbw->shown. The old area is erased. The painting and |
342 * erasing is done cleverly so that no flickering will occur. | |
342 */ | 343 */ |
343 | |
344 static void | 344 static void |
345 PaintThumb(ScrollbarWidget sbw) | 345 PaintThumb(ScrollbarWidget sbw) |
346 { | 346 { |
347 Position oldtop, oldbot, newtop, newbot; | 347 Position oldtop, oldbot, newtop, newbot; |
348 Dimension margin, tzl; | 348 Dimension margin, tzl; |
367 if (newbot < oldbot) | 367 if (newbot < oldbot) |
368 FillArea(sbw, AT_MAX(newbot, oldtop), oldbot, 0,0); | 368 FillArea(sbw, AT_MAX(newbot, oldtop), oldbot, 0,0); |
369 if (newbot > oldbot) | 369 if (newbot > oldbot) |
370 FillArea(sbw, AT_MAX(newtop, oldbot-1), newbot, 1,0); | 370 FillArea(sbw, AT_MAX(newtop, oldbot-1), newbot, 1,0); |
371 | 371 |
372 /* Only draw the missing shadows */ | 372 // Only draw the missing shadows |
373 FillArea(sbw, newtop, newbot, 0, 1); | 373 FillArea(sbw, newtop, newbot, 0, 1); |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 static void | 377 static void |
406 point[4].x = thickness - off - sbw->scrollbar.shadow_width; | 406 point[4].x = thickness - off - sbw->scrollbar.shadow_width; |
407 point[4].y = sbw->scrollbar.length - size; | 407 point[4].y = sbw->scrollbar.length - size; |
408 point[5].x = thickness / 2; | 408 point[5].x = thickness / 2; |
409 point[5].y = sbw->scrollbar.length - sbw->scrollbar.shadow_width - 1; | 409 point[5].y = sbw->scrollbar.length - sbw->scrollbar.shadow_width - 1; |
410 | 410 |
411 /* horizontal arrows require that x and y coordinates be swapped */ | 411 // horizontal arrows require that x and y coordinates be swapped |
412 if (sbw->scrollbar.orientation == XtorientHorizontal) | 412 if (sbw->scrollbar.orientation == XtorientHorizontal) |
413 { | 413 { |
414 int n; | 414 int n; |
415 int swap; | 415 int swap; |
416 for (n = 0; n < 6; n++) | 416 for (n = 0; n < 6; n++) |
418 swap = point[n].x; | 418 swap = point[n].x; |
419 point[n].x = point[n].y; | 419 point[n].x = point[n].y; |
420 point[n].y = swap; | 420 point[n].y = swap; |
421 } | 421 } |
422 } | 422 } |
423 /* draw the up/left arrow */ | 423 // draw the up/left arrow |
424 XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 424 XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
425 sbw->scrollbar.gc, | 425 sbw->scrollbar.gc, |
426 point, 3, | 426 point, 3, |
427 Convex, CoordModeOrigin); | 427 Convex, CoordModeOrigin); |
428 XDrawLines (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 428 XDrawLines (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
431 CoordModeOrigin); | 431 CoordModeOrigin); |
432 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 432 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
433 sbw->scrollbar.top_shadow_GC, | 433 sbw->scrollbar.top_shadow_GC, |
434 point[0].x, point[0].y, | 434 point[0].x, point[0].y, |
435 point[2].x, point[2].y); | 435 point[2].x, point[2].y); |
436 /* draw the down/right arrow */ | 436 // draw the down/right arrow |
437 XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 437 XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
438 sbw->scrollbar.gc, | 438 sbw->scrollbar.gc, |
439 point+3, 3, | 439 point+3, 3, |
440 Convex, CoordModeOrigin); | 440 Convex, CoordModeOrigin); |
441 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), | 441 XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), |
495 if (sbw->scrollbar.thumb != None) | 495 if (sbw->scrollbar.thumb != None) |
496 { | 496 { |
497 gcValues.fill_style = FillSolid; | 497 gcValues.fill_style = FillSolid; |
498 mask |= GCFillStyle; | 498 mask |= GCFillStyle; |
499 } | 499 } |
500 /* the creation should be non-caching, because */ | 500 // the creation should be non-caching, because |
501 /* we now set and clear clip masks on the gc returned */ | 501 // we now set and clear clip masks on the gc returned |
502 sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues); | 502 sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues); |
503 } | 503 } |
504 | 504 |
505 static void | 505 static void |
506 SetDimensions(ScrollbarWidget sbw) | 506 SetDimensions(ScrollbarWidget sbw) |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 static void | 520 static void |
521 Initialize( | 521 Initialize( |
522 Widget request UNUSED, /* what the client asked for */ | 522 Widget request UNUSED, // what the client asked for |
523 Widget new, /* what we're going to give him */ | 523 Widget new, // what we're going to give him |
524 ArgList args UNUSED, | 524 ArgList args UNUSED, |
525 Cardinal *num_args UNUSED) | 525 Cardinal *num_args UNUSED) |
526 { | 526 { |
527 ScrollbarWidget sbw = (ScrollbarWidget) new; | 527 ScrollbarWidget sbw = (ScrollbarWidget) new; |
528 | 528 |
549 Realize( | 549 Realize( |
550 Widget w, | 550 Widget w, |
551 Mask *valueMask, | 551 Mask *valueMask, |
552 XSetWindowAttributes *attributes) | 552 XSetWindowAttributes *attributes) |
553 { | 553 { |
554 /* The Simple widget actually stuffs the value in the valuemask. */ | 554 // The Simple widget actually stuffs the value in the valuemask. |
555 (*vim_scrollbarWidgetClass->core_class.superclass->core_class.realize) | 555 (*vim_scrollbarWidgetClass->core_class.superclass->core_class.realize) |
556 (w, valueMask, attributes); | 556 (w, valueMask, attributes); |
557 } | 557 } |
558 | 558 |
559 static Boolean | 559 static Boolean |
560 SetValues( | 560 SetValues( |
561 Widget current, /* what I am */ | 561 Widget current, // what I am |
562 Widget request UNUSED, /* what he wants me to be */ | 562 Widget request UNUSED, // what he wants me to be |
563 Widget desired, /* what I will become */ | 563 Widget desired, // what I will become |
564 ArgList args UNUSED, | 564 ArgList args UNUSED, |
565 Cardinal *num_args UNUSED) | 565 Cardinal *num_args UNUSED) |
566 { | 566 { |
567 ScrollbarWidget sbw = (ScrollbarWidget) current; | 567 ScrollbarWidget sbw = (ScrollbarWidget) current; |
568 ScrollbarWidget dsbw = (ScrollbarWidget) desired; | 568 ScrollbarWidget dsbw = (ScrollbarWidget) desired; |
598 } | 598 } |
599 | 599 |
600 static void | 600 static void |
601 Resize(Widget w) | 601 Resize(Widget w) |
602 { | 602 { |
603 /* ForgetGravity has taken care of background, but thumb may | 603 // ForgetGravity has taken care of background, but thumb may |
604 * have to move as a result of the new size. */ | 604 // have to move as a result of the new size. |
605 SetDimensions ((ScrollbarWidget) w); | 605 SetDimensions ((ScrollbarWidget) w); |
606 Redisplay(w, (XEvent*) NULL, (Region)NULL); | 606 Redisplay(w, (XEvent*) NULL, (Region)NULL); |
607 } | 607 } |
608 | 608 |
609 | 609 |
631 height = sbw->scrollbar.shownLength; | 631 height = sbw->scrollbar.shownLength; |
632 } | 632 } |
633 if (region == NULL || | 633 if (region == NULL || |
634 XRectInRegion (region, x, y, width, height) != RectangleOut) | 634 XRectInRegion (region, x, y, width, height) != RectangleOut) |
635 { | 635 { |
636 /* Forces entire thumb to be painted. */ | 636 // Forces entire thumb to be painted. |
637 sbw->scrollbar.topLoc = -(sbw->scrollbar.length + 1); | 637 sbw->scrollbar.topLoc = -(sbw->scrollbar.length + 1); |
638 PaintThumb (sbw); | 638 PaintThumb (sbw); |
639 } | 639 } |
640 /* we'd like to be region aware here!!!! */ | 640 // we'd like to be region aware here!!!! |
641 PaintArrows(sbw); | 641 PaintArrows(sbw); |
642 } | 642 } |
643 | 643 |
644 | 644 |
645 static Boolean | 645 static Boolean |
691 static Bool | 691 static Bool |
692 PeekNotifyEvent(Display *dpy, XEvent *event, char *args) | 692 PeekNotifyEvent(Display *dpy, XEvent *event, char *args) |
693 { | 693 { |
694 struct EventData *eventData = (struct EventData*)args; | 694 struct EventData *eventData = (struct EventData*)args; |
695 | 695 |
696 return ((++eventData->count == QLength(dpy)) /* since PeekIf blocks */ | 696 return ((++eventData->count == QLength(dpy)) // since PeekIf blocks |
697 || CompareEvents(event, eventData->oldEvent)); | 697 || CompareEvents(event, eventData->oldEvent)); |
698 } | 698 } |
699 | 699 |
700 | 700 |
701 static Boolean | 701 static Boolean |
717 | 717 |
718 | 718 |
719 static void | 719 static void |
720 ExtractPosition( | 720 ExtractPosition( |
721 XEvent *event, | 721 XEvent *event, |
722 Position *x, /* RETURN */ | 722 Position *x, // RETURN |
723 Position *y, /* RETURN */ | 723 Position *y, // RETURN |
724 unsigned int *state) /* RETURN */ | 724 unsigned int *state) // RETURN |
725 { | 725 { |
726 switch (event->type) | 726 switch (event->type) |
727 { | 727 { |
728 case MotionNotify: | 728 case MotionNotify: |
729 *x = event->xmotion.x; | 729 *x = event->xmotion.x; |
769 Position x, y, loc; | 769 Position x, y, loc; |
770 ScrollbarWidget sbw = (ScrollbarWidget) w; | 770 ScrollbarWidget sbw = (ScrollbarWidget) w; |
771 | 771 |
772 ExtractPosition(event, &x, &y, (unsigned int *)NULL); | 772 ExtractPosition(event, &x, &y, (unsigned int *)NULL); |
773 loc = PICKLENGTH(sbw, x, y); | 773 loc = PICKLENGTH(sbw, x, y); |
774 /* if the motion event puts the pointer in thumb, call Move and Notify */ | 774 // if the motion event puts the pointer in thumb, call Move and Notify |
775 /* also call Move and Notify if we're already in continuous scroll mode */ | 775 // also call Move and Notify if we're already in continuous scroll mode |
776 if (sbw->scrollbar.scroll_mode == SMODE_CONT || | 776 if (sbw->scrollbar.scroll_mode == SMODE_CONT || |
777 (loc >= sbw->scrollbar.topLoc && | 777 (loc >= sbw->scrollbar.topLoc && |
778 loc <= sbw->scrollbar.topLoc + (int)sbw->scrollbar.shownLength)) | 778 loc <= sbw->scrollbar.topLoc + (int)sbw->scrollbar.shownLength)) |
779 { | 779 { |
780 XtCallActionProc(w, "MoveThumb", event, params, *num_params); | 780 XtCallActionProc(w, "MoveThumb", event, params, *num_params); |
874 XEvent *event, | 874 XEvent *event, |
875 int call_data) | 875 int call_data) |
876 { | 876 { |
877 ScrollbarWidget sbw = (ScrollbarWidget) w; | 877 ScrollbarWidget sbw = (ScrollbarWidget) w; |
878 | 878 |
879 if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if scroll continuous */ | 879 if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if scroll continuous |
880 return; | 880 return; |
881 | 881 |
882 if (LookAhead(w, event)) | 882 if (LookAhead(w, event)) |
883 return; | 883 return; |
884 | 884 |
898 Dimension arrow_size; | 898 Dimension arrow_size; |
899 unsigned long delay = 0; | 899 unsigned long delay = 0; |
900 int call_data = 0; | 900 int call_data = 0; |
901 unsigned int state; | 901 unsigned int state; |
902 | 902 |
903 if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if scroll continuous */ | 903 if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if scroll continuous |
904 return; | 904 return; |
905 | 905 |
906 if (LookAhead (w, event)) | 906 if (LookAhead (w, event)) |
907 return; | 907 return; |
908 | 908 |
966 } | 966 } |
967 | 967 |
968 if (call_data) | 968 if (call_data) |
969 XtCallCallbacks(w, XtNscrollProc, (XtPointer)(long_u)call_data); | 969 XtCallCallbacks(w, XtNscrollProc, (XtPointer)(long_u)call_data); |
970 | 970 |
971 /* establish autoscroll */ | 971 // establish autoscroll |
972 if (delay) | 972 if (delay) |
973 sbw->scrollbar.timer_id = | 973 sbw->scrollbar.timer_id = |
974 XtAppAddTimeOut(XtWidgetToApplicationContext(w), | 974 XtAppAddTimeOut(XtWidgetToApplicationContext(w), |
975 delay, RepeatNotify, (XtPointer)w); | 975 delay, RepeatNotify, (XtPointer)w); |
976 } | 976 } |
983 Cardinal *num_params UNUSED) | 983 Cardinal *num_params UNUSED) |
984 { | 984 { |
985 ScrollbarWidget sbw = (ScrollbarWidget) w; | 985 ScrollbarWidget sbw = (ScrollbarWidget) w; |
986 | 986 |
987 sbw->scrollbar.scroll_mode = SMODE_NONE; | 987 sbw->scrollbar.scroll_mode = SMODE_NONE; |
988 /* no need to remove any autoscroll timeout; it will no-op */ | 988 // no need to remove any autoscroll timeout; it will no-op |
989 /* because the scroll_mode is SMODE_NONE */ | 989 // because the scroll_mode is SMODE_NONE |
990 /* but be sure to remove timeout in destroy proc */ | 990 // but be sure to remove timeout in destroy proc |
991 } | 991 } |
992 | 992 |
993 static float | 993 static float |
994 FractionLoc(ScrollbarWidget sbw, int x, int y) | 994 FractionLoc(ScrollbarWidget sbw, int x, int y) |
995 { | 995 { |
1014 ScrollbarWidget sbw = (ScrollbarWidget)w; | 1014 ScrollbarWidget sbw = (ScrollbarWidget)w; |
1015 Position x, y; | 1015 Position x, y; |
1016 float top; | 1016 float top; |
1017 char old_mode = sbw->scrollbar.scroll_mode; | 1017 char old_mode = sbw->scrollbar.scroll_mode; |
1018 | 1018 |
1019 sbw->scrollbar.scroll_mode = SMODE_CONT; /* indicate continuous scroll */ | 1019 sbw->scrollbar.scroll_mode = SMODE_CONT; // indicate continuous scroll |
1020 | 1020 |
1021 if (LookAhead(w, event)) | 1021 if (LookAhead(w, event)) |
1022 return; | 1022 return; |
1023 | 1023 |
1024 if (!event->xmotion.same_screen) | 1024 if (!event->xmotion.same_screen) |
1026 | 1026 |
1027 ExtractPosition(event, &x, &y, (unsigned int *)NULL); | 1027 ExtractPosition(event, &x, &y, (unsigned int *)NULL); |
1028 | 1028 |
1029 top = FractionLoc(sbw, x, y); | 1029 top = FractionLoc(sbw, x, y); |
1030 | 1030 |
1031 if (old_mode != SMODE_CONT) /* start dragging: set offset */ | 1031 if (old_mode != SMODE_CONT) // start dragging: set offset |
1032 { | 1032 { |
1033 if (event->xbutton.button == Button2) | 1033 if (event->xbutton.button == Button2) |
1034 sbw->scrollbar.scroll_off = sbw->scrollbar.shown / 2.; | 1034 sbw->scrollbar.scroll_off = sbw->scrollbar.shown / 2.; |
1035 else | 1035 else |
1036 sbw->scrollbar.scroll_off = top - sbw->scrollbar.top; | 1036 sbw->scrollbar.scroll_off = top - sbw->scrollbar.top; |
1043 else | 1043 else |
1044 top = FloatInRange(top, 0.0, sbw->scrollbar.max); | 1044 top = FloatInRange(top, 0.0, sbw->scrollbar.max); |
1045 | 1045 |
1046 sbw->scrollbar.top = top; | 1046 sbw->scrollbar.top = top; |
1047 PaintThumb(sbw); | 1047 PaintThumb(sbw); |
1048 XFlush(XtDisplay(w)); /* re-draw it before Notifying */ | 1048 XFlush(XtDisplay(w)); // re-draw it before Notifying |
1049 } | 1049 } |
1050 | 1050 |
1051 | 1051 |
1052 static void | 1052 static void |
1053 NotifyThumb( | 1053 NotifyThumb( |
1055 XEvent *event, | 1055 XEvent *event, |
1056 String *params UNUSED, | 1056 String *params UNUSED, |
1057 Cardinal *num_params UNUSED) | 1057 Cardinal *num_params UNUSED) |
1058 { | 1058 { |
1059 ScrollbarWidget sbw = (ScrollbarWidget)w; | 1059 ScrollbarWidget sbw = (ScrollbarWidget)w; |
1060 /* Use a union to avoid a warning for the weird conversion from float to | 1060 // Use a union to avoid a warning for the weird conversion from float to |
1061 * XtPointer. Comes from Xaw/Scrollbar.c. */ | 1061 // XtPointer. Comes from Xaw/Scrollbar.c. |
1062 union { | 1062 union { |
1063 XtPointer xtp; | 1063 XtPointer xtp; |
1064 float xtf; | 1064 float xtf; |
1065 } xtpf; | 1065 } xtpf; |
1066 | 1066 |
1067 if (LookAhead(w, event)) | 1067 if (LookAhead(w, event)) |
1068 return; | 1068 return; |
1069 | 1069 |
1070 /* thumbProc is not pretty, but is necessary for backwards | 1070 // thumbProc is not pretty, but is necessary for backwards |
1071 compatibility on those architectures for which it work{s,ed}; | 1071 // compatibility on those architectures for which it work{s,ed}; |
1072 the intent is to pass a (truncated) float by value. */ | 1072 // the intent is to pass a (truncated) float by value. |
1073 xtpf.xtf = sbw->scrollbar.top; | 1073 xtpf.xtf = sbw->scrollbar.top; |
1074 XtCallCallbacks(w, XtNthumbProc, xtpf.xtp); | 1074 XtCallCallbacks(w, XtNthumbProc, xtpf.xtp); |
1075 XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top); | 1075 XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top); |
1076 } | 1076 } |
1077 | 1077 |
1135 { | 1135 { |
1136 top = sbw->scrollbar.bot_shadow_GC; | 1136 top = sbw->scrollbar.bot_shadow_GC; |
1137 bot = sbw->scrollbar.top_shadow_GC; | 1137 bot = sbw->scrollbar.top_shadow_GC; |
1138 } | 1138 } |
1139 | 1139 |
1140 /* top-left shadow */ | 1140 // top-left shadow |
1141 if ((region == NULL) || | 1141 if ((region == NULL) || |
1142 (XRectInRegion (region, 0, 0, w, s) != RectangleOut) || | 1142 (XRectInRegion (region, 0, 0, w, s) != RectangleOut) || |
1143 (XRectInRegion (region, 0, 0, s, h) != RectangleOut)) | 1143 (XRectInRegion (region, 0, 0, s, h) != RectangleOut)) |
1144 { | 1144 { |
1145 pt[0].x = 0; pt[0].y = h; | 1145 pt[0].x = 0; pt[0].y = h; |
1149 pt[4].x = pt[4].y = s; | 1149 pt[4].x = pt[4].y = s; |
1150 pt[5].x = s; pt[5].y = hms; | 1150 pt[5].x = s; pt[5].y = hms; |
1151 XFillPolygon (dpy, win, top, pt, 6, Complex, CoordModeOrigin); | 1151 XFillPolygon (dpy, win, top, pt, 6, Complex, CoordModeOrigin); |
1152 } | 1152 } |
1153 | 1153 |
1154 /* bottom-right shadow */ | 1154 // bottom-right shadow |
1155 if ((region == NULL) || | 1155 if ((region == NULL) || |
1156 (XRectInRegion (region, 0, hms, w, s) != RectangleOut) || | 1156 (XRectInRegion (region, 0, hms, w, s) != RectangleOut) || |
1157 (XRectInRegion (region, wms, 0, s, h) != RectangleOut)) | 1157 (XRectInRegion (region, wms, 0, s, h) != RectangleOut)) |
1158 { | 1158 { |
1159 pt[0].x = 0; pt[0].y = h; | 1159 pt[0].x = 0; pt[0].y = h; |
1174 void | 1174 void |
1175 vim_XawScrollbarSetThumb(Widget w, double top, double shown, double max) | 1175 vim_XawScrollbarSetThumb(Widget w, double top, double shown, double max) |
1176 { | 1176 { |
1177 ScrollbarWidget sbw = (ScrollbarWidget) w; | 1177 ScrollbarWidget sbw = (ScrollbarWidget) w; |
1178 | 1178 |
1179 if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if still thumbing */ | 1179 if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if still thumbing |
1180 return; | 1180 return; |
1181 | 1181 |
1182 sbw->scrollbar.max = (max > 1.0) ? 1.0 : | 1182 sbw->scrollbar.max = (max > 1.0) ? 1.0 : |
1183 (max >= 0.0) ? max : sbw->scrollbar.max; | 1183 (max >= 0.0) ? max : sbw->scrollbar.max; |
1184 | 1184 |