[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

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

3231.0. "DwtNborderWidth in lost_focus - weird results" by STAR09::BELDIN () Mon Aug 20 1990 17:56

    
    	Is there any 'illegal' or dreadfully 'bad' in trying to set
    	the customer DwtNborderWidth of a simple text widget in a 
    	lost_focus callback?  A customer wanted to do this to try
    	to indicate to his users that the field was not currently
    	being edited.  I duplicated the problem which is that if you
    	try to set the DwtNborderWidth in the lost_focus your original
    	window (with the simple text) starts to resize itself continually.
    
    
    	Stepping into the debugger shows the code somewhere in 
    	DWT$XLIBSHR, looping continually... Code does the same thing
    	on VMS 5.3-1 and some field test of VMS 5.4. Is it possible that the
    	geometry manager gets confused on the lost_focus somehow?
    
    	Following notes are the C code and the UIL.
    
    	Rick Beldin
    	VMS Workstation Support
T.RTitleUserPersonal
Name
DateLines
3231.1focus_cb.cSTAR09::BELDINMon Aug 20 1990 17:57203
#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 */


    
3231.2focus_cb.uilSTAR09::BELDINMon Aug 20 1990 17:5852
module focus_cb
    names = case_sensitive

    include file 'decw$include:dwtappl.uil';

    procedure
        focus_cb ();
        lost_cb ();

    object

        o_main_window : private main_window 
            {
             arguments {
                 height = 0;
                 width  = 0;
             };
             controls {
                 attached_dialog_box o_adb;
             };
        };

        o_adb : private attached_dialog_box 
            {
             arguments {
		width = 400;
		height = 400;
	     };
             controls {
		simple_text o_stext;
	     };
        };

	o_stext : private simple_text
	    {
            arguments {
		cols = 8;
		resize_height = false;
		half_border = false;
		border_width = 0;
		insertion_point_visible = false;
		simple_text_value = "0";
	    };
            callbacks {
                focus = procedure focus_cb ();
                lost_focus = procedure lost_cb ();
            };
	};


end module /* focus_cb */;
    
3231.3Yes, it doesn't workLOWELL::KLEINMon Aug 20 1990 18:5913
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-