home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
n
/
newmarch.zip
/
MOTIF_HE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-08
|
3KB
|
129 lines
/* Author: $Author: jan $
* File: $Source: /usr/usrs/jan/desktop/X_Book.boo/programs/RCS/motif_hello.c,v $
* Date: $Date: 1992/09/09 00:10:04 $
* Revision: $Revision: 1.1 $
*/
#include "copyright.h"
#include <stdio.h>
#include <Xm/DrawingA.h>
/*------------------------------------------------------
** Forward Declarations
*/
void main ();
void CreateApplication ();
void display_somethingCB ();
/*------------------------------------------------------
** Global Variables
*/
#define MAX_ARGS 20
#define Class_name "Draw"
Widget draw_area; /* Drawing Area widget */
Display *display; /* the display device */
Screen *screen; /* the screen on the display */
Window draw_window; /* the drawing area
widget's window */
GC gc;
/*-----------------------------------------------------
** Create a graphics context using default values, and
** return it in the pointer gc
*/
GC
getGC ()
{ GC gc;
gc = XCreateGC (display, draw_window,
(unsigned long) 0, NULL);
XSetForeground (display, gc,
BlackPixelOfScreen (screen));
XSetBackground (display, gc,
WhitePixelOfScreen (screen));
return (gc);
}
/*------------------------------------------------------
** Write a string
** and draw a circle
*/
void display_somethingCB (w, client_data, call_data)
Widget w;
caddr_t client_data;
caddr_t call_data;
{
/* the proverbial string */
XDrawImageString (display, draw_window, gc,
10, 10, "Hello world",
strlen ("Hello world"));
/* and a world (circle) to go with it */
XDrawArc (display, draw_window, gc,
30, 30,
100, 100,
0, 360*64);
XFlush (display);
}
/*------------------------------------------------------
** main - main logic for application
*/
void main (argc,argv)
unsigned int argc;
char **argv;
{
Widget app_shell;
app_shell = XtInitialize(NULL,
Class_name,
NULL,
0,
&argc, argv);
/* set up all the sub-widgets */
CreateApplication(app_shell);
XtRealizeWidget (app_shell);
/* Now get info about windows, etc
** The XtWindow() _must_ occur after XtRealize() has
** created the Drawing Area's window
*/
display = XtDisplay (draw_area);
draw_window = XtWindow (draw_area);
screen = XtScreen (draw_area);
gc = getGC ();
/* Get and dispatch events.
*/
XtMainLoop ();
}
/*--------------------------------------------------
** CreateApplication - create main window
*/
void CreateApplication (parent)
Widget parent;
{
Arg args[MAX_ARGS];
register int n;
/* Create Drawing Area
** Make it a reasonable size
*/
n = 0;
XtSetArg (args[n], XmNwidth, 300); n++;
XtSetArg (args[n], XmNheight, 300); n++;
draw_area = XmCreateDrawingArea (parent, "an_area",
args, n);
XtAddCallback (draw_area, XmNexposeCallback,
display_somethingCB, NULL);
XtManageChild (draw_area);
}