changed: gcc8 base update
[opensg.git] / Source / WindowSystem / X / OSGXWindowBase.cpp
blob0cd93cd861d72a49d3974e2224f91584bbf8e023
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
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 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
66 #include "OSGXWindowBase.h"
67 #include "OSGXWindow.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::XWindow
78 The class for X-based windows. See \ref PageWindowX for a description.
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var DisplayP XWindowBase::_sfDisplay
89 /*! \var X11Window XWindowBase::_sfWindow
93 /*! \var GLXContext XWindowBase::_sfContext
97 /*! \var Int32 XWindowBase::_sfFbConfigId
102 /***************************************************************************\
103 * FieldType/FieldTrait Instantiation *
104 \***************************************************************************/
106 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
107 PointerType FieldTraits<XWindow *, nsOSG>::_type(
108 "XWindowPtr",
109 "WindowPtr",
110 XWindow::getClassType(),
111 nsOSG);
112 #endif
114 OSG_FIELDTRAITS_GETTYPE_NS(XWindow *, nsOSG)
116 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
117 XWindow *,
118 nsOSG)
120 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
121 XWindow *,
122 nsOSG)
124 /***************************************************************************\
125 * Field Description *
126 \***************************************************************************/
128 void XWindowBase::classDescInserter(TypeObject &oType)
130 FieldDescriptionBase *pDesc = NULL;
133 pDesc = new SFDisplayP::Description(
134 SFDisplayP::getClassType(),
135 "display",
137 DisplayFieldId, DisplayFieldMask,
138 true,
139 (Field::FClusterLocal),
140 static_cast<FieldEditMethodSig>(&XWindow::editHandleDisplay),
141 static_cast<FieldGetMethodSig >(&XWindow::getHandleDisplay));
143 oType.addInitialDesc(pDesc);
145 pDesc = new SFX11Window::Description(
146 SFX11Window::getClassType(),
147 "window",
149 WindowFieldId, WindowFieldMask,
150 true,
151 (Field::FClusterLocal),
152 static_cast<FieldEditMethodSig>(&XWindow::editHandleWindow),
153 static_cast<FieldGetMethodSig >(&XWindow::getHandleWindow));
155 oType.addInitialDesc(pDesc);
157 pDesc = new SFGLXContext::Description(
158 SFGLXContext::getClassType(),
159 "context",
161 ContextFieldId, ContextFieldMask,
162 true,
163 (Field::FClusterLocal),
164 static_cast<FieldEditMethodSig>(&XWindow::editHandleContext),
165 static_cast<FieldGetMethodSig >(&XWindow::getHandleContext));
167 oType.addInitialDesc(pDesc);
169 pDesc = new SFInt32::Description(
170 SFInt32::getClassType(),
171 "fbConfigId",
173 FbConfigIdFieldId, FbConfigIdFieldMask,
174 true,
175 (Field::FClusterLocal),
176 static_cast<FieldEditMethodSig>(&XWindow::editHandleFbConfigId),
177 static_cast<FieldGetMethodSig >(&XWindow::getHandleFbConfigId));
179 oType.addInitialDesc(pDesc);
183 XWindowBase::TypeObject XWindowBase::_type(
184 XWindowBase::getClassname(),
185 Inherited::getClassname(),
186 "NULL",
187 nsOSG, //Namespace
188 reinterpret_cast<PrototypeCreateF>(&XWindowBase::createEmptyLocal),
189 reinterpret_cast<InitContainerF>(&XWindow::initMethod),
190 reinterpret_cast<ExitContainerF>(&XWindow::exitMethod),
191 reinterpret_cast<InitalInsertDescFunc>(
192 reinterpret_cast<void *>(&XWindow::classDescInserter)),
193 false,
195 "<?xml version=\"1.0\"?>\n"
196 "\n"
197 "<FieldContainer\n"
198 " name=\"XWindow\"\n"
199 " parent=\"Window\"\n"
200 " library=\"WindowX\"\n"
201 " pointerfieldtypes=\"both\"\n"
202 " structure=\"concrete\"\n"
203 " systemcomponent=\"true\"\n"
204 " parentsystemcomponent=\"true\"\n"
205 " docGroupBase=\"GrpWindowX\"\n"
206 " >\n"
207 " The class for X-based windows. See \\ref PageWindowX for a description.\n"
208 " <Field\n"
209 " name=\"display\"\n"
210 " type=\"DisplayP\"\n"
211 " cardinality=\"single\"\n"
212 " visibility=\"internal\"\n"
213 " defaultValue=\"NULL\"\n"
214 " fieldHeader=\"OSGXWindowDataFields.h\"\n"
215 " access=\"public\"\n"
216 " fieldFlags=\"FClusterLocal\"\n"
217 " >\n"
218 " </Field>\n"
219 " <Field\n"
220 " name=\"window\"\n"
221 " type=\"X11Window\"\n"
222 " cardinality=\"single\"\n"
223 " visibility=\"internal\"\n"
224 " defaultValue=\"NULL\"\n"
225 " fieldHeader=\"OSGXWindowDataFields.h\"\n"
226 " access=\"public\"\n"
227 " fieldFlags=\"FClusterLocal\"\n"
228 " >\n"
229 " </Field>\n"
230 " <Field\n"
231 " name=\"context\"\n"
232 " type=\"GLXContext\"\n"
233 " cardinality=\"single\"\n"
234 " visibility=\"internal\"\n"
235 " defaultValue=\"NULL\"\n"
236 " fieldHeader=\"OSGXWindowDataFields.h\"\n"
237 " access=\"public\"\n"
238 " fieldFlags=\"FClusterLocal\"\n"
239 " >\n"
240 " </Field>\n"
241 " <Field\n"
242 " name=\"fbConfigId\"\n"
243 " type=\"Int32\"\n"
244 " cardinality=\"single\"\n"
245 " visibility=\"internal\"\n"
246 " defaultValue=\"-1\"\n"
247 " access=\"public\"\n"
248 " fieldFlags=\"FClusterLocal\"\n"
249 " >\n"
250 " </Field>\n"
251 "</FieldContainer>\n",
252 "The class for X-based windows. See \\ref PageWindowX for a description.\n"
255 /*------------------------------ get -----------------------------------*/
257 FieldContainerType &XWindowBase::getType(void)
259 return _type;
262 const FieldContainerType &XWindowBase::getType(void) const
264 return _type;
267 UInt32 XWindowBase::getContainerSize(void) const
269 return sizeof(XWindow);
272 /*------------------------- decorator get ------------------------------*/
275 SFDisplayP *XWindowBase::editSFDisplay(void)
277 editSField(DisplayFieldMask);
279 return &_sfDisplay;
282 const SFDisplayP *XWindowBase::getSFDisplay(void) const
284 return &_sfDisplay;
288 SFX11Window *XWindowBase::editSFWindow(void)
290 editSField(WindowFieldMask);
292 return &_sfWindow;
295 const SFX11Window *XWindowBase::getSFWindow(void) const
297 return &_sfWindow;
301 SFGLXContext *XWindowBase::editSFContext(void)
303 editSField(ContextFieldMask);
305 return &_sfContext;
308 const SFGLXContext *XWindowBase::getSFContext(void) const
310 return &_sfContext;
314 SFInt32 *XWindowBase::editSFFbConfigId(void)
316 editSField(FbConfigIdFieldMask);
318 return &_sfFbConfigId;
321 const SFInt32 *XWindowBase::getSFFbConfigId(void) const
323 return &_sfFbConfigId;
331 /*------------------------------ access -----------------------------------*/
333 SizeT XWindowBase::getBinSize(ConstFieldMaskArg whichField)
335 SizeT returnValue = Inherited::getBinSize(whichField);
337 if(FieldBits::NoField != (DisplayFieldMask & whichField))
339 returnValue += _sfDisplay.getBinSize();
341 if(FieldBits::NoField != (WindowFieldMask & whichField))
343 returnValue += _sfWindow.getBinSize();
345 if(FieldBits::NoField != (ContextFieldMask & whichField))
347 returnValue += _sfContext.getBinSize();
349 if(FieldBits::NoField != (FbConfigIdFieldMask & whichField))
351 returnValue += _sfFbConfigId.getBinSize();
354 return returnValue;
357 void XWindowBase::copyToBin(BinaryDataHandler &pMem,
358 ConstFieldMaskArg whichField)
360 Inherited::copyToBin(pMem, whichField);
362 if(FieldBits::NoField != (DisplayFieldMask & whichField))
364 _sfDisplay.copyToBin(pMem);
366 if(FieldBits::NoField != (WindowFieldMask & whichField))
368 _sfWindow.copyToBin(pMem);
370 if(FieldBits::NoField != (ContextFieldMask & whichField))
372 _sfContext.copyToBin(pMem);
374 if(FieldBits::NoField != (FbConfigIdFieldMask & whichField))
376 _sfFbConfigId.copyToBin(pMem);
380 void XWindowBase::copyFromBin(BinaryDataHandler &pMem,
381 ConstFieldMaskArg whichField)
383 Inherited::copyFromBin(pMem, whichField);
385 if(FieldBits::NoField != (DisplayFieldMask & whichField))
387 editSField(DisplayFieldMask);
388 _sfDisplay.copyFromBin(pMem);
390 if(FieldBits::NoField != (WindowFieldMask & whichField))
392 editSField(WindowFieldMask);
393 _sfWindow.copyFromBin(pMem);
395 if(FieldBits::NoField != (ContextFieldMask & whichField))
397 editSField(ContextFieldMask);
398 _sfContext.copyFromBin(pMem);
400 if(FieldBits::NoField != (FbConfigIdFieldMask & whichField))
402 editSField(FbConfigIdFieldMask);
403 _sfFbConfigId.copyFromBin(pMem);
407 //! create a new instance of the class
408 XWindowTransitPtr XWindowBase::createLocal(BitVector bFlags)
410 XWindowTransitPtr fc;
412 if(getClassType().getPrototype() != NULL)
414 FieldContainerTransitPtr tmpPtr =
415 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
417 fc = dynamic_pointer_cast<XWindow>(tmpPtr);
420 return fc;
423 //! create a new instance of the class, copy the container flags
424 XWindowTransitPtr XWindowBase::createDependent(BitVector bFlags)
426 XWindowTransitPtr fc;
428 if(getClassType().getPrototype() != NULL)
430 FieldContainerTransitPtr tmpPtr =
431 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
433 fc = dynamic_pointer_cast<XWindow>(tmpPtr);
436 return fc;
439 //! create a new instance of the class
440 XWindowTransitPtr XWindowBase::create(void)
442 XWindowTransitPtr fc;
444 if(getClassType().getPrototype() != NULL)
446 FieldContainerTransitPtr tmpPtr =
447 getClassType().getPrototype()-> shallowCopy();
449 fc = dynamic_pointer_cast<XWindow>(tmpPtr);
452 return fc;
455 XWindow *XWindowBase::createEmptyLocal(BitVector bFlags)
457 XWindow *returnValue;
459 newPtr<XWindow>(returnValue, bFlags);
461 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
463 return returnValue;
466 //! create an empty new instance of the class, do not copy the prototype
467 XWindow *XWindowBase::createEmpty(void)
469 XWindow *returnValue;
471 newPtr<XWindow>(returnValue, Thread::getCurrentLocalFlags());
473 returnValue->_pFieldFlags->_bNamespaceMask &=
474 ~Thread::getCurrentLocalFlags();
476 return returnValue;
480 FieldContainerTransitPtr XWindowBase::shallowCopyLocal(
481 BitVector bFlags) const
483 XWindow *tmpPtr;
485 newPtr(tmpPtr, dynamic_cast<const XWindow *>(this), bFlags);
487 FieldContainerTransitPtr returnValue(tmpPtr);
489 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
491 return returnValue;
494 FieldContainerTransitPtr XWindowBase::shallowCopyDependent(
495 BitVector bFlags) const
497 XWindow *tmpPtr;
499 newPtr(tmpPtr, dynamic_cast<const XWindow *>(this), ~bFlags);
501 FieldContainerTransitPtr returnValue(tmpPtr);
503 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
505 return returnValue;
508 FieldContainerTransitPtr XWindowBase::shallowCopy(void) const
510 XWindow *tmpPtr;
512 newPtr(tmpPtr,
513 dynamic_cast<const XWindow *>(this),
514 Thread::getCurrentLocalFlags());
516 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
518 FieldContainerTransitPtr returnValue(tmpPtr);
520 return returnValue;
526 /*------------------------- constructors ----------------------------------*/
528 XWindowBase::XWindowBase(void) :
529 Inherited(),
530 _sfDisplay (DisplayP(NULL)),
531 _sfWindow (X11Window(NULL)),
532 _sfContext (GLXContext(NULL)),
533 _sfFbConfigId (Int32(-1))
537 XWindowBase::XWindowBase(const XWindowBase &source) :
538 Inherited(source),
539 _sfDisplay (source._sfDisplay ),
540 _sfWindow (source._sfWindow ),
541 _sfContext (source._sfContext ),
542 _sfFbConfigId (source._sfFbConfigId )
547 /*-------------------------- destructors ----------------------------------*/
549 XWindowBase::~XWindowBase(void)
554 GetFieldHandlePtr XWindowBase::getHandleDisplay (void) const
556 SFDisplayP::GetHandlePtr returnValue(
557 new SFDisplayP::GetHandle(
558 &_sfDisplay,
559 this->getType().getFieldDesc(DisplayFieldId),
560 const_cast<XWindowBase *>(this)));
562 return returnValue;
565 EditFieldHandlePtr XWindowBase::editHandleDisplay (void)
567 SFDisplayP::EditHandlePtr returnValue(
568 new SFDisplayP::EditHandle(
569 &_sfDisplay,
570 this->getType().getFieldDesc(DisplayFieldId),
571 this));
574 editSField(DisplayFieldMask);
576 return returnValue;
579 GetFieldHandlePtr XWindowBase::getHandleWindow (void) const
581 SFX11Window::GetHandlePtr returnValue(
582 new SFX11Window::GetHandle(
583 &_sfWindow,
584 this->getType().getFieldDesc(WindowFieldId),
585 const_cast<XWindowBase *>(this)));
587 return returnValue;
590 EditFieldHandlePtr XWindowBase::editHandleWindow (void)
592 SFX11Window::EditHandlePtr returnValue(
593 new SFX11Window::EditHandle(
594 &_sfWindow,
595 this->getType().getFieldDesc(WindowFieldId),
596 this));
599 editSField(WindowFieldMask);
601 return returnValue;
604 GetFieldHandlePtr XWindowBase::getHandleContext (void) const
606 SFGLXContext::GetHandlePtr returnValue(
607 new SFGLXContext::GetHandle(
608 &_sfContext,
609 this->getType().getFieldDesc(ContextFieldId),
610 const_cast<XWindowBase *>(this)));
612 return returnValue;
615 EditFieldHandlePtr XWindowBase::editHandleContext (void)
617 SFGLXContext::EditHandlePtr returnValue(
618 new SFGLXContext::EditHandle(
619 &_sfContext,
620 this->getType().getFieldDesc(ContextFieldId),
621 this));
624 editSField(ContextFieldMask);
626 return returnValue;
629 GetFieldHandlePtr XWindowBase::getHandleFbConfigId (void) const
631 SFInt32::GetHandlePtr returnValue(
632 new SFInt32::GetHandle(
633 &_sfFbConfigId,
634 this->getType().getFieldDesc(FbConfigIdFieldId),
635 const_cast<XWindowBase *>(this)));
637 return returnValue;
640 EditFieldHandlePtr XWindowBase::editHandleFbConfigId (void)
642 SFInt32::EditHandlePtr returnValue(
643 new SFInt32::EditHandle(
644 &_sfFbConfigId,
645 this->getType().getFieldDesc(FbConfigIdFieldId),
646 this));
649 editSField(FbConfigIdFieldMask);
651 return returnValue;
655 #ifdef OSG_MT_CPTR_ASPECT
656 void XWindowBase::execSyncV( FieldContainer &oFrom,
657 ConstFieldMaskArg whichField,
658 AspectOffsetStore &oOffsets,
659 ConstFieldMaskArg syncMode,
660 const UInt32 uiSyncInfo)
662 XWindow *pThis = static_cast<XWindow *>(this);
664 pThis->execSync(static_cast<XWindow *>(&oFrom),
665 whichField,
666 oOffsets,
667 syncMode,
668 uiSyncInfo);
670 #endif
673 #ifdef OSG_MT_CPTR_ASPECT
674 FieldContainer *XWindowBase::createAspectCopy(
675 const FieldContainer *pRefAspect) const
677 XWindow *returnValue;
679 newAspectCopy(returnValue,
680 dynamic_cast<const XWindow *>(pRefAspect),
681 dynamic_cast<const XWindow *>(this));
683 return returnValue;
685 #endif
687 void XWindowBase::resolveLinks(void)
689 Inherited::resolveLinks();
695 OSG_END_NAMESPACE