[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
|
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
2971.0. "problems defining cursor" by KLEE::SCHMIDT (Christiane Schmidt, @KLE Germany) Thu Jun 21 1990 08:09
I have problems defining a different cursor for a widget (pushbutton)
in my widget hierarchy. I defined my widgets with UIL and try to
define a cursor for my pushbutton, when it is created. But no effect.
Can anybody tell me, what i am doing wrong?
Thanks for any help
Christiane
#include <stdio.h>
# include <decw$include/cursorfont.h>
#include <decw$include/DECwDwtApplProg.h>
/*
Forward declarations of procedures
*/
#define screenNumber DefaultScreen(display)
#define hello "Hello World"
#define goodbye "Goodbye World"
#define iconName windowName
#define forever while(1)
#define windowName "Cursor_test"
#define windowClass windowName
#define uidFile "cursor_test.uid"
#define nFiles(x) (sizeof(x)/sizeof(char *))
#define nRegs(x) (sizeof(x)/sizeof(DRMRegisterArg))
/*
Digital Resource Manager (DRM) data structures
*/
static void LabelCreated(); /* create callback for label widget */
static void ButtonCreated (); /* create callback for push button */
static void ButtonActivated(); /* activate callback for push button */
static Widget label, button, mainWidget;
static DRMHierarchy hierarchy; /* DRM database hierarchy id */
static char *namvec[] = {uidFile}; /* DRM database file list */
static DRMCode class;
static DRMRegisterArg regvec[] = {
{"ButtonCreated", (caddr_t)ButtonCreated},
{"ButtonActivated", (caddr_t)ButtonActivated},
{"LabelCreated", (caddr_t)LabelCreated}
};
Display *display;
Widget top_level, /* top level widget */
main_widget; /* application main widget */
static Cursor watchcursor;
main(argc,argv)
unsigned int argc;
char *argv[];
{
int status, i;
unsigned long attribute_mask;
/* Open the default display */
if (!(display = XOpenDisplay(NULL))) {
fprintf(stderr,"Can't open display\n");
exit(0);
}
/* Initialize the Digital Resource Manager */
DwtInitializeDRM();
/* Initialize the toolkit, and create the top-level widget */
top_level = XtInitialize (windowName,
windowClass,
NULL,0, /* no options */
&argc,argv); /* command line */
/* Define the DRM hierarchy */
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 */
"mainWidget", /* index of widget to fetch */
top_level, /* parent widget */
&main_widget, /* 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_widget);
/* Realize the widget heirarchy, creating and mapping windows */
XtRealizeWidget(top_level);
/* Wait for something to happen */
XtMainLoop(); /* Never returns */
}
static void LabelCreated(widget,tag,reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;
{
label = widget;
}
static void ButtonCreated(widget,tag,reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;
{
button = widget;
watchcursor = XCreateFontCursor(display,XC_watch);
XDefineCursor(display,button,watchcursor);
}
static void ButtonActivated(widget,tag,reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;
{
Arg arg;
static int changed = False;
if (changed)
exit(1);
else {
XtSetArg(arg,DwtNlabel,DwtLatin1String(tag));
XtSetValues(label,&arg,1);
changed = True;
}
}
/********************************************/
UIL-FILE
/********************************************/
module cursor_test
version = 'v1.0'
names = case_sensitive
value
click: compound_string('Click Here');
hello: compound_string('Hello, World!');
goodbye: 'Goodbye, World!';
procedure
LabelCreated();
ButtonCreated();
ButtonActivated(string);
object
mainWidget: main_window {
arguments {
width = 200;
height = 100;
};
controls {
dialog_box dialogBox;
};
};
object
dialogBox: dialog_box {
controls {
label label;
push_button pushButton;
};
};
object
label: label {
arguments {
x = 10;
y = 10;
label_label = hello;
};
callbacks {
create = procedure LabelCreated();
};
};
object
pushButton: push_button {
arguments {
x = 10;
y = 30;
label_label = click;
};
callbacks {
activate = procedure ButtonActivated(goodbye);
create = procedure ButtonCreated ();
};
};
end module;
T.R | Title | User | Personal Name | Date | Lines |
---|
2971.1 | Problems defining cursor | RTL::JUNE | | Fri Jun 22 1990 14:23 | 5 |
|
In your call to XDefineCursor, you're passing a widget (button) instead
of a window. Try it with XtWindow(button) as the second parameter.
Rich
|