Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtmail / dtmail / Dialog.C
1 /*
2  *+SNOTICE
3  *
4  *      $XConsortium: Dialog.C /main/4 1996/04/21 19:41:15 drk $
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 "Dialog.h"
22 #include "Application.h"
23 #include "RoamMenuWindow.h"
24 #include <Xm/DialogS.h>
25 #include <assert.h>
26 #include "Help.hh"
27
28 // The following header is private to CDE and should NOT be required
29 // but unfortunately is.
30 //
31 extern "C" {
32 #include <Dt/HourGlass.h>
33 }
34
35
36 Dialog::Dialog(char *name, RoamMenuWindow *parent) : UIComponent(name)
37 {
38   _parent = parent;
39   _workArea = NULL;
40     
41   _w = XtCreatePopupShell(_name,
42                           xmDialogShellWidgetClass,
43                           parent->baseWidget(),
44                           NULL, 0 );
45
46   XtVaSetValues(_w, XmNdefaultPosition, False, NULL);
47
48   assert( theApplication != NULL );
49 }
50
51 Dialog::Dialog(RoamMenuWindow *parent) : UIComponent("")
52 {
53   _parent = parent;
54   _workArea=NULL;
55 }
56
57 Dialog::~Dialog()
58 {
59 }
60
61 void
62 Dialog::initialize()
63 {
64     
65     
66
67     XtVaSetValues( _w,
68                    XmNdefaultPosition, False, NULL );
69     
70     XtAddCallback( _w,
71                    XmNpopupCallback,
72                    ( XtCallbackProc ) &Dialog::popupCallback,
73                    XtPointer( this ) );
74     
75     XtAddCallback( _w,
76                    XmNpopdownCallback,
77                    ( XtCallbackProc ) &Dialog::popdownCallback,
78                    XtPointer( this ) );
79     
80     _workArea = createWorkArea ( _w );  
81     assert ( _workArea != NULL );
82     printHelpId("_workArea", _workArea);
83     /* add help callback */
84     // XtAddCallback(_workArea, XmNhelpCallback, HelpCB, helpId);
85
86     if ( !XtIsManaged ( _workArea ) )
87         XtManageChild ( _workArea ); 
88 }
89
90
91 void
92 Dialog::title(
93     char *text
94 )
95 {
96     XtVaSetValues ( _w, XmNtitle, text, NULL );
97 }
98
99
100 void
101 Dialog::popupCallback( Widget ,
102                        XtPointer clientData,
103                        XmAnyCallbackStruct *
104 )
105 {
106     Dialog *window=( Dialog * ) clientData;
107     
108     window->popped_up();
109     
110 }
111
112
113 void
114 Dialog::popdownCallback( Widget ,               // w
115                          XtPointer clientData,
116                          XmAnyCallbackStruct *
117 )
118 {
119     Dialog *window=( Dialog * ) clientData;
120     
121     window->popped_down();
122     
123 }
124
125 void
126 Dialog::manage()
127 {
128     if ( !XtIsManaged ( _workArea ) )
129         XtManageChild ( _workArea ); 
130     UIComponent::manage();
131 }
132
133 void
134 Dialog::busyCursor()
135 {
136     // Do nothing if the widget has not been realized.
137
138     if (XtIsRealized(_w)) {
139         _DtTurnOnHourGlass(_w);
140     }
141 }
142
143 void
144 Dialog::normalCursor()
145 {
146     // Do nothing if the widget has not been realized
147
148     if (XtIsRealized(_w)) {
149         _DtTurnOffHourGlass(_w);
150     }
151 }