2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: WorkingDialogManager.C /main/4 1996/04/21 19:40:36 drk $ */
27 * $XConsortium: WorkingDialogManager.C /main/4 1996/04/21 19:40:36 drk $
29 * RESTRICTED CONFIDENTIAL INFORMATION:
31 * The information in this document is subject to special
32 * restrictions in a confidential disclosure agreement bertween
33 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
34 * document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
35 * Sun's specific written approval. This documment and all copies
36 * and derivative works thereof must be returned or destroyed at
39 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
44 ///////////////////////////////////////////////////////////////////////////////
45 //////////////////////////////////////////////////////////////////////////////
46 // This example code is from the book:
48 // Object-Oriented Programming with C++ and OSF/Motif
51 // Prentice Hall, 1992
54 // Copyright 1991 by Prentice Hall
55 // All Rights Reserved
57 // Permission to use, copy, modify, and distribute this software for
58 // any purpose except publication and without fee is hereby granted, provided
59 // that the above copyright notice appear in all copies of the software.
60 ///////////////////////////////////////////////////////////////////////////////
61 //////////////////////////////////////////////////////////////////////////////
64 ///////////////////////////////////////////////////////////
65 // WorkingDialogManager.C:
66 //////////////////////////////////////////////////////////
67 #include "WorkingDialogManager.h"
68 #include "Application.h"
70 #include <Xm/MessageB.h>
72 #include "BusyPixmap.h"
75 WorkingDialogManager *theWorkingDialogManager =
76 new WorkingDialogManager ( "WorkingDialog" );
78 WorkingDialogManager::WorkingDialogManager ( char *name ) :
79 DialogManager ( name )
85 Widget WorkingDialogManager::createDialog ( Widget parent )
87 Widget dialog = XmCreateWorkingDialog ( parent, _name, NULL, 0 );
89 XtVaSetValues ( dialog,
90 XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL,
93 XtAddCallback ( dialog,
95 &WorkingDialogManager::unpostCallback,
98 XtAddCallback ( dialog,
100 &WorkingDialogManager::unpostCallback,
103 // if ( !_busyPixmaps )
104 // _busyPixmaps = new BusyPixmap ( dialog );
109 Widget WorkingDialogManager::post (char *title,
113 DialogCallback cancel,
114 DialogCallback help )
116 // The the dialog already exists, and is currently in use,
117 // just return this dialog. The WorkingDialogManager
118 // only supports one dialog.
120 if ( _w && XtIsManaged ( _w ) )
123 // Pass the message on to the base class
125 DialogManager::post (title, text, clientData, ok, cancel, help );
127 // Call timer to start an animation sequence for this dialog
135 WorkingDialogManager::post (char *title,
140 DialogCallback cancel,
141 DialogCallback help )
143 // The the dialog already exists, and is currently in use,
144 // just return this dialog. The WorkingDialogManager
145 // only supports one dialog.
147 if ( _w && XtIsManaged ( _w ) )
150 // Pass the message on to the base class
152 DialogManager::post (title, text, wid, clientData, ok, cancel, help );
154 // Call timer to start an animation sequence for this dialog
161 void WorkingDialogManager::timerCallback ( XtPointer clientData,
164 WorkingDialogManager *obj = ( WorkingDialogManager * ) clientData;
169 void WorkingDialogManager::timer ()
175 // Reinstall the time-out callback to be called again
178 XtAppAddTimeOut ( XtWidgetToApplicationContext ( _w ),
180 &WorkingDialogManager::timerCallback,
181 ( XtPointer ) this );
183 // Get the next pixmap in the animation sequence and display
184 // it in the dialog's symbol area.
186 // XtVaSetValues ( _w,
187 // XmNsymbolPixmap, _busyPixmaps->next(),
193 void WorkingDialogManager::unpostCallback ( Widget ,
194 XtPointer clientData,
197 WorkingDialogManager *obj = ( WorkingDialogManager* ) clientData;
202 void WorkingDialogManager::unpost ()
204 assert ( _w != NULL );
206 // Remove the dialog from the screen
208 XtUnmanageChild ( _w );
210 // Stop the animation
213 XtRemoveTimeOut ( _intervalId );
216 void WorkingDialogManager::updateMessage ( char *text )
221 // Just change the string displayed in the dialog
223 XmString xmstr = XmStringCreateLocalized ( text );
224 XtVaSetValues ( _w, XmNmessageString, xmstr, NULL );
225 XmStringFree ( xmstr );