Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtmail / dtmail / DialogShell.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /*
24  *+SNOTICE
25  *
26  *      $TOG: DialogShell.C /main/10 1998/02/03 12:10:06 mgreess $
27  *
28  *      RESTRICTED CONFIDENTIAL INFORMATION:
29  *      
30  *      The information in this document is subject to special
31  *      restrictions in a confidential disclosure agreement between
32  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
33  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
34  *      Sun's specific written approval.  This document and all copies
35  *      and derivative works thereof must be returned or destroyed at
36  *      Sun's request.
37  *
38  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
39  *
40  *+ENOTICE
41  */
42
43 #include <assert.h>
44 #include <X11/Intrinsic.h>
45 #include <X11/Xmu/Editres.h>
46 #include <Xm/Protocols.h>
47 #include <Xm/AtomMgr.h>
48
49 #include <Dt/Wsm.h>
50 #include <Dt/Session.h>
51 #include <DtMail/IO.hh>
52
53 // The following headers are private to CDE and should NOT be required
54 // but unfortunately are.
55 //
56 extern "C" {
57 #include <Dt/HourGlass.h>
58 }
59 #include <Dt/Icon.h>
60 #include <Dt/IconP.h>
61 #include <Dt/IconFile.h>
62
63 #include "DialogShell.h"
64 #include "Application.h"
65 #include "RoamMenuWindow.h"
66
67
68 DialogShell::DialogShell(char *name, RoamMenuWindow *parent, WidgetClass wc)
69 : UIComponent(name)
70 {
71     _parent=parent;
72     _workArea=NULL;
73     _widgetClass=wc;
74     
75     assert( theApplication != NULL );
76 }
77
78 DialogShell::~DialogShell()
79 {
80     Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ),
81                                         "WM_DELETE_WINDOW",
82                                         False );
83     XmRemoveWMProtocolCallback( _w,
84                                 WM_DELETE_WINDOW,
85                                 ( XtCallbackProc ) quitCallback,
86                                 NULL );
87
88 }
89
90
91 void
92 DialogShell::initialize()
93 {
94     _w = XtVaCreatePopupShell(
95                         _name, _widgetClass, _parent->baseWidget(),
96                         XmNdefaultPosition, False,
97                         NULL, 0 );
98 #ifdef USE_EDITRES
99     XtAddEventHandler(
100                 _w, (EventMask) 0, True,
101                 (XtEventHandler) _XEditResCheckMessages, NULL);
102 #endif
103
104     installDestroyHandler();
105     _workArea = createWorkArea ( _w );  
106     assert ( _workArea != NULL );
107
108     XtVaSetValues( _w, XmNdefaultPosition, False, NULL );
109     XtAddCallback( _w,
110                    XmNpopupCallback,
111                    ( XtCallbackProc ) &DialogShell::popupCallback,
112                    XtPointer( this ) );
113     XtAddCallback( _w,
114                    XmNpopdownCallback,
115                    ( XtCallbackProc ) &DialogShell::popdownCallback,
116                    XtPointer( this ) );
117
118     Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ),
119                                         "WM_DELETE_WINDOW",
120                                         False );
121
122     XmAddWMProtocolCallback( _w,
123                              WM_DELETE_WINDOW,
124                              ( XtCallbackProc ) quitCallback,
125                              this );
126     
127 //  if (!XtIsManaged(_workArea)) XtManageChild(_workArea); 
128 }
129
130
131 void
132 DialogShell::title(
133     char *text
134 )
135 {
136     XtVaSetValues ( _w, XmNtitle, text, NULL );
137 }
138
139
140 void
141 DialogShell::popupCallback( Widget ,
142                        XtPointer clientData,
143                        XmAnyCallbackStruct *
144 )
145 {
146     DialogShell *obj=( DialogShell * ) clientData;
147     obj->popped_up();
148     obj->displayInCurrentWorkspace();
149 }
150
151
152 void
153 DialogShell::popdownCallback( Widget ,
154                          XtPointer clientData,
155                          XmAnyCallbackStruct *
156 )
157 {
158     DialogShell *obj=( DialogShell * ) clientData;
159     obj->popped_down();
160 }
161
162 void
163 DialogShell::manage()
164 {
165     if (NULL == _workArea) return;
166     if (!XtIsManaged(_workArea )) XtManageChild(_workArea); 
167     UIComponent::manage();
168 }
169
170
171 void
172 DialogShell::quitCallback( Widget,
173                           XtPointer clientData,
174                           XmAnyCallbackStruct *)
175 {
176   DialogShell *dlg = ( DialogShell *) clientData;
177   dlg->quit();
178 }
179
180 void
181 DialogShell::busyCursor()
182 {
183     // Do nothing if the widget has not been realized
184
185     if (XtIsRealized(_w)) {
186         _DtTurnOnHourGlass(_w);
187     }
188 }
189
190 void
191 DialogShell::normalCursor()
192 {
193     // Do nothing if the widget has not been realized
194     
195     if (XtIsRealized ( _w ))
196     {
197         _DtTurnOffHourGlass(_w);
198     }
199 }