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