Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheFakeMontyOnTheRun/9984b82a30d3c147fcc439139a9ff6ff to your computer and use it in GitHub Desktop.
Save TheFakeMontyOnTheRun/9984b82a30d3c147fcc439139a9ff6ff to your computer and use it in GitHub Desktop.
Very simple XAW example
#include <stdlib.h>
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Label.h>
void
quit_callback (widget, client_data, call_data)
Widget widget;
caddr_t client_data;
caddr_t call_data;
{ exit (0);
}
main (argc, argv)
int argc;
char *argv[];
{ /* main */
Widget parent;
Arg args[20];
int n;
Widget pane_widget, quit_widget;
Widget label_widget;
/* Set up top−level shell widget */
parent = XtInitialize (argv[0], "Xaw1", NULL, 0, &argc, argv);
/* Set up pane to control whole application */
n = 0;
pane_widget = XtCreateManagedWidget ("pane",
panedWidgetClass, parent, args, n);
/* Set up command widget to act as a push button */
n = 0;
quit_widget = XtCreateManagedWidget ("quit",
commandWidgetClass,
pane_widget, args, n);
/* Set up a callback function */
XtAddCallback (quit_widget, XtNcallback, quit_callback, (caddr_t) NULL);
/* Set up label widget */
n = 0;
XtSetArg (args[n], XtNlabel, "This is a label.");
n++;
label_widget = XtCreateManagedWidget ("label",
labelWidgetClass,
pane_widget, args, n);
/* Map widgets and handle events */
XtRealizeWidget (parent);
XtMainLoop ();
}
@TheFakeMontyOnTheRun
Copy link
Author

Lifted (and fixed) from https://www.comp.nus.edu.sg/~cs3283/2001-semesterII/notes3.pdf

Use cc -oxaw xaw.c -lXt -lXaw to build.
On a Mac, you will need XQuartz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment