Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

object.h

Go to the documentation of this file.
00001 /***************************************************************************
00002              object.h  -  Base object class for windowing toolkit
00003                              -------------------
00004     begin                : Sun Nov 17 2002
00005     copyright            : (C) 2002 by Mattias Jansson
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, NeoWTK, object.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2002
00023  Reality Rift Studios. All Rights Reserved.
00024 
00025  ***************************************************************************/
00026 
00027 #ifndef __NEOWTKOBJECT_H
00028 #define __NEOWTKOBJECT_H
00029 
00030 
00031 #include "base.h"
00032 #include "coord.h"
00033 
00034 #include <neoengine/hashstring.h>
00035 #include <neoengine/updateentity.h>
00036 #include <neoengine/renderentity.h>
00037 #include <neoengine/inputentity.h>
00038 #include <neoengine/input.h>
00039 
00040 #ifdef HAVE_NEOCHUNKIO
00041 #  include <neochunkio/complex.h>
00042 #  include "chunktype.h"
00043 #endif
00044 
00045 #include <vector>
00046 
00047 
00054 namespace NeoWTK
00055 {
00056 
00057 
00058 // External classes
00059 class Msg;
00060 class MsgHook;
00061 class AttributeBase;
00062 
00063 
00064 #ifdef HAVE_NEOCHUNKIO
00065 
00066 
00067 // Forward declarations
00068 class ObjectChunk;
00069 
00070 
00071 #endif
00072 
00073 
00074 #ifdef WIN32
00075 #  pragma warning( disable : 4231 )
00076 #  ifndef __HAVE_VECTOR_NEWTKOBJECT
00077      WtkUDTVectorEXPIMP( class Object* );
00078 #    define __HAVE_VECTOR_NEWTKOBJECT
00079 #  endif
00080 #  ifndef __HAVE_VECTOR_NEWTKMSGHOOK
00081      WtkUDTVectorEXPIMP( class MsgHook* );
00082 #    define __HAVE_VECTOR_NEWTKMSGHOOK
00083 #  endif
00084 #endif
00085 
00086 
00091 class NEOWTK_API Object : public virtual NeoEngine::UpdateEntity, public virtual NeoEngine::RenderEntity, public NeoEngine::InputEntity, public NeoEngine::InputGroup
00092 {
00093 #ifdef HAVE_NEOCHUNKIO
00094     friend class ObjectChunk;
00095 #endif
00096 
00097     public:
00098 
00103         enum HITTESTRESULT
00104         {
00106           OUTSIDE,
00107 
00109           INSIDE,
00110 
00112           EDGE          
00113         };
00114 
00115 
00116     protected:
00117 
00119         unsigned int                                  m_uiID;
00120 
00122         Object                                       *m_pkParent;
00123 
00125         std::vector< Object* >                        m_vpkChildren;
00126 
00128         Coord                                         m_kPos;
00129 
00131         Coord                                         m_kWorldPos;
00132 
00134         Coord                                         m_kSize;
00135 
00137         NeoEngine::HashString                         m_strName;
00138 
00140         std::vector< MsgHook* >                       m_vpkMsgHook;
00141 
00143         HITTESTRESULT                                 m_eLastMouse;
00144 
00145 
00150         void                                          UpdateWorldCache( bool bRecurse = true );
00151 
00152 
00153     public:
00154 
00155 
00161                                                       Object( Object *pkParent, Object *pkObject = 0, bool bDuplicateChildren = true );
00162 
00166         virtual                                      ~Object();
00167 
00173         virtual const Coord                          &SetPosition( const Coord &rkPos );
00174 
00180         virtual const Coord                          &SetSize( const Coord &rkSize );
00181 
00185         const Coord                                  &GetPosition() const;
00186 
00190         const Coord                                  &GetWorldPosition();
00191 
00195         const Coord                                  &GetSize() const;
00196 
00200         virtual void                                  SetName( const NeoEngine::HashString &rstrName );
00201 
00205         virtual const NeoEngine::HashString          &GetName() const;
00206 
00211         virtual void                                  SetAttribute( const AttributeBase &rkAttribute );
00212 
00216         inline unsigned int                           GetID() const { return m_uiID; }
00217 
00221         virtual Object                               *GetParent();
00222 
00226         virtual Object                               *GetRoot();
00227 
00233         virtual Object                               *GetObject( const std::string &rstrName );
00234 
00239         virtual const std::vector< Object* >         &GetChildObjects() const;
00240 
00245         virtual void                                  AttachObject( Object *pkObject );
00246 
00251         virtual void                                  DetachObject( Object *pkObject );
00252 
00257         virtual void                                  AttachToObject( Object *pkParent );
00258 
00264         virtual unsigned int                          ProcessMsg( Msg *pkMsg );
00265 
00272         virtual bool                                  Render( NeoEngine::Frustum *pkFrustum = 0, bool bForce = false );
00273 
00278         virtual void                                  AddHook( MsgHook *pkMsgHook );
00279 
00284         virtual void                                  RemoveHook( MsgHook *pkMsgHook );
00285         
00290         virtual void                                  Input( const NeoEngine::InputEvent *pkEvent );
00291 
00297         HITTESTRESULT                                 HitTest( const Coord &rkCoord );
00298 
00303         virtual void                                  Update( float fDeltaTime );
00304 
00311         virtual Object                               *Duplicate( Object *pkParent = 0, Object *pkObject = 0 );
00312 };
00313 
00314 
00315 #ifdef HAVE_NEOCHUNKIO
00316 
00317 
00322 class NEOWTK_API ObjectChunk : public NeoChunkIO::ComplexChunk
00323 {
00324     public:
00325 
00330         enum PARSEFLAG
00331         {
00333           NOCHILDREN                                  = 0x00100000,
00334 
00336           NOATTRIBUTES                                = 0x00200000
00337         };
00338 
00339 
00340 
00342         Object                                       *m_pkObject;
00343 
00344 
00351                                                       ObjectChunk( unsigned short usType, const NeoEngine::HashString &rstrType, const NeoEngine::HashString &rstrID = "" ) : NeoChunkIO::ComplexChunk( usType, rstrType, rstrID ), m_pkObject( 0 ) { m_usFindType = NeoWTK::ChunkType::OBJECT; }
00352         
00356         virtual                                      ~ObjectChunk() { delete m_pkObject; }
00357 
00364         virtual int                                   ParseData( unsigned int uiFlags, NeoEngine::FileManager *pkFileManager );
00365 
00369         virtual void                                  AttachChildren();
00370 
00374         virtual void                                  SetAttributes();
00375 
00383         static NeoChunkIO::Chunk                     *Allocator( unsigned short usType, const NeoEngine::HashString &rstrType, const NeoEngine::HashString &rstrID ) { return new ObjectChunk( usType, rstrType, rstrID ); }
00384 };
00385 
00386 
00387 #endif
00388 
00389 
00390 };
00391 
00392 
00393 #endif

Generated on Wed Jan 21 14:21:20 2004 for NeoWTK by doxygen 1.3.5