| /****************************************************************************
This application draws filled circles.. Select the FILE menu and pick
the "test grphics" item.
****************************************************************************/
#include <stdio.h>
#ifdef VMS
#include <decw$include/DwtAppl.h>
#else
#include <X11/DwtAppl.h>
#endif
#define MAXARGS 4
/* UIL routines */
static XtCallbackProc test_graphics(),
ExitButtonActivated();
/*
Digital Resource Manager (DRM) data structures
*/
static DRMHierarchy hierarchy; /* DRM hierarch id */
static char *namvec[] = {"gtest.uid"}; /* DRM file list */
static DRMCode class;
/* Associate UIL routine names with C-code routine names */
static DRMRegisterArg regvec[] = {
{"test_graphics",(caddr_t)test_graphics},
{"ExitButtonActivated", (caddr_t)ExitButtonActivated}
};
Widget top_level; /* Requiered for each application, invisible */
Widget main_window; /* Application main window (empty) */
short root_x,root_y;
Arg args[MAXARGS];
GC defgc;
/*
Macros for counting things in file and name lists
*/
#define nFiles(x) (sizeof(x)/sizeof(char *))
#define nRegs(x) (sizeof(x)/sizeof(DRMRegisterArg))
main(argc,argv)
unsigned int argc;
char *argv[];
{
int status,n;
/* Initialize the Digital Resource Manager */
DwtInitializeDRM();
/* Initialize the toolkit, and create the top-level widget */
top_level = XtInitialize("Hi!","Example",NULL,0,&argc,argv);
defgc = XDefaultGC(XtDisplay(top_level), DefaultScreen(XtDisplay(top_level)));
n = 0;
XtSetArg(args[n],XtNallowShellResize,True); ++n;
XtSetValues(top_level,args,n);
/* Define the DRM hierarchy, NOTE here in DECW we have to explictly
open the resource file. */
status = DwtOpenHierarchy(nFiles(namvec), /* number of files */
namvec, /* file names */
NULL, /* no extensions */
&hierarchy); /* pointer to hierarchy id */
if (status != DRMSuccess) {
fprintf(stderr,"Can't open DRM hierarchy\n");
exit(0);
}
/* Register callback routines */
DwtRegisterDRMNames(regvec,nRegs(regvec));
/* Ask DRM to create the pushbutton widget */
status = DwtFetchWidget(hierarchy, /* DRM hierarchy id */
"mainwindow", /* index of widget to fetch */
top_level, /* parent widget */
&main_window, /* returned widget id */
&class); /* returned widget class */
if (status != DRMSuccess) {
fprintf(stderr,"Can't fetch widget\n");
exit(0);
}
/* Include fetched widget in its parent's managed set */
XtManageChild(main_window);
XtRealizeWidget(top_level);
XtMainLoop(); /* Never returns */
}
/****************************************************************************
/*
/* This function is invoked when "Test graphics" menu item is selected
/* (from the "File" menu).
/* This function draws some graphics in the main window.
/*
/****************************************************************************/
static XtCallbackProc test_graphics(widget,tag,reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;
{
int status;
int x,y;
unsigned int width,height,i;
int angle1,angle2;
Boolean reverse = True;
Display *disp$;
x = y = 35;
width = height = 200;
angle1 = 0;
angle2 = 360*64;
disp$ = XtDisplay(top_level);
for(i=0;i < 45; i++)
{
width = height -= 4;
x = y += 2;
if(reverse)
{
XSetForeground(disp$, defgc,
BlackPixel(disp$, XDefaultScreen(disp$)));
}
else
{
XSetForeground(disp$, defgc,
WhitePixel(disp$, XDefaultScreen(disp$)));
}
reverse = !reverse;
XFillArc(disp$, XtWindow(main_window), defgc,
x,y, width ,height, 0, 360*64);
}
}
/****************************************************************************
/*
/* This function is invoked when "EXIT" is selected from "File" menu or
/* from the dialog_box.
/*
/****************************************************************************/
static XtCallbackProc ExitButtonActivated(widget,tag,reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;
{
exit(1);
}
|
| module Gtest
version = 'v1.0'
names = case_sensitive
include file 'decw$include:DwtAppl.uil';
value
adb_top_attachment: argument('adbTopAttachment', integer);
adb_bottom_attachment: argument('adbBottomAttachment', integer);
adb_left_attachment: argument('adbLeftAttachment', integer);
adb_right_attachment: argument('adbRightAttachment', integer);
adb_top_widget: argument('adbTopWidget', any);
adb_bottom_widget: argument('adbBottomWidget', any);
adb_left_widget: argument('adbLeftWidget', any);
adb_right_widget: argument('adbRightWidget', any);
adb_top_offset: argument('adbTopOffset', integer);
adb_bottom_offset: argument('adbBottomOffset', integer);
adb_left_offset: argument('adbLeftOffset', integer);
adb_right_offset: argument('adbRightOffset', integer);
value
exit_label : compound_string('Exit');
procedure
ExitButtonActivated();
test_graphics();
object mainwindow : main_window {
arguments {
width = 300;
height = 300;
accept_focus = true;
};
controls {
menu_bar menu_bar_3b;
};
};
object menu_bar_3b : menu_bar
{
arguments {
orientation = DwtOrientationHorizontal;
spacing = 15; ! Spacing of items in the menu.
};
controls {
pulldown_entry file_menu_entry;
};
};
object file_menu_entry : pulldown_entry ! "File" menu entry.
{
arguments {
label_label = "File";
};
controls {
pulldown_menu file_menu;
};
};
object file_menu : pulldown_menu ! "File" contents in the menu.
{
arguments {
orientation = DwtOrientationVertical;
};
controls {
push_button mb_graphics;
push_button mb_exit;
};
};
object mb_graphics : push_button { ! "Test graphics"
arguments {
label_label = "Test Graphics";
accelerator_text = '^B';
button_accelerator = 'Ctrl<KeyPress>B:';
};
callbacks {
activate = procedure test_graphics();
};
};
object mb_exit : push_button { ! "Exit"
arguments {
label_label = "Exit";
accelerator_text = '^E';
button_accelerator = 'Ctrl<KeyPress>E:';
};
callbacks {
activate = procedure ExitButtonActivated();
};
};
end module;
|