XtAccelerators Get_Accelerators (Object a) { register char *s; XtAccelerators ret; Alloca_Begin; Get_Strsym_Stack (a, s); if ((ret = XtParseAcceleratorTable (s)) == 0) Primitive_Error ("bad accelerator table: ~s", a); Alloca_End; return ret; }
static void create_menu_entries(struct button_info *item, Widget parent) { size_t i; /* add our own popdown-submenus() action to the default translations of this menu */ XtAccelerators menu_accels = XtParseAcceleratorTable("<BtnUp>:MenuPopdown()notify()unhighlight()popdown-submenus()"); for (i = 0; item != NULL && i < item->size; i++) { Widget w; if (item->elems[i].submenu != NULL) { /* another submenu */ XDVI_ERROR((stderr, "Xaw menus don't support nested pulldown menus (ignoring)")); continue; } if (item->elems[i].type == BT_SEP) { /* separator */ w = XtCreateManagedWidget(item->elems[i].title, smeLineObjectClass, parent, NULL, 0); } else if (item->elems[i].action != NULL && item->elems[i].action->proc == Act_recent_files) { /* special case: submenu with recent files */ w = XtVaCreateManagedWidget(item->elems[i].title, smeBSBObjectClass, parent, XtNlabel, item->elems[i].title, XtNleftMargin, 20, XtNrightMargin, 16, XtNrightBitmap, menu_arrow_bitmap, NULL); m_submenu = w; XtOverrideTranslations(parent, menu_accels); } else { /* normal menu entry */ w = XtVaCreateManagedWidget(item->elems[i].title, smeBSBObjectClass, parent, XtNlabel, item->elems[i].title, XtNleftMargin, 20, NULL); XtAddCallback(w, XtNcallback, handle_command, item->elems[i].action); } item->elems[i].widget = w; } }
static void XSetupDisplay(int nframes) { XGCValues xgcv; XtAccelerators keys; /* Had to do it this way since embedding the keystrokes in the fallback resources failed to work properly -- what a kludge. */ keys = XtParseAcceleratorTable(ckeys); xi.depth = DefaultDepthOfScreen(DefaultScreenOfDisplay(xi.disp)); // give me TrueColor if (!XMatchVisualInfo(xi.disp, xi.screenno, xi.depth, TrueColor, &(xi.vi))) ErrorExit(ERROR_BADPARM, "Could not find a TrueColor visual"); xi.vis = xi.vi.visual; xi.root = RootWindow(xi.disp, xi.screenno); // AllocNone -- clients can allocate the colormap entries // For TrueColor, alloc must be AloocNone xi.colormap = XCreateColormap(xi.disp, xi.root, xi.vis, AllocNone); toplevel = XtVaAppCreateShell("NMovie", "NMovie", applicationShellWidgetClass, xi.disp, XtNvisual, xi.vis, XtNcolormap, xi.colormap, NULL); XtAppAddActions(xi.context,actions,XtNumber(actions)); // frame frame = XtVaCreateManagedWidget("Frame", formWidgetClass, toplevel, NULL); // create buttons buttons = XtVaCreateManagedWidget("Buttons", formWidgetClass, frame, NULL ); loop_bt = XtVaCreateManagedWidget("Loop", commandWidgetClass, buttons, NULL); swing_bt = XtVaCreateManagedWidget("Swing", commandWidgetClass, buttons, NULL); fast_bt = XtVaCreateManagedWidget("Faster", commandWidgetClass, buttons, NULL); slow_bt = XtVaCreateManagedWidget("Slower", commandWidgetClass, buttons, NULL); stop_bt = XtVaCreateManagedWidget("Stop", commandWidgetClass, buttons, NULL); back_bt = XtVaCreateManagedWidget("Back", commandWidgetClass, buttons, NULL); forward_bt = XtVaCreateManagedWidget("Forward", commandWidgetClass, buttons, NULL); quit_bt = XtVaCreateManagedWidget("Quit", commandWidgetClass, buttons, NULL); // canvas canvas = XtVaCreateManagedWidget("Canvas", simpleWidgetClass, frame, XtNwidth, cols, XtNheight, rows, XtNaccelerators, keys, NULL); XtInstallAllAccelerators(canvas,toplevel); XtRealizeWidget(toplevel); xi.canvas = XtWindow(canvas); xi.theGC = XCreateGC(xi.disp, xi.canvas, 0L, &xgcv); xi.rmask = xi.vis->red_mask; // 0xFF0000 xi.gmask = xi.vis->green_mask; // 0x00FF00 xi.bmask = xi.vis->blue_mask; // 0x0000FF xi.rshift = 7 - highbit(xi.rmask); // -16 xi.gshift = 7 - highbit(xi.gmask); // -8 xi.bshift = 7 - highbit(xi.bmask); // 0 // format is ZPixmap offset,data ximg = XCreateImage(xi.disp,xi.vis,xi.depth,ZPixmap, 0, NULL, // bytes_per_line = 0 means assume contiguous and calculated cols, rows, 32, 0); if ((imgdata = (char *)calloc((size_t)(rows*ximg->bytes_per_line*nframes), sizeof(byte))) ==NULL) ErrorExit(ERROR_NO_MEMORY,"Failed to allocate image buffer"); ximg->data = (char *) imgdata; }