// Apply button static void ApplyPlotCommandCB(Widget, XtPointer client_data, XtPointer) { PlotWindowInfo *plot = (PlotWindowInfo *)client_data; Widget text = XmCommandGetChild(plot->command, XmDIALOG_COMMAND_TEXT); String cmd_s = 0; if (XmIsTextField(text)) cmd_s = XmTextFieldGetString(text); else if (XmIsText(text)) cmd_s = XmTextGetString(text); else { assert(0); ::abort(); } string cmd = cmd_s; XtFree(cmd_s); send_and_replot(plot, cmd); }
void scrnInitX(void) { Widget toplevel, control; Widget mb, fileMenu, viewMenu, confMenu, helpMenu; Widget procFrame = NULL, bboxFrame = NULL; #ifdef ICON_DEFINED Pixmap icon; #endif XmString s; Arg args[10]; unsigned i, n; int argc = 0; addRegwRsrcOpts(); addDatwRsrcOpts(); toplevel = XtAppInitialize(&app_context, "XSki", options, topopts, &argc, NULL, NULL, NULL, 0); top_level = toplevel; /* XXX - temporary for Platform only */ XtGetApplicationResources(toplevel, &app_data, resources, toprsrc, NULL, 0); XtAppAddActions(app_context, actions, XtNumber(actions)); dpy = XtDisplay(toplevel); #ifdef ICON_DEFINED /* set default icon */ icon = XCreateBitmapFromData(dpy, RootWindowOfScreen(XtScreen(toplevel)), icon_bits, icon_width, icon_height); XtSetArg(args[0], XmNiconPixmap, icon); XtSetValues(toplevel, args, 1); #endif #if 0 XSynchronize(dpy, True); #endif /* create control window manager */ control = XmCreateForm(toplevel, "control", NULL, 0); XtManageChild(control); /* Control window menubar */ n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; mb = XmCreateMenuBar(control, "mb", args, n); XtManageChild(mb); fileMenu = createMBitem(mb, "File"); viewMenu = createMBitem(mb, "View"); confMenu = createMBitem(mb, "Configure"); helpMenu = createMBitem(mb, "Help"); #if 0 createSubmenuItem(fileMenu, "load", loadCallback); #else createSubmenuItem(fileMenu, "load", 0); #endif createSubmenuItem(fileMenu, "save", 0); createSubmenuItem(fileMenu, "trace", 0); createSubmenuItem(fileMenu, "traceOn", 0); createSubmenuItem(fileMenu, "traceOff", 0); createSubmenuItem(fileMenu, "read", 0); XtManageChild(XmCreateSeparatorGadget(fileMenu, "", NULL, 0)); createSubmenuItem(fileMenu, "quit", simCmdCallback); createSubmenuItem(viewMenu, "program", programCallback); createSubmenuItem(viewMenu, "data", dataCallback); createSubmenuItem(viewMenu, "registers", regCallback); createSubmenuItem(viewMenu, "cache", 0); createSubmenuItem(viewMenu, "tlb", sdtCallback); XtManageChild(XmCreateSeparatorGadget(viewMenu, "", NULL, 0)); createSubmenuItem(viewMenu, "callstack", cstCallback); createSubmenuItem(viewMenu, "statistics", 0); createSubmenuItem(viewMenu, "breakpoints", blistCallback); createSubmenuItem(viewMenu, "branches", 0); createSubmenuItem(viewMenu, "symbols", symlistCallback); createSubmenuItem(viewMenu, "macros", 0); #if 0 /* No support for window format yet */ createSubmenuItem(confMenu, "program", prgFmtCallback); #else createSubmenuItem(confMenu, "program", 0); #endif createSubmenuItem(confMenu, "data", 0); #if 0 /* No support for window format yet */ createSubmenuItem(confMenu, "registers", regFmtCallback); #else createSubmenuItem(confMenu, "registers", 0); #endif createSubmenuItem(helpMenu, "context", 0); createSubmenuItem(helpMenu, "overview", 0); createSubmenuItem(helpMenu, "commands", cmdHelpCallback); createSubmenuItem(helpMenu, "product", prodInfoCallback); /* Control window processor option menu */ if (nproc > 1) { Widget procMenu, proc[NPROC]; n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, mb); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; procFrame = XmCreateFrame(control, "", args, n); XtManageChild(procFrame); procMenu = XmCreatePulldownMenu(procFrame, "", NULL, 0); for (i = 0; i < nproc; i++) { char name[4]; (void)sprintf(name, "p%d", i); proc[i] = XmCreatePushButton(procMenu, name, NULL, 0); XtAddCallback(proc[i], XmNactivateCallback, changeCprocCallback, (XtPointer)i); } XtManageChildren(proc, nproc); n = 0; XtSetArg(args[n], XmNsubMenuId, procMenu); n++; XtManageChild(XmCreateOptionMenu(procFrame, "procOption", args, n)); } /* Control window button box */ if (app_data.numButtons) { Widget bbox, btns[20]; /* create button box manager */ n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, procFrame ? procFrame : mb); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; bboxFrame = XmCreateFrame(control, "", args, n); XtManageChild(bboxFrame); /* create button box window */ bbox = XmCreateRowColumn(bboxFrame, "bbox", NULL, 0); XtManageChild(bbox); /* create each button */ for (i = 0; i < app_data.numButtons; i++) { char name[8]; (void)sprintf(name, "bb%d", i); btns[i] = XmCreatePushButton(bbox, name, NULL, 0); } XtManageChildren(btns, app_data.numButtons); } /* Control window command area */ n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, bboxFrame ? bboxFrame : procFrame ? procFrame : mb); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; cmd = XmCreateCommand(control, "cmd", args, n); XtManageChild(cmd); XtAddCallback(cmd, XmNcommandEnteredCallback, simCmdCallback, 0); /* command history box */ n = 0; XtSetArg(args[0], XmNinitialFocus, cmd); n++; XtSetValues(control, args, n); cmdHist = XmCommandGetChild(cmd, XmDIALOG_HISTORY_LIST); /* message window */ msgs = XmCreateScrolledText(control, "msgs", NULL, 0); XtManageChild(msgs); n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, cmd); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetValues(XtParent(msgs), args, n); /* create stop simulation dialog */ /* Consider changing this to a button. This would allow other functionality to still be active when simulation is going on. For example, Help, Quit, opening and closing windows, etc. */ stopsim = XmCreateWorkingDialog(control, "stopsim", NULL, 0); n = 0; XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++; s = XmStringCreateLocalized("Running..."); XtSetArg(args[n], XmNdialogTitle, s); n++; s = XmStringCreateLocalized(" icnt: 0 "); XtSetArg(args[n], XmNmessageString, s); n++; s = XmStringCreateLocalized("Stop"); XtSetArg(args[n], XmNcancelLabelString, s); n++; XtSetValues(stopsim, args, n); XtAddCallback(stopsim, XmNcancelCallback, stop_execLoopXCB, NULL); XtUnmanageChild(XmMessageBoxGetChild(stopsim, XmDIALOG_OK_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(stopsim, XmDIALOG_HELP_BUTTON)); XmStringFree(s); /* XXX - This should probably be inside regwInit */ for (i = 0; i < topregw; i++) regwtbl[i].show = app_data.showRs[i]; /* XXX - This should probably be inside datwInit */ for (i = 0; i < topdatw; i++) datwtbl[i].show = app_data.viewDw[i]; prgwInit(); datwInit(); regwInit(); if (app_data.viewProg) prgwDrawX(); datwDrawX(); if (app_data.viewRegs) regwDrawX(); noscreen = NO; XtRealizeWidget(toplevel); }