/* ** Generated by X-Designer */ /* **LIBS: -lXm -lXt -lX11 */ #include #include #include #include #include #include #include #include #include extern Boolean aardvarkConverter (); extern Boolean objStringConverter (); Widget appshell = (Widget) NULL; Widget rowcol = (Widget) NULL; Widget text1_sw = (Widget) NULL; Widget text1 = (Widget) NULL; Widget text2_sw = (Widget) NULL; Widget text2 = (Widget) NULL; void create_appshell (display, app_name, app_argc, app_argv) Display *display; char *app_name; int app_argc; char **app_argv; { Arg al[64]; /* Arg List */ register int ac = 0; /* Arg Count */ XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++; XtSetArg(al[ac], XmNtitle, "Text Sources"); ac++; XtSetArg(al[ac], XmNargc, app_argc); ac++; XtSetArg(al[ac], XmNargv, app_argv); ac++; appshell = XtAppCreateShell ( app_name, "XApplication", applicationShellWidgetClass, display, al, ac ); ac = 0; XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++; rowcol = XmCreateRowColumn ( appshell, "rowcol", al, ac ); ac = 0; XtSetArg(al[ac], XmNcolumns, 38); ac++; XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++; XtSetArg(al[ac], XmNrows, 8); ac++; XtSetArg(al[ac], XmNwordWrap, TRUE); ac++; XtSetArg(al[ac], XmNscrollHorizontal, FALSE); ac++; text1 = XmCreateScrolledText ( rowcol, "text1", al, ac ); ac = 0; text1_sw = XtParent ( text1 ); XmTextSetString ( text1, "These two text widgets share a common text source\n\nThis means that any edits I make in one text widget will be automatically reflected in the other.\n\nThe text widgets can be displaying different parts of the source at the same time." ); XtSetArg(al[ac], XmNcolumns, 24); ac++; XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++; XtSetArg(al[ac], XmNwordWrap, TRUE); ac++; XtSetArg(al[ac], XmNscrollHorizontal, FALSE); ac++; text2 = XmCreateScrolledText ( rowcol, "text2", al, ac ); ac = 0; text2_sw = XtParent ( text2 ); XmTextSetSource(text2, XmTextGetSource(text1), 0, 0 ); XtManageChild(text1); XtManageChild(text2); XtManageChild ( rowcol); } XtAppContext app_context; Display *display; /* Display */ void change(Widget w, XtPointer client, XtPointer call) { char *s = (char *)client; fprintf(stderr, "%s in widget %s\n", s, XtName(w)); } int main (argc,argv) int argc; char **argv; { XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL ); XtToolkitInitialize (); app_context = XtCreateApplicationContext (); display = XtOpenDisplay (app_context, NULL, argv[0], "XApplication", NULL, 0, &argc, argv); if (!display) { printf("%s: can't open display, exiting...\n", argv[0]); exit (-1); } create_appshell ( display, argv[0], argc, argv ); XtRealizeWidget (appshell); /* Check if a change callback is reported from both widgets */ XtAddCallback(text1, XmNvalueChangedCallback, change, XmNvalueChangedCallback); XtAddCallback(text2, XmNvalueChangedCallback, change, XmNvalueChangedCallback); XtAddCallback(text1, XmNmodifyVerifyCallback, change, XmNmodifyVerifyCallback); XtAddCallback(text2, XmNmodifyVerifyCallback, change, XmNmodifyVerifyCallback); { static XtWidgetGeometry Expected[] = { CWWidth | CWHeight , 56, 72, 455, 128, 0,0,0, /* rowcol */ CWWidth | CWHeight | CWX | CWY, 3, 3, 265, 122, 0,0,0, /* text1SW */ CWWidth | CWHeight | CWX | CWY, 250, 0, 15, 122, 0,0,0, /* VertScrollBar */ CWWidth | CWHeight | CWX | CWY, 0, 0, 246, 122, 0,0,0, /* text1 */ CWWidth | CWHeight | CWX | CWY, 271, 3, 181, 122, 0,0,0, /* text2SW */ CWWidth | CWHeight | CWX | CWY, 166, 0, 15, 122, 0,0,0, /* VertScrollBar */ CWWidth | CWHeight | CWX | CWY, 0, 0, 162, 122, 0,0,0, /* text2 */ }; PrintDetails(appshell,Expected); }; LessTifTestMainLoop(appshell); exit (0); }