main(int argc, char **argv) { Widget top_level, pane, text, display_button, quit_button; Arg arg[5]; top_level = XtInitialize(argv[0], "test", NULL, 0, &argc, argv); pane = XmCreatePanedWindow(top_level, "pane", NULL, 0); XtSetArg(arg[0], XmNwidth, 400); XtSetArg(arg[1], XmNheight, 400); XtSetArg(arg[3], XmNwordWrap, TRUE); XtSetArg(arg[4], XmNeditMode, XmMULTI_LINE_EDIT); text = XmCreateText(pane, "text", arg, 5); display_button = XmCreatePushButton(pane, "Display", NULL, 0); quit_button = XmCreatePushButton(pane, "Quit", NULL, 0); XtAddCallback(display_button, XmNactivateCallback, (XtCallbackProc)do_get_text, text); XtAddCallback(quit_button, XmNactivateCallback, (XtCallbackProc)do_quit, NULL); XtManageChild(text); XtManageChild(display_button); XtManageChild(quit_button); XtManageChild(pane); XtRealizeWidget(top_level); XtMainLoop(); }
void create_feature_menu(Widget parent) { Widget feature_menu_pane, feature_button, area_button, feature_sep_1, perimeter_button, feature_sep_2, ctomass_button, feature_sep_3, moments_button, feature_sep_4, circular_button; /* Create the menu pane for the menu */ feature_menu_pane = XmCreatePulldownMenu(parent, "feature menu pane", NULL, 0); /* Populate the menu pane */ area_button = XmCreatePushButton(feature_menu_pane, "Area", NULL, 0); XtManageChild(area_button); XtAddCallback(area_button, XmNactivateCallback, (XtCallbackProc) activate_area_callback, (XtPointer) NULL); /* Separator 1 */ feature_sep_1 = XmCreateSeparator(feature_menu_pane, "feature sep 1", NULL, 0); XtManageChild(feature_sep_1); perimeter_button = XmCreatePushButton(feature_menu_pane, "Perimeter", NULL, 0); XtManageChild(perimeter_button); XtAddCallback(perimeter_button, XmNactivateCallback, (XtCallbackProc) activate_perimeter_callback, (XtPointer) NULL); /* Separator 2*/ feature_sep_2 = XmCreateSeparator(feature_menu_pane, "feature sep 2", NULL, 0); XtManageChild(feature_sep_2); ctomass_button = XmCreatePushButton(feature_menu_pane, "Ctomass", NULL, 0); XtManageChild(ctomass_button); XtAddCallback(ctomass_button, XmNactivateCallback, (XtCallbackProc) activate_ctomass_callback, (XtPointer) NULL); /* Separator3*/ feature_sep_3 = XmCreateSeparator(feature_menu_pane, "feature sep 3", NULL, 0); XtManageChild(feature_sep_3); moments_button = XmCreatePushButton(feature_menu_pane, "Moments", NULL, 0); XtManageChild(moments_button); XtAddCallback(moments_button, XmNactivateCallback, NULL /*(XtCallbackProc) activate_moments_callback */, (XtPointer) NULL); /* Separator4*/ feature_sep_4 = XmCreateSeparator(feature_menu_pane, "feature sep 4", NULL, 0); XtManageChild(feature_sep_4); circular_button = XmCreatePushButton(feature_menu_pane, "Circular", NULL, 0); XtManageChild(circular_button); XtAddCallback(circular_button, XmNactivateCallback, (XtCallbackProc) activate_circular_callback, (XtPointer) NULL); /* Create the featurea cascade button on the menu bar and */ /* attach the about menu pane to it. */ argcount = 0; XtSetArg(args[argcount], XmNsubMenuId, feature_menu_pane); argcount++; feature_button = XmCreateCascadeButton(parent, "Feature ", args, argcount); /* XtManageChild(feature_button); */ }
void create_about_menu(Widget parent) { Widget about_menu_pane, about_menu_button, version_button,help_button; /* Create the menu pane for the menu */ about_menu_pane = XmCreatePulldownMenu(parent, "Help ", NULL, 0); help_button = XmCreatePushButton(about_menu_pane, "Help", NULL, 0); XtManageChild(help_button); /* Populate the menu pane */ /* Version button */ version_button = XmCreatePushButton(about_menu_pane, "Version", NULL, 0); XtManageChild(version_button); /* Create the version dialog and add the activation function as */ /* the version button's activate callback. */ create_version_dialog(parent); XtAddCallback(version_button, XmNactivateCallback, (XtCallbackProc) activate_version_dialog, (XtPointer) NULL); XtAddCallback(help_button, XmNactivateCallback, (XtCallbackProc) help_moi, (XtPointer) NULL); /* Create the about cascade button on the menu bar and */ /* attach the about menu pane to it. */ argcount = 0; XtSetArg(args[argcount], XmNsubMenuId, about_menu_pane); argcount++; about_menu_button = XmCreateCascadeButton(parent, "Help ", args, argcount); XtManageChild(about_menu_button); }
void create_multi_menu(Widget parent) { Widget multi_menu_pane, inverse_button, multi_menu_button, twofile_button, merg_button; /* Create the menu pane for the menu */ multi_menu_pane = XmCreatePulldownMenu(parent, "MultiImage ", NULL, 0); /* Populate the menu pane */ /* Version button */ twofile_button = XmCreatePushButton(multi_menu_pane, "Compare f1&f2=>f3", NULL, 0); XtManageChild(twofile_button); merg_button = XmCreatePushButton(multi_menu_pane, "Merge f1&f2=>f3", NULL, 0); XtManageChild(merg_button); /* Create the version dialog and add the activation function as */ /* the version button's activate callback. */ XtAddCallback(twofile_button, XmNactivateCallback, (XtCallbackProc) multi_window_callback, (XtPointer) NULL); XtAddCallback(merg_button, XmNactivateCallback, (XtCallbackProc) multi_merge_callback, (XtPointer) NULL); inverse_button = XmCreatePushButton(multi_menu_pane, "Inverse f1=>-f1", NULL, 0); XtManageChild(inverse_button); /* Create the version dialog and add the activation function as */ /* the version button's activate callback. */ XtAddCallback(inverse_button, XmNactivateCallback, (XtCallbackProc) inverse_callback, (XtPointer) NULL); /* Create the about cascade button on the menu bar and */ /* attach the about menu pane to it. */ argcount = 0; XtSetArg(args[argcount], XmNsubMenuId, multi_menu_pane); argcount++; multi_menu_button = XmCreateCascadeButton(parent, "MultiImage ", args, argcount); XtManageChild(multi_menu_button); }
//create buttons void InvPartEditor::createSelectButtons(Widget parent) { Arg args[5]; //We want to order the buttons in a column XtSetArg(args[0], XmNorientation, XmVERTICAL); Widget partSelection = XtCreateManagedWidget("partSelection", xmRowColumnWidgetClass, parent, args, 1); //A button to select all part-ids Widget selectAll = XmCreatePushButton(partSelection, (char *)"All visible", NULL, 0); XtAddCallback(selectAll, XmNactivateCallback, selectAllCB, (XtPointer) this); //Probably the user wants to see all parts by default //when he starts selectAllToggleButtons(this, True); //A Button to unselect all part-ids Widget unselectAll = XmCreatePushButton(partSelection, (char *)"All invisible", NULL, 0); XtAddCallback(unselectAll, XmNactivateCallback, unselectAllCB, (XtPointer) this); //A Button to invert the selection //after pressing this button formerly unselected parts are selected //and formerly selected parts are unselected. Widget invert = XmCreatePushButton(partSelection, (char *)"Invert selection", NULL, 0); XtAddCallback(invert, XmNactivateCallback, invertAllToggleButtonsCB, (XtPointer) this); createRegFrame(partSelection); XtManageChild(selectAll); XtManageChild(unselectAll); XtManageChild(invert); }
int main(int argc, char **argv) { int i; Widget toplevel, bb, label, pressme, pb; XtAppContext app; XmString item; Arg args[5]; XtSetLanguageProc(NULL, NULL, NULL); toplevel = XtVaAppInitialize(&app, "GrabShell", NULL, 0, &argc, argv, NULL, NULL); bb = XmCreateBulletinBoard(toplevel, "bb", NULL, 0); pressme = XmCreatePushButton(bb,"Press me and let's see what the grab shell does.",NULL,0); XtManageChild(pressme); XtManageChild(bb); i = 0; XtSetArg(args[i], XmNownerEvents, True); i++; XtSetArg(args[i], XmNgrabStyle, GrabModeSync); i++; grabshell = XmCreateGrabShell(bb, "grab", args, i); label = XmCreateLabel(grabshell, "Hello World", NULL, 0); XtManageChild(label); i = 0; XtSetArg(args[i], XmNy, 100); i++; XtSetArg(args[i], XmNx, 0); i++; pb = XmCreatePushButton(grabshell,"hello", args, i); XtManageChild(pb); /* setup callback for an activate action */ XtAddCallback(pressme, XmNactivateCallback, (XtCallbackProc) onActivate, (XtPointer) grabshell); XtAddCallback(grabshell, XmNpopupCallback, (XtCallbackProc) onPopup, (XtPointer) grabshell); XtRealizeWidget(toplevel); #if 1 GrabShellResources(grabshell); #endif check_geometry(); LessTifTestMainLoop(toplevel); exit(0); }
static Widget CreateMainWindowWithMenuBar(Widget toplevel) { Widget main_window, menu_bar, menu_pane, cascade, button ; Arg args[20]; Cardinal n; /* Create MainWindow. */ n = 0; main_window = XmCreateMainWindow (toplevel, "main_window", args, n); XtManageChild (main_window); /* Create MenuBar in MainWindow. */ n = 0; menu_bar = XmCreateMenuBar (main_window, "menu_bar", args, n); XtManageChild (menu_bar); /* Create "File" PulldownMenu. */ n = 0; menu_pane = XmCreatePulldownMenu (menu_bar, "menu_pane", args, n); n = 0; button = XmCreatePushButton (menu_pane, "Exit", args, n); XtManageChild (button); XtAddCallback (button, XmNactivateCallback, QuitCB, NULL); n = 0; XtSetArg (args[n], XmNsubMenuId, menu_pane); n++; cascade = XmCreateCascadeButton (menu_bar, "File", args, n); XtManageChild (cascade); /* Create "Help" PulldownMenu. */ n = 0; menu_pane = XmCreatePulldownMenu (menu_bar, "menu_pane3", args, n); n = 0; button = XmCreatePushButton (menu_pane, "Overview", args, n); XtManageChild (button); XtAddCallback (button, XmNactivateCallback, HelpCB, NULL); n = 0; XtSetArg (args[n], XmNsubMenuId, menu_pane); n++; cascade = XmCreateCascadeButton (menu_bar, "Help", args, n); XtManageChild (cascade); n = 0; XtSetArg (args[n], XmNmenuHelpWidget, cascade); n++; XtSetValues (menu_bar, args, n); return main_window ; }
/* -------------------------------------------------------------------- */ static void CreatePreferences() { int i; Cardinal n; Arg args[2]; Widget frame, RC, plRC, label, b[3]; PreferShell = XtCreatePopupShell("prefParmsShell", topLevelShellWidgetClass, AppShell, NULL, 0); PreferWindow = XmCreateRowColumn(PreferShell, (char *)"prefRC", NULL, 0); n = 0; frame = XmCreateFrame(PreferWindow, (char *)"prefFrame", args, n); XtManageChild(frame); n = 0; RC = XmCreateRowColumn(frame, (char *)"prefRC", args, n); for (i = 0; i < TOTAL_PREFERS; ++i) { plRC = XmCreateRowColumn(RC, (char *)"plRC", args, n); XtManageChild(plRC); sprintf(buffer, "prefer%d", i); label = XmCreateLabel(plRC, buffer, args, n); XtManageChild(label); prefText[i] = XmCreateTextField(plRC, (char *)"prefText", args, n); XtManageChild(prefText[i]); XtAddCallback(prefText[i], XmNlosingFocusCallback, ApplyPreferences, NULL); } /* Command buttons. */ n = 0; frame = XmCreateFrame(PreferWindow, (char *)"buttonFrame", args, 0); XtManageChild(frame); n = 0; plRC = XmCreateForm(frame, (char *)"buttonRC", args, n); n = 0; b[0] = XmCreatePushButton(plRC, (char *)"dismissButton", args, n); XtAddCallback(b[0], XmNactivateCallback, DismissWindow, PreferWindow); n = 0; b[1] = XmCreatePushButton(plRC, (char *)"saveButton", args, n); XtAddCallback(b[1], XmNactivateCallback, SavePreferences, NULL); XtManageChildren(b, 2); XtManageChild(plRC); XtManageChild(RC); } /* END CREATEPREFERENCES */
void create_tools_menu(Widget parent) { Widget tools_menu_pane, tools_menu_button, editing_tools_button, region_cut_button, zoom_button, tools_sep_1, tools_sep_2; /* Create the menu pane for the menu */ tools_menu_pane = XmCreatePulldownMenu(parent, "tools menu pane", NULL, 0); /* Create the representation cascade button on the menu bar and */ /* Editing tools button */ editing_tools_button = XmCreatePushButton(tools_menu_pane, "Editing Tools ", NULL, 0); XtManageChild(editing_tools_button); /* Create the editing tools window and add the activation function as */ /* the editing tools button's activate callback. */ create_editing_tools_window(parent); XtAddCallback(editing_tools_button, XmNactivateCallback, (XtCallbackProc) activate_editing_tools_window, (XtPointer) NULL); /* Separator 1 */ tools_sep_1 = XmCreateSeparator(tools_menu_pane, "tools sep 1", NULL, 0); XtManageChild(tools_sep_1); /* Region cut button*/ region_cut_button = XmCreatePushButton(tools_menu_pane, "Region Cut", NULL, 0); /* XtManageChild(region_cut_button); */ XtAddCallback(region_cut_button, XmNactivateCallback, (XtCallbackProc) region_cut_callback, (XtPointer) NULL); /* Separator 2 */ tools_sep_2 = XmCreateSeparator(tools_menu_pane, "tools sep 2", NULL, 0); XtManageChild(tools_sep_2); /* Zoom button */ zoom_button = XmCreatePushButton(tools_menu_pane, "Zoom ... ", NULL, 0); XtManageChild(zoom_button); create_zoom_dialog(parent); XtAddCallback(zoom_button, XmNactivateCallback, (XtCallbackProc) activate_zoom_dialog, (XtPointer) NULL); /* attach the tools menu pane to it. */ argcount = 0; XtSetArg(args[argcount], XmNsubMenuId, tools_menu_pane); argcount++; tools_menu_button = XmCreateCascadeButton(parent, "Tools ", args, argcount); XtManageChild(tools_menu_button); }
int main(int argc, char **argv) { Widget toplevel, nb, b, tf, cw; XtAppContext app; Arg al[10]; int ac; XtSetLanguageProc(NULL, NULL, NULL); toplevel = XtVaAppInitialize(&app, "Notebook", NULL, 0, &argc, argv, NULL, NULL); ac = 0; XtSetArg(al[ac], XmNbindingType, XmSOLID); ac++; nb = XmCreateNotebook(toplevel, "notebook", al, ac); ac = 0; XtSetArg(al[ac], XmNnotebookChildType, XmPAGE); ac++; XtSetArg(al[ac], XmNpageNumber, 1); ac++; tf = XmCreateTextField(nb, "tf", al, ac); XtManageChild(tf); ac = 0; XtSetArg(al[ac], XmNnotebookChildType, XmPAGE); ac++; XtSetArg(al[ac], XmNpageNumber, 2); ac++; b = XmCreatePushButton(nb, "quit", al, ac); XtManageChild(b); XtAddCallback(b, XmNactivateCallback, Quit, NULL); ac = 0; XtSetArg(al[ac], XmNpageNumber, 1); ac++; b = XmCreatePushButton(nb, "Editor", al, ac); XtManageChild(b); ac = 0; XtSetArg(al[ac], XmNpageNumber, 2); ac++; b = XmCreatePushButton(nb, "Quit", al, ac); XtManageChild(b); XtManageChild(nb); XtRealizeWidget(toplevel); check_geometry(toplevel); LessTifTestMainLoop(toplevel); exit(0); }
void CreateMainW(Widget w, String name) { Widget Form, MenuBar, Label, FileCascade, FileMenu; Widget Cascade, CascadeMenu, wch; Form = XmCreateForm(w, name, NULL, 0); MenuBar = XmCreateMenuBar(Form, "menubar", NULL, 0); XtVaSetValues(MenuBar, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); Label = XmCreateLabel(Form, "ExtTest Test Application", NULL, 0); XtVaSetValues(Label, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, MenuBar, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); FileCascade = XmCreateCascadeButton(MenuBar, "File", NULL, 0); FileMenu = XmCreatePulldownMenu(MenuBar, "filemenu", NULL, 0); XtVaSetValues(FileCascade, XmNsubMenuId, FileMenu, NULL); Cascade = XmCreateCascadeButton(FileMenu, "Cascade", NULL, 0); XtManageChild(Cascade); XtManageChild(wch = XmCreatePushButton(FileMenu, "Modeless Dialog", NULL, 0)); XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) XmDIALOG_MODELESS); XtManageChild(wch = XmCreatePushButton(FileMenu, "Two Modeless Dialogs", NULL, 0)); XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) 42); XtManageChild(wch = XmCreatePushButton(FileMenu, "Two Modeless Dialogs Cascaded", NULL, 0)); XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) 43); XtManageChild(wch = XmCreatePushButton(FileMenu, "Application Modal Dialog", NULL, 0)); XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) XmDIALOG_APPLICATION_MODAL); XtManageChild(wch = XmCreatePushButton(FileMenu, "Two Application Modal Dialogs", NULL, 0)); XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) 44); XtManageChild(wch = XmCreatePushButton(FileMenu, "Full Application Modal Dialog", NULL, 0)); XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) XmDIALOG_FULL_APPLICATION_MODAL); XtManageChild(XmCreatePushButton(FileMenu, "Quit", NULL, 0)); CascadeMenu = XmCreatePulldownMenu(FileMenu, "cascademenu", NULL, 0); XtVaSetValues(Cascade, XmNsubMenuId, CascadeMenu, NULL); XtManageChild(XmCreatePushButton(CascadeMenu, "Test1", NULL, 0)); XtManageChild(wch = XmCreatePushButton(CascadeMenu, "Test2", NULL, 0)); XtAddCallback(wch, XmNarmCallback, DumpCB, (XtPointer) NULL); XtManageChild(FileCascade); XtManageChild(MenuBar); XtManageChild(Label); XtManageChild(Form); } /* CreateMainW */
// // create a LABEL + Edit line + an apply button // void InvAnnotationEditor::createEditLine(Widget parent) { Arg args[5]; int i(0); Widget rc = XmCreateRowColumn(parent, (char *)"rc", NULL, 0); // XtSetArg(args[i], XmNlabelString, descStr); i++; i = 0; XmString descStr = XmStringCreateSimple((char *)"enter annotation text:"); XtSetArg(args[i], XmNlabelString, descStr); i++; Widget description = XmCreateLabel(rc, (char *)"description", args, 1); mTextField_ = XmCreateTextField(rc, (char *)"tf", NULL, 0); Widget applyBut = XmCreatePushButton(rc, (char *)"Apply", NULL, 0); XtAddCallback(applyBut, XmNactivateCallback, editApplyCB, (XtPointer) this); // manage all XtManageChild(rc); XtManageChild(description); XtManageChild(mTextField_); XtManageChild(applyBut); }
int main(int argc, char *argv[]) { int n; Arg args[10]; XtAppContext app; Widget toplevel, button; XmString label, label1, label2; setlocale(LC_ALL, ""); //建立顶级窗口 toplevel = XtVaAppInitialize(&app, "FontList1", NULL, 0, &argc, argv, NULL, NULL); //建立按钮上标签的字符串 label1 = XmStringCreate("复合字符串Testing", "small"); label2 = XmStringCreate("大字体Testing", "large"); label = XmStringConcat(label1, label2); n = 0; XtSetArg(args[n], XmNlabelString, label); n++; button = XmCreatePushButton(toplevel, "pushbutton", args, n); XtManageChild(button); //显示窗口 XtRealizeWidget(toplevel); //进入事件循环 XtAppMainLoop(app); }
static Widget create_tictactoe(Widget parent) { static Widget board = 0; if (board != 0) return board; install_images(); Arg args[10]; int arg = 0; XtSetArg(args[arg], XmNorientation, XmHORIZONTAL); arg++; XtSetArg(args[arg], XmNpacking, XmPACK_COLUMN); arg++; XtSetArg(args[arg], XmNnumColumns, 3); arg++; board = XmCreateRowColumn(parent, XMST("board"), args, arg); for (int i = 1; i <= 9; i++) { arg = 0; buttons[i] = XmCreatePushButton(board, XMST("field"), args, arg); XtManageChild(buttons[i]); XtAddCallback(buttons[i], XmNactivateCallback, MakeMoveCB, XtPointer(i)); } XtManageChild(board); return board; }
void make_button(QSP_ARG_DECL Screen_Obj *sop) { #ifdef HAVE_MOTIF Arg al[10]; int ac = 0; /* set geometry and placement */ XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNtopOffset, curr_panel->po_curry); ac++; XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++; XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNleftOffset, curr_panel->po_currx); ac++; XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++; sop->so_obj = XmCreatePushButton(curr_panel->po_panel_obj, (char *)sop->so_name, al, ac); /* Save object position */ sop->so_x = curr_panel->po_currx; sop->so_y = curr_panel->po_curry; /* add callback function */ XtAddCallback(sop->so_obj, XmNactivateCallback, button_func, NULL); /* manage the child */ XtManageChild(sop->so_obj); #endif /* HAVE_MOTIF */ }
void make_menu_choice(QSP_ARG_DECL Screen_Obj *mip, Screen_Obj *parent) { #ifdef HAVE_MOTIF Arg al[5]; int ac = 0; XtSetArg(al[ac], XmNy, dialog_y); ac++; #ifdef FOOBAR if(popups_supported) { /* XmCreatePopupMenu works on SGI and X, but not with OPENWIN */ mip->so_obj = XtVaCreateManagedWidget(mip->so_name, xmPushButtonWidgetClass, parent->so_obj, NULL); XtAddCallback(mip->so_obj, XmNactivateCallback, button_func, NULL); } else #endif /* FOOBAR */ { mip->so_obj = XmCreatePushButton(parent->so_obj, (char *)mip->so_name, al, ac); XtManageChild(mip->so_obj); XtAddCallback(mip->so_obj, XmNactivateCallback, button_func, NULL); dialog_y += BUTTON_HEIGHT + GAP_HEIGHT + 15; } #endif /* HAVE_MOTIF */ }
int main(int argc, char **argv) { toplevel = XtVaAppInitialize(&app_context, "listTest", NULL, 0, &argc, argv, NULL, NULL); push = XmCreatePushButton(toplevel, "push", NULL, 0); XtVaSetValues(push, XtVaTypedArg, XmNlabelString, XtRString, "Push me !", 9, NULL); XtAddCallback(push, XmNactivateCallback, Push, box); XtManageChild(push); XtRealizeWidget(toplevel); LessTifTestWaitForIt(toplevel); LessTifTestPushButton(push); LessTifTestMainLoop(toplevel); XtAppMainLoop(app_context); exit(0); }
/* * allocate storage & subwidgets used by week view */ static void allocator(Calendar *c) { int n; Week *w; Arg args[1]; /* main storage for other week data */ calendar->view->week_info = (caddr_t) ckalloc(sizeof(Week)); w = (Week *)c->view->week_info; /* navigation buttons to day view */ w->hot_button = (Widget *) ckalloc(7 * sizeof(Widget)); /* Set the recomputeSize of the PushButtons to False, to prevent a loop where a SetValues is done on the PushButton's width from the exposeCallback of the DrawingArea */ XtSetArg(args[0], XmNrecomputeSize, False); for (n=0; n<7; n++) { w->hot_button[n] = XmCreatePushButton(c->canvas, "week2day", args, 1); XtAddCallback(w->hot_button[n],XmNactivateCallback, quick_button_cb, (XtPointer) (intptr_t) n); } /* selection info (and init its permanent attributes) */ w->current_selection = ckalloc(sizeof(Selection)); ((Selection*)w->current_selection)->row = 0; ((Selection*)w->current_selection)->nunits = 1; }
static Widget netlist_button (Widget parent, char *name, char *string, Widget top, Widget bottom, Widget left, Widget right, XtCallbackProc callback, void *user_data) { Widget rv; XmString str; #define NLB_W(w) if (w == NLB_FORM) { stdarg(XmN ## w ## Attachment, XmATTACH_FORM); } \ else if (w) { stdarg(XmN ## w ## Attachment, XmATTACH_WIDGET); \ stdarg (XmN ## w ## Widget, w); } NLB_W (top); NLB_W (bottom); NLB_W (left); NLB_W (right); str = XmStringCreatePCB (string); stdarg(XmNlabelString, str); rv = XmCreatePushButton (parent, name, args, n); XtManageChild (rv); if (callback) XtAddCallback (rv, XmNactivateCallback, callback, (XtPointer)user_data); XmStringFree(str); return rv; }
IconButton::IconButton(std::string name, PulldownMenu* pulldownMenu) { widget = XmCreatePushButton(pulldownMenu->getWidget(), (char*)name.c_str(), NULL, 0); XtAddCallback(widget, XmNactivateCallback, activateCallback, this); //XtAddCallback(widget, XmNarmCallback, armCallback, this); //XtAddCallback(widget, XmNdisarmCallback, disarmCallback, this); XtManageChild(widget); }
/* -------------------------------------------------------------------- */ static void CreateStatsWindow() { Arg args[8]; Cardinal n; Widget drFrame, drRC, b[3]; n = 0; StatsShell = XtCreatePopupShell("statsShell", topLevelShellWidgetClass, AppShell, args, n); n = 0; StatsWindow = XmCreateForm(StatsShell, (char *)"statsForm", args, n); n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; drFrame = XmCreateFrame(StatsWindow, (char *)"buttonFrame", args, n); XtManageChild(drFrame); n = 0; drRC = XmCreateRowColumn(drFrame, (char *)"buttonRC", args, n); XtManageChild(drRC); n = 0; b[0] = XmCreatePushButton(drRC, (char *)"dismissButton", args, n); b[1] = XmCreatePushButton(drRC, (char *)"printButton", args, n); b[2] = XmCreatePushButton(drRC, (char *)"parmsButton", args, n); XtManageChildren(b, 3); XtAddCallback(b[0], XmNactivateCallback, DismissStats, StatsWindow); XtAddCallback(b[1], XmNactivateCallback, PrintStats, NULL); XtAddCallback(b[2], XmNactivateCallback, EditStatsParms, NULL); n = 0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, drFrame); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; statsText = XmCreateScrolledText(StatsWindow, (char *)"statsText", args, n); XtManageChild(statsText); } /* END CREATESTATSWINDOW */
int main(int argc, char *argv[]) { int i, n; Arg args[10]; XtAppContext app; Widget toplevel, rowcol, sep, button; XmString str_months[12]; setlocale(LC_ALL, ""); //建立顶级窗口 toplevel = XtVaAppInitialize(&app, "Text", NULL, 0, &argc, argv, NULL, NULL); //建立rowcolumn 布局 n = 0; XtSetArg(args[n], XmNpacking, XmPACK_TIGHT); n++; rowcol = XmCreateRowColumn(toplevel, "rowcol", args, n); XtManageChild(rowcol); //建立输入条 n = 0; XtSetArg(args[n], XmNvalue, "输入条"); n++; textf = XmCreateTextField(rowcol, "textf", args, n); XtManageChild(textf); //建立回调 XtAddCallback(textf, XmNactivateCallback, (XtCallbackProc)checkit, NULL); //建立输入区 n = 0; XtSetArg(args[n], XmNrows, 10); n++; XtSetArg(args[n], XmNcolumns, 40); n++; XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; XtSetArg(args[n], XmNvalue, "输入区域\n请测试"); n++; text = XmCreateScrolledText(rowcol, "text", args, n); //text = XmCreateText(rowcol, "text", args, n); XtManageChild(text); //建立分隔符 sep = XmCreateSeparator(rowcol, "separator", NULL, 0); XtManageChild(sep); //建立一个普通按钮 button = XmCreatePushButton(rowcol, "打印输入条和文本区内容", NULL, 0); XtManageChild(button); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)checkit, NULL); //显示窗口 XtRealizeWidget(toplevel); //进入事件循环 XtAppMainLoop(app); }
int main(int argc, char **argv) { XtAppContext app; Arg arg[1]; toplevel = XtVaAppInitialize(&app, "listTest", NULL, 0, &argc, argv, fallbacks, NULL); formw = XmCreateForm(toplevel, "form", NULL, 0); button1 = XmCreatePushButton(formw, "button", NULL, 0); listw = XmCreateScrolledList(formw, "list", arg, 0); XtVaSetValues(XtParent(listw), XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, button1, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XtVaSetValues(button1, XmNtopAttachment, XmATTACH_NONE, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XtManageChild(formw); XtManageChild(button1); XtManageChild(listw); XtRealizeWidget(toplevel); XtAddCallback(button1, XmNactivateCallback, button_cb1, NULL); XdbPrintTree(toplevel); { static XtWidgetGeometry Expected[] = { CWWidth | CWHeight , 56, 72, 78, 131, 0,0,0, /* form */ CWWidth | CWHeight | CWX | CWY, 0, 106, 78, 25, 0,0,0, /* button */ CWWidth | CWHeight | CWX | CWY, 0, 0, 78, 106, 0,0,0, /* listSW */ CWWidth | CWHeight | CWX | CWY, 63, 0, 15, 87, 0,0,0, /* VertScrollBar */ CWWidth | CWHeight | CWX | CWY, 0, 91, 59, 15, 0,0,0, /* HorScrollBar */ CWWidth | CWHeight | CWX | CWY, 0, 0, 59, 87, 0,0,0, /* list */ }; /* toplevel should be replaced with to correct applicationShell */ PrintDetails(toplevel, Expected); } LessTifTestMainLoop(toplevel); exit(0); }
Widget make_menu_item(Widget menu, char *label, char *command) { Widget button; button = XmCreatePushButton(menu, label, NULL, 0); XtManageChild(button); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc) callback, command); return button; }
static void createSubmenuItem(Widget parent, char *name, XtCallbackProc p) { Widget btn; btn = XmCreatePushButton(parent, name, NULL, 0); XtManageChild(btn); if (p) XtAddCallback(btn, XmNactivateCallback, p, (XtPointer)name); else XtSetSensitive(btn, False); }
static Widget style_button (int i) { Widget pb, set; n = 0; stdarg (XmNtopAttachment, XmATTACH_WIDGET); stdarg (XmNtopWidget, i ? style_pb[i - 1] : value_form); stdarg (XmNleftAttachment, XmATTACH_FORM); stdarg (XmNlabelString, XmStringCreatePCB ("Name")); set = XmCreatePushButton (style_dialog, "style", args, n); XtManageChild (set); XtAddCallback (set, XmNactivateCallback, (XtCallbackProc) style_name_cb, (XtPointer) (size_t) i); n = 0; stdarg (XmNtopAttachment, XmATTACH_WIDGET); stdarg (XmNtopWidget, i ? style_pb[i - 1] : value_form); stdarg (XmNleftAttachment, XmATTACH_WIDGET); stdarg (XmNleftWidget, set); stdarg (XmNlabelString, XmStringCreatePCB ("Set")); set = XmCreatePushButton (style_dialog, "style", args, n); XtManageChild (set); XtAddCallback (set, XmNactivateCallback, (XtCallbackProc) style_set_cb, (XtPointer) (size_t) i); n = 0; stdarg (XmNtopAttachment, XmATTACH_WIDGET); stdarg (XmNtopWidget, i ? style_pb[i - 1] : value_form); stdarg (XmNrightAttachment, XmATTACH_FORM); stdarg (XmNleftAttachment, XmATTACH_WIDGET); stdarg (XmNleftWidget, set); stdarg (XmNlabelString, XmStringCreatePCB (PCB->RouteStyle[i].Name)); stdarg (XmNindicatorType, XmONE_OF_MANY); stdarg (XmNalignment, XmALIGNMENT_BEGINNING); pb = XmCreateToggleButton (style_dialog, "style", args, n); XtManageChild (pb); XtAddCallback (pb, XmNvalueChangedCallback, (XtCallbackProc) style_selected, (XtPointer) (size_t) i); return pb; }
int main(int argc, char *argv[]) { XtAppContext app; Widget root_widget; Widget row_column; Widget update_button; Widget close_button; NodeInfoWidget *node_info_widget; int i; void update_callback(Widget, XtPointer, XtPointer); void close_callback(Widget, XtPointer, XtPointer); XtSetLanguageProc(NULL, NULL, NULL); root_widget = XtVaOpenApplication(&app, "Node Info", NULL, 0, &argc, argv, NULL, sessionShellWidgetClass, NULL); row_column = XmCreateRowColumn(root_widget, "MainRowCol", NULL, 0); node_info_widget = create_node_info_widget(&row_column); update_button = XmCreatePushButton(row_column, "Update", NULL, 0); XtAddCallback(update_button, XmNactivateCallback, update_callback, node_info_widget); close_button = XmCreatePushButton(row_column, "Close", NULL, 0); XtAddCallback(close_button, XmNactivateCallback, close_callback, NULL); XtManageChild(update_button); XtManageChild(close_button); XtManageChild(row_column); XtRealizeWidget(root_widget); XtAppMainLoop(app); free(node_info_widget); return 0; }
Widget CreatePushbutton(Widget parent, char* name, XtCallbackProc callback, XtPointer client_data) { Widget button; Arg args[20]; int n = 0; button =XmCreatePushButton(parent, name, args, n); XtManageChild(button); XtAddCallback(button, XmNactivateCallback, callback, client_data); return(button); }
void InvPartEditor::createRegFrame(Widget parent) { Widget regFrame = XtVaCreateManagedWidget( "RegFrame", xmFrameWidgetClass, parent, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNleftOffset, 5, XmNrightOffset, 5, XmNbottomOffset, 5, XmNtopOffset, 5, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_WIDGET, //XmNbottomWidget, push_button, NULL); Arg args[5]; //Now the togglebutton and textfield for the reference part XtSetArg(args[0], XmNorientation, XmVERTICAL); Widget regCol = XtCreateManagedWidget("parent", xmRowColumnWidgetClass, regFrame, args, 1); XmString descStr = XmStringCreateSimple((char *)"Enter regular expression to specify parts"); XtSetArg(args[0], XmNlabelString, descStr); Widget description = XmCreateLabel(regCol, (char *)"description", args, 1); Widget visible = XmCreatePushButton(regCol, (char *)"visible", NULL, 0); Widget invisible = XmCreatePushButton(regCol, (char *)"invisible", NULL, 0); Widget invert = XmCreatePushButton(regCol, (char *)"invert", NULL, 0); XtManageChild(description); XtManageChild(visible); XtManageChild(invisible); XtManageChild(invert); //A text field to specify part-ids by a given regular expression //since this widget is referenced by several callback //it is no local variable but a member of the class. partname_ = XmCreateTextField(regCol, (char *)"partname_", NULL, 0); XtManageChild(partname_); XtAddCallback(invert, XmNactivateCallback, invertByNameCB, (XtPointer) this); XtAddCallback(invisible, XmNactivateCallback, unselectByNameCB, (XtPointer) this); XtAddCallback(visible, XmNactivateCallback, selectByNameCB, (XtPointer) this); }
int main (int argc, char**argv) { // The worlds most useless user interface Widget top_level = XtVaAppInitialize (NULL, "buttontest", NULL, 0, &argc, argv, NULL, NULL); Widget button = XmCreatePushButton (top_level, "change", 0, 0); XtManageChild (button); XtAddCallback (button, XmNactivateCallback, ActivateCB, NULL); // A reactor beastie. ACE_XtReactor xreactor (XtWidgetToApplicationContext (top_level)); ACE_Reactor reactor (&xreactor); // Print a message when data is recv'd on stdin... ACE_Event_Handler *stdin_; ACE_NEW_RETURN (stdin_, Stdin (new Stdout (&reactor)), -1); reactor.register_handler (stdin_, ACE_Event_Handler::READ_MASK); // Print a message every 10 seconds. if (reactor.schedule_timer (stdin_, 0, ACE_Time_Value (10), ACE_Time_Value (10)) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); // Show the top_level widget. XtRealizeWidget (top_level); // Demonstrate Reactor/Xt event loop unification. XtAppMainLoop (XtWidgetToApplicationContext (top_level)); return 0; }