| #module focus_cb focus_cb
/*****************************************************************************
**
** COPYRIGHT (c) 1990 BY
** DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
** ALL RIGHTS RESERVED
**
** THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE
** AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
** CORPORATION.
**
** DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
** SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
**
CAUTION: This sample program has been tested using VAX C, V3.0 on
VAX/VMS, V5.3-1. However, we cannot guarantee its effectiveness because
of the possibility of error in transmitting or implementing it. It is
meant to be used as a template for writing your own program, and it may
require modification for use on your system.
*****************************************************************************/
/*
**++
**
** ABSTRACT:
**
** Sample program that shows how to highlight a simple text on the
** focus callback using UIL and C
**
** MODIFICATION HISTORY:
**
**--
*/
/*
**
** INCLUDE FILES
**
*/
#include <sys$library/stdio>
#include <decw$include/dwtappl>
#include <decw$include/Xlib.h>
#define NUMBER_OF_FILES(x) sizeof(x)/sizeof(char *)
#define nFiles(x) (sizeof(x)/sizeof(char *))
#define nRegs(x) (sizeof(x)/sizeof(DRMRegisterArg))
/* Actually just counts the number of pointers to strings */
#define NUMBER_OF_FILES(x) sizeof(x)/sizeof(char *)
/*
* $SETARG: an alternative to the XtSetArg macro when using an array
*
* arg - address of array
* ind - next array index to use ( auto-incremented on return )
* n - resource name to change
* v - new value
*/
#define SETARG_( arg, ind, n, v ) \
( (arg)[(ind)].name = (n), (arg)[(ind)].value = (XtArgVal)(v), ++ind )
/*
**
** FUNCTION PROTOTYPE DEFINITIONS
**
**/
static void focus_cb (Widget, char*, DwtAnyCallbackStruct*);
static void lost_cb (Widget, char*, DwtAnyCallbackStruct*);
/*
**
** GLOBAL VARIABLE DEFINITIONS
**
**/
static DRMHierarchy hierarchy_id; /* hierarchy id */
Widget the_shell, /* shell widget */
the_top; /* the real widget */
static DRMType class; /* Return class from */
/* DwtFetchWidget */
/* */
/* */
/* */
/* */
/* M A I N R O U T I N E */
/* */
/* */
/* */
/* */
main (int argc, char *argv[], char *envp[])
{
int ac; /* Count of arguments in the list */
Arg al[10]; /* Argument list */
long int status; /* return status value */
char *uid_files[] = { "focus_cb.uid" }; /* this should be a ptr */
/* to an array of */
/* uid filenames */
/* regvec is a list of name, procedure pairs, for use in registering the
callback names */
static DRMRegisterArg regvec[] =
{
{"lost_cb", (caddr_t)lost_cb},
{"focus_cb", (caddr_t)focus_cb}
};
/* Initialize the Drm hierarchy */
DwtInitializeDRM();
the_shell = XtInitialize("Focus_cb", "Focus_cb",NULL,0,&argc,argv);
ac = 0;
SETARG_(al,ac,DwtNallowShellResize,TRUE);
SETARG_(al,ac,DwtNx,100);
SETARG_(al,ac,DwtNy,100);
XtSetValues(the_shell,al,ac);
status = DwtOpenHierarchy(NUMBER_OF_FILES(uid_files),
uid_files,
NULL,
&hierarchy_id);
/* Check the return status - if it is ok, proceed. Otherwise, exit */
/* in a structured manner. */
if (status != DRMSuccess)
{
printf ("Error opening DRM Hierarchy, check .uid file\n");
}
else
{
/* Register callback routines */
DwtRegisterDRMNames(regvec,nRegs(regvec));
/* Get the top-level widget */
status = DwtFetchWidget(hierarchy_id, /* heirarchy id */
"o_main_window", /* shell name */
the_shell, /* shell id */
&the_top, /* top level */
&class); /* class */
/* check the status before proceeding */
if (status != DRMSuccess)
{
printf ("Error opening widget - check name in UIL file and code\n");
}
else
{
/* Manage the widget */
XtManageChild(the_top);
/* Realize the widget */
XtRealizeWidget(the_shell);
XtMainLoop();
}
}
} /* main */
/********************* L O C A L F U N C T I O N S ******************/
static void focus_cb( Widget widget, char* tag,
DwtAnyCallbackStruct* reason)
{
int ac; /* Count of arguments in the list */
Arg al[10]; /* Argument list */
printf("in focus callback\n");
ac = 0;
SETARG_(al,ac,DwtNborderWidth,10);
XtSetValues(widget,al,ac);
} /* focus callback */
static void lost_cb( Widget widget, char* tag,
DwtAnyCallbackStruct* reason)
{
int ac; /* Count of arguments in the list */
Arg al[10]; /* Argument list */
printf("in lost callback\n");
ac = 0;
SETARG_(al,ac,DwtNborderWidth,1);
XtSetValues(widget,al,ac);
} /* focus callback */
|
| Looks like a toolkit bug to me. Suggest that they change the border color
instead of the border width.
I think that what is happening is that when
the border width changes, the widget re-exposes itself, which, in turn,
results in a redraw - but with the old border width, and then it changes
the border width again, exposes itself again, etc, etc. One clue is
that the window seems to flicker between the old size and the new size,
and that millions of events (probably expose events) are being sent
from the server to the client. But I can't tell for sure what's happening
other that to confirm that indeed it does not work.
-steve-
|