#include #include #include #include #include #include "/home/comp320/public_html/2002/general-support/boolean.h" XtAppContext app_context; Widget toplevel; /* The overall window. */ Widget form; /* The layout of the window. */ Widget quit_button; /* The button in the window. */ Widget new_button; /* The new button in the window. */ /* The callback function for the quit button. */ void quit_proc (Widget w, XtPointer client_data, XtPointer call_data) { XtDestroyApplicationContext (app_context); exit (0); } /* The callback function for the new button. */ void new_proc(Widget w, XtPointer client_data, XtPointer call_data) { static bool changing = true; if (changing) { /* Set label resource to a new string. */ XtVaSetValues (w, XtNlabel, "Am I changing?", NULL); } else { /* Set label resource to a new string. */ XtVaSetValues (w, XtNlabel, "Yes", NULL); } changing = !changing; } int main (int argc, char ** argv) { /* Create the window and its contents' appearance. */ toplevel = XtOpenApplication (&app_context, "XFirst", NULL, 0, &argc, argv, NULL, applicationShellWidgetClass, NULL, 0); form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, XtNhSpace, 10, NULL); quit_button = XtVaCreateManagedWidget ("quit_button", commandWidgetClass, form, XtNlabel, "Quit", NULL); new_button = XtVaCreateManagedWidget ("new_button", /* widget name */ commandWidgetClass, /* widget type */ form, /* parent widget */ XtNlabel, "I'm gonna change", /* initial label */ XtNwidth, 300, /* width in pixels */ XtNfromHoriz, quit_button, /* placed horizontally next to quit_button */ NULL /* end of arguments marker */ ); /* Create window's behavior. */ XtAddCallback (quit_button, XtNcallback, quit_proc, NULL); XtAddCallback (another_button, XtNcallback, another_proc, NULL); /* Display the window. */ XtRealizeWidget (toplevel); /* Infinite loop, waiting for events to happen. */ XtAppMainLoop (app_context); return 0; }