| 1 |
#include <stdlib.h> |
| 2 |
#include <X11/StringDefs.h> |
| 3 |
#include <Xaw/Box.h> |
| 4 |
#include <Xaw/Simple.h> |
| 5 |
#include <Xaw/Command.h> |
| 6 |
#include <X11/Xmu/Drawing.h> |
| 7 |
|
| 8 |
/* |
| 9 |
this is the draw function. it uses two pencils (GC) with |
| 10 |
different colors. one pencil is used to draw the logo, |
| 11 |
the other is used to fill the background. |
| 12 |
*/ |
| 13 |
|
| 14 |
static void ac_set ( Widget w, XEvent *event, String *params, Cardinal *num_params ) |
| 15 |
{ |
| 16 |
GC gc1,gc2; |
| 17 |
XGCValues values; |
| 18 |
Dimension wi,hi; |
| 19 |
|
| 20 |
if (!XtIsRealized(w)) |
| 21 |
return ; |
| 22 |
|
| 23 |
if (strcmp(XtName(w),"draw") != 0) |
| 24 |
return ; |
| 25 |
|
| 26 |
XtVaGetValues(w,XtNheight,&hi,XtNwidth,&wi,NULL); |
| 27 |
values.foreground = 0xcf00fe; //purple |
| 28 |
gc1 = XtGetGC(w, GCForeground, &values); |
| 29 |
values.foreground = 0x00ff00; //green |
| 30 |
gc2 = XtGetGC(w, GCForeground, &values); |
| 31 |
XmuDrawLogo(XtDisplay(w), XtWindow(w), gc1, gc2, 0,0, wi, hi ); |
| 32 |
XtReleaseGC(w,gc1); |
| 33 |
XtReleaseGC(w,gc2); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
static void |
| 38 |
quit_cb(Widget w, XtPointer data, XtPointer call_data) |
| 39 |
{ |
| 40 |
XtAppSetExitFlag( XtWidgetToApplicationContext(w) ); |
| 41 |
}; |
| 42 |
|
| 43 |
int main(int argc, char **argv) |
| 44 |
{ |
| 45 |
Widget toplevel,box,command,simple; |
| 46 |
XtAppContext app; |
| 47 |
static char translation[] = |
| 48 |
"<Expose>:set()\n"; |
| 49 |
static XtActionsRec actionTable[] = { |
| 50 |
{"set",ac_set } |
| 51 |
}; |
| 52 |
|
| 53 |
toplevel = XtAppInitialize(&app, "demo", NULL, 0, |
| 54 |
&argc, argv, NULL, |
| 55 |
NULL, 0); |
| 56 |
|
| 57 |
XtAppAddActions(app, actionTable, XtNumber(actionTable) ); |
| 58 |
|
| 59 |
box = XtCreateManagedWidget("box", boxWidgetClass, toplevel, NULL, 0); |
| 60 |
|
| 61 |
command = XtVaCreateManagedWidget("cmd", |
| 62 |
commandWidgetClass, box, |
| 63 |
XtNlabel, "EXIT", |
| 64 |
NULL); |
| 65 |
|
| 66 |
simple=XtVaCreateManagedWidget("draw", |
| 67 |
simpleWidgetClass, box, |
| 68 |
XtNheight,250, |
| 69 |
XtNwidth,250, |
| 70 |
XtNbackground, 0xff0000, |
| 71 |
XtNtranslations,XtParseTranslationTable(translation), |
| 72 |
NULL); |
| 73 |
|
| 74 |
XtAddCallback(command, XtNcallback, quit_cb, simple ); |
| 75 |
|
| 76 |
XtRealizeWidget(toplevel); |
| 77 |
XtAppMainLoop(app); |
| 78 |
exit(0); |
| 79 |
} |