1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
50 *****************************************************************************
51 \*****************************************************************************/
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)
72 /***************************************************************************\
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");
97 OSG_FIELDTRAITS_GETTYPE(CocoaWindow
*)
99 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
103 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
107 /***************************************************************************\
108 * Field Description *
109 \***************************************************************************/
111 void CocoaWindowBase::classDescInserter(TypeObject
&oType
)
113 FieldDescriptionBase
*pDesc
= NULL
;
116 pDesc
= new SFNSOpenGLContextP::Description(
117 SFNSOpenGLContextP::getClassType(),
120 ContextFieldId
, ContextFieldMask
,
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(),
135 reinterpret_cast<PrototypeCreateF
>(&CocoaWindowBase::createEmptyLocal
),
136 CocoaWindow::initMethod
,
137 CocoaWindow::exitMethod
,
138 reinterpret_cast<InitalInsertDescFunc
>(&CocoaWindow::classDescInserter
),
141 "<?xml version=\"1.0\"?>\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"
153 " The class for MacOS X Cocoa windows.\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"
164 "</FieldContainer>\n",
165 "The class for MacOS X Cocoa windows.\n"
168 /*------------------------------ get -----------------------------------*/
170 FieldContainerType
&CocoaWindowBase::getType(void)
175 const FieldContainerType
&CocoaWindowBase::getType(void) const
180 UInt32
CocoaWindowBase::getContainerSize(void) const
182 return sizeof(CocoaWindow
);
185 /*------------------------- decorator get ------------------------------*/
188 SFNSOpenGLContextP
*CocoaWindowBase::editSFContext(void)
190 editSField(ContextFieldMask
);
195 const SFNSOpenGLContextP
*CocoaWindowBase::getSFContext(void) const
205 /*------------------------------ access -----------------------------------*/
207 SizeT
CocoaWindowBase::getBinSize(ConstFieldMaskArg whichField
)
209 SizeT returnValue
= Inherited::getBinSize(whichField
);
211 if(FieldBits::NoField
!= (ContextFieldMask
& whichField
))
213 returnValue
+= _sfContext
.getBinSize();
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
);
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
);
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
);
290 CocoaWindow
*CocoaWindowBase::createEmptyLocal(BitVector bFlags
)
292 CocoaWindow
*returnValue
;
294 newPtr
<CocoaWindow
>(returnValue
, bFlags
);
296 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
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();
315 FieldContainerTransitPtr
CocoaWindowBase::shallowCopyLocal(
316 BitVector bFlags
) const
320 newPtr(tmpPtr
, dynamic_cast<const CocoaWindow
*>(this), bFlags
);
322 FieldContainerTransitPtr
returnValue(tmpPtr
);
324 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
329 FieldContainerTransitPtr
CocoaWindowBase::shallowCopyDependent(
330 BitVector bFlags
) const
334 newPtr(tmpPtr
, dynamic_cast<const CocoaWindow
*>(this), ~bFlags
);
336 FieldContainerTransitPtr
returnValue(tmpPtr
);
338 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
343 FieldContainerTransitPtr
CocoaWindowBase::shallowCopy(void) const
348 dynamic_cast<const CocoaWindow
*>(this),
349 Thread::getCurrentLocalFlags());
351 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
353 FieldContainerTransitPtr
returnValue(tmpPtr
);
361 /*------------------------- constructors ----------------------------------*/
363 CocoaWindowBase::CocoaWindowBase(void) :
365 _sfContext (NSOpenGLContextP(0))
369 CocoaWindowBase::CocoaWindowBase(const CocoaWindowBase
&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(
388 this->getType().getFieldDesc(ContextFieldId
),
389 const_cast<CocoaWindowBase
*>(this)));
394 EditFieldHandlePtr
CocoaWindowBase::editHandleContext (void)
396 SFNSOpenGLContextP::EditHandlePtr
returnValue(
397 new SFNSOpenGLContextP::EditHandle(
399 this->getType().getFieldDesc(ContextFieldId
),
403 editSField(ContextFieldMask
);
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
),
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));
441 void CocoaWindowBase::resolveLinks(void)
443 Inherited::resolveLinks();