📄 internal.c
字号:
else if (menu->x_pos < 0) menu->x_pos = 0; if(menu->y_pos + menu->height > DisplayHeight(display, screen)) menu->y_pos = DisplayHeight(display, screen) - menu->height; else if (menu->y_pos < 0) menu->y_pos = 0;}/* * _XMRecomputePane - Internal subroutine to recompute pane * window dependencies. */int_XMRecomputePane(display, menu, p_ptr, p_num) register Display *display; /* Standard X display variable. */ register XMenu *menu; /* Menu object being recomputed. */ register XMPane *p_ptr; /* Pane pointer. */ register int p_num; /* Pane sequence number. */{ register int window_x; /* Recomputed window X coordinate. */ register int window_y; /* Recomputed window Y coordinate. */ unsigned long change_mask; /* Value mask to reconfigure window. */ XWindowChanges *changes; /* Values to use in configure window. */ register Bool config_p = False; /* Reconfigure pane window? */ /* * Update the pane serial number. */ p_ptr->serial = p_num; /* * Recompute window X and Y coordinates. */ switch (menu->menu_style) { case LEFT: window_x = menu->p_x_off * ((menu->p_count - 1) - p_num); window_y = menu->p_y_off * ((menu->p_count - 1) - p_num); break; case RIGHT: window_x = menu->p_x_off * p_num; window_y = menu->p_y_off * ((menu->p_count - 1) - p_num); break; case CENTER: window_x = 0; window_y = menu->p_y_off * ((menu->p_count - 1) - p_num); break; default: /* Error! Invalid style parameter. */ _XMErrorCode = XME_STYLE_PARAM; return(_FAILURE); } window_x += menu->x_pos; window_y += menu->y_pos; /* * If the newly compute pane coordinates differ from the * current coordinates, reset the current coordinates and * reconfigure the pane. */ if ( (window_x != p_ptr->window_x) || (window_y != p_ptr->window_y) ){ /* * Reset the coordinates and schedule * the pane for reconfiguration. */ p_ptr->window_x = window_x; p_ptr->window_y = window_y; config_p = True; } /* * If the local pane width and height differs from the * menu pane width and height, reset the local values. */ if ( (p_ptr->window_w != menu->p_width) || (p_ptr->window_h != menu->p_height) ){ /* * Reset window width and height and schedule * the pane for reconfiguration. */ p_ptr->window_w = menu->p_width; p_ptr->window_h = menu->p_height; config_p = True; } /* * If we need to reconfigure the pane window do it now. */ if (config_p == True) { /* * If the pane window has already been created then * reconfigure the existing window, otherwise queue * it for creation with the new configuration. */ if (p_ptr->window) { change_mask = (CWX | CWY | CWWidth | CWHeight); changes = (XWindowChanges *)malloc(sizeof(XWindowChanges)); changes->x = p_ptr->window_x; changes->y = p_ptr->window_y; changes->width = p_ptr->window_w; changes->height = p_ptr->window_h; XConfigureWindow( display, p_ptr->window, change_mask, changes ); free(changes); } else { if (_XMWinQueAddPane(display, menu, p_ptr) == _FAILURE) { return(_FAILURE); } } } /* * Recompute label X position. */ switch (menu->p_style) { case LEFT: p_ptr->label_x = menu->p_x_off + menu->p_fnt_pad; break; case RIGHT: p_ptr->label_x = menu->p_width - (p_ptr->label_width + menu->p_x_off + menu->p_fnt_pad); break; case CENTER: p_ptr->label_x = (menu->p_width - p_ptr->label_width) >> 1; break; default: /* Error! Invalid style parameter. */ _XMErrorCode = XME_STYLE_PARAM; return(_FAILURE); } /* * Recompute label Y positions. */ p_ptr->label_uy = menu->p_fnt_pad + menu->p_fnt_info->max_bounds.ascent; p_ptr->label_ly = (menu->p_height - menu->p_fnt_pad - menu->p_fnt_info->max_bounds.descent); /* * All went well, return successfully. */ _XMErrorCode = XME_NO_ERROR; return(_SUCCESS);}/* * _XMRecomputeSelection - Internal subroutine to recompute * selection window dependencies. */int_XMRecomputeSelection(display, menu, s_ptr, s_num) register Display *display; register XMenu *menu; /* Menu object being recomputed. */ register XMSelect *s_ptr; /* Selection pointer. */ register int s_num; /* Selection sequence number. */{ register Bool config_s = False; /* Reconfigure selection window? */ XWindowChanges *changes; /* Values to change in configure. */ unsigned long change_mask; /* Value mask for XConfigureWindow. */ /* * If the selection serial numbers are out of order, begin * resequencing selections. Recompute selection window coordinates * and serial number. * * When selections are created they are given a serial number of * -1, this causes this routine to give a new selection * its initial coordinates and serial number. */ if (s_ptr->serial != s_num) { /* * Fix the sequence number. */ s_ptr->serial = s_num; /* * Recompute window X and Y coordinates. */ s_ptr->window_x = menu->s_x_off; s_ptr->window_y = menu->flag_height + (menu->s_y_off * s_num); /* * We must reconfigure the window. */ config_s = True; } /* * If the local selection width and height differs from the * menu selection width and height, reset the local values. */ if ( (s_ptr->window_w != menu->s_width) || (s_ptr->window_h != menu->s_height) ){ /* * We must reconfigure the window. */ config_s = True; /* * Reset window width and height. */ s_ptr->window_w = menu->s_width; s_ptr->window_h = menu->s_height; } /* * If we need to reconfigure the selection window do it now. */ if (config_s == True) { /* * If the selection window has already been created then * reconfigure the existing window, otherwise queue it * for creation with the new configuration. */ if (s_ptr->window) { changes = (XWindowChanges *)malloc(sizeof(XWindowChanges)); change_mask = (CWX | CWY | CWWidth | CWHeight); changes = (XWindowChanges *)malloc(sizeof(XWindowChanges)); changes->x = s_ptr->window_x; changes->y = s_ptr->window_y; changes->width = s_ptr->window_w; changes->height = s_ptr->window_h; XConfigureWindow( display, s_ptr->window, change_mask, changes ); free(changes); } else { if (_XMWinQueAddSelection(display, menu, s_ptr) == _FAILURE) { return(_FAILURE); } } } /* * Recompute label X position. */ switch (menu->s_style) { case LEFT: s_ptr->label_x = menu->s_bdr_width + menu->s_fnt_pad + s_ptr->window_x; break; case RIGHT: s_ptr->label_x = s_ptr->window_x + menu->s_width - (s_ptr->label_width + menu->s_bdr_width + menu->s_fnt_pad); break; case CENTER: s_ptr->label_x = s_ptr->window_x + ((menu->s_width - s_ptr->label_width) >> 1); break; default: /* Error! Invaild style parameter. */ _XMErrorCode = XME_STYLE_PARAM; return(_FAILURE); } /* * Recompute label Y position. */ s_ptr->label_y = s_ptr->window_y + menu->s_fnt_info->max_bounds.ascent + menu->s_fnt_pad + menu->s_bdr_width; /* * All went well, return successfully. */ _XMErrorCode = XME_NO_ERROR; return(_SUCCESS);}/* * _XMTransToOrigin - Internal subroutine to translate the point at * the center of the current pane and selection to the * the menu origin. * * WARNING! ****** Be certain that all menu depencies have been * recomputed before calling this routine or * unpredictable results will follow. */_XMTransToOrigin(display, menu, p_ptr, s_ptr, x_pos, y_pos, orig_x, orig_y) Display *display; /* Not used. Included for consistency. */ register XMenu *menu; /* Menu being computed against. */ register XMPane *p_ptr; /* Current pane pointer. */ register XMSelect *s_ptr; /* Current selection pointer. */ int x_pos; /* X coordinate of point to translate. */ int y_pos; /* Y coordinate of point to translate. */ int *orig_x; /* Return value X coord. of the menu origin. */ int *orig_y; /* Return value Y coord. of the menu origin. */{ register int l_orig_x; /* Local X coordinate of the menu origin. */ register int l_orig_y; /* Local Y coordinate of the menu origin. */ /* * Translate the menu origin such that the cursor hot point will be in the * center of the desired current selection and pane. * If the current selection pointer is NULL then assume that the hot point * will be in the center of the current pane flag. */ if (s_ptr == NULL) { /* * Translate from the center of the pane flag to the upper left * of the current pane window. */ l_orig_x = x_pos - (menu->p_width >> 1) - menu->p_bdr_width; l_orig_y = y_pos - (menu->flag_height >> 1) - menu->p_bdr_width; } else { /* * First translate from the center of the current selection * to the upper left of the current selection window. */ l_orig_x = x_pos - (menu->s_width >> 1); l_orig_y = y_pos - (menu->s_height >> 1); /* * Then translate to the upper left of the current pane window. */ l_orig_x -= (s_ptr->window_x + menu->p_bdr_width); l_orig_y -= (s_ptr->window_y + menu->p_bdr_width); } /* * Finally translate to the upper left of the menu. */ l_orig_x -= (p_ptr->window_x - menu->x_pos); l_orig_y -= (p_ptr->window_y - menu->y_pos); /* * Set the return values. */ *orig_x = l_orig_x; *orig_y = l_orig_y;}/* * _XMRefreshPane - Internal subroutine to completely refresh * the contents of a pane. */_XMRefreshPane(display, menu, pane) register Display *display; register XMenu *menu; register XMPane *pane;{ register XMSelect *s_list = pane->s_list; register XMSelect *s_ptr; /* * First clear the pane. */ XClearWindow(display, pane->window); if (!pane->activated) { XFillRectangle(display, pane->window, menu->inverse_select_GC, pane->label_x - menu->p_fnt_pad, pane->label_uy - menu->p_fnt_info->max_bounds.ascent - menu->p_fnt_pad, pane->label_width + (menu->p_fnt_pad << 1), menu->flag_height); XFillRectangle(display, pane->window, menu->inverse_select_GC, pane->label_x - menu->p_fnt_pad, pane->label_ly - menu->p_fnt_info->max_bounds.ascent - menu->p_fnt_pad, pane->label_width + (menu->p_fnt_pad << 1), menu->flag_height); } if (!pane->active) { XDrawString(display, pane->window, menu->inact_GC, pane->label_x, pane->label_uy, pane->label, pane->label_length); XDrawString(display, pane->window, menu->inact_GC, pane->label_x, pane->label_ly, pane->label, pane->label_length); } else { XDrawString(display, pane->window, menu->pane_GC, pane->label_x, pane->label_uy, pane->label, pane->label_length); XDrawString(display, pane->window, menu->pane_GC, pane->label_x, pane->label_ly, pane->label, pane->label_length); /* * Finally refresh each selection if the pane is activated. */ if (pane->activated) { for (s_ptr = s_list->next; s_ptr != s_list; s_ptr = s_ptr->next) _XMRefreshSelection(display, menu, s_ptr); } }} /* * _XMRefreshSelection - Internal subroutine that refreshes * a single selection window. */_XMRefreshSelection(display, menu, select) register Display *display; register XMenu *menu; register XMSelect *select;{ register int width = select->window_w; register int height = select->window_h; register int bdr_width = menu->s_bdr_width; if (select->activated) { if (menu->menu_mode == INVERT) { XFillRectangle(display, select->parent_p->window, menu->normal_select_GC, select->window_x, select->window_y, width, height); XDrawString(display, select->parent_p->window, menu->inverse_select_GC, select->label_x, select->label_y, select->label, select->label_length); } else { /* * Using BOX mode. * Since most drawing routines with arbitrary width lines * are slow compared to raster-ops lets use a raster-op to * draw the boxes. */ XDrawRectangle(display, select->parent_p->window, menu->normal_select_GC, select->window_x + (bdr_width >> 1), select->window_y + (bdr_width >> 1 ), width - bdr_width, height - bdr_width); XDrawString(display, select->parent_p->window, menu->normal_select_GC, select->label_x, select->label_y, select->label, select->label_length); } } else { XClearArea(display, select->parent_p->window, select->window_x, select->window_y, width, height, False); if (select->active) { XDrawString(display, select->parent_p->window, menu->normal_select_GC, select->label_x, select->label_y, select->label, select->label_length); } else { XDrawString(display, select->parent_p->window, menu->inact_GC, select->label_x, select->label_y, select->label, select->label_length); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -