(executable-command-find-posix-p): Doc fix.
[emacs.git] / oldXMenu / Internal.c
blob70a917a8eff25701cc409f8dd191da0a77a91e4f
1 #include "copyright.h"
3 /* $Header: /cvsroot/emacs/emacs/oldXMenu/Internal.c,v 1.2 2003/02/04 14:19:01 lektu Exp $ */
4 /* Copyright Massachusetts Institute of Technology 1985 */
6 /*
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
12 * November, 1985
16 #include <config.h>
17 #include "XMenuInt.h"
20 * Toggle color macro.
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
29 #define P_QUE_SIZE 20
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 {
37 int sq_size;
38 XMSelect *sq[S_QUE_SIZE];
39 XMSelect **sq_ptr;
40 int pq_size;
41 XMPane *pq[P_QUE_SIZE];
42 XMPane **pq_ptr;
43 } XMWinQue;
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.
58 char *
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
88 * queue.
90 _XMWinQueInit()
93 * If the queue is not initialized initialize it.
95 if (!_XMWinQueIsInit) {
97 * Blank the queue structure.
99 register int i;
101 for (i = 0; i < S_QUE_SIZE; i++)
102 _XMWinQue.sq[i] = 0;
104 for (i = 0; i < P_QUE_SIZE; i++)
105 _XMWinQue.pq[i] = 0;
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
121 * window queue.
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;
141 _XMWinQue.pq_ptr++;
142 _XMWinQue.pq_size++;
145 * All went well, return successfully.
147 _XMErrorCode = XME_NO_ERROR;
148 return(_SUCCESS);
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;
175 _XMWinQue.sq_ptr++;
176 _XMWinQue.sq_size++;
179 * All went well, return successfully.
181 _XMErrorCode = XME_NO_ERROR;
182 return(_SUCCESS);
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;
224 pq_index >= 0;
225 pq_index--)
227 p_ptr = _XMWinQue.pq[pq_index]; /* Retrieve next pane. */
228 if (p_ptr == pane) break;
229 p_ptr->window = XCreateWindow(display,
230 menu->parent,
231 p_ptr->window_x,
232 p_ptr->window_y,
233 p_ptr->window_w,
234 p_ptr->window_h,
235 menu->p_bdr_width,
236 CopyFromParent,
237 InputOutput,
238 CopyFromParent,
239 valuemask,
240 attributes);
241 XMakeAssoc(display, menu->assoc_tab, p_ptr->window, p_ptr);
242 XSelectInput(display, p_ptr->window, menu->p_events);
244 for (pq_index = 0;
245 pq_index < _XMWinQue.pq_size;
246 pq_index++)
248 p_ptr = _XMWinQue.pq[pq_index]; /* Retrieve next pane. */
249 p_ptr->window = XCreateWindow(display,
250 menu->parent,
251 p_ptr->window_x,
252 p_ptr->window_y,
253 p_ptr->window_w,
254 p_ptr->window_h,
255 menu->p_bdr_width,
256 CopyFromParent,
257 InputOutput,
258 CopyFromParent,
259 valuemask,
260 attributes);
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,
286 s_ptr->window_x,
287 s_ptr->window_y,
288 s_ptr->window_w,
289 s_ptr->window_h,
290 0, /* border width*/
291 CopyFromParent,
292 InputOnly,
293 CopyFromParent,
295 attributes);
298 * Insert the new window id and its
299 * associated XMSelect structure into the
300 * association table.
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.
316 XFlush(display);
319 * All went well, return successfully.
321 _XMErrorCode = XME_NO_ERROR;
322 return(_SUCCESS);
328 * _XMGetPanePtr - Given a menu pointer and a pane index number, return
329 * a pane pointer that points to the indexed pane.
331 XMPane *
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;
344 return(NULL);
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;
357 return(p_ptr);
363 * _XMGetSelectionPtr - Given pane pointer and a selection index number,
364 * return a selection pointer that points to the
365 * indexed selection.
367 XMSelect *
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;
380 return(NULL);
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;
393 return(s_ptr);
399 * _XMRecomputeGlobals - Internal subroutine to recompute menu wide
400 * global values.
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. */
423 * For each pane...
425 for (
426 p_ptr = menu->p_list->next;
427 p_ptr != menu->p_list;
428 p_ptr = p_ptr->next
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...
444 for (
445 s_ptr = p_ptr->s_list->next;
446 s_ptr != p_ptr->s_list;
447 s_ptr = s_ptr->next
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
464 * selection windows.
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) {
540 case LEFT:
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);
543 break;
544 case RIGHT:
545 window_x = menu->p_x_off * p_num;
546 window_y = menu->p_y_off * ((menu->p_count - 1) - p_num);
547 break;
548 case CENTER:
549 window_x = 0;
550 window_y = menu->p_y_off * ((menu->p_count - 1) - p_num);
551 break;
552 default:
553 /* Error! Invalid style parameter. */
554 _XMErrorCode = XME_STYLE_PARAM;
555 return(_FAILURE);
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.
565 if (
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;
575 config_p = True;
579 * If the local pane width and height differs from the
580 * menu pane width and height, reset the local values.
582 if (
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;
592 config_p = True;
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.
604 if (p_ptr->window) {
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;
612 XConfigureWindow(
613 display,
614 p_ptr->window,
615 change_mask,
616 changes
618 free(changes);
621 else {
622 if (_XMWinQueAddPane(display, menu, p_ptr) == _FAILURE) {
623 return(_FAILURE);
629 * Recompute label X position.
631 switch (menu->p_style) {
632 case LEFT:
633 p_ptr->label_x = menu->p_x_off + menu->p_fnt_pad;
634 break;
635 case RIGHT:
636 p_ptr->label_x = menu->p_width -
637 (p_ptr->label_width + menu->p_x_off + menu->p_fnt_pad);
638 break;
639 case CENTER:
640 p_ptr->label_x = (menu->p_width - p_ptr->label_width) >> 1;
641 break;
642 default:
643 /* Error! Invalid style parameter. */
644 _XMErrorCode = XME_STYLE_PARAM;
645 return(_FAILURE);
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;
657 return(_SUCCESS);
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
680 * and serial number.
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.
699 config_s = True;
703 * If the local selection width and height differs from the
704 * menu selection width and height, reset the local values.
706 if (
707 (s_ptr->window_w != menu->s_width) ||
708 (s_ptr->window_h != menu->s_height)
711 * We must reconfigure the window.
713 config_s = True;
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.
730 if (s_ptr->window) {
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;
739 XConfigureWindow(
740 display,
741 s_ptr->window,
742 change_mask,
743 changes
745 free(changes);
748 else {
749 if (_XMWinQueAddSelection(display, menu, s_ptr) == _FAILURE) {
750 return(_FAILURE);
756 * Recompute label X position.
758 switch (menu->s_style) {
759 case LEFT:
760 s_ptr->label_x = menu->s_bdr_width + menu->s_fnt_pad + s_ptr->window_x;
761 break;
762 case RIGHT:
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);
765 break;
766 case CENTER:
767 s_ptr->label_x = s_ptr->window_x + ((menu->s_width - s_ptr->label_width) >> 1);
768 break;
769 default:
770 /* Error! Invalid style parameter. */
771 _XMErrorCode = XME_STYLE_PARAM;
772 return(_FAILURE);
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;
783 return(_SUCCESS);
789 * _XMTransToOrigin - Internal subroutine to translate the point at
790 * the center of the current pane and selection to the
791 * the menu origin.
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.
817 if (s_ptr == NULL) {
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;
825 else {
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.
849 *orig_x = l_orig_x;
850 *orig_y = l_orig_y;
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,
871 pane->window,
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),
876 menu->flag_height);
878 XFillRectangle(display,
879 pane->window,
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),
884 menu->flag_height);
886 if (!pane->active) {
887 XDrawString(display,
888 pane->window,
889 menu->inact_GC,
890 pane->label_x, pane->label_uy,
891 pane->label, pane->label_length);
892 XDrawString(display,
893 pane->window,
894 menu->inact_GC,
895 pane->label_x, pane->label_ly,
896 pane->label, pane->label_length);
898 else {
899 XDrawString(display,
900 pane->window,
901 menu->pane_GC,
902 pane->label_x, pane->label_uy,
903 pane->label, pane->label_length);
904 XDrawString(display,
905 pane->window,
906 menu->pane_GC,
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) {
937 XDrawLine(display,
938 select->parent_p->window,
939 menu->normal_select_GC,
940 select->window_x,
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,
951 width, height);
952 XDrawString(display,
953 select->parent_p->window,
954 menu->inverse_select_GC,
955 select->label_x,
956 select->label_y,
957 select->label, select->label_length);
959 else {
961 * Using BOX mode.
962 * Since most drawing routines with arbitrary width lines
963 * are slow compared to raster-ops lets use a raster-op to
964 * draw the boxes.
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 ),
972 width - bdr_width,
973 height - bdr_width);
974 XDrawString(display,
975 select->parent_p->window,
976 menu->normal_select_GC,
977 select->label_x,
978 select->label_y,
979 select->label, select->label_length);
982 else {
983 XClearArea(display,
984 select->parent_p->window,
985 select->window_x, select->window_y,
986 width, height,
987 False);
988 if (select->active) {
989 XDrawString(display,
990 select->parent_p->window,
991 menu->normal_select_GC,
992 select->label_x,
993 select->label_y,
994 select->label, select->label_length);
996 else {
997 XDrawString(display,
998 select->parent_p->window,
999 menu->inact_GC,
1000 select->label_x,
1001 select->label_y,
1002 select->label, select->label_length);
1007 /* arch-tag: 3ac61957-0852-4e72-8b88-7dfab1a5dee9
1008 (do not change this comment) */