home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
n
/
newmarch.zip
/
FORM2A.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-08
|
5KB
|
150 lines
/* Author: $Author: jan $
* File: $Source: /usr/usrs/jan/desktop/X_Book.boo/programs/RCS/form2a.c,v $
* Date: $Date: 1992/09/09 00:09:56 $
* Revision: $Revision: 1.1 $
*/
#include "copyright.h"
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/PushB.h>
#include <Xm/Form.h>
/*-------------------------------------------------------------
** Forward Declarations
*/
void main (); /* main logic for application */
void CreateApplication (); /* create main window */
void QuitCB (); /* callback for quit button */
/*-------------------------------------------------------------
** Global Variables
*/
#define MAX_ARGS 20
#define Class_name "FourButtons"
static XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
/*-------------------------------------------------------------
** main - main logic for application
*/
void main (argc,argv)
unsigned int argc;
char **argv;
{
Widget app_shell; /* ApplicationShell */
/* Initialize toolkit, open the display and create the toplevel widget. */
app_shell = XtInitialize(argv[0], /* application name */
Class_name, /* class name */
NULL, /* options */
0, /* number of options */
&argc, argv);
/* set up all the sub-widgets */
CreateApplication(app_shell);
XtRealizeWidget (app_shell);
/* Get and dispatch events.
*/
XtMainLoop ();
}
/*-------------------------------------------------------------
** CreateApplication - create main window
** This must be customised for each application.
*/
void CreateApplication (parent)
Widget parent; /* parent widget */
{
Widget row_column; /* RowColumn */
Widget widget1, widget2, widget3, widget4;
Arg args[MAX_ARGS]; /* arg list */
register int n; /* arg count */
/* Create RowColumn Window.
*/
n = 0;
row_column = XmCreateForm (parent, "rowColumn", args, n);
XtManageChild (row_column);
n = 0;
widget1 = XmCreatePushButton (row_column, "Widget 1", args, n);
XtAddCallback (widget1, XmNactivateCallback, QuitCB, NULL);
n = 0;
widget2 = XmCreatePushButton (row_column, "Long Widget 2", args, n);
XtAddCallback (widget2, XmNactivateCallback, QuitCB, NULL);
n = 0;
widget3 = XmCreatePushButton (row_column, "Widget 3", args, n);
XtAddCallback (widget3, XmNactivateCallback, QuitCB, NULL);
n = 0;
widget4 = XmCreatePushButton (row_column, "Long Widget 4", args, n);
XtAddCallback (widget4, XmNactivateCallback, QuitCB, NULL);
n = 0;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNrightPosition, 50); n++;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNbottomPosition, 50); n++;
XtSetValues (widget1, args, n);
n = 0;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNrightPosition, 50); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNtopPosition, 50); n++;
XtSetValues (widget2, args, n);
n = 0;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNleftPosition, 50); n++;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNbottomPosition, 50); n++;
XtSetValues (widget3, args, n);
n = 0;
XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNleftPosition, 50); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
XtSetArg (args[n], XmNtopPosition, 50); n++;
XtSetValues (widget4, args, n);
XtManageChild (widget1);
XtManageChild (widget2);
XtManageChild (widget3);
XtManageChild (widget4);
}
/*-------------------------------------------------------------
** QuitCB - callback for quit button
*/
void QuitCB (w, client_data, call_data)
Widget w; /* widget id */
caddr_t client_data; /* data from application */
caddr_t call_data; /* data from widget class */
{
/* Terminate the application.
*/
printf("button was pressed\n");
exit (0);
}