From: rchui@nswc-wo.nswc.navy.mil (Raymond Chui)
Newsgroups: fj.mail-lists.x-window
Subject: I need some hits for my exercises
Date: 10 Oct 92 13:13:02 GMT
Distribution: fj
Organization: Naval Surface Warfare Center - White Oak

Date: Wed, 7 Oct 1992 17:42:38 GMT
Message-Id: <1992Oct7.174238.5274@relay.nswc.navy.mil>
Newsgroups: comp.windows.x.motif,comp.windows.x

I am doing some exercises from O'Reilly book volume 6 the 
"Motif Programming Manual" at chapter 16. So far I created
a DrawingAreaWidget with a popup menu, and a FormWidget with
a menu bar, pulldown menu, the popup and pulldown menus have
some drawing function. I also combined the color_draw.c program 
(at chapter 10) into my program. I can draw line, circle, rectangle,
fill_circle and fill_rectangle with a selecting color. 
OK. Here are questions that I need someoen to help.

1) I want to do some drawing not only with a selecting color, I
also want to have a selecting pattern. Can someone out there give
me some hits, guide and help? 
  I look at Douglas Young book "Window System Programming and
applications with Xt" Motif Edition at chapter 10 draw.c. So far I
success made the pattern ToggleButtons, but failed to draw patterns
into the DrawAreaWidget. All I need is a "set_fill_pattern" function
other than the one Young wrote.

2) When I doing a draw circle or draw rectangle function, I must
press the mouse button very hard, otherwise just draw a line. But
when play Young's draw.c program, I don't need to press mouse
button very hard. I like the way Young's doing, But I can not
understand how Young call the "activate" register to the DrawAreaWidget.
Can someone out there explain to me? The way I create draw functions
as follow:

#include <....>
...
...

int objfunc;
....
....

main()

static XtCallbackRec command_info[] = {
     /* "Line", */ {lines, (XtPointer)0},
     /* "Circle", */ {circles, (XtPointer)1},
     /* "Rectangle", */ {rectangles,(XtPointer)2},
     /* "Filled Circle", */ {fill_circle, (XtPointer)3},
     /* "Filled Rectangle", */ {fill_rectangle, (XtPointer)4},
        {(XtCallbackProc) NULL, (caddr_t) NULL},

 };

....
....
....
	  drawing_a = XtVaCreateManagedWidget("drawing_a",
        xmDrawingAreaWidgetClass, sw, /* sw is the ScrollWindowWidget */
        XmNunitType, Xm1000TH_INCHES,
        XmNwidth, 5000,
        XmNheight, 5000,
        XmNinputCallback, command_info,
        NULL); 
...
...
...
	XtAppMainLoop(app);

void lines(....)
{
...
 if(objfunc != 0) return;
/* otherwise do draw line */
...
}
void circles(...)
{
....
	if(objfunc != 1) return;
/* otherwise do draw arc */
....
}
What I doing is change the "objfunc" value by toggle the ToggleButton
from either pulldown menu or popup menu.

Can someone out there tell me is(are) there other better way(s) do the
drawing functions?

Thank you in advance!
-- 
Raymond H. Chui
NSWC N62
10901 New Hampshire Ave.
Silver Spring, MD 20903-5000
U.S.A.
Voice:1-301-394-5192 Fax:1-301-394-5835
E-Mail:rchui@nswc-wo.nswc.navy.mil
 _ __                                  _    ,    __
' )  )                           /    ' )  /    /  ) /
 /--' __. , , ____   ______   __/      /--/    /    /_  . . o
/  \_(_(_(_/_/) ) )_(_) /) )_(_(_     /  ( o  (__/ / /_(_/_(_
          /
         '