/************************************************************************ * * _XmSFUpdateNavigatorsValues convenience function * *************************************<->***********************************/ void _XmSFUpdateNavigatorsValue( Widget sf, XmNavigatorData nav_data, Boolean notify) { Cardinal i, num_nav_list ; Widget * nav_list ; Boolean inited ; /* there is a possibility that the SW was not inited for navigation business: APP_DEFINED where no scrollbar have been added yet */ inited = ((XmScrollFrameTrait) XmeTraitGet((XtPointer) XtClass(sf), XmQTscrollFrame)) ->getInfo(sf, NULL, &nav_list, &num_nav_list); if (!inited) return ; /* loop over the associated navigator list and call the change value method for each navigator */ /* Updating the first navigator only if notify is True is not enough, since the dimension is pertinent */ for (i=0; i < num_nav_list; i++) { Widget nav = nav_list[i] ; XmNavigatorSetValueProc nav_setValue = ((XmNavigatorTrait) XmeTraitGet((XtPointer) XtClass(nav), XmQTnavigator))->setValue; nav_setValue(nav, nav_data, notify); } }
/* * XmeTraitGet finds out whether or not a given object has installed a given * trait. If it has installed, a pointer to the associated trait record is * returned, otherwise the result is NULL. * * object the object (a widget class) that you are inquiring about. * trait the trait name. */ extern XtPointer XmeTraitGet(XtPointer obj, XrmQuark trait) { int i, j; WidgetClass super; if (obj == NULL || trait == 0) { DEBUGOUT(_LtDebug(__FILE__, NULL, "XmeTraitGet(NULL)\n")); _XmInitTraits(); return NULL; } DEBUGOUT(_LtDebug(__FILE__, NULL, "XmeTraitGet(%s,%s)\n", ((WidgetClass)obj)->core_class.class_name, XrmQuarkToString(trait))); for (i=0; i<_num_traits; i++) { if (_traits[i].wc == (WidgetClass)obj) { for (j=0; _traits[i].traits[j].trait && j<_traits[i].num; j++) if (_traits[i].traits[j].trait == trait) { /* We may have a removed trait here, * search superclass for it */ if (_traits[i].traits[j].traitrec == NULL) { super = XtSuperclass(obj); return XmeTraitGet((XtPointer)super, trait); } return _traits[i].traits[j].traitrec; } /* Not found, look in the superclass */ #if 1 /* Sometimes XtSuperclass doesn't work. */ /* Use its expansion instead */ super = ((WidgetClass)obj)->core_class.superclass; #else super = XtSuperclass(obj); #endif return XmeTraitGet((XtPointer)super, trait); /* Never reached */ } } /* Widget Class not found */ return NULL; }
static XmToolTipConfigTrait ToolTipGetData (Widget w) { Widget top = w; XmToolTipConfigTrait ttp; while (XtParent (top)) { top = XtParent (top); } ttp = (XmToolTipConfigTrait) XmeTraitGet (top, XmQTtoolTipConfig); if (ttp != NULL && ttp->label == NULL && !top->core.being_destroyed) { Widget shell; shell = XtVaCreateWidget ("TipShell", transientShellWidgetClass, top, XmNoverrideRedirect, True, NULL); ttp->label = XmCreateLabel (shell, "TipLabel", NULL, 0); XtManageChild (ttp->label); #ifdef FIX_1388 XtAddCallback(top, XmNdestroyCallback, (XtCallbackProc) ToolTipLabelDestroyCallback, (XtPointer) NULL); #endif } return ttp; }
/************************************************************************ * * _XmNotifyChildrenVisual * Loop through the child set of new and for any widget/gadget that has * a CareParentVisual trait, call the redraw proc. * The redraw proc will return True if the widget needs to have the * parent redrawn as well. * ************************************************************************/ Boolean _XmNotifyChildrenVisual( Widget cur, Widget new_w, Mask visual_flag) { register int i; Widget child; Boolean redisplay = False; XmCareVisualTrait care_visual ; CompositeWidget cw = (CompositeWidget) new_w ; for (i = 0; i < cw->composite.num_children; i++) { child = cw->composite.children[i]; if ((care_visual = (XmCareVisualTrait) XmeTraitGet((XtPointer) XtClass(child), XmQTcareParentVisual)) != NULL) redisplay |= care_visual->redraw(child, cur, new_w, visual_flag) ; } return (redisplay); }
XmString XmGetToolTipString (Widget w) { XmToolTipTrait ttp; ttp = (XmToolTipTrait)XmeTraitGet(w, XmQTtoolTip); return ttp ? ttp->tool_tip_string : NULL; }
/*ARGSUSED*/ static Boolean SetValues( Widget current, Widget request, /* unused */ Widget new_w, ArgList args, /* unused */ Cardinal *num_args ) /* unused */ { Widget child ; XmDialogSavvyTrait trait ; if(!current->core.mapped_when_managed && new_w->core.mapped_when_managed) { if((child = GetRectObjKid ((CompositeWidget) new_w)) && !child->core.being_destroyed ) { if ((trait = (XmDialogSavvyTrait) XmeTraitGet((XtPointer) XtClass(child), XmQTdialogShellSavvy)) != NULL) { trait->callMapUnmapCB(child, True); /* call Map callback */ } XtPopup(new_w, XtGrabNone) ; } } return (FALSE); }
void _XmToolTipRemove(Widget w) { XmToolTipTrait ttp; _XmToolTipLeave(w, NULL, NULL, NULL); ttp = (XmToolTipTrait) XmeTraitGet(w, XmQTtoolTip); if (ttp != NULL) { XmStringFree(ttp->tool_tip_string); XmeTraitSet(w, XmQTtoolTip, (XtPointer) NULL); XtFree((char*)ttp); } }
void XmSetToolTipString (Widget w, XmString s) { XmToolTipTrait ttp; ttp = (XmToolTipTrait)XmeTraitGet(w, XmQTtoolTip); if (!ttp) { ttp = (XmToolTipTrait)XtCalloc(1, sizeof(XmToolTipTraitRec)); XmeTraitSet(w, XmQTtoolTip, ttp); } if (ttp->tool_tip_string) XmStringFree(ttp->tool_tip_string); ttp->tool_tip_string = XmStringCopy(s); }
static void ToolTipLabelDestroyCallback(Widget w, XtPointer client_data, XtPointer call_data) { XmToolTipConfigTrait ttcp; ttcp = (XmToolTipConfigTrait) XmeTraitGet(w, XmQTtoolTipConfig); if (ttcp != NULL) if (ttcp->label != NULL) { Widget shell = XtParent(ttcp->label); XtDestroyWidget(ttcp->label); ttcp->label = NULL; XtDestroyWidget(shell); } }
static void draw_unhighlight(XmEnhancedButtonWidget eb) { GC manager_background_GC; eb->primitive.highlighted = False; eb->primitive.highlight_drawn = False; if (!XtWidth(eb) || !XtHeight(eb) || !eb->primitive.highlight_thickness) return; if (XmIsManager(eb->core.parent)) { #ifdef UNHIGHLIGHTT XmSpecifyUnhighlightTrait UnhighlightT; if (((UnhighlightT = (XmSpecifyUnhighlightTrait) XmeTraitGet((XtPointer) XtClass(eb->core.parent), XmQTspecifyUnhighlight)) != NULL) && (UnhighlightT->getUnhighlightGC != NULL)) { /* if unhighlight trait in parent use specified GC... */ manager_background_GC = UnhighlightT->getUnhighlightGC(eb->core.parent, (Widget) eb); } else { /* ...otherwise, use parent's background GC */ manager_background_GC = ((XmManagerWidget) (eb->core.parent))->manager.background_GC; } #else manager_background_GC = ((XmManagerWidget) (eb->core.parent))->manager.background_GC; #endif XmeDrawHighlight(XtDisplay(eb), XtWindow(eb), manager_background_GC, 0, 0, XtWidth(eb), XtHeight(eb), eb->primitive.highlight_thickness); if (!eb->pushbutton.armed && eb->primitive.shadow_thickness) XmeClearBorder(XtDisplay(eb), XtWindow(eb), eb->primitive.highlight_thickness, eb->primitive.highlight_thickness, eb->core.width - 2 * eb->primitive.highlight_thickness, eb->core.height - 2 * eb->primitive.highlight_thickness, eb->primitive.shadow_thickness); } else XmeClearBorder(XtDisplay(eb), XtWindow(eb), 0, 0, XtWidth(eb), XtHeight(eb), eb->primitive.highlight_thickness); }
static void ClassInitialize() #endif { baseClassExtRec.record_type = XmQmotif; #if XmVersion == 2000 /* Trait records */ XmeTraitSet((XtPointer) xmtMenuWidgetClass, XmQTmenuSystem, (XtPointer) &_XmRC_menuSystemRecord); #endif #if XmVersion >= 2001 /* Trait records */ XmeTraitSet((XtPointer) xmtMenuWidgetClass, XmQTmenuSystem, XmeTraitGet ((XtPointer) xmRowColumnWidgetClass, XmQTmenuSystem)); #endif }
static Widget GetRectObjKid( CompositeWidget p ) { Cardinal i; Widget *currKid; for (i = 0, currKid = p->composite.children; i < p->composite.num_children; i++, currKid++) { if ((XtIsRectObj( *currKid) /* The Input Method child is a CoreClass object; ignore it. */ && ((*currKid)->core.widget_class != coreWidgetClass)) || XmeTraitGet((XtPointer) XtClass(*currKid), XmQTdialogShellSavvy)) { return (*currKid); } } return NULL; }
static void BorderUnhighlight( Widget w ) { XmGadget g = (XmGadget) w ; XmSpecifyUnhighlightTrait UnhighlightT; GC manager_background_GC; g->gadget.highlighted = False ; g->gadget.highlight_drawn = False ; if ( g->rectangle.width == 0 || g->rectangle.height == 0 || g->gadget.highlight_thickness == 0) { return ; } /* If unhighlight trait in parent use specified GC, else just clear area */ if ( XmIsManager(g->object.parent) && ((UnhighlightT=(XmSpecifyUnhighlightTrait)XmeTraitGet((XtPointer) XtClass(g->object.parent), XmQTspecifyUnhighlight)) != NULL) && (UnhighlightT->getUnhighlightGC != NULL)) { /* Get and use parent's specified background GC for unhighlighting */ manager_background_GC = UnhighlightT->getUnhighlightGC( g->object.parent, w); XmeDrawHighlight( XtDisplay( g), XtWindow( g), manager_background_GC, g->rectangle.x, g->rectangle.y, g->rectangle.width, g->rectangle.height, g->gadget.highlight_thickness) ; } else { XmeClearBorder( XtDisplay( g), XtWindow( g), g->rectangle.x, g->rectangle.y, g->rectangle.width, g->rectangle.height, g->gadget.highlight_thickness) ; } return ; }
/************************************************************************ * * _XmSFAddNavigator convenience function * Entering here, sf is an initialized scrollframe, and * scroll_frame_data is always valid (but the move_cb field can be * NULL, for pure APP_DEFINED case support). * *************************************<->***********************************/ void _XmSFAddNavigator( Widget sf, Widget nav, Mask dimMask, XmScrollFrameData scroll_frame_data) { XmNavigatorTrait nav_trait ; XmNavigatorDataRec nav_data ; if ((nav_trait = (XmNavigatorTrait) XmeTraitGet((XtPointer) XtClass(nav), XmQTnavigator)) != NULL) { /* check for NULL move_cb */ if (scroll_frame_data->move_cb) nav_trait -> changeMoveCB(nav, scroll_frame_data->move_cb, (XtPointer) scroll_frame_data->scrollable, True) ; nav_data.valueMask = NavDimMask ; nav_data.dimMask = dimMask ; nav_trait -> setValue(nav, &nav_data, False); if (scroll_frame_data->num_nav_list == scroll_frame_data->num_nav_slots) { /* Allocate more space */ scroll_frame_data->num_nav_slots += 2; scroll_frame_data->nav_list = (WidgetList) XtRealloc((char*)scroll_frame_data->nav_list, scroll_frame_data->num_nav_slots * sizeof(Widget)); } scroll_frame_data->nav_list[scroll_frame_data->num_nav_list] = nav; scroll_frame_data->num_nav_list++; } else { XmeWarning(sf, SWMessage3); } }
Widget _XmBB_CreateButtonG( Widget bb, XmString l_string, char *name, XmLabelStringLoc l_loc ) { Arg al[10] ; register Cardinal ac = 0 ; Widget button ; XmTakesDefaultTrait trait_default ; XmString default_label_string_loc = NULL; /****************/ if( l_string ) { XtSetArg( al[ac], XmNlabelString, l_string) ; ac++ ; } else { default_label_string_loc = XmStringCreate(GetLabelString(l_loc), XmFONTLIST_DEFAULT_TAG); XtSetArg( al[ac], XmNlabelString, default_label_string_loc); ac++; } XtSetArg( al[ac], XmNstringDirection, BB_StringDirection( bb)) ; ac++ ; button = XmCreatePushButtonGadget( (Widget) bb, name, al, ac) ; trait_default = (XmTakesDefaultTrait) XmeTraitGet((XtPointer) XtClass(button), XmQTtakesDefault) ; if (trait_default) trait_default->showAsDefault (button, XmDEFAULT_READY); if (default_label_string_loc) XmStringFree(default_label_string_loc); return( button ) ; }
/************************************************************************ * * _XmSFRemoveNavigator convenience function * *************************************<->***********************************/ void _XmSFRemoveNavigator( Widget sf, Widget nav, XmScrollFrameData scroll_frame_data) { Cardinal position, i; XmNavigatorTrait nav_trait ; if ((nav_trait = (XmNavigatorTrait) XmeTraitGet((XtPointer) XtClass(nav), XmQTnavigator)) != NULL) { /* remove the move callback */ if (scroll_frame_data->move_cb) nav_trait -> changeMoveCB(nav, scroll_frame_data->move_cb, (XtPointer) scroll_frame_data->scrollable, False) ; } else { XmeWarning(sf, SWMessage4); return ; } for (position = 0; position<scroll_frame_data->num_nav_list; position++) { if (scroll_frame_data->nav_list[position] == nav) { break; } } if (position == scroll_frame_data->num_nav_list) return; scroll_frame_data->num_nav_list--; for (i = position; i < scroll_frame_data->num_nav_list; i++) { scroll_frame_data->nav_list[i] = scroll_frame_data->nav_list[i+1]; } }
/* * border width and size and location are ty... * * 1. We allow the border width of a XmDialogShell child to change * size arbitrarily. * * 2. The border width of the shell widget tracks the child's * at all times, exactly. * * 3. The width of the shell is kept exactly the same as the * width of the child at all times. * * 4. The child is always positioned at the location * (- child_border, - child_border). * * the net result is the child has a border width which is always * what the user asked for; but none of it is ever seen, it's all * clipped by the shell (parent). The user sees the border * of the shell which is the size he set the child's border to. * * In the DEC window manager world the window manager does * exactly the same thing with the window it puts around the shell. * Hence the shell and child have a border width just as the user * set but the window manager overrides that and only a single * pixel border is displayed. In a non-wm environment the child * appears to have a border width, in reality this is the shell * widget border. You wanted to know... */ static void ChangeManaged( Widget wid ) { XmDialogShellWidget shell = (XmDialogShellWidget) wid ; /* * If the child went to unmanaged, call XtPopdown. * If the child went to managed, call XtPopup. */ Widget child; XmWidgetExtData extData = _XmGetWidgetExtData((Widget) shell, XmSHELL_EXTENSION); XmVendorShellExtObject ve = (XmVendorShellExtObject)extData->widget; XmDialogSavvyTrait trait ; if (((child = GetRectObjKid((CompositeWidget) shell)) == NULL) || (child->core.being_destroyed)) return; trait = (XmDialogSavvyTrait) XmeTraitGet((XtPointer) XtClass(child), XmQTdialogShellSavvy) ; /* MANAGED Case first ********/ if (child->core.managed) { XtWidgetGeometry request; Position kidX, kidY; Dimension kidBW; Boolean defaultPosition = True; /* * temporary workaround for setkeyboard focus ||| */ if (child != ve->vendor.old_managed) { XtSetKeyboardFocus((Widget)shell, (Widget)child); ve->vendor.old_managed = (Widget)child; } /* * if the child isn't realized, then we need to realize it * so we have a valid size. It will get created as a result * so we zero out it's position info so it'll * be okay and then restore it. */ if (!XtIsRealized(child)) { kidX = XtX(child); kidY = XtY(child); kidBW = XtBorderWidth(child); XtX(child) = 0; XtY(child) = 0; XtBorderWidth(child) = 0; /* Bug 4102306, This is an additional difference brought forward from motif 1.2 */ if (XtHeight(shell) != XtHeight(child)) { _XmImChangeManaged((Widget)shell); } /* End fix for Bug 4012306 */ XtRealizeWidget(child); XtX(child) = kidX; XtY(child) = kidY; XtBorderWidth(child) = kidBW; } else if (trait) { /* * Move the window to 0,0 * but don't tell the widget. It thinks it's where * the shell is... */ if ((XtX(child) != 0) || (XtY(child) != 0)) XMoveWindow (XtDisplay(child), XtWindow(child), 0, 0); } /* * map callback should occur BEFORE child default positioning * otherwise, widgets such as fileselection using map callback for * correct sizing have default positioning done before the widget * grows to its correct dimensions */ if(shell->core.mapped_when_managed && trait ) { trait->callMapUnmapCB(child, True); /* call Map callback */ } /* * Make sure that the shell has the same common parameters as * its child. Then move the child so that the shell will * correctly surround it. */ request.request_mode = 0; if (trait) { XtVaGetValues(child, XmNdefaultPosition, &defaultPosition, NULL); if (defaultPosition && (ve->vendor.externalReposition)) { defaultPosition = False; XtVaSetValues(child, XmNdefaultPosition, False, NULL); } } if (XtX(child) && trait) { kidX = XtX(child); XtX(child) = 0; } else kidX = XtX(shell); if (XtY(child) && trait) { kidY = XtY(child); XtY(child) = 0; } else kidY = XtY(shell); if (XtBorderWidth(child) && trait) { kidBW = XtBorderWidth(child); XtBorderWidth(child) = 0; } else kidBW = XtBorderWidth(shell); if (XtWidth (child) != XtWidth (shell)) { request.request_mode |= CWWidth; request.width = XtWidth(child); } if (XtHeight (child) + ve->vendor.im_height != XtHeight (shell)) { request.request_mode |= CWHeight; request.height = XtHeight(child) + ve->vendor.im_height; } if (trait) { if (defaultPosition) { GetDefaultPosition(child, XtParent(shell), &request.x, &request.y); if (request.x != kidX) request.request_mode |= CWX; if (request.y != kidY) request.request_mode |= CWY; } else { if (kidX != XtX(shell)) { request.request_mode |= CWX; if (kidX == XmDIALOG_SAVVY_FORCE_ORIGIN) request.x = 0; else request.x = kidX; } if (kidY != XtY(shell)) { request.request_mode |= CWY; if (kidY == XmDIALOG_SAVVY_FORCE_ORIGIN) request.y = 0; else request.y = kidY; } } } else { if (kidX != XtX(shell)) { request.request_mode |= CWX; request.x = kidX; } if (kidY != XtY(shell)) { request.request_mode |= CWY; request.y = kidY; } if (kidBW != XtBorderWidth(shell)) { request.request_mode |= CWBorderWidth; request.border_width = kidBW; } } if (request.request_mode) { unsigned int old_height = ve->vendor.im_height; XtMakeGeometryRequest((Widget) shell, &request, &request); _XmImResize((Widget)shell); if (ve->vendor.im_height != old_height) { request.request_mode = CWHeight; request.height = XtHeight(child) + ve->vendor.im_height; XtMakeGeometryRequest((Widget) shell, &request, &request); _XmImResize((Widget)shell); } } /* * the grab_kind is handled in the popup_callback */ if(shell->core.mapped_when_managed ) { XtPopup ((Widget) shell, XtGrabNone); } } /* * CHILD BEING UNMANAGED */ else { int i, j; /* * Fix for CR5043, CR5758 and CR8825 - * For nested Dialog Shells, it is necessary to unmanage * dialog shell popups of the child of this dialog shell. */ for (i = 0; i < child->core.num_popups; i++) { if (XmIsDialogShell(child->core.popup_list[i])) { XmDialogShellWidget next_shell = (XmDialogShellWidget)(child->core.popup_list[i]); for (j = 0; j < next_shell->composite.num_children; j++) { XtUnmanageChild(next_shell->composite.children[j]); } } } /* End Fix CR5043, CR5758 and CR8825 */ /* * take it down and then tell user */ XtPopdown((Widget) shell); if(trait ) { trait->callMapUnmapCB(child, False); /* call UnMap callback */ } } XmeNavigChangeManaged((Widget) shell); }
/************************************************************************ * * * InsertChild * * * ************************************************************************/ static void InsertChild( Widget w ) { CompositeWidgetClass superclass = (CompositeWidgetClass) xmMainWindowClassRec.core_class.superclass ; XmMainWindowWidget mw = (XmMainWindowWidget ) w->core.parent; XmScrolledWindowConstraint nc = GetSWConstraint(w); XtWidgetProc insert_child; if (!XtIsRectObj(w)) return; /* Try to guess the nature of the child_type . If we're lucky, fine, otherwise, something bad might happens: the scrolledwindow can take it as a workwindow and possibly reparents it to the clipwindow. In the absence of a set childType constraint resource set, there is not much we can do to avoid the problem */ /* Note: auto created Separator were already labelled in Initialize */ if (nc->child_type == (unsigned char) RESOURCE_DEFAULT) { XmMenuSystemTrait menuSTrait; if ((menuSTrait = (XmMenuSystemTrait) XmeTraitGet ((XtPointer) XtClass(w), XmQTmenuSystem)) != NULL) { if (menuSTrait->type(w) == XmMENU_BAR && !mw->mwindow.MenuBar) { /* If it's a menubar, and we don't have one yet, use it. */ nc->child_type = XmMENU_BAR ; } } else if (XmIsCommandBox(w)) { if (!mw->mwindow.CommandWindow) { /* If it's a command, and we don't have one, get it */ nc->child_type = XmCOMMAND_WINDOW ; } } else /* new in 2.0 */ if (XmIsMessageBox(w)) { if (!mw->mwindow.Message) { nc->child_type = XmMESSAGE_WINDOW ; } } } if (nc->child_type == XmMENU_BAR) { mw->mwindow.MenuBar = w; } else if (nc->child_type == XmCOMMAND_WINDOW) { mw->mwindow.CommandWindow = w; } else if (nc->child_type == XmMESSAGE_WINDOW) { mw->mwindow.Message = w; } /* call ScrolledWindow InsertChild directly, since it does nothing to the MainWindow known childType */ _XmProcessLock(); insert_child = superclass->composite_class.insert_child; _XmProcessUnlock(); (*insert_child)(w); }