changed: auto add updateData callback to stages so that stagedata can be updated...
[opensg.git] / Source / WindowSystem / WIN32 / OSGWIN32WindowBase.cpp
blob45b31a97d8f48cbec410d0773223ec5ecde5a4c0
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 WIN32Window!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #include "OSGConfig.h"
61 #include "OSGWIN32WindowBase.h"
62 #include "OSGWIN32Window.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::WIN32Window
77 The class for WIN32 windows.
80 /***************************************************************************\
81 * Field Documentation *
82 \***************************************************************************/
84 /*! \var HWND WIN32WindowBase::_sfHwnd
88 /*! \var HDC WIN32WindowBase::_sfHdc
92 /*! \var HGLRC WIN32WindowBase::_sfHglrc
96 /*! \var Int32 WIN32WindowBase::_sfDummy0
97 This field only exists so that all platform window types have the same
98 number of fields.
99 Otherwise transmitting field masks across a cluster is not possible.
103 /***************************************************************************\
104 * FieldType/FieldTrait Instantiation *
105 \***************************************************************************/
107 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
108 PointerType FieldTraits<WIN32Window *, nsOSG>::_type(
109 "WIN32WindowPtr",
110 "WindowPtr",
111 WIN32Window::getClassType(),
112 nsOSG);
113 #endif
115 OSG_FIELDTRAITS_GETTYPE_NS(WIN32Window *, nsOSG)
117 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
118 WIN32Window *,
119 nsOSG);
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
122 WIN32Window *,
123 nsOSG);
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void WIN32WindowBase::classDescInserter(TypeObject &oType)
131 FieldDescriptionBase *pDesc = NULL;
134 pDesc = new SFHWND::Description(
135 SFHWND::getClassType(),
136 "hwnd",
138 HwndFieldId, HwndFieldMask,
139 true,
140 (Field::FClusterLocal),
141 static_cast<FieldEditMethodSig>(&WIN32Window::editHandleHwnd),
142 static_cast<FieldGetMethodSig >(&WIN32Window::getHandleHwnd));
144 oType.addInitialDesc(pDesc);
146 pDesc = new SFHDC::Description(
147 SFHDC::getClassType(),
148 "hdc",
150 HdcFieldId, HdcFieldMask,
151 true,
152 (Field::FClusterLocal),
153 static_cast<FieldEditMethodSig>(&WIN32Window::editHandleHdc),
154 static_cast<FieldGetMethodSig >(&WIN32Window::getHandleHdc));
156 oType.addInitialDesc(pDesc);
158 pDesc = new SFHGLRC::Description(
159 SFHGLRC::getClassType(),
160 "hglrc",
162 HglrcFieldId, HglrcFieldMask,
163 true,
164 (Field::FClusterLocal),
165 static_cast<FieldEditMethodSig>(&WIN32Window::editHandleHglrc),
166 static_cast<FieldGetMethodSig >(&WIN32Window::getHandleHglrc));
168 oType.addInitialDesc(pDesc);
170 pDesc = new SFInt32::Description(
171 SFInt32::getClassType(),
172 "dummy0",
173 "This field only exists so that all platform window types have the same\n"
174 "number of fields.\n"
175 "Otherwise transmitting field masks across a cluster is not possible.\n",
176 Dummy0FieldId, Dummy0FieldMask,
177 true,
178 (Field::FClusterLocal),
179 static_cast<FieldEditMethodSig>(&WIN32Window::editHandleDummy0),
180 static_cast<FieldGetMethodSig >(&WIN32Window::getHandleDummy0));
182 oType.addInitialDesc(pDesc);
186 WIN32WindowBase::TypeObject WIN32WindowBase::_type(
187 WIN32WindowBase::getClassname(),
188 Inherited::getClassname(),
189 "NULL",
190 nsOSG, //Namespace
191 reinterpret_cast<PrototypeCreateF>(&WIN32WindowBase::createEmptyLocal),
192 WIN32Window::initMethod,
193 WIN32Window::exitMethod,
194 reinterpret_cast<InitalInsertDescFunc>(&WIN32Window::classDescInserter),
195 false,
197 "<?xml version=\"1.0\"?>\n"
198 "\n"
199 "<FieldContainer\n"
200 " name=\"WIN32Window\"\n"
201 " parent=\"Window\"\n"
202 " library=\"WindowWIN32\"\n"
203 " pointerfieldtypes=\"both\"\n"
204 " structure=\"concrete\"\n"
205 " systemcomponent=\"true\"\n"
206 " parentsystemcomponent=\"true\"\n"
207 " docGroupBase=\"GrpWindowWIN32\"\n"
208 " >\n"
209 " The class for WIN32 windows.\n"
210 " <Field\n"
211 " name=\"hwnd\"\n"
212 " type=\"HWND\"\n"
213 " cardinality=\"single\"\n"
214 " visibility=\"internal\"\n"
215 " defaultValue=\"0\"\n"
216 " fieldHeader=\"OSGWIN32WindowDataFields.h\"\n"
217 " access=\"public\"\n"
218 " fieldFlags=\"FClusterLocal\"\n"
219 " >\n"
220 " </Field>\n"
221 " <Field\n"
222 " name=\"hdc\"\n"
223 " type=\"HDC\"\n"
224 " cardinality=\"single\"\n"
225 " visibility=\"internal\"\n"
226 " defaultValue=\"0\"\n"
227 " fieldHeader=\"OSGWIN32WindowDataFields.h\"\n"
228 " access=\"public\"\n"
229 " fieldFlags=\"FClusterLocal\"\n"
230 " >\n"
231 " </Field>\n"
232 " <Field\n"
233 " name=\"hglrc\"\n"
234 " type=\"HGLRC\"\n"
235 " cardinality=\"single\"\n"
236 " visibility=\"internal\"\n"
237 " defaultValue=\"0\"\n"
238 " fieldHeader=\"OSGWIN32WindowDataFields.h\"\n"
239 " access=\"public\"\n"
240 " fieldFlags=\"FClusterLocal\"\n"
241 " >\n"
242 " </Field>\n"
243 " <Field\n"
244 " name=\"dummy0\"\n"
245 " type=\"Int32\"\n"
246 " category=\"data\"\n"
247 " cardinality=\"single\"\n"
248 " visibility=\"internal\"\n"
249 " defaultValue=\"0\"\n"
250 " access=\"public\"\n"
251 " fieldFlags=\"FClusterLocal\"\n"
252 " >\n"
253 " This field only exists so that all platform window types have the same\n"
254 " number of fields.\n"
255 " Otherwise transmitting field masks across a cluster is not possible.\n"
256 " </Field>\n"
257 "</FieldContainer>\n",
258 "The class for WIN32 windows.\n"
261 /*------------------------------ get -----------------------------------*/
263 FieldContainerType &WIN32WindowBase::getType(void)
265 return _type;
268 const FieldContainerType &WIN32WindowBase::getType(void) const
270 return _type;
273 UInt32 WIN32WindowBase::getContainerSize(void) const
275 return sizeof(WIN32Window);
278 /*------------------------- decorator get ------------------------------*/
281 SFHWND *WIN32WindowBase::editSFHwnd(void)
283 editSField(HwndFieldMask);
285 return &_sfHwnd;
288 const SFHWND *WIN32WindowBase::getSFHwnd(void) const
290 return &_sfHwnd;
294 SFHDC *WIN32WindowBase::editSFHdc(void)
296 editSField(HdcFieldMask);
298 return &_sfHdc;
301 const SFHDC *WIN32WindowBase::getSFHdc(void) const
303 return &_sfHdc;
307 SFHGLRC *WIN32WindowBase::editSFHglrc(void)
309 editSField(HglrcFieldMask);
311 return &_sfHglrc;
314 const SFHGLRC *WIN32WindowBase::getSFHglrc(void) const
316 return &_sfHglrc;
320 SFInt32 *WIN32WindowBase::editSFDummy0(void)
322 editSField(Dummy0FieldMask);
324 return &_sfDummy0;
327 const SFInt32 *WIN32WindowBase::getSFDummy0(void) const
329 return &_sfDummy0;
337 /*------------------------------ access -----------------------------------*/
339 SizeT WIN32WindowBase::getBinSize(ConstFieldMaskArg whichField)
341 SizeT returnValue = Inherited::getBinSize(whichField);
343 if(FieldBits::NoField != (HwndFieldMask & whichField))
345 returnValue += _sfHwnd.getBinSize();
347 if(FieldBits::NoField != (HdcFieldMask & whichField))
349 returnValue += _sfHdc.getBinSize();
351 if(FieldBits::NoField != (HglrcFieldMask & whichField))
353 returnValue += _sfHglrc.getBinSize();
355 if(FieldBits::NoField != (Dummy0FieldMask & whichField))
357 returnValue += _sfDummy0.getBinSize();
360 return returnValue;
363 void WIN32WindowBase::copyToBin(BinaryDataHandler &pMem,
364 ConstFieldMaskArg whichField)
366 Inherited::copyToBin(pMem, whichField);
368 if(FieldBits::NoField != (HwndFieldMask & whichField))
370 _sfHwnd.copyToBin(pMem);
372 if(FieldBits::NoField != (HdcFieldMask & whichField))
374 _sfHdc.copyToBin(pMem);
376 if(FieldBits::NoField != (HglrcFieldMask & whichField))
378 _sfHglrc.copyToBin(pMem);
380 if(FieldBits::NoField != (Dummy0FieldMask & whichField))
382 _sfDummy0.copyToBin(pMem);
386 void WIN32WindowBase::copyFromBin(BinaryDataHandler &pMem,
387 ConstFieldMaskArg whichField)
389 Inherited::copyFromBin(pMem, whichField);
391 if(FieldBits::NoField != (HwndFieldMask & whichField))
393 editSField(HwndFieldMask);
394 _sfHwnd.copyFromBin(pMem);
396 if(FieldBits::NoField != (HdcFieldMask & whichField))
398 editSField(HdcFieldMask);
399 _sfHdc.copyFromBin(pMem);
401 if(FieldBits::NoField != (HglrcFieldMask & whichField))
403 editSField(HglrcFieldMask);
404 _sfHglrc.copyFromBin(pMem);
406 if(FieldBits::NoField != (Dummy0FieldMask & whichField))
408 editSField(Dummy0FieldMask);
409 _sfDummy0.copyFromBin(pMem);
413 //! create a new instance of the class
414 WIN32WindowTransitPtr WIN32WindowBase::createLocal(BitVector bFlags)
416 WIN32WindowTransitPtr fc;
418 if(getClassType().getPrototype() != NULL)
420 FieldContainerTransitPtr tmpPtr =
421 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
423 fc = dynamic_pointer_cast<WIN32Window>(tmpPtr);
426 return fc;
429 //! create a new instance of the class, copy the container flags
430 WIN32WindowTransitPtr WIN32WindowBase::createDependent(BitVector bFlags)
432 WIN32WindowTransitPtr fc;
434 if(getClassType().getPrototype() != NULL)
436 FieldContainerTransitPtr tmpPtr =
437 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
439 fc = dynamic_pointer_cast<WIN32Window>(tmpPtr);
442 return fc;
445 //! create a new instance of the class
446 WIN32WindowTransitPtr WIN32WindowBase::create(void)
448 WIN32WindowTransitPtr fc;
450 if(getClassType().getPrototype() != NULL)
452 FieldContainerTransitPtr tmpPtr =
453 getClassType().getPrototype()-> shallowCopy();
455 fc = dynamic_pointer_cast<WIN32Window>(tmpPtr);
458 return fc;
461 WIN32Window *WIN32WindowBase::createEmptyLocal(BitVector bFlags)
463 WIN32Window *returnValue;
465 newPtr<WIN32Window>(returnValue, bFlags);
467 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
469 return returnValue;
472 //! create an empty new instance of the class, do not copy the prototype
473 WIN32Window *WIN32WindowBase::createEmpty(void)
475 WIN32Window *returnValue;
477 newPtr<WIN32Window>(returnValue, Thread::getCurrentLocalFlags());
479 returnValue->_pFieldFlags->_bNamespaceMask &=
480 ~Thread::getCurrentLocalFlags();
482 return returnValue;
486 FieldContainerTransitPtr WIN32WindowBase::shallowCopyLocal(
487 BitVector bFlags) const
489 WIN32Window *tmpPtr;
491 newPtr(tmpPtr, dynamic_cast<const WIN32Window *>(this), bFlags);
493 FieldContainerTransitPtr returnValue(tmpPtr);
495 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
497 return returnValue;
500 FieldContainerTransitPtr WIN32WindowBase::shallowCopyDependent(
501 BitVector bFlags) const
503 WIN32Window *tmpPtr;
505 newPtr(tmpPtr, dynamic_cast<const WIN32Window *>(this), ~bFlags);
507 FieldContainerTransitPtr returnValue(tmpPtr);
509 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
511 return returnValue;
514 FieldContainerTransitPtr WIN32WindowBase::shallowCopy(void) const
516 WIN32Window *tmpPtr;
518 newPtr(tmpPtr,
519 dynamic_cast<const WIN32Window *>(this),
520 Thread::getCurrentLocalFlags());
522 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
524 FieldContainerTransitPtr returnValue(tmpPtr);
526 return returnValue;
532 /*------------------------- constructors ----------------------------------*/
534 WIN32WindowBase::WIN32WindowBase(void) :
535 Inherited(),
536 _sfHwnd (HWND(0)),
537 _sfHdc (HDC(0)),
538 _sfHglrc (HGLRC(0)),
539 _sfDummy0 (Int32(0))
543 WIN32WindowBase::WIN32WindowBase(const WIN32WindowBase &source) :
544 Inherited(source),
545 _sfHwnd (source._sfHwnd ),
546 _sfHdc (source._sfHdc ),
547 _sfHglrc (source._sfHglrc ),
548 _sfDummy0 (source._sfDummy0 )
553 /*-------------------------- destructors ----------------------------------*/
555 WIN32WindowBase::~WIN32WindowBase(void)
560 GetFieldHandlePtr WIN32WindowBase::getHandleHwnd (void) const
562 SFHWND::GetHandlePtr returnValue(
563 new SFHWND::GetHandle(
564 &_sfHwnd,
565 this->getType().getFieldDesc(HwndFieldId),
566 const_cast<WIN32WindowBase *>(this)));
568 return returnValue;
571 EditFieldHandlePtr WIN32WindowBase::editHandleHwnd (void)
573 SFHWND::EditHandlePtr returnValue(
574 new SFHWND::EditHandle(
575 &_sfHwnd,
576 this->getType().getFieldDesc(HwndFieldId),
577 this));
580 editSField(HwndFieldMask);
582 return returnValue;
585 GetFieldHandlePtr WIN32WindowBase::getHandleHdc (void) const
587 SFHDC::GetHandlePtr returnValue(
588 new SFHDC::GetHandle(
589 &_sfHdc,
590 this->getType().getFieldDesc(HdcFieldId),
591 const_cast<WIN32WindowBase *>(this)));
593 return returnValue;
596 EditFieldHandlePtr WIN32WindowBase::editHandleHdc (void)
598 SFHDC::EditHandlePtr returnValue(
599 new SFHDC::EditHandle(
600 &_sfHdc,
601 this->getType().getFieldDesc(HdcFieldId),
602 this));
605 editSField(HdcFieldMask);
607 return returnValue;
610 GetFieldHandlePtr WIN32WindowBase::getHandleHglrc (void) const
612 SFHGLRC::GetHandlePtr returnValue(
613 new SFHGLRC::GetHandle(
614 &_sfHglrc,
615 this->getType().getFieldDesc(HglrcFieldId),
616 const_cast<WIN32WindowBase *>(this)));
618 return returnValue;
621 EditFieldHandlePtr WIN32WindowBase::editHandleHglrc (void)
623 SFHGLRC::EditHandlePtr returnValue(
624 new SFHGLRC::EditHandle(
625 &_sfHglrc,
626 this->getType().getFieldDesc(HglrcFieldId),
627 this));
630 editSField(HglrcFieldMask);
632 return returnValue;
635 GetFieldHandlePtr WIN32WindowBase::getHandleDummy0 (void) const
637 SFInt32::GetHandlePtr returnValue(
638 new SFInt32::GetHandle(
639 &_sfDummy0,
640 this->getType().getFieldDesc(Dummy0FieldId),
641 const_cast<WIN32WindowBase *>(this)));
643 return returnValue;
646 EditFieldHandlePtr WIN32WindowBase::editHandleDummy0 (void)
648 SFInt32::EditHandlePtr returnValue(
649 new SFInt32::EditHandle(
650 &_sfDummy0,
651 this->getType().getFieldDesc(Dummy0FieldId),
652 this));
655 editSField(Dummy0FieldMask);
657 return returnValue;
661 #ifdef OSG_MT_CPTR_ASPECT
662 void WIN32WindowBase::execSyncV( FieldContainer &oFrom,
663 ConstFieldMaskArg whichField,
664 AspectOffsetStore &oOffsets,
665 ConstFieldMaskArg syncMode,
666 const UInt32 uiSyncInfo)
668 WIN32Window *pThis = static_cast<WIN32Window *>(this);
670 pThis->execSync(static_cast<WIN32Window *>(&oFrom),
671 whichField,
672 oOffsets,
673 syncMode,
674 uiSyncInfo);
676 #endif
679 #ifdef OSG_MT_CPTR_ASPECT
680 FieldContainer *WIN32WindowBase::createAspectCopy(
681 const FieldContainer *pRefAspect) const
683 WIN32Window *returnValue;
685 newAspectCopy(returnValue,
686 dynamic_cast<const WIN32Window *>(pRefAspect),
687 dynamic_cast<const WIN32Window *>(this));
689 return returnValue;
691 #endif
693 void WIN32WindowBase::resolveLinks(void)
695 Inherited::resolveLinks();
701 OSG_END_NAMESPACE