/** * Initialize the window system */ void CGWindow::Initialize(int argc, char *argv[]) { Arg al[10]; int ac; /* create the toplevel shell */ ac=0; XtSetArg(al[ac],XtNtitle,"CGWindow Phase1"); ac++; m_Toplevel = XtAppInitialize(&m_Context,"",NULL,0,&argc,argv, NULL,al,ac); /* set window size. */ ac=0; XtSetArg(al[ac],XmNheight,300); ac++; XtSetArg(al[ac],XmNwidth,300); ac++; XtSetValues(m_Toplevel,al,ac); /* create a drawing area widget. */ ac=0; m_DrawingArea=XmCreateDrawingArea(m_Toplevel,"drawing_area",al,ac); XtManageChild(m_DrawingArea); setupGC(); XtAddCallback(m_DrawingArea,XmNexposeCallback,ExposeCB,(XtPointer)this); }
void imagesc(void *data, int x, int y, const char* type, double (*transf)(double), const char **colormap, char *title) { static XtAppContext context; Widget drawing_area; Widget toplevel; Atom wm_delete; XEvent event; XpmImage *xpmImage; Boolean exitFlag = False; static Display *display = NULL; Arg al[10]; int ac; int argc = 0; xpmImage = CreateXpmImage(data, x, y, type, transf, colormap); /* create the toplevel shell */ XtToolkitInitialize(); if (display == NULL) { context = XtCreateApplicationContext(); display = XtOpenDisplay(context, NULL, NULL, "", NULL, 0, &argc, NULL); } toplevel =XtAppCreateShell(title, "", applicationShellWidgetClass, display, NULL, 0); /* set window size. */ ac=0; XtSetArg(al[ac],XmNmaxWidth, x); ac++; XtSetArg(al[ac],XmNmaxHeight, y); ac++; XtSetArg(al[ac],XmNminWidth, x); ac++; XtSetArg(al[ac],XmNminHeight, y); ac++; XtSetArg(al[ac],XmNdeleteResponse, XmDO_NOTHING); ac++; XtSetValues(toplevel,al,ac); ac=0; drawing_area=XmCreateDrawingArea(toplevel,"drawing_area",al,ac); XtManageChild(drawing_area); XtAddCallback(drawing_area,XmNexposeCallback,draw_pixmap,(XtPointer) xpmImage); XtAddEventHandler(drawing_area, KeyReleaseMask, false, KeyAction, (XtPointer) &exitFlag); XtRealizeWidget(toplevel); wm_delete = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False); XmAddWMProtocolCallback(toplevel, wm_delete, quitCB, (XtPointer) &exitFlag); XmActivateWMProtocol(toplevel, wm_delete); while (!exitFlag) { XtAppNextEvent(context, &event); XtDispatchEvent(&event); } XtDestroyWidget(drawing_area); XtDestroyWidget(toplevel); free(xpmImage); }
void main(int argc, char **argv) { int i=21,forcer=0; /* init variables. */ Display *p_disp; FILE *fpo; char text[]="MultiSliceRTPsession0"; /* Create the top-level shell widget and initialize the toolkit */ argcount = 0; XtSetArg(args[argcount], XmNallowShellResize, False); argcount++; XtSetArg(args[argcount], XmNtitle, APP_TITLE); argcount++; XtSetArg(args[argcount], XmNiconName, ICON_TITLE); argcount++; top_level = XtAppInitialize(&app, "Slice", NULL, 0, &argc, argv, NULL, args, argcount); theAppName = argv[0]; #include "command_slice.c" /* Create the main window widget */ argcount = 0; /* XtSetArg(args[argcount], XmNwidth , WIDTH); argcount++; XtSetArg(args[argcount], XmNheight, HEIGHT); argcount++; */ main_window = XmCreateRowColumn(top_level, "Main", args, argcount); XtManageChild(main_window); p_disp=XtDisplay(main_window); if(forcer != 1) { /* if(XFetchBytes(p_disp,&i) != NULL){ if(i==21){ fprintf(stderr,"\nOnly one copy of MultiSlice can run at one time...\nslice -forceload will forcibly load a second copy.\nSelf-Destruct Initialised...\nSecond copy destructed...OK\n"); XtCloseDisplay(XtDisplay(main_window));exit(-1);}} i=21; XStoreBytes(p_disp,text,i); */ if((fopen("slicetempyhsTN","r")) != 0){ fprintf(stderr,"\nOnly one copy of MultiSlice RTP can run at one time...\nslice -forceload will forcibly load a second copy if \n the first one was terminated incorrectly.\n"); system("cat slicetempyhsTN"); fprintf(stderr,"\nSelf-destruct initialised...\nSecond copy destructed...OK\n"); XtCloseDisplay(XtDisplay(main_window));exit(-1);}} i=0; strcpy(tempfileold,"slicetempyhsT"); strcpy(tempfilenew,"slicetempyhsT"); addcharac[1]='\0'; strcat(tempfilenew,addcharac); system("echo First copy of MultiSliceRTP started at :- >slicetempyhsTN"); system("date >>slicetempyhsTN"); for(i=0;i<11;i++){yhs_filename[i]=0;squash[i]=0;squash[i+10]=0;} i=0; fprintf(stderr,"\n\n-------------------MultiSlice RTP Status Messages-------------------\n"); fprintf(stderr,"Launching application..."); system("date"); fprintf(stderr,"Load and select file(s) to process...\n"); /* Create the main menu */ create_main_menu(main_window); /* Create the drawing area 1 */ argcount = 0; XtSetArg(args[argcount], XmNwidth , IMAGE_WIDTH); argcount++; XtSetArg(args[argcount], XmNheight, IMAGE_HEIGHT); argcount++; draw_1 = XmCreateDrawingArea(top_level, "draw_1", args, argcount); /* XtManageChild(draw_1); */ /* Create the drawing area 2 */ argcount = 0; XtSetArg(args[argcount], XmNwidth , IMAGE_WIDTH); argcount++; XtSetArg(args[argcount], XmNheight, IMAGE_HEIGHT); argcount++; draw_2 = XmCreateDrawingArea(top_level, "draw_2", args, argcount); /* XtManageChild(draw_2); */ /* Create a watch cursor */ theCursor = XCreateFontCursor(XtDisplay(main_window), XC_watch); /* Create the icon window for the application */ app_icon = XCreateBitmapFromData(XtDisplay(top_level), DefaultRootWindow(XtDisplay(top_level)), icon_bits, icon_width, icon_height); argcount = 0; XtSetArg(args[argcount], XmNiconPixmap, app_icon); argcount++; XtSetValues(top_level, args, argcount); XtAppAddTimeOut(app,2*1000,update_time,NULL); /* Realize all widgets */ XtRealizeWidget(top_level); /* Make some initializations */ setup_display (top_level); create_region_list(®ion_list); /* Event handling loop--keep processing events until done */ XtAppMainLoop(app); }
/************************************** build_box_widget *************************************** Purpose: To build the widgets for the detail view. The box is sized here; the text is actually initially drawn during the expose callback ***************************************/ void build_box_widget (int ndx) { int y; /* y coordinate of widget */ int direction; /* string direction */ int ascent; /* max ascent for font */ int descent; /* max descent for font */ XCharStruct overall; /* string characteristics */ char locbuf[100]; /* local buffer */ #ifdef FT char acc_plus[69]; /* account and compt attente */ #endif /* get dimensions of account id and set box width accordingly */ #ifdef FT memset(acc_plus,'\0',sizeof(acc_plus)); sprintf(acc_plus,"%s - Compte Attente: %s", accts[ndx].external_id, accts[ndx].compte_attente); XTextExtents (font_info, acc_plus, strlen (acc_plus), &direction, &ascent, &descent, &overall); #else XTextExtents (font_info, accts[ndx].external_id, strlen (accts[ndx].external_id), &direction, &ascent, &descent, &overall); #endif accts[ndx].width = overall.width + 25; /* build second line, name of either the company or the individual. */ /* Next, get dimensions of the name and reset box width if required */ y = ascent + descent + TEXT_SEPARATION; if (accts[ndx].category == 0) /* business */ #ifdef FT { if (strlen(accts[ndx].cust_company) == 0) strcpy(accts[ndx].cust_company, "None"); /* sprintf (accts[ndx].text2, "Bill %s Cust %s", accts[ndx].company, accts[ndx].cust_company); */ } #else /* sprintf (accts[ndx].text2, "%s", accts[ndx].company); */ #endif /* else */ /* must be individual */ /* sprintf (accts[ndx].text2, "%s, %s", accts[ndx].last_name, accts[ndx].first_name); XTextExtents (font_info, accts[ndx].text2, strlen (accts[ndx].text2), &direction, &ascent, &descent, &overall); */ if (overall.width + 25 > accts[ndx].width) accts[ndx].width = overall.width + 25; /* next, work on the line with the status information */ y += ascent + descent + TEXT_SEPARATION; /* assume that ACT is the longest length string */ strcpy (locbuf, "ACT B 9 9 99+ 999+ "); XTextExtents (font_info, locbuf, strlen (locbuf), &direction, &ascent, &descent, &overall); if (overall.width + 25 > accts[ndx].width) accts[ndx].width = overall.width + 25; /* if the widget has not yet been created, then build it now */ if (accts[ndx].widget == (Widget) NULL) { n = 0; XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT), n++; XtSetArg (args[n], XmNshadowThickness, 2), n++; accts[ndx].widget = XmCreateFrame (drawing_area, accts[ndx].external_id, args, n); n = 0; accts[ndx].bb = XmCreateDrawingArea (accts[ndx].widget, accts[ndx].external_id, args, n); XtAddCallback (accts[ndx].bb, XmNexposeCallback, (XtCallbackProc) widget_cb, (XtPointer) ndx); XtAddCallback (accts[ndx].bb, XmNresizeCallback, (XtCallbackProc) widget_cb, (XtPointer) ndx); XtAddCallback (accts[ndx].bb, XmNinputCallback, (XtCallbackProc) widget_cb, (XtPointer) ndx); XtManageChild (accts[ndx].bb); } /* set the height and save for later positioning */ accts[ndx].height = y + 2 * font_height; XtVaSetValues (accts[ndx].widget, XmNwidth, accts[ndx].width, XmNheight, accts[ndx].height, NULL); }
/************************************************************** * DaCreateGui: **************************************************************/ Widget DaCreateGui(char * name, char * aclass, int argc, char ** argv, Display * display) { Arg args[15]; Widget widget_array[10]; int n; /***************** object of type : ApplicationShell *****************/ n = 0; /* Setup argc & argv attribute */ XtSetArg(args[n], XtNargc, argc); n++; XtSetArg(args[n], XtNargv, argv); n++; widget_array[WI_DAINPUT] = XtAppCreateShell(name, aclass, applicationShellWidgetClass, display, args, n); /***************** mainWindow : XmMainWindow *****************/ widget_array[WI_MAINWINDOW] = XmCreateMainWindow(widget_array[WI_DAINPUT], "mainWindow", NULL, 0); /***************** menuBar : XmMenuBar *****************/ widget_array[WI_MENUBAR] = XmCreateMenuBar(widget_array[WI_MAINWINDOW], "menuBar", NULL, 0); /***************** File : XmCascadeButton *****************/ widget_array[WI_FILE] = XmCreateCascadeButton(widget_array[WI_MENUBAR], "File", NULL, 0); /***************** fileMenu : XmPulldownMenu *****************/ widget_array[WI_FILEMENU] = XmCreatePulldownMenu(widget_array[WI_MENUBAR], "fileMenu", NULL, 0); { Arg args[1]; XtSetArg(args[0], XmNsubMenuId, widget_array[WI_FILEMENU]); XtSetValues(widget_array[WI_FILE], args, 1); } /***************** Exit : XmPushButton *****************/ widget_array[WI_EXIT] = XmCreatePushButton(widget_array[WI_FILEMENU], "Exit", NULL, 0); XtAddCallback(widget_array[WI_EXIT], XmNactivateCallback, DaExit, NULL); /***************** Help : XmCascadeButton *****************/ widget_array[WI_HELP] = XmCreateCascadeButton(widget_array[WI_MENUBAR], "Help", NULL, 0); /***************** helpMenu : XmPulldownMenu *****************/ widget_array[WI_HELPMENU] = XmCreatePulldownMenu(widget_array[WI_MENUBAR], "helpMenu", NULL, 0); { Arg args[1]; XtSetArg(args[0], XmNsubMenuId, widget_array[WI_HELPMENU]); XtSetValues(widget_array[WI_HELP], args, 1); } /***************** Overview : XmPushButton *****************/ widget_array[WI_OVERVIEW] = XmCreatePushButton(widget_array[WI_HELPMENU], "Overview", NULL, 0); XtAddCallback(widget_array[WI_OVERVIEW], XmNactivateCallback, DaOverView, NULL); /***************** workArea : XmDrawingArea *****************/ n = 0; XtSetArg(args[n], XmNwidth, 300); n++; XtSetArg(args[n], XmNheight, 35); n++; widget_array[WI_WORKAREA] = XmCreateDrawingArea(widget_array[WI_MAINWINDOW], "workArea", args, n); /* * Register drawing area for input method support and set input * context values. */ XmImRegister(widget_array[WI_WORKAREA], 0); { Pixel bg, fg; Pixmap bg_pixmap; n = 0; XtSetArg(args[n], XmNbackground, &bg); n++; XtSetArg(args[n], XmNforeground, &fg); n++; XtSetArg(args[n], XmNbackgroundPixmap, &bg_pixmap);n++; XtGetValues(widget_array[WI_WORKAREA], args, n); n = 0; XtSetArg(args[n], XmNbackground, bg); n++; XtSetArg(args[n], XmNforeground, fg); n++; XtSetArg(args[n], XmNbackgroundPixmap, bg_pixmap);n++; XmImSetValues(widget_array[WI_WORKAREA], args, n); } /* * Add event handler for focus events. This is needed for the * input method to correctly display the input area. */ XtAddEventHandler(widget_array[WI_WORKAREA], EnterWindowMask|LeaveWindowMask|FocusChangeMask, False, DaFocusHandler, NULL); XtAddCallback(widget_array[WI_WORKAREA], XmNexposeCallback, DaRedrawText, NULL); XtAddCallback(widget_array[WI_WORKAREA], XmNinputCallback, DaInputText, NULL); XtAddCallback(widget_array[WI_WORKAREA], XmNresizeCallback, DaResizedText, NULL); /***************** menuBar : XmMenuBar *****************/ n = 0; XtSetArg(args[n], XmNmenuHelpWidget, widget_array[WI_HELP]); n++; XtSetValues(widget_array[WI_MENUBAR], args, n); XtManageChild(widget_array[WI_EXIT]); XtManageChild(widget_array[WI_FILE]); XtManageChild(widget_array[WI_OVERVIEW]); XtManageChild(widget_array[WI_HELP]); XtManageChild(widget_array[WI_MENUBAR]); XtManageChild(widget_array[WI_WORKAREA]); XtManageChild(widget_array[WI_MAINWINDOW]); /* * Return the first created widget. */ return widget_array[WI_DAINPUT]; }
int main(int argc, char *argv[]) { #define MAIN_CHILDREN 3 #define FORM_CHILDREN 3 #define PLANE_CHILDREN 6 #define TRAFFIC_CHILDREN 3 #define SetMenuEntry(k,l,p,d) labels[k]=l;procs[k]=p;private[k]=d; Pixmap flying; Pixmap parked; Pixmap mask; Widget theWidgetRoot; Widget main_tab[MAIN_CHILDREN]; Widget from_tab[PLANE_CHILDREN]; Widget to_tab[TRAFFIC_CHILDREN]; Widget form_tab[FORM_CHILDREN]; Widget framed[2]; Widget entry; static char myClass[] = "XmdAirport"; Arg args[10]; int n ; String labels[4]; XtCallbackProc procs[4]; XtPointer private[4]; XGCValues gcv; Airport this; /* * Initialize */ this = (Airport) XtCalloc(sizeof(AirportRec), 1); XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL); theWidgetRoot = XtVaOpenApplication( &this->context, myClass, NULL, 0, &argc, argv, NULL, sessionShellWidgetClass, XmNallowShellResize, True, NULL); this->display = XtDisplay(theWidgetRoot); FlightAtom = XmInternAtom(this->display, "FLIGHT", False); DeleteAtom = XmInternAtom(this->display, "DELETE", False); XtGetApplicationResources(theWidgetRoot, &AirportResources, AirportResourcesSpecs, XtNumber(AirportResourcesSpecs), (ArgList) NULL, 0); /* * Create the Main Window, the menubar and the pulldown menus */ n = 0; this->main = XmCreateMainWindow(theWidgetRoot, "main", args, n); n = 0; main_tab[0] = XmCreateMenuBar(this->main, "menubar", args, n); n = 0; SetMenuEntry(n, "Exit", (XtCallbackProc) ExitCallback, (XtPointer) this ); n++; entry = MenuBarEntry(main_tab[0], "File", labels, procs, private, n); n = 0; SetMenuEntry(0, "Tutorial", (XtCallbackProc) HelpCallback, (XtPointer) this); n++; entry = MenuBarEntry(main_tab[0], "Help", labels, procs, private, n); n = 0; XtSetArg(args[n], XmNmenuHelpWidget, entry); n++; XtSetValues(main_tab[0], args, n); /* * Create the Airport widget structure. * Two framed radio boxes show state. * A drawing area in the middle show track and planes */ n = 0; this->screen_width = WidthOfScreen(XtScreenOfObject(this->main)); this->screen_height = HeightOfScreen(XtScreenOfObject(this->main)); XtSetArg(args[n], XmNwidth, this->screen_width*3/7); n++; XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++; main_tab[1] = XmCreateForm(this->main, "airport", args, n); n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNbottomAttachment,XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM) ; n++; form_tab[0] = XmCreateFrame(main_tab[1], "flight", args, n); n = 0; XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++; framed[0] = XmCreateLabel(form_tab[0], "title", args, n); n = 0; XtSetArg(args[n], XmNchildType, XmFRAME_WORKAREA_CHILD); n++; XtSetArg(args[n], XmNresizePolicy, XmRESIZE_GROW); n++; XtSetArg(args[n], XmNradioBehavior, True); n++; framed[1] = XmCreateRadioBox(form_tab[0], "panel", args, n); n = 0; XtSetArg(args[n], XmNset, True); n++; XtSetArg(args[n], XmNvisibleWhenOff, False); n++; this->from.departure = from_tab[0] = XmCreateToggleButton(framed[1], "departure", args, n); n = 0; XtSetArg(args[n], XmNvisibleWhenOff, False); n++; this->from.over_ocean = from_tab[1] = XmCreateToggleButton(framed[1], "over_ocean", args, n); n = 0; XtSetArg(args[n], XmNvisibleWhenOff, False); n++; this->from.over_land = from_tab[2] = XmCreateToggleButton(framed[1], "over_land", args, n); n = 0; XtSetArg(args[n], XmNvisibleWhenOff, False); n++; this->from.over_site = from_tab[3] = XmCreateToggleButton(framed[1], "radar", args, n); n = 0; XtSetArg(args[n], XmNvisibleWhenOff, False); n++; this->from.landing = from_tab[4] = XmCreateToggleButton(framed[1], "landing", args, n); n = 0; XtSetArg(args[n], XmNvisibleWhenOff, False); n++; this->from.landed = from_tab[5] = XmCreateToggleButton(framed[1], "landed", args, n); XtManageChildren(from_tab, PLANE_CHILDREN); XtManageChildren(framed, 2); /* * Create the Airport Traffic control state */ n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNbottomAttachment,XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM) ; n++; form_tab[1] = XmCreateFrame(main_tab[1], "traffic", args, n); n = 0; XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++; framed[0] = XmCreateLabel(form_tab[1], "title", args, n); n = 0; XtSetArg(args[n], XmNchildType, XmFRAME_WORKAREA_CHILD); n++; XtSetArg(args[n], XmNradioBehavior, True); n++; framed[1] = XmCreateRadioBox(form_tab[1], "traffic_box", args, n); n = 0; XtSetArg(args[n], XmNset, True); n++; XtSetArg(args[n], XmNvisibleWhenOff, False); n++; this->to.leave = to_tab[1] = XmCreateToggleButton(framed[1], "no_traffic", args, n); n = 0; XtSetArg(args[n], XmNvisibleWhenOff, False); n++; this->to.enter = to_tab[0] = XmCreateToggleButton(framed[1], "radar_echo", args, n); n = 0; XtSetArg(args[n], XmNvisibleWhenOff, False); n++; this->to.landing = to_tab[2] = XmCreateToggleButton(framed[1], "landing", args, n); XtManageChildren(to_tab, TRAFFIC_CHILDREN); XtManageChildren(framed, 2); /* * Create the Airport picture */ n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNbottomAttachment,XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET) ; n++; XtSetArg(args[n], XmNleftWidget, form_tab[0]) ; n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET) ; n++; XtSetArg(args[n], XmNrightWidget, form_tab[1]) ; n++; this->airport = form_tab[2] = XmCreateDrawingArea(main_tab[1], "da", args, n); XtAddCallback(this->airport, XmNexposeCallback, (XtCallbackProc) ShowAirport, (XtPointer) this); XtAddCallback(this->airport, XmNresizeCallback, (XtCallbackProc) ResizeAirport, (XtPointer) this); XtAddCallback(this->airport, XmNinputCallback, (XtCallbackProc) AirportInput, (XtPointer) this); /* * Create the Airport Message area */ n = 0; main_tab[2] = XmCreateFrame(this->main, "message", args, n); n = 0; XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++; framed[0] = XmCreateLabel(main_tab[2], "title", args, n); n = 0; XtSetArg(args[n], XmNchildType, XmFRAME_WORKAREA_CHILD); n++; XtSetArg(args[n], XmNvisibleItemCount, 4); n++; this->msg_area = XmCreateScrolledList(main_tab[2], "msg_list", args, n); XtManageChild(this->msg_area); framed[1] = XtParent(this->msg_area); XtManageChildren(framed, 2); n = 0; XtSetArg(args[n], XmNmenuBar, main_tab[0]); n++; XtSetArg(args[n], XmNworkWindow, main_tab[1]); n++; XtSetArg(args[n], XmNmessageWindow, main_tab[2]); n++; XtSetValues(this->main, args, n); XtManageChildren(form_tab, FORM_CHILDREN); XtManageChildren(main_tab, MAIN_CHILDREN); XtManageChild(this->main); XtRealizeWidget(theWidgetRoot); /* * Create the drag icon */ parked = XCreateBitmapFromData(this->display, XtWindow(this->main), (char*)plane_bits, plane_width, plane_height); flying = XCreateBitmapFromData(this->display, XtWindow(this->main), (char*)flying_bits, flying_icon_width, flying_icon_height); mask = XCreateBitmapFromData(this->display, XtWindow(this->main), (char*)flying_mask_bits, flying_mask_width, flying_mask_height); n = 0; XtSetArg(args[n], XmNpixmap, flying); n++; XtSetArg(args[n], XmNdepth, 1); n++; XtSetArg(args[n], XmNmask, mask); n++; XtSetArg(args[n], XmNwidth, flying_icon_width); n++; XtSetArg(args[n], XmNheight, flying_icon_height) ; n++; this->dragIcon = XmCreateDragIcon(form_tab[2], "drag", args, n); if (this->dragIcon == NULL) { printf("cannot create drag icon\n"); exit(0); } /* Create GC for drawing planes */ gcv.function = GXcopy; gcv.fill_style = FillOpaqueStippled; gcv.stipple = parked; gcv.foreground = AirportResources.spot_foreground; gcv.background = AirportResources.spot_background; this->park.gc = XCreateGC(this->display, XtWindow(this->main), GCFunction|GCStipple|GCFillStyle |GCForeground|GCBackground, &gcv); gcv.line_style = LineDoubleDash; gcv.line_width = AirportResources.track_border_width; gcv.fill_style = FillSolid; gcv.foreground = AirportResources.track_foreground; gcv.background = AirportResources.track_background; this->track.gc = XCreateGC(this->display, XtWindow(this->main), GCFunction|GCLineWidth|GCLineStyle |GCFillStyle|GCForeground|GCBackground, &gcv); XtAppMainLoop(this->context); return 0; /* make compiler happy */ }
static Widget createContents(Widget parent, SpaceWindow *window, int hasEventBar, char *eventBarText) { Arg args[50]; int ac; XmString s1, s2; char ctmp[10]; Widget form, displayMode, stability, particleType, rotation, stats; Widget formt1, allSliders; Widget controls, trackInfoFrame, trackInfo; Widget scaleFrame, scaleRC, scaleLabel, scaleArea; Widget stabilityLabel, particleTypeLabel; Widget eventCtrlFrame, eventCtrlForm, eventNumLabel, upArrow; Widget eventNumText, downArrow, eventCtrlText; Widget widget, spin; Pixel foreground, background; Pixmap pm; /* Create the form onto which everything goes */ ac = 0; XtSetArg(args[ac], XmNmarginHeight, 0); ac++; form = XmCreateForm(parent, "form", args, ac); XtManageChild(form); if (hasEventBar) { ac = 0; XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++; eventCtrlFrame = XmCreateFrame(form, "eventCtrlFrame", args, ac); XtManageChild(eventCtrlFrame); ac = 0; eventCtrlForm = XmCreateForm(eventCtrlFrame, "eventCtrlForm", args, ac); XtManageChild(eventCtrlForm); ac = 0; XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING("Event #"))); ac++; eventNumLabel = (Widget) XmCreateLabelGadget( eventCtrlForm, "eventNumLabel", args, ac); XmStringFree(s1); XtManageChild(eventNumLabel); ac = 0; XtSetArg(args[ac], XmNarrowDirection, XmARROW_UP); ac++; XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNleftWidget, eventNumLabel); ac++; upArrow = XmCreateArrowButton(eventCtrlForm, "upArrow", args, ac); XtAddCallback(upArrow, XmNactivateCallback, (XtCallbackProc) nextEvtCB, window); XtManageChild(upArrow); ac = 0; sprintf(ctmp," %d ", ac); XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(ctmp))); ac++; XtSetArg(args[ac], XmNcolumns, 7); ac++; XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNleftWidget, upArrow); ac++; eventNumText = (Widget) XmCreateLabelGadget( eventCtrlForm, "eventNumText", args, ac); /* eventNumText = XmCreateText(eventCtrlForm, "eventNumText", args, ac); */ XtManageChild(eventNumText); ac = 0; XtSetArg(args[ac], XmNarrowDirection, XmARROW_DOWN); ac++; XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNleftWidget, eventNumText); ac++; downArrow = XmCreateArrowButton(eventCtrlForm, "downArrow", args, ac); XtAddCallback(downArrow, XmNactivateCallback, (XtCallbackProc) previousEvtCB, window); XtManageChild(downArrow); ac = 0; XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(eventBarText))); ac++; XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; eventCtrlText = (Widget) XmCreateLabelGadget( eventCtrlForm, "eventCtrlText", args, ac); XmStringFree(s1); XtManageChild(eventCtrlText); } /* Create a Form for the controls along the left edge of window */ ac = 0; if (hasEventBar) { XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNtopWidget, eventCtrlFrame); ac++; } else { XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++; } controls = XmCreateForm(form, "controls", args, ac); XtManageChild(controls); ac = 0; XtSetArg(args[ac], XmNborderWidth, (Dimension)0); ac++; XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++; XtSetArg(args[ac], XmNspacing, 0); ac++; XtSetArg(args[ac], XmNnumColumns, (short)2); ac++; stability = XmCreateRowColumn(controls, "stability", args, ac); XtManageChild(stability); ac = 0; XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING("Particle Types"))); ac++; XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNtopWidget, stability); ac++; particleTypeLabel = (Widget) XmCreateLabelGadget( controls, "particleTypeLabel", args, ac); XmStringFree(s1); XtManageChild(particleTypeLabel); ac = 0; XtSetArg(args[ac], XmNborderWidth, (Dimension)0); ac++; XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++; XtSetArg(args[ac], XmNspacing, 0); ac++; XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNnumColumns, (short)2); ac++; XtSetArg(args[ac], XmNtopWidget, particleTypeLabel); ac++; particleType = XmCreateRowColumn(controls, "particleType", args, ac); XtManageChild(particleType); ac = 0; XtSetArg(args[ac], XmNhighlightThickness, 0); ac++; XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++; XtSetArg(args[ac], XmNspacing, 0); ac++; XtSetArg(args[ac], XmNorientation, XmHORIZONTAL); ac++; if (hasEventBar) { XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNtopWidget, eventCtrlFrame); ac++; } else { XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++; } XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNleftWidget, controls); ac++; XtSetArg(args[ac], XmNtopOffset, (int)2); ac++; XtSetArg(args[ac], XmNleftOffset, (int)0); ac++; stats = XmCreateRowColumn(form, "stats", args, ac); XtManageChild(stats); #define TOGGLE_BTN(parent, label, name, cb, set) \ ac = 0; \ XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(label))); ac++; \ XtSetArg(args[ac], XmNset, set); ac++; \ XtSetArg(args[ac], XmNmarginHeight, 0); ac++; \ widget = XmCreateToggleButtonGadget(parent, name, args, ac); \ XmStringFree(s1); \ XtAddCallback(widget, XmNvalueChangedCallback, \ (XtCallbackProc) cb, window); \ XtManageChild(widget); \ TOGGLE_BTN(stability, "Stable", "stable", stableCB, True); TOGGLE_BTN(stability, "Unstable", "unstable", unstableCB, True); TOGGLE_BTN(particleType, "Charged", "charged", chargedCB, True); TOGGLE_BTN(particleType, "Neutral", "neutral", neutralCB, True); TOGGLE_BTN(particleType, "Electrons", "electrons", electronsCB, True); TOGGLE_BTN(particleType, "Muons", "muons", muonsCB, True); TOGGLE_BTN(particleType, "Neutrinos", "neutrinos", neutrinosCB, True); TOGGLE_BTN(particleType, "Gammas", "gammas", gammasCB, True); TOGGLE_BTN(particleType, "Quarks/Gluons", "quarks", quarksCB, True); TOGGLE_BTN(particleType,"Hadrons", "hadrons", hadronsCB, True); TOGGLE_BTN(particleType,"W/Z", "wz", wzCB, True); /* Do now the slider.. X, Y ,Z translation first. */ ac = 0; XtSetArg(args[ac], XmNborderWidth, (Dimension)0); ac++; XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++; XtSetArg(args[ac], XmNspacing, 0); ac++; XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++; /* XtSetArg(args[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++; */ XtSetArg(args[ac], XmNnumColumns, (short)1); ac++; XtSetArg(args[ac], XmNtopWidget, particleType); ac++; /* XtSetArg(args[ac], XmNrightWidget, particleType); ac++; */ allSliders = XmCreateRowColumn(controls, "allSliders", args, ac); XtManageChild(allSliders); ac = 0; XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++; XtSetArg(args[ac], XmNadjustLast, False); ac++; XtSetArg(args[ac], XmNspacing, 0); ac++; XtSetArg(args[ac], XmNnumColumns, (short)5); ac++; XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNtopWidget, allSliders); ac++; rotation = XmCreateRowColumn(controls, "rotation", args, ac); XtManageChild(rotation); /* Get foreground an background colors for pixmap buttons */ ac = 0; XtSetArg(args[ac], XmNforeground, &foreground); ac++; XtSetArg(args[ac], XmNbackground, &background); ac++; XtGetValues(controls, args, ac); #define ROTATE_BTN(pmName, widgetName, cb) \ pm = XmGetPixmap(XtScreen(parent), pmName, foreground, background); \ ac = 0; \ XtSetArg(args[ac], XmNlabelType, XmPIXMAP); ac++; \ XtSetArg(args[ac], XmNlabelPixmap, pm); ac++; \ widget = XmCreatePushButtonGadget(rotation, widgetName, args, ac); \ XtAddCallback(widget, XmNactivateCallback, \ (XtCallbackProc) cb, window); \ XtManageChild(widget); ROTATE_BTN("viewRotXPos", "viewRotXPos", viewRotXPosCB) ROTATE_BTN("viewRotYPos", "viewRotYPos", viewRotYPosCB) ROTATE_BTN("viewRotZPos", "viewRotZPos", viewRotZPosCB) ROTATE_BTN("viewRotXNeg", "viewRotXNeg", viewRotXNegCB) ROTATE_BTN("viewRotYNeg", "viewRotYNeg", viewRotYNegCB) ROTATE_BTN("viewRotZNeg", "viewRotZNeg", viewRotZNegCB) ROTATE_BTN("coordRotXPos", "coordRotXPos", coordRotXPosCB) ROTATE_BTN("coordRotYPos", "coordRotYPos", coordRotYPosCB) ROTATE_BTN("coordRotZPos", "coordRotZPos", coordRotZPosCB) ROTATE_BTN("coordRotXNeg", "coordRotXNeg", coordRotXNegCB) ROTATE_BTN("coordRotYNeg", "coordRotYNeg", coordRotYNegCB) ROTATE_BTN("coordRotZNeg", "coordRotZNeg", coordRotZNegCB) ROTATE_BTN("scaleUp", "scaleUp", scaleUpCB) ROTATE_BTN("scaleDown", "scaleDown", scaleDownCB) ROTATE_BTN("resetRotation", "resetRotation", resetRotationCB) ac = 0; XtSetArg(args[ac], XmNshadowType, XmSHADOW_IN); ac++; XtSetArg(args[ac], XmNshadowThickness, 1); ac++; scaleFrame = XmCreateFrame(stats, "scaleFrame", args, ac); XtManageChild(scaleFrame); trackInfoFrame = XmCreateFrame(stats, "trackInfoFrame", args, ac); XtManageChild(trackInfoFrame); ac = 0; XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++; XtSetArg(args[ac], XmNentryAlignment, XmALIGNMENT_CENTER); ac++; XtSetArg(args[ac], XmNspacing, 0); ac++; scaleRC = XmCreateRowColumn(scaleFrame, "scaleRC", args, ac); XtManageChild(scaleRC); ac = 0; scaleArea = XmCreateDrawingArea(scaleRC, "scaleArea", args, ac); XtAddCallback(scaleArea, XmNexposeCallback, (XtCallbackProc) scaleExposeCB, window); XtManageChild(scaleArea); ac = 0; XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING("x"))); ac++; XtSetArg(args[ac], XmNmarginHeight, 0); ac++; scaleLabel = (Widget) XmCreateLabelGadget( scaleRC, "scaleLabel", args, ac); XmStringFree(s1); XtManageChild(scaleLabel); ac = 0; XtSetArg(args[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; XtSetArg(args[ac], XmNrecomputeSize, False); ac++; XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING( "00000 tracks, 00000 are stable\nx\nTrack of max. xxxxx is a(n) xxxx"))); ac++; trackInfo = (Widget) XmCreateLabelGadget( trackInfoFrame, "trackInfo", args, ac); XmStringFree(s1); XtManageChild(trackInfo); ac = 0; XtSetArg(args[ac], XmNshowAxes, True); ac++; XtSetArg(args[ac], XmNperspectiveOn, True); ac++; XtSetArg(args[ac], XmNdoubleBuffer, False); ac++; XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++; XtSetArg(args[ac], XmNleftWidget, controls); ac++; XtSetArg(args[ac], XmNtopWidget, stats); ac++; XtSetArg(args[ac], XmNtopOffset, (int)0); ac++; XtSetArg(args[ac], XmNbottomOffset, (int)0); ac++; XtSetArg(args[ac], XmNleftOffset, (int)0); ac++; XtSetArg(args[ac], XmNrightOffset, (int)0); ac++; spin = XtCreateManagedWidget("spin", spinWidgetClass, form, args, ac); XtAddCallback(spin, XmNresizeCallback, (XtCallbackProc) resizeCB, window); XtAddCallback(spin, XmNredisplayCallback, (XtCallbackProc) redisplayCB, window); XtAddCallback(spin, XmNbtn2Callback, (XtCallbackProc) spinSelectCB, window); /* Place now the Sliders, right attached to the spin widget */ formt1 = createSpaceSlider(&window->scaleSliderScale, &window->scaleSliderValue, allSliders, spin, "scaleScale", "Overall Scale", SLIDER_MAX, window, scaleCB); formt1 = createSpaceSlider(&window->xTranslSliderScale, &window->xTranslSliderValue, allSliders, spin, "scaleX", "X transl.", (SLIDER_MAX/2), window, xTransCB); formt1 = createSpaceSlider(&window->yTranslSliderScale, &window->yTranslSliderValue, allSliders, spin, "scaleY", "Y transl.", (SLIDER_MAX/2), window, yTransCB); formt1 = createSpaceSlider(&window->zTranslSliderScale, &window->zTranslSliderValue, allSliders, spin, "scaleZ", "Z transl.", (SLIDER_MAX/2), window, zTransCB); formt1 = createSpaceSlider(&window->momToSpaceSliderScale, &window->momToSpaceSliderValue, allSliders, spin, "momtospace", "P to Dist", (SLIDER_MAX/10), window, momToSpaceCB); formt1 = createSpaceSlider(&window->longToTrSliderScale, &window->longToTrSliderValue, allSliders, spin, "LongToTr", "Aspect ratio Long/Tr. ", (SLIDER_MAX/10), window, longToTrCB); /* This last string is in fact constraining the appearance of the widget */ window->spin = spin; window->eventNumText = eventNumText; window->eventSelectorLabel = eventCtrlText; window->statsLabel = trackInfo; window->scaleArea = scaleArea; window->scaleLabel = scaleLabel; window->stable = True; window->unstable = True; window->charged = True; window->neutral = True; window->electrons = True; window->muons = True; window->gammas = True; window->neutrinos = True; window->quarks = True; window->hadrons = True; window->wz = True; return(form); }
main( int argc, char *argv[] ) { XtAppContext app_context; Widget toplevel, bb, pic, annotation; /*Widget button;*/ toplevel = XtVaAppInitialize( &app_context, "Test", NULL, 0, &argc, argv, fallback_resources, NULL ); XtAddEventHandler( toplevel, (EventMask)0, True,_XEditResCheckMessages, NULL ); n = 0; XtSetArg( args[n], XmNheight, 400 ); n++; XtSetArg( args[n], XmNwidth, 400 ); n++; XtSetValues( toplevel, args, n ); bb = XmCreateDrawingArea( toplevel, "bb", args, n ); XtManageChild( bb ); n = 0; XtSetArg( args[n], XmNx, 200 ); n++; XtSetArg( args[n], XmNy, 100 ); n++; annotation = XtCreateManagedWidget( "annotation", xipAnnotationWidgetClass, bb, args, n ); XtAddCallback( annotation, XipNactivateCallback, activate, NULL ); n = 0; XtSetArg( args[n], XmNx, 0 ); n++; XtSetArg( args[n], XmNy, 0 ); n++; XtSetArg( args[n], XipNquantisation, True ); n++; XtSetArg( args[n], XipNpic, mitkIpPicGet( "../b.pic", NULL ) ); n++; pic = XtCreateManagedWidget( "pic", xipPicWidgetClass, bb, args, n ); /**************/ XtRealizeWidget( toplevel ); /**************/ { mitkIpPicDescriptor *pic; _mitkIpPicTagsElement_t *head; mitkIpPicTSV_t *tsv; pic = mitkIpPicGetTags( "../b.pic", NULL ); tsv = mitkIpPicQueryTag( pic, "ANNOTATION" ); if( tsv != NULL ) { head = tsv->value; tsv = _mitkIpPicFindTag( head, "TEXT" )->tsv; text = malloc( strlen(tsv->value) ); strcpy( text, tsv->value ); printf( "%s\n", text ); tsv = _mitkIpPicFindTag( head, "POSITION" )->tsv; x = ((mitkIpUInt4_t *)(tsv->value))[0]; y = ((mitkIpUInt4_t *)(tsv->value))[1]; printf( "%i %i\n", x, y ); } mitkIpPicFree( pic ); } /**************/ XtVaSetValues( annotation, XmNx, x, XmNy, y, NULL ); /**************/ XtAppMainLoop(app_context); }
Widget XmCreateDrawingArea_TNK(Widget parent, String name, ArgList arglist,Cardinal argcount) { return XmCreateDrawingArea(parent, name, arglist, argcount);}
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; }
/* -------------------------------------------------------------------- */ static void CreateSpectrumWindow() { Widget optRC, frame, plRC, rc, RC[8], b[8], pb; Cardinal n; Arg args[8]; if (SpectrumWindow) return; n = 0; SpecShell = XtCreatePopupShell("specShell", topLevelShellWidgetClass, AppShell, args, n); n = 0; SpectrumWindow = XmCreateForm(SpecShell, "specForm", args, n); /* RC for Options. */ n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; optRC = XmCreateRowColumn(SpectrumWindow, "specOptForm", args, n); XtManageChild(optRC); /* Command buttons. */ n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNrightWidget, optRC); n++; frame = XmCreateFrame(SpectrumWindow, "buttonFrame", args, n); XtManageChild(frame); n = 0; rc = XmCreateRowColumn(frame, "buttonRC", args, n); XtManageChild(rc); n = 0; b[0] = XmCreatePushButton(rc, "dismissButton", args, n); b[1] = XmCreatePushButton(rc, "printButton", args, n); b[2] = XmCreatePushButton(rc, "parmsButton", args, n); b[3] = XmCreatePushButton(rc, "savepngButton", args, n); XtManageChildren(b, 4); XtAddCallback(b[0], XmNactivateCallback, SpecWinDown, NULL); XtAddCallback(b[1], XmNactivateCallback, specPostScript, NULL); XtAddCallback(b[2], XmNactivateCallback, EditSpecParms, NULL); #ifdef PNG XtAddCallback(b[3], XmNactivateCallback, SavePNGspec, NULL); #endif /* Create Graphics Canvas */ n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, frame); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNrightWidget, optRC); n++; specPlot.canvas = XmCreateDrawingArea(SpectrumWindow, "specCanvas", args,n); XtManageChild(specPlot.canvas); n = 0; frame = XmCreateFrame(optRC, "specDefsFrame", args, 0); XtManageChild(frame); n = 0; RC[0] = XmCreateRadioBox(frame, "specTypeRB", args, n); n = 0; typeButts[0] = XmCreateToggleButton(RC[0], "Spectrum", args, n); typeButts[1] = XmCreateToggleButton(RC[0], "Co-Spectrum", args, n); typeButts[2] = XmCreateToggleButton(RC[0], "Quadrature", args, n); typeButts[3] = XmCreateToggleButton(RC[0], "Coherence", args, n); typeButts[4] = XmCreateToggleButton(RC[0], "Phase", args, n); typeButts[5] = XmCreateToggleButton(RC[0], "Spectral ratio", args, n); XtManageChildren(typeButts, 6); XtAddCallback(typeButts[0],XmNvalueChangedCallback,SpecWinUp,(XtPointer)SPECTRA); XtAddCallback(typeButts[1],XmNvalueChangedCallback,SpecWinUp,(XtPointer)COSPECTRA); XtAddCallback(typeButts[2],XmNvalueChangedCallback,SpecWinUp,(XtPointer)QUADRATURE); XtAddCallback(typeButts[3],XmNvalueChangedCallback,SpecWinUp,(XtPointer)COHERENCE); XtAddCallback(typeButts[4],XmNvalueChangedCallback,SpecWinUp,(XtPointer)PHASE); XtAddCallback(typeButts[5],XmNvalueChangedCallback,SpecWinUp,(XtPointer)RATIO); /* Optional stuff. PreFilter, SegLen, Window, Detrend menus. */ n = 0; frame = XmCreateFrame(optRC, "specDefsFrame", args, 0); XtManageChild(frame); n = 0; RC[1] = XmCreateRowColumn(frame, "specDefsRC", args, n); dtOpMenu = CreateDropDownMenu(RC[1], "dtOpMenu", detrendInfo); slOpMenu = CreateDropDownMenu(RC[1], "slOpMenu", segLenInfo); winOpMenu = CreateDropDownMenu(RC[1], "winOpMenu", windowInfo); n = 0; XtSetArg(args[n], XmNalignment, XmALIGNMENT_CENTER); n++; pb = XmCreatePushButton(RC[1], "Recompute", args, n); XtManageChild(pb); XtAddCallback(pb, XmNactivateCallback, SpecWinUp, NULL); /* Variance widgets. */ n = 0; frame = XmCreateFrame(optRC, "specDefsFrame", args, 0); XtManageChild(frame); XtManageChild(XmCreateLabel(frame, "fluxLabel", args, n)); n = 0; RC[2] = XmCreateRowColumn(frame, "plRCv", args, n); plRC = XmCreateRowColumn(RC[2], "plRC", args, n); XtManageChild(XmCreateLabel(plRC, "Start freq", args, n)); sFreq = XmCreateTextField(plRC, "fluxFreq", args, n); XtManageChild(XmCreateLabel(plRC, "Hz", args, n)); XtManageChild(plRC); XtManageChild(sFreq); XtAddCallback(sFreq, XmNlosingFocusCallback, ValidateFloat, (XtPointer)"%g"); XtAddCallback(sFreq, XmNlosingFocusCallback, ComputeBandLimitedVariance,NULL); XtAddCallback(sFreq, XmNlosingFocusCallback, (XtCallbackProc)PlotSpectrum, NULL); plRC = XmCreateRowColumn(RC[2], "plRC", args, n); XtManageChild(XmCreateLabel(plRC, "End freq", args, n)); eFreq = XmCreateTextField(plRC, "fluxFreq", args, n); XtManageChild(XmCreateLabel(plRC, "Hz", args, n)); XtManageChild(plRC); XtManageChild(eFreq); XtAddCallback(eFreq, XmNlosingFocusCallback, ValidateFloat, (XtPointer)"%g"); XtAddCallback(eFreq, XmNlosingFocusCallback, ComputeBandLimitedVariance,NULL); XtAddCallback(eFreq, XmNlosingFocusCallback, (XtCallbackProc)PlotSpectrum, NULL); XmTextFieldSetString(sFreq, "0.0"); XmTextFieldSetString(eFreq, "5000.0"); /* Plot Methods. */ n = 0; frame = XmCreateFrame(optRC, "specDefsFrame", args, 0); XtManageChild(frame); XtManageChild(XmCreateLabel(frame, "plotMethodLabel", args, n)); n = 0; RC[3] = XmCreateRowColumn(frame, "plRCv", args, n); n = 0; pmOptButt[0] = XmCreateToggleButton(RC[3], "Grid", args,n); pmOptButt[1] = XmCreateToggleButton(RC[3], "-5/3 (-2/3 x f) slope line", args,n); pmOptButt[2] = XmCreateToggleButton(RC[3], "Multiply output by frequency", args,n); pmOptButt[3] = XmCreateToggleButton(RC[3], "Multiply output by freq^(5/3)", args,n); pmOptButt[4] = XmCreateToggleButton(RC[3], "Wave number scale", args,n); pmOptButt[5] = XmCreateToggleButton(RC[3], "Wave length scale", args,n); XtManageChildren(pmOptButt, 6); XtAddCallback(pmOptButt[0], XmNvalueChangedCallback, ToggleSpecGrid, NULL); XtAddCallback(pmOptButt[0], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL); XtAddCallback(pmOptButt[1], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL); XtAddCallback(pmOptButt[2], XmNvalueChangedCallback, ToggleMultByFreq, NULL); XtAddCallback(pmOptButt[2], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL); XtAddCallback(pmOptButt[3], XmNvalueChangedCallback, ToggleMultByFreq, NULL); XtAddCallback(pmOptButt[3], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL); XtAddCallback(pmOptButt[4], XmNvalueChangedCallback, ToggleWaveNumberScale, NULL); XtAddCallback(pmOptButt[4], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL); XtAddCallback(pmOptButt[5], XmNvalueChangedCallback, ToggleWaveLengthScale, NULL); XtAddCallback(pmOptButt[5], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL); XmToggleButtonSetState(pmOptButt[1], true, false); /* Equal-log interval averaging */ n = 0; frame = XmCreateFrame(optRC, "eliaFrame", args, 0); XtManageChild(frame); n = 0; RC[4] = XmCreateRowColumn(frame, "plRCv", args, n); n = 0; pmOptButt[6] = XmCreateToggleButton(RC[4], "Equal-log interval averaging", args,n); XtManageChild(pmOptButt[6]); XtAddCallback(pmOptButt[6], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL); n = 0; plRC = XmCreateRowColumn(RC[4], "plRC", args, n); XtManageChild(plRC); XtManageChild(XmCreateLabel(plRC, "Total number points", args, n)); eliaText = XmCreateTextField(plRC, "eliaText", args, n); XtManageChild(eliaText); XmTextFieldSetString(eliaText, "30"); XtAddCallback(eliaText, XmNlosingFocusCallback, ValidateInteger, NULL); XtAddCallback(eliaText, XmNlosingFocusCallback, (XtCallbackProc)PlotSpectrum, NULL); /* Time shift. */ n = 0; frame = XmCreateFrame(optRC, "specDefsFrame", args, 0); XtManageChild(frame); n = 0; RC[5] = XmCreateRowColumn(frame, "plRC", args, n); XtManageChild(XmCreateLabel(RC[5], "Time shift", args, n)); tShift = XmCreateTextField(RC[5], "timeShift", args, n); XtManageChild(tShift); XtAddCallback(tShift, XmNlosingFocusCallback, ValidateInteger, NULL); XtAddCallback(tShift, XmNlosingFocusCallback, SpecWinUp, NULL); XtManageChild(XmCreateLabel(RC[5], "milliseconds", args, n)); XtManageChild(RC[0]); XtManageChild(RC[1]); XtManageChild(RC[2]); XtManageChild(RC[3]); XtManageChild(RC[4]); XtManageChild(RC[5]); } /* END CREATESPECTRUMWINDOW */
static void create_shell(Display *display, char *app_name, int app_argc, char **app_argv) { Arg al[12]; /* Arg List */ int ac; /* Arg Count */ XmString *list_items; /* For list items */ int list_item; /* Index for list_items */ /* XmFontList f1; */ ac = 0; XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++; XtSetArg(al[ac], XmNargc, app_argc); ac++; XtSetArg(al[ac], XmNargv, app_argv); ac++; shell = XtAppCreateShell ( app_name, "XApplication", applicationShellWidgetClass, display, al, ac ); initialise_objects ( shell ); ac = 0; XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++; XtSetArg(al[ac], XmNlabelFontList, f1); ac++; XtSetArg(al[ac], XmNheight, 400); ac++; form = XmCreateForm ( shell, "form", al, ac ); ac = 0; XtSetArg(al[ac], XmNfontList, f1); ac++; XtSetArg(al[ac], XmNselectionPolicy, XmSINGLE_SELECT); ac++; XtSetArg(al[ac], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); ac++; XtSetArg(al[ac], XmNitemCount, 5); ac++; list_items = (XmString *) XtMalloc ( sizeof (XmString) * 5 ); list_items[0] = XmStringCreateLtoR("The", "large_italic"); list_items[1] = XmStringCreateLtoR("Quick", "small_bold"); /*list_items[2] = XmStringCreateLtoR("\033$BF|\033(B\033$BK\\\033(B", "japanese" );*/ list_items[2] = XmStringCreateLtoR("F| K\\", "japanese" ); list_items[3] = XmStringCreateLtoR("Brown", "small_italic"); list_items[4] = XmStringCreateLtoR("Fox", "large_bold"); XtSetArg(al[ac], XmNitems, list_items); ac++; list1 = XmCreateScrolledList ( form, "list1", al, ac ); list1_sw = XtParent ( list1 ); for (list_item = 0; list_item < 5; list_item++ ) XmStringFree (list_items [list_item]); XtFree ( (char *) list_items ); da = XmCreateDrawingArea ( form, "da", al, 0 ); ac = 0; XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_POSITION); ac++; XtSetArg(al[ac], XmNbottomPosition, 65); ac++; XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; XtSetValues ( list1_sw,al, ac ); ac = 0; XtSetArg(al[ac], XmNtopAttachment, XmATTACH_POSITION); ac++; XtSetArg(al[ac], XmNtopPosition, 65); ac++; XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; XtSetValues ( da,al, ac ); XtManageChild(list1); XtAddCallback (da, XmNexposeCallback, da_expose, list1); XtManageChild(da); XtManageChild ( form); }
extern Boolean XltWorking(Widget w, String Question, int PercentDone) { static Widget Dialog = NULL; static WorkingData_t Data; static Boolean abortflag = False; static Boolean mapped = False; XmString string; if (Dialog == NULL) { Widget shell = w; Widget frame; Widget frame_title; XGCValues values; Dialog = XmCreateWorkingDialog(shell, "Working", NULL, 0); XtVaSetValues(Dialog, XmNautoUnmanage, False, NULL); XtUnmanageChild(XmMessageBoxGetChild(Dialog, XmDIALOG_HELP_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(Dialog, XmDIALOG_CANCEL_BUTTON)); XtAddCallback(Dialog, XmNokCallback, (XtCallbackProc)callback, &abortflag); XtAddCallback(Dialog, XmNunmapCallback, (XtCallbackProc)callback, &abortflag); XtAddEventHandler(XtParent(Dialog), StructureNotifyMask, False, (XtEventHandler)StructureNotifyHandler, (XtPointer)&mapped); mapped = False; frame = XmCreateFrame(Dialog,"Frame",NULL,0); frame_title = XmCreateLabel(frame,"Title", NULL,0); XtVaSetValues(frame_title, XmNchildType, XmFRAME_TITLE_CHILD, NULL); Data.Da = XmCreateDrawingArea(frame, "Graph", NULL, 0); XtManageChild(frame_title); XtManageChild(Data.Da); XtManageChild(frame); XtRealizeWidget(Dialog); Data.Id = (XtIntervalId)NULL; XtVaGetValues(Data.Da, XmNforeground, &values.foreground, XmNbackground, &values.background, NULL); Data.gc = XCreateGC(XtDisplay(Data.Da), XtWindow(Data.Da), GCForeground | GCBackground, &values); } if (Question) { string = XmStringCreateSimple(Question); XtVaSetValues(Dialog, XmNmessageString, string, NULL); XmStringFree(string); } if (PercentDone >= 0) { Data.percent = PercentDone; } switch (PercentDone) { case 0: abortflag = False; XtManageChild(Dialog); if (Data.Id == (XtIntervalId)NULL) { XClearArea(XtDisplay(Data.Da), XtWindow(Data.Da), 0, 0, 0, 0, False); Data.Id = XtAppAddTimeOut(XtWidgetToApplicationContext(Dialog), 0, (XtTimerCallbackProc)UpdateGraph, &Data); } break; case 100: if (Data.Id != (XtIntervalId)NULL) { XtRemoveTimeOut(Data.Id); Data.Id = (XtIntervalId)NULL; } while (XtIsManaged(Dialog) && !mapped) { XtAppProcessEvent(XtWidgetToApplicationContext(Dialog), XtIMXEvent); } UpdateGraph(&Data); XtRemoveTimeOut(Data.Id); Data.Id = (XtIntervalId)NULL; XtUnmanageChild(Dialog); while (!XtIsManaged(Dialog) && mapped) { XtAppProcessEvent(XtWidgetToApplicationContext(Dialog), XtIMXEvent); } abortflag = False; break; default: { XtInputMask mask; while ((mask = (XtAppPending(XtWidgetToApplicationContext(Dialog)) & ~XtIMAlternateInput))) { XtAppProcessEvent(XtWidgetToApplicationContext(Dialog), mask); } if (!XtIsManaged(Dialog)) { abortflag = True; } } break; } return(abortflag); }
void buttonHistory(Widget w, XtPointer client, XtPointer call) { int i; unsigned long k; Arg newArgs[CONFIG_ARG_COUNT]; extern struct mainInfo *pMainMainInfo; historyClose(w, client, call); if(pMainMainInfo->hstPixmap == 0) { if((pMainMainInfo->hstPixmap = XCreatePixmap(pMainMainInfo->appDisplay, RootWindowOfScreen(pMainMainInfo->appScreen), NUM_HISTORY_WIDTH, NUM_HISTORY_HEIGHT, DefaultDepthOfScreen(pMainMainInfo->appScreen))) == 0) { warningMessage(ERROR_SLIGHT, "Error occurred while trying to allocate memory for pixmap", pMainMainInfo); return; } } // Create panel i = 0; XtSetArg(newArgs[i], XmNtitle, WINDOW_TITLE_HISTORY); i++; XtSetArg(newArgs[i], XmNdeleteResponse, XmDESTROY); i++; pMainMainInfo->hstDialog = XmCreateDialogShell(pMainMainInfo->dlgHistory, TITLE_HISTORY_TITLE, newArgs, i); i = 0; XtSetArg(newArgs[i], XmNorientation, XmVERTICAL); i++; XtSetArg(newArgs[i], XmNpacking, XmPACK_TIGHT); i++; XtSetArg(newArgs[i], XmNscrollingPolicy, XmAUTOMATIC); i++; pMainMainInfo->hstPanel = XmCreateRowColumn(pMainMainInfo->hstDialog, "history_panel", newArgs, i); i = 0; XtSetArg(newArgs[i], XmNorientation, XmHORIZONTAL); i++; XtSetArg(newArgs[i], XmNpacking, XmPACK_TIGHT); i++; XtSetArg(newArgs[i], XmNscrollingPolicy, XmAUTOMATIC); i++; pMainMainInfo->hstOutput = XmCreateRowColumn(pMainMainInfo->hstPanel, "history_form", newArgs, i); // Create drawing area i = 0; XtSetArg(newArgs[i], XmNwidth, NUM_HISTORY_WIDTH); i++; XtSetArg(newArgs[i], XmNheight, NUM_HISTORY_HEIGHT); i++; pMainMainInfo->hstDraw = XmCreateDrawingArea(pMainMainInfo->hstOutput, "history_drawing", newArgs, i); XtAddCallback(pMainMainInfo->hstDraw, XmNinputCallback, historyExpose, NULL); XtAddCallback(pMainMainInfo->hstDraw, XmNexposeCallback, historyExpose, NULL); XtVaSetValues(pMainMainInfo->hstDraw, XmNuserData, pMainMainInfo->appGC, NULL); XtManageChild(pMainMainInfo->hstDraw); // Create control area i = 0; XtSetArg(newArgs[i], XmNorientation, XmVERTICAL); i++; XtSetArg(newArgs[i], XmNpacking, XmPACK_TIGHT); i++; XtSetArg(newArgs[i], XmNrowColumnType, XmWORK_AREA); i++; XtSetArg(newArgs[i], XmNscrollingPolicy, XmNONE); i++; pMainMainInfo->hstCtrl = XtCreateManagedWidget("history_controls", xmRowColumnWidgetClass, pMainMainInfo->hstOutput, newArgs, i); // Create control area menus netFetchDays(pMainMainInfo); pMainMainInfo->hstMenuDate = XmCreatePulldownMenu(pMainMainInfo->hstCtrl, "date", NULL, 0); i = 0; XtSetArg(newArgs[i], XmNsubMenuId, pMainMainInfo->hstMenuDate); i++; pMainMainInfo->hstOptionDate = XmCreateOptionMenu(pMainMainInfo->hstCtrl, "option", newArgs, i); XtManageChild(pMainMainInfo->hstOptionDate); for(k = 0; ; k++) { if(pMainMainInfo->hstArrays[k].label[0] == 0) { break; } pMainMainInfo->hstButtonDate = XtCreateManagedWidget(pMainMainInfo->hstArrays[k].label, xmPushButtonWidgetClass, pMainMainInfo->hstMenuDate, NULL, 0); XtAddCallback(pMainMainInfo->hstButtonDate, XmNactivateCallback, historyMenuDate, (XtPointer) k); } if(k == 0) { pMainMainInfo->hstButtonDate = XtCreateManagedWidget(TITLE_HISTORY_MENU_EMPTY, xmPushButtonWidgetClass, pMainMainInfo->hstMenuDate, NULL, 0); } pMainMainInfo->hstDaysFetch = 0; // Create separator pMainMainInfo->hstButton = XmCreateSeparatorGadget(pMainMainInfo->hstCtrl, "history_separator", NULL, 0); XtManageChild(pMainMainInfo->hstButton); // Create control area buttons i = 0; XtSetArg(newArgs[i], XmNshowAsDefault, True); i++; pMainMainInfo->hstButton = XmCreatePushButtonGadget(pMainMainInfo->hstCtrl, TITLE_HISTORY_BUTTON_UPDATE, newArgs, i); XtAddCallback(pMainMainInfo->hstButton, XmNactivateCallback, historyUpdate, NULL); XtManageChild(pMainMainInfo->hstButton); i = 0; XtSetArg(newArgs[i], XmNshowAsDefault, True); i++; pMainMainInfo->hstButton = XmCreatePushButtonGadget(pMainMainInfo->hstCtrl, TITLE_HISTORY_BUTTON_SAVE, newArgs, i); XtAddCallback(pMainMainInfo->hstButton, XmNactivateCallback, historyExport, NULL); XtManageChild(pMainMainInfo->hstButton); // Create separator pMainMainInfo->hstButton = XmCreateSeparatorGadget(pMainMainInfo->hstCtrl, "history_separator", NULL, 0); XtManageChild(pMainMainInfo->hstButton); i = 0; XtSetArg(newArgs[i], XmNshowAsDefault, True); i++; pMainMainInfo->hstButton = XmCreatePushButtonGadget(pMainMainInfo->hstCtrl, TITLE_HISTORY_BUTTON_DISMISS, newArgs, i); XtAddCallback(pMainMainInfo->hstButton, XmNactivateCallback, historyClose, NULL); XtManageChild(pMainMainInfo->hstButton); XtManageChild(pMainMainInfo->hstOutput); XtManageChild(pMainMainInfo->hstPanel); historyMenuDate(w, client, call); }