51 |
/* |
/* |
52 |
* _XMErrorCode - Global XMenu error code. |
* _XMErrorCode - Global XMenu error code. |
53 |
*/ |
*/ |
54 |
int _XMErrorCode = XME_NO_ERROR; |
int _XMErrorCode = XME_NO_ERROR; |
55 |
/* |
/* |
56 |
* _XMErrorList - Global XMenu error code description strings. |
* _XMErrorList - Global XMenu error code description strings. |
57 |
*/ |
*/ |
204 |
/* |
/* |
205 |
* If the pane window queue is not empty... |
* If the pane window queue is not empty... |
206 |
*/ |
*/ |
207 |
|
|
208 |
if (_XMWinQue.pq_size > 0) { |
if (_XMWinQue.pq_size > 0) { |
209 |
/* |
/* |
210 |
* set up attributes for pane window to be created. |
* set up attributes for pane window to be created. |
214 |
attributes->border_pixel = menu->p_bdr_color; |
attributes->border_pixel = menu->p_bdr_color; |
215 |
attributes->background_pixmap = menu->inact_pixmap; |
attributes->background_pixmap = menu->inact_pixmap; |
216 |
attributes->override_redirect = True; |
attributes->override_redirect = True; |
217 |
|
|
218 |
/* |
/* |
219 |
* Create all the pending panes in order, so that the |
* Create all the pending panes in order, so that the |
220 |
* current pane will be on top, with the others |
* current pane will be on top, with the others |
222 |
*/ |
*/ |
223 |
for (pq_index = _XMWinQue.pq_size - 1; |
for (pq_index = _XMWinQue.pq_size - 1; |
224 |
pq_index >= 0; |
pq_index >= 0; |
225 |
pq_index--) |
pq_index--) |
226 |
{ |
{ |
227 |
p_ptr = _XMWinQue.pq[pq_index]; /* Retrieve next pane. */ |
p_ptr = _XMWinQue.pq[pq_index]; /* Retrieve next pane. */ |
228 |
if (p_ptr == pane) break; |
if (p_ptr == pane) break; |
243 |
} |
} |
244 |
for (pq_index = 0; |
for (pq_index = 0; |
245 |
pq_index < _XMWinQue.pq_size; |
pq_index < _XMWinQue.pq_size; |
246 |
pq_index++) |
pq_index++) |
247 |
{ |
{ |
248 |
p_ptr = _XMWinQue.pq[pq_index]; /* Retrieve next pane. */ |
p_ptr = _XMWinQue.pq[pq_index]; /* Retrieve next pane. */ |
249 |
p_ptr->window = XCreateWindow(display, |
p_ptr->window = XCreateWindow(display, |
273 |
/* |
/* |
274 |
* If the selection window queue is not empty... |
* If the selection window queue is not empty... |
275 |
*/ |
*/ |
276 |
|
|
277 |
if (_XMWinQue.sq_size > 0) { |
if (_XMWinQue.sq_size > 0) { |
278 |
|
|
279 |
for (sq_index = 0; sq_index < _XMWinQue.sq_size; sq_index++) { |
for (sq_index = 0; sq_index < _XMWinQue.sq_size; sq_index++) { |
293 |
CopyFromParent, |
CopyFromParent, |
294 |
0, |
0, |
295 |
attributes); |
attributes); |
296 |
|
|
297 |
/* |
/* |
298 |
* Insert the new window id and its |
* Insert the new window id and its |
299 |
* associated XMSelect structure into the |
* associated XMSelect structure into the |
300 |
* association table. |
* association table. |
301 |
*/ |
*/ |
302 |
XMakeAssoc(display, menu->assoc_tab, s_ptr->window, s_ptr); |
XMakeAssoc(display, menu->assoc_tab, s_ptr->window, s_ptr); |
371 |
{ |
{ |
372 |
register XMSelect *s_ptr; /* Selection pointer to be returned. */ |
register XMSelect *s_ptr; /* Selection pointer to be returned. */ |
373 |
register int i; /* Loop counter. */ |
register int i; /* Loop counter. */ |
374 |
|
|
375 |
/* |
/* |
376 |
* Is the selection number out of range? |
* Is the selection number out of range? |
377 |
*/ |
*/ |
400 |
* global values. |
* global values. |
401 |
*/ |
*/ |
402 |
_XMRecomputeGlobals(display, menu) |
_XMRecomputeGlobals(display, menu) |
403 |
register Display *display; /*X11 display variable. */ |
register Display *display; /*X11 display variable. */ |
404 |
register XMenu *menu; /* Menu object to compute from. */ |
register XMenu *menu; /* Menu object to compute from. */ |
405 |
{ |
{ |
406 |
register XMPane *p_ptr; /* Pane pointer. */ |
register XMPane *p_ptr; /* Pane pointer. */ |
418 |
int s_width; /* Selection window width. */ |
int s_width; /* Selection window width. */ |
419 |
|
|
420 |
int screen; /* DefaultScreen holder. */ |
int screen; /* DefaultScreen holder. */ |
421 |
|
|
422 |
/* |
/* |
423 |
* For each pane... |
* For each pane... |
424 |
*/ |
*/ |
427 |
p_ptr != menu->p_list; |
p_ptr != menu->p_list; |
428 |
p_ptr = p_ptr->next |
p_ptr = p_ptr->next |
429 |
){ |
){ |
430 |
|
|
431 |
/* |
/* |
432 |
* Recompute maximum pane label width. |
* Recompute maximum pane label width. |
433 |
*/ |
*/ |
434 |
max_p_label = max(max_p_label, p_ptr->label_width); |
max_p_label = max(max_p_label, p_ptr->label_width); |
435 |
|
|
436 |
/* |
/* |
437 |
* Recompute maximum selection count. |
* Recompute maximum selection count. |
438 |
*/ |
*/ |
439 |
s_count = max(s_count, p_ptr->s_count); |
s_count = max(s_count, p_ptr->s_count); |
440 |
|
|
495 |
menu->p_width = p_width; |
menu->p_width = p_width; |
496 |
menu->s_width = s_width; |
menu->s_width = s_width; |
497 |
|
|
498 |
/* |
/* |
499 |
* Ensure that the origin of the menu is placed so that |
* Ensure that the origin of the menu is placed so that |
500 |
* None of the panes ore selections are off the screen. |
* None of the panes ore selections are off the screen. |
501 |
*/ |
*/ |
522 |
{ |
{ |
523 |
register int window_x; /* Recomputed window X coordinate. */ |
register int window_x; /* Recomputed window X coordinate. */ |
524 |
register int window_y; /* Recomputed window Y coordinate. */ |
register int window_y; /* Recomputed window Y coordinate. */ |
525 |
|
|
526 |
unsigned long change_mask; /* Value mask to reconfigure window. */ |
unsigned long change_mask; /* Value mask to reconfigure window. */ |
527 |
XWindowChanges *changes; /* Values to use in configure window. */ |
XWindowChanges *changes; /* Values to use in configure window. */ |
528 |
|
|
529 |
register Bool config_p = False; /* Reconfigure pane window? */ |
register Bool config_p = False; /* Reconfigure pane window? */ |
530 |
|
|
531 |
/* |
/* |
558 |
window_y += menu->y_pos; |
window_y += menu->y_pos; |
559 |
|
|
560 |
/* |
/* |
561 |
* If the newly compute pane coordinates differ from the |
* If the newly compute pane coordinates differ from the |
562 |
* current coordinates, reset the current coordinates and |
* current coordinates, reset the current coordinates and |
563 |
* reconfigure the pane. |
* reconfigure the pane. |
564 |
*/ |
*/ |
608 |
changes->y = p_ptr->window_y; |
changes->y = p_ptr->window_y; |
609 |
changes->width = p_ptr->window_w; |
changes->width = p_ptr->window_w; |
610 |
changes->height = p_ptr->window_h; |
changes->height = p_ptr->window_h; |
611 |
|
|
612 |
XConfigureWindow( |
XConfigureWindow( |
613 |
display, |
display, |
614 |
p_ptr->window, |
p_ptr->window, |
616 |
changes |
changes |
617 |
); |
); |
618 |
free(changes); |
free(changes); |
619 |
|
|
620 |
} |
} |
621 |
else { |
else { |
622 |
if (_XMWinQueAddPane(display, menu, p_ptr) == _FAILURE) { |
if (_XMWinQueAddPane(display, menu, p_ptr) == _FAILURE) { |
624 |
} |
} |
625 |
} |
} |
626 |
} |
} |
627 |
|
|
628 |
/* |
/* |
629 |
* Recompute label X position. |
* Recompute label X position. |
630 |
*/ |
*/ |
673 |
register Bool config_s = False; /* Reconfigure selection window? */ |
register Bool config_s = False; /* Reconfigure selection window? */ |
674 |
XWindowChanges *changes; /* Values to change in configure. */ |
XWindowChanges *changes; /* Values to change in configure. */ |
675 |
unsigned long change_mask; /* Value mask for XConfigureWindow. */ |
unsigned long change_mask; /* Value mask for XConfigureWindow. */ |
676 |
|
|
677 |
/* |
/* |
678 |
* If the selection serial numbers are out of order, begin |
* If the selection serial numbers are out of order, begin |
679 |
* resequencing selections. Recompute selection window coordinates |
* resequencing selections. Recompute selection window coordinates |
735 |
changes->y = s_ptr->window_y; |
changes->y = s_ptr->window_y; |
736 |
changes->width = s_ptr->window_w; |
changes->width = s_ptr->window_w; |
737 |
changes->height = s_ptr->window_h; |
changes->height = s_ptr->window_h; |
738 |
|
|
739 |
XConfigureWindow( |
XConfigureWindow( |
740 |
display, |
display, |
741 |
s_ptr->window, |
s_ptr->window, |
743 |
changes |
changes |
744 |
); |
); |
745 |
free(changes); |
free(changes); |
746 |
|
|
747 |
} |
} |
748 |
else { |
else { |
749 |
if (_XMWinQueAddSelection(display, menu, s_ptr) == _FAILURE) { |
if (_XMWinQueAddSelection(display, menu, s_ptr) == _FAILURE) { |
775 |
* Recompute label Y position. |
* Recompute label Y position. |
776 |
*/ |
*/ |
777 |
s_ptr->label_y = s_ptr->window_y + menu->s_fnt_info->max_bounds.ascent + menu->s_fnt_pad + menu->s_bdr_width; |
s_ptr->label_y = s_ptr->window_y + menu->s_fnt_info->max_bounds.ascent + menu->s_fnt_pad + menu->s_bdr_width; |
778 |
|
|
779 |
/* |
/* |
780 |
* All went well, return successfully. |
* All went well, return successfully. |
781 |
*/ |
*/ |
787 |
|
|
788 |
/* |
/* |
789 |
* _XMTransToOrigin - Internal subroutine to translate the point at |
* _XMTransToOrigin - Internal subroutine to translate the point at |
790 |
* the center of the current pane and selection to the |
* the center of the current pane and selection to the |
791 |
* the menu origin. |
* the menu origin. |
792 |
* |
* |
793 |
* WARNING! ****** Be certain that all menu dependencies have been |
* WARNING! ****** Be certain that all menu dependencies have been |
806 |
{ |
{ |
807 |
register int l_orig_x; /* Local X coordinate of the menu origin. */ |
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. */ |
register int l_orig_y; /* Local Y coordinate of the menu origin. */ |
809 |
|
|
810 |
/* |
/* |
811 |
* Translate the menu origin such that the cursor hot point will be in the |
* Translate the menu origin such that the cursor hot point will be in the |
812 |
* center of the desired current selection and pane. |
* center of the desired current selection and pane. |
863 |
register XMSelect *s_ptr; |
register XMSelect *s_ptr; |
864 |
|
|
865 |
/* |
/* |
866 |
* First clear the pane. |
* First clear the pane. |
867 |
*/ |
*/ |
868 |
XClearWindow(display, pane->window); |
XClearWindow(display, pane->window); |
869 |
if (!pane->activated) { |
if (!pane->activated) { |
916 |
} |
} |
917 |
} |
} |
918 |
} |
} |
919 |
|
|
920 |
|
|
921 |
|
|
922 |
|
|
923 |
/* |
/* |
924 |
* _XMRefreshSelection - Internal subroutine that refreshes |
* _XMRefreshSelection - Internal subroutine that refreshes |
925 |
* a single selection window. |
* a single selection window. |
926 |
*/ |
*/ |
927 |
_XMRefreshSelection(display, menu, select) |
_XMRefreshSelection(display, menu, select) |
932 |
register int width = select->window_w; |
register int width = select->window_w; |
933 |
register int height = select->window_h; |
register int height = select->window_h; |
934 |
register int bdr_width = menu->s_bdr_width; |
register int bdr_width = menu->s_bdr_width; |
935 |
|
|
936 |
if (select->type == SEPARATOR) { |
if (select->type == SEPARATOR) { |
937 |
XDrawLine(display, |
XDrawLine(display, |
938 |
select->parent_p->window, |
select->parent_p->window, |
944 |
} |
} |
945 |
else if (select->activated) { |
else if (select->activated) { |
946 |
if (menu->menu_mode == INVERT) { |
if (menu->menu_mode == INVERT) { |
947 |
XFillRectangle(display, |
XFillRectangle(display, |
948 |
select->parent_p->window, |
select->parent_p->window, |
949 |
menu->normal_select_GC, |
menu->normal_select_GC, |
950 |
select->window_x, select->window_y, |
select->window_x, select->window_y, |
951 |
width, height); |
width, height); |
952 |
XDrawString(display, |
XDrawString(display, |
953 |
select->parent_p->window, |
select->parent_p->window, |
954 |
menu->inverse_select_GC, |
menu->inverse_select_GC, |
963 |
* are slow compared to raster-ops lets use a raster-op to |
* are slow compared to raster-ops lets use a raster-op to |
964 |
* draw the boxes. |
* draw the boxes. |
965 |
*/ |
*/ |
966 |
|
|
967 |
XDrawRectangle(display, |
XDrawRectangle(display, |
968 |
select->parent_p->window, |
select->parent_p->window, |
969 |
menu->normal_select_GC, |
menu->normal_select_GC, |
980 |
} |
} |
981 |
} |
} |
982 |
else { |
else { |
983 |
XClearArea(display, |
XClearArea(display, |
984 |
select->parent_p->window, |
select->parent_p->window, |
985 |
select->window_x, select->window_y, |
select->window_x, select->window_y, |
986 |
width, height, |
width, height, |