1 /* $XConsortium: WorkingDialogManager.C /main/4 1996/04/21 19:40:36 drk $ */
5 * $XConsortium: WorkingDialogManager.C /main/4 1996/04/21 19:40:36 drk $
7 * RESTRICTED CONFIDENTIAL INFORMATION:
9 * The information in this document is subject to special
10 * restrictions in a confidential disclosure agreement bertween
11 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
12 * document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
13 * Sun's specific written approval. This documment and all copies
14 * and derivative works thereof must be returned or destroyed at
17 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
22 ///////////////////////////////////////////////////////////////////////////////
23 //////////////////////////////////////////////////////////////////////////////
24 // This example code is from the book:
26 // Object-Oriented Programming with C++ and OSF/Motif
29 // Prentice Hall, 1992
32 // Copyright 1991 by Prentice Hall
33 // All Rights Reserved
35 // Permission to use, copy, modify, and distribute this software for
36 // any purpose except publication and without fee is hereby granted, provided
37 // that the above copyright notice appear in all copies of the software.
38 ///////////////////////////////////////////////////////////////////////////////
39 //////////////////////////////////////////////////////////////////////////////
42 ///////////////////////////////////////////////////////////
43 // WorkingDialogManager.C:
44 //////////////////////////////////////////////////////////
45 #include "WorkingDialogManager.h"
46 #include "Application.h"
48 #include <Xm/MessageB.h>
50 #include "BusyPixmap.h"
53 WorkingDialogManager *theWorkingDialogManager =
54 new WorkingDialogManager ( "WorkingDialog" );
56 WorkingDialogManager::WorkingDialogManager ( char *name ) :
57 DialogManager ( name )
63 Widget WorkingDialogManager::createDialog ( Widget parent )
65 Widget dialog = XmCreateWorkingDialog ( parent, _name, NULL, 0 );
67 XtVaSetValues ( dialog,
68 XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL,
71 XtAddCallback ( dialog,
73 &WorkingDialogManager::unpostCallback,
76 XtAddCallback ( dialog,
78 &WorkingDialogManager::unpostCallback,
81 // if ( !_busyPixmaps )
82 // _busyPixmaps = new BusyPixmap ( dialog );
87 Widget WorkingDialogManager::post (char *title,
91 DialogCallback cancel,
94 // The the dialog already exists, and is currently in use,
95 // just return this dialog. The WorkingDialogManager
96 // only supports one dialog.
98 if ( _w && XtIsManaged ( _w ) )
101 // Pass the message on to the base class
103 DialogManager::post (title, text, clientData, ok, cancel, help );
105 // Call timer to start an animation sequence for this dialog
113 WorkingDialogManager::post (char *title,
118 DialogCallback cancel,
119 DialogCallback help )
121 // The the dialog already exists, and is currently in use,
122 // just return this dialog. The WorkingDialogManager
123 // only supports one dialog.
125 if ( _w && XtIsManaged ( _w ) )
128 // Pass the message on to the base class
130 DialogManager::post (title, text, wid, clientData, ok, cancel, help );
132 // Call timer to start an animation sequence for this dialog
139 void WorkingDialogManager::timerCallback ( XtPointer clientData,
142 WorkingDialogManager *obj = ( WorkingDialogManager * ) clientData;
147 void WorkingDialogManager::timer ()
153 // Reinstall the time-out callback to be called again
156 XtAppAddTimeOut ( XtWidgetToApplicationContext ( _w ),
158 &WorkingDialogManager::timerCallback,
159 ( XtPointer ) this );
161 // Get the next pixmap in the animation sequence and display
162 // it in the dialog's symbol area.
164 // XtVaSetValues ( _w,
165 // XmNsymbolPixmap, _busyPixmaps->next(),
171 void WorkingDialogManager::unpostCallback ( Widget ,
172 XtPointer clientData,
175 WorkingDialogManager *obj = ( WorkingDialogManager* ) clientData;
180 void WorkingDialogManager::unpost ()
182 assert ( _w != NULL );
184 // Remove the dialog from the screen
186 XtUnmanageChild ( _w );
188 // Stop the animation
191 XtRemoveTimeOut ( _intervalId );
194 void WorkingDialogManager::updateMessage ( char *text )
199 // Just change the string displayed in the dialog
201 XmString xmstr = XmStringCreateLocalized ( text );
202 XtVaSetValues ( _w, XmNmessageString, xmstr, NULL );
203 XmStringFree ( xmstr );