| #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() */
|
| 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-
|