UI2DView::UI2DView () : DBObject ("Noname 2DView",sizeof (UI2DView)) { char name [DBStringLength]; Widget menuBar, scrolledWindow, radioBox; Widget button; static Pixmap iconPixmap = (Pixmap) NULL, meshPixmap = (Pixmap) NULL; static Pixmap fullPixmap = (Pixmap) NULL, extentPixmap = (Pixmap) NULL; static Pixmap capturePixmap = (Pixmap) NULL, redrawPixmap = (Pixmap) NULL; static Pixmap zoomPixmap = (Pixmap) NULL, panePixmap = (Pixmap) NULL, userPixmap = (Pixmap) NULL; Pixel foreground, background; XWindowAttributes xwa; XSetWindowAttributes xswa; Atom deleteWindowAtom = XmInternAtom(XtDisplay(UITopLevel ()),(char *) "WM_DELETE_WINDOW",FALSE); _UI2DViewLIST.Add (this); sprintf (name,"2DView:%2d",RowID ()); Name (name); Image = (XImage *) NULL; DrawRegion = FullRegion = NULL; MaxVertexNumVAR = 0; PointARR = (XPoint *) NULL; RequiredEXT = (UIDataset ())->Extent (); DShell = XtVaCreatePopupShell ("UI2DView",xmDialogShellWidgetClass,UITopLevel (), XmNkeyboardFocusPolicy, XmPOINTER, XmNtitle, Name (), XmNtransient, false, XmNminWidth, 600, XmNminHeight, 450, NULL); XmAddWMProtocolCallback (DShell,deleteWindowAtom,(XtCallbackProc) _UI2DViewDeleteCBK,(XtPointer) this); MainFormW = XtVaCreateManagedWidget ("UI2DViewForm",xmFormWidgetClass,DShell, XmNdialogStyle, XmDIALOG_WORK_AREA, XmNshadowThickness, 0, XmNwidth, 600, XmNheight, 450, NULL); menuBar = XtVaCreateManagedWidget ("UI2DViewMenuBar",xmRowColumnWidgetClass,MainFormW, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 2, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 2, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 2, XmNorientation, XmHORIZONTAL, XmNrowColumnType, XmWORK_AREA, NULL); XtVaGetValues (MainFormW,XmNforeground, &foreground,XmNbackground, &background,NULL); iconPixmap = iconPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen (UITopLevel()),(char *) "GHAAS2Dview.bmp",foreground,background): iconPixmap; XtVaSetValues (DShell,XmNiconPixmap, iconPixmap,NULL); fullPixmap = fullPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASfull.bmp", foreground,background) : fullPixmap; extentPixmap = extentPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASextent.bmp",foreground,background) : extentPixmap; capturePixmap= capturePixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAAScapture.bmp",foreground,background):capturePixmap; redrawPixmap = redrawPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASredraw.bmp", foreground,background) : redrawPixmap; zoomPixmap = zoomPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASzoom.bmp", foreground,background) : zoomPixmap; panePixmap = panePixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASpane.bmp", foreground,background) : panePixmap; userPixmap = userPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASuser.bmp", foreground,background) : userPixmap; meshPixmap = meshPixmap == (Pixmap) NULL ? XmGetPixmap(XtScreen(UITopLevel()),(char *) "GHAASmesh.bmp", foreground,background) : meshPixmap; button = XtVaCreateManagedWidget ("UI2DViewRedrawButton",xmPushButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, redrawPixmap, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewRedrawCBK,this); button = XtVaCreateManagedWidget ("UI2DViewFullButton",xmPushButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, fullPixmap, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewFullActivateCBK,this); button = XtVaCreateManagedWidget ("UI2DViewExtentButton",xmPushButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, extentPixmap, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UI2DViewExtentActivateCBK,this); button = XtVaCreateManagedWidget ("UI2DViewCaptureButton",xmPushButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, capturePixmap, NULL); radioBox = XtVaCreateManagedWidget ("UI2DViewRadioBox",xmRowColumnWidgetClass,menuBar, XmNorientation, XmHORIZONTAL, XmNpacking, XmPACK_COLUMN, XmNisHomogeneous, true, XmNentryClass, xmToggleButtonGadgetClass, XmNradioBehavior, true, NULL); ZoomToggle = XtVaCreateManagedWidget ("UI2DViewZoomToggle",xmToggleButtonGadgetClass,radioBox, XmNlabelType, XmPIXMAP, XmNlabelPixmap, zoomPixmap, XmNshadowThickness, 0, XmNset, true, NULL); XtAddCallback (ZoomToggle,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewZoomToggleValueCBK,this); PaneToggle = XtVaCreateManagedWidget ("UI2DViewPaneToggle",xmToggleButtonGadgetClass,radioBox, XmNlabelType, XmPIXMAP, XmNlabelPixmap, panePixmap, XmNshadowThickness, 0, NULL); XtAddCallback (PaneToggle,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewPaneToggleValueCBK,this); UserToggle = XtVaCreateWidget ("UI2DViewUserToggle",xmToggleButtonGadgetClass,radioBox, XmNlabelType, XmPIXMAP, XmNlabelPixmap, userPixmap, XmNmappedWhenManaged, false, XmNshadowThickness, 0, NULL); XtAddCallback (UserToggle,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewUserToggleValueCBK,this); if (_UI2DViewUserFunction != (UI2DViewUserFunction) NULL) XtManageChild (UserToggle); MeshOptionW = XtVaCreateManagedWidget ("UI2DViewMeshOption",xmToggleButtonGadgetClass,menuBar, XmNlabelType, XmPIXMAP, XmNlabelPixmap, meshPixmap, XmNshadowThickness, 0, NULL); XtAddCallback (MeshOptionW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewMeshOptionCBK,this); XtVaSetValues (menuBar, XmNmenuHelpWidget, MeshOptionW, NULL); ScaleW = XtVaCreateManagedWidget ("UI2DViewScale",xmScaleWidgetClass,MainFormW, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, menuBar, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 2, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 18, XmNorientation, XmVERTICAL, XmNwidth, 16, NULL); XtAddCallback (ScaleW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewScaleValueChangedCBK,this); scrolledWindow = XtVaCreateManagedWidget ("UI2DViewScrolledWindow",xmScrolledWindowWidgetClass,MainFormW, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, menuBar, XmNtopOffset, 2, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, ScaleW, XmNleftOffset, 3, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 3, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 3, XmNspacing, 2, NULL); HorScrollBarW = XtVaCreateManagedWidget ("UI2DViewHorScrollBar", xmScrollBarWidgetClass, scrolledWindow, XmNsliderSize, 100, XmNorientation, XmHORIZONTAL, XmNheight, 16, NULL); XtAddCallback (HorScrollBarW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewHorScrollBarValueChangedCBK,this); VerScrollBarW = XtVaCreateManagedWidget ("UI2DViewVerScrollBar", xmScrollBarWidgetClass, scrolledWindow, XmNsliderSize, 100, XmNorientation, XmVERTICAL, XmNwidth, 16, NULL); XtAddCallback (VerScrollBarW,XmNvalueChangedCallback,(XtCallbackProc) _UI2DViewVerScrollBarValueChangedCBK,this); DrawingAreaW = XtVaCreateManagedWidget ("UI2DViewDrawingArea", xmDrawingAreaWidgetClass, scrolledWindow, XmNuserData, this, XmNbackground, UIColor (UIColorStandard,0), NULL); XtAddCallback (DrawingAreaW,XmNresizeCallback,(XtCallbackProc) _UI2DViewResizeCBK,this); XtAddEventHandler (DrawingAreaW,EnterWindowMask|LeaveWindowMask|PointerMotionMask|ButtonPressMask|ButtonReleaseMask, false,(XtEventHandler) _UI2DViewPointerEHR,this); XmScrolledWindowSetAreas(scrolledWindow,HorScrollBarW,VerScrollBarW,DrawingAreaW); _UI2DViewViewCursor = _UI2DViewViewCursor != (Cursor) NULL ? _UI2DViewViewCursor : XCreateFontCursor (XtDisplay (DrawingAreaW),XC_top_left_arrow), _UI2DViewUserCursor = _UI2DViewUserCursor != (Cursor) NULL ? _UI2DViewUserCursor : XCreateFontCursor (XtDisplay (DrawingAreaW),XC_crosshair); RegenCursor = XCreateFontCursor (XtDisplay (DrawingAreaW),XC_watch); ActiveCursor = xswa.cursor = _UI2DViewViewCursor; XChangeWindowAttributes (XtDisplay (DrawingAreaW), XtWindow (DrawingAreaW), CWCursor, &xswa); XGetWindowAttributes (XtDisplay (DrawingAreaW),XtWindow (DrawingAreaW),&xwa); Background = xwa.backing_pixel; xswa.backing_store = Always; XChangeWindowAttributes (XtDisplay (DrawingAreaW), XtWindow (DrawingAreaW),CWBackingStore,&xswa); InputMode (ZOOM_MODE); Size (); Set (); }
int main(int argc, char **argv) { Widget toplevel; Widget sw, da, rc; XtAppContext app; XtSetLanguageProc(NULL, NULL, NULL); toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, NULL, NULL); rc = XtVaCreateManagedWidget("rc",xmRowColumnWidgetClass, toplevel, NULL); /* create a 'VARIABLE' scrolledwin */ sw = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, rc, XmNscrollingPolicy, XmAPPLICATION_DEFINED, XmNvisualPolicy, XmVARIABLE, XmNwidth,200, XmNheight,100, NULL); /* the child is smaller, but at creation time their * `variable' scrolledw doesn't shrink. */ da = XtVaCreateManagedWidget("da", xmDrawingAreaWidgetClass, sw, XmNwidth,100, XmNheight,100, NULL); XmScrolledWindowSetAreas(sw, NULL, NULL, da); /* create another 'VARIABLE' scrolledwin */ sw = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, rc, XmNscrollingPolicy, XmAPPLICATION_DEFINED, XmNvisualPolicy, XmVARIABLE, XmNwidth,200, XmNheight,100, NULL); /* this time, the child is bigger, but at creation time their * `variable' scrolledw doesn't grow. */ da = XtVaCreateManagedWidget("da", xmDrawingAreaWidgetClass, sw, XmNwidth,300, XmNheight,300, NULL); XmScrolledWindowSetAreas(sw, NULL, NULL, da); XtRealizeWidget(toplevel); { static XtWidgetGeometry Expected[] = { CWWidth | CWHeight , 4, 50, 206, 209, 0,0,0, /* rc */ CWWidth | CWHeight | CWX | CWY, 3, 3, 200, 100, 0,0,0, /* sw */ CWWidth | CWHeight | CWX | CWY, 0, 0, 200, 100, 0,0,0, /* da */ CWWidth | CWHeight | CWX | CWY, 3, 106, 200, 100, 0,0,0, /* sw */ CWWidth | CWHeight | CWX | CWY, 0, 0, 200, 100, 0,0,0, /* da */ }; PrintDetails(toplevel,Expected); }; LessTifTestMainLoop(toplevel); exit(0); }
int main(int argc, char **argv) { Widget toplevel; Widget sw, hsb, vsb, da; XtAppContext app; XtSetLanguageProc(NULL, NULL, NULL); toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, NULL, NULL); sw = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, toplevel, XmNscrollingPolicy, XmAPPLICATION_DEFINED, XmNscrollBarPlacement, XmBOTTOM_RIGHT, NULL); dump_sw("after create\n", sw); hsb = XtVaCreateManagedWidget("hsb", xmScrollBarWidgetClass, sw, XmNorientation, XmHORIZONTAL, NULL); dump_sw("after create HSB\n", sw); vsb = XtVaCreateManagedWidget("vsb", xmScrollBarWidgetClass, sw, XmNorientation, XmVERTICAL, NULL); dump_sw("after create VSB\n", sw); da = XtVaCreateManagedWidget("da", xmDrawingAreaWidgetClass, sw, NULL); dump_sw("after create DA\n", sw); XmScrolledWindowSetAreas(sw, hsb, vsb, da); dump_sw("after SetAreas\n", sw); XtRealizeWidget(toplevel); dump_sw("after realize\n", sw); { static XtWidgetGeometry Expected[] = { CWWidth | CWHeight , 508, 524, 19, 19, 0,0,0, /* sw */ CWWidth | CWHeight | CWX | CWY, 0, 4, 1, 15, 0,0,0, /* hsb */ CWWidth | CWHeight | CWX | CWY, 4, 0, 15, 1, 0,0,0, /* vsb */ CWWidth | CWHeight | CWX | CWY, 0, 0, 1, 1, 0,0,0, /* da */ }; PrintDetails(toplevel,Expected); }; LessTifTestMainLoop(toplevel); exit(0); }
static PlotWindowInfo *new_decoration(const string& name) { PlotWindowInfo *plot = 0; // Check whether we can reuse an existing decoration for (int i = 0; i < plot_infos.size(); i++) { PlotWindowInfo *info = (PlotWindowInfo *)plot_infos[i]; if (info->plotter == 0) { // Shell is unused - use this one plot = info; break; } } if (plot == 0) { plot = new PlotWindowInfo; // Create decoration windows Arg args[10]; Cardinal arg = 0; XtSetArg(args[arg], XmNallowShellResize, True); arg++; XtSetArg(args[arg], XmNdeleteResponse, XmDO_NOTHING); arg++; // Mark shell as `used' XtSetArg(args[arg], XmNuserData, XtPointer(True)); arg++; plot->shell = verify(XtCreateWidget("plot", topLevelShellWidgetClass, find_shell(), args, arg)); AddDeleteWindowCallback(plot->shell, CancelPlotCB, XtPointer(plot)); arg = 0; Widget main_window = XmCreateMainWindow(plot->shell, XMST("main_window"), args, arg); XtManageChild(main_window); MMcreateMenuBar(main_window, "menubar", menubar); MMaddCallbacks(file_menu, XtPointer(plot)); MMaddCallbacks(simple_edit_menu); MMaddCallbacks(view_menu, XtPointer(plot)); MMaddCallbacks(plot_menu, XtPointer(plot)); MMaddCallbacks(scale_menu, XtPointer(plot)); MMaddCallbacks(contour_menu, XtPointer(plot)); MMaddCallbacks(simple_help_menu); MMaddHelpCallback(menubar, ImmediateHelpCB); arg = 0; XtSetArg(args[arg], XmNscrollingPolicy, XmAPPLICATION_DEFINED); arg++; XtSetArg(args[arg], XmNvisualPolicy, XmVARIABLE); arg++; Widget scroll = XmCreateScrolledWindow(main_window, XMST("scroll"), args, arg); XtManageChild(scroll); // Create work window Widget work; string plot_term_type = downcase(app_data.plot_term_type); if (plot_term_type.contains("xlib", 0)) { // xlib type - create plot area to draw plot commands arg = 0; work = XmCreateDrawingArea(scroll, XMST(PLOT_AREA_NAME), args, arg); XtManageChild(work); plot->area = new PlotArea(work, make_font(app_data, FixedWidthDDDFont)); XtVaSetValues(work, XmNuserData, XtPointer(plot->area), XtPointer(0)); } else if (plot_term_type.contains("x11", 0)) { // x11 type - swallow Gnuplot window arg = 0; work = plot->swallower = XtCreateManagedWidget(SWALLOWER_NAME, swallowerWidgetClass, scroll, args, arg); } else { // Unknown terminal type post_error("Unknown plot terminal type " + quote(app_data.plot_term_type), "unknown_plot_term_type_error"); return 0; } // Create scroll bars const int slider_size = 20; arg = 0; XtSetArg(args[arg], XmNorientation, XmHORIZONTAL); arg++; XtSetArg(args[arg], XmNminimum, 0); arg++; XtSetArg(args[arg], XmNmaximum, 360 + slider_size); arg++; plot->hsb = XmCreateScrollBar(scroll, XMST("hsb"), args, arg); XtManageChild(plot->hsb); arg = 0; XtSetArg(args[arg], XmNorientation, XmVERTICAL); arg++; XtSetArg(args[arg], XmNminimum, 0); arg++; XtSetArg(args[arg], XmNmaximum, 180 + slider_size); arg++; plot->vsb = XmCreateScrollBar(scroll, XMST("vsb"), args, arg); XtManageChild(plot->vsb); XtAddCallback(plot->hsb, XmNvalueChangedCallback, SetViewCB, XtPointer(plot)); XtAddCallback(plot->vsb, XmNvalueChangedCallback, SetViewCB, XtPointer(plot)); #if 0 XtAddCallback(plot->hsb, XmNdragCallback, SetViewCB, XtPointer(plot)); XtAddCallback(plot->vsb, XmNdragCallback, SetViewCB, XtPointer(plot)); #endif XmScrolledWindowSetAreas(scroll, plot->hsb, plot->vsb, work); Delay::register_shell(plot->shell); InstallButtonTips(plot->shell); plot_infos += plot; } string title = DDD_NAME ": " + name; XtVaSetValues(plot->shell, XmNtitle, title.chars(), XmNiconName, title.chars(), XtPointer(0)); if (plot->swallower != 0) { XtRemoveAllCallbacks(plot->swallower, XtNwindowCreatedCallback); XtAddCallback(plot->swallower, XtNwindowCreatedCallback, SwallowCB, XtPointer(plot)); XtRemoveAllCallbacks(plot->swallower, XtNwindowGoneCallback); XtAddCallback(plot->swallower, XtNwindowGoneCallback, SwallowAgainCB, XtPointer(plot)); if (plot->swallow_timer != 0) XtRemoveTimeOut(plot->swallow_timer); plot->swallow_timer = XtAppAddTimeOut(XtWidgetToApplicationContext(plot->swallower), app_data.plot_window_delay, SwallowTimeOutCB, XtPointer(plot)); } plot->active = false; return plot; }
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(); }