changed: auto add updateData callback to stages so that stagedata can be updated...
[opensg.git] / Source / WindowSystem / Cocoa / OSGCocoaWindowBase.cpp
blob6244a872fed9dd8319e32c3666a6866afcfffee9
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 CocoaWindow!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #include "OSGConfig.h"
61 #include "OSGCocoaWindowBase.h"
62 #include "OSGCocoaWindow.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::CocoaWindow
77 The class for MacOS X Cocoa windows.
80 /***************************************************************************\
81 * Field Documentation *
82 \***************************************************************************/
84 /*! \var NSOpenGLContextP CocoaWindowBase::_sfContext
89 /***************************************************************************\
90 * FieldType/FieldTrait Instantiation *
91 \***************************************************************************/
93 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
94 DataType FieldTraits<CocoaWindow *>::_type("CocoaWindowPtr", "WindowPtr");
95 #endif
97 OSG_FIELDTRAITS_GETTYPE(CocoaWindow *)
99 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
100 CocoaWindow *,
103 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
104 CocoaWindow *,
107 /***************************************************************************\
108 * Field Description *
109 \***************************************************************************/
111 void CocoaWindowBase::classDescInserter(TypeObject &oType)
113 FieldDescriptionBase *pDesc = NULL;
116 pDesc = new SFNSOpenGLContextP::Description(
117 SFNSOpenGLContextP::getClassType(),
118 "context",
120 ContextFieldId, ContextFieldMask,
121 true,
122 (Field::SFDefaultFlags | Field::FStdAccess),
123 static_cast<FieldEditMethodSig>(&CocoaWindow::editHandleContext),
124 static_cast<FieldGetMethodSig >(&CocoaWindow::getHandleContext));
126 oType.addInitialDesc(pDesc);
130 CocoaWindowBase::TypeObject CocoaWindowBase::_type(
131 CocoaWindowBase::getClassname(),
132 Inherited::getClassname(),
133 "NULL",
135 reinterpret_cast<PrototypeCreateF>(&CocoaWindowBase::createEmptyLocal),
136 CocoaWindow::initMethod,
137 CocoaWindow::exitMethod,
138 reinterpret_cast<InitalInsertDescFunc>(&CocoaWindow::classDescInserter),
139 false,
141 "<?xml version=\"1.0\"?>\n"
142 "\n"
143 "<FieldContainer\n"
144 " name=\"CocoaWindow\"\n"
145 " parent=\"Window\"\n"
146 " library=\"WindowCocoa\"\n"
147 " pointerfieldtypes=\"both\"\n"
148 " structure=\"concrete\"\n"
149 " systemcomponent=\"true\"\n"
150 " parentsystemcomponent=\"true\"\n"
151 " docGroupBase=\"GrpWindowCocao\"\n"
152 " >\n"
153 " The class for MacOS X Cocoa windows.\n"
154 " <Field\n"
155 "\t name=\"context\"\n"
156 "\t type=\"NSOpenGLContextP\"\n"
157 "\t cardinality=\"single\"\n"
158 "\t visibility=\"internal\"\n"
159 "\t defaultValue=\"0\"\n"
160 "\t fieldHeader=\"OSGCocoaWindowDataFields.h\"\n"
161 "\t access=\"public\"\n"
162 "\t >\n"
163 " </Field>\n"
164 "</FieldContainer>\n",
165 "The class for MacOS X Cocoa windows.\n"
168 /*------------------------------ get -----------------------------------*/
170 FieldContainerType &CocoaWindowBase::getType(void)
172 return _type;
175 const FieldContainerType &CocoaWindowBase::getType(void) const
177 return _type;
180 UInt32 CocoaWindowBase::getContainerSize(void) const
182 return sizeof(CocoaWindow);
185 /*------------------------- decorator get ------------------------------*/
188 SFNSOpenGLContextP *CocoaWindowBase::editSFContext(void)
190 editSField(ContextFieldMask);
192 return &_sfContext;
195 const SFNSOpenGLContextP *CocoaWindowBase::getSFContext(void) const
197 return &_sfContext;
205 /*------------------------------ access -----------------------------------*/
207 SizeT CocoaWindowBase::getBinSize(ConstFieldMaskArg whichField)
209 SizeT returnValue = Inherited::getBinSize(whichField);
211 if(FieldBits::NoField != (ContextFieldMask & whichField))
213 returnValue += _sfContext.getBinSize();
216 return returnValue;
219 void CocoaWindowBase::copyToBin(BinaryDataHandler &pMem,
220 ConstFieldMaskArg whichField)
222 Inherited::copyToBin(pMem, whichField);
224 if(FieldBits::NoField != (ContextFieldMask & whichField))
226 _sfContext.copyToBin(pMem);
230 void CocoaWindowBase::copyFromBin(BinaryDataHandler &pMem,
231 ConstFieldMaskArg whichField)
233 Inherited::copyFromBin(pMem, whichField);
235 if(FieldBits::NoField != (ContextFieldMask & whichField))
237 editSField(ContextFieldMask);
238 _sfContext.copyFromBin(pMem);
242 //! create a new instance of the class
243 CocoaWindowTransitPtr CocoaWindowBase::createLocal(BitVector bFlags)
245 CocoaWindowTransitPtr fc;
247 if(getClassType().getPrototype() != NULL)
249 FieldContainerTransitPtr tmpPtr =
250 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
252 fc = dynamic_pointer_cast<CocoaWindow>(tmpPtr);
255 return fc;
258 //! create a new instance of the class, copy the container flags
259 CocoaWindowTransitPtr CocoaWindowBase::createDependent(BitVector bFlags)
261 CocoaWindowTransitPtr fc;
263 if(getClassType().getPrototype() != NULL)
265 FieldContainerTransitPtr tmpPtr =
266 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
268 fc = dynamic_pointer_cast<CocoaWindow>(tmpPtr);
271 return fc;
274 //! create a new instance of the class
275 CocoaWindowTransitPtr CocoaWindowBase::create(void)
277 CocoaWindowTransitPtr fc;
279 if(getClassType().getPrototype() != NULL)
281 FieldContainerTransitPtr tmpPtr =
282 getClassType().getPrototype()-> shallowCopy();
284 fc = dynamic_pointer_cast<CocoaWindow>(tmpPtr);
287 return fc;
290 CocoaWindow *CocoaWindowBase::createEmptyLocal(BitVector bFlags)
292 CocoaWindow *returnValue;
294 newPtr<CocoaWindow>(returnValue, bFlags);
296 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
298 return returnValue;
301 //! create an empty new instance of the class, do not copy the prototype
302 CocoaWindow *CocoaWindowBase::createEmpty(void)
304 CocoaWindow *returnValue;
306 newPtr<CocoaWindow>(returnValue, Thread::getCurrentLocalFlags());
308 returnValue->_pFieldFlags->_bNamespaceMask &=
309 ~Thread::getCurrentLocalFlags();
311 return returnValue;
315 FieldContainerTransitPtr CocoaWindowBase::shallowCopyLocal(
316 BitVector bFlags) const
318 CocoaWindow *tmpPtr;
320 newPtr(tmpPtr, dynamic_cast<const CocoaWindow *>(this), bFlags);
322 FieldContainerTransitPtr returnValue(tmpPtr);
324 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
326 return returnValue;
329 FieldContainerTransitPtr CocoaWindowBase::shallowCopyDependent(
330 BitVector bFlags) const
332 CocoaWindow *tmpPtr;
334 newPtr(tmpPtr, dynamic_cast<const CocoaWindow *>(this), ~bFlags);
336 FieldContainerTransitPtr returnValue(tmpPtr);
338 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
340 return returnValue;
343 FieldContainerTransitPtr CocoaWindowBase::shallowCopy(void) const
345 CocoaWindow *tmpPtr;
347 newPtr(tmpPtr,
348 dynamic_cast<const CocoaWindow *>(this),
349 Thread::getCurrentLocalFlags());
351 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
353 FieldContainerTransitPtr returnValue(tmpPtr);
355 return returnValue;
361 /*------------------------- constructors ----------------------------------*/
363 CocoaWindowBase::CocoaWindowBase(void) :
364 Inherited(),
365 _sfContext (NSOpenGLContextP(0))
369 CocoaWindowBase::CocoaWindowBase(const CocoaWindowBase &source) :
370 Inherited(source),
371 _sfContext (source._sfContext )
376 /*-------------------------- destructors ----------------------------------*/
378 CocoaWindowBase::~CocoaWindowBase(void)
383 GetFieldHandlePtr CocoaWindowBase::getHandleContext (void) const
385 SFNSOpenGLContextP::GetHandlePtr returnValue(
386 new SFNSOpenGLContextP::GetHandle(
387 &_sfContext,
388 this->getType().getFieldDesc(ContextFieldId),
389 const_cast<CocoaWindowBase *>(this)));
391 return returnValue;
394 EditFieldHandlePtr CocoaWindowBase::editHandleContext (void)
396 SFNSOpenGLContextP::EditHandlePtr returnValue(
397 new SFNSOpenGLContextP::EditHandle(
398 &_sfContext,
399 this->getType().getFieldDesc(ContextFieldId),
400 this));
403 editSField(ContextFieldMask);
405 return returnValue;
409 #ifdef OSG_MT_CPTR_ASPECT
410 void CocoaWindowBase::execSyncV( FieldContainer &oFrom,
411 ConstFieldMaskArg whichField,
412 AspectOffsetStore &oOffsets,
413 ConstFieldMaskArg syncMode,
414 const UInt32 uiSyncInfo)
416 CocoaWindow *pThis = static_cast<CocoaWindow *>(this);
418 pThis->execSync(static_cast<CocoaWindow *>(&oFrom),
419 whichField,
420 oOffsets,
421 syncMode,
422 uiSyncInfo);
424 #endif
427 #ifdef OSG_MT_CPTR_ASPECT
428 FieldContainer *CocoaWindowBase::createAspectCopy(
429 const FieldContainer *pRefAspect) const
431 CocoaWindow *returnValue;
433 newAspectCopy(returnValue,
434 dynamic_cast<const CocoaWindow *>(pRefAspect),
435 dynamic_cast<const CocoaWindow *>(this));
437 return returnValue;
439 #endif
441 void CocoaWindowBase::resolveLinks(void)
443 Inherited::resolveLinks();
449 OSG_END_NAMESPACE