All pastes #613843 Raw Edit

Something

public text v1 · immutable
·published 2007-07-11 06:23 UTC
rendered paste body
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/AsciiText.h>

Arg args[1];
Widget window, box, label, form, button, text;

static void button_handler(Widget w, XtPointer callData, XtPointer clientData)
{
	String string;
	char msg[256];
	
	XtSetArg(args[0], XtNstring, &string);
	XtGetValues(text, args, 1);
	memset(&msg, '\0', 256);
	memcpy(&msg, "Hello, ", strlen("Hello, "));
	memcpy((&msg[0] + strlen(&msg[0])), string, strlen(string));
	memcpy((&msg[0] + strlen(&msg[0])), "! Where is your GNOME now!?", \
			strlen("! Where is your GNOME now!?"));
	
	XtVaSetValues(label, XtNlabel, &msg, NULL);
}


int main(int argc, char** argv)
{
	XtAppContext cx;

	window = XtVaAppInitialize(&cx, "Hello World", NULL, 0, \
				    &argc, argv, NULL, NULL);
	
	box = XtVaCreateManagedWidget("box", boxWidgetClass, window, NULL);

	label = XtVaCreateManagedWidget("label", labelWidgetClass, box, \
		XtNlabel, "Hi! What's your name?", XtNborderWidth, 0, NULL);

	form = XtVaCreateManagedWidget("form", formWidgetClass, \
		box, XtNsensitive, True, XtNborderWidth, 0, NULL);
	
	text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, \
		form, XtNheight, 20, XtNwidth, 500, NULL, NULL, NULL, NULL, \
		NULL);
	
	button = XtVaCreateManagedWidget("button", commandWidgetClass, form, \
		XtNlabel, "Okay", XtNfromVert, text, NULL);

	XtAddCallback(button, XtNcallback, button_handler, label);

	XtVaSetValues(text, XtNeditType, XawtextEdit, XtNdisplayCaret, True, \
		NULL);
	
	XtRealizeWidget(window);
	XtAppMainLoop(cx);
}