changed: auto add updateData callback to stages so that stagedata can be updated...
[opensg.git] / Source / WindowSystem / X / OSGXWindowBase.cpp
blob394762cad8f02286d3bf7154eb4a0cefbc043e04
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class XWindow!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #include "OSGConfig.h"
61 #include "OSGXWindowBase.h"
62 #include "OSGXWindow.h"
64 #include <boost/bind.hpp>
66 #ifdef WIN32 // turn off 'this' : used in base member initializer list warning
67 #pragma warning(disable:4355)
68 #endif
70 OSG_BEGIN_NAMESPACE
72 /***************************************************************************\
73 * Description *
74 \***************************************************************************/
76 /*! \class OSG::XWindow
77 The class for X-based windows. See \ref PageWindowX for a description.
80 /***************************************************************************\
81 * Field Documentation *
82 \***************************************************************************/
84 /*! \var DisplayP XWindowBase::_sfDisplay
88 /*! \var X11Window XWindowBase::_sfWindow
92 /*! \var GLXContext XWindowBase::_sfContext
96 /*! \var Int32 XWindowBase::_sfFbConfigId
101 /***************************************************************************\
102 * FieldType/FieldTrait Instantiation *
103 \***************************************************************************/
105 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
106 PointerType FieldTraits<XWindow *, nsOSG>::_type(
107 "XWindowPtr",
108 "WindowPtr",
109 XWindow::getClassType(),
110 nsOSG);
111 #endif
113 OSG_FIELDTRAITS_GETTYPE_NS(XWindow *, nsOSG)
115 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
116 XWindow *,
117 nsOSG);
119 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
120 XWindow *,
121 nsOSG);
123 /***************************************************************************\
124 * Field Description *
125 \***************************************************************************/
127 void XWindowBase::classDescInserter(TypeObject &oType)
129 FieldDescriptionBase *pDesc = NULL;
132 pDesc = new SFDisplayP::Description(
133 SFDisplayP::getClassType(),
134 "display",
136 DisplayFieldId, DisplayFieldMask,
137 true,
138 (Field::FClusterLocal),
139 static_cast<FieldEditMethodSig>(&XWindow::editHandleDisplay),
140 static_cast<FieldGetMethodSig >(&XWindow::getHandleDisplay));
142 oType.addInitialDesc(pDesc);
144 pDesc = new SFX11Window::Description(
145 SFX11Window::getClassType(),
146 "window",
148 WindowFieldId, WindowFieldMask,
149 true,
150 (Field::FClusterLocal),
151 static_cast<FieldEditMethodSig>(&XWindow::editHandleWindow),
152 static_cast<FieldGetMethodSig >(&XWindow::getHandleWindow));
154 oType.addInitialDesc(pDesc);
156 pDesc = new SFGLXContext::Description(
157 SFGLXContext::getClassType(),
158 "context",
160 ContextFieldId, ContextFieldMask,
161 true,
162 (Field::FClusterLocal),
163 static_cast<FieldEditMethodSig>(&XWindow::editHandleContext),
164 static_cast<FieldGetMethodSig >(&XWindow::getHandleContext));
166 oType.addInitialDesc(pDesc);
168 pDesc = new SFInt32::Description(
169 SFInt32::getClassType(),
170 "fbConfigId",
172 FbConfigIdFieldId, FbConfigIdFieldMask,
173 true,
174 (Field::FClusterLocal),
175 static_cast<FieldEditMethodSig>(&XWindow::editHandleFbConfigId),
176 static_cast<FieldGetMethodSig >(&XWindow::getHandleFbConfigId));
178 oType.addInitialDesc(pDesc);
182 XWindowBase::TypeObject XWindowBase::_type(
183 XWindowBase::getClassname(),
184 Inherited::getClassname(),
185 "NULL",
186 nsOSG, //Namespace
187 reinterpret_cast<PrototypeCreateF>(&XWindowBase::createEmptyLocal),
188 XWindow::initMethod,
189 XWindow::exitMethod,
190 reinterpret_cast<InitalInsertDescFunc>(&XWindow::classDescInserter),
191 false,
193 "<?xml version=\"1.0\"?>\n"
194 "\n"
195 "<FieldContainer\n"
196 " name=\"XWindow\"\n"
197 " parent=\"Window\"\n"
198 " library=\"WindowX\"\n"
199 " pointerfieldtypes=\"both\"\n"
200 " structure=\"concrete\"\n"
201 " systemcomponent=\"true\"\n"
202 " parentsystemcomponent=\"true\"\n"
203 " docGroupBase=\"GrpWindowX\"\n"
204 " >\n"
205 " The class for X-based windows. See \\ref PageWindowX for a description.\n"
206 " <Field\n"
207 " name=\"display\"\n"
208 " type=\"DisplayP\"\n"
209 " cardinality=\"single\"\n"
210 " visibility=\"internal\"\n"
211 " defaultValue=\"NULL\"\n"
212 " fieldHeader=\"OSGXWindowDataFields.h\"\n"
213 " access=\"public\"\n"
214 " fieldFlags=\"FClusterLocal\"\n"
215 " >\n"
216 " </Field>\n"
217 " <Field\n"
218 " name=\"window\"\n"
219 " type=\"X11Window\"\n"
220 " cardinality=\"single\"\n"
221 " visibility=\"internal\"\n"
222 " defaultValue=\"NULL\"\n"
223 " fieldHeader=\"OSGXWindowDataFields.h\"\n"
224 " access=\"public\"\n"
225 " fieldFlags=\"FClusterLocal\"\n"
226 " >\n"
227 " </Field>\n"
228 " <Field\n"
229 " name=\"context\"\n"
230 " type=\"GLXContext\"\n"
231 " cardinality=\"single\"\n"
232 " visibility=\"internal\"\n"
233 " defaultValue=\"NULL\"\n"
234 " fieldHeader=\"OSGXWindowDataFields.h\"\n"
235 " access=\"public\"\n"
236 " fieldFlags=\"FClusterLocal\"\n"
237 " >\n"
238 " </Field>\n"
239 " <Field\n"
240 " name=\"fbConfigId\"\n"
241 " type=\"Int32\"\n"
242 " cardinality=\"single\"\n"
243 " visibility=\"internal\"\n"
244 " defaultValue=\"-1\"\n"
245 " access=\"public\"\n"
246 " fieldFlags=\"FClusterLocal\"\n"
247 " >\n"
248 " </Field>\n"
249 "</FieldContainer>\n",
250 "The class for X-based windows. See \\ref PageWindowX for a description.\n"
253 /*------------------------------ get -----------------------------------*/
255 FieldContainerType &XWindowBase::getType(void)
257 return _type;
260 const FieldContainerType &XWindowBase::getType(void) const
262 return _type;
265 UInt32 XWindowBase::getContainerSize(void) const
267 return sizeof(XWindow);
270 /*------------------------- decorator get ------------------------------*/
273 SFDisplayP *XWindowBase::editSFDisplay(void)
275 editSField(DisplayFieldMask);
277 return &_sfDisplay;
280 const SFDisplayP *XWindowBase::getSFDisplay(void) const
282 return &_sfDisplay;
286 SFX11Window *XWindowBase::editSFWindow(void)
288 editSField(WindowFieldMask);
290 return &_sfWindow;
293 const SFX11Window *XWindowBase::getSFWindow(void) const
295 return &_sfWindow;
299 SFGLXContext *XWindowBase::editSFContext(void)
301 editSField(ContextFieldMask);
303 return &_sfContext;
306 const SFGLXContext *XWindowBase::getSFContext(void) const
308 return &_sfContext;
312 SFInt32 *XWindowBase::editSFFbConfigId(void)
314 editSField(FbConfigIdFieldMask);
316 return &_sfFbConfigId;
319 const SFInt32 *XWindowBase::getSFFbConfigId(void) const
321 return &_sfFbConfigId;
329 /*------------------------------ access -----------------------------------*/
331 SizeT XWindowBase::getBinSize(ConstFieldMaskArg whichField)
333 SizeT returnValue = Inherited::getBinSize(whichField);
335 if(FieldBits::NoField != (DisplayFieldMask & whichField))
337 returnValue += _sfDisplay.getBinSize();
339 if(FieldBits::NoField != (WindowFieldMask & whichField))
341 returnValue += _sfWindow.getBinSize();
343 if(FieldBits::NoField != (ContextFieldMask & whichField))
345 returnValue += _sfContext.getBinSize();
347 if(FieldBits::NoField != (FbConfigIdFieldMask & whichField))
349 returnValue += _sfFbConfigId.getBinSize();
352 return returnValue;
355 void XWindowBase::copyToBin(BinaryDataHandler &pMem,
356 ConstFieldMaskArg whichField)
358 Inherited::copyToBin(pMem, whichField);
360 if(FieldBits::NoField != (DisplayFieldMask & whichField))
362 _sfDisplay.copyToBin(pMem);
364 if(FieldBits::NoField != (WindowFieldMask & whichField))
366 _sfWindow.copyToBin(pMem);
368 if(FieldBits::NoField != (ContextFieldMask & whichField))
370 _sfContext.copyToBin(pMem);
372 if(FieldBits::NoField != (FbConfigIdFieldMask & whichField))
374 _sfFbConfigId.copyToBin(pMem);
378 void XWindowBase::copyFromBin(BinaryDataHandler &pMem,
379 ConstFieldMaskArg whichField)
381 Inherited::copyFromBin(pMem, whichField);
383 if(FieldBits::NoField != (DisplayFieldMask & whichField))
385 editSField(DisplayFieldMask);
386 _sfDisplay.copyFromBin(pMem);
388 if(FieldBits::NoField != (WindowFieldMask & whichField))
390 editSField(WindowFieldMask);
391 _sfWindow.copyFromBin(pMem);
393 if(FieldBits::NoField != (ContextFieldMask & whichField))
395 editSField(ContextFieldMask);
396 _sfContext.copyFromBin(pMem);
398 if(FieldBits::NoField != (FbConfigIdFieldMask & whichField))
400 editSField(FbConfigIdFieldMask);
401 _sfFbConfigId.copyFromBin(pMem);
405 //! create a new instance of the class
406 XWindowTransitPtr XWindowBase::createLocal(BitVector bFlags)
408 XWindowTransitPtr fc;
410 if(getClassType().getPrototype() != NULL)
412 FieldContainerTransitPtr tmpPtr =
413 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
415 fc = dynamic_pointer_cast<XWindow>(tmpPtr);
418 return fc;
421 //! create a new instance of the class, copy the container flags
422 XWindowTransitPtr XWindowBase::createDependent(BitVector bFlags)
424 XWindowTransitPtr fc;
426 if(getClassType().getPrototype() != NULL)
428 FieldContainerTransitPtr tmpPtr =
429 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
431 fc = dynamic_pointer_cast<XWindow>(tmpPtr);
434 return fc;
437 //! create a new instance of the class
438 XWindowTransitPtr XWindowBase::create(void)
440 XWindowTransitPtr fc;
442 if(getClassType().getPrototype() != NULL)
444 FieldContainerTransitPtr tmpPtr =
445 getClassType().getPrototype()-> shallowCopy();
447 fc = dynamic_pointer_cast<XWindow>(tmpPtr);
450 return fc;
453 XWindow *XWindowBase::createEmptyLocal(BitVector bFlags)
455 XWindow *returnValue;
457 newPtr<XWindow>(returnValue, bFlags);
459 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
461 return returnValue;
464 //! create an empty new instance of the class, do not copy the prototype
465 XWindow *XWindowBase::createEmpty(void)
467 XWindow *returnValue;
469 newPtr<XWindow>(returnValue, Thread::getCurrentLocalFlags());
471 returnValue->_pFieldFlags->_bNamespaceMask &=
472 ~Thread::getCurrentLocalFlags();
474 return returnValue;
478 FieldContainerTransitPtr XWindowBase::shallowCopyLocal(
479 BitVector bFlags) const
481 XWindow *tmpPtr;
483 newPtr(tmpPtr, dynamic_cast<const XWindow *>(this), bFlags);
485 FieldContainerTransitPtr returnValue(tmpPtr);
487 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
489 return returnValue;
492 FieldContainerTransitPtr XWindowBase::shallowCopyDependent(
493 BitVector bFlags) const
495 XWindow *tmpPtr;
497 newPtr(tmpPtr, dynamic_cast<const XWindow *>(this), ~bFlags);
499 FieldContainerTransitPtr returnValue(tmpPtr);
501 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
503 return returnValue;
506 FieldContainerTransitPtr XWindowBase::shallowCopy(void) const
508 XWindow *tmpPtr;
510 newPtr(tmpPtr,
511 dynamic_cast<const XWindow *>(this),
512 Thread::getCurrentLocalFlags());
514 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
516 FieldContainerTransitPtr returnValue(tmpPtr);
518 return returnValue;
524 /*------------------------- constructors ----------------------------------*/
526 XWindowBase::XWindowBase(void) :
527 Inherited(),
528 _sfDisplay (DisplayP(NULL)),
529 _sfWindow (X11Window(NULL)),
530 _sfContext (GLXContext(NULL)),
531 _sfFbConfigId (Int32(-1))
535 XWindowBase::XWindowBase(const XWindowBase &source) :
536 Inherited(source),
537 _sfDisplay (source._sfDisplay ),
538 _sfWindow (source._sfWindow ),
539 _sfContext (source._sfContext ),
540 _sfFbConfigId (source._sfFbConfigId )
545 /*-------------------------- destructors ----------------------------------*/
547 XWindowBase::~XWindowBase(void)
552 GetFieldHandlePtr XWindowBase::getHandleDisplay (void) const
554 SFDisplayP::GetHandlePtr returnValue(
555 new SFDisplayP::GetHandle(
556 &_sfDisplay,
557 this->getType().getFieldDesc(DisplayFieldId),
558 const_cast<XWindowBase *>(this)));
560 return returnValue;
563 EditFieldHandlePtr XWindowBase::editHandleDisplay (void)
565 SFDisplayP::EditHandlePtr returnValue(
566 new SFDisplayP::EditHandle(
567 &_sfDisplay,
568 this->getType().getFieldDesc(DisplayFieldId),
569 this));
572 editSField(DisplayFieldMask);
574 return returnValue;
577 GetFieldHandlePtr XWindowBase::getHandleWindow (void) const
579 SFX11Window::GetHandlePtr returnValue(
580 new SFX11Window::GetHandle(
581 &_sfWindow,
582 this->getType().getFieldDesc(WindowFieldId),
583 const_cast<XWindowBase *>(this)));
585 return returnValue;
588 EditFieldHandlePtr XWindowBase::editHandleWindow (void)
590 SFX11Window::EditHandlePtr returnValue(
591 new SFX11Window::EditHandle(
592 &_sfWindow,
593 this->getType().getFieldDesc(WindowFieldId),
594 this));
597 editSField(WindowFieldMask);
599 return returnValue;
602 GetFieldHandlePtr XWindowBase::getHandleContext (void) const
604 SFGLXContext::GetHandlePtr returnValue(
605 new SFGLXContext::GetHandle(
606 &_sfContext,
607 this->getType().getFieldDesc(ContextFieldId),
608 const_cast<XWindowBase *>(this)));
610 return returnValue;
613 EditFieldHandlePtr XWindowBase::editHandleContext (void)
615 SFGLXContext::EditHandlePtr returnValue(
616 new SFGLXContext::EditHandle(
617 &_sfContext,
618 this->getType().getFieldDesc(ContextFieldId),
619 this));
622 editSField(ContextFieldMask);
624 return returnValue;
627 GetFieldHandlePtr XWindowBase::getHandleFbConfigId (void) const
629 SFInt32::GetHandlePtr returnValue(
630 new SFInt32::GetHandle(
631 &_sfFbConfigId,
632 this->getType().getFieldDesc(FbConfigIdFieldId),
633 const_cast<XWindowBase *>(this)));
635 return returnValue;
638 EditFieldHandlePtr XWindowBase::editHandleFbConfigId (void)
640 SFInt32::EditHandlePtr returnValue(
641 new SFInt32::EditHandle(
642 &_sfFbConfigId,
643 this->getType().getFieldDesc(FbConfigIdFieldId),
644 this));
647 editSField(FbConfigIdFieldMask);
649 return returnValue;
653 #ifdef OSG_MT_CPTR_ASPECT
654 void XWindowBase::execSyncV( FieldContainer &oFrom,
655 ConstFieldMaskArg whichField,
656 AspectOffsetStore &oOffsets,
657 ConstFieldMaskArg syncMode,
658 const UInt32 uiSyncInfo)
660 XWindow *pThis = static_cast<XWindow *>(this);
662 pThis->execSync(static_cast<XWindow *>(&oFrom),
663 whichField,
664 oOffsets,
665 syncMode,
666 uiSyncInfo);
668 #endif
671 #ifdef OSG_MT_CPTR_ASPECT
672 FieldContainer *XWindowBase::createAspectCopy(
673 const FieldContainer *pRefAspect) const
675 XWindow *returnValue;
677 newAspectCopy(returnValue,
678 dynamic_cast<const XWindow *>(pRefAspect),
679 dynamic_cast<const XWindow *>(this));
681 return returnValue;
683 #endif
685 void XWindowBase::resolveLinks(void)
687 Inherited::resolveLinks();
693 OSG_END_NAMESPACE