DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T x

⟦0af7dff4a⟧ TextFile

    Length: 2116 (0x844)
    Types: TextFile
    Names: »xclickcount.c«

Derivation

└─⟦8648bda34⟧ Bits:30007244 EUUGD5_II: X11R5
    └─⟦2ca9b63e1⟧ »./contrib-1/contrib-1.00« 
        └─⟦a8392fb20⟧ 
            └─⟦this⟧ »contrib/examples/OReilly/Vol4/ch02/xclickcount.c« 

TextFile

/*
 * Copyright 1989 O'Reilly and Associates, Inc.
 * See ../Copyright for complete rights and liability information.
 */

/*
 * xclickcount.c - simple program to count button clicks.
 */

#include <stdio.h>

/*
 * Include files required for all Toolkit programs
 */
#include <X11/Intrinsic.h>	/* Intrinsics Definitions */
#include <X11/StringDefs.h>	/* Standard Name-String definitions */

/*
 * Public include file for widgets we actually use in this file.
 */
#include <X11/Xaw/Label.h>		/* Athena Label Widget */

#define MAXLEN 50

char userstring[MAXLEN];

/*ARGSUSED*/
static void IncrementCount(w, event, params, num_params)
Widget w;
XButtonEvent *event;
String *params; 
Cardinal *num_params;
{
	char string[MAXLEN];
	static int count;

	count++;

	(void) sprintf(string, "%s: %d", userstring, count);

	XtVaSetValues(w, 
			XtNwidth, 100,
			XtNlabel, string,
			NULL);
}

main(argc, argv)
int argc;
char **argv;
{
	XtAppContext app_context;
	Widget topLevel, hello;
	String trans =
	"<BtnDown>:	IncrementCount()";

	XtTranslations compiled_trans;

	static XtActionsRec hello_actions[] = {
		{"IncrementCount", IncrementCount},
	};

	char *p;

    topLevel = XtVaAppInitialize(
        &app_context,       /* Application context */
        "XClickcount",         /* Application class */
        NULL, 0,            /* command line option list */
        &argc, argv,        /* command line args */
        NULL,               /* for missing app-defaults file */
        NULL);              /* terminate varargs list */

	hello = XtVaCreateManagedWidget(
		"hello",		/* arbitrary widget name */
		labelWidgetClass,	/* widget class from Label.h */
		topLevel,	/* parent widget*/
		NULL);		/* terminate varargs list */

	XtVaGetValues(hello, 
		XtNlabel, &p,
		NULL);

	strcpy(userstring, p);

	XtAppAddActions(app_context, hello_actions, 1);

	compiled_trans = XtParseTranslationTable(trans);

	XtVaSetValues(hello, 
		XtNtranslations, compiled_trans,
		NULL);
	/*
	 *  Create windows for widgets and map them.
	 */
	XtRealizeWidget(topLevel);

	/*
	 *  Loop for events.
	 */
	XtAppMainLoop(app_context);
}