Debian Codegraph @

libSoXt/src/SoXt.c++

raw symbols SCIP
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990-93 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.3 $
44 |
45 | Classes:
46 | SoXt
47 | SoXtEventHandler
48 |
49 | Author(s): David Mott, Nick Thompson, Paul Isaacs, Alain Dumesny
50 |
51 ______________ S I L I C O N G R A P H I C S I N C . ____________
52 _______________________________________________________________________
53 */
54
55 #include <Inventor/errors/SoDebugError.h>cxx . . $ `<file>/lib/database/include/Inventor/errors/SoDebugError.h`/
56 #include <Inventor/SoDB.h>cxx . . $ `<file>/lib/database/include/Inventor/SoDB.h`/
57 #include <Inventor/SoInteraction.h>cxx . . $ `<file>/lib/interaction/include/Inventor/SoInteraction.h`/
58 #include <Inventor/nodekits/SoNodeKit.h>cxx . . $ `<file>/lib/nodekits/include/Inventor/nodekits/SoNodeKit.h`/
59 #include <Inventor/sensors/SoSensorManager.h>cxx . . $ `<file>/lib/database/include/Inventor/sensors/SoSensorManager.h`/
60 #include <Inventor/Xt/SoXt.h>cxx . . $ `<file>/libSoXt/include/Inventor/Xt/SoXt.h`/
61 #include <Xm/MessageB.h>
62 #include <SoDebug.h>cxx . . $ `<file>/lib/database/include/SoDebug.h`/
63 #include <X11/Intrinsic.h>
64 #include <X11/Xresource.h>
65 #include <X11/StringDefs.h>
66
67
68
69 // This SG_ routine is from /usr/src/X11/motif/overlay_demos.
70 // Someday, it may be a standard function in a lib, but for
71 // now it is just sample code. We include it here for convenience
72 // to our users.
73 extern "C" {
74 int iv_SG_getPopupArgs(Displaycxx . . $ Display# *, int, ArgListcxx . . $ ArgList#, int *);
75 }
76
77
78
79 #include <SoDebug.h>cxx . . $ `<file>/lib/database/include/SoDebug.h`/
80
81
82 static void overlayMenuMappedCBcxx . . $ overlayMenuMappedCB(efdf3a8c7e75b420).(Widgetcxx . . $ Widget# w, Widgetcxx . . $ Widget# shell, XtPointercxx . . $ XtPointer#);
83 static void overlayMenuUnmappedCBcxx . . $ overlayMenuUnmappedCB(efdf3a8c7e75b420).(Widgetcxx . . $ Widget# w, Widgetcxx . . $ Widget# shell, XtPointercxx . . $ XtPointer#);
84
85
86 // this class ties Inventor sensors into Xt events
87 class SoXtEventHandlercxx . . $ SoXtEventHandler# {
88 public:
89 SoXtEventHandlercxx . . $ SoXtEventHandler#SoXtEventHandler(3a7ea920eb8634cb).(XtAppContextcxx . . $ XtAppContext# context);
90
91 private:
92 XtAppContextcxx . . $ XtAppContext# appContextcxx . . $ SoXtEventHandler#appContext.;
93
94 SbBoolcxx . . $ SbBool# timerOncxx . . $ SoXtEventHandler#timerOn.;
95 XtIntervalIdcxx . . $ XtIntervalId# xtTimercxx . . $ SoXtEventHandler#xtTimer.;
96 SbTimecxx . . $ SbTime# currentDeadlinecxx . . $ SoXtEventHandler#currentDeadline.;
97
98 SbBoolcxx . . $ SbBool# workProcOncxx . . $ SoXtEventHandler#workProcOn.;
99 XtWorkProcIdcxx . . $ XtWorkProcId# xtWorkProccxx . . $ SoXtEventHandler#xtWorkProc.;
100
101 // Callback used by the timer
102 static void xtTimerCallbackcxx . . $ SoXtEventHandler#xtTimerCallback(5918bc31ac4a6afc).(XtPointercxx . . $ XtPointer# closure, XtIntervalIdcxx . . $ XtIntervalId# *id);
103
104 // Callback used by the workproc
105 static Booleancxx . . $ Boolean# xtWorkProcCallbackcxx . . $ SoXtEventHandler#xtWorkProcCallback(2b2072af246337f).(XtPointercxx . . $ XtPointer# closure);
106
107 // Callback for changes to the sensor manager
108 static void sensorManagerChangedCallbackcxx . . $ SoXtEventHandler#sensorManagerChangedCallback(5d22bdacc48458e8).(void *data);
109
110 void setUpCallbackscxx . . $ SoXtEventHandler#setUpCallbacks(49f6e7a06ebc5aa8).();
111 };
112
113 class SoExtensionEventHandlercxx . . $ SoExtensionEventHandler# {
114 public:
115 SoExtensionEventHandlercxx . . $ SoExtensionEventHandler#SoExtensionEventHandler(cc4122b38376ad8).(
116 Widgetcxx . . $ Widget# widget,
117 int eventType,
118 XtEventHandlercxx . . $ XtEventHandler# proc,
119 XtPointercxx . . $ XtPointer# data);
120
121 Widgetcxx . . $ Widget# getWidgetcxx . . $ SoExtensionEventHandler#getWidget(5908e39d78662822).() { return widgetcxx . . $ SoExtensionEventHandler#widget.; }
122 int getEventTypecxx . . $ SoExtensionEventHandler#getEventType(b126dc7c1de90089).() { return eventTypecxx . . $ SoExtensionEventHandler#eventType.; }
123 XtEventHandlercxx . . $ XtEventHandler# getEventHandlercxx . . $ SoExtensionEventHandler#getEventHandler(1856817e228e0b40).() { return proccxx . . $ SoExtensionEventHandler#proc.; }
124 XtPointercxx . . $ XtPointer# getClientDatacxx . . $ SoExtensionEventHandler#getClientData(50c7df7de5344ebb).() { return datacxx . . $ SoExtensionEventHandler#data.; }
125
126 private:
127 Widgetcxx . . $ Widget# widgetcxx . . $ SoExtensionEventHandler#widget.;
128 int eventTypecxx . . $ SoExtensionEventHandler#eventType.;
129 XtEventHandlercxx . . $ XtEventHandler# proccxx . . $ SoExtensionEventHandler#proc.;
130 XtPointercxx . . $ XtPointer# datacxx . . $ SoExtensionEventHandler#data.;
131 };
132
133 // static members
134 Widgetcxx . . $ Widget# SoXtcxx . . $ SoXt#::mainWidgetcxx . . $ SoXt#mainWidget. = 0;
135 SoXtEventHandlercxx . . $ SoXtEventHandler# * SoXtcxx . . $ SoXt#::eventHandlercxx . . $ SoXt#eventHandler. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
136 SbPListcxx . . $ SbPList# * SoXtcxx . . $ SoXt#::handlerListcxx . . $ SoXt#handlerList. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
137
138
139 ////////////////////////////////////////////////////////////////////////
140 //
141 // Description:
142 // This initializes the database, interaction, and Xt.
143 // It creates a returns a top level shell widget.
144 //
145 // static public
146 //
147 Widgetcxx . . $ Widget#
148 SoXtcxx . . $ SoXt#::initcxx . . $ SoXt#init(f26396d30ee60cad).(
149 const char *appName,
150 const char *className)
151 //
152 ////////////////////////////////////////////////////////////////////////
153 {
154 // see if we are already initialized!
155 if (mainWidgetcxx . . $ SoXt#mainWidget. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
156 return mainWidgetcxx . . $ SoXt#mainWidget.;
157
158 // init Xt, and store the widget it returns.
159 XtAppContextcxx . . $ XtAppContext# appContext;
160 char *argv[1];
161 int argc = 1;
162 argv[0] = (char *) appName;
163
164 mainWidgetcxx . . $ SoXt#mainWidget. = XtAppInitialize(
165 &appContext, // context will be returned
166 className, // application class
167 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, // options
168 (int *) &argc, argv, // command line args (appName!)
169 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, // fallback_resources
170 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0); // args, num_args
171
172 // init Inventor
173 SoDBcxx . . $ SoDB#::initcxx . . $ SoDB#init(49f6e7a06ebc5aa8).();
174 SoNodeKitcxx . . $ SoNodeKit#::initcxx . . $ SoNodeKit#init(49f6e7a06ebc5aa8).();
175 SoInteractioncxx . . $ SoInteraction#::initcxx . . $ SoInteraction#init(49f6e7a06ebc5aa8).();
176
177 // bind Inventor with Xt
178 eventHandlercxx . . $ SoXt#eventHandler. = new SoXtEventHandlercxx . . $ SoXtEventHandler#SoXtEventHandler(3a7ea920eb8634cb).(XtWidgetToApplicationContext(mainWidgetcxx . . $ SoXt#mainWidget.));
179
180 return mainWidgetcxx . . $ SoXt#mainWidget.;
181 }
182
183 ////////////////////////////////////////////////////////////////////////
184 //
185 // Description:
186 // This initializes the database and interaction. Xt was initialized
187 // by the caller.
188 //
189 // static public
190 //
191 void
192 SoXtcxx . . $ SoXt#::initcxx . . $ SoXt#init(cfa999c5a14729dd).(Widgetcxx . . $ Widget# topLevelWidget)
193 //
194 ////////////////////////////////////////////////////////////////////////
195 {
196 // see if we are already initialized!
197 if (mainWidgetcxx . . $ SoXt#mainWidget. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
198 return;
199
200 // see if the passed widget is ok
201 if (topLevelWidget == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
202 return;
203
204 // save the widget
205 mainWidgetcxx . . $ SoXt#mainWidget. = topLevelWidget;
206
207 // init Inventor
208 SoDBcxx . . $ SoDB#::initcxx . . $ SoDB#init(49f6e7a06ebc5aa8).();
209 SoNodeKitcxx . . $ SoNodeKit#::initcxx . . $ SoNodeKit#init(49f6e7a06ebc5aa8).();
210 SoInteractioncxx . . $ SoInteraction#::initcxx . . $ SoInteraction#init(49f6e7a06ebc5aa8).();
211
212 // bind Inventor with Xt
213 eventHandlercxx . . $ SoXt#eventHandler. = new SoXtEventHandlercxx . . $ SoXtEventHandler#SoXtEventHandler(3a7ea920eb8634cb).(XtWidgetToApplicationContext(mainWidgetcxx . . $ SoXt#mainWidget.));
214 }
215
216 ////////////////////////////////////////////////////////////////////////
217 //
218 // Description:
219 // This displays the passed widget.
220 //
221 // static public
222 //
223 void
224 SoXtcxx . . $ SoXt#::showcxx . . $ SoXt#show(cfa999c5a14729dd).(Widgetcxx . . $ Widget# w)
225 //
226 ////////////////////////////////////////////////////////////////////////
227 {
228 if (w == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
229 return;
230
231 if (XtIsShellcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1078:9`!(w)) {
232 // raise and de-iconify the window if it already exists
233 if (XtWindow(w) != 0)
234 XMapRaised(XtDisplay(w), XtWindow(w));
235 else {
236 XtRealizeWidget(w);
237 XMapWindow(XtDisplay(w), XtWindow(w));
238 }
239 }
240 else
241 XtManageChild(w);
242 }
243
244 ////////////////////////////////////////////////////////////////////////
245 //
246 // Description:
247 // This hides the passed widget.
248 //
249 // static public
250 //
251 void
252 SoXtcxx . . $ SoXt#::hidecxx . . $ SoXt#hide(cfa999c5a14729dd).(Widgetcxx . . $ Widget# w)
253 //
254 ////////////////////////////////////////////////////////////////////////
255 {
256 if (w == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
257 return;
258
259 // ??? temporary disable the idle queue timer to prevent a redraw timer
260 // ??? from happening before we get chance to process all unmap events
261 // ??? that will be generated from this hide(). SoXtComponents will
262 // ??? depend of those unmap events to know that they are not visible.
263 // ??? .....see comment below about XSync()......
264 SbTimecxx . . $ SbTime# savedTime = SoDBcxx . . $ SoDB#::getDelaySensorTimeoutcxx . . $ SoDB#getDelaySensorTimeout(7547d33f09dd6226).();
265 if (savedTime !=cxx . . $ SbTime#`operator!=`(64f90dbbb710e095). SbTimecxx . . $ SbTime#::zerocxx . . $ SbTime#zero(a7df0c55874e8fee).())
266 SoDBcxx . . $ SoDB#::setDelaySensorTimeoutcxx . . $ SoDB#setDelaySensorTimeout(cf18edd44c50d8bf).(0.0cxx . . $ SbTime#SbTime(ba8836b59fb42830).);
267
268 if (XtIsShellcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1078:9`!(w)) {
269 if (XtWindow(w))
270 XUnmapWindow(XtDisplay(w), XtWindow(w));
271 }
272 else
273 XtUnmanageChild(w);
274
275 // call XSync() to force the unmap events to be received by the X server,
276 // which are needed to prevent SoXtComponents from redrawing into a
277 // window that is unmaped. Redrawing to an unmapped window seems to
278 // screw up some hardware gfx the NEXT time you redraw to the
279 // front buffer. (see bug 290854)
280 XSync(XtDisplay(w), FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!);
281
282 // ??? restore the timer. This actually will give us about 1/10 second to
283 // ??? process all unmap events...idealy we could use an XSendEvent() to
284 // ??? restore the timer with our onw event.
285 if (savedTime !=cxx . . $ SbTime#`operator!=`(64f90dbbb710e095). SbTimecxx . . $ SbTime#::zerocxx . . $ SbTime#zero(a7df0c55874e8fee).())
286 SoDBcxx . . $ SoDB#::setDelaySensorTimeoutcxx . . $ SoDB#setDelaySensorTimeout(cf18edd44c50d8bf).(savedTime);
287 }
288
289 ////////////////////////////////////////////////////////////////////////
290 //
291 // Description:
292 // This adds the passed proc as an event handler for an X extension
293 // event.
294 //
295 // static public
296 //
297 void
298 SoXtcxx . . $ SoXt#::addExtensionEventHandlercxx . . $ SoXt#addExtensionEventHandler(cc4122b38376ad8).(
299 Widgetcxx . . $ Widget# w,
300 int extensionEventType,
301 XtEventHandlercxx . . $ XtEventHandler# proc,
302 XtPointercxx . . $ XtPointer# clientData)
303 //
304 ////////////////////////////////////////////////////////////////////////
305 {
306 if (handlerListcxx . . $ SoXt#handlerList. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
307 handlerListcxx . . $ SoXt#handlerList. = new SbPListcxx . . $ SbPList#;
308
309 // add the passed proc as an event handler for extension events on w
310 SoExtensionEventHandlercxx . . $ SoExtensionEventHandler# *data = new SoExtensionEventHandlercxx . . $ SoExtensionEventHandler#
311 (w, extensionEventType, proc, clientData);
312
313 handlerListcxx . . $ SoXt#handlerList.->appendcxx . . $ SbPList#append(5d22bdacc48458e8).(data);
314 }
315
316 ////////////////////////////////////////////////////////////////////////
317 //
318 // Description:
319 // This removes the passed proc as an event handler for and X extension
320 // event.
321 //
322 // static public
323 //
324 void
325 SoXtcxx . . $ SoXt#::removeExtensionEventHandlercxx . . $ SoXt#removeExtensionEventHandler(cc4122b38376ad8).(
326 Widgetcxx . . $ Widget# w,
327 int extensionEventType,
328 XtEventHandlercxx . . $ XtEventHandler# proc,
329 XtPointercxx . . $ XtPointer# clientData)
330 //
331 ////////////////////////////////////////////////////////////////////////
332 {
333 // loop through each item in handlerList,
334 // and see if w,eventType,proc, and data match.
335 SbBoolcxx . . $ SbBool# found = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
336 for (int i = 0; !found && (i < handlerListcxx . . $ SoXt#handlerList.->getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).()); i++) {
337 SoExtensionEventHandlercxx . . $ SoExtensionEventHandler# *handler =
338 (SoExtensionEventHandlercxx . . $ SoExtensionEventHandler# *) (*handlerListcxx . . $ SoXt#handlerList.)[cxx . . $ SbPList#`operator[]`(5f9a4f363ac2f591).i];
339
340 if ((handler->getWidgetcxx . . $ SoExtensionEventHandler#getWidget(5908e39d78662822).() == w) &&
341 (handler->getEventTypecxx . . $ SoExtensionEventHandler#getEventType(b126dc7c1de90089).() == extensionEventType) &&
342 (handler->getEventHandlercxx . . $ SoExtensionEventHandler#getEventHandler(1856817e228e0b40).() == proc) &&
343 (handler->getClientDatacxx . . $ SoExtensionEventHandler#getClientData(50c7df7de5344ebb).() == clientData)) {
344 found = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
345 handlerListcxx . . $ SoXt#handlerList.->removecxx . . $ SbPList#remove(d4f767463ce0a6b3).(i);
346 }
347 }
348 }
349
350 ////////////////////////////////////////////////////////////////////////
351 //
352 // Description:
353 // This locates the widget which will handle the event.
354 // Input: event
355 // Output: w, proc, clientData
356 //
357 // static protected
358 //
359 void
360 SoXtcxx . . $ SoXt#::getExtensionEventHandlercxx . . $ SoXt#getExtensionEventHandler(abe47ddd0fc31605).(
361 XEventcxx . . $ XEvent# *event,
362 Widgetcxx . . $ Widget# &w,
363 XtEventHandlercxx . . $ XtEventHandler# &proc,
364 XtPointercxx . . $ XtPointer# &clientData)
365 //
366 ////////////////////////////////////////////////////////////////////////
367 {
368 // extension event. look up in our list of event handlers
369 // for a match
370 proc = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
371 for (int i = 0; (proc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) && (i < handlerListcxx . . $ SoXt#handlerList.->getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).()); i++) {
372 SoExtensionEventHandlercxx . . $ SoExtensionEventHandler# *handler =
373 (SoExtensionEventHandlercxx . . $ SoExtensionEventHandler# *) (*handlerListcxx . . $ SoXt#handlerList.)[cxx . . $ SbPList#`operator[]`(5f9a4f363ac2f591).i];
374
375 w = XtWindowToWidget(event->xanycxx . . $ _XEvent#xany..displaycxx . . $ $anonymous_type_17d7f07cf933eea7_53#display.,
376 event->xanycxx . . $ _XEvent#xany..windowcxx . . $ $anonymous_type_17d7f07cf933eea7_53#window.);
377
378 if (handler->getWidgetcxx . . $ SoExtensionEventHandler#getWidget(5908e39d78662822).() == w) {
379 if (handler->getEventTypecxx . . $ SoExtensionEventHandler#getEventType(b126dc7c1de90089).() == event->typecxx . . $ _XEvent#type.) {
380 // we found a match!
381 proc = handler->getEventHandlercxx . . $ SoExtensionEventHandler#getEventHandler(1856817e228e0b40).();
382 clientData = handler->getClientDatacxx . . $ SoExtensionEventHandler#getClientData(50c7df7de5344ebb).();
383 }
384 }
385 }
386 }
387
388 ////////////////////////////////////////////////////////////////////////
389 //
390 // Description:
391 // This dispatches events.
392 //
393 // static public
394 //
395 Booleancxx . . $ Boolean#
396 SoXtcxx . . $ SoXt#::dispatchEventcxx . . $ SoXt#dispatchEvent(cdfbd57a4bf44d89).(XEventcxx . . $ XEvent# *event)
397 //
398 ////////////////////////////////////////////////////////////////////////
399 {
400 Booleancxx . . $ Boolean# success = Truecxx . . $ `<external>/4815335266304551920/ICElib.h:37:9`!;
401
402 if(event->typecxx . . $ _XEvent#type. >= LASTEventcxx . . $ `<external>/1208737181511191802/X.h:215:9`!) {
403 XtEventHandlercxx . . $ XtEventHandler# proc;
404 XtPointercxx . . $ XtPointer# clientData;
405 Widgetcxx . . $ Widget# w;
406 Booleancxx . . $ Boolean# dummy;
407
408 // Get the event handling function which was
409 // registered with Inventor for handling this
410 // event type in this widget
411 SoXtcxx . . $ SoXt#::getExtensionEventHandlercxx . . $ SoXt#getExtensionEventHandler(abe47ddd0fc31605).(event, w, proc, clientData);
412
413 // Call the event handler!
414 if (proc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
415 success = Falsecxx . . $ `<external>/4815335266304551920/ICElib.h:38:9`!;
416 else
417 (*proc) (w, clientData, event, &dummy);
418
419 }
420
421 // else it is not an extension event - let Xt dispatch it
422 else success = XtDispatchEvent(event);
423
424 return success;
425 }
426
427 ////////////////////////////////////////////////////////////////////////
428 //
429 // Description:
430 // This retrieves and dispatches events (it loops forever!)
431 //
432 // static public
433 //
434 void
435 SoXtcxx . . $ SoXt#::mainLoopcxx . . $ SoXt#mainLoop(49f6e7a06ebc5aa8).()
436 //
437 ////////////////////////////////////////////////////////////////////////
438 {
439 if (mainWidgetcxx . . $ SoXt#mainWidget. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
440 #ifdef DEBUG
441 SoDebugError::post("SoXt::mainLoop",
442 "exiting -- SoXt::init never called");
443 #endif
444 return;
445 }
446
447 // We cannot call XtAppMainLoop, because we need to handle
448 // extension devices, like the spaceball. (Xt will ignore them).
449 XtAppContextcxx . . $ XtAppContext# context = getAppContextcxx . . $ SoXt#getAppContext(21316aac53ae5b70).();
450 XEventcxx . . $ XEvent# event;
451
452 for (;;) {
453 SoXtcxx . . $ SoXt#::nextEventcxx . . $ SoXt#nextEvent(f69b08e3c1a31b7a).(context, &event);
454 SoXtcxx . . $ SoXt#::dispatchEventcxx . . $ SoXt#dispatchEvent(cdfbd57a4bf44d89).(&event);
455 }
456 }
457
458 ////////////////////////////////////////////////////////////////////////
459 //
460 // Description:
461 // This returns the application context for the mainWidget.
462 //
463 // static public
464 //
465 XtAppContextcxx . . $ XtAppContext#
466 SoXtcxx . . $ SoXt#::getAppContextcxx . . $ SoXt#getAppContext(21316aac53ae5b70).()
467 //
468 ////////////////////////////////////////////////////////////////////////
469 {
470 return mainWidgetcxx . . $ SoXt#mainWidget. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ? NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! : XtWidgetToApplicationContext(mainWidgetcxx . . $ SoXt#mainWidget.);
471 }
472
473 ////////////////////////////////////////////////////////////////////////
474 //
475 // Description:
476 // This returns the display for the mainWidget.
477 //
478 // static public
479 //
480 Displaycxx . . $ Display# *
481 SoXtcxx . . $ SoXt#::getDisplaycxx . . $ SoXt#getDisplay(17eb9fe335efbb88).()
482 //
483 ////////////////////////////////////////////////////////////////////////
484 {
485 return mainWidgetcxx . . $ SoXt#mainWidget. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ? NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! : XtDisplay(mainWidgetcxx . . $ SoXt#mainWidget.);
486 }
487
488 ////////////////////////////////////////////////////////////////////////
489 //
490 // Description:
491 // This returns the display for the mainWidget.
492 //
493 // static public
494 //
495 Widgetcxx . . $ Widget#
496 SoXtcxx . . $ SoXt#::getTopLevelWidgetcxx . . $ SoXt#getTopLevelWidget(5908e39d78662822).()
497 //
498 ////////////////////////////////////////////////////////////////////////
499 {
500 return mainWidgetcxx . . $ SoXt#mainWidget.;
501 }
502
503 ////////////////////////////////////////////////////////////////////////
504 //
505 // Description:
506 // Convert the char* to an XmString.
507 //
508 // static public
509 //
510 XmString
511 SoXtcxx . . $ SoXt#::encodeStringcxx . . $ SoXt#encodeString(420e528e8186b5e6).(char *s)
512 //
513 ////////////////////////////////////////////////////////////////////////
514 {
515 XmString xs = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
516
517 if (s != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
518 xs = XmStringCreate(s, XmSTRING_DEFAULT_CHARSETcxx . . $ `<external>/427401153941432933/XmStrDefs.h:5447:9`!);
519
520 return xs;
521 }
522
523 ////////////////////////////////////////////////////////////////////////
524 //
525 // Description:
526 // Convert the XmString to a char*.
527 //
528 // static public
529 //
530 char *
531 SoXtcxx . . $ SoXt#::decodeStringcxx . . $ SoXt#decodeString(f22a079418a7e7c7).(XmString xs)
532 //
533 ////////////////////////////////////////////////////////////////////////
534 {
535 XmStringContext ctx;
536 char *text = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
537 XmStringCharSet charset;
538 XmStringDirection dirRtoL;
539 Booleancxx . . $ Boolean# separator;
540 Booleancxx . . $ Boolean# initOK = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
541 Booleancxx . . $ Boolean# getOK = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
542
543 initOK = XmStringInitContext(&ctx, xs);
544
545 if (initOK)
546 getOK = XmStringGetNextSegment(ctx, &text,
547 &charset, &dirRtoL, &separator);
548
549 #ifdef DEBUG
550 if (!initOK)
551 SoDebugError::post("SoXt::decodeString",
552 "XmStringInitContext failed.");
553 if (!getOK)
554 SoDebugError::post("SoXt::decodeString",
555 "XmStringGetNextSegment failed.");
556 #endif
557
558 return text;
559 }
560
561
562 //----------------------------------------------------------------------
563 //
564 // SoXtEventHandler - this class ties in sensors to Xt events
565 //
566 //----------------------------------------------------------------------
567
568 SoXtEventHandlercxx . . $ SoXtEventHandler#::SoXtEventHandlercxx . . $ SoXtEventHandler#SoXtEventHandler(3a7ea920eb8634cb).(XtAppContextcxx . . $ XtAppContext# context)
569 {
570 appContextcxx . . $ SoXtEventHandler#appContext. = context;
571 timerOncxx . . $ SoXtEventHandler#timerOn. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
572 workProcOncxx . . $ SoXtEventHandler#workProcOn. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
573
574 SoDBcxx . . $ SoDB#::getSensorManagercxx . . $ SoDB#getSensorManager(82d1414facc01a9a).()->setChangedCallbackcxx . . $ SoSensorManager#setChangedCallback(97a347b124788245).
575 (SoXtEventHandlercxx . . $ SoXtEventHandler#::sensorManagerChangedCallbackcxx . . $ SoXtEventHandler#sensorManagerChangedCallback(5d22bdacc48458e8).,
576 this);
577 // Call this once because things might already be in the timer queue.
578 // If we don't call this and no new things happen, then the callbacks
579 // will never be set up.
580 setUpCallbackscxx . . $ SoXtEventHandler#setUpCallbacks(49f6e7a06ebc5aa8).();
581 }
582
583 void
584 SoXtEventHandlercxx . . $ SoXtEventHandler#::setUpCallbackscxx . . $ SoXtEventHandler#setUpCallbacks(49f6e7a06ebc5aa8).()
585 {
586 SbTimecxx . . $ SbTime# nextEventcxx . . $ SbTime#SbTime(49f6e7a06ebc5aa8).;
587
588 // If we have a timer at some point, schedule that
589 if (SoDBcxx . . $ SoDB#::getSensorManagercxx . . $ SoDB#getSensorManager(82d1414facc01a9a).()->isTimerSensorPendingcxx . . $ SoSensorManager#isTimerSensorPending(e7fdf436ad9cf213).(nextEvent)) {
590 // Only change the timer if its deadline is different from the
591 // current one.
592 if (!timerOncxx . . $ SoXtEventHandler#timerOn. || nextEvent !=cxx . . $ SbTime#`operator!=`(64f90dbbb710e095). currentDeadlinecxx . . $ SoXtEventHandler#currentDeadline.) {
593 long msec; // System long
594
595 if (timerOncxx . . $ SoXtEventHandler#timerOn.) { // get rid of existing timer if present
596 XtRemoveTimeOut(xtTimercxx . . $ SoXtEventHandler#xtTimer.);
597 timerOncxx . . $ SoXtEventHandler#timerOn. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
598 }
599
600 currentDeadlinecxx . . $ SoXtEventHandler#currentDeadline. =cxx . . $ SbTime#`operator=`(73027bd0a2429d7a). nextEvent;
601 msec = (nextEvent -cxx . . $ operator-(22f32cf074e3d57c). SbTimecxx . . $ SbTime#::getTimeOfDaycxx . . $ SbTime#getTimeOfDay(a7df0c55874e8fee).()).getMsecValuecxx . . $ SbTime#getMsecValue(fe4d2d262d4164a8).();
602
603 xtTimercxx . . $ SoXtEventHandler#xtTimer. = XtAppAddTimeOut(appContextcxx . . $ SoXtEventHandler#appContext., msec > 0 ? msec : 0,
604 (XtTimerCallbackProccxx . . $ XtTimerCallbackProc#)
605 SoXtEventHandlercxx . . $ SoXtEventHandler#::xtTimerCallbackcxx . . $ SoXtEventHandler#xtTimerCallback(5918bc31ac4a6afc).,
606 (XtPointercxx . . $ XtPointer#) this);
607 timerOncxx . . $ SoXtEventHandler#timerOn. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
608 #ifdef DEBUG
609 if (SoDebug::GetEnv("IV_DEBUG_SENSORS")) {
610 SoDebug::RTPrintf("XtAppAddTimeOut %d msec\n", msec);
611 }
612 #endif
613 }
614 }
615 else if (timerOncxx . . $ SoXtEventHandler#timerOn.) { // get rid of existing timer
616 XtRemoveTimeOut(xtTimercxx . . $ SoXtEventHandler#xtTimer.);
617 timerOncxx . . $ SoXtEventHandler#timerOn. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
618 #ifdef DEBUG
619 if (SoDebug::GetEnv("IV_DEBUG_SENSORS")) {
620 SoDebug::RTPrintf("XtRemoveTimeOut\n");
621 }
622 #endif
623 }
624
625 // If we have an idle task, schedule a workproc for it
626 if (SoDBcxx . . $ SoDB#::getSensorManagercxx . . $ SoDB#getSensorManager(82d1414facc01a9a).()->isDelaySensorPendingcxx . . $ SoSensorManager#isDelaySensorPending(b126dc7c1de90089).()) {
627 // only schedule it if one is not already active
628 if (!workProcOncxx . . $ SoXtEventHandler#workProcOn.) {
629 xtWorkProccxx . . $ SoXtEventHandler#xtWorkProc. =
630 XtAppAddWorkProc(appContextcxx . . $ SoXtEventHandler#appContext.,
631 (XtWorkProccxx . . $ XtWorkProc#)
632 SoXtEventHandlercxx . . $ SoXtEventHandler#::xtWorkProcCallbackcxx . . $ SoXtEventHandler#xtWorkProcCallback(2b2072af246337f).,
633 (XtPointercxx . . $ XtPointer#) this);
634 workProcOncxx . . $ SoXtEventHandler#workProcOn. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
635 #ifdef DEBUG
636 if (SoDebug::GetEnv("IV_DEBUG_SENSORS")) {
637 SoDebug::RTPrintf("XtAppAddWorkProc\n");
638 }
639 #endif
640 }
641 }
642 else if (workProcOncxx . . $ SoXtEventHandler#workProcOn.) { // remove obsolete workproc
643 XtRemoveWorkProc(xtWorkProccxx . . $ SoXtEventHandler#xtWorkProc.);
644 workProcOncxx . . $ SoXtEventHandler#workProcOn. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
645 #ifdef DEBUG
646 if (SoDebug::GetEnv("IV_DEBUG_SENSORS")) {
647 SoDebug::RTPrintf("XtRemoveWorkProc\n");
648 }
649 #endif
650 }
651 }
652
653 void
654 SoXtEventHandlercxx . . $ SoXtEventHandler#::xtTimerCallbackcxx . . $ SoXtEventHandler#xtTimerCallback(5918bc31ac4a6afc).(XtPointercxx . . $ XtPointer# closure, XtIntervalIdcxx . . $ XtIntervalId# *)
655 {
656 SoXtEventHandlercxx . . $ SoXtEventHandler# *eh = (SoXtEventHandlercxx . . $ SoXtEventHandler# *) closure;
657
658 // process the timer queue
659 SoDBcxx . . $ SoDB#::getSensorManagercxx . . $ SoDB#getSensorManager(82d1414facc01a9a).()->processTimerQueuecxx . . $ SoSensorManager#processTimerQueue(49f6e7a06ebc5aa8).();
660
661 // set up for the next time around
662 // hide the fact that this timer exists so that setUpEvents
663 // won't try to delete it (Xt will do that automatically)
664 eh->timerOncxx . . $ SoXtEventHandler#timerOn. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
665 eh->setUpCallbackscxx . . $ SoXtEventHandler#setUpCallbacks(49f6e7a06ebc5aa8).();
666 }
667
668 Booleancxx . . $ Boolean#
669 SoXtEventHandlercxx . . $ SoXtEventHandler#::xtWorkProcCallbackcxx . . $ SoXtEventHandler#xtWorkProcCallback(2b2072af246337f).(XtPointercxx . . $ XtPointer# closure)
670 {
671 SoXtEventHandlercxx . . $ SoXtEventHandler# *eh = (SoXtEventHandlercxx . . $ SoXtEventHandler# *) closure;
672
673 // process the idle queue
674 SoDBcxx . . $ SoDB#::getSensorManagercxx . . $ SoDB#getSensorManager(82d1414facc01a9a).()->processDelayQueuecxx . . $ SoSensorManager#processDelayQueue(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
675
676 // set up for the next time around
677 // hide the fact that this workproc exists so that setUpEvents
678 // won't try to delete it (Xt will do that automatically)
679 eh->workProcOncxx . . $ SoXtEventHandler#workProcOn. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
680 eh->setUpCallbackscxx . . $ SoXtEventHandler#setUpCallbacks(49f6e7a06ebc5aa8).();
681
682 // Always return TRUE, meaning delete the workproc now. The
683 // workproc will be installed again if it is necessary. This
684 // should be pretty cheap, as Xt keeps a pool of these.
685 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
686 }
687
688 // Callback for changes to the sensor manager
689 void
690 SoXtEventHandlercxx . . $ SoXtEventHandler#::sensorManagerChangedCallbackcxx . . $ SoXtEventHandler#sensorManagerChangedCallback(5d22bdacc48458e8).(void *data)
691 {
692 SoXtEventHandlercxx . . $ SoXtEventHandler# *eh = (SoXtEventHandlercxx . . $ SoXtEventHandler# *) data;
693
694 // update the Xt timeout and workproc if necessary
695 eh->setUpCallbackscxx . . $ SoXtEventHandler#setUpCallbacks(49f6e7a06ebc5aa8).();
696 }
697
698 SoExtensionEventHandlercxx . . $ SoExtensionEventHandler#::SoExtensionEventHandlercxx . . $ SoExtensionEventHandler#SoExtensionEventHandler(cc4122b38376ad8).(
699 Widgetcxx . . $ Widget# w,
700 int et,
701 XtEventHandlercxx . . $ XtEventHandler# p,
702 XtPointercxx . . $ XtPointer# d)
703 {
704 widgetcxx . . $ SoExtensionEventHandler#widget. = w;
705 eventTypecxx . . $ SoExtensionEventHandler#eventType. = et;
706 proccxx . . $ SoExtensionEventHandler#proc. = p;
707 datacxx . . $ SoExtensionEventHandler#data. = d;
708 }
709
710 ////////////////////////////////////////////////////////////////////////
711 //
712 // Resize the given widget. It calls XtSetArg/Values on the widget.
713 //
714 // Use: static public
715 void
716 SoXtcxx . . $ SoXt#::setWidgetSizecxx . . $ SoXt#setWidgetSize(d484dc10591e8426).(Widgetcxx . . $ Widget# w, const SbVec2scxx . . $ SbVec2s# &size)
717 //
718 ////////////////////////////////////////////////////////////////////////
719 {
720 if (w == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
721 return;
722
723 Argcxx . . $ Arg# args[2];
724 XtSetArgcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1160:9`!(args[0], XtNwidthcxx . . $ `<external>/1418573538627700912/StringDefs.h:564:9`!, size[0]);
725 XtSetArgcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1160:9`!(args[1], XtNheightcxx . . $ `<external>/1418573538627700912/StringDefs.h:384:9`!, size[1]);
726 XtSetValues(w, args, 2);
727 }
728
729 ////////////////////////////////////////////////////////////////////////
730 //
731 // Returns the given widget size.
732 //
733 // Use: static public
734 SbVec2scxx . . $ SbVec2s#
735 SoXtcxx . . $ SoXt#::getWidgetSizecxx . . $ SoXt#getWidgetSize(84d4688b36c419b7).(Widgetcxx . . $ Widget# w)
736 //
737 ////////////////////////////////////////////////////////////////////////
738 {
739 if (w == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
740 return SbVec2scxx . . $ SbVec2s#SbVec2s(af780a7c10c7990f).(0, 0);
741
742 Argcxx . . $ Arg# args[2];
743 short _w, _h; // HAS to be shorts for XtGetValues to work !!
744 XtSetArgcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1160:9`!(args[0], XtNheightcxx . . $ `<external>/1418573538627700912/StringDefs.h:384:9`!, &_h);
745 XtSetArgcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1160:9`!(args[1], XtNwidthcxx . . $ `<external>/1418573538627700912/StringDefs.h:564:9`!, &_w);
746 XtGetValues(w, args, 2);
747 return SbVec2scxx . . $ SbVec2s#SbVec2s(af780a7c10c7990f).(_w, _h);
748 }
749
750 ////////////////////////////////////////////////////////////////////////
751 //
752 // Returns the shell widget which contains this widget
753 //
754 // Use: static public
755 Widgetcxx . . $ Widget#
756 SoXtcxx . . $ SoXt#::getShellWidgetcxx . . $ SoXt#getShellWidget(a686be44a4028679).(Widgetcxx . . $ Widget# w)
757 //
758 ////////////////////////////////////////////////////////////////////////
759 {
760 for (; w != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; w = XtParent(w))
761 if (XtIsShellcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1078:9`!(w))
762 return w;
763
764 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
765 }
766
767 static void destroyDialogCBcxx . . $ destroyDialogCB(ced67b223103c42b).(Widgetcxx . . $ Widget# dialog, void *, void *)
768 { XtDestroyWidget(dialog); }
769
770 ////////////////////////////////////////////////////////////////////////
771 //
772 // creates a simple error dialog box with the given error
773 //
774 // Use: static public
775 void
776 SoXtcxx . . $ SoXt#::createSimpleErrorDialogcxx . . $ SoXt#createSimpleErrorDialog(f9dbcb154b73d276).(Widgetcxx . . $ Widget# widget,
777 char *dialogTitle, char *str1, char *str2)
778 //
779 ////////////////////////////////////////////////////////////////////////
780 {
781 // ??? Make the motif dialog on the shell of the 'widget' variable
782 // ??? instead of the 'widget' itself otherwise the color editor
783 // ??? has problem building once the dialog has been opened.
784 // ??? I can't figure that one out. Weird... (alain)
785 Widgetcxx . . $ Widget# shell = SoXtcxx . . $ SoXt#::getShellWidgetcxx . . $ SoXt#getShellWidget(a686be44a4028679).(widget);
786 if (shell == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
787 return;
788
789 Argcxx . . $ Arg# args[5];
790 XmString xmstr = XmStringCreateSimple(str1);
791 if (str2 != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
792 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
793 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
794 xmstr = XmStringConcat(xmstr, XmStringCreateSimple(str2));
795 }
796
797 int n = 0;
798 XtSetArgcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1160:9`!(args[n], XmNautoUnmanagecxx . . $ `<external>/427401153941432933/XmStrDefs.h:2409:9`!, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); n++;
799 XtSetArgcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1160:9`!(args[n], XtNtitlecxx . . $ `<external>/5585922817170358163/Shell.h:275:9`!, dialogTitle); n++;
800 XtSetArgcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1160:9`!(args[n], XmNmessageStringcxx . . $ `<external>/427401153941432933/XmStrDefs.h:3018:9`!, xmstr); n++;
801 XtSetArgcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1160:9`!(args[n], XmNdialogStylecxx . . $ `<external>/427401153941432933/XmStrDefs.h:2598:9`!, XmDIALOG_FULL_APPLICATION_MODAL); n++;
802 Widgetcxx . . $ Widget# dialog = XmCreateErrorDialog(shell, "Error Dialog", args, n);
803 XmStringFree(xmstr);
804
805 XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
806 XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
807
808 // register callback to destroy (and not just unmap) the dialog
809 XtAddCallback(dialog, XmNokCallbackcxx . . $ `<external>/427401153941432933/XmStrDefs.h:3117:9`!,
810 (XtCallbackProccxx . . $ XtCallbackProc#) destroyDialogCBcxx . . $ destroyDialogCB(ced67b223103c42b)., (XtPointercxx . . $ XtPointer#)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
811
812 XtManageChild(dialog);
813 }
814
815 ////////////////////////////////////////////////////////////////////////
816 //
817 // Convenience routine for creating menus in the popup planes.
818 //
819 // Use: static public
820 void
821 SoXtcxx . . $ SoXt#::getPopupArgscxx . . $ SoXt#getPopupArgs(7a40afbc522bec16).(
822 Displaycxx . . $ Display# *d,
823 int scr,
824 ArgListcxx . . $ ArgList# args,
825 int *n)
826 //
827 ////////////////////////////////////////////////////////////////////////
828 {
829 iv_SG_getPopupArgs(d, scr, args, n);
830 }
831
832
833 ////////////////////////////////////////////////////////////////////////
834 //
835 // register map/unmap callbacks to load/unload the given color maps
836 // when the pulldown menu (or popup menu) gets mapped.
837 //
838 // Use: static public
839 void
840 SoXtcxx . . $ SoXt#::registerColormapLoadcxx . . $ SoXt#registerColormapLoad(ac584ac68aa7390d).(Widgetcxx . . $ Widget# w, Widgetcxx . . $ Widget# shell)
841 //
842 ////////////////////////////////////////////////////////////////////////
843 {
844 if (! w || ! shell || ! XtIsShellcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1078:9`!(shell))
845 return;
846
847 XtAddCallback(w, XmNmapCallbackcxx . . $ `<external>/427401153941432933/XmStrDefs.h:2958:9`!, (XtCallbackProccxx . . $ XtCallbackProc#) overlayMenuMappedCBcxx . . $ overlayMenuMappedCB(efdf3a8c7e75b420)., shell);
848 XtAddCallback(w, XmNunmapCallbackcxx . . $ `<external>/427401153941432933/XmStrDefs.h:3510:9`!, (XtCallbackProccxx . . $ XtCallbackProc#) overlayMenuUnmappedCBcxx . . $ overlayMenuUnmappedCB(efdf3a8c7e75b420)., shell);
849 }
850
851 //
852 // Called when an overlay menu (pulldown or popup) is about to be
853 // mapped - this will load the correct color map on the window.
854 //
855 static void
856 overlayMenuMappedCBcxx . . $ overlayMenuMappedCB(efdf3a8c7e75b420).(Widgetcxx . . $ Widget# w, Widgetcxx . . $ Widget# shell, XtPointercxx . . $ XtPointer#)
857 {
858 //printf("MAP overlayMenuMappedCB called\n");
859 SoXtcxx . . $ SoXt#::addColormapToShellcxx . . $ SoXt#addColormapToShell(ac584ac68aa7390d).(w, shell);
860 }
861
862 //
863 // Called when an overlay menu (pulldown or popup) is no longer
864 // mapped - this will unload the color map to make sure that the OGL
865 // overlay (really popup planes on 8 bit machine) colormap gets used.
866 //
867 static void
868 overlayMenuUnmappedCBcxx . . $ overlayMenuUnmappedCB(efdf3a8c7e75b420).(Widgetcxx . . $ Widget# w, Widgetcxx . . $ Widget# shell, XtPointercxx . . $ XtPointer#)
869 {
870 //printf("UNMAP overlayMenuUnmappedCB called\n");
871 SoXtcxx . . $ SoXt#::removeColormapFromShellcxx . . $ SoXt#removeColormapFromShell(ac584ac68aa7390d).(w, shell);
872 }
873
874
875 ////////////////////////////////////////////////////////////////////////
876 //
877 // Convenience routine to load the given colormap
878 //
879 // Use: static public
880 void
881 SoXtcxx . . $ SoXt#::addColormapToShellcxx . . $ SoXt#addColormapToShell(ac584ac68aa7390d).(Widgetcxx . . $ Widget# w, Widgetcxx . . $ Widget# shell)
882 //
883 ////////////////////////////////////////////////////////////////////////
884 {
885 if (! w || ! shell || ! XtIsShellcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1078:9`!(shell))
886 return;
887
888 // load the color map RIGH AWAY to reduce pulldown menu flickers
889 Colormapcxx . . $ Colormap# map;
890 XtVaGetValues(w, XmNcolormapcxx . . $ `<external>/427401153941432933/XmStrDefs.h:6006:9`!, &map, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
891 XInstallColormap(XtDisplay(w), map);
892
893 // check to see if there is already a property
894 Windowcxx . . $ Window# *windowsReturn;
895 int countReturn;
896 Statuscxx . . $ `<external>/4815335266304551920/ICElib.h:36:9`! status = XGetWMColormapWindows(XtDisplay(shell),
897 XtWindow(shell), &windowsReturn, &countReturn);
898
899 // if no property, just create one
900 if (!status)
901 {
902 Windowcxx . . $ Window# windows[2];
903 windows[0] = XtWindow(w);
904 windows[1] = XtWindow(shell);
905 XSetWMColormapWindows(XtDisplay(shell), XtWindow(shell),
906 windows, 2);
907 }
908 // else there was a property, add myself to the beginning
909 else {
910 Windowcxx . . $ Window# *windows = (Windowcxx . . $ Window# *)XtMalloc((sizeof(Windowcxx . . $ Window#))*
911 (countReturn+1));
912 windows[0] = XtWindow(w);
913 for (int i=0; i<countReturn; i++)
914 windows[i+1] = windowsReturn[i];
915 XSetWMColormapWindows(XtDisplay(shell), XtWindow(shell),
916 windows, countReturn+1);
917 XtFree((char *)windows);
918 XFree((char *)windowsReturn);
919 }
920 }
921
922 ////////////////////////////////////////////////////////////////////////
923 //
924 // Convenience routine to remove the given colormap
925 //
926 void
927 SoXtcxx . . $ SoXt#::removeColormapFromShellcxx . . $ SoXt#removeColormapFromShell(ac584ac68aa7390d).(Widgetcxx . . $ Widget# w, Widgetcxx . . $ Widget# shell)
928 //
929 ////////////////////////////////////////////////////////////////////////
930 {
931 if (! w || ! shell || ! XtIsShellcxx . . $ `<external>/3673480128541058774/Intrinsic.h:1078:9`!(shell))
932 return;
933
934 // check to see if there is a property
935 Windowcxx . . $ Window# *windowsReturn;
936 int countReturn;
937 Statuscxx . . $ `<external>/4815335266304551920/ICElib.h:36:9`! status = XGetWMColormapWindows(XtDisplay(shell),
938 XtWindow(shell), &windowsReturn, &countReturn);
939
940 // if no property, just return. If there was a property, continue
941 if (status)
942 {
943 // search for a match
944 for (int i=0; i<countReturn; i++)
945 {
946 if (windowsReturn[i] == XtWindow(w))
947 {
948 // we found a match, now copu the rest down
949 for (i++; i<countReturn; i++)
950 windowsReturn[i-1] = windowsReturn[i];
951
952 XSetWMColormapWindows(XtDisplay(w), XtWindow(shell),
953 windowsReturn, countReturn-1);
954 break; // from outer for
955 }
956 }
957 XFree((char *)windowsReturn);
958 }
959 }
960