3 /* $Header: /u/src/emacs/19.0/oldXMenu/RCS/Internal.c,v 1.1 1992/04/11 22:10:20 jimb Exp $ */
4 /* Copyright Massachusetts Institute of Technology 1985 */
7 * XMenu: MIT Project Athena, X Window system menu package
9 * XMenuInternal.c - XMenu internal (not user visible) routines.
11 * Author: Tony Della Fera, DEC
22 #define toggle_color(x) \
23 ((x) == menu->bkgnd_color ? menu->s_frg_color : menu->bkgnd_color)
26 * Internal Window creation queue sizes.
28 #define S_QUE_SIZE 300
30 #define BUFFER_SIZE (S_QUE_SIZE >= P_QUE_SIZE ? S_QUE_SIZE : P_QUE_SIZE)
34 * XMWinQue - Internal window creation queue datatype.
36 typedef struct _xmwinquedef
{
38 XMSelect
*sq
[S_QUE_SIZE
];
41 XMPane
*pq
[P_QUE_SIZE
];
46 * _XMWinQue - Internal static window creation queue.
48 static Bool _XMWinQueIsInit
= False
;
49 static XMWinQue _XMWinQue
;
52 * _XMErrorCode - Global XMenu error code.
54 int _XMErrorCode
= XME_NO_ERROR
;
56 * _XMErrorList - Global XMenu error code description strings.
59 _XMErrorList
[XME_CODE_COUNT
] = {
60 "No error", /* XME_NO_ERROR */
61 "Menu not initialized", /* XME_NOT_INIT */
62 "Argument out of bounds", /* XME_ARG_BOUNDS */
63 "Pane not found", /* XME_P_NOT_FOUND */
64 "Selection not found", /* XME_S_NOT_FOUND */
65 "Invalid menu style parameter", /* XME_STYLE_PARAM */
66 "Unable to grab mouse", /* XME_GRAB_MOUSE */
67 "Unable to interpret locator", /* XME_INTERP_LOC */
68 "Unable to calloc memory", /* XME_CALLOC */
69 "Unable to create XAssocTable", /* XME_CREATE_ASSOC */
70 "Unable to store bitmap", /* XME_STORE_BITMAP */
71 "Unable to make tile pixmaps", /* XME_MAKE_TILES */
72 "Unable to make pixmap", /* XME_MAKE_PIXMAP */
73 "Unable to create cursor", /* XME_CREATE_CURSOR */
74 "Unable to open font", /* XME_OPEN_FONT */
75 "Unable to create windows", /* XME_CREATE_WINDOW */
76 "Unable to create transparencies", /* XME_CREATE_TRANSP */
80 * _XMEventHandler - Internal event handler variable.
82 int (*_XMEventHandler
)() = NULL
;
87 * _XMWinQueInit - Internal routine to initialize the window
93 * If the queue is not initialized initialize it.
95 if (!_XMWinQueIsInit
) {
97 * Blank the queue structure.
101 for (i
= 0; i
< S_QUE_SIZE
; i
++)
104 for (i
= 0; i
< P_QUE_SIZE
; i
++)
107 _XMWinQue
.sq_size
= _XMWinQue
.pq_size
= 0;
110 * Initialize the next free location pointers.
112 _XMWinQue
.sq_ptr
= _XMWinQue
.sq
;
113 _XMWinQue
.pq_ptr
= _XMWinQue
.pq
;
120 * _XMWinQueAddPane - Internal routine to add a pane to the pane
124 _XMWinQueAddPane(display
, menu
, p_ptr
)
125 register Display
*display
;
126 register XMenu
*menu
; /* Menu being manipulated. */
127 register XMPane
*p_ptr
; /* XMPane being queued. */
130 * If the queue is currently full then flush it.
132 if (_XMWinQue
.pq_size
== P_QUE_SIZE
) {
133 if (_XMWinQueFlush(display
, menu
, 0, 0) == _FAILURE
) return(_FAILURE
);
137 * Insert the new XMPane pointer and increment the queue pointer
138 * and the queue size.
140 *_XMWinQue
.pq_ptr
= p_ptr
;
145 * All went well, return successfully.
147 _XMErrorCode
= XME_NO_ERROR
;
154 * _XMWinQueAddSelection - Internal routine to add a selection to
155 * the selection window queue.
158 _XMWinQueAddSelection(display
, menu
, s_ptr
)
159 register Display
*display
;
160 register XMenu
*menu
; /* Menu being manipulated. */
161 register XMSelect
*s_ptr
; /* XMSelection being queued. */
164 * If this entry will overflow the queue then flush it.
166 if (_XMWinQue
.sq_size
== S_QUE_SIZE
) {
167 if (_XMWinQueFlush(display
, menu
, 0, 0) == _FAILURE
) return(_FAILURE
);
171 * Insert the new XMSelect pointer and increment the queue pointer
172 * and the queue size.
174 *_XMWinQue
.sq_ptr
= s_ptr
;
179 * All went well, return successfully.
181 _XMErrorCode
= XME_NO_ERROR
;
188 * _XMWinQueFlush - Internal routine to flush the pane and
189 * selection window queues.
192 _XMWinQueFlush(display
, menu
, pane
, select
)
193 register Display
*display
;
194 register XMenu
*menu
; /* Menu being manipulated. */
195 register XMPane
*pane
; /* Current pane. */
197 register int pq_index
; /* Pane queue index. */
198 register int sq_index
; /* Selection queue index. */
199 register XMPane
*p_ptr
; /* XMPane pointer. */
200 register XMSelect
*s_ptr
; /* XMSelect pointer. */
201 unsigned long valuemask
; /* Which attributes to set. */
202 XSetWindowAttributes
*attributes
; /* Attributes to be set. */
205 * If the pane window queue is not empty...
208 if (_XMWinQue
.pq_size
> 0) {
210 * set up attributes for pane window to be created.
212 valuemask
= (CWBackPixmap
| CWBorderPixel
| CWOverrideRedirect
);
213 attributes
= (XSetWindowAttributes
*)malloc(sizeof(XSetWindowAttributes
));
214 attributes
->border_pixel
= menu
->p_bdr_color
;
215 attributes
->background_pixmap
= menu
->inact_pixmap
;
216 attributes
->override_redirect
= True
;
219 * Create all the pending panes in order, so that the
220 * current pane will be on top, with the others
221 * stacked appropriately under it.
223 for (pq_index
= _XMWinQue
.pq_size
- 1;
227 p_ptr
= _XMWinQue
.pq
[pq_index
]; /* Retrieve next pane. */
228 if (p_ptr
== pane
) break;
229 p_ptr
->window
= XCreateWindow(display
,
241 XMakeAssoc(display
, menu
->assoc_tab
, p_ptr
->window
, p_ptr
);
242 XSelectInput(display
, p_ptr
->window
, menu
->p_events
);
245 pq_index
< _XMWinQue
.pq_size
;
248 p_ptr
= _XMWinQue
.pq
[pq_index
]; /* Retrieve next pane. */
249 p_ptr
->window
= XCreateWindow(display
,
261 XMakeAssoc(display
, menu
->assoc_tab
, p_ptr
->window
, p_ptr
);
262 XSelectInput(display
, p_ptr
->window
, menu
->p_events
);
263 if (p_ptr
== pane
) break;
267 * Reset the pane queue pointer and size.
269 _XMWinQue
.pq_size
= 0;
270 _XMWinQue
.pq_ptr
= _XMWinQue
.pq
;
274 * If the selection window queue is not empty...
277 if (_XMWinQue
.sq_size
> 0) {
279 for (sq_index
= 0; sq_index
< _XMWinQue
.sq_size
; sq_index
++) {
281 * Retrieve the XMSelect pointer.
283 s_ptr
= _XMWinQue
.sq
[sq_index
];
284 s_ptr
->window
= XCreateWindow(display
,
285 s_ptr
->parent_p
->window
,
298 * Insert the new window id and its
299 * associated XMSelect structure into the
302 XMakeAssoc(display
, menu
->assoc_tab
, s_ptr
->window
, s_ptr
);
303 XSelectInput(display
, s_ptr
->window
, menu
->s_events
);
307 * Reset the selection queue pointer and size.
309 _XMWinQue
.sq_size
= 0;
310 _XMWinQue
.sq_ptr
= _XMWinQue
.sq
;
314 * Flush X's internal queues.
319 * All went well, return successfully.
321 _XMErrorCode
= XME_NO_ERROR
;
328 * _XMGetPanePtr - Given a menu pointer and a pane index number, return
329 * a pane pointer that points to the indexed pane.
332 _XMGetPanePtr(menu
, p_num
)
333 register XMenu
*menu
; /* Menu to find the pane in. */
334 register int p_num
; /* Index number of pane to find. */
336 register XMPane
*p_ptr
; /* Pane pointer to be returned. */
337 register int i
; /* Loop counter. */
340 * Is the pane number out of range?
342 if ((p_num
< 0) || (p_num
> (menu
->p_count
- 1))) {
343 _XMErrorCode
= XME_P_NOT_FOUND
;
348 * Find the right pane.
350 p_ptr
= menu
->p_list
->next
;
351 for (i
= 0; i
< p_num
; i
++) p_ptr
= p_ptr
->next
;
354 * Return successfully.
356 _XMErrorCode
= XME_NO_ERROR
;
363 * _XMGetSelectionPtr - Given pane pointer and a selection index number,
364 * return a selection pointer that points to the
368 _XMGetSelectionPtr(p_ptr
, s_num
)
369 register XMPane
*p_ptr
; /* Pane to find the selection in. */
370 register int s_num
; /* Index number of the selection to find. */
372 register XMSelect
*s_ptr
; /* Selection pointer to be returned. */
373 register int i
; /* Loop counter. */
376 * Is the selection number out of range?
378 if ((s_num
< 0) || (s_num
> (p_ptr
->s_count
- 1))) {
379 _XMErrorCode
= XME_S_NOT_FOUND
;
384 * Find the right selection.
386 s_ptr
= p_ptr
->s_list
->next
;
387 for (i
= 0; i
< s_num
; i
++) s_ptr
= s_ptr
->next
;
390 * Return successfully.
392 _XMErrorCode
= XME_NO_ERROR
;
399 * _XMRecomputeGlobals - Internal subroutine to recompute menu wide
402 _XMRecomputeGlobals(display
, menu
)
403 register Display
*display
; /*X11 display variable. */
404 register XMenu
*menu
; /* Menu object to compute from. */
406 register XMPane
*p_ptr
; /* Pane pointer. */
407 register XMSelect
*s_ptr
; /* Selection pointer. */
409 register int max_p_label
= 0; /* Maximum pane label width. */
410 register int max_s_label
= 0; /* Maximum selection label width. */
411 register int s_count
= 0; /* Maximum selection count. */
413 int p_s_pad
; /* Pane <-> selection padding. */
414 int p_s_diff
; /* Pane <-> selection separation. */
416 int p_height
; /* Pane window height. */
417 int p_width
; /* Pane window width. */
418 int s_width
; /* Selection window width. */
420 int screen
; /* DefaultScreen holder. */
426 p_ptr
= menu
->p_list
->next
;
427 p_ptr
!= menu
->p_list
;
432 * Recompute maximum pane label width.
434 max_p_label
= max(max_p_label
, p_ptr
->label_width
);
437 * Recompute maximum selection count.
439 s_count
= max(s_count
, p_ptr
->s_count
);
442 * For each selection in the current pane...
445 s_ptr
= p_ptr
->s_list
->next
;
446 s_ptr
!= p_ptr
->s_list
;
451 * Recompute maximum selection label width.
453 max_s_label
= max(max_s_label
, s_ptr
->label_width
);
458 * Recompute pane height.
460 p_height
= (menu
->flag_height
<< 1) + (menu
->s_y_off
* s_count
);
463 * Recompute horizontal padding between the pane window and the
466 p_s_pad
= menu
->p_x_off
<< 1;
469 * Recompute pane and selection window widths.
470 * This is done by first computing the window sizes from the maximum
471 * label widths. If the spacing between the selection window and the
472 * containing pane window is less than the pane selection padding value
473 * (twice the pane X offset) then change the size of the pane to be
474 * the size of the selection window plus the padding. If, however the
475 * spacing between the selection window and the containing pane window
476 * is more than the pane selection padding value increase the size of
477 * the selection to its maximum possible value (the pane width minus
478 * the pane selection padding value).
480 p_width
= max_p_label
+ p_s_pad
;
481 s_width
= max_s_label
+ (menu
->s_fnt_pad
<< 1) + (menu
->s_bdr_width
<< 1);
482 p_s_diff
= p_width
- s_width
;
483 if (p_s_diff
< p_s_pad
) {
484 p_width
= s_width
+ p_s_pad
;
486 else if (p_s_diff
> p_s_pad
) {
487 s_width
= p_width
- p_s_pad
;
491 * Reset menu wide global values.
493 menu
->s_count
= s_count
;
494 menu
->p_height
= p_height
;
495 menu
->p_width
= p_width
;
496 menu
->s_width
= s_width
;
499 * Ensure that the origin of the menu is placed so that
500 * None of the panes ore selections are off the screen.
502 screen
= DefaultScreen(display
);
503 if (menu
->x_pos
+ menu
->width
> DisplayWidth(display
, screen
))
504 menu
->x_pos
= DisplayWidth(display
, screen
) - menu
->width
;
505 else if (menu
->x_pos
< 0) menu
->x_pos
= 0;
506 if(menu
->y_pos
+ menu
->height
> DisplayHeight(display
, screen
))
507 menu
->y_pos
= DisplayHeight(display
, screen
) - menu
->height
;
508 else if (menu
->y_pos
< 0) menu
->y_pos
= 0;
513 * _XMRecomputePane - Internal subroutine to recompute pane
514 * window dependencies.
517 _XMRecomputePane(display
, menu
, p_ptr
, p_num
)
518 register Display
*display
; /* Standard X display variable. */
519 register XMenu
*menu
; /* Menu object being recomputed. */
520 register XMPane
*p_ptr
; /* Pane pointer. */
521 register int p_num
; /* Pane sequence number. */
523 register int window_x
; /* Recomputed window X coordinate. */
524 register int window_y
; /* Recomputed window Y coordinate. */
526 unsigned long change_mask
; /* Value mask to reconfigure window. */
527 XWindowChanges
*changes
; /* Values to use in configure window. */
529 register Bool config_p
= False
; /* Reconfigure pane window? */
532 * Update the pane serial number.
534 p_ptr
->serial
= p_num
;
537 * Recompute window X and Y coordinates.
539 switch (menu
->menu_style
) {
541 window_x
= menu
->p_x_off
* ((menu
->p_count
- 1) - p_num
);
542 window_y
= menu
->p_y_off
* ((menu
->p_count
- 1) - p_num
);
545 window_x
= menu
->p_x_off
* p_num
;
546 window_y
= menu
->p_y_off
* ((menu
->p_count
- 1) - p_num
);
550 window_y
= menu
->p_y_off
* ((menu
->p_count
- 1) - p_num
);
553 /* Error! Invalid style parameter. */
554 _XMErrorCode
= XME_STYLE_PARAM
;
557 window_x
+= menu
->x_pos
;
558 window_y
+= menu
->y_pos
;
561 * If the newly compute pane coordinates differ from the
562 * current coordinates, reset the current coordinates and
563 * reconfigure the pane.
566 (window_x
!= p_ptr
->window_x
) ||
567 (window_y
!= p_ptr
->window_y
)
570 * Reset the coordinates and schedule
571 * the pane for reconfiguration.
573 p_ptr
->window_x
= window_x
;
574 p_ptr
->window_y
= window_y
;
579 * If the local pane width and height differs from the
580 * menu pane width and height, reset the local values.
583 (p_ptr
->window_w
!= menu
->p_width
) ||
584 (p_ptr
->window_h
!= menu
->p_height
)
587 * Reset window width and height and schedule
588 * the pane for reconfiguration.
590 p_ptr
->window_w
= menu
->p_width
;
591 p_ptr
->window_h
= menu
->p_height
;
596 * If we need to reconfigure the pane window do it now.
598 if (config_p
== True
) {
600 * If the pane window has already been created then
601 * reconfigure the existing window, otherwise queue
602 * it for creation with the new configuration.
605 change_mask
= (CWX
| CWY
| CWWidth
| CWHeight
);
606 changes
= (XWindowChanges
*)malloc(sizeof(XWindowChanges
));
607 changes
->x
= p_ptr
->window_x
;
608 changes
->y
= p_ptr
->window_y
;
609 changes
->width
= p_ptr
->window_w
;
610 changes
->height
= p_ptr
->window_h
;
622 if (_XMWinQueAddPane(display
, menu
, p_ptr
) == _FAILURE
) {
629 * Recompute label X position.
631 switch (menu
->p_style
) {
633 p_ptr
->label_x
= menu
->p_x_off
+ menu
->p_fnt_pad
;
636 p_ptr
->label_x
= menu
->p_width
-
637 (p_ptr
->label_width
+ menu
->p_x_off
+ menu
->p_fnt_pad
);
640 p_ptr
->label_x
= (menu
->p_width
- p_ptr
->label_width
) >> 1;
643 /* Error! Invalid style parameter. */
644 _XMErrorCode
= XME_STYLE_PARAM
;
648 * Recompute label Y positions.
650 p_ptr
->label_uy
= menu
->p_fnt_pad
+ menu
->p_fnt_info
->max_bounds
.ascent
;
651 p_ptr
->label_ly
= (menu
->p_height
- menu
->p_fnt_pad
- menu
->p_fnt_info
->max_bounds
.descent
);
654 * All went well, return successfully.
656 _XMErrorCode
= XME_NO_ERROR
;
663 * _XMRecomputeSelection - Internal subroutine to recompute
664 * selection window dependencies.
667 _XMRecomputeSelection(display
, menu
, s_ptr
, s_num
)
668 register Display
*display
;
669 register XMenu
*menu
; /* Menu object being recomputed. */
670 register XMSelect
*s_ptr
; /* Selection pointer. */
671 register int s_num
; /* Selection sequence number. */
673 register Bool config_s
= False
; /* Reconfigure selection window? */
674 XWindowChanges
*changes
; /* Values to change in configure. */
675 unsigned long change_mask
; /* Value mask for XConfigureWindow. */
678 * If the selection serial numbers are out of order, begin
679 * resequencing selections. Recompute selection window coordinates
682 * When selections are created they are given a serial number of
683 * -1, this causes this routine to give a new selection
684 * its initial coordinates and serial number.
686 if (s_ptr
->serial
!= s_num
) {
688 * Fix the sequence number.
690 s_ptr
->serial
= s_num
;
692 * Recompute window X and Y coordinates.
694 s_ptr
->window_x
= menu
->s_x_off
;
695 s_ptr
->window_y
= menu
->flag_height
+ (menu
->s_y_off
* s_num
);
697 * We must reconfigure the window.
703 * If the local selection width and height differs from the
704 * menu selection width and height, reset the local values.
707 (s_ptr
->window_w
!= menu
->s_width
) ||
708 (s_ptr
->window_h
!= menu
->s_height
)
711 * We must reconfigure the window.
715 * Reset window width and height.
717 s_ptr
->window_w
= menu
->s_width
;
718 s_ptr
->window_h
= menu
->s_height
;
722 * If we need to reconfigure the selection window do it now.
724 if (config_s
== True
) {
726 * If the selection window has already been created then
727 * reconfigure the existing window, otherwise queue it
728 * for creation with the new configuration.
731 changes
= (XWindowChanges
*)malloc(sizeof(XWindowChanges
));
732 change_mask
= (CWX
| CWY
| CWWidth
| CWHeight
);
733 changes
= (XWindowChanges
*)malloc(sizeof(XWindowChanges
));
734 changes
->x
= s_ptr
->window_x
;
735 changes
->y
= s_ptr
->window_y
;
736 changes
->width
= s_ptr
->window_w
;
737 changes
->height
= s_ptr
->window_h
;
749 if (_XMWinQueAddSelection(display
, menu
, s_ptr
) == _FAILURE
) {
756 * Recompute label X position.
758 switch (menu
->s_style
) {
760 s_ptr
->label_x
= menu
->s_bdr_width
+ menu
->s_fnt_pad
+ s_ptr
->window_x
;
763 s_ptr
->label_x
= s_ptr
->window_x
+ menu
->s_width
-
764 (s_ptr
->label_width
+ menu
->s_bdr_width
+ menu
->s_fnt_pad
);
767 s_ptr
->label_x
= s_ptr
->window_x
+ ((menu
->s_width
- s_ptr
->label_width
) >> 1);
770 /* Error! Invalid style parameter. */
771 _XMErrorCode
= XME_STYLE_PARAM
;
775 * Recompute label Y position.
777 s_ptr
->label_y
= s_ptr
->window_y
+ menu
->s_fnt_info
->max_bounds
.ascent
+ menu
->s_fnt_pad
+ menu
->s_bdr_width
;
780 * All went well, return successfully.
782 _XMErrorCode
= XME_NO_ERROR
;
789 * _XMTransToOrigin - Internal subroutine to translate the point at
790 * the center of the current pane and selection to the
793 * WARNING! ****** Be certain that all menu dependencies have been
794 * recomputed before calling this routine or
795 * unpredictable results will follow.
797 _XMTransToOrigin(display
, menu
, p_ptr
, s_ptr
, x_pos
, y_pos
, orig_x
, orig_y
)
798 Display
*display
; /* Not used. Included for consistency. */
799 register XMenu
*menu
; /* Menu being computed against. */
800 register XMPane
*p_ptr
; /* Current pane pointer. */
801 register XMSelect
*s_ptr
; /* Current selection pointer. */
802 int x_pos
; /* X coordinate of point to translate. */
803 int y_pos
; /* Y coordinate of point to translate. */
804 int *orig_x
; /* Return value X coord. of the menu origin. */
805 int *orig_y
; /* Return value Y coord. of the menu origin. */
807 register int l_orig_x
; /* Local X coordinate of the menu origin. */
808 register int l_orig_y
; /* Local Y coordinate of the menu origin. */
811 * Translate the menu origin such that the cursor hot point will be in the
812 * center of the desired current selection and pane.
813 * If the current selection pointer is NULL then assume that the hot point
814 * will be in the center of the current pane flag.
819 * Translate from the center of the pane flag to the upper left
820 * of the current pane window.
822 l_orig_x
= x_pos
- (menu
->p_width
>> 1) - menu
->p_bdr_width
;
823 l_orig_y
= y_pos
- (menu
->flag_height
>> 1) - menu
->p_bdr_width
;
827 * First translate from the center of the current selection
828 * to the upper left of the current selection window.
830 l_orig_x
= x_pos
- (menu
->s_width
>> 1);
831 l_orig_y
= y_pos
- (menu
->s_height
>> 1);
834 * Then translate to the upper left of the current pane window.
836 l_orig_x
-= (s_ptr
->window_x
+ menu
->p_bdr_width
);
837 l_orig_y
-= (s_ptr
->window_y
+ menu
->p_bdr_width
);
841 * Finally translate to the upper left of the menu.
843 l_orig_x
-= (p_ptr
->window_x
- menu
->x_pos
);
844 l_orig_y
-= (p_ptr
->window_y
- menu
->y_pos
);
847 * Set the return values.
854 * _XMRefreshPane - Internal subroutine to completely refresh
855 * the contents of a pane.
857 _XMRefreshPane(display
, menu
, pane
)
858 register Display
*display
;
859 register XMenu
*menu
;
860 register XMPane
*pane
;
862 register XMSelect
*s_list
= pane
->s_list
;
863 register XMSelect
*s_ptr
;
866 * First clear the pane.
868 XClearWindow(display
, pane
->window
);
869 if (!pane
->activated
) {
870 XFillRectangle(display
,
872 menu
->inverse_select_GC
,
873 pane
->label_x
- menu
->p_fnt_pad
,
874 pane
->label_uy
- menu
->p_fnt_info
->max_bounds
.ascent
- menu
->p_fnt_pad
,
875 pane
->label_width
+ (menu
->p_fnt_pad
<< 1),
878 XFillRectangle(display
,
880 menu
->inverse_select_GC
,
881 pane
->label_x
- menu
->p_fnt_pad
,
882 pane
->label_ly
- menu
->p_fnt_info
->max_bounds
.ascent
- menu
->p_fnt_pad
,
883 pane
->label_width
+ (menu
->p_fnt_pad
<< 1),
890 pane
->label_x
, pane
->label_uy
,
891 pane
->label
, pane
->label_length
);
895 pane
->label_x
, pane
->label_ly
,
896 pane
->label
, pane
->label_length
);
902 pane
->label_x
, pane
->label_uy
,
903 pane
->label
, pane
->label_length
);
907 pane
->label_x
, pane
->label_ly
,
908 pane
->label
, pane
->label_length
);
911 * Finally refresh each selection if the pane is activated.
913 if (pane
->activated
) {
914 for (s_ptr
= s_list
->next
; s_ptr
!= s_list
; s_ptr
= s_ptr
->next
)
915 _XMRefreshSelection(display
, menu
, s_ptr
);
924 * _XMRefreshSelection - Internal subroutine that refreshes
925 * a single selection window.
927 _XMRefreshSelection(display
, menu
, select
)
928 register Display
*display
;
929 register XMenu
*menu
;
930 register XMSelect
*select
;
932 register int width
= select
->window_w
;
933 register int height
= select
->window_h
;
934 register int bdr_width
= menu
->s_bdr_width
;
936 if (select
->type
== SEPARATOR
) {
938 select
->parent_p
->window
,
939 menu
->normal_select_GC
,
941 select
->window_y
+ height
/ 2,
942 select
->window_x
+ width
,
943 select
->window_y
+ height
/ 2);
945 else if (select
->activated
) {
946 if (menu
->menu_mode
== INVERT
) {
947 XFillRectangle(display
,
948 select
->parent_p
->window
,
949 menu
->normal_select_GC
,
950 select
->window_x
, select
->window_y
,
953 select
->parent_p
->window
,
954 menu
->inverse_select_GC
,
957 select
->label
, select
->label_length
);
962 * Since most drawing routines with arbitrary width lines
963 * are slow compared to raster-ops lets use a raster-op to
967 XDrawRectangle(display
,
968 select
->parent_p
->window
,
969 menu
->normal_select_GC
,
970 select
->window_x
+ (bdr_width
>> 1),
971 select
->window_y
+ (bdr_width
>> 1 ),
975 select
->parent_p
->window
,
976 menu
->normal_select_GC
,
979 select
->label
, select
->label_length
);
984 select
->parent_p
->window
,
985 select
->window_x
, select
->window_y
,
988 if (select
->active
) {
990 select
->parent_p
->window
,
991 menu
->normal_select_GC
,
994 select
->label
, select
->label_length
);
998 select
->parent_p
->window
,
1002 select
->label
, select
->label_length
);