[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

3113.0. "Iconless popup dialog box" by RHETT::MACEACHERN () Mon Jul 23 1990 13:18

    In the next two repies, I will put code I received from a customer who
    is trying to get a popup dialog box without an icon box.  I can
    change the code around to get the main window without an icon, but
    I have not been able to get the popup to come up without an icon.
    
    I'd appreciate any help.
    
    He also asked if there is any way to get a list box, which the color of
    the individual lines can be changed, i.e. one line red, one green, one
    purple...
    
    Thanks again
    
    Dave.
    
T.RTitleUserPersonal
Name
DateLines
3113.1c source codeRHETT::MACEACHERNMon Jul 23 1990 13:222
    

3113.22nd attempt c source codeRHETT::MACEACHERNMon Jul 23 1990 13:24115
#include stdio
#include <DwtAppl.h>

#define nFiles(x)		(sizeof(x)/sizeof(char *))
#define nRegs(x)		(sizeof(x)/sizeof(DRMRegisterArg))
#define screenNumber	DefaultScreen( display )
#define defaultGC		DefaultGC( display, screenNumber )
#define defaultColormap	DefaultColormap( display, screenNumber )

#define options_box		10
#define MAXWIDGETS		40

Display			*display;
Widget			widget_id[MAXWIDGETS], alarm_top, review_top,
			main_widget;

int			depth, top_x = 0, top_width, big_y = 68,
			big_height, small_y, small_height = 100, screen_height;
DRMHierarchy		alarm_hierarchy, review_hierarchy;
char			*alarmvec[] = { "iconify.uid" }, 
			*widget_name[MAXWIDGETS];
XtWorkProcId	widget_proc[MAXWIDGETS];
DRMCode			class;
Window			top_window;

/*
 *	W i d g e t C r e a t e d
 */

void WidgetCreated( widget, tag, reason )	/* callback for widget creation 
*/
Widget widget;
int *tag;
DwtAnyCallbackStruct *reason;
	{
	widget_id[*tag] = widget;				/* save widget i
dentifier */
	} /* WidgetCreated() */

/* Procedures */
DRMRegisterArg regvec[] = {
	{ "WidgetCreated",			(caddr_t)WidgetCreated },
};

/*
 * 	m a i n
 */
main( unsigned int argc, char *argv[] )
	{
	int *ip, n;
	XSizeHints size_hints;
	Arg args[10];
	DwtCompString *ls;
	XColor color, exact_color;
	Screen *screen;

	/* Initialize DRM and toolkit */
	DwtInitializeDRM();
	if( DwtOpenHierarchy( nFiles( alarmvec ), alarmvec, NULL,
	  &alarm_hierarchy ) != DRMSuccess )
		{
		fprintf( stderr, "Can't open DRM alarm hierarchy\n" );
		lib$stop( -1 );
		}
	alarm_top = XtInitialize( "", "", NULL, 0, &argc, argv );
	display = XtDisplay( alarm_top );
	depth = DefaultDepth( display, DefaultScreen( display ) );

	/* Register callback routines */
	DwtRegisterDRMNames( regvec, nRegs( regvec ) );

	/* Display window must be non-occludable and immobile */
	n = 0;
	XtSetArg( args[n], DwtNoverrideRedirect, True ); ++n;
	XtSetValues( alarm_top, &args[0], n );

	memset( widget_id, 0, sizeof( widget_id ) );
	if( DwtFetchWidget( alarm_hierarchy, "mainWindow", alarm_top,
			     &main_widget,&class ) != DRMSuccess )
		{
		fprintf( stderr, "Can't fetch widget 'mainWindow'\n" );
		lib$stop( -1 );
		}
	XtManageChild( main_widget );

	/* Size and position the display window */
	screen = XDefaultScreenOfDisplay( display );
	top_width = XWidthOfScreen( screen ) - 2;
	screen_height = XHeightOfScreen( screen );
	small_y = screen_height - small_height - 2;
	big_height = XHeightOfScreen( screen ) - big_y;	
	XtRealizeWidget( alarm_top );
	top_window = XtWindow( alarm_top );
	XMoveResizeWindow( display, top_window, top_x, small_y, top_width,
	  small_height );

	/* Create a shell for the review functions */
	/* Suppress the iconify button */
	n = 0;
	XtSetArg( args[n], DwtNnoIconify, True ); ++n;
	XtSetValues( main_widget, &args[0], n );
	review_top = XtCreateApplicationShell( "reviewShell",
	  transientShellWidgetClass, &args[0], n );

	if( DwtFetchWidget( alarm_hierarchy, "alarmReview", review_top,
	  &widget_id[options_box], &class ) != DRMSuccess )
		{
		fprintf( stderr, "Can't fetch widget 'alarmReview'\n" );
		lib$stop( -1 );
		}
	XtManageChild( widget_id[options_box] );

	XtMainLoop();
	} /* main() */

3113.3uil codeRHETT::MACEACHERNMon Jul 23 1990 13:2640
Module ICONIFY
	version = 'v1.0'
	names = case_sensitive

include file 'DwtAppl.uil';

object
mainWindow: main_window
	{
	arguments
		{
		width = 400;
		height = 100;
		};
	};

value
	option_box:		20;

procedure
	WidgetCreated( integer );

object
alarmReview: popup_attached_db
	{
	arguments
		{
		style = DwtModeless;
		title = compound_string( 'Alarm Review Option Select' );
		width = 622;
		height = 123;
		x = 400;
		y = 635;
		};
	callbacks
		{
		create = procedure WidgetCreated( option_box );
		};
	};
end module;
3113.4VList/TList widgetsLOWELL::KLEINMon Jul 23 1990 15:068
>    He also asked if there is any way to get a list box, which the color of
>    the individual lines can be changed, i.e. one line red, one green, one
>    purple...

The TList and VList widgets have this functionality.  For a pointer to the
sources, send me mail.

-steve-
3113.5simplifyLOWELL::KLEINMon Jul 23 1990 15:2144
My guess on the no-iconify problem is that the program has too much
code for its own good:

>	/* Create a shell for the review functions */
>	/* Suppress the iconify button */
>	n = 0;
>	XtSetArg( args[n], DwtNnoIconify, True ); ++n;
>(1)	XtSetValues( main_widget, &args[0], n );
>(2)	review_top = XtCreateApplicationShell( "reviewShell",
>	  transientShellWidgetClass, &args[0], n );
>
>	if( DwtFetchWidget( alarm_hierarchy, "alarmReview", review_top,
>	  &widget_id[options_box], &class ) != DRMSuccess )
>		{
>		fprintf( stderr, "Can't fetch widget 'alarmReview'\n" );
>		lib$stop( -1 );
>		}

(1) it is not clear why they're setting main_widget to have
DwtNnoIconify==true, although this probably has no harm or effect.

(2) They are setting the new application shell (reviewShell) to noIconify,
but this shell is not being used (!) because subsequently, when alarmReview
is fetched, another shell is created.  This is because alarmReview is
a popup dialog box, which creates its own shell.  This is probably the
crux of the whole problem, since the special-case code in the popup dialog
box that determines whether it needs an iconify button is based on checking
whether the parent widget has been realized, and this code is being
defeated by the extra application shell which has been inserted in the
hierarchy.

By making the parent of the popup dialog box be the mainWindow, and by
first realizing the mainWindow (which is already being done correctly),
the popup dialog box should automatically know that it should not have
an iconify button:

>>	if( DwtFetchWidget( alarm_hierarchy, "alarmReview", mainWindow,
>>	  &widget_id[options_box], &class ) != DRMSuccess )
>>		{
>>		fprintf( stderr, "Can't fetch widget 'alarmReview'\n" );
>>		lib$stop( -1 );
>>		}

-steve-