Mercurial > hg > xemacs-beta
comparison lwlib/xlwmenu.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | f220cc83d72e |
children | c9fe270a4101 |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
30 #include <limits.h> | 30 #include <limits.h> |
31 #ifdef HAVE_UNISTD_H | 31 #ifdef HAVE_UNISTD_H |
32 #include <unistd.h> | 32 #include <unistd.h> |
33 #endif | 33 #endif |
34 | 34 |
35 #if 0 /* mrb */ | |
36 #include <X11/Xos.h> | |
37 #endif | |
38 #include <X11/IntrinsicP.h> | 35 #include <X11/IntrinsicP.h> |
39 #include <X11/ShellP.h> | 36 #include <X11/ShellP.h> |
40 #include <X11/StringDefs.h> | 37 #include <X11/StringDefs.h> |
41 #include <X11/cursorfont.h> | 38 #include <X11/cursorfont.h> |
42 #include <X11/bitmaps/gray> | 39 #include <X11/bitmaps/gray> |
343 sizeof (widget_value*)); | 340 sizeof (widget_value*)); |
344 } | 341 } |
345 } | 342 } |
346 | 343 |
347 static Boolean | 344 static Boolean |
348 close_to_reference_time(Widget w, Time reference_time, XEvent *ev) | 345 close_to_reference_time (Widget w, Time reference_time, XEvent *ev) |
349 { | 346 { |
350 return | 347 return |
351 reference_time && | 348 reference_time && |
352 (ev->xbutton.time - reference_time < XtGetMultiClickTime (XtDisplay (w))); | 349 (ev->xbutton.time - reference_time < XtGetMultiClickTime (XtDisplay (w))); |
353 } | 350 } |
381 } | 378 } |
382 | 379 |
383 static char massaged_resource_char[256]; | 380 static char massaged_resource_char[256]; |
384 | 381 |
385 static void | 382 static void |
386 Initialize_massaged_resource_char (void) | 383 initialize_massaged_resource_char (void) |
387 { | 384 { |
388 int j; | 385 int j; |
389 for (j = 0; j < sizeof (massaged_resource_char); j++) | 386 for (j = 0; j < (int) sizeof (massaged_resource_char); j++) |
390 { | 387 { |
391 if ((j >= 'a' && j <= 'z') || | 388 if ((j >= 'a' && j <= 'z') || |
392 (j >= 'A' && j <= 'Z') || | 389 (j >= 'A' && j <= 'Z') || |
393 (j >= '0' && j <= '9') || | 390 (j >= '0' && j <= '9') || |
394 (j == '_') || | 391 (j == '_') || |
431 } | 428 } |
432 #else | 429 #else |
433 chars = string; | 430 chars = string; |
434 #endif | 431 #endif |
435 | 432 |
436 for (i = j = 0; chars[i] && (j < sizeof (newchars)); i++) | 433 for (i = j = 0; chars[i] && (j < (int) sizeof (newchars)); i++) |
437 if (chars[i]=='%'&&chars[i+1]=='_') | 434 if (chars[i]=='%'&&chars[i+1]=='_') |
438 i++; | 435 i++; |
439 else | 436 else |
440 newchars[j++] = chars[i]; | 437 newchars[j++] = chars[i]; |
441 newchars[j] = '\0'; | 438 newchars[j] = '\0'; |
442 | 439 |
443 #ifdef NEED_MOTIF | 440 #ifdef NEED_MOTIF |
444 newstring = XmStringLtoRCreate (newchars, XmFONTLIST_DEFAULT_TAG); | 441 newstring = XmStringLtoRCreate (newchars, XmFONTLIST_DEFAULT_TAG); |
445 XmStringExtent (mw->menu.font_list, newstring, &width, &height); | 442 XmStringExtent (mw->menu.font_list, newstring, &width, &height); |
446 XmStringFree(newstring); | 443 XmStringFree (newstring); |
447 return width; | 444 return width; |
448 #else | 445 #else |
449 # ifdef USE_XFONTSET | 446 # ifdef USE_XFONTSET |
450 XmbTextExtents(mw->menu.font_set, newchars, j, &ri, &rl); | 447 XmbTextExtents (mw->menu.font_set, newchars, j, &ri, &rl); |
451 return rl.width; | 448 return rl.width; |
452 # else /* ! USE_XFONTSET */ | 449 # else /* ! USE_XFONTSET */ |
453 XTextExtents (mw->menu.font, newchars, j, &drop, &drop, &drop, &xcs); | 450 XTextExtents (mw->menu.font, newchars, j, &drop, &drop, &drop, &xcs); |
454 return xcs.width; | 451 return xcs.width; |
455 # endif /* USE_XFONTSET */ | 452 # endif /* USE_XFONTSET */ |
491 } | 488 } |
492 } | 489 } |
493 *out = 0; | 490 *out = 0; |
494 | 491 |
495 #ifdef PRINT_XLWMENU_RESOURCE_CONVERSIONS | 492 #ifdef PRINT_XLWMENU_RESOURCE_CONVERSIONS |
496 printf("! Emacs*XlwMenu.%s.labelString:\t%s\n", save_out, save_in); | 493 printf ("! Emacs*XlwMenu.%s.labelString:\t%s\n", save_out, save_in); |
497 printf( "Emacs*XlwMenu.%s.labelString:\n", save_out); | 494 printf ( "Emacs*XlwMenu.%s.labelString:\n", save_out); |
498 #endif | 495 #endif |
499 } | 496 } |
500 | 497 |
501 static XtResource | 498 static XtResource |
502 nameResource[] = | 499 nameResource[] = |
521 static char* | 518 static char* |
522 parameterize_string (CONST char *string, CONST char *value) | 519 parameterize_string (CONST char *string, CONST char *value) |
523 { | 520 { |
524 char *percent; | 521 char *percent; |
525 char *result; | 522 char *result; |
526 unsigned done = 0; | 523 unsigned int done = 0; |
527 unsigned ntimes; | 524 unsigned int ntimes; |
528 | 525 |
529 if (!string) | 526 if (!string) |
530 { | 527 { |
531 result = XtMalloc(1); | 528 result = XtMalloc(1); |
532 result[0] = '\0'; | 529 result[0] = '\0'; |
543 result = XtMalloc ((ntimes * strlen(value)) + strlen(string) + 4); | 540 result = XtMalloc ((ntimes * strlen(value)) + strlen(string) + 4); |
544 result[0] = '\0'; | 541 result[0] = '\0'; |
545 | 542 |
546 while ((percent = strchr(string, '%'))) | 543 while ((percent = strchr(string, '%'))) |
547 { | 544 { |
548 unsigned left_pad; | 545 unsigned int left_pad; |
549 unsigned right_pad; | 546 unsigned int right_pad; |
550 char *p; | 547 char *p; |
551 | 548 |
552 if (percent[1] == '%') | 549 if (percent[1] == '%') |
553 { /* it's a real % */ | 550 { /* it's a real % */ |
554 strncat(result, string, 1 + percent - string); /* incl % */ | 551 strncat (result, string, 1 + percent - string); /* incl % */ |
555 string = &percent[2]; /* after the second '%' */ | 552 string = &percent[2]; /* after the second '%' */ |
556 continue; /* with the while() loop */ | 553 continue; /* with the while() loop */ |
557 } | 554 } |
558 | 555 |
559 left_pad = 0; | 556 left_pad = 0; |
569 { /* right pad */ | 566 { /* right pad */ |
570 right_pad++; | 567 right_pad++; |
571 } | 568 } |
572 else if (*p == '1') | 569 else if (*p == '1') |
573 { /* param and terminator */ | 570 { /* param and terminator */ |
574 strncat(result, string, percent - string); | 571 strncat (result, string, percent - string); |
575 if (value[0] != '\0') | 572 if (value[0] != '\0') |
576 { | 573 { |
577 unsigned i; | 574 unsigned int i; |
578 for (i = 0; i < left_pad; i++) | 575 for (i = 0; i < left_pad; i++) |
579 strcat(result, " "); | 576 strcat (result, " "); |
580 strcat(result, value); | 577 strcat (result, value); |
581 for (i = 0; i < right_pad; i++) | 578 for (i = 0; i < right_pad; i++) |
582 strcat(result, " "); | 579 strcat (result, " "); |
583 } | 580 } |
584 string = &p[1]; /* after the '1' */ | 581 string = &p[1]; /* after the '1' */ |
585 done++; /* no need to do old way */ | 582 done++; /* no need to do old way */ |
586 break; /* out of for() loop */ | 583 break; /* out of for() loop */ |
587 } | 584 } |
588 else | 585 else |
589 { /* bogus, copy the format as is */ | 586 { /* bogus, copy the format as is */ |
590 /* out of for() loop */ | 587 /* out of for() loop */ |
591 strncat(result, string, 1 + p - string); | 588 strncat (result, string, 1 + p - string); |
592 string= (*p ? &p[1] : p); | 589 string = (*p ? &p[1] : p); |
593 break; | 590 break; |
594 } | 591 } |
595 } | 592 } |
596 } | 593 } |
597 | 594 |
598 /* | 595 /* Copy the tail of the string */ |
599 * Copy the tail of the string | 596 strcat (result, string); |
600 */ | 597 |
601 strcat(result, string); | 598 /* If we have not processed a % string, and we have a value, tail it. */ |
602 | |
603 /* | |
604 * If we have not processed a % string, and we have a value, tail it. | |
605 */ | |
606 if (!done && value[0] != '\0') | 599 if (!done && value[0] != '\0') |
607 { | 600 { |
608 strcat(result, " "); | 601 strcat (result, " "); |
609 strcat(result, value); | 602 strcat (result, value); |
610 } | 603 } |
611 | 604 |
612 return result; | 605 return result; |
613 } | 606 } |
614 | 607 |
633 /* If we have a value (parameter) see if we can find a "Named" | 626 /* If we have a value (parameter) see if we can find a "Named" |
634 resource. */ | 627 resource. */ |
635 if (val->value) | 628 if (val->value) |
636 { | 629 { |
637 char named_name[1024]; | 630 char named_name[1024]; |
638 sprintf(named_name, "%sNamed", massaged_name); | 631 sprintf (named_name, "%sNamed", massaged_name); |
639 XtGetSubresources ((Widget) mw, | 632 XtGetSubresources ((Widget) mw, |
640 (XtPointer) &resourced_name, | 633 (XtPointer) &resourced_name, |
641 named_name, named_name, | 634 named_name, named_name, |
642 nameResource, 1, NULL, 0); | 635 nameResource, 1, NULL, 0); |
643 } | 636 } |
655 /* Still nothing yet, use the name as the value. */ | 648 /* Still nothing yet, use the name as the value. */ |
656 if (!resourced_name) | 649 if (!resourced_name) |
657 resourced_name = val->name; | 650 resourced_name = val->name; |
658 | 651 |
659 /* Parameterize the string. */ | 652 /* Parameterize the string. */ |
660 converted_name = parameterize_string(resourced_name, val->value); | 653 converted_name = parameterize_string (resourced_name, val->value); |
661 | 654 |
662 /* nuke newline characters to prevent menubar screwups */ | 655 /* nuke newline characters to prevent menubar screwups */ |
663 for ( str = converted_name ; *str ; str++ ) | 656 for ( str = converted_name ; *str ; str++ ) |
664 { | 657 { |
665 if (str[0] == '\n') str[0] = ' '; | 658 if (str[0] == '\n') str[0] = ' '; |
680 return (XmString) val->toolkit_data; | 673 return (XmString) val->toolkit_data; |
681 } | 674 } |
682 | 675 |
683 /* Unused */ | 676 /* Unused */ |
684 #if 0 | 677 #if 0 |
685 /* | 678 /* These two routines should be a seperate file..djw */ |
686 * These two routines should be a seperate file..djw | |
687 */ | |
688 static char * | 679 static char * |
689 xlw_create_localized_string (Widget w, | 680 xlw_create_localized_string (Widget w, |
690 char *name, | 681 char *name, |
691 char **args, | 682 char **args, |
692 unsigned nargs) | 683 unsigned int nargs) |
693 { | 684 { |
694 char *string = NULL; | 685 char *string = NULL; |
695 char *arg = NULL; | 686 char *arg = NULL; |
696 | 687 |
697 if (nargs > 0) | 688 if (nargs > 0) |
712 | 703 |
713 static XmString | 704 static XmString |
714 xlw_create_localized_xmstring (Widget w, | 705 xlw_create_localized_xmstring (Widget w, |
715 char *name, | 706 char *name, |
716 char **args, | 707 char **args, |
717 unsigned nargs) | 708 unsigned int nargs) |
718 { | 709 { |
719 char * string = xlw_create_localized_string (w, name, args, nargs); | 710 char * string = xlw_create_localized_string (w, name, args, nargs); |
720 XmString xm_string = XmStringCreateLtoR (string, XmSTRING_DEFAULT_CHARSET); | 711 XmString xm_string = XmStringCreateLtoR (string, XmSTRING_DEFAULT_CHARSET); |
721 XtFree(string); | 712 XtFree (string); |
722 return xm_string; | 713 return xm_string; |
723 } | 714 } |
724 #endif /* 0 */ | 715 #endif /* 0 */ |
725 | 716 |
726 #else /* !Motif */ | 717 #else /* !Motif */ |
744 nameResource, 1, NULL, 0); | 735 nameResource, 1, NULL, 0); |
745 } | 736 } |
746 if (!resourced_name) | 737 if (!resourced_name) |
747 resourced_name = val->name; | 738 resourced_name = val->name; |
748 | 739 |
749 complete_name = parameterize_string(resourced_name, val->value); | 740 complete_name = parameterize_string (resourced_name, val->value); |
750 | 741 |
751 val->toolkit_data = complete_name; | 742 val->toolkit_data = complete_name; |
752 /* nuke newline characters to prevent menubar screwups */ | 743 /* nuke newline characters to prevent menubar screwups */ |
753 for ( ; *complete_name ; complete_name++ ) | 744 for ( ; *complete_name ; complete_name++ ) |
754 { | 745 { |
760 return (char *) val->toolkit_data; | 751 return (char *) val->toolkit_data; |
761 } | 752 } |
762 | 753 |
763 #endif /* !Motif */ | 754 #endif /* !Motif */ |
764 | 755 |
765 /* | 756 /* Code for drawing strings. */ |
766 * Code for drawing strings. | 757 static void |
767 */ | 758 string_draw (XlwMenuWidget mw, |
768 static void | 759 Window window, |
769 string_draw(XlwMenuWidget mw, | 760 int x, int y, |
770 Window window, | 761 GC gc, |
771 int x, int y, | |
772 GC gc, | |
773 #ifdef NEED_MOTIF | 762 #ifdef NEED_MOTIF |
774 XmString string | 763 XmString string |
775 #else | 764 #else |
776 char *string | 765 char *string |
777 #endif | 766 #endif |
778 ) | 767 ) |
779 { | 768 { |
780 #ifdef NEED_MOTIF | 769 #ifdef NEED_MOTIF |
781 XmStringDraw (XtDisplay (mw), window, | 770 XmStringDraw (XtDisplay (mw), window, |
911 #else | 900 #else |
912 string_draw (mw, w, x, y, gc, value); | 901 string_draw (mw, w, x, y, gc, value); |
913 #endif | 902 #endif |
914 } | 903 } |
915 | 904 |
916 /* | 905 /* Low level code for drawing 3-D edges. */ |
917 * Low level code for drawing 3-D edges. | |
918 */ | |
919 static void | 906 static void |
920 shadow_rectangle_draw (Display *dpy, | 907 shadow_rectangle_draw (Display *dpy, |
921 Window window, | 908 Window window, |
922 GC top_gc, | 909 GC top_gc, |
923 GC bottom_gc, | 910 GC bottom_gc, |
924 int x, int y, unsigned width, unsigned height, | 911 int x, int y, |
925 unsigned thickness) | 912 unsigned int width, |
913 unsigned int height, | |
914 unsigned int thickness) | |
926 { | 915 { |
927 XPoint points [4]; | 916 XPoint points [4]; |
928 | 917 |
929 if (!thickness) | 918 if (!thickness) |
930 return; | 919 return; |
990 } shadow_type; | 979 } shadow_type; |
991 | 980 |
992 static void | 981 static void |
993 shadow_draw (XlwMenuWidget mw, | 982 shadow_draw (XlwMenuWidget mw, |
994 Window window, | 983 Window window, |
995 int x, int y, unsigned width, unsigned height, | 984 int x, int y, |
985 unsigned int width, | |
986 unsigned int height, | |
996 shadow_type type) | 987 shadow_type type) |
997 { | 988 { |
998 Display *dpy = XtDisplay (mw); | 989 Display *dpy = XtDisplay (mw); |
999 GC top_gc; | 990 GC top_gc; |
1000 GC bottom_gc; | 991 GC bottom_gc; |
1030 break; | 1021 break; |
1031 } | 1022 } |
1032 | 1023 |
1033 if (etched) | 1024 if (etched) |
1034 { | 1025 { |
1035 unsigned half = thickness/2; | 1026 unsigned int half = thickness/2; |
1036 shadow_rectangle_draw (dpy, | 1027 shadow_rectangle_draw (dpy, |
1037 window, | 1028 window, |
1038 top_gc, | 1029 top_gc, |
1039 top_gc, | 1030 top_gc, |
1040 x, y, | 1031 x, y, |
1062 | 1053 |
1063 static void | 1054 static void |
1064 arrow_decoration_draw (XlwMenuWidget mw, | 1055 arrow_decoration_draw (XlwMenuWidget mw, |
1065 Window window, | 1056 Window window, |
1066 int x, int y, | 1057 int x, int y, |
1067 unsigned width, | 1058 unsigned int width, |
1068 Boolean raised) | 1059 Boolean raised) |
1069 { | 1060 { |
1070 Display *dpy = XtDisplay (mw); | 1061 Display *dpy = XtDisplay (mw); |
1071 GC top_gc; | 1062 GC top_gc; |
1072 GC bottom_gc; | 1063 GC bottom_gc; |
1093 { | 1084 { |
1094 top_gc = mw->menu.shadow_top_gc; | 1085 top_gc = mw->menu.shadow_top_gc; |
1095 bottom_gc = mw->menu.shadow_bottom_gc; | 1086 bottom_gc = mw->menu.shadow_bottom_gc; |
1096 } | 1087 } |
1097 | 1088 |
1098 /* | 1089 /* Fill internal area. We do this first so that the borders have a |
1099 * Fill internal area, we do this first so that the borders | 1090 nice sharp edge. */ |
1100 * have a nice sharp edge. | |
1101 */ | |
1102 points [0].x = x + thickness; | 1091 points [0].x = x + thickness; |
1103 points [0].y = y + thickness; | 1092 points [0].y = y + thickness; |
1104 points [1].x = x + length - thickness; | 1093 points [1].x = x + length - thickness; |
1105 points [1].y = y + half_width; | 1094 points [1].y = y + half_width; |
1106 points [2].x = x + length - thickness; | 1095 points [2].x = x + length - thickness; |
1155 | 1144 |
1156 static void | 1145 static void |
1157 toggle_decoration_draw (XlwMenuWidget mw, | 1146 toggle_decoration_draw (XlwMenuWidget mw, |
1158 Window window, | 1147 Window window, |
1159 int x, int y, | 1148 int x, int y, |
1160 unsigned width, | 1149 unsigned int width, |
1161 Boolean set) | 1150 Boolean set) |
1162 { | 1151 { |
1163 Display *dpy = XtDisplay (mw); | 1152 Display *dpy = XtDisplay (mw); |
1164 int thickness = mw->menu.shadow_thickness; | 1153 int thickness = mw->menu.shadow_thickness; |
1165 shadow_type type; | 1154 shadow_type type; |
1168 if (set) | 1157 if (set) |
1169 type = SHADOW_IN; | 1158 type = SHADOW_IN; |
1170 else | 1159 else |
1171 type = SHADOW_OUT; | 1160 type = SHADOW_OUT; |
1172 | 1161 |
1173 /* | 1162 /* Fill internal area. */ |
1174 * Fill internal area. | |
1175 */ | |
1176 if (set) | 1163 if (set) |
1177 XFillRectangle (dpy, | 1164 XFillRectangle (dpy, |
1178 window, | 1165 window, |
1179 select_gc, | 1166 select_gc, |
1180 x + thickness, | 1167 x + thickness, |
1181 y + thickness, | 1168 y + thickness, |
1182 width - (2*thickness), | 1169 width - (2*thickness), |
1183 width - (2*thickness)); | 1170 width - (2*thickness)); |
1184 | 1171 |
1185 shadow_draw(mw, window, x, y, width, width, type); | 1172 shadow_draw (mw, window, x, y, width, width, type); |
1186 } | 1173 } |
1187 | 1174 |
1188 static void | 1175 static void |
1189 radio_decoration_draw (XlwMenuWidget mw, | 1176 radio_decoration_draw (XlwMenuWidget mw, |
1190 Window window, | 1177 Window window, |
1191 int x, int y, | 1178 int x, int y, |
1192 unsigned width, | 1179 unsigned int width, |
1193 Boolean enabled) | 1180 Boolean enabled) |
1194 { | 1181 { |
1195 Display *dpy = XtDisplay (mw); | 1182 Display *dpy = XtDisplay (mw); |
1196 GC top_gc; | 1183 GC top_gc; |
1197 GC bottom_gc; | 1184 GC bottom_gc; |
1218 top_gc = mw->menu.shadow_top_gc; | 1205 top_gc = mw->menu.shadow_top_gc; |
1219 bottom_gc = mw->menu.shadow_bottom_gc; | 1206 bottom_gc = mw->menu.shadow_bottom_gc; |
1220 } | 1207 } |
1221 | 1208 |
1222 #if 1 | 1209 #if 1 |
1223 /* | 1210 /* Draw the bottom first, just in case the regions overlap. |
1224 * Draw the bottom first, just incase the regions overlap. | 1211 The top should cast the longer shadow. */ |
1225 * The top should cast the longer shadow. | |
1226 */ | |
1227 points [0].x = x; /* left corner */ | 1212 points [0].x = x; /* left corner */ |
1228 points [0].y = y + half_width; | 1213 points [0].y = y + half_width; |
1229 points [1].x = x + half_width; /* bottom corner */ | 1214 points [1].x = x + half_width; /* bottom corner */ |
1230 points [1].y = y + width; | 1215 points [1].y = y + width; |
1231 points [2].x = x + half_width; /* bottom inside corner */ | 1216 points [2].x = x + half_width; /* bottom inside corner */ |
1266 points [3].x = x + half_width; /* top inside corner */ | 1251 points [3].x = x + half_width; /* top inside corner */ |
1267 points [3].y = y + thickness; | 1252 points [3].y = y + thickness; |
1268 | 1253 |
1269 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin); | 1254 XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin); |
1270 #else | 1255 #else |
1271 /* | 1256 /* Draw the bottom first, just in case the regions overlap. |
1272 * Draw the bottom first, just incase the regions overlap. | 1257 The top should cast the longer shadow. */ |
1273 * The top should cast the longer shadow. | |
1274 */ | |
1275 npoints = 0; | 1258 npoints = 0; |
1276 points [npoints].x = x; /* left corner */ | 1259 points [npoints].x = x; /* left corner */ |
1277 points [npoints++].y = y + half_width; | 1260 points [npoints++].y = y + half_width; |
1278 points [npoints].x = x + half_width; /* bottom corner */ | 1261 points [npoints].x = x + half_width; /* bottom corner */ |
1279 points [npoints++].y = y + width; | 1262 points [npoints++].y = y + width; |
1307 XFillPolygon (dpy, window, top_gc, points, npoints, Nonconvex, | 1290 XFillPolygon (dpy, window, top_gc, points, npoints, Nonconvex, |
1308 CoordModeOrigin); | 1291 CoordModeOrigin); |
1309 #endif | 1292 #endif |
1310 | 1293 |
1311 | 1294 |
1312 /* | 1295 /* Fill internal area. */ |
1313 * Fill internal area. | |
1314 */ | |
1315 if (enabled) | 1296 if (enabled) |
1316 { | 1297 { |
1317 points [0].x = x + thickness; | 1298 points [0].x = x + thickness; |
1318 points [0].y = y + half_width; | 1299 points [0].y = y + half_width; |
1319 points [1].x = x + half_width; | 1300 points [1].x = x + half_width; |
1334 | 1315 |
1335 static void | 1316 static void |
1336 separator_decoration_draw (XlwMenuWidget mw, | 1317 separator_decoration_draw (XlwMenuWidget mw, |
1337 Window window, | 1318 Window window, |
1338 int x, int y, | 1319 int x, int y, |
1339 unsigned width, | 1320 unsigned int width, |
1340 Boolean vertical, | 1321 Boolean vertical, |
1341 shadow_type type) | 1322 shadow_type type) |
1342 { | 1323 { |
1343 Display *dpy = XtDisplay (mw); | 1324 Display *dpy = XtDisplay (mw); |
1344 GC top_gc; | 1325 GC top_gc; |
1345 GC bottom_gc; | 1326 GC bottom_gc; |
1346 unsigned offset = 0; | 1327 unsigned int offset = 0; |
1347 unsigned num_separators = 1; | 1328 unsigned int num_separators = 1; |
1348 unsigned top_line_thickness = 0; | 1329 unsigned int top_line_thickness = 0; |
1349 unsigned bottom_line_thickness = 0; | 1330 unsigned int bottom_line_thickness = 0; |
1350 Boolean dashed = False; | 1331 Boolean dashed = False; |
1351 int i; | |
1352 | 1332 |
1353 switch (type) | 1333 switch (type) |
1354 { | 1334 { |
1355 case SHADOW_NO_LINE: /* nothing to do */ | 1335 case SHADOW_NO_LINE: /* nothing to do */ |
1356 return; | 1336 return; |
1414 XChangeGC (dpy, bottom_gc, GCLineStyle, &values); | 1394 XChangeGC (dpy, bottom_gc, GCLineStyle, &values); |
1415 } | 1395 } |
1416 | 1396 |
1417 while (num_separators--) | 1397 while (num_separators--) |
1418 { | 1398 { |
1399 unsigned int i; | |
1419 for (i = 0; i < top_line_thickness; i++) | 1400 for (i = 0; i < top_line_thickness; i++) |
1420 XDrawLine (dpy, window, top_gc, x, y + i, x + width, y + i); | 1401 XDrawLine (dpy, window, top_gc, x, y + i, x + width, y + i); |
1421 | 1402 |
1422 for (i = 0; i < bottom_line_thickness; i++) | 1403 for (i = 0; i < bottom_line_thickness; i++) |
1423 XDrawLine (dpy, window, bottom_gc, | 1404 XDrawLine (dpy, window, bottom_gc, |
1457 static void | 1438 static void |
1458 print_widget_value (widget_value *wv, int just_one, int depth) | 1439 print_widget_value (widget_value *wv, int just_one, int depth) |
1459 { | 1440 { |
1460 char d [200]; | 1441 char d [200]; |
1461 int i; | 1442 int i; |
1462 for (i = 0; i < depth; i++) d[i] = ' '; | 1443 for (i = 0; i < depth; i++) |
1444 d[i] = ' '; | |
1463 d[depth]=0; | 1445 d[depth]=0; |
1464 if (!wv) | 1446 if (!wv) |
1465 { | 1447 { |
1466 printf ("%s(null widget value pointer)\n", d); | 1448 printf ("%s(null widget value pointer)\n", d); |
1467 return; | 1449 return; |
1508 if (val->type != UNSPECIFIED_TYPE) | 1490 if (val->type != UNSPECIFIED_TYPE) |
1509 return val->type; | 1491 return val->type; |
1510 else | 1492 else |
1511 { | 1493 { |
1512 #if SLOPPY_TYPES | 1494 #if SLOPPY_TYPES |
1513 if (all_dashes_p(val->name)) | 1495 if (all_dashes_p (val->name)) |
1514 return SEPARATOR_TYPE; | 1496 return SEPARATOR_TYPE; |
1515 else if (val->name && val->name[0] == '\0') /* push right */ | 1497 else if (val->name && val->name[0] == '\0') /* push right */ |
1516 return PUSHRIGHT_TYPE; | 1498 return PUSHRIGHT_TYPE; |
1517 else if (val->contents) /* cascade */ | 1499 else if (val->contents) /* cascade */ |
1518 return CASCADE_TYPE; | 1500 return CASCADE_TYPE; |
1528 | 1510 |
1529 static void | 1511 static void |
1530 label_button_size (XlwMenuWidget mw, | 1512 label_button_size (XlwMenuWidget mw, |
1531 widget_value *val, | 1513 widget_value *val, |
1532 Boolean in_menubar, | 1514 Boolean in_menubar, |
1533 unsigned *toggle_width, | 1515 unsigned int *toggle_width, |
1534 unsigned *label_width, | 1516 unsigned int *label_width, |
1535 unsigned *bindings_width, | 1517 unsigned int *bindings_width, |
1536 unsigned *height) | 1518 unsigned int *height) |
1537 { | 1519 { |
1538 *height = (mw->menu.font_ascent + mw->menu.font_descent + | 1520 *height = (mw->menu.font_ascent + mw->menu.font_descent + |
1539 2 * mw->menu.vertical_margin + | 1521 2 * mw->menu.vertical_margin + |
1540 2 * mw->menu.shadow_thickness); | 1522 2 * mw->menu.shadow_thickness); |
1541 /* no left column decoration */ | 1523 /* no left column decoration */ |
1550 widget_value *val, | 1532 widget_value *val, |
1551 Boolean in_menubar, | 1533 Boolean in_menubar, |
1552 Boolean highlighted, | 1534 Boolean highlighted, |
1553 Window window, | 1535 Window window, |
1554 int x, int y, | 1536 int x, int y, |
1555 unsigned width, | 1537 unsigned int width, |
1556 unsigned height, | 1538 unsigned int height, |
1557 unsigned label_offset, | 1539 unsigned int label_offset, |
1558 unsigned binding_tab) | 1540 unsigned int binding_tab) |
1559 { | 1541 { |
1560 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; | 1542 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; |
1561 GC gc; | 1543 GC gc; |
1562 | 1544 |
1563 if (!label_offset) | 1545 if (!label_offset) |
1568 else if (in_menubar || val->contents) | 1550 else if (in_menubar || val->contents) |
1569 gc = mw->menu.foreground_gc; | 1551 gc = mw->menu.foreground_gc; |
1570 else | 1552 else |
1571 gc = mw->menu.title_gc; | 1553 gc = mw->menu.title_gc; |
1572 | 1554 |
1573 /* | 1555 /* Draw the label string. */ |
1574 * Draw the label string. | |
1575 */ | |
1576 string_draw_u (mw, | 1556 string_draw_u (mw, |
1577 window, | 1557 window, |
1578 x + label_offset, y + y_offset, | 1558 x + label_offset, y + y_offset, |
1579 gc, | 1559 gc, |
1580 resource_widget_value (mw, val)); | 1560 resource_widget_value (mw, val)); |
1582 | 1562 |
1583 static void | 1563 static void |
1584 push_button_size (XlwMenuWidget mw, | 1564 push_button_size (XlwMenuWidget mw, |
1585 widget_value *val, | 1565 widget_value *val, |
1586 Boolean in_menubar, | 1566 Boolean in_menubar, |
1587 unsigned *toggle_width, | 1567 unsigned int *toggle_width, |
1588 unsigned *label_width, | 1568 unsigned int *label_width, |
1589 unsigned *bindings_width, | 1569 unsigned int *bindings_width, |
1590 unsigned *height) | 1570 unsigned int *height) |
1591 { | 1571 { |
1592 /* inherit */ | 1572 /* inherit */ |
1593 label_button_size (mw, val, in_menubar, | 1573 label_button_size (mw, val, in_menubar, |
1594 toggle_width, label_width, bindings_width, | 1574 toggle_width, label_width, bindings_width, |
1595 height); | 1575 height); |
1598 if (!in_menubar && val->key) | 1578 if (!in_menubar && val->key) |
1599 { | 1579 { |
1600 int w; | 1580 int w; |
1601 #ifdef NEED_MOTIF | 1581 #ifdef NEED_MOTIF |
1602 XmString key = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET); | 1582 XmString key = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET); |
1603 w = string_width(mw, key); | 1583 w = string_width (mw, key); |
1604 XmStringFree (key); | 1584 XmStringFree (key); |
1605 #else | 1585 #else |
1606 char *key = val->key; | 1586 char *key = val->key; |
1607 w = string_width (mw, key); | 1587 w = string_width (mw, key); |
1608 #endif | 1588 #endif |
1615 widget_value *val, | 1595 widget_value *val, |
1616 Boolean in_menubar, | 1596 Boolean in_menubar, |
1617 Boolean highlighted, | 1597 Boolean highlighted, |
1618 Window window, | 1598 Window window, |
1619 int x, int y, | 1599 int x, int y, |
1620 unsigned width, unsigned height, | 1600 unsigned int width, |
1621 unsigned label_offset, | 1601 unsigned int height, |
1622 unsigned binding_offset) | 1602 unsigned int label_offset, |
1603 unsigned int binding_offset) | |
1623 { | 1604 { |
1624 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; | 1605 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; |
1625 GC gc; | 1606 GC gc; |
1626 shadow_type type; | 1607 shadow_type type; |
1627 Boolean menu_pb = in_menubar && (menu_item_type (val) == BUTTON_TYPE); | 1608 Boolean menu_pb = in_menubar && (menu_item_type (val) == BUTTON_TYPE); |
1628 | 1609 |
1629 /* | 1610 /* Draw the label string. */ |
1630 * Draw the label string. | |
1631 */ | |
1632 if (!label_offset) | 1611 if (!label_offset) |
1633 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; | 1612 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; |
1634 | 1613 |
1635 if (highlighted) | 1614 if (highlighted) |
1636 { | 1615 { |
1656 | 1635 |
1657 string_draw_u (mw, | 1636 string_draw_u (mw, |
1658 window, | 1637 window, |
1659 x + label_offset, y + y_offset, | 1638 x + label_offset, y + y_offset, |
1660 gc, | 1639 gc, |
1661 resource_widget_value(mw, val)); | 1640 resource_widget_value (mw, val)); |
1662 | 1641 |
1663 /* | 1642 /* Draw the keybindings */ |
1664 * Draw the keybindings | |
1665 */ | |
1666 if (val->key) | 1643 if (val->key) |
1667 { | 1644 { |
1668 if (!binding_offset) | 1645 if (!binding_offset) |
1669 { | 1646 { |
1670 unsigned s_width = string_width (mw, resource_widget_value(mw, val)); | 1647 unsigned int s_width = |
1648 string_width (mw, resource_widget_value (mw, val)); | |
1671 binding_offset = label_offset + s_width + mw->menu.shadow_thickness; | 1649 binding_offset = label_offset + s_width + mw->menu.shadow_thickness; |
1672 } | 1650 } |
1673 binding_draw (mw, window, | 1651 binding_draw (mw, window, |
1674 x + binding_offset + mw->menu.column_spacing, | 1652 x + binding_offset + mw->menu.column_spacing, |
1675 y + y_offset, gc, val->key); | 1653 y + y_offset, gc, val->key); |
1676 } | 1654 } |
1677 | 1655 |
1678 /* | 1656 /* Draw the shadow */ |
1679 * Draw the shadow | |
1680 */ | |
1681 if (menu_pb) | 1657 if (menu_pb) |
1682 { | 1658 { |
1683 if (highlighted) | 1659 if (highlighted) |
1684 type = SHADOW_OUT; | 1660 type = SHADOW_OUT; |
1685 else | 1661 else |
1697 } | 1673 } |
1698 | 1674 |
1699 static unsigned int | 1675 static unsigned int |
1700 arrow_decoration_height (XlwMenuWidget mw) | 1676 arrow_decoration_height (XlwMenuWidget mw) |
1701 { | 1677 { |
1702 unsigned int result = | 1678 int result = (mw->menu.font_ascent + mw->menu.font_descent) / 2; |
1703 (mw->menu.font_ascent + mw->menu.font_descent) / (unsigned int)2; | |
1704 | 1679 |
1705 result += 2 * mw->menu.shadow_thickness; | 1680 result += 2 * mw->menu.shadow_thickness; |
1706 | 1681 |
1707 if (result > (mw->menu.font_ascent + mw->menu.font_descent)) | 1682 if (result > (mw->menu.font_ascent + mw->menu.font_descent)) |
1708 result = mw->menu.font_ascent + mw->menu.font_descent; | 1683 result = mw->menu.font_ascent + mw->menu.font_descent; |
1712 | 1687 |
1713 static void | 1688 static void |
1714 cascade_button_size (XlwMenuWidget mw, | 1689 cascade_button_size (XlwMenuWidget mw, |
1715 widget_value *val, | 1690 widget_value *val, |
1716 Boolean in_menubar, | 1691 Boolean in_menubar, |
1717 unsigned *toggle_width, | 1692 unsigned int *toggle_width, |
1718 unsigned *label_width, | 1693 unsigned int *label_width, |
1719 unsigned *arrow_width, | 1694 unsigned int *arrow_width, |
1720 unsigned *height) | 1695 unsigned int *height) |
1721 { | 1696 { |
1722 /* inherit */ | 1697 /* inherit */ |
1723 label_button_size (mw, val, in_menubar, | 1698 label_button_size (mw, val, in_menubar, |
1724 toggle_width, label_width, arrow_width, | 1699 toggle_width, label_width, arrow_width, |
1725 height); | 1700 height); |
1726 /* we have a pull aside arrow */ | 1701 /* we have a pull aside arrow */ |
1727 if (!in_menubar) | 1702 if (!in_menubar) |
1728 { | 1703 { |
1729 *arrow_width += arrow_decoration_height(mw) + mw->menu.column_spacing; | 1704 *arrow_width += arrow_decoration_height (mw) + mw->menu.column_spacing; |
1730 } | 1705 } |
1731 } | 1706 } |
1732 | 1707 |
1733 static void | 1708 static void |
1734 cascade_button_draw (XlwMenuWidget mw, | 1709 cascade_button_draw (XlwMenuWidget mw, |
1735 widget_value *val, | 1710 widget_value *val, |
1736 Boolean in_menubar, | 1711 Boolean in_menubar, |
1737 Boolean highlighted, | 1712 Boolean highlighted, |
1738 Window window, | 1713 Window window, |
1739 int x, int y, | 1714 int x, int y, |
1740 unsigned width, unsigned height, | 1715 unsigned int width, |
1741 unsigned label_offset, | 1716 unsigned int height, |
1742 unsigned binding_offset) | 1717 unsigned int label_offset, |
1718 unsigned int binding_offset) | |
1743 { | 1719 { |
1744 shadow_type type; | 1720 shadow_type type; |
1745 | 1721 |
1746 /* | 1722 /* Draw the label string. */ |
1747 * Draw the label string. | |
1748 */ | |
1749 label_button_draw (mw, val, in_menubar, highlighted, | 1723 label_button_draw (mw, val, in_menubar, highlighted, |
1750 window, x, y, width, height, label_offset, | 1724 window, x, y, width, height, label_offset, |
1751 binding_offset); | 1725 binding_offset); |
1752 | 1726 |
1753 /* | 1727 /* Draw the pull aside arrow */ |
1754 * Draw the pull aside arrow | |
1755 */ | |
1756 if (!in_menubar && val->contents) | 1728 if (!in_menubar && val->contents) |
1757 { | 1729 { |
1758 int y_offset; | 1730 int y_offset; |
1759 unsigned arrow_height = arrow_decoration_height (mw); | 1731 unsigned int arrow_height = arrow_decoration_height (mw); |
1760 | 1732 |
1761 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin + | 1733 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin + |
1762 (mw->menu.font_ascent+mw->menu.font_descent - arrow_height)/2; | 1734 (mw->menu.font_ascent+mw->menu.font_descent - arrow_height)/2; |
1763 | 1735 |
1764 if (!binding_offset) | 1736 if (!binding_offset) |
1765 { | 1737 { |
1766 unsigned s_width = string_width(mw, resource_widget_value (mw, val)); | 1738 unsigned int s_width = |
1739 string_width (mw, resource_widget_value (mw, val)); | |
1767 | 1740 |
1768 if (!label_offset) | 1741 if (!label_offset) |
1769 label_offset = mw->menu.shadow_thickness + | 1742 label_offset = mw->menu.shadow_thickness + |
1770 mw->menu.horizontal_margin; | 1743 mw->menu.horizontal_margin; |
1771 | 1744 |
1778 y + y_offset, | 1751 y + y_offset, |
1779 arrow_height, | 1752 arrow_height, |
1780 highlighted); | 1753 highlighted); |
1781 } | 1754 } |
1782 | 1755 |
1783 /* | 1756 /* Draw the shadow */ |
1784 * Draw the shadow | |
1785 */ | |
1786 if (highlighted) | 1757 if (highlighted) |
1787 type = SHADOW_OUT; | 1758 type = SHADOW_OUT; |
1788 else | 1759 else |
1789 type = SHADOW_BACKGROUND; | 1760 type = SHADOW_BACKGROUND; |
1790 | 1761 |
1791 shadow_draw(mw, window, x, y, width, height, type); | 1762 shadow_draw (mw, window, x, y, width, height, type); |
1792 } | 1763 } |
1793 | 1764 |
1794 static unsigned | 1765 static unsigned int |
1795 toggle_decoration_height(XlwMenuWidget mw) | 1766 toggle_decoration_height (XlwMenuWidget mw) |
1796 { | 1767 { |
1797 unsigned rv; | 1768 int rv; |
1798 if (mw->menu.indicator_size > 0) | 1769 if (mw->menu.indicator_size > 0) |
1799 rv = mw->menu.indicator_size; | 1770 rv = mw->menu.indicator_size; |
1800 else | 1771 else |
1801 rv = mw->menu.font_ascent; | 1772 rv = mw->menu.font_ascent; |
1802 | 1773 |
1803 if (rv > (mw->menu.font_ascent+mw->menu.font_descent)) | 1774 if (rv > (mw->menu.font_ascent + mw->menu.font_descent)) |
1804 rv = mw->menu.font_ascent+mw->menu.font_descent; | 1775 rv = mw->menu.font_ascent + mw->menu.font_descent; |
1805 | 1776 |
1806 /* | 1777 /* radio button can't be smaller than its border or a filling |
1807 * radio button can't be smaller than its border or a filling | 1778 error will occur. */ |
1808 * error will occur. | |
1809 */ | |
1810 if (rv < 2 * mw->menu.shadow_thickness) | 1779 if (rv < 2 * mw->menu.shadow_thickness) |
1811 rv = 2 * mw->menu.shadow_thickness; | 1780 rv = 2 * mw->menu.shadow_thickness; |
1812 | 1781 |
1813 return rv; | 1782 return rv; |
1814 } | 1783 } |
1815 | 1784 |
1816 static void | 1785 static void |
1817 toggle_button_size (XlwMenuWidget mw, | 1786 toggle_button_size (XlwMenuWidget mw, |
1818 widget_value *val, | 1787 widget_value *val, |
1819 Boolean in_menubar, | 1788 Boolean in_menubar, |
1820 unsigned *toggle_width, | 1789 unsigned int *toggle_width, |
1821 unsigned *label_width, | 1790 unsigned int *label_width, |
1822 unsigned *bindings_width, | 1791 unsigned int *bindings_width, |
1823 unsigned *height) | 1792 unsigned int *height) |
1824 { | 1793 { |
1825 /* inherit */ | 1794 /* inherit */ |
1826 push_button_size (mw, val, in_menubar, | 1795 push_button_size (mw, val, in_menubar, |
1827 toggle_width, label_width, bindings_width, | 1796 toggle_width, label_width, bindings_width, |
1828 height); | 1797 height); |
1829 /* we have a toggle */ | 1798 /* we have a toggle */ |
1830 *toggle_width += toggle_decoration_height(mw) + mw->menu.column_spacing; | 1799 *toggle_width += toggle_decoration_height (mw) + mw->menu.column_spacing; |
1831 } | 1800 } |
1832 | 1801 |
1833 static void | 1802 static void |
1834 toggle_button_draw (XlwMenuWidget mw, | 1803 toggle_button_draw (XlwMenuWidget mw, |
1835 widget_value *val, | 1804 widget_value *val, |
1836 Boolean in_menubar, | 1805 Boolean in_menubar, |
1837 Boolean highlighted, | 1806 Boolean highlighted, |
1838 Window window, | 1807 Window window, |
1839 int x, int y, | 1808 int x, int y, |
1840 unsigned width, unsigned height, | 1809 unsigned int width, |
1841 unsigned label_tab, | 1810 unsigned int height, |
1842 unsigned binding_tab) | 1811 unsigned int label_tab, |
1812 unsigned int binding_tab) | |
1843 { | 1813 { |
1844 int x_offset; | 1814 int x_offset; |
1845 int y_offset; | 1815 int y_offset; |
1846 unsigned t_height = toggle_decoration_height(mw); | 1816 unsigned int t_height = toggle_decoration_height (mw); |
1847 | 1817 |
1848 /* | 1818 /* Draw a toggle. */ |
1849 * Draw a toggle. | |
1850 */ | |
1851 x_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; | 1819 x_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; |
1852 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; | 1820 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; |
1853 y_offset += (mw->menu.font_ascent + mw->menu.font_descent - t_height)/2; | 1821 y_offset += (mw->menu.font_ascent + mw->menu.font_descent - t_height)/2; |
1854 | 1822 |
1855 toggle_decoration_draw (mw, window, x + x_offset, y + y_offset, | 1823 toggle_decoration_draw (mw, window, x + x_offset, y + y_offset, |
1856 t_height, val->selected); | 1824 t_height, val->selected); |
1857 | 1825 |
1858 /* | 1826 /* Draw the pushbutton parts. */ |
1859 * Draw the pushbutton parts. | |
1860 */ | |
1861 push_button_draw (mw, val, in_menubar, highlighted, window, x, y, width, | 1827 push_button_draw (mw, val, in_menubar, highlighted, window, x, y, width, |
1862 height, label_tab, binding_tab); | 1828 height, label_tab, binding_tab); |
1863 } | 1829 } |
1864 | 1830 |
1865 static unsigned | 1831 static unsigned int |
1866 radio_decoration_height(XlwMenuWidget mw) | 1832 radio_decoration_height (XlwMenuWidget mw) |
1867 { | 1833 { |
1868 return toggle_decoration_height(mw); | 1834 return toggle_decoration_height (mw); |
1869 } | 1835 } |
1870 | 1836 |
1871 static void | 1837 static void |
1872 radio_button_draw (XlwMenuWidget mw, | 1838 radio_button_draw (XlwMenuWidget mw, |
1873 widget_value *val, | 1839 widget_value *val, |
1874 Boolean in_menubar, | 1840 Boolean in_menubar, |
1875 Boolean highlighted, | 1841 Boolean highlighted, |
1876 Window window, | 1842 Window window, |
1877 int x, int y, | 1843 int x, int y, |
1878 unsigned width, unsigned height, | 1844 unsigned int width, |
1879 unsigned label_tab, | 1845 unsigned int height, |
1880 unsigned binding_tab) | 1846 unsigned int label_tab, |
1847 unsigned int binding_tab) | |
1881 { | 1848 { |
1882 int x_offset; | 1849 int x_offset; |
1883 int y_offset; | 1850 int y_offset; |
1884 unsigned r_height = radio_decoration_height(mw); | 1851 unsigned int r_height = radio_decoration_height (mw); |
1885 | 1852 |
1886 /* | 1853 /* Draw a toggle. */ |
1887 * Draw a toggle. | |
1888 */ | |
1889 x_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; | 1854 x_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; |
1890 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; | 1855 y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; |
1891 y_offset += (mw->menu.font_ascent + mw->menu.font_descent - r_height)/2; | 1856 y_offset += (mw->menu.font_ascent + mw->menu.font_descent - r_height)/2; |
1892 | 1857 |
1893 radio_decoration_draw (mw, window, x + x_offset, y + y_offset, r_height, | 1858 radio_decoration_draw (mw, window, x + x_offset, y + y_offset, r_height, |
1894 val->selected); | 1859 val->selected); |
1895 | 1860 |
1896 /* | 1861 /* Draw the pushbutton parts. */ |
1897 * Draw the pushbutton parts. | |
1898 */ | |
1899 push_button_draw (mw, val, in_menubar, highlighted, window, x, y, width, | 1862 push_button_draw (mw, val, in_menubar, highlighted, window, x, y, width, |
1900 height, label_tab, binding_tab); | 1863 height, label_tab, binding_tab); |
1901 } | 1864 } |
1902 | 1865 |
1903 static struct _shadow_names | 1866 static struct _shadow_names |
1924 }; | 1887 }; |
1925 | 1888 |
1926 static shadow_type | 1889 static shadow_type |
1927 separator_type (char *name) | 1890 separator_type (char *name) |
1928 { | 1891 { |
1929 int i; | |
1930 | |
1931 if (name) | 1892 if (name) |
1932 { | 1893 { |
1933 for (i = 0; i < XtNumber(shadow_names); i++ ) | 1894 int i; |
1895 for (i = 0; i < (int) (XtNumber (shadow_names)); i++ ) | |
1934 { | 1896 { |
1935 if (strcmp (name, shadow_names[i].name) == 0) | 1897 if (strcmp (name, shadow_names[i].name) == 0) |
1936 return shadow_names[i].type; | 1898 return shadow_names[i].type; |
1937 } | 1899 } |
1938 } | 1900 } |
1939 return SHADOW_BACKGROUND; | 1901 return SHADOW_BACKGROUND; |
1940 } | 1902 } |
1941 | 1903 |
1942 static unsigned | 1904 static unsigned int |
1943 separator_decoration_height (XlwMenuWidget mw, widget_value *val) | 1905 separator_decoration_height (XlwMenuWidget mw, widget_value *val) |
1944 { | 1906 { |
1945 | 1907 |
1946 switch (separator_type(val->value)) | 1908 switch (separator_type (val->value)) |
1947 { | 1909 { |
1948 case SHADOW_NO_LINE: | 1910 case SHADOW_NO_LINE: |
1949 case SHADOW_SINGLE_LINE: | 1911 case SHADOW_SINGLE_LINE: |
1950 case SHADOW_SINGLE_DASHED_LINE: | 1912 case SHADOW_SINGLE_DASHED_LINE: |
1951 return 1; | 1913 return 1; |
1966 | 1928 |
1967 static void | 1929 static void |
1968 separator_size (XlwMenuWidget mw, | 1930 separator_size (XlwMenuWidget mw, |
1969 widget_value *val, | 1931 widget_value *val, |
1970 Boolean in_menubar, | 1932 Boolean in_menubar, |
1971 unsigned *toggle_width, | 1933 unsigned int *toggle_width, |
1972 unsigned *label_width, | 1934 unsigned int *label_width, |
1973 unsigned *rest_width, | 1935 unsigned int *rest_width, |
1974 unsigned *height) | 1936 unsigned int *height) |
1975 { | 1937 { |
1976 *height = separator_decoration_height (mw, val); | 1938 *height = separator_decoration_height (mw, val); |
1977 *label_width = 1; | 1939 *label_width = 1; |
1978 *toggle_width = *rest_width = 0; | 1940 *toggle_width = *rest_width = 0; |
1979 } | 1941 } |
1983 widget_value *val, | 1945 widget_value *val, |
1984 Boolean in_menubar, | 1946 Boolean in_menubar, |
1985 Boolean highlighted, | 1947 Boolean highlighted, |
1986 Window window, | 1948 Window window, |
1987 int x, int y, | 1949 int x, int y, |
1988 unsigned width, unsigned height, | 1950 unsigned int width, |
1989 unsigned label_tab, | 1951 unsigned int height, |
1990 unsigned binding_tab) | 1952 unsigned int label_tab, |
1991 { | 1953 unsigned int binding_tab) |
1992 unsigned sep_width; | 1954 { |
1955 unsigned int sep_width; | |
1993 | 1956 |
1994 if (in_menubar) | 1957 if (in_menubar) |
1995 sep_width = height; | 1958 sep_width = height; |
1996 else | 1959 else |
1997 sep_width = width; | 1960 sep_width = width; |
2007 | 1970 |
2008 static void | 1971 static void |
2009 pushright_size (XlwMenuWidget mw, | 1972 pushright_size (XlwMenuWidget mw, |
2010 widget_value *val, | 1973 widget_value *val, |
2011 Boolean in_menubar, | 1974 Boolean in_menubar, |
2012 unsigned *toggle_width, | 1975 unsigned int *toggle_width, |
2013 unsigned *label_width, | 1976 unsigned int *label_width, |
2014 unsigned *rest_width, | 1977 unsigned int *rest_width, |
2015 unsigned *height | 1978 unsigned int *height) |
2016 ) | |
2017 { | 1979 { |
2018 *height = *label_width = *toggle_width = *rest_width = 0; | 1980 *height = *label_width = *toggle_width = *rest_width = 0; |
2019 } | 1981 } |
2020 | 1982 |
2021 static void | 1983 static void |
2022 size_menu_item (XlwMenuWidget mw, | 1984 size_menu_item (XlwMenuWidget mw, |
2023 widget_value *val, | 1985 widget_value *val, |
2024 int horizontal, | 1986 int horizontal, |
2025 unsigned *toggle_width, | 1987 unsigned int *toggle_width, |
2026 unsigned *label_width, | 1988 unsigned int *label_width, |
2027 unsigned *rest_width, | 1989 unsigned int *rest_width, |
2028 unsigned *height | 1990 unsigned int *height) |
2029 ) | |
2030 { | 1991 { |
2031 void (*function_ptr) (XlwMenuWidget _mw, | 1992 void (*function_ptr) (XlwMenuWidget _mw, |
2032 widget_value *_val, | 1993 widget_value *_val, |
2033 Boolean _in_menubar, | 1994 Boolean _in_menubar, |
2034 unsigned *_toggle_width, | 1995 unsigned int *_toggle_width, |
2035 unsigned *_label_width, | 1996 unsigned int *_label_width, |
2036 unsigned *_rest_width, | 1997 unsigned int *_rest_width, |
2037 unsigned *_height); | 1998 unsigned int *_height); |
2038 | 1999 |
2039 switch (menu_item_type (val)) | 2000 switch (menu_item_type (val)) |
2040 { | 2001 { |
2041 case TOGGLE_TYPE: | 2002 case TOGGLE_TYPE: |
2042 case RADIO_TYPE: | 2003 case RADIO_TYPE: |
2080 Boolean just_compute) | 2041 Boolean just_compute) |
2081 { | 2042 { |
2082 | 2043 |
2083 int x = where->x /* + mw->menu.shadow_thickness */ ; | 2044 int x = where->x /* + mw->menu.shadow_thickness */ ; |
2084 int y = where->y /* + mw->menu.shadow_thickness */ ; | 2045 int y = where->y /* + mw->menu.shadow_thickness */ ; |
2085 unsigned toggle_width; | 2046 unsigned int toggle_width; |
2086 unsigned label_width; | 2047 unsigned int label_width; |
2087 unsigned binding_width; | 2048 unsigned int binding_width; |
2088 unsigned width; | 2049 unsigned int width; |
2089 unsigned height; | 2050 unsigned int height; |
2090 unsigned label_tab; | 2051 unsigned int label_tab; |
2091 unsigned binding_tab; | 2052 unsigned int binding_tab; |
2092 void (*function_ptr) (XlwMenuWidget _mw, | 2053 void (*function_ptr) (XlwMenuWidget _mw, |
2093 widget_value *_val, | 2054 widget_value *_val, |
2094 Boolean _in_menubar, | 2055 Boolean _in_menubar, |
2095 Boolean _highlighted, | 2056 Boolean _highlighted, |
2096 Window _window, | 2057 Window _window, |
2097 int _x, int _y, | 2058 int _x, int _y, |
2098 unsigned _width, unsigned _height, | 2059 unsigned int _width, |
2099 unsigned _label_tab, | 2060 unsigned int _height, |
2100 unsigned _binding_tab); | 2061 unsigned int _label_tab, |
2062 unsigned int _binding_tab); | |
2101 | 2063 |
2102 size_menu_item (mw, val, horizontal, | 2064 size_menu_item (mw, val, horizontal, |
2103 &toggle_width, &label_width, &binding_width, &height); | 2065 &toggle_width, &label_width, &binding_width, &height); |
2104 | 2066 |
2105 if (horizontal) | 2067 if (horizontal) |
2160 } | 2122 } |
2161 | 2123 |
2162 static void | 2124 static void |
2163 size_menu (XlwMenuWidget mw, int level) | 2125 size_menu (XlwMenuWidget mw, int level) |
2164 { | 2126 { |
2165 unsigned toggle_width; | 2127 unsigned int toggle_width; |
2166 unsigned label_width; | 2128 unsigned int label_width; |
2167 unsigned rest_width; | 2129 unsigned int rest_width; |
2168 unsigned height; | 2130 unsigned int height; |
2169 unsigned max_toggle_width = 0; | 2131 unsigned int max_toggle_width = 0; |
2170 unsigned max_label_width = 0; | 2132 unsigned int max_label_width = 0; |
2171 unsigned max_rest_width = 0; | 2133 unsigned int max_rest_width = 0; |
2172 unsigned max_height = 0; | 2134 unsigned int max_height = 0; |
2173 int horizontal_p = mw->menu.horizontal && (level == 0); | 2135 int horizontal_p = mw->menu.horizontal && (level == 0); |
2174 widget_value* val; | 2136 widget_value* val; |
2175 window_state* ws; | 2137 window_state* ws; |
2176 | 2138 |
2177 if (level >= mw->menu.old_depth) | 2139 if (level >= mw->menu.old_depth) |
2641 xgcv.font = mw->menu.font->fid; | 2603 xgcv.font = mw->menu.font->fid; |
2642 #endif | 2604 #endif |
2643 | 2605 |
2644 xgcv.foreground = mw->core.background_pixel; | 2606 xgcv.foreground = mw->core.background_pixel; |
2645 xgcv.background = mw->menu.foreground; | 2607 xgcv.background = mw->menu.foreground; |
2646 mw->menu.background_gc = XtGetGC ((Widget)mw, flags, &xgcv); | 2608 mw->menu.background_gc = XtGetGC ((Widget) mw, flags, &xgcv); |
2647 | 2609 |
2648 xgcv.foreground = mw->menu.foreground; | 2610 xgcv.foreground = mw->menu.foreground; |
2649 xgcv.background = mw->core.background_pixel; | 2611 xgcv.background = mw->core.background_pixel; |
2650 mw->menu.foreground_gc = XtGetGC ((Widget)mw, flags, &xgcv); | 2612 mw->menu.foreground_gc = XtGetGC ((Widget) mw, flags, &xgcv); |
2651 | 2613 |
2652 if (mw->menu.select_color != (Pixel)-1) | 2614 if (mw->menu.select_color != (Pixel)-1) |
2653 { | 2615 { |
2654 xgcv.foreground = mw->menu.select_color; | 2616 xgcv.foreground = mw->menu.select_color; |
2655 } | 2617 } |
2664 { /* color */ | 2626 { /* color */ |
2665 XColor xcolor; | 2627 XColor xcolor; |
2666 Colormap cmap = mw->core.colormap; | 2628 Colormap cmap = mw->core.colormap; |
2667 xcolor.pixel = mw->core.background_pixel; | 2629 xcolor.pixel = mw->core.background_pixel; |
2668 XQueryColor (dpy, cmap, &xcolor); | 2630 XQueryColor (dpy, cmap, &xcolor); |
2669 xcolor.red *= 0.85; | 2631 xcolor.red = (xcolor.red * 17) / 20; |
2670 xcolor.green *= 0.85; | 2632 xcolor.green = (xcolor.green * 17) / 20; |
2671 xcolor.blue *= 0.85; | 2633 xcolor.blue = (xcolor.blue * 17) / 20; |
2672 if (allocate_nearest_color (dpy, cmap, &xcolor)) | 2634 if (allocate_nearest_color (dpy, cmap, &xcolor)) |
2673 xgcv.foreground = xcolor.pixel; | 2635 xgcv.foreground = xcolor.pixel; |
2674 } | 2636 } |
2675 } | 2637 } |
2676 xgcv.background = mw->core.background_pixel; | 2638 xgcv.background = mw->core.background_pixel; |
2736 Display *dpy = XtDisplay ((Widget) mw); | 2698 Display *dpy = XtDisplay ((Widget) mw); |
2737 Colormap cmap = mw->core.colormap; | 2699 Colormap cmap = mw->core.colormap; |
2738 XColor topc, botc; | 2700 XColor topc, botc; |
2739 int top_frobbed = 0, bottom_frobbed = 0; | 2701 int top_frobbed = 0, bottom_frobbed = 0; |
2740 | 2702 |
2741 if (mw->menu.top_shadow_color == -1) | 2703 if (mw->menu.top_shadow_color == (Pixel) (-1)) |
2742 mw->menu.top_shadow_color = mw->core.background_pixel; | 2704 mw->menu.top_shadow_color = mw->core.background_pixel; |
2743 if (mw->menu.bottom_shadow_color == -1) | 2705 if (mw->menu.bottom_shadow_color == (Pixel) (-1)) |
2744 mw->menu.bottom_shadow_color = mw->menu.foreground; | 2706 mw->menu.bottom_shadow_color = mw->menu.foreground; |
2745 | 2707 |
2746 if (mw->menu.top_shadow_color == mw->core.background_pixel || | 2708 if (mw->menu.top_shadow_color == mw->core.background_pixel || |
2747 mw->menu.top_shadow_color == mw->menu.foreground) | 2709 mw->menu.top_shadow_color == mw->menu.foreground) |
2748 { | 2710 { |
2776 if (mw->menu.bottom_shadow_color == mw->menu.foreground || | 2738 if (mw->menu.bottom_shadow_color == mw->menu.foreground || |
2777 mw->menu.bottom_shadow_color == mw->core.background_pixel) | 2739 mw->menu.bottom_shadow_color == mw->core.background_pixel) |
2778 { | 2740 { |
2779 botc.pixel = mw->core.background_pixel; | 2741 botc.pixel = mw->core.background_pixel; |
2780 XQueryColor (dpy, cmap, &botc); | 2742 XQueryColor (dpy, cmap, &botc); |
2781 botc.red *= 0.6; | 2743 botc.red = (botc.red * 3) / 5; |
2782 botc.green *= 0.6; | 2744 botc.green = (botc.green * 3) / 5; |
2783 botc.blue *= 0.6; | 2745 botc.blue = (botc.blue * 3) / 5; |
2784 if (allocate_nearest_color (dpy, cmap, &botc)) | 2746 if (allocate_nearest_color (dpy, cmap, &botc)) |
2785 { | 2747 { |
2786 if (botc.pixel == mw->core.background_pixel) | 2748 if (botc.pixel == mw->core.background_pixel) |
2787 { | 2749 { |
2788 XFreeColors (dpy, cmap, &botc.pixel, 1, 0); | 2750 XFreeColors (dpy, cmap, &botc.pixel, 1, 0); |
3082 } | 3044 } |
3083 | 3045 |
3084 static void | 3046 static void |
3085 XlwMenuClassInitialize (void) | 3047 XlwMenuClassInitialize (void) |
3086 { | 3048 { |
3087 Initialize_massaged_resource_char(); | 3049 initialize_massaged_resource_char(); |
3088 } | 3050 } |
3089 | 3051 |
3090 static void | 3052 static void |
3091 XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes) | 3053 XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes) |
3092 { | 3054 { |
3290 handle_motion_event (XlwMenuWidget mw, XMotionEvent *ev, | 3252 handle_motion_event (XlwMenuWidget mw, XMotionEvent *ev, |
3291 Boolean select_p) | 3253 Boolean select_p) |
3292 { | 3254 { |
3293 int x = ev->x_root; | 3255 int x = ev->x_root; |
3294 int y = ev->y_root; | 3256 int y = ev->y_root; |
3295 int state = ev->state; | 3257 unsigned int state = ev->state; |
3296 XMotionEvent *event= ev, dummy; | 3258 XMotionEvent *event= ev, dummy; |
3297 | 3259 |
3298 /* allow motion events to be generated again */ | 3260 /* allow motion events to be generated again */ |
3299 dummy.window = ev->window; | 3261 dummy.window = ev->window; |
3300 if (ev->is_hint | 3262 if (ev->is_hint |