/************************************************************************** ... **************************************************************************/ void main_show_info_popup(XEvent *event) { XButtonEvent *ev = (XButtonEvent *)event; if (ev->button == Button1) { Widget p; Position x, y; Dimension w, h; p = XtCreatePopupShell("popupinfo", overrideShellWidgetClass, info_command, NULL, 0); XtAddCallback(p, XtNpopdownCallback, destroy_me_callback, NULL); XtVaCreateManagedWidget("fullinfopopuplabel", labelWidgetClass, p, XtNlabel, get_info_label_text_popup(), NULL); XtRealizeWidget(p); XtVaGetValues(p, XtNwidth, &w, XtNheight, &h, NULL); XtTranslateCoords(info_command, ev->x, ev->y, &x, &y); XtVaSetValues(p, XtNx, MAX(0, x - w / 2), XtNy, MAX(0, y - h / 2), NULL); XtPopupSpringLoaded(p); } }
int GMmenudisplay (Gwidget_t *parent, Gwidget_t *widget) { Window rwin, cwin; Dimension width, height; int rx, ry, x, y; unsigned int mask; XQueryPointer ( Gdisplay, XtWindow (parent->w), &rwin, &cwin, &rx, &ry, &x, &y, &mask ); XtRealizeWidget (widget->w); RESETARGS; ADD2ARGS (XtNwidth, &width); ADD2ARGS (XtNheight, &height); XtGetValues (widget->w, argp, argn); if (rx + width > DisplayWidth (Gdisplay, Gscreenn)) rx = DisplayWidth (Gdisplay, Gscreenn) - width; if (ry + height > DisplayHeight (Gdisplay, Gscreenn)) ry = DisplayHeight (Gdisplay, Gscreenn) - height; if (rx < 0) rx = 0; if (ry < 0) ry = 0; RESETARGS; ADD2ARGS (XtNx, rx); ADD2ARGS (XtNy, ry); XtSetValues (widget->w, argp, argn); menupoped = TRUE; menuselected = -1; XtPopupSpringLoaded (widget->w); while (menupoped) Gprocessevents (TRUE, G_ONEEVENT); Gpopdownflag = TRUE; return menuselected; }
void onActivate(Widget w, XtPointer mydata, XtPointer cbs) { Widget grabshell = (Widget) mydata; XtPopupSpringLoaded(grabshell); #if 0 XdbPrintCompleteTree(grabshell); #endif }
/* Acutally pop up the pullright menu */ static void popup_pullright(XtPointer client_data, XtIntervalId *id) { int pos_x, pos_y; Dimension w1; Window dummy; static Widget files_submenu = NULL; struct pullright_position_info *info = (struct pullright_position_info *)client_data; UNUSED(id); if (files_submenu == NULL) files_submenu = create_files_submenu(); /* XtManageChild(files_submenu); */ XTranslateCoordinates(DISP, XtWindow(XtParent(m_submenu)), RootWindowOfScreen(SCRN), info->w, info->y, &pos_x, &pos_y, &dummy); XtRealizeWidget(files_submenu); XtVaGetValues(files_submenu, XtNwidth, &w1, NULL); TRACE_GUI((stderr, "Popping up at %d, %d, %d, %d", pos_x, pos_y, w1, WidthOfScreen(SCRN))); /* if not sufficient place on the right, pop it up on the left */ /* fprintf(stderr, "border_width: %d\n", info->border_width); */ if (pos_x + w1 > WidthOfScreen(SCRN)) { /* fprintf(stderr, "%d > %d!\n", pos_x + w1, WidthOfScreen(SCRN)); */ pos_x -= (w1 + info->w + 3 * info->border_width); /* fprintf(stderr, "new x: %d\n", pos_x); */ } else { pos_x += info->border_width; } XtVaSetValues(files_submenu, XtNx, pos_x, XtNy, pos_y, NULL); /* use XtPopupSpringLoaded() instead of XtPopup() since it does a few things that make the pullright behave like a proper menu, like highlighting the current selection, setting the cursor shape etc. */ XtPopupSpringLoaded(files_submenu); m_active_submenu = files_submenu; }
void dirPopup(Widget w, XEvent *event, String *params, Cardinal *num_params) { int i; FileWindowRec *fw; Display *dpy; Window root, child; int x, y, x_win, y_win; unsigned int mask; i = findWidget(w, &fw); if (!fw) { /* error("Internal error:", "widget not found in dirPopup"); */ return; } popup_fw = fw; fileSelect(w, event, params, num_params); if (!strcmp(fw->files[i]->name, ".") || !strcmp(fw->files[i]->name, "..")) { grayOut(dir_popup_items[2]); grayOut(dir_popup_items[3]); grayOut(dir_popup_items[6]); } else { fillIn(dir_popup_items[2]); fillIn(dir_popup_items[3]); fillIn(dir_popup_items[6]); } dpy = XtDisplay(toplevel); XQueryPointer(dpy, DefaultRootWindow(dpy), &root, &child, &x, &y, &x_win, &y_win, &mask); XtVaSetValues(dir_popup_widget, XtNx, (XtArgVal) x, XtNy, (XtArgVal) y, NULL); XtPopupSpringLoaded(dir_popup_widget); }
/************************************************************************** ... **************************************************************************/ static void popit(int xin, int yin, struct tile *ptile) { Position x, y; int dw, dh; Dimension w, h, b; static struct tile *cross_list[2+1]; struct tile **cross_head = cross_list; int i; struct unit *punit; char *content; static bool is_orders; if (TILE_UNKNOWN != client_tile_get_known(ptile)) { Widget p=XtCreatePopupShell("popupinfo", simpleMenuWidgetClass, map_canvas, NULL, 0); content = (char *) popup_info_text(ptile); /* content is provided to us as a single string with multiple lines, but xaw doens't support multi-line labels. So we break it up. We mangle it in the process, but who cares? It's never going to be used again anyway. */ while (1) { char *end = strchr(content, '\n'); if (end) { *end='\0'; } XtCreateManagedWidget(content, smeBSBObjectClass, p, NULL, 0); if (end) { content = end+1; } else { break; } } punit = find_visible_unit(ptile); is_orders = show_unit_orders(punit); if (punit && punit->goto_tile) { *cross_head = punit->goto_tile; cross_head++; } *cross_head = ptile; cross_head++; xin /= tileset_tile_width(tileset); xin *= tileset_tile_width(tileset); yin /= tileset_tile_height(tileset); yin *= tileset_tile_height(tileset); xin += (tileset_tile_width(tileset) / 2); XtTranslateCoords(map_canvas, xin, yin, &x, &y); dw = XDisplayWidth (display, screen_number); dh = XDisplayHeight (display, screen_number); XtRealizeWidget(p); XtVaGetValues(p, XtNwidth, &w, XtNheight, &h, XtNborderWidth, &b, NULL); w += (2 * b); h += (2 * b); x -= (w / 2); y -= h; if ((x + w) > dw) x = dw - w; if (x < 0) x = 0; if ((y + h) > dh) y = dh - h; if (y < 0) y = 0; XtVaSetValues(p, XtNx, x, XtNy, y, NULL); *cross_head = NULL; for (i = 0; cross_list[i]; i++) { put_cross_overlay_tile(cross_list[i]); } XtAddCallback(p,XtNpopdownCallback,popupinfo_popdown_callback, (XtPointer)&is_orders); XtPopupSpringLoaded(p); } }