// Convert String to Pixmap (using XmGetPixmap) // A Pixmap will be read in as bitmap file // 1 and 0 values are set according to the widget's // foreground/background colors. static Boolean CvtStringToPixmap(Display *display, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *) { // Default parameters Screen *screen = DefaultScreenOfDisplay(display); Pixel background = WhitePixelOfScreen(screen); Pixel foreground = BlackPixelOfScreen(screen); if (*num_args >= 1) { // convert first arg into widget Widget w = *(Widget *) args[0].addr; background = w->core.background_pixel; screen = XtScreen(w); if (XtIsWidget(w) && XmIsPrimitive(w)) { // Get foreground color from widget foreground = XmPrimitiveWidget(w)->primitive.foreground; } else { // Ask Motif for a default foreground color Pixel newfg, newtop, newbot, newselect; XmGetColors(screen, w->core.colormap, background, &newfg, &newtop, &newbot, &newselect); foreground = newfg; } } // Get pixmap Pixmap p = XmUNSPECIFIED_PIXMAP; string value = str(fromVal, false); // Some Motif versions use `unspecified_pixmap' and `unspecified pixmap' // as values for XmUNSPECIFIED_PIXMAP. Check for this. string v = downcase(value); v.gsub(" ", "_"); if (v.contains("xm", 0)) v = v.after("xm"); if (v != "unspecified_pixmap") { p = XmGetPixmap(screen, XMST(value.chars()), foreground, background); if (p == XmUNSPECIFIED_PIXMAP) { XtDisplayStringConversionWarning(display, fromVal->addr, XmRPixmap); return False; } } done(Pixmap, p); }
static void ParentActivate(Widget w, XEvent *event, String *params, Cardinal *num_params) { if (XmIsManager(w)) { XtCallActionProc(w, "ManagerParentActivate", event, params, *num_params); } else if (XmIsPrimitive(w)) { XtCallActionProc(w, "PrimitiveParentActivate", event, params, *num_params); } else { } }
void _XmToolTipEnter (Widget wid, XEvent * event, String * params, Cardinal * num_params) { XmToolTipConfigTrait ttp; /* ToolTip pointer */ ttp = ToolTipGetData (wid); if (ttp == NULL) { XtWarning ("ToolTipGetData() returned NULL in _XmToolTipEnter()"); return; } if ((XmIsPrimitive (wid) || XmIsGadget(wid)) && XmGetToolTipString(wid)) { if (ttp->enable && !ttp->timer) { unsigned long delay; if (event && (event->xcrossing.time - ttp->leave_time < ttp->post_delay)) { delay = 0; } else { delay = (unsigned long) ttp->post_delay; } if (ttp->duration_timer) { XtRemoveTimeOut (ttp->duration_timer); ttp->duration_timer = (XtIntervalId) NULL; } ttp->timer = XtAppAddTimeOut (XtWidgetToApplicationContext (wid), delay, (XtTimerCallbackProc) ToolTipPost, wid); } } }
Boolean XmWidgetGetBaselines( Widget wid, Dimension **baselines, int *line_count) { _XmWidgetToAppContext(wid); _XmAppLock(app); if (XmIsPrimitive(wid)) { XmPrimitiveClassExt *wcePtr; WidgetClass wc = XtClass(wid); wcePtr = _XmGetPrimitiveClassExtPtr(wc, NULLQUARK); if (*wcePtr && (*wcePtr)->widget_baseline) { _XmAppUnlock(app); return( (*((*wcePtr)->widget_baseline)) (wid, baselines, line_count)) ; } } else if (XmIsGadget(wid)) { XmGadgetClassExt *wcePtr; WidgetClass wc = XtClass(wid); wcePtr = _XmGetGadgetClassExtPtr(wc, NULLQUARK); if (*wcePtr && (*wcePtr)->widget_baseline) { _XmAppUnlock(app); return( (*((*wcePtr)->widget_baseline)) (wid, baselines, line_count)) ; } } _XmAppUnlock(app); return (False); }
Boolean XmWidgetGetDisplayRect( Widget wid, XRectangle *displayrect) { _XmWidgetToAppContext(wid); _XmAppLock(app); if (XmIsPrimitive(wid)) { XmPrimitiveClassExt *wcePtr; WidgetClass wc = XtClass(wid); wcePtr = _XmGetPrimitiveClassExtPtr(wc, NULLQUARK); if (*wcePtr && (*wcePtr)->widget_display_rect) (*((*wcePtr)->widget_display_rect)) (wid, displayrect); _XmAppUnlock(app); return (True); } else if (XmIsGadget(wid)) { XmGadgetClassExt *wcePtr; WidgetClass wc = XtClass(wid); wcePtr = _XmGetGadgetClassExtPtr(wc, NULLQUARK); if (*wcePtr && (*wcePtr)->widget_display_rect) (*((*wcePtr)->widget_display_rect)) (wid, displayrect); _XmAppUnlock(app); return (True); } else { _XmAppUnlock(app); return (False); } }
static void ToolTipPost (XtPointer client_data, XtIntervalId * id) { Widget w = (Widget) client_data; int rx, ry, x, y; unsigned int key; Window root, child; XtWidgetGeometry geo; Position destX, destY; XmToolTipConfigTrait ttp; /* ToolTip pointer */ ttp = ToolTipGetData (w); if (ttp == NULL) { XtWarning ("ToolTipGetData() returned NULL in ToolTipPost()"); return; } ttp->timer = (XtIntervalId) NULL; XQueryPointer (XtDisplay (w), XtWindow (w), &root, &child, &rx, &ry, &x, &y, &key); if (ttp->duration_timer != (XtIntervalId) NULL) { XtRemoveTimeOut (ttp->duration_timer); ttp->duration_timer = (XtIntervalId) NULL; } if (XmIsPrimitive(w) || XmIsGadget(w)) { XtVaSetValues (ttp->label, XmNlabelString, XmGetToolTipString(w), NULL); } else { XmString string; string = XmStringCreateLocalized (XtName (w)); XtVaSetValues (ttp->label, XmNlabelString, string, NULL); XmStringFree (string); } XtQueryGeometry (ttp->label, NULL, &geo); /* rws 25 Feb 2001 Fix for Bug #1153 Don't let the tip be off the right/bottom of the screen */ destX = rx + (XmIsGadget (w) ? XtX (w) : 0) - x + XtWidth (w) / 2; if (destX + geo.width > WidthOfScreen (XtScreen (w))) { destX = WidthOfScreen (XtScreen (w)) - geo.width; } destY = ry + (XmIsGadget (w) ? XtY (w) : 0) - y + XtHeight (w); if (destY + geo.height > HeightOfScreen (XtScreen (w))) { destY = ry + (XmIsGadget (w) ? XtY (w) : 0) - y - geo.height; } XtVaSetValues (XtParent (ttp->label), XmNx, rx + 1, XmNy, ry + 1, XmNwidth, 1, XmNheight, 1, NULL); ttp->slider = XtVaCreateWidget ("ToolTipSlider", xmSlideContextWidgetClass, XmGetXmDisplay (XtDisplay (w)), XmNslideWidget, XtParent (ttp->label), XmNslideDestX, destX, XmNslideDestY, destY, XmNslideDestWidth, geo.width, XmNslideDestHeight, geo.height, NULL); XtAddCallback (ttp->slider, XmNslideFinishCallback, (XtCallbackProc) ToolTipPostFinish, ttp); XtPopup (XtParent (ttp->label), XtGrabNone); }