1 /* Copyright Massachusetts Institute of Technology 1985 */
6 Copyright (C) 1993, 1996, 2001, 2002, 2003, 2004, 2005, 2006,
7 2007 Free Software Foundation, Inc.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; see the file COPYING. If not, write to the
21 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
26 * XMenu: MIT Project Athena, X Window system menu package
28 * XMenuInternal.c - XMenu internal (not user visible) routines.
30 * Author: Tony Della Fera, DEC
41 #define toggle_color(x) \
42 ((x) == menu->bkgnd_color ? menu->s_frg_color : menu->bkgnd_color)
45 * Internal Window creation queue sizes.
47 #define S_QUE_SIZE 300
49 #define BUFFER_SIZE (S_QUE_SIZE >= P_QUE_SIZE ? S_QUE_SIZE : P_QUE_SIZE)
53 * XMWinQue - Internal window creation queue datatype.
55 typedef struct _xmwinquedef
{
57 XMSelect
*sq
[S_QUE_SIZE
];
60 XMPane
*pq
[P_QUE_SIZE
];
65 * _XMWinQue - Internal static window creation queue.
67 static Bool _XMWinQueIsInit
= False
;
68 static XMWinQue _XMWinQue
;
71 * _XMErrorCode - Global XMenu error code.
73 int _XMErrorCode
= XME_NO_ERROR
;
75 * _XMErrorList - Global XMenu error code description strings.
78 _XMErrorList
[XME_CODE_COUNT
] = {
79 "No error", /* XME_NO_ERROR */
80 "Menu not initialized", /* XME_NOT_INIT */
81 "Argument out of bounds", /* XME_ARG_BOUNDS */
82 "Pane not found", /* XME_P_NOT_FOUND */
83 "Selection not found", /* XME_S_NOT_FOUND */
84 "Invalid menu style parameter", /* XME_STYLE_PARAM */
85 "Unable to grab mouse", /* XME_GRAB_MOUSE */
86 "Unable to interpret locator", /* XME_INTERP_LOC */
87 "Unable to calloc memory", /* XME_CALLOC */
88 "Unable to create XAssocTable", /* XME_CREATE_ASSOC */
89 "Unable to store bitmap", /* XME_STORE_BITMAP */
90 "Unable to make tile pixmaps", /* XME_MAKE_TILES */
91 "Unable to make pixmap", /* XME_MAKE_PIXMAP */
92 "Unable to create cursor", /* XME_CREATE_CURSOR */
93 "Unable to open font", /* XME_OPEN_FONT */
94 "Unable to create windows", /* XME_CREATE_WINDOW */
95 "Unable to create transparencies", /* XME_CREATE_TRANSP */
99 * _XMEventHandler - Internal event handler variable.
101 int (*_XMEventHandler
)() = NULL
;
106 * _XMWinQueInit - Internal routine to initialize the window
112 * If the queue is not initialized initialize it.
114 if (!_XMWinQueIsInit
) {
116 * Blank the queue structure.
120 for (i
= 0; i
< S_QUE_SIZE
; i
++)
123 for (i
= 0; i
< P_QUE_SIZE
; i
++)
126 _XMWinQue
.sq_size
= _XMWinQue
.pq_size
= 0;
129 * Initialize the next free location pointers.
131 _XMWinQue
.sq_ptr
= _XMWinQue
.sq
;
132 _XMWinQue
.pq_ptr
= _XMWinQue
.pq
;
139 * _XMWinQueAddPane - Internal routine to add a pane to the pane
143 _XMWinQueAddPane(display
, menu
, p_ptr
)
144 register Display
*display
;
145 register XMenu
*menu
; /* Menu being manipulated. */
146 register XMPane
*p_ptr
; /* XMPane being queued. */
149 * If the queue is currently full then flush it.
151 if (_XMWinQue
.pq_size
== P_QUE_SIZE
) {
152 if (_XMWinQueFlush(display
, menu
, 0, 0) == _FAILURE
) return(_FAILURE
);
156 * Insert the new XMPane pointer and increment the queue pointer
157 * and the queue size.
159 *_XMWinQue
.pq_ptr
= p_ptr
;
164 * All went well, return successfully.
166 _XMErrorCode
= XME_NO_ERROR
;
173 * _XMWinQueAddSelection - Internal routine to add a selection to
174 * the selection window queue.
177 _XMWinQueAddSelection(display
, menu
, s_ptr
)
178 register Display
*display
;
179 register XMenu
*menu
; /* Menu being manipulated. */
180 register XMSelect
*s_ptr
; /* XMSelection being queued. */
183 * If this entry will overflow the queue then flush it.
185 if (_XMWinQue
.sq_size
== S_QUE_SIZE
) {
186 if (_XMWinQueFlush(display
, menu
, 0, 0) == _FAILURE
) return(_FAILURE
);
190 * Insert the new XMSelect pointer and increment the queue pointer
191 * and the queue size.
193 *_XMWinQue
.sq_ptr
= s_ptr
;
198 * All went well, return successfully.
200 _XMErrorCode
= XME_NO_ERROR
;
207 * _XMWinQueFlush - Internal routine to flush the pane and
208 * selection window queues.
211 _XMWinQueFlush(display
, menu
, pane
, select
)
212 register Display
*display
;
213 register XMenu
*menu
; /* Menu being manipulated. */
214 register XMPane
*pane
; /* Current pane. */
216 register int pq_index
; /* Pane queue index. */
217 register int sq_index
; /* Selection queue index. */
218 register XMPane
*p_ptr
; /* XMPane pointer. */
219 register XMSelect
*s_ptr
; /* XMSelect pointer. */
220 unsigned long valuemask
; /* Which attributes to set. */
221 XSetWindowAttributes
*attributes
; /* Attributes to be set. */
224 * If the pane window queue is not empty...
227 if (_XMWinQue
.pq_size
> 0) {
229 * set up attributes for pane window to be created.
231 valuemask
= (CWBackPixmap
| CWBorderPixel
| CWOverrideRedirect
);
232 attributes
= (XSetWindowAttributes
*)malloc(sizeof(XSetWindowAttributes
));
233 attributes
->border_pixel
= menu
->p_bdr_color
;
234 attributes
->background_pixmap
= menu
->inact_pixmap
;
235 attributes
->override_redirect
= True
;
238 * Create all the pending panes in order, so that the
239 * current pane will be on top, with the others
240 * stacked appropriately under it.
242 for (pq_index
= _XMWinQue
.pq_size
- 1;
246 p_ptr
= _XMWinQue
.pq
[pq_index
]; /* Retrieve next pane. */
247 if (p_ptr
== pane
) break;
248 p_ptr
->window
= XCreateWindow(display
,
260 XMakeAssoc(display
, menu
->assoc_tab
, p_ptr
->window
, p_ptr
);
261 XSelectInput(display
, p_ptr
->window
, menu
->p_events
);
264 pq_index
< _XMWinQue
.pq_size
;
267 p_ptr
= _XMWinQue
.pq
[pq_index
]; /* Retrieve next pane. */
268 p_ptr
->window
= XCreateWindow(display
,
280 XMakeAssoc(display
, menu
->assoc_tab
, p_ptr
->window
, p_ptr
);
281 XSelectInput(display
, p_ptr
->window
, menu
->p_events
);
282 if (p_ptr
== pane
) break;
286 * Reset the pane queue pointer and size.
288 _XMWinQue
.pq_size
= 0;
289 _XMWinQue
.pq_ptr
= _XMWinQue
.pq
;
293 * If the selection window queue is not empty...
296 if (_XMWinQue
.sq_size
> 0) {
298 for (sq_index
= 0; sq_index
< _XMWinQue
.sq_size
; sq_index
++) {
300 * Retrieve the XMSelect pointer.
302 s_ptr
= _XMWinQue
.sq
[sq_index
];
303 s_ptr
->window
= XCreateWindow(display
,
304 s_ptr
->parent_p
->window
,
317 * Insert the new window id and its
318 * associated XMSelect structure into the
321 XMakeAssoc(display
, menu
->assoc_tab
, s_ptr
->window
, s_ptr
);
322 XSelectInput(display
, s_ptr
->window
, menu
->s_events
);
326 * Reset the selection queue pointer and size.
328 _XMWinQue
.sq_size
= 0;
329 _XMWinQue
.sq_ptr
= _XMWinQue
.sq
;
333 * Flush X's internal queues.
338 * All went well, return successfully.
340 _XMErrorCode
= XME_NO_ERROR
;
347 * _XMGetPanePtr - Given a menu pointer and a pane index number, return
348 * a pane pointer that points to the indexed pane.
351 _XMGetPanePtr(menu
, p_num
)
352 register XMenu
*menu
; /* Menu to find the pane in. */
353 register int p_num
; /* Index number of pane to find. */
355 register XMPane
*p_ptr
; /* Pane pointer to be returned. */
356 register int i
; /* Loop counter. */
359 * Is the pane number out of range?
361 if ((p_num
< 0) || (p_num
> (menu
->p_count
- 1))) {
362 _XMErrorCode
= XME_P_NOT_FOUND
;
367 * Find the right pane.
369 p_ptr
= menu
->p_list
->next
;
370 for (i
= 0; i
< p_num
; i
++) p_ptr
= p_ptr
->next
;
373 * Return successfully.
375 _XMErrorCode
= XME_NO_ERROR
;
382 * _XMGetSelectionPtr - Given pane pointer and a selection index number,
383 * return a selection pointer that points to the
387 _XMGetSelectionPtr(p_ptr
, s_num
)
388 register XMPane
*p_ptr
; /* Pane to find the selection in. */
389 register int s_num
; /* Index number of the selection to find. */
391 register XMSelect
*s_ptr
; /* Selection pointer to be returned. */
392 register int i
; /* Loop counter. */
395 * Is the selection number out of range?
397 if ((s_num
< 0) || (s_num
> (p_ptr
->s_count
- 1))) {
398 _XMErrorCode
= XME_S_NOT_FOUND
;
403 * Find the right selection.
405 s_ptr
= p_ptr
->s_list
->next
;
406 for (i
= 0; i
< s_num
; i
++) s_ptr
= s_ptr
->next
;
409 * Return successfully.
411 _XMErrorCode
= XME_NO_ERROR
;
418 * _XMRecomputeGlobals - Internal subroutine to recompute menu wide
421 _XMRecomputeGlobals(display
, menu
)
422 register Display
*display
; /*X11 display variable. */
423 register XMenu
*menu
; /* Menu object to compute from. */
425 register XMPane
*p_ptr
; /* Pane pointer. */
426 register XMSelect
*s_ptr
; /* Selection pointer. */
428 register int max_p_label
= 0; /* Maximum pane label width. */
429 register int max_s_label
= 0; /* Maximum selection label width. */
430 register int s_count
= 0; /* Maximum selection count. */
432 int p_s_pad
; /* Pane <-> selection padding. */
433 int p_s_diff
; /* Pane <-> selection separation. */
435 int p_height
; /* Pane window height. */
436 int p_width
; /* Pane window width. */
437 int s_width
; /* Selection window width. */
439 int screen
; /* DefaultScreen holder. */
445 p_ptr
= menu
->p_list
->next
;
446 p_ptr
!= menu
->p_list
;
451 * Recompute maximum pane label width.
453 max_p_label
= max(max_p_label
, p_ptr
->label_width
);
456 * Recompute maximum selection count.
458 s_count
= max(s_count
, p_ptr
->s_count
);
461 * For each selection in the current pane...
464 s_ptr
= p_ptr
->s_list
->next
;
465 s_ptr
!= p_ptr
->s_list
;
470 * Recompute maximum selection label width.
472 max_s_label
= max(max_s_label
, s_ptr
->label_width
);
477 * Recompute pane height.
479 p_height
= (menu
->flag_height
<< 1) + (menu
->s_y_off
* s_count
);
482 * Recompute horizontal padding between the pane window and the
485 p_s_pad
= menu
->p_x_off
<< 1;
488 * Recompute pane and selection window widths.
489 * This is done by first computing the window sizes from the maximum
490 * label widths. If the spacing between the selection window and the
491 * containing pane window is less than the pane selection padding value
492 * (twice the pane X offset) then change the size of the pane to be
493 * the size of the selection window plus the padding. If, however the
494 * spacing between the selection window and the containing pane window
495 * is more than the pane selection padding value increase the size of
496 * the selection to its maximum possible value (the pane width minus
497 * the pane selection padding value).
499 p_width
= max_p_label
+ p_s_pad
;
500 s_width
= max_s_label
+ (menu
->s_fnt_pad
<< 1) + (menu
->s_bdr_width
<< 1);
501 p_s_diff
= p_width
- s_width
;
502 if (p_s_diff
< p_s_pad
) {
503 p_width
= s_width
+ p_s_pad
;
505 else if (p_s_diff
> p_s_pad
) {
506 s_width
= p_width
- p_s_pad
;
510 * Reset menu wide global values.
512 menu
->s_count
= s_count
;
513 menu
->p_height
= p_height
;
514 menu
->p_width
= p_width
;
515 menu
->s_width
= s_width
;
518 * Ensure that the origin of the menu is placed so that
519 * None of the panes ore selections are off the screen.
521 screen
= DefaultScreen(display
);
522 if (menu
->x_pos
+ menu
->width
> DisplayWidth(display
, screen
))
523 menu
->x_pos
= DisplayWidth(display
, screen
) - menu
->width
;
524 else if (menu
->x_pos
< 0) menu
->x_pos
= 0;
525 if(menu
->y_pos
+ menu
->height
> DisplayHeight(display
, screen
))
526 menu
->y_pos
= DisplayHeight(display
, screen
) - menu
->height
;
527 else if (menu
->y_pos
< 0) menu
->y_pos
= 0;
532 * _XMRecomputePane - Internal subroutine to recompute pane
533 * window dependencies.
536 _XMRecomputePane(display
, menu
, p_ptr
, p_num
)
537 register Display
*display
; /* Standard X display variable. */
538 register XMenu
*menu
; /* Menu object being recomputed. */
539 register XMPane
*p_ptr
; /* Pane pointer. */
540 register int p_num
; /* Pane sequence number. */
542 register int window_x
; /* Recomputed window X coordinate. */
543 register int window_y
; /* Recomputed window Y coordinate. */
545 unsigned long change_mask
; /* Value mask to reconfigure window. */
546 XWindowChanges
*changes
; /* Values to use in configure window. */
548 register Bool config_p
= False
; /* Reconfigure pane window? */
551 * Update the pane serial number.
553 p_ptr
->serial
= p_num
;
556 * Recompute window X and Y coordinates.
558 switch (menu
->menu_style
) {
560 window_x
= menu
->p_x_off
* ((menu
->p_count
- 1) - p_num
);
561 window_y
= menu
->p_y_off
* ((menu
->p_count
- 1) - p_num
);
564 window_x
= menu
->p_x_off
* p_num
;
565 window_y
= menu
->p_y_off
* ((menu
->p_count
- 1) - p_num
);
569 window_y
= menu
->p_y_off
* ((menu
->p_count
- 1) - p_num
);
572 /* Error! Invalid style parameter. */
573 _XMErrorCode
= XME_STYLE_PARAM
;
576 window_x
+= menu
->x_pos
;
577 window_y
+= menu
->y_pos
;
580 * If the newly compute pane coordinates differ from the
581 * current coordinates, reset the current coordinates and
582 * reconfigure the pane.
585 (window_x
!= p_ptr
->window_x
) ||
586 (window_y
!= p_ptr
->window_y
)
589 * Reset the coordinates and schedule
590 * the pane for reconfiguration.
592 p_ptr
->window_x
= window_x
;
593 p_ptr
->window_y
= window_y
;
598 * If the local pane width and height differs from the
599 * menu pane width and height, reset the local values.
602 (p_ptr
->window_w
!= menu
->p_width
) ||
603 (p_ptr
->window_h
!= menu
->p_height
)
606 * Reset window width and height and schedule
607 * the pane for reconfiguration.
609 p_ptr
->window_w
= menu
->p_width
;
610 p_ptr
->window_h
= menu
->p_height
;
615 * If we need to reconfigure the pane window do it now.
617 if (config_p
== True
) {
619 * If the pane window has already been created then
620 * reconfigure the existing window, otherwise queue
621 * it for creation with the new configuration.
624 change_mask
= (CWX
| CWY
| CWWidth
| CWHeight
);
625 changes
= (XWindowChanges
*)malloc(sizeof(XWindowChanges
));
626 changes
->x
= p_ptr
->window_x
;
627 changes
->y
= p_ptr
->window_y
;
628 changes
->width
= p_ptr
->window_w
;
629 changes
->height
= p_ptr
->window_h
;
641 if (_XMWinQueAddPane(display
, menu
, p_ptr
) == _FAILURE
) {
648 * Recompute label X position.
650 switch (menu
->p_style
) {
652 p_ptr
->label_x
= menu
->p_x_off
+ menu
->p_fnt_pad
;
655 p_ptr
->label_x
= menu
->p_width
-
656 (p_ptr
->label_width
+ menu
->p_x_off
+ menu
->p_fnt_pad
);
659 p_ptr
->label_x
= (menu
->p_width
- p_ptr
->label_width
) >> 1;
662 /* Error! Invalid style parameter. */
663 _XMErrorCode
= XME_STYLE_PARAM
;
667 * Recompute label Y positions.
669 p_ptr
->label_uy
= menu
->p_fnt_pad
+ menu
->p_fnt_info
->max_bounds
.ascent
;
670 p_ptr
->label_ly
= (menu
->p_height
- menu
->p_fnt_pad
- menu
->p_fnt_info
->max_bounds
.descent
);
673 * All went well, return successfully.
675 _XMErrorCode
= XME_NO_ERROR
;
682 * _XMRecomputeSelection - Internal subroutine to recompute
683 * selection window dependencies.
686 _XMRecomputeSelection(display
, menu
, s_ptr
, s_num
)
687 register Display
*display
;
688 register XMenu
*menu
; /* Menu object being recomputed. */
689 register XMSelect
*s_ptr
; /* Selection pointer. */
690 register int s_num
; /* Selection sequence number. */
692 register Bool config_s
= False
; /* Reconfigure selection window? */
693 XWindowChanges
*changes
; /* Values to change in configure. */
694 unsigned long change_mask
; /* Value mask for XConfigureWindow. */
697 * If the selection serial numbers are out of order, begin
698 * resequencing selections. Recompute selection window coordinates
701 * When selections are created they are given a serial number of
702 * -1, this causes this routine to give a new selection
703 * its initial coordinates and serial number.
705 if (s_ptr
->serial
!= s_num
) {
707 * Fix the sequence number.
709 s_ptr
->serial
= s_num
;
711 * Recompute window X and Y coordinates.
713 s_ptr
->window_x
= menu
->s_x_off
;
714 s_ptr
->window_y
= menu
->flag_height
+ (menu
->s_y_off
* s_num
);
716 * We must reconfigure the window.
722 * If the local selection width and height differs from the
723 * menu selection width and height, reset the local values.
726 (s_ptr
->window_w
!= menu
->s_width
) ||
727 (s_ptr
->window_h
!= menu
->s_height
)
730 * We must reconfigure the window.
734 * Reset window width and height.
736 s_ptr
->window_w
= menu
->s_width
;
737 s_ptr
->window_h
= menu
->s_height
;
741 * If we need to reconfigure the selection window do it now.
743 if (config_s
== True
) {
745 * If the selection window has already been created then
746 * reconfigure the existing window, otherwise queue it
747 * for creation with the new configuration.
750 changes
= (XWindowChanges
*)malloc(sizeof(XWindowChanges
));
751 change_mask
= (CWX
| CWY
| CWWidth
| CWHeight
);
752 changes
= (XWindowChanges
*)malloc(sizeof(XWindowChanges
));
753 changes
->x
= s_ptr
->window_x
;
754 changes
->y
= s_ptr
->window_y
;
755 changes
->width
= s_ptr
->window_w
;
756 changes
->height
= s_ptr
->window_h
;
768 if (_XMWinQueAddSelection(display
, menu
, s_ptr
) == _FAILURE
) {
775 * Recompute label X position.
777 switch (menu
->s_style
) {
779 s_ptr
->label_x
= menu
->s_bdr_width
+ menu
->s_fnt_pad
+ s_ptr
->window_x
;
782 s_ptr
->label_x
= s_ptr
->window_x
+ menu
->s_width
-
783 (s_ptr
->label_width
+ menu
->s_bdr_width
+ menu
->s_fnt_pad
);
786 s_ptr
->label_x
= s_ptr
->window_x
+ ((menu
->s_width
- s_ptr
->label_width
) >> 1);
789 /* Error! Invalid style parameter. */
790 _XMErrorCode
= XME_STYLE_PARAM
;
794 * Recompute label Y position.
796 s_ptr
->label_y
= s_ptr
->window_y
+ menu
->s_fnt_info
->max_bounds
.ascent
+ menu
->s_fnt_pad
+ menu
->s_bdr_width
;
799 * All went well, return successfully.
801 _XMErrorCode
= XME_NO_ERROR
;
808 * _XMTransToOrigin - Internal subroutine to translate the point at
809 * the center of the current pane and selection to the
812 * WARNING! ****** Be certain that all menu dependencies have been
813 * recomputed before calling this routine or
814 * unpredictable results will follow.
816 _XMTransToOrigin(display
, menu
, p_ptr
, s_ptr
, x_pos
, y_pos
, orig_x
, orig_y
)
817 Display
*display
; /* Not used. Included for consistency. */
818 register XMenu
*menu
; /* Menu being computed against. */
819 register XMPane
*p_ptr
; /* Current pane pointer. */
820 register XMSelect
*s_ptr
; /* Current selection pointer. */
821 int x_pos
; /* X coordinate of point to translate. */
822 int y_pos
; /* Y coordinate of point to translate. */
823 int *orig_x
; /* Return value X coord. of the menu origin. */
824 int *orig_y
; /* Return value Y coord. of the menu origin. */
826 register int l_orig_x
; /* Local X coordinate of the menu origin. */
827 register int l_orig_y
; /* Local Y coordinate of the menu origin. */
830 * Translate the menu origin such that the cursor hot point will be in the
831 * center of the desired current selection and pane.
832 * If the current selection pointer is NULL then assume that the hot point
833 * will be in the center of the current pane flag.
838 * Translate from the center of the pane flag to the upper left
839 * of the current pane window.
841 l_orig_x
= x_pos
- (menu
->p_width
>> 1) - menu
->p_bdr_width
;
842 l_orig_y
= y_pos
- (menu
->flag_height
>> 1) - menu
->p_bdr_width
;
846 * First translate from the center of the current selection
847 * to the upper left of the current selection window.
849 l_orig_x
= x_pos
- (menu
->s_width
>> 1);
850 l_orig_y
= y_pos
- (menu
->s_height
>> 1);
853 * Then translate to the upper left of the current pane window.
855 l_orig_x
-= (s_ptr
->window_x
+ menu
->p_bdr_width
);
856 l_orig_y
-= (s_ptr
->window_y
+ menu
->p_bdr_width
);
860 * Finally translate to the upper left of the menu.
862 l_orig_x
-= (p_ptr
->window_x
- menu
->x_pos
);
863 l_orig_y
-= (p_ptr
->window_y
- menu
->y_pos
);
866 * Set the return values.
873 * _XMRefreshPane - Internal subroutine to completely refresh
874 * the contents of a pane.
876 _XMRefreshPane(display
, menu
, pane
)
877 register Display
*display
;
878 register XMenu
*menu
;
879 register XMPane
*pane
;
881 register XMSelect
*s_list
= pane
->s_list
;
882 register XMSelect
*s_ptr
;
885 * First clear the pane.
887 XClearWindow(display
, pane
->window
);
888 if (!pane
->activated
) {
889 XFillRectangle(display
,
891 menu
->inverse_select_GC
,
892 pane
->label_x
- menu
->p_fnt_pad
,
893 pane
->label_uy
- menu
->p_fnt_info
->max_bounds
.ascent
- menu
->p_fnt_pad
,
894 pane
->label_width
+ (menu
->p_fnt_pad
<< 1),
897 XFillRectangle(display
,
899 menu
->inverse_select_GC
,
900 pane
->label_x
- menu
->p_fnt_pad
,
901 pane
->label_ly
- menu
->p_fnt_info
->max_bounds
.ascent
- menu
->p_fnt_pad
,
902 pane
->label_width
+ (menu
->p_fnt_pad
<< 1),
909 pane
->label_x
, pane
->label_uy
,
910 pane
->label
, pane
->label_length
);
914 pane
->label_x
, pane
->label_ly
,
915 pane
->label
, pane
->label_length
);
921 pane
->label_x
, pane
->label_uy
,
922 pane
->label
, pane
->label_length
);
926 pane
->label_x
, pane
->label_ly
,
927 pane
->label
, pane
->label_length
);
930 * Finally refresh each selection if the pane is activated.
932 if (pane
->activated
) {
933 for (s_ptr
= s_list
->next
; s_ptr
!= s_list
; s_ptr
= s_ptr
->next
)
934 _XMRefreshSelection(display
, menu
, s_ptr
);
943 * _XMRefreshSelection - Internal subroutine that refreshes
944 * a single selection window.
946 _XMRefreshSelection(display
, menu
, select
)
947 register Display
*display
;
948 register XMenu
*menu
;
949 register XMSelect
*select
;
951 register int width
= select
->window_w
;
952 register int height
= select
->window_h
;
953 register int bdr_width
= menu
->s_bdr_width
;
955 if (select
->type
== SEPARATOR
) {
957 select
->parent_p
->window
,
958 menu
->normal_select_GC
,
960 select
->window_y
+ height
/ 2,
961 select
->window_x
+ width
,
962 select
->window_y
+ height
/ 2);
964 else if (select
->activated
) {
965 if (menu
->menu_mode
== INVERT
) {
966 XFillRectangle(display
,
967 select
->parent_p
->window
,
968 menu
->normal_select_GC
,
969 select
->window_x
, select
->window_y
,
972 select
->parent_p
->window
,
973 menu
->inverse_select_GC
,
976 select
->label
, select
->label_length
);
981 * Since most drawing routines with arbitrary width lines
982 * are slow compared to raster-ops lets use a raster-op to
986 XDrawRectangle(display
,
987 select
->parent_p
->window
,
988 menu
->normal_select_GC
,
989 select
->window_x
+ (bdr_width
>> 1),
990 select
->window_y
+ (bdr_width
>> 1 ),
994 select
->parent_p
->window
,
995 menu
->normal_select_GC
,
998 select
->label
, select
->label_length
);
1003 select
->parent_p
->window
,
1004 select
->window_x
, select
->window_y
,
1007 if (select
->active
) {
1008 XDrawString(display
,
1009 select
->parent_p
->window
,
1010 menu
->normal_select_GC
,
1013 select
->label
, select
->label_length
);
1016 XDrawString(display
,
1017 select
->parent_p
->window
,
1021 select
->label
, select
->label_length
);
1026 /* arch-tag: 3ac61957-0852-4e72-8b88-7dfab1a5dee9
1027 (do not change this comment) */