1 /*
2 * Motif
3 *
4 * Copyright (c) 1987-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 #ifdef REV_INFO
24 #ifndef lint
25 static char rcsid[] = "$XConsortium: DialogSE.c /main/10 1995/07/14 10:19:03 drk $"
26 #endif
27 #endif
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31
32
33 #include <Xm/Xm.h> /* To make cpp on Sun happy. CR 5943 */
34 #include <Xm/DialogSEP.h>
35 #include <Xm/BaseClassP.h>
36 #include <X11/ShellP.h>
37
38
39 /******** Static Function Declarations ********/
40
41 static void ClassInitialize( void ) ;
42 static void DeleteWindowHandler(
43 Widget wid,
44 XtPointer closure,
45 XtPointer call_data) ;
46 static Widget GetManagedKid(
47 CompositeWidget p) ;
48
49 /******** End Static Function Declarations ********/
50
51
52 static XtResource extResources[]= {
53 {
54 XmNdeleteResponse, XmCDeleteResponse,
55 XmRDeleteResponse, sizeof(unsigned char),
56 XtOffsetOf( struct _XmDialogShellExtRec, vendor.delete_response),
57 XmRImmediate, (XtPointer) XmUNMAP,
58 },
59 };
60
61
62 static XmBaseClassExtRec myExtExtension = {
63 NULL, /* Next extension */
64 NULLQUARK, /* record type XmQmotif */
65 XmBaseClassExtVersion, /* version */
66 sizeof(XmBaseClassExtRec), /* size */
67 XmInheritInitializePrehook, /* initialize prehook */
68 XmInheritSetValuesPrehook, /* set_values prehook */
69 XmInheritInitializePosthook, /* initialize posthook */
70 XmInheritSetValuesPosthook, /* set_values posthook */
71 XmInheritClass, /* secondary class */
72 XmInheritSecObjectCreate, /* creation proc */
73 XmInheritGetSecResData, /* getSecRes data */
74 {0}, /* fast subclass */
75 XmInheritGetValuesPrehook, /* get_values prehook */
76 XmInheritGetValuesPosthook, /* get_values posthook */
77 XmInheritClassPartInitPrehook, /* class_part_prehook */
78 XmInheritClassPartInitPosthook, /* class_part_posthook */
79 NULL, /* compiled_ext_resources*/
80 NULL, /* ext_resources */
81 0, /* resource_count */
82 TRUE, /* use_sub_resources */
83 };
84
85 /* ext rec static initialization */
86 externaldef(xmdialogshellextclassrec)
87 XmDialogShellExtClassRec xmDialogShellExtClassRec = {
88 {
89 (WidgetClass) &xmVendorShellExtClassRec, /* superclass */
90 "XmDialogShell", /* class_name */
91 sizeof(XmDialogShellExtRec), /* size */
92 ClassInitialize, /* Class Initializer */
93 NULL, /* class_part_init */
94 FALSE, /* Class init'ed ? */
95 NULL, /* initialize */
96 NULL, /* initialize_notify */
97 NULL, /* realize */
98 NULL, /* actions */
99 0, /* num_actions */
100 extResources, /* resources */
101 XtNumber(extResources), /* resource_count */
102 NULLQUARK, /* xrm_class */
103 FALSE, /* compress_motion */
104 FALSE, /* compress_exposure */
105 FALSE, /* compress_enterleave */
106 FALSE, /* visible_interest */
107 NULL, /* destroy */
108 NULL, /* resize */
109 NULL, /* expose */
110 NULL, /* set_values */
111 NULL, /* set_values_hook */
112 NULL, /* set_values_almost */
113 NULL, /* get_values_hook */
114 NULL, /* accept_focus */
115 XtVersion, /* intrinsics version */
116 NULL, /* callback offsets */
117 NULL, /* tm_table */
118 NULL, /* query_geometry */
119 NULL, /* display_accelerator */
120 (XtPointer) &myExtExtension, /* extension */
121 },
122 {
123 NULL, /* synthetic resources */
124 0, /* num syn resources */
125 NULL, /* extension */
126 },
127 { /* desktop */
128 NULL, /* child_class */
129 XtInheritInsertChild, /* insert_child */
130 XtInheritDeleteChild, /* delete_child */
131 NULL, /* extension */
132 },
133 { /* shell extension */
134 XmInheritEventHandler, /* structureNotify */
135 NULL, /* extension */
136 },
137 { /* vendor ext */
138 DeleteWindowHandler, /* delete window handler*/
139 XmInheritProtocolHandler, /* offset_handler */
140 NULL, /* extension */
141 },
142 { /* dialog ext */
143 (XtPointer) NULL, /* extension */
144 }
145 };
146
147 externaldef(xmdialogshellextobjectclass)
148 WidgetClass xmDialogShellExtObjectClass = (WidgetClass) &xmDialogShellExtClassRec;
149
150
151 static void
ClassInitialize(void)152 ClassInitialize( void )
153 {
154 myExtExtension.record_type = XmQmotif;
155 }
156
157 /************************************************************************
158 *
159 * DeleteWindowHandler
160 *
161 ************************************************************************/
162 /*ARGSUSED*/
163 static void
DeleteWindowHandler(Widget wid,XtPointer closure,XtPointer call_data)164 DeleteWindowHandler(
165 Widget wid,
166 XtPointer closure,
167 XtPointer call_data ) /* unused */
168 {
169 VendorShellWidget w = (VendorShellWidget) wid ;
170 XmVendorShellExtObject ve = (XmVendorShellExtObject) closure;
171
172 switch(ve->vendor.delete_response)
173 {
174 case XmUNMAP:
175 {
176 Widget managedKid;
177
178 if ((managedKid = GetManagedKid((CompositeWidget) w)) != NULL)
179 XtUnmanageChild(managedKid);
180 break;
181 }
182 case XmDESTROY:
183 XtDestroyWidget(wid);
184 break;
185
186 case XmDO_NOTHING:
187 default:
188 break;
189 }
190 }
191
192 static Widget
GetManagedKid(CompositeWidget p)193 GetManagedKid(
194 CompositeWidget p )
195 {
196 Cardinal i;
197 Widget *currKid;
198
199 for (i = 0, currKid = p->composite.children;
200 i < p->composite.num_children;
201 i++, currKid++)
202 {
203 if (XtIsManaged(*currKid))
204 return (*currKid);
205 }
206 return NULL;
207 }
208