void AttachArea::initialize() { // We're making the assumption here that this widget's parent` // is also a form XtWidgetGeometry size; Dimension parWid, parHeight; Dimension txt_w, txt_h; XmFontList fl; XmString xms; int colorUse; short act, inact, prim, second, text; XmPixelSet pixels[XmCO_NUM_COLORS]; _w = XtVaCreateManagedWidget ( "AttachPane", xmFormWidgetClass, _parent, NULL); // Get pixel data. XmeGetColorObjData(XtScreen(_parent), &colorUse, pixels, XmCO_NUM_COLORS, &act, &inact, &prim, &second, &text); _foreground = pixels[text].fg; _background = pixels[text].sc; parWid = _myOwner->textEditor()->get_text_width(); fl = _myOwner->textEditor()->get_text_fontList(); xms = XmStringCreateLocalized("Xyb"); XmStringExtent(fl, xms, &txt_w, &txt_h); parHeight = txt_h + Icon::maxIconHeight() + (2*VSPACE); _appBackground = _background; _appForeground = _foreground; _sw = XtVaCreateManagedWidget ( "AttachPane_ScrolledWindow", xmScrolledWindowWidgetClass, _w, XmNscrollingPolicy, XmAPPLICATION_DEFINED, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNshadowThickness, (Dimension)1, XmNspacing, 2, XmNwidth, parWid, XmNheight, parHeight, NULL); rowOfAttachmentsStatus = XtCreateManagedWidget("Attachments_Status", xmFormWidgetClass, _w, NULL, 0); XtVaSetValues(rowOfAttachmentsStatus, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, _sw, XmNtopOffset, 5, XmNbottomOffset, 5, NULL ); this->addToRowOfAttachmentsStatus(); size.request_mode = CWHeight; XtQueryGeometry(rowOfAttachmentsStatus, NULL, &size); XtVaSetValues( rowOfAttachmentsStatus, XmNpaneMaximum, size.height, XmNpaneMinimum, size.height, NULL ); _vsb = XtVaCreateManagedWidget("vsb", xmScrollBarWidgetClass, _sw, XmNorientation, XmVERTICAL, XmNsliderSize, 1, XmNmaximum, 1, XmNpageIncrement, 1, NULL); XtAddCallback( _vsb, XmNvalueChangedCallback,&AttachArea::valueChangedCallback, (XtPointer) this ); XtAddCallback( _vsb, XmNdragCallback, &AttachArea::dragCallback, (XtPointer) this ); _clipWindow = XtVaCreateManagedWidget("AttachArea_clipWindow", xmDrawingAreaWidgetClass, _sw, XmNresizePolicy, XmRESIZE_NONE, XmNbackground, _background, XmNwidth, parWid, XmNheight, parHeight, NULL); XmScrolledWindowSetAreas(_sw, NULL, _vsb, _clipWindow); XtManageChild(_clipWindow); XtManageChild(_vsb); XtManageChild(_sw); // Set RowCol to NULL here. // It gets set in the expose_all_attachments. _rc = NULL; CalcSizeOfAttachPane(); installDestroyHandler(); }
/* * ------------------------------------------------------------------------ * Name: PdmShellCreate * * Description: * * This function creates a top level application shell. * * Return value: * * 0 if successful; a PDM_EXIT code if not. * */ static int PdmShellCreate(PdmShell* me, const String* fallback_resources, int* argc_in_out, String* argv_in_out) { String app_class; String app_name; XmPixelSet pixelSets[XmCO_NUM_COLORS]; XrmClass class_list[3]; XrmDatabase db; XrmName name_list[3]; XrmRepresentation rep_type; XrmValue value; int decor; int funcs; short secondary_id; /* * create the application context and open the video display */ XtToolkitInitialize(); XtSetLanguageProc((XtAppContext)NULL, (XtLanguageProc)NULL, (XtPointer)NULL); me->app_context = XtCreateApplicationContext(); XtAppSetFallbackResources(me->app_context, (String*)fallback_resources); me->display = XtOpenDisplay(me->app_context, (String)NULL, (String)NULL, "Dtpdm", PdmOptions, XtNumber(PdmOptions), argc_in_out, argv_in_out); if((Display*)NULL == me->display) return PDM_EXIT_VXAUTH; XtGetApplicationNameAndClass(me->display, &app_name, &app_class); /* * the fallback resources are only intended for the video display, so * remove them from the application context */ XtAppSetFallbackResources(me->app_context, (String*)NULL); /* * get the parent video window id from the display's resource database */ db = XtDatabase(me->display); name_list[0] = XrmStringToQuark(app_name); name_list[1] = XrmStringToQuark("parentWindowStr"); name_list[2] = NULLQUARK; class_list[0] = XrmStringToQuark(app_class); class_list[1] = XrmStringToQuark("ParentWindowStr"); class_list[2] = NULLQUARK; XrmQGetResource(db, name_list, class_list, &rep_type, &value); if(!value.addr) return PDM_EXIT_ERROR; me->parent_window = (Window)strtoul((char*)value.addr, (char**)NULL, 0); /* * obtain the parent video window's attributes */ if(!XGetWindowAttributes(me->display, me->parent_window, &me->parent_attr)) return PDM_EXIT_ERROR; /* * register interest in the DestroyNotify event for the parent window */ XSelectInput(me->display, me->parent_window, StructureNotifyMask); /* * create the application shell */ decor = MWM_DECOR_ALL | MWM_DECOR_RESIZEH | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE; funcs = MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE; me->widget = XtVaAppCreateShell(app_name, app_class, applicationShellWidgetClass, me->display, XmNdeleteResponse, XmDESTROY, XmNmappedWhenManaged, False, XmNmwmDecorations, decor, XmNmwmFunctions, funcs, XmNmwmInputMode,MWM_INPUT_PRIMARY_APPLICATION_MODAL, XmNscreen, me->parent_attr.screen, XmNtransient, True, NULL); /* * pick up the secondary color set, so that the PDM presents the same * colors as a secondary window. (the XmColorObj is created by the * the XmDisplay object, which is created when the app shell is * created) */ if(XmeGetColorObjData(XtScreen(me->widget), (int*)NULL, pixelSets, XmCO_NUM_COLORS, (short*)NULL, (short*)NULL, (short*)NULL, &secondary_id, (short*)NULL)) { /* * In the Xrm database, reassign primary color resource values * with the corresponding secondary color values. This will cause * subsequently created widgets that utilize colors from the * primary set to actually present secondary colors. */ db = XtScreenDatabase(XtScreen(me->widget)); value.size = sizeof(Pixel); value.addr = (char*)&pixelSets[secondary_id].bg; XrmPutResource (&db, "*background", "Pixel", &value); XrmPutResource (&db, "*frameBackground", "Pixel", &value); value.addr = (char*)&pixelSets[secondary_id].fg; XrmPutResource (&db, "*foreground", "Pixel", &value); XrmPutResource (&db, "*backPageForeground", "Pixel", &value); value.addr = (char*)&pixelSets[secondary_id].bs; XrmPutResource (&db, "*bottomShadowColor", "Pixel", &value); value.addr = (char*)&pixelSets[secondary_id].ts; XrmPutResource (&db, "*topShadowColor", "Pixel", &value); } /* * get the application resources */ XtGetApplicationResources(me->widget, me, PdmResources, XtNumber(PdmResources), NULL, 0); /* * return */ return 0; }