Created
March 11, 2024 23:30
-
-
Save TheFakeMontyOnTheRun/9984b82a30d3c147fcc439139a9ff6ff to your computer and use it in GitHub Desktop.
Very simple XAW example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 (); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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