void MotifUI::GetResources(const XtResourceList resources, const int numResources) { if (_w && resources) XtGetSubresources(XtParent(_w), (XtPointer) this, _widgetName, className(), resources, numResources, NULL, 0); }
Widget XmCreateSimplePulldownMenu( Widget parent, String name, ArgList args, Cardinal arg_count ) { Widget rc; XmSimpleMenuRec mr; int n, i; Arg local_args[3]; WidgetList buttons; Cardinal num_buttons; _XmWidgetToAppContext(parent); _XmAppLock(app); XtGetSubresources(parent, &mr, name, XmCSimplePulldownMenu, SimpleMenuResources, XtNumber(SimpleMenuResources), args, arg_count); rc = XmCreatePulldownMenu(parent, name, args, arg_count); EvaluateConvenienceStructure(rc, &mr); if (mr.post_from_button >= 0) { n = 0; XtSetArg(local_args[n], XtNchildren, &buttons); n++; XtSetArg(local_args[n], XtNnumChildren, &num_buttons); n++; XtGetValues(parent, local_args, n); if (!num_buttons) { /* error condition */ _XmAppUnlock(app); return(rc); } else { for (i = 0; i < num_buttons; i++) { if (((XmIsCascadeButtonGadget(buttons[i])) || (XmIsCascadeButton(buttons[i]))) && (i == mr.post_from_button)) break; } if ( i < num_buttons) { n = 0; XtSetArg(local_args[n], XmNsubMenuId, rc); n++; XtSetValues(buttons[i], local_args, n); } } } _XmAppUnlock(app); return(rc); }
void XltHelpOnStrokes(Widget W) { static Widget Dialog = NULL; Widget Shell = W; while (!XtIsShell(Shell)) Shell = XtParent(Shell); if (Dialog == NULL) { XmString string; XtResource resources[] = { {"messageString", "MessageString", XtRString, sizeof(String), XtOffset(AppResourcesPtr, DefaultHelpString), XtRImmediate, DefaultHelp}, }; Dialog = XmCreateInformationDialog(Shell, "HelpOnStrokes", NULL, 0); XtGetSubresources(W, &AppResources, XtName(Dialog), XtClass(Dialog)->core_class.class_name, resources, XtNumber(resources), NULL, 0); string = XmStringCreateLtoR(AppResources.DefaultHelpString, XmFONTLIST_DEFAULT_TAG); XtVaSetValues(Dialog, XmNmessageString, string, NULL); XmStringFree(string); XtUnmanageChild(XmMessageBoxGetChild(Dialog, XmDIALOG_HELP_BUTTON)); } XtManageChild(Dialog); }
void XsComponent::_getResources (const XtResourceList resources, int num) { assert (_base != 0); assert (resources != 0); // Validate input if (num <= 0) return; // Get the subresources XtGetSubresources (XtParent (_base), (XtPointer)this, _name, className ( ), resources, num, 0, 0); }
Widget XmCreateSimpleCheckBox( Widget parent, String name, ArgList args, Cardinal arg_count ) { Arg local_args[5]; Widget rc, child; int i, n; XmSimpleMenuRec mr; char name_buf[20]; rc = XmCreateRadioBox(parent, name, args, arg_count); n = 0; XtSetArg(local_args[n], XmNradioBehavior, FALSE); n++; XtSetValues(rc, local_args, n); XtGetSubresources(parent, &mr, name, XmCSimpleCheckBox, SimpleMenuResources, XtNumber(SimpleMenuResources), args, arg_count); for(i=0; i < mr.count; i++) { sprintf(name_buf,"button_%d", i); n = 0; if (mr.label_string && mr.label_string[i]) { XtSetArg(local_args[n], XmNlabelString, mr.label_string[i]); n++; } child = XtCreateManagedWidget(name_buf, xmToggleButtonGadgetClass, (Widget) rc, local_args, n); if (mr.callback) XtAddCallback(child, XmNvalueChangedCallback, mr.callback, (XtPointer)(unsigned long)i); } return(rc); }
static StrokeStatePtr StrokeGetMap(Widget W) { StrokeStatePtr State; State = StrokeMapList; while (State != NULL) { if (State->widget == W) { break; } State = State->next; } if (State == NULL) { StrokeStatePtr NewState; NewState = XtNew(StrokeState_t); NewState->next = StrokeMapList; StrokeMapList = NewState; NewState->widget = W; NewState->InStroke = False; NewState->points = NULL; NewState->box = NULL; NewState->Map = NULL; NewState->npoints = 0; NewState->maxpoints = 0; NewState->gc = (GC)NULL; XtGetSubresources(XtParent(W), NewState, XtName(W), XtClass(W)->core_class.class_name, resources, XtNumber(resources), NULL, 0); CompileTranslations(NewState); State = NewState; } return (State); }
/*ARGSUSED*/ static void InitializePrehook(Widget req, /* unused */ Widget new_w, ArgList args, Cardinal *num_args) { XmExtObjectClass ec = (XmExtObjectClass) XtClass(new_w); XmBaseClassExt *wcePtr = _XmGetBaseClassExtPtr(ec, XmQmotif); if ((*wcePtr)->use_sub_resources) { /* * Get a uncompiled resource list to use with XtGetSubresources. * We can't do this in ClassPartInitPosthook because Xt doesn't * set class_inited at the right place and thereby mishandles * the XtGetResourceList call. */ _XmProcessLock(); if ((*wcePtr)->ext_resources == NULL) { ec->object_class.resources = (*wcePtr)->compiled_ext_resources; ec->object_class.num_resources = (*wcePtr)->num_ext_resources; XtGetResourceList((WidgetClass) ec, &((*wcePtr)->ext_resources), &((*wcePtr)->num_ext_resources)); } XtGetSubresources(XtParent(new_w), (XtPointer)new_w, NULL, NULL, (*wcePtr)->ext_resources, (*wcePtr)->num_ext_resources, args, *num_args); _XmProcessUnlock(); } }
Widget XmCreateSimplePopupMenu( Widget parent, String name, ArgList args, Cardinal arg_count ) { Widget rc; XmSimpleMenuRec mr; _XmWidgetToAppContext(parent); _XmAppLock(app); XtGetSubresources(parent, &mr, name, XmCSimplePopupMenu, SimpleMenuResources, XtNumber(SimpleMenuResources), args, arg_count); rc = XmCreatePopupMenu(parent, name, args, arg_count); EvaluateConvenienceStructure( rc, &mr); _XmAppUnlock(app); return(rc); }
/********************************************************************* * Function: CreateDA * * CreateDA creates a Text Graphic area with the appropriate scroll bars. * *********************************************************************/ static XtPointer HelpCreateDA( Widget parent, char *name, short vert_flag, short horz_flag, Boolean traversal_flag, _DtCvValue honor_size, _DtCvRenderType render_type, int rows, int columns, unsigned short media_resolution, void (*hyperTextCB)(), void (*resizeCB)(), int (*exec_ok_routine)(), XtPointer client_data, XmFontList default_list ) { DtHelpDispAreaStruct *pDAS; DAArgs DA_args; Arg args[20]; int n; int maxFontAscent; int maxFontDescent; int maxFontCharWidth; short margin_width; short margin_height; short shadowThick, highThick; Dimension hBarHeight = 0; Dimension vBarWidth = 0; Dimension width; Boolean value; Widget form; Display *dpy = XtDisplay(parent); Screen *retScr = XtScreen(parent); int screen = XScreenNumberOfScreen(retScr); Colormap colormap; Pixmap tile; XGCValues gcValues; unsigned long gcMask; unsigned long char_width; Atom xa_ave_width; XFontStruct *tmpFont = NULL; XtPointer default_font = NULL; XRectangle rectangle[1]; XmFontContext fontContext; XmFontListEntry fontEntry; XmFontType fontType; /* Allocate the Display Area. */ pDAS = (DtHelpDispAreaStruct *) XtMalloc(sizeof(DtHelpDispAreaStruct)); /* * get the resources */ XtGetSubresources(parent, &DA_args, name, "XmDrawnButton", Resources, XtNumber(Resources), NULL, 0); if (rows <= 0) rows = 1; if (columns <= 0) columns = 1; /* * initialize the structure variables. */ pDAS->text_selected = False; pDAS->primary = False; pDAS->select_state = _DtHelpNothingDoing; pDAS->toc_y = 0; pDAS->toc_base = 0; pDAS->toc_flag = 0; if (traversal_flag) pDAS->toc_flag = _DT_HELP_SHADOW_TRAVERSAL | _DT_HELP_NOT_INITIALIZED; pDAS->max_spc = 0; pDAS->cur_spc = 0; pDAS->maxX = 0; pDAS->virtualX = 0; pDAS->firstVisible = 0; pDAS->visibleCount = rows; pDAS->maxYpos = 0; pDAS->neededFlags = 0; pDAS->vert_init_scr = DA_args.initialDelay; pDAS->vert_rep_scr = DA_args.repeatDelay; pDAS->horz_init_scr = DA_args.initialDelay; pDAS->horz_rep_scr = DA_args.repeatDelay; pDAS->moveThreshold = DA_args.moveThreshold; pDAS->marginWidth = DA_args.marginWidth; pDAS->marginHeight = DA_args.marginHeight; pDAS->searchColor = DA_args.search_color; pDAS->depth = 0; pDAS->spc_chars = NULL; pDAS->scr_timer_id = 0; pDAS->def_pix = 0; pDAS->context = NULL; pDAS->vertIsMapped = False; pDAS->horzIsMapped = False; pDAS->lst_topic = NULL; pDAS->nextNonVisible = 0; pDAS->media_resolution = media_resolution; pDAS->honor_size = honor_size; pDAS->render_type = render_type; pDAS->dtinfo = 0; pDAS->stipple = None; /* * locale dependant information */ pDAS->nl_to_space = 1; pDAS->cant_begin_chars = NULL; pDAS->cant_end_chars = NULL; if (1 < MB_CUR_MAX) _DtHelpLoadMultiInfo (&(pDAS->cant_begin_chars), &(pDAS->cant_end_chars), &(pDAS->nl_to_space)); /* * initialize the hypertext callback pointer */ pDAS->exec_filter = exec_ok_routine; pDAS->hyperCall = hyperTextCB; pDAS->resizeCall = resizeCB; pDAS->clientData = client_data; /* * zero out other callback fields */ pDAS->vScrollNotify = NULL ; pDAS->armCallback = NULL ; /* * create the atoms needed */ xa_ave_width = XmInternAtom(dpy, "AVERAGE_WIDTH" , False); /* * Malloc for the default font. */ (void) XmeRenderTableGetDefaultFont(DA_args.userFont, &tmpFont); if (default_list != NULL && XmFontListInitFontContext (&fontContext, default_list)) { fontEntry = XmFontListNextEntry (fontContext); if (fontEntry != NULL) default_font = XmFontListEntryGetFont (fontEntry, &fontType); XmFontListFreeFontContext (fontContext); } /* * fake out the next call by using the parent as the display widget */ pDAS->dispWid = parent; __DtHelpFontDatabaseInit (pDAS, default_font, fontType, tmpFont); /* * Get the base font meterics. */ __DtHelpFontMetrics (pDAS->font_info, __DtHelpDefaultFontIndexGet(pDAS), &maxFontAscent, &maxFontDescent, &maxFontCharWidth, NULL, NULL); pDAS->leading = DA_args.leading; pDAS->fontAscent = maxFontAscent; pDAS->lineHeight = maxFontAscent + maxFontDescent + pDAS->leading + 1; n = __DtHelpDefaultFontIndexGet(pDAS); if (n < 0) value = get_fontsetproperty(__DtHelpFontSetGet(pDAS->font_info, n), xa_ave_width, ((unsigned long *) &(pDAS->charWidth))); else value = XGetFontProperty(__DtHelpFontStructGet(pDAS->font_info, n), xa_ave_width, ((unsigned long *) &(pDAS->charWidth))); if (False == value || 0 == pDAS->charWidth) { int len = maxFontCharWidth; if (n < 0) len += XmbTextEscapement( __DtHelpFontSetGet(pDAS->font_info,n),"1",1); else len += XTextWidth(__DtHelpFontStructGet(pDAS->font_info, n),"1",1); pDAS->charWidth = 10 * len / 2; } /* * Create the form to manage the window and scroll bars. */ n = 0; XtSetArg(args[n], XmNresizePolicy , XmRESIZE_ANY); ++n; XtSetArg(args[n], XmNshadowType , XmSHADOW_OUT); ++n; form = XmCreateForm(parent, "DisplayAreaForm", args, n); XtManageChild(form); /* * force the shadowThickness to zero. The XmManager will try to set * this to one. */ n = 0; XtSetArg(args[n], XmNshadowThickness , 0); ++n; XtSetArg(args[n], XmNhighlightThickness, 0); ++n; XtSetValues (form, args, n); /* * get the colors and margin widths and heights */ n = 0; XtSetArg (args[n], XmNmarginWidth , &margin_width); ++n; XtSetArg (args[n], XmNmarginHeight, &margin_height); ++n; XtSetArg (args[n], XmNcolormap , &colormap); ++n; XtGetValues(form, args, n); /* Create the vertical scrollbar. */ pDAS->vertScrollWid = NULL; if (vert_flag != _DtHelpNONE) { if (vert_flag == _DtHelpSTATIC) pDAS->vertIsMapped = True; n = 0; XtSetArg(args[n], XmNtopAttachment , XmATTACH_FORM); ++n; XtSetArg(args[n], XmNtopOffset , 0); ++n; XtSetArg(args[n], XmNbottomAttachment , XmATTACH_FORM); ++n; XtSetArg(args[n], XmNbottomOffset , margin_height); ++n; XtSetArg(args[n], XmNrightAttachment , XmATTACH_FORM); ++n; XtSetArg(args[n], XmNrightOffset , 0); ++n; XtSetArg(args[n], XmNorientation , XmVERTICAL); ++n; XtSetArg(args[n], XmNtraversalOn , True); ++n; XtSetArg(args[n], XmNhighlightThickness, 1); ++n; XtSetArg(args[n], XmNshadowType , XmSHADOW_IN); ++n; XtSetArg(args[n], XmNvalue , 0); ++n; XtSetArg(args[n], XmNminimum , 0); ++n; /* fake out the scrollbar manager, who will init dims to 100 */ XtSetArg(args[n], XmNheight , 1); ++n; XtSetArg(args[n], XmNmaximum , 1); ++n; XtSetArg(args[n], XmNincrement , 1); ++n; XtSetArg(args[n], XmNpageIncrement , 1); ++n; XtSetArg(args[n], XmNsliderSize , 1); ++n; XtSetArg(args[n], XtNmappedWhenManaged , pDAS->vertIsMapped); ++n; pDAS->vertScrollWid = XmCreateScrollBar(form, "DisplayDtHelpVertScrollBar", args, n); XtManageChild(pDAS->vertScrollWid); if (vert_flag != _DtHelpSTATIC) pDAS->neededFlags = _DtHelpSET_AS_NEEDED (pDAS->neededFlags, _DtHelpVERTICAL_SCROLLBAR); XtAddCallback(pDAS->vertScrollWid, XmNdragCallback, _DtHelpVertScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->vertScrollWid, XmNincrementCallback, _DtHelpVertScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->vertScrollWid, XmNdecrementCallback, _DtHelpVertScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->vertScrollWid, XmNpageIncrementCallback, _DtHelpVertScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->vertScrollWid, XmNpageDecrementCallback, _DtHelpVertScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->vertScrollWid, XmNtoBottomCallback, _DtHelpVertScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->vertScrollWid, XmNtoTopCallback, _DtHelpVertScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->vertScrollWid, XmNvalueChangedCallback, _DtHelpVertScrollCB, (XtPointer) pDAS); XtAddEventHandler (pDAS->vertScrollWid, ButtonPressMask, True, (XtEventHandler)_DtHelpMoveBtnFocusCB,(XtPointer) pDAS); } /* Create the horizontal scrollbar. */ pDAS->horzScrollWid = NULL; if (horz_flag != _DtHelpNONE) { if (horz_flag == _DtHelpSTATIC) pDAS->horzIsMapped = True; n = 0; XtSetArg(args[n], XmNbottomAttachment , XmATTACH_FORM); ++n; XtSetArg(args[n], XmNbottomOffset , 0); ++n; XtSetArg(args[n], XmNrightAttachment , XmATTACH_FORM); ++n; XtSetArg(args[n], XmNrightOffset , margin_width); ++n; XtSetArg(args[n], XmNleftAttachment , XmATTACH_FORM); ++n; XtSetArg(args[n], XmNleftOffset , 0); ++n; XtSetArg(args[n], XmNorientation , XmHORIZONTAL); ++n; XtSetArg(args[n], XmNtraversalOn , True); ++n; XtSetArg(args[n], XmNhighlightThickness, 1); ++n; XtSetArg(args[n], XmNshadowType , XmSHADOW_IN); ++n; XtSetArg(args[n], XmNvalue , 0); ++n; XtSetArg(args[n], XmNminimum , 0); ++n; XtSetArg(args[n], XmNmaximum , (pDAS->charWidth/10)); ++n; /* fake out the scrollbar manager, who will init dims to 100 */ XtSetArg(args[n], XmNwidth , 1); ++n; XtSetArg(args[n], XmNincrement , (pDAS->charWidth/10)); ++n; XtSetArg(args[n], XmNpageIncrement , (pDAS->charWidth/10)); ++n; XtSetArg(args[n], XmNsliderSize , (pDAS->charWidth/10)); ++n; XtSetArg(args[n], XtNmappedWhenManaged , pDAS->horzIsMapped); ++n; pDAS->horzScrollWid = XmCreateScrollBar(form, "DisplayHorzScrollBar", args, n); XtManageChild(pDAS->horzScrollWid); if (horz_flag != _DtHelpSTATIC) pDAS->neededFlags = _DtHelpSET_AS_NEEDED (pDAS->neededFlags, _DtHelpHORIZONTAL_SCROLLBAR); XtAddCallback(pDAS->horzScrollWid, XmNdragCallback, _DtHelpHorzScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->horzScrollWid, XmNincrementCallback, _DtHelpHorzScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->horzScrollWid, XmNdecrementCallback, _DtHelpHorzScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->horzScrollWid, XmNpageIncrementCallback, _DtHelpHorzScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->horzScrollWid, XmNpageDecrementCallback, _DtHelpHorzScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->horzScrollWid, XmNtoBottomCallback, _DtHelpHorzScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->horzScrollWid, XmNtoTopCallback, _DtHelpHorzScrollCB, (XtPointer) pDAS); XtAddCallback(pDAS->horzScrollWid, XmNvalueChangedCallback, _DtHelpHorzScrollCB, (XtPointer) pDAS); } /* * check for the horizontal attachments */ n = 0; if (horz_flag == _DtHelpSTATIC) { XtSetArg(args[n], XmNbottomAttachment , XmATTACH_WIDGET); ++n; XtSetArg(args[n], XmNbottomWidget , pDAS->horzScrollWid); ++n; } else { XtSetArg(args[n], XmNbottomAttachment , XmATTACH_FORM); ++n; } /* * check for the vertical attachments */ if (vert_flag == _DtHelpSTATIC) { XtSetArg(args[n], XmNrightAttachment , XmATTACH_WIDGET); ++n; XtSetArg(args[n], XmNrightWidget , pDAS->vertScrollWid); ++n; } else { XtSetArg(args[n], XmNrightAttachment , XmATTACH_FORM); ++n; } /* * do the rest of the arguments */ XtSetArg(args[n], XmNbottomOffset , margin_height); ++n; XtSetArg(args[n], XmNrightOffset , margin_width); ++n; XtSetArg(args[n], XmNtopAttachment , XmATTACH_FORM); ++n; XtSetArg(args[n], XmNtopOffset , 0); ++n; XtSetArg(args[n], XmNleftAttachment , XmATTACH_FORM); ++n; XtSetArg(args[n], XmNleftOffset , 0); ++n; XtSetArg(args[n], XmNrecomputeSize , False); ++n; XtSetArg(args[n], XmNpushButtonEnabled , False); ++n; XtSetArg(args[n], XmNtraversalOn , True); ++n; XtSetArg(args[n], XmNhighlightThickness, 1); ++n; XtSetArg(args[n], XmNshadowType , XmSHADOW_IN); ++n; XtSetArg(args[n], XmNmultiClick , XmMULTICLICK_DISCARD); ++n; XtSetArg(args[n], XmNuserData , pDAS); ++n; pDAS->dispWid = XmCreateDrawnButton(form, name, args, n); XtManageChild(pDAS->dispWid); XtAddCallback(pDAS->dispWid, XmNexposeCallback, _DtHelpExposeCB, (XtPointer) pDAS); XtAddCallback(pDAS->dispWid, XmNresizeCallback, _DtHelpResizeCB, (XtPointer) pDAS); XtAddCallback(pDAS->dispWid, XmNarmCallback, _DtHelpClickOrSelectCB, (XtPointer) pDAS); XtAddCallback(pDAS->dispWid, XmNdisarmCallback, _DtHelpEndSelectionCB, (XtPointer) pDAS); XtAddEventHandler (pDAS->dispWid, Button1MotionMask, True, (XtEventHandler)_DtHelpMouseMoveCB, (XtPointer) pDAS); /* * add my actions * parse the translations. */ _DtHelpProcessLock(); if (DrawnBTrans == NULL) DrawnBTrans = XtParseTranslationTable(DrawnBTransTable); /* * override the translations XtSetArg(args[n], XmNtranslations , DrawnBTrans); ++n; */ if (DrawnBTrans != NULL) XtOverrideTranslations(pDAS->dispWid, DrawnBTrans); _DtHelpProcessUnlock(); if (_XmGetFocusPolicy(parent) == XmPOINTER) { XtAddEventHandler (pDAS->dispWid, EnterWindowMask, True, (XtEventHandler)_DtHelpEnterLeaveCB, (XtPointer) pDAS); XtAddEventHandler (pDAS->dispWid, LeaveWindowMask, True, (XtEventHandler)_DtHelpEnterLeaveCB, (XtPointer) pDAS); } else XtAddEventHandler (pDAS->dispWid, FocusChangeMask, True, (XtEventHandler)_DtHelpFocusCB, (XtPointer) pDAS); XtAddEventHandler (pDAS->dispWid, VisibilityChangeMask, True, (XtEventHandler)_DtHelpVisibilityCB, (XtPointer) pDAS); /* Add a destroy callback so that the display area can clean up prior to * the help widget getting destroyed (e.g. display area's parent) */ XtAddCallback(pDAS->dispWid, XmNdestroyCallback, _DtHelpDisplayAreaDestroyCB, (XtPointer) pDAS); n = 0; XtSetArg(args[n], XmNshadowThickness , &shadowThick); ++n; XtSetArg(args[n], XmNhighlightThickness, &highThick); ++n; XtSetArg(args[n], XmNforeground , &(pDAS->foregroundColor)); ++n; XtSetArg(args[n], XmNbackground , &(pDAS->backgroundColor)); ++n; XtSetArg(args[n], XmNhighlightColor, &(pDAS->traversalColor) ); ++n; XtSetArg(args[n], XmNdepth , &(pDAS->depth) ); ++n; XtGetValues(pDAS->dispWid, args, n); pDAS->decorThickness = shadowThick + highThick; /* * Get the underline information */ GetUnderLineInfo (dpy, pDAS, &(pDAS->lineThickness)); /* * get the tiling pattern. */ tile = XmGetPixmap (XtScreen(pDAS->dispWid), "50_foreground", pDAS->foregroundColor, pDAS->backgroundColor); /* * Get the data for the graphics contexts and create the GC's. */ gcMask = (GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth | GCLineStyle | GCClipXOrigin | GCClipYOrigin | GCClipMask); gcValues.function = GXcopy; gcValues.plane_mask = AllPlanes; gcValues.foreground = pDAS->foregroundColor; gcValues.background = pDAS->backgroundColor; gcValues.line_style = LineSolid; gcValues.line_width = pDAS->lineThickness; gcValues.clip_x_origin = 0; gcValues.clip_y_origin = 0; gcValues.clip_mask = None; if (tile) { gcMask |= GCTile; gcValues.tile = tile; } pDAS->normalGC = XCreateGC(dpy, RootWindowOfScreen(XtScreen(pDAS->dispWid)), gcMask, &gcValues); gcMask &= (~GCTile); pDAS->pixmapGC = XCreateGC(dpy, RootWindowOfScreen(XtScreen(pDAS->dispWid)), gcMask, &gcValues); gcValues.foreground = pDAS->backgroundColor; gcValues.background = pDAS->foregroundColor; pDAS->invertGC = XCreateGC(dpy, RootWindowOfScreen(XtScreen(pDAS->dispWid)), gcMask, &gcValues); /* * Set the size of the text view area to the requested * number of columns and lines. */ char_width = pDAS->charWidth * columns; /* * Make sure the margins include enough room for a traversal line */ if (((int) pDAS->marginWidth) < pDAS->lineThickness) pDAS->marginWidth = pDAS->lineThickness; if (((int) pDAS->marginHeight) < pDAS->lineThickness) pDAS->marginHeight = pDAS->lineThickness; if (pDAS->leading < pDAS->lineThickness) pDAS->leading = pDAS->lineThickness; /* * get the scrollbar widths. */ if (NULL != pDAS->horzScrollWid) { n = 0; XtSetArg(args[n], XmNheight , &hBarHeight); n++; XtSetArg(args[n], XmNinitialDelay, &(pDAS->horz_init_scr)); n++; XtSetArg(args[n], XmNrepeatDelay , &(pDAS->horz_rep_scr)); n++; XtGetValues(pDAS->horzScrollWid, args, n); } if (NULL != pDAS->vertScrollWid) { n = 0; XtSetArg(args[n], XmNwidth , &vBarWidth); n++; XtSetArg(args[n], XmNinitialDelay, &(pDAS->vert_init_scr)); n++; XtSetArg(args[n], XmNrepeatDelay , &(pDAS->vert_rep_scr)); n++; XtGetValues(pDAS->vertScrollWid, args, n); } /* * calculate the display area height/width */ pDAS->dispUseWidth = ((int) (char_width / 10 + (char_width % 10 ? 1 : 0))) + 2 * pDAS->marginWidth; if (vert_flag != _DtHelpSTATIC && pDAS->dispUseWidth < vBarWidth) pDAS->dispUseWidth = vBarWidth; pDAS->dispWidth = pDAS->dispUseWidth + 2 * pDAS->decorThickness; pDAS->dispUseHeight = pDAS->lineHeight * rows; if (horz_flag != _DtHelpSTATIC && pDAS->dispUseHeight < hBarHeight) pDAS->dispUseHeight = hBarHeight; pDAS->dispHeight = pDAS->dispUseHeight + 2 * pDAS->decorThickness; /* * Truncate the width and height to the size of the display. * This will prevent an X protocal error when it is asked for * a too large size. Besides, any decent window manager will * force the overall size to the height and width of the display. * This simply refines the size down to a closer (but not perfect) * fit. */ if (((int) pDAS->dispWidth) > XDisplayWidth (dpy, screen)) { pDAS->dispWidth = XDisplayWidth (dpy, screen); } if (((int) pDAS->dispHeight) > XDisplayHeight (dpy, screen)) { pDAS->dispHeight = XDisplayHeight (dpy, screen); } n = 0; pDAS->formWidth = 0; pDAS->formHeight = 0; XtSetArg(args[n], XmNwidth, pDAS->dispWidth); ++n; XtSetArg(args[n], XmNheight, pDAS->dispHeight); ++n; XtSetValues(pDAS->dispWid, args, n); /* * set the scroll bar values */ if (pDAS->vertScrollWid != NULL) { n = 0; XtSetArg(args[n], XmNmaximum , pDAS->dispUseHeight); ++n; XtSetArg(args[n], XmNincrement , pDAS->lineHeight); ++n; XtSetArg(args[n], XmNpageIncrement , pDAS->lineHeight); ++n; XtSetArg(args[n], XmNsliderSize , pDAS->dispUseHeight); ++n; XtSetValues(pDAS->vertScrollWid, args, n); } if (pDAS->resizeCall) (*(pDAS->resizeCall)) (pDAS->clientData); /* * calculate the offset for the right edge of the * horizontal scrollbar. */ if (vert_flag == _DtHelpSTATIC && pDAS->horzScrollWid) { width = vBarWidth + margin_width; XtSetArg(args[0], XmNrightOffset , width); XtSetValues(pDAS->horzScrollWid, args, 1); } /* * calculate the offset for the bottom end of the * vertical scrollbar. */ if (horz_flag == _DtHelpSTATIC && pDAS->vertScrollWid) { width = hBarHeight + margin_height; XtSetArg(args[0], XmNbottomOffset , width); XtSetValues(pDAS->vertScrollWid, args, 1); } rectangle[0].x = pDAS->decorThickness; rectangle[0].y = pDAS->decorThickness; rectangle[0].width = pDAS->dispUseWidth; rectangle[0].height = pDAS->dispUseHeight; XSetClipRectangles(XtDisplay(pDAS->dispWid), pDAS->normalGC, 0, 0, rectangle, 1, Unsorted); XSetClipRectangles(XtDisplay(pDAS->dispWid), pDAS->invertGC, 0, 0, rectangle, 1, Unsorted); /* * get the colormap and the visual */ if (!XtIsShell(parent) && XtParent(parent) != NULL) parent = XtParent(parent); pDAS->visual = NULL; n = 0; XtSetArg (args[n], XmNcolormap, &(pDAS->colormap)); n++; XtSetArg (args[n], XmNvisual , &(pDAS->visual )); n++; XtGetValues (parent, args, n); if (pDAS->visual == NULL) pDAS->visual = XDefaultVisualOfScreen(XtScreen(pDAS->dispWid)); /* * set up the canvas */ _DtHelpProcessLock(); DefVirtFunctions.exec_cmd_filter = exec_ok_routine; pDAS->canvas = _DtCanvasCreate (DefVirtFunctions, (_DtCvPointer) pDAS); _DtHelpProcessUnlock(); return (XtPointer) pDAS; } /* End _DtHelpCreateDA */
/************************************************************************ * * Initialize * The main widget instance initialization routine. * ************************************************************************/ static void Initialize( Widget rw, Widget nw, ArgList args, Cardinal *num_args ) { XmGadget request = (XmGadget) rw ; XmGadget gw = (XmGadget) nw; XmBaseClassExt *cePtr; XtInitProc secondaryCreate; XmString tool_tip_string; static XtResource subresources[] = { { XmNtoolTipString, XmCToolTipString, XmRXmString, sizeof(XmString), 0, XmRImmediate, (XtPointer) NULL }, }; if( !XmRepTypeValidValue( XmRID_UNIT_TYPE, gw->gadget.unit_type, (Widget) gw) ) { gw->gadget.unit_type = XmPIXELS; } /* Convert the fields from unit values to pixel values */ _XmGadgetImportArgs( (Widget) gw, args, num_args); _XmGadgetImportSecondaryArgs( (Widget) gw, args, num_args); cePtr = _XmGetBaseClassExtPtr(XtClass(gw), XmQmotif); if ((*cePtr) && (*cePtr)->secondaryObjectClass && (secondaryCreate = (*cePtr)->secondaryObjectCreate)) (*secondaryCreate)( (Widget) request, (Widget) gw, args, num_args); XtGetSubresources(nw, &tool_tip_string, NULL, NULL, subresources, XtNumber(subresources), args, *num_args); XmSetToolTipString(nw, tool_tip_string); gw->gadget.event_mask = 0; gw->gadget.have_traversal = FALSE ; gw->gadget.highlighted = FALSE ; gw->gadget.highlight_drawn = FALSE ; if( (gw->gadget.navigation_type != XmDYNAMIC_DEFAULT_TAB_GROUP) && !XmRepTypeValidValue( XmRID_NAVIGATION_TYPE, gw->gadget.navigation_type, (Widget) gw) ) { gw->gadget.navigation_type = XmNONE ; } _XmNavigInitialize ((Widget) request, (Widget) gw, args, num_args); gw->gadget.have_traversal = FALSE ; /* Check the geometry information for the widget */ if (request->rectangle.width == 0) gw->rectangle.width += gw->gadget.highlight_thickness * 2 + gw->gadget.shadow_thickness * 2; if (request->rectangle.height == 0) gw->rectangle.height += gw->gadget.highlight_thickness * 2 + gw->gadget.shadow_thickness * 2; /* Force the border width to 0 */ gw->rectangle.border_width = 0; return ; }
void MakeChooser( void ) { int i; /** greeting **/ XtGetSubresources(table, &greetInfo, "greeting", "Greeting", greetResources, XtNumber(greetResources), NULL, 0); i = InitArg(LabelG); xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_TITLE, MC_DEF_CHOOSER_TITLE); XtSetArg(argt[i], XmNtraversalOn, False); i++; XtSetArg(argt[i], XmNlabelString, xmstr); i++; XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNtopOffset, 10); i++; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER); i++; if ( greetInfo.fontList != NULL ) { XtSetArg(argt[i], XmNfontList, greetInfo.fontList); i++; } greeting = XmCreateLabel(matte1, "greeting", argt, i); XtManageChild(greeting); XmStringFree(xmstr); /** list head **/ i = InitArg(LabelG); xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_HEADING, MC_DEF_CHOOSER_HEADING); XtSetArg(argt[i], XmNtraversalOn, False); i++; XtSetArg(argt[i], XmNlabelString, xmstr); i++; XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++; XtSetArg(argt[i], XmNtopWidget, greeting); i++; XtSetArg(argt[i], XmNtopOffset, 10); i++; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNleftOffset, 13); i++; if (appInfo.chlistFont != NULL) { XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++; } list_head = XmCreateLabelGadget(matte1, "list_head", argt, i); XtManageChild(list_head); XmStringFree(xmstr); i = 0; XtSetArg(argt[i], XmNresizable, True); XtSetValues(matte, argt, i); XtSetValues(matte1, argt, i); /** chooser_list **/ i = 0; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNleftOffset, 10); i++; XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNrightOffset, 10); i++; XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++; XtSetArg(argt[i], XmNtopWidget, list_head); i++; XtSetArg(argt[i], XmNtopOffset, 1); i++; XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET); i++; XtSetArg(argt[i], XmNbottomWidget, ok_button); i++; XtSetArg(argt[i], XmNbottomOffset, 10); i++; XtSetArg(argt[i], XmNallowShellResize, True); i++; XtSetArg(argt[i], XmNlistSizePolicy, XmCONSTANT); i++; XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmSTATIC); i++; if (appInfo.chlistFont != NULL) { XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++; } chooser_list = XmCreateScrolledList(matte1, "chooser_list", argt, i); XtAddCallback(chooser_list, XmNdefaultActionCallback, DoAccept, NULL); XtManageChild(chooser_list); if (appInfo.workspaceCursor) { MakeRootCursor(); } else { XUndefineCursor(dpyinfo.dpy, dpyinfo.root); } }
void MakeLogo( void ) { register int i; char *logoFile; /* name of logo bitmap file */ Pixmap logoPixmap; /* logo pixmap */ char *logoName; /* logo name */ int logoWidth, logoHeight; /* width, height of logo */ Pixel fg, bg; /* foreground, background colors */ Pixmap dsPixmap; /* drop shadow pixmap */ int dsWidth, dsHeight; /* width, height of drop shadow */ Pixmap pixmap; /* scratch pixmap */ GC gc; /* scratch GC */ XGCValues gcval; /* GC values */ unsigned int width, height; /* width, height of bitmap */ int x_hot, y_hot; /* bitmap hot spot (if any)*/ /* * get the user's logo preferences... */ XtGetSubresources(table, &logoInfo, "logo", "Logo", logoResources, XtNumber(logoResources), NULL, 0); /* * create the logo frame... */ i = InitArg(Frame); XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++; XtSetArg(argt[i], XmNshadowThickness, 2); i++; XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNtopOffset, 15); i++; XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNbottomOffset, 15); i++; XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++; XtSetArg(argt[i], XmNrightOffset, 15); i++; XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++; XtSetArg(argt[i], XmNleftWidget, matteFrame); i++; logo1 = XmCreateFrame(matte, "logo", argt, i); XtManageChild(logo1); /* * get the colors of the frame... */ XtSetArg(argt[0], XmNforeground, &fg); XtSetArg(argt[1], XmNbackground, &bg); XtGetValues(logo1, argt, 2); /* * create the logo pixmap... */ logoFile = logoInfo.bitmapFile; #if defined (_AIX) && defined (_POWER) /* * On AIX4 we have a Dtlogo.s.pm */ # define LOGO_TYPE (LOWRES ? DtSMALL : 0) #else # define LOGO_TYPE 0 #endif logoName = _DtGetIconFileName(DefaultScreenOfDisplay(dpyinfo.dpy), logoFile, NULL, NULL, LOGO_TYPE); if (logoName == NULL) { LogError( ReadCatalog(MC_LOG_SET,MC_LOG_NO_LOGOBIT,MC_DEF_LOG_NO_LOGOBIT), logoFile); logoFile = NULL; } /* * create the logo control... */ i = InitArg(LabelG); XtSetArg(argt[i], XmNmarginWidth, 0); i++; XtSetArg(argt[i], XmNmarginHeight, 0); i++; XtSetArg(argt[i], XmNhighlightThickness, 0); i++; XtSetArg(argt[i], XmNbehavior, XmICON_LABEL); i++; XtSetArg(argt[i], XmNfillMode, XmFILL_TRANSPARENT); i++; XtSetArg(argt[i], XmNstring, NULL); i++; if (logoName != NULL) { XtSetArg(argt[i], XmNpixmapForeground, fg); i++; XtSetArg(argt[i], XmNpixmapBackground, bg); i++; XtSetArg(argt[i], XmNimageName, logoName); i++; } else { /* * use built-in logo if no logo was not found */ logoPixmap = XCreatePixmapFromBitmapData( dpyinfo.dpy, /* display */ dpyinfo.root, /* drawable */ (char *)dt_logo_bits, /* data */ dt_logo_width, /* width */ dt_logo_height, /* height */ fg, /* foreground */ bg, /* background */ dpyinfo.depth); /* depth */ logoWidth = dt_logo_width; logoHeight = dt_logo_height; XtSetArg(argt[i], XmNpixmap, logoPixmap); i++; } logo_pixmap = _DtCreateIcon(logo1, "logo_pixmap", argt, i); XtManageChild(logo_pixmap); XtSetArg(argt[0], XmNheight, 245); /* keeps dialog a consistent height and width */ XtSetArg(argt[1], XmNwidth, 245); XtSetValues(logo1, argt, 2); }
Widget XmCreateSimpleOptionMenu( Widget parent, String name, ArgList args, Cardinal arg_count ) { Widget rc, sub_rc; XmSimpleMenuRec mr; int n, i, button_count; Arg local_args[5]; WidgetList buttons; Cardinal num_buttons; _XmWidgetToAppContext(parent); _XmAppLock(app); XtGetSubresources(parent, &mr, name, XmCSimpleOptionMenu, SimpleMenuResources, XtNumber(SimpleMenuResources), args, arg_count); rc = XmCreateOptionMenu(parent, name, args, arg_count); sub_rc = XmCreatePulldownMenu(parent, name, args, arg_count); EvaluateConvenienceStructure(sub_rc, &mr); n = 0; if (mr.option_label) { XtSetArg(local_args[n], XmNlabelString, mr.option_label); n++; } if (mr.option_mnemonic) { XtSetArg(local_args[n], XmNmnemonic, mr.option_mnemonic); n++; } XtSetArg(local_args[n], XmNsubMenuId, sub_rc); n++; XtSetValues(rc, local_args, n); if (mr.button_set >= 0) { n = 0; XtSetArg(local_args[n], XtNchildren, &buttons); n++; XtSetArg(local_args[n], XtNnumChildren, &num_buttons); n++; XtGetValues(sub_rc, local_args, n); if (!num_buttons) { /* error condition */ _XmAppUnlock(app); return(rc); } else { button_count = 0; for (i = 0; i < num_buttons; i++) { /* count only PushB */ if ((XmIsPushButtonGadget(buttons[i])) || (XmIsPushButton(buttons[i]))) { if (button_count == mr.button_set) break; button_count++; } } if ( i < num_buttons) { n = 0; XtSetArg(local_args[n], XmNmenuHistory, buttons[i]); n++; XtSetValues(rc, local_args, n); } } } _XmAppUnlock(app); return(rc); }