diff --git a/src/gaming/cgameobject.cpp b/src/gaming/cgameobject.cpp index 1a9e1723f..886bcb5f4 100644 --- a/src/gaming/cgameobject.cpp +++ b/src/gaming/cgameobject.cpp @@ -13,8 +13,12 @@ cGameObject::~cGameObject() { } +Uint32 cGameObject::Type() const { + return GAMEOBJECT_TYPE_BASE; +} + bool cGameObject::IsType( const Uint32& type ) { - return type == Type(); + return type == cGameObject::Type(); } const Uint32& cGameObject::Flags() const { @@ -94,10 +98,6 @@ eeSize cGameObject::Size() { return eeSize(); } -Uint32 cGameObject::Type() const { - return GAMEOBJECT_TYPE_BASE; -} - Uint32 cGameObject::DataId() { return 0; } diff --git a/src/gaming/cgameobjectshape.cpp b/src/gaming/cgameobjectshape.cpp index 307a3d38e..d4f2d9410 100644 --- a/src/gaming/cgameobjectshape.cpp +++ b/src/gaming/cgameobjectshape.cpp @@ -22,7 +22,7 @@ Uint32 cGameObjectShape::Type() const { } bool cGameObjectShape::IsType( const Uint32& type ) { - return ( Type() == type ) ? true : cGameObject::IsType( type ); + return ( cGameObjectShape::Type() == type ) ? true : cGameObject::IsType( type ); } void cGameObjectShape::Draw() { diff --git a/src/gaming/cgameobjectshapeex.cpp b/src/gaming/cgameobjectshapeex.cpp index 9ce24e067..da90dd5a8 100644 --- a/src/gaming/cgameobjectshapeex.cpp +++ b/src/gaming/cgameobjectshapeex.cpp @@ -28,7 +28,7 @@ Uint32 cGameObjectShapeEx::Type() const { } bool cGameObjectShapeEx::IsType( const Uint32& type ) { - return ( Type() == type ) ? true : cGameObjectShape::IsType( type ); + return ( cGameObjectShapeEx::Type() == type ) ? true : cGameObjectShape::IsType( type ); } void cGameObjectShapeEx::Draw() { diff --git a/src/gaming/cgameobjectsprite.cpp b/src/gaming/cgameobjectsprite.cpp index b024b4f21..ecd6f7f43 100644 --- a/src/gaming/cgameobjectsprite.cpp +++ b/src/gaming/cgameobjectsprite.cpp @@ -24,7 +24,7 @@ Uint32 cGameObjectSprite::Type() const { } bool cGameObjectSprite::IsType( const Uint32& type ) { - return ( Type() == type ) ? true : cGameObject::IsType( type ); + return ( cGameObjectSprite::Type() == type ) ? true : cGameObject::IsType( type ); } void cGameObjectSprite::Draw() { diff --git a/src/gaming/cgameobjectvirtual.cpp b/src/gaming/cgameobjectvirtual.cpp index 6b32fa403..d109c0268 100644 --- a/src/gaming/cgameobjectvirtual.cpp +++ b/src/gaming/cgameobjectvirtual.cpp @@ -38,7 +38,7 @@ Uint32 cGameObjectVirtual::Type() const { } bool cGameObjectVirtual::IsType( const Uint32& type ) { - return ( Type() == type ) ? true : cGameObject::IsType( type ); + return ( cGameObjectVirtual::Type() == type ) ? true : cGameObject::IsType( type ); } Uint32 cGameObjectVirtual::RealType() const { diff --git a/src/gaming/mapeditor/cmapeditor.cpp b/src/gaming/mapeditor/cmapeditor.cpp index 46b79b836..5beb4bfd3 100644 --- a/src/gaming/mapeditor/cmapeditor.cpp +++ b/src/gaming/mapeditor/cmapeditor.cpp @@ -741,7 +741,7 @@ void cMapEditor::MapSave( const cUIEvent * Event ) { } void cMapEditor::FileMenuClick( const cUIEvent * Event ) { - if ( !Event->Ctrl()->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) + if ( !Event->Ctrl()->IsType( UI_TYPE_MENUITEM ) ) return; const String& txt = reinterpret_cast ( Event->Ctrl() )->Text(); @@ -792,7 +792,7 @@ void cMapEditor::OnMapClose( const cUIEvent * Event ) { } void cMapEditor::ViewMenuClick( const cUIEvent * Event ) { - if ( !Event->Ctrl()->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) + if ( !Event->Ctrl()->IsType( UI_TYPE_MENUITEM ) ) return; const String& txt = reinterpret_cast ( Event->Ctrl() )->Text(); @@ -807,7 +807,7 @@ void cMapEditor::ViewMenuClick( const cUIEvent * Event ) { } void cMapEditor::MapMenuClick( const cUIEvent * Event ) { - if ( !Event->Ctrl()->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) + if ( !Event->Ctrl()->IsType( UI_TYPE_MENUITEM ) ) return; const String& txt = reinterpret_cast ( Event->Ctrl() )->Text(); @@ -830,7 +830,7 @@ void cMapEditor::MapMenuClick( const cUIEvent * Event ) { } void cMapEditor::LayerMenuClick( const cUIEvent * Event ) { - if ( !Event->Ctrl()->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) + if ( !Event->Ctrl()->IsType( UI_TYPE_MENUITEM ) ) return; const String& txt = reinterpret_cast ( Event->Ctrl() )->Text(); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 303de126f..08f3eb94c 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -632,7 +632,7 @@ void cEETest::CloseClick( const cUIEvent * Event ) { } void cEETest::ItemClick( const cUIEvent * Event ) { - if ( !Event->Ctrl()->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) + if ( !Event->Ctrl()->IsType( UI_TYPE_MENUITEM ) ) return; const String& txt = reinterpret_cast ( Event->Ctrl() )->Text(); @@ -849,7 +849,7 @@ void cEETest::LoadTextures() { CurMan->Visible( false ); CurMan->Visible( true ); CurMan->Set( Window::Cursor::SYS_CURSOR_LINK ); - CurMan->Set( CurMan->Add( CurMan->Create( CursorP[1], eeVector2i( 2, 2 ), "cursor_special" ) ) ); + CurMan->Set( CurMan->Add( CurMan->Create( CursorP[1], eeVector2i( 1, 1 ), "cursor_special" ) ) ); CL1.AddFrame(TN[2]); CL1.Position( 500, 400 ); diff --git a/src/ui/cuicheckbox.cpp b/src/ui/cuicheckbox.cpp index dec55e306..4bcb1b6b0 100644 --- a/src/ui/cuicheckbox.cpp +++ b/src/ui/cuicheckbox.cpp @@ -7,8 +7,6 @@ cUICheckBox::cUICheckBox( const cUITextBox::CreateParams& Params ) : cUITextBox( Params ), mActive( false ) { - mType = UI_TYPE_CHECKBOX; - cUIControlAnim::CreateParams ButtonParams( Params ); ButtonParams.Parent( this ); @@ -31,6 +29,14 @@ cUICheckBox::cUICheckBox( const cUITextBox::CreateParams& Params ) : cUICheckBox::~cUICheckBox() { } +Uint32 cUICheckBox::Type() const { + return UI_TYPE_CHECKBOX; +} + +bool cUICheckBox::IsType( const Uint32& type ) const { + return cUICheckBox::Type() == type ? true : cUITextBox::IsType( type ); +} + void cUICheckBox::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "checkbox" ); diff --git a/src/ui/cuicheckbox.hpp b/src/ui/cuicheckbox.hpp index 77a60f317..a802c5049 100644 --- a/src/ui/cuicheckbox.hpp +++ b/src/ui/cuicheckbox.hpp @@ -12,6 +12,10 @@ class EE_API cUICheckBox : public cUITextBox { ~cUICheckBox(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); const bool& IsActive() const; diff --git a/src/ui/cuicombobox.cpp b/src/ui/cuicombobox.cpp index 08f2db877..cb5557959 100644 --- a/src/ui/cuicombobox.cpp +++ b/src/ui/cuicombobox.cpp @@ -6,8 +6,6 @@ cUIComboBox::cUIComboBox( cUIComboBox::CreateParams& Params ) : cUIDropDownList( Params ), mButton( NULL ) { - mType = UI_TYPE_COMBOBOX; - AllowEditing( true ); ApplyDefaultTheme(); @@ -16,6 +14,14 @@ cUIComboBox::cUIComboBox( cUIComboBox::CreateParams& Params ) : cUIComboBox::~cUIComboBox() { } +Uint32 cUIComboBox::Type() const { + return UI_TYPE_COMBOBOX; +} + +bool cUIComboBox::IsType( const Uint32& type ) const { + return cUIComboBox::Type() == type ? true : cUIDropDownList::IsType( type ); +} + void cUIComboBox::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "combobox" ); diff --git a/src/ui/cuicombobox.hpp b/src/ui/cuicombobox.hpp index a02754f71..ff48cdf54 100644 --- a/src/ui/cuicombobox.hpp +++ b/src/ui/cuicombobox.hpp @@ -11,6 +11,10 @@ class EE_API cUIComboBox : public cUIDropDownList { ~cUIComboBox(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); protected: cUIControl * mButton; diff --git a/src/ui/cuicommondialog.cpp b/src/ui/cuicommondialog.cpp index 90350c54f..cc5a3c696 100644 --- a/src/ui/cuicommondialog.cpp +++ b/src/ui/cuicommondialog.cpp @@ -13,8 +13,6 @@ cUICommonDialog::cUICommonDialog( const cUICommonDialog::CreateParams& Params ) mCurPath( Params.DefaultDirectory ), mCDLFlags( Params.CDLFlags ) { - mType = UI_TYPE_COMMONDIALOG; - if ( mSize.Width() < CDLG_MIN_WIDTH ) mSize.x = CDLG_MIN_WIDTH; @@ -140,6 +138,14 @@ cUICommonDialog::cUICommonDialog( const cUICommonDialog::CreateParams& Params ) cUICommonDialog::~cUICommonDialog() { } +Uint32 cUICommonDialog::Type() const { + return UI_TYPE_COMMONDIALOG; +} + +bool cUICommonDialog::IsType( const Uint32& type ) const { + return cUICommonDialog::Type() == type ? true : cUIWindow::IsType( type ); +} + void cUICommonDialog::SetTheme( cUITheme * Theme ) { cUIWindow::SetTheme( Theme ); @@ -239,7 +245,7 @@ Uint32 cUICommonDialog::OnMessage( const cUIMessage * Msg ) { case cUIMessage::MsgDoubleClick: { if ( Msg->Flags() & EE_BUTTON_LMASK ) { - if ( Msg->Sender()->IsTypeOrInheritsFrom( UI_TYPE_LISTBOXITEM ) ) { + if ( Msg->Sender()->IsType( UI_TYPE_LISTBOXITEM ) ) { std::string newPath = mCurPath + mList->GetItemSelectedText(); if ( IsDirectory( newPath ) ) { diff --git a/src/ui/cuicommondialog.hpp b/src/ui/cuicommondialog.hpp index 7d43ed204..184ed9e03 100644 --- a/src/ui/cuicommondialog.hpp +++ b/src/ui/cuicommondialog.hpp @@ -34,6 +34,10 @@ class EE_API cUICommonDialog : public cUIWindow { virtual ~cUICommonDialog(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); void RefreshFolder(); diff --git a/src/ui/cuicomplexcontrol.cpp b/src/ui/cuicomplexcontrol.cpp index 92e616863..203cd84c6 100644 --- a/src/ui/cuicomplexcontrol.cpp +++ b/src/ui/cuicomplexcontrol.cpp @@ -8,7 +8,6 @@ cUIComplexControl::cUIComplexControl( const cUIComplexControl::CreateParams& Par mTooltip( NULL ), mMinControlSize( Params.MinControlSize ) { - mType = UI_TYPE_CONTROL_COMPLEX; mControlFlags |= UI_CTRL_FLAG_COMPLEX; CalcDistToBorder(); @@ -20,6 +19,14 @@ cUIComplexControl::~cUIComplexControl() { eeSAFE_DELETE( mTooltip ); } +Uint32 cUIComplexControl::Type() const { + return UI_TYPE_CONTROL_COMPLEX; +} + +bool cUIComplexControl::IsType( const Uint32& type ) const { + return cUIComplexControl::Type() == type ? true : cUIControlAnim::IsType( type ); +} + void cUIComplexControl::CalcDistToBorder() { if ( NULL != mParentCtrl ) { mDistToBorder = eeRecti( mPos.x, mPos.y, mParentCtrl->Size().x - ( mPos.x + mSize.x ), mParentCtrl->Size().y - ( mPos.y + mSize.y ) ); diff --git a/src/ui/cuicomplexcontrol.hpp b/src/ui/cuicomplexcontrol.hpp index 9ad4ef460..83d39c3d5 100644 --- a/src/ui/cuicomplexcontrol.hpp +++ b/src/ui/cuicomplexcontrol.hpp @@ -41,6 +41,10 @@ class EE_API cUIComplexControl : public cUIControlAnim { virtual ~cUIComplexControl(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void Update(); virtual void Size( const eeSize &Size ); diff --git a/src/ui/cuicontrol.cpp b/src/ui/cuicontrol.cpp index 31e052fbc..c4231f9f1 100644 --- a/src/ui/cuicontrol.cpp +++ b/src/ui/cuicontrol.cpp @@ -7,7 +7,6 @@ cUIControl::cUIControl( const CreateParams& Params ) : mPos( Params.Pos ), mSize( Params.Size ), mFlags( Params.Flags ), - mType( UI_TYPE_CONTROL ), mData( 0 ), mParentCtrl( Params.ParentCtrl ), mChild( NULL ), @@ -89,19 +88,11 @@ void cUIControl::ControlToScreen( eeVector2i& Pos ) const { } Uint32 cUIControl::Type() const { - return mType; + return UI_TYPE_CONTROL; } -bool cUIControl::IsType( const Uint32& Type ) const { - return mType == Type; -} - -bool cUIControl::InheritsFrom( const Uint32 Type ) { - return false; -} - -bool cUIControl::IsTypeOrInheritsFrom( const Uint32 Type ) { - return IsType( Type ) || InheritsFrom( Type ); +bool cUIControl::IsType( const Uint32& type ) const { + return cUIControl::Type() == type; } void cUIControl::MessagePost( const cUIMessage * Msg ) { diff --git a/src/ui/cuicontrol.hpp b/src/ui/cuicontrol.hpp index dcda1de29..536410623 100644 --- a/src/ui/cuicontrol.hpp +++ b/src/ui/cuicontrol.hpp @@ -78,14 +78,9 @@ class EE_API cUIControl { void ControlToScreen( eeVector2i& Pos ) const; - Uint32 Type() const; + virtual Uint32 Type() const; - bool IsType( const Uint32& Type ) const; - - //! This exists because i want to avoid dynamic_cast if it's possible. It's ugly, i don't like the solution, but, works. - virtual bool InheritsFrom( const Uint32 Type ); - - bool IsTypeOrInheritsFrom( const Uint32 Type ); + virtual bool IsType( const Uint32& type ) const; virtual void MessagePost( const cUIMessage * Msg ); @@ -244,7 +239,6 @@ class EE_API cUIControl { eeSize mSize; Uint32 mFlags; - Uint32 mType; Uint32 mData; cUIControl * mParentCtrl; diff --git a/src/ui/cuicontrolanim.cpp b/src/ui/cuicontrolanim.cpp index 3bbdc99c5..de4004f58 100644 --- a/src/ui/cuicontrolanim.cpp +++ b/src/ui/cuicontrolanim.cpp @@ -13,7 +13,6 @@ cUIControlAnim::cUIControlAnim( const CreateParams& Params ) : mAlphaAnim(NULL), mMoveAnim(NULL) { - mType = UI_TYPE_CONTROL_ANIM; mControlFlags |= UI_CTRL_FLAG_ANIM; } @@ -24,6 +23,14 @@ cUIControlAnim::~cUIControlAnim() { eeSAFE_DELETE( mMoveAnim ); } +Uint32 cUIControlAnim::Type() const { + return UI_TYPE_CONTROL_ANIM; +} + +bool cUIControlAnim::IsType( const Uint32& type ) const { + return cUIControlAnim::Type() == type ? true : cUIControl::IsType( type ); +} + void cUIControlAnim::Draw() { if ( mVisible && 0.f != mAlpha ) { if ( mFlags & UI_FILL_BACKGROUND ) diff --git a/src/ui/cuicontrolanim.hpp b/src/ui/cuicontrolanim.hpp index 7ab8b2122..dac233067 100644 --- a/src/ui/cuicontrolanim.hpp +++ b/src/ui/cuicontrolanim.hpp @@ -13,6 +13,10 @@ class EE_API cUIControlAnim : public cUIDragable { virtual ~cUIControlAnim(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void Update(); const eeFloat& Angle() const; diff --git a/src/ui/cuidragable.cpp b/src/ui/cuidragable.cpp index 1efdab800..ff340e3f1 100644 --- a/src/ui/cuidragable.cpp +++ b/src/ui/cuidragable.cpp @@ -8,13 +8,20 @@ cUIDragable::cUIDragable( const cUIControl::CreateParams& Params ) : cUIControl( Params ), mDragButton( EE_BUTTON_LMASK ) { - mType = UI_TYPE_CONTROL_DRAGABLE; mControlFlags |= UI_CTRL_FLAG_DRAGABLE; } cUIDragable::~cUIDragable() { } +Uint32 cUIDragable::Type() const { + return UI_TYPE_CONTROL_DRAGABLE; +} + +bool cUIDragable::IsType( const Uint32& type ) const { + return cUIDragable::Type() == type ? true : cUIControl::IsType( type ); +} + Uint32 cUIDragable::OnMouseDown( const eeVector2i& Pos, const Uint32 Flags ) { if ( !( cUIManager::instance()->LastPressTrigger() & mDragButton ) && ( Flags & mDragButton ) && DragEnable() && !Dragging() ) { Dragging( true ); diff --git a/src/ui/cuidragable.hpp b/src/ui/cuidragable.hpp index 9be9d5129..7014bbece 100644 --- a/src/ui/cuidragable.hpp +++ b/src/ui/cuidragable.hpp @@ -9,6 +9,10 @@ class EE_API cUIDragable : public cUIControl { public: cUIDragable( const cUIControl::CreateParams& Params ); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + bool Dragging() const; void Dragging( const bool& dragging ); diff --git a/src/ui/cuidropdownlist.cpp b/src/ui/cuidropdownlist.cpp index b3380ab6a..f458e0234 100644 --- a/src/ui/cuidropdownlist.cpp +++ b/src/ui/cuidropdownlist.cpp @@ -9,8 +9,6 @@ cUIDropDownList::cUIDropDownList( cUIDropDownList::CreateParams& Params ) : mMinNumVisibleItems( Params.MinNumVisibleItems ), mPopUpToMainControl( Params.PopUpToMainControl ) { - mType = UI_TYPE_DROPDOWNLIST; - AllowEditing( false ); ApplyDefaultTheme(); @@ -37,6 +35,14 @@ cUIDropDownList::cUIDropDownList( cUIDropDownList::CreateParams& Params ) : cUIDropDownList::~cUIDropDownList() { } +Uint32 cUIDropDownList::Type() const { + return UI_TYPE_DROPDOWNLIST; +} + +bool cUIDropDownList::IsType( const Uint32& type ) const { + return cUIDropDownList::Type() == type ? true : cUITextInput::IsType( type ); +} + void cUIDropDownList::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "dropdownlist" ); diff --git a/src/ui/cuidropdownlist.hpp b/src/ui/cuidropdownlist.hpp index 8ec1e8f75..fbff5a9e2 100644 --- a/src/ui/cuidropdownlist.hpp +++ b/src/ui/cuidropdownlist.hpp @@ -29,6 +29,10 @@ class EE_API cUIDropDownList : public cUITextInput { ~cUIDropDownList(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); cUIListBox * ListBox() const; diff --git a/src/ui/cuigenericgrid.cpp b/src/ui/cuigenericgrid.cpp index 317de88e7..88bfb99f2 100644 --- a/src/ui/cuigenericgrid.cpp +++ b/src/ui/cuigenericgrid.cpp @@ -23,8 +23,6 @@ cUIGenericGrid::cUIGenericGrid( const cUIGenericGrid::CreateParams& Params ) : mSelected(-1), mCollWidthAssigned( false ) { - mType = UI_TYPE_GENERICGRID; - mCollumnsWidth.resize( mCollumnsCount, 0 ); mCollumnsPos.resize( mCollumnsCount, 0 ); @@ -72,6 +70,14 @@ cUIGenericGrid::cUIGenericGrid( const cUIGenericGrid::CreateParams& Params ) : cUIGenericGrid::~cUIGenericGrid() { } +Uint32 cUIGenericGrid::Type() const { + return UI_TYPE_GENERICGRID; +} + +bool cUIGenericGrid::IsType( const Uint32& type ) const { + return cUIGenericGrid::Type() == type ? true : cUIControlAnim::IsType( type ); +} + void cUIGenericGrid::SetDefaultCollumnsWidth() { if ( mCollWidthAssigned ) return; diff --git a/src/ui/cuigenericgrid.hpp b/src/ui/cuigenericgrid.hpp index 0e61298a1..28be03abc 100644 --- a/src/ui/cuigenericgrid.hpp +++ b/src/ui/cuigenericgrid.hpp @@ -38,6 +38,10 @@ class EE_API cUIGenericGrid : public cUIControlAnim { ~cUIGenericGrid(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); void Add( cUIGridCell * Cell ); diff --git a/src/ui/cuigfx.cpp b/src/ui/cuigfx.cpp index 84f6a377a..28581d3f3 100644 --- a/src/ui/cuigfx.cpp +++ b/src/ui/cuigfx.cpp @@ -9,8 +9,6 @@ cUIGfx::cUIGfx( const cUIGfx::CreateParams& Params ) : mRender( Params.ShapeRender ), mAlignOffset(0,0) { - mType = UI_TYPE_GFX; - if ( NULL != mShape && ( ( Flags() & UI_AUTO_SIZE ) || ( Params.Size.x == -1 && Params.Size.y == -1 ) ) ) Size( mShape->Size() ); @@ -22,6 +20,14 @@ cUIGfx::cUIGfx( const cUIGfx::CreateParams& Params ) : cUIGfx::~cUIGfx() { } +Uint32 cUIGfx::Type() const { + return UI_TYPE_GFX; +} + +bool cUIGfx::IsType( const Uint32& type ) const { + return cUIGfx::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUIGfx::Shape( cShape * shape ) { mShape = shape; diff --git a/src/ui/cuigfx.hpp b/src/ui/cuigfx.hpp index fa37a22ba..e1ede4196 100644 --- a/src/ui/cuigfx.hpp +++ b/src/ui/cuigfx.hpp @@ -28,6 +28,10 @@ class EE_API cUIGfx : public cUIComplexControl { ~cUIGfx(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void Draw(); virtual void Alpha( const eeFloat& alpha ); diff --git a/src/ui/cuilistbox.cpp b/src/ui/cuilistbox.cpp index 0ea205f47..7218b7c02 100644 --- a/src/ui/cuilistbox.cpp +++ b/src/ui/cuilistbox.cpp @@ -27,8 +27,6 @@ cUIListBox::cUIListBox( cUIListBox::CreateParams& Params ) : mVisibleFirst(0), mVisibleLast(0) { - mType = UI_TYPE_LISTBOX; - if ( NULL == Params.Font && NULL != cUIThemeManager::instance()->DefaultFont() ) mFont = cUIThemeManager::instance()->DefaultFont(); @@ -78,6 +76,14 @@ cUIListBox::cUIListBox( cUIListBox::CreateParams& Params ) : cUIListBox::~cUIListBox() { } +Uint32 cUIListBox::Type() const { + return UI_TYPE_LISTBOX; +} + +bool cUIListBox::IsType( const Uint32& type ) const { + return cUIListBox::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUIListBox::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "listbox" ); diff --git a/src/ui/cuilistbox.hpp b/src/ui/cuilistbox.hpp index 9b1c9f9c2..57b37f13b 100644 --- a/src/ui/cuilistbox.hpp +++ b/src/ui/cuilistbox.hpp @@ -54,6 +54,10 @@ class EE_API cUIListBox : public cUIComplexControl { virtual ~cUIListBox(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + void Clear(); void AddListBoxItems( std::vector Texts ); diff --git a/src/ui/cuilistboxitem.cpp b/src/ui/cuilistboxitem.cpp index fb74320d2..458625501 100644 --- a/src/ui/cuilistboxitem.cpp +++ b/src/ui/cuilistboxitem.cpp @@ -7,8 +7,6 @@ namespace EE { namespace UI { cUIListBoxItem::cUIListBoxItem( const cUITextBox::CreateParams& Params ) : cUITextBox( Params ) { - mType = UI_TYPE_LISTBOXITEM; - ApplyDefaultTheme(); } @@ -20,6 +18,14 @@ cUIListBoxItem::~cUIListBoxItem() { cUIManager::instance()->OverControl( mParentCtrl ); } +Uint32 cUIListBoxItem::Type() const { + return UI_TYPE_LISTBOXITEM; +} + +bool cUIListBoxItem::IsType( const Uint32& type ) const { + return cUIListBoxItem::Type() == type ? true : cUITextBox::IsType( type ); +} + void cUIListBoxItem::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "listboxitem" ); } diff --git a/src/ui/cuilistboxitem.hpp b/src/ui/cuilistboxitem.hpp index 00f0fe4eb..59b2b5b02 100644 --- a/src/ui/cuilistboxitem.hpp +++ b/src/ui/cuilistboxitem.hpp @@ -14,6 +14,10 @@ class EE_API cUIListBoxItem : public cUITextBox { virtual ~cUIListBoxItem(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); virtual void Update(); diff --git a/src/ui/cuimenu.cpp b/src/ui/cuimenu.cpp index 93fd93569..0a763d24e 100644 --- a/src/ui/cuimenu.cpp +++ b/src/ui/cuimenu.cpp @@ -23,8 +23,6 @@ cUIMenu::cUIMenu( cUIMenu::CreateParams& Params ) : mClickHide( false ), mLastTickMove( 0 ) { - mType = UI_TYPE_MENU; - OnSizeChange(); ApplyDefaultTheme(); @@ -33,6 +31,14 @@ cUIMenu::cUIMenu( cUIMenu::CreateParams& Params ) : cUIMenu::~cUIMenu() { } +Uint32 cUIMenu::Type() const { + return UI_TYPE_MENU; +} + +bool cUIMenu::IsType( const Uint32& type ) const { + return cUIMenu::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUIMenu::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "menu" ); DoAfterSetTheme(); @@ -145,7 +151,7 @@ Uint32 cUIMenu::AddSubMenu( const String& Text, cShape * Icon, cUIMenu * SubMenu } bool cUIMenu::CheckControlSize( cUIControl * Control, const bool& Resize ) { - if ( Control->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) { + if ( Control->IsType( UI_TYPE_MENUITEM ) ) { cUIMenuItem * tItem = reinterpret_cast ( Control ); if ( NULL != tItem->Icon() && tItem->IconHorizontalMargin() + tItem->Icon()->Size().Width() > (Int32)mBiggestIcon ) { @@ -153,7 +159,7 @@ bool cUIMenu::CheckControlSize( cUIControl * Control, const bool& Resize ) { } if ( mFlags & UI_AUTO_SIZE ) { - if ( Control->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) ) { + if ( Control->IsType( UI_TYPE_MENUSUBMENU ) ) { cUIMenuSubMenu * tMenu = reinterpret_cast ( tItem ); if ( tMenu->TextBox()->GetTextWidth() + mBiggestIcon + tMenu->Arrow()->Size().Width() + mMinRightMargin > (Int32)mMaxWidth - mPadding.Left - mPadding.Right ) { @@ -203,7 +209,7 @@ Uint32 cUIMenu::Add( cUIControl * Control ) { } void cUIMenu::SetControlSize( cUIControl * Control, const Uint32& Pos ) { - if ( Control->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) { + if ( Control->IsType( UI_TYPE_MENUITEM ) ) { Control->Size( mSize.Width() - mPadding.Left - mPadding.Right, mRowHeight ); } else { Control->Size( mSize.Width() - mPadding.Left - mPadding.Right, Control->Size().Height() ); @@ -237,7 +243,7 @@ cUIControl * cUIMenu::GetItem( const Uint32& Index ) { cUIControl * cUIMenu::GetItem( const String& Text ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { - if ( mItems[i]->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) { + if ( mItems[i]->IsType( UI_TYPE_MENUITEM ) ) { cUIMenuItem * tMenuItem = reinterpret_cast( mItems[i] ); if ( tMenuItem->Text() == Text ) @@ -308,7 +314,7 @@ void cUIMenu::Insert( cUIControl * Control, const Uint32& Index ) { bool cUIMenu::IsSubMenu( cUIControl * Ctrl ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { - if ( mItems[i]->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) ) { + if ( mItems[i]->IsType( UI_TYPE_MENUSUBMENU ) ) { cUIMenuSubMenu * tMenu = reinterpret_cast ( mItems[i] ); if ( tMenu->SubMenu() == Ctrl ) @@ -420,7 +426,7 @@ bool cUIMenu::Hide() { void cUIMenu::SetItemSelected( cUIControl * Item ) { if ( NULL != mItemSelected ) { - if ( mItemSelected->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) ) { + if ( mItemSelected->IsType( UI_TYPE_MENUSUBMENU ) ) { cUIMenuSubMenu * tMenu = reinterpret_cast ( mItemSelected ); if ( NULL != tMenu->SubMenu() ) @@ -441,7 +447,7 @@ void cUIMenu::SetItemSelected( cUIControl * Item ) { void cUIMenu::TrySelect( cUIControl * Ctrl, bool Up ) { if ( mItems.size() ) { - if ( !Ctrl->IsTypeOrInheritsFrom( UI_TYPE_SEPARATOR ) ) { + if ( !Ctrl->IsType( UI_TYPE_SEPARATOR ) ) { SetItemSelected( Ctrl ); } else { Uint32 Index = GetItemIndex( Ctrl ); @@ -450,7 +456,7 @@ void cUIMenu::TrySelect( cUIControl * Ctrl, bool Up ) { if ( Up ) { if ( Index > 0 ) { for ( Int32 i = (Int32)Index - 1; i >= 0; i-- ) { - if ( !mItems[i]->IsTypeOrInheritsFrom( UI_TYPE_SEPARATOR ) ) { + if ( !mItems[i]->IsType( UI_TYPE_SEPARATOR ) ) { SetItemSelected( mItems[i] ); return; } @@ -460,7 +466,7 @@ void cUIMenu::TrySelect( cUIControl * Ctrl, bool Up ) { SetItemSelected( mItems[ mItems.size() ] ); } else { for ( Uint32 i = Index + 1; i < mItems.size(); i++ ) { - if ( !mItems[i]->IsTypeOrInheritsFrom( UI_TYPE_SEPARATOR ) ) { + if ( !mItems[i]->IsType( UI_TYPE_SEPARATOR ) ) { SetItemSelected( mItems[i] ); return; } @@ -515,7 +521,7 @@ Uint32 cUIMenu::OnKeyDown( const cUIEventKey& Event ) { break; case KEY_RIGHT: - if ( NULL != mItemSelected && ( mItemSelected->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) ) ) { + if ( NULL != mItemSelected && ( mItemSelected->IsType( UI_TYPE_MENUSUBMENU ) ) ) { cUIMenuSubMenu * tMenu = reinterpret_cast ( mItemSelected ); tMenu->ShowSubMenu(); diff --git a/src/ui/cuimenu.hpp b/src/ui/cuimenu.hpp index 5adb4973b..85e6b7793 100644 --- a/src/ui/cuimenu.hpp +++ b/src/ui/cuimenu.hpp @@ -60,6 +60,10 @@ class EE_API cUIMenu : public cUIComplexControl { ~cUIMenu(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + Uint32 Add( const String& Text, cShape * Icon = NULL ); Uint32 Add( cUIControl * Control ); diff --git a/src/ui/cuimenucheckbox.cpp b/src/ui/cuimenucheckbox.cpp index 05bcc0b5e..c564036f3 100644 --- a/src/ui/cuimenucheckbox.cpp +++ b/src/ui/cuimenucheckbox.cpp @@ -9,14 +9,20 @@ cUIMenuCheckBox::cUIMenuCheckBox( cUIMenuCheckBox::CreateParams& Params ) : mSkinActive( NULL ), mSkinInactive( NULL ) { - mType = UI_TYPE_MENUCHECKBOX; - ApplyDefaultTheme(); } cUIMenuCheckBox::~cUIMenuCheckBox() { } +Uint32 cUIMenuCheckBox::Type() const { + return UI_TYPE_MENUCHECKBOX; +} + +bool cUIMenuCheckBox::IsType( const Uint32& type ) const { + return cUIMenuCheckBox::Type() == type ? true : cUIMenuItem::IsType( type ); +} + void cUIMenuCheckBox::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "menuitem" ); diff --git a/src/ui/cuimenucheckbox.hpp b/src/ui/cuimenucheckbox.hpp index 387ebd033..0bd9dfdaf 100644 --- a/src/ui/cuimenucheckbox.hpp +++ b/src/ui/cuimenucheckbox.hpp @@ -11,6 +11,10 @@ class cUIMenuCheckBox : public cUIMenuItem { ~cUIMenuCheckBox(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); const bool& Active() const; diff --git a/src/ui/cuimenuitem.cpp b/src/ui/cuimenuitem.cpp index 3bb821120..653647d0a 100644 --- a/src/ui/cuimenuitem.cpp +++ b/src/ui/cuimenuitem.cpp @@ -6,14 +6,20 @@ namespace EE { namespace UI { cUIMenuItem::cUIMenuItem( cUIPushButton::CreateParams& Params ) : cUIPushButton( Params ) { - mType = UI_TYPE_MENUITEM; - ApplyDefaultTheme(); } cUIMenuItem::~cUIMenuItem() { } +Uint32 cUIMenuItem::Type() const { + return UI_TYPE_MENUITEM; +} + +bool cUIMenuItem::IsType( const Uint32& type ) const { + return cUIMenuItem::Type() == type ? true : cUIPushButton::IsType( type ); +} + void cUIMenuItem::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "menuitem" ); DoAfterSetTheme(); diff --git a/src/ui/cuimenuitem.hpp b/src/ui/cuimenuitem.hpp index ff894c007..9490d6428 100644 --- a/src/ui/cuimenuitem.hpp +++ b/src/ui/cuimenuitem.hpp @@ -11,6 +11,10 @@ class EE_API cUIMenuItem : public cUIPushButton { ~cUIMenuItem(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); protected: virtual Uint32 OnMouseEnter( const eeVector2i &Pos, Uint32 Flags ); diff --git a/src/ui/cuimenusubmenu.cpp b/src/ui/cuimenusubmenu.cpp index b04221186..eefca1110 100644 --- a/src/ui/cuimenusubmenu.cpp +++ b/src/ui/cuimenusubmenu.cpp @@ -14,8 +14,6 @@ cUIMenuSubMenu::cUIMenuSubMenu( cUIMenuSubMenu::CreateParams& Params ) : mCbId( 0 ), mCbId2( 0 ) { - mType = UI_TYPE_MENUSUBMENU; - cUIGfx::CreateParams GfxParams; GfxParams.Parent( this ); GfxParams.Shape = NULL; @@ -32,6 +30,14 @@ cUIMenuSubMenu::cUIMenuSubMenu( cUIMenuSubMenu::CreateParams& Params ) : cUIMenuSubMenu::~cUIMenuSubMenu() { } +Uint32 cUIMenuSubMenu::Type() const { + return UI_TYPE_MENUSUBMENU; +} + +bool cUIMenuSubMenu::IsType( const Uint32& type ) const { + return cUIMenuSubMenu::Type() == type ? true : cUIMenuItem::IsType( type ); +} + void cUIMenuSubMenu::SetTheme( cUITheme * Theme ) { cUIMenuItem::SetTheme( Theme ); diff --git a/src/ui/cuimenusubmenu.hpp b/src/ui/cuimenusubmenu.hpp index 3e89c5144..dfe1d208f 100644 --- a/src/ui/cuimenusubmenu.hpp +++ b/src/ui/cuimenusubmenu.hpp @@ -28,6 +28,10 @@ class cUIMenuSubMenu : public cUIMenuItem { ~cUIMenuSubMenu(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); void SubMenu( cUIMenu * SubMenu ); diff --git a/src/ui/cuipopupmenu.cpp b/src/ui/cuipopupmenu.cpp index c0acedb4c..0e9f353ee 100644 --- a/src/ui/cuipopupmenu.cpp +++ b/src/ui/cuipopupmenu.cpp @@ -6,14 +6,20 @@ namespace EE { namespace UI { cUIPopUpMenu::cUIPopUpMenu( cUIPopUpMenu::CreateParams Params ) : cUIMenu( Params ) { - mType = UI_TYPE_POPUPMENU; - ApplyDefaultTheme(); } cUIPopUpMenu::~cUIPopUpMenu() { } +Uint32 cUIPopUpMenu::Type() const { + return UI_TYPE_POPUPMENU; +} + +bool cUIPopUpMenu::IsType( const Uint32& type ) const { + return cUIPopUpMenu::Type() == type ? true : cUIMenu::IsType( type ); +} + void cUIPopUpMenu::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "popupmenu" ); DoAfterSetTheme(); @@ -74,7 +80,7 @@ Uint32 cUIPopUpMenu::OnMessage( const cUIMessage * Msg ) { switch ( Msg->Msg() ) { case cUIMessage::MsgMouseUp: { - if ( !Msg->Sender()->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) && ( Msg->Flags() & EE_BUTTONS_LRM ) ) { + if ( !Msg->Sender()->IsType( UI_TYPE_MENUSUBMENU ) && ( Msg->Flags() & EE_BUTTONS_LRM ) ) { SendCommonEvent( cUIEvent::EventOnHideByClick ); cUIManager::instance()->MainControl()->SetFocus(); diff --git a/src/ui/cuipopupmenu.hpp b/src/ui/cuipopupmenu.hpp index 932856e42..775686986 100644 --- a/src/ui/cuipopupmenu.hpp +++ b/src/ui/cuipopupmenu.hpp @@ -11,6 +11,10 @@ class cUIPopUpMenu : public cUIMenu { ~cUIPopUpMenu(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); virtual bool Show(); diff --git a/src/ui/cuiprogressbar.cpp b/src/ui/cuiprogressbar.cpp index 9dd9b6aa4..434d2c517 100644 --- a/src/ui/cuiprogressbar.cpp +++ b/src/ui/cuiprogressbar.cpp @@ -12,8 +12,6 @@ cUIProgressBar::cUIProgressBar( const cUIProgressBar::CreateParams& Params ) : mTotalSteps( 100.f ), mParallax( NULL ) { - mType = UI_TYPE_PROGRESSBAR; - cUITextBox::CreateParams TxtBoxParams = Params; TxtBoxParams.Parent( this ); @@ -32,6 +30,14 @@ cUIProgressBar::~cUIProgressBar() { eeSAFE_DELETE( mParallax ); } +Uint32 cUIProgressBar::Type() const { + return UI_TYPE_PROGRESSBAR; +} + +bool cUIProgressBar::IsType( const Uint32& type ) const { + return cUIProgressBar::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUIProgressBar::Draw() { cUIControlAnim::Draw(); diff --git a/src/ui/cuiprogressbar.hpp b/src/ui/cuiprogressbar.hpp index 256739370..23d1dc99f 100644 --- a/src/ui/cuiprogressbar.hpp +++ b/src/ui/cuiprogressbar.hpp @@ -31,6 +31,10 @@ class cUIProgressBar : public cUIComplexControl { ~cUIProgressBar(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); virtual void Progress( eeFloat Val ); diff --git a/src/ui/cuipushbutton.cpp b/src/ui/cuipushbutton.cpp index 12e1ea5f7..b60b7cf96 100644 --- a/src/ui/cuipushbutton.cpp +++ b/src/ui/cuipushbutton.cpp @@ -10,8 +10,6 @@ cUIPushButton::cUIPushButton( const cUIPushButton::CreateParams& Params ) : mTextBox( NULL ), mIconSpace( Params.IconHorizontalMargin ) { - mType = UI_TYPE_PUSHBUTTON; - cUIGfx::CreateParams GfxParams; GfxParams.Parent( this ); GfxParams.Shape = Params.Icon; @@ -55,6 +53,17 @@ cUIPushButton::cUIPushButton( const cUIPushButton::CreateParams& Params ) : ApplyDefaultTheme(); } +cUIPushButton::~cUIPushButton() { +} + +Uint32 cUIPushButton::Type() const { + return UI_TYPE_PUSHBUTTON; +} + +bool cUIPushButton::IsType( const Uint32& type ) const { + return cUIPushButton::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUIPushButton::OnSizeChange() { if ( NULL != mTextBox ) { mTextBox->Size( mSize.Width(), mSize.Height() ); @@ -112,9 +121,6 @@ void cUIPushButton::OnSizeChange() { */ } -cUIPushButton::~cUIPushButton() { -} - void cUIPushButton::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "button" ); diff --git a/src/ui/cuipushbutton.hpp b/src/ui/cuipushbutton.hpp index 52482bc08..0085bbfd0 100644 --- a/src/ui/cuipushbutton.hpp +++ b/src/ui/cuipushbutton.hpp @@ -58,6 +58,10 @@ class EE_API cUIPushButton : public cUIComplexControl { ~cUIPushButton(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); virtual void Icon( cShape * Icon ); diff --git a/src/ui/cuiradiobutton.cpp b/src/ui/cuiradiobutton.cpp index 2d05b631b..eed56b5ff 100644 --- a/src/ui/cuiradiobutton.cpp +++ b/src/ui/cuiradiobutton.cpp @@ -9,8 +9,6 @@ cUIRadioButton::cUIRadioButton( const cUITextBox::CreateParams& Params ) : mInactiveButton(NULL), mActive( false ) { - mType = UI_TYPE_RADIOBUTTON; - cUIControlAnim::CreateParams ButtonParams( Params ); ButtonParams.Parent( this ); @@ -35,6 +33,14 @@ cUIRadioButton::cUIRadioButton( const cUITextBox::CreateParams& Params ) : cUIRadioButton::~cUIRadioButton() { } +Uint32 cUIRadioButton::Type() const { + return UI_TYPE_RADIOBUTTON; +} + +bool cUIRadioButton::IsType( const Uint32& type ) const { + return cUIRadioButton::Type() == type ? true : cUITextBox::IsType( type ); +} + void cUIRadioButton::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "radiobutton" ); @@ -130,7 +136,7 @@ void cUIRadioButton::Active( const bool& active ) { cUIControl * tChild = mParentCtrl->ChildGetFirst(); while ( NULL != tChild ) { - if ( tChild->IsType( UI_TYPE_RADIOBUTTON ) || tChild->InheritsFrom( UI_TYPE_RADIOBUTTON ) ) { + if ( tChild->IsType( UI_TYPE_RADIOBUTTON ) ) { if ( tChild != this ) { cUIRadioButton * tRB = reinterpret_cast ( tChild ); @@ -149,7 +155,7 @@ bool cUIRadioButton::CheckActives() { cUIControl * tChild = mParentCtrl->ChildGetFirst(); while ( NULL != tChild ) { - if ( tChild->IsTypeOrInheritsFrom( UI_TYPE_RADIOBUTTON ) ) { + if ( tChild->IsType( UI_TYPE_RADIOBUTTON ) ) { if ( tChild != this ) { cUIRadioButton * tRB = reinterpret_cast ( tChild ); @@ -172,7 +178,7 @@ void cUIRadioButton::AutoActivate() { cUIControl * tChild = mParentCtrl->ChildGetFirst(); while ( NULL != tChild ) { - if ( tChild->IsTypeOrInheritsFrom( UI_TYPE_RADIOBUTTON ) ) { + if ( tChild->IsType( UI_TYPE_RADIOBUTTON ) ) { if ( tChild != this ) { cUIRadioButton * tRB = reinterpret_cast ( tChild ); diff --git a/src/ui/cuiradiobutton.hpp b/src/ui/cuiradiobutton.hpp index 9127096d4..ac3bdbcab 100644 --- a/src/ui/cuiradiobutton.hpp +++ b/src/ui/cuiradiobutton.hpp @@ -12,6 +12,10 @@ class EE_API cUIRadioButton : public cUITextBox { ~cUIRadioButton(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); const bool& IsActive() const; diff --git a/src/ui/cuiscrollbar.cpp b/src/ui/cuiscrollbar.cpp index d0d7269e7..e242cdeb1 100644 --- a/src/ui/cuiscrollbar.cpp +++ b/src/ui/cuiscrollbar.cpp @@ -6,8 +6,6 @@ namespace EE { namespace UI { cUIScrollBar::cUIScrollBar( const cUIScrollBar::CreateParams& Params ) : cUIComplexControl( Params ) { - mType = UI_TYPE_SCROLLBAR; - cUIControlAnim::CreateParams CParams = Params; CParams.Size = eeSize( 16, 16 ); CParams.Parent( this ); @@ -46,6 +44,14 @@ cUIScrollBar::cUIScrollBar( const cUIScrollBar::CreateParams& Params ) : cUIScrollBar::~cUIScrollBar() { } +Uint32 cUIScrollBar::Type() const { + return UI_TYPE_SCROLLBAR; +} + +bool cUIScrollBar::IsType( const Uint32& type ) const { + return cUIScrollBar::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUIScrollBar::SetTheme( cUITheme * Theme ) { if ( !IsVertical() ) { cUIControl::SetTheme( Theme, "hscrollbar" ); diff --git a/src/ui/cuiscrollbar.hpp b/src/ui/cuiscrollbar.hpp index 537ca1294..71ca810da 100644 --- a/src/ui/cuiscrollbar.hpp +++ b/src/ui/cuiscrollbar.hpp @@ -25,6 +25,10 @@ class cUIScrollBar : public cUIComplexControl { ~cUIScrollBar(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void Value( eeFloat Val ); const eeFloat& Value() const; diff --git a/src/ui/cuiselectbutton.cpp b/src/ui/cuiselectbutton.cpp index 7dd31654c..2ae8864c8 100644 --- a/src/ui/cuiselectbutton.cpp +++ b/src/ui/cuiselectbutton.cpp @@ -6,12 +6,19 @@ namespace EE { namespace UI { cUISelectButton::cUISelectButton( const cUIPushButton::CreateParams& Params ) : cUIPushButton( Params ) { - mType = UI_TYPE_SELECTBUTTON; } cUISelectButton::~cUISelectButton() { } +Uint32 cUISelectButton::Type() const { + return UI_TYPE_SELECTBUTTON; +} + +bool cUISelectButton::IsType( const Uint32& type ) const { + return cUISelectButton::Type() == type ? true : cUIPushButton::IsType( type ); +} + void cUISelectButton::Select() { bool wasSelected = Selected(); diff --git a/src/ui/cuiselectbutton.hpp b/src/ui/cuiselectbutton.hpp index b0873b694..8a5f018aa 100644 --- a/src/ui/cuiselectbutton.hpp +++ b/src/ui/cuiselectbutton.hpp @@ -11,6 +11,10 @@ class cUISelectButton : public cUIPushButton { virtual ~cUISelectButton(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual bool Selected() const; virtual void Unselect(); diff --git a/src/ui/cuiseparator.cpp b/src/ui/cuiseparator.cpp index 8f26864a4..6fa7f664a 100644 --- a/src/ui/cuiseparator.cpp +++ b/src/ui/cuiseparator.cpp @@ -5,14 +5,20 @@ namespace EE { namespace UI { cUISeparator::cUISeparator( cUIControlAnim::CreateParams Params ) : cUIControlAnim( Params ) { - mType = UI_TYPE_SEPARATOR; - ApplyDefaultTheme(); } cUISeparator::~cUISeparator() { } - + +Uint32 cUISeparator::Type() const { + return UI_TYPE_SEPARATOR; +} + +bool cUISeparator::IsType( const Uint32& type ) const { + return cUISeparator::Type() == type ? true : cUIControlAnim::IsType( type ); +} + void cUISeparator::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "separator" ); diff --git a/src/ui/cuiseparator.hpp b/src/ui/cuiseparator.hpp index a189601e7..f0447dc5c 100644 --- a/src/ui/cuiseparator.hpp +++ b/src/ui/cuiseparator.hpp @@ -10,7 +10,11 @@ class cUISeparator : public cUIControlAnim { cUISeparator( cUIControlAnim::CreateParams Params ); ~cUISeparator(); - + + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); protected: }; diff --git a/src/ui/cuislider.cpp b/src/ui/cuislider.cpp index 4e51f0197..4e77f1117 100644 --- a/src/ui/cuislider.cpp +++ b/src/ui/cuislider.cpp @@ -16,8 +16,6 @@ cUISlider::cUISlider( const cUISlider::CreateParams& Params ) : mClickStep( 0.1f ), mOnPosChange( false ) { - mType = UI_TYPE_SLIDER; - cUIControl::CreateParams BgParams; BgParams.Parent( this ); @@ -52,6 +50,14 @@ cUISlider::cUISlider( const cUISlider::CreateParams& Params ) : cUISlider::~cUISlider() { } +Uint32 cUISlider::Type() const { + return UI_TYPE_SLIDER; +} + +bool cUISlider::IsType( const Uint32& type ) const { + return cUISlider::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUISlider::SetTheme( cUITheme * Theme ) { if ( !mVertical ) { cUIControl::SetTheme( Theme, "hslider" ); diff --git a/src/ui/cuislider.hpp b/src/ui/cuislider.hpp index 218a672cf..a79217508 100644 --- a/src/ui/cuislider.hpp +++ b/src/ui/cuislider.hpp @@ -29,6 +29,10 @@ class EE_API cUISlider : public cUIComplexControl { ~cUISlider(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); virtual void Value( eeFloat Val ); diff --git a/src/ui/cuispinbox.cpp b/src/ui/cuispinbox.cpp index 8956fa1f6..e89f8f153 100644 --- a/src/ui/cuispinbox.cpp +++ b/src/ui/cuispinbox.cpp @@ -9,8 +9,6 @@ cUISpinBox::cUISpinBox( const cUISpinBox::CreateParams& Params ) : mValue( Params.DefaultValue ), mClickStep( 1.f ) { - mType = UI_TYPE_SPINBOX; - cUITextInput::CreateParams InputParams( Params ); InputParams.PosSet( 0, 0 ); InputParams.Parent( this ); @@ -49,7 +47,14 @@ cUISpinBox::cUISpinBox( const cUISpinBox::CreateParams& Params ) : } cUISpinBox::~cUISpinBox() { +} +Uint32 cUISpinBox::Type() const { + return UI_TYPE_SPINBOX; +} + +bool cUISpinBox::IsType( const Uint32& type ) const { + return cUISpinBox::Type() == type ? true : cUIComplexControl::IsType( type ); } void cUISpinBox::SetTheme( cUITheme * Theme ) { diff --git a/src/ui/cuispinbox.hpp b/src/ui/cuispinbox.hpp index d2043082c..8cf1c406d 100644 --- a/src/ui/cuispinbox.hpp +++ b/src/ui/cuispinbox.hpp @@ -28,6 +28,10 @@ class EE_API cUISpinBox : public cUIComplexControl { ~cUISpinBox(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); virtual void Padding( const eeRecti& padding ); diff --git a/src/ui/cuisprite.cpp b/src/ui/cuisprite.cpp index b1db4ea28..fed69dc1a 100644 --- a/src/ui/cuisprite.cpp +++ b/src/ui/cuisprite.cpp @@ -9,8 +9,6 @@ cUISprite::cUISprite( const cUISprite::CreateParams& Params ) : mAlignOffset(0,0), mShapeLast(NULL) { - mType = UI_TYPE_SPRITE; - if ( Params.DeallocSprite ) mControlFlags |= UI_CTRL_FLAG_FREE_USE; @@ -26,6 +24,14 @@ cUISprite::~cUISprite() { eeSAFE_DELETE( mSprite ); } +Uint32 cUISprite::Type() const { + return UI_TYPE_SPRITE; +} + +bool cUISprite::IsType( const Uint32& type ) const { + return cUISprite::Type() == type ? true : cUIComplexControl::IsType( type ); +} + Uint32 cUISprite::DeallocSprite() { return mControlFlags & UI_CTRL_FLAG_FREE_USE; } diff --git a/src/ui/cuisprite.hpp b/src/ui/cuisprite.hpp index 20a6f43af..287837f77 100644 --- a/src/ui/cuisprite.hpp +++ b/src/ui/cuisprite.hpp @@ -28,6 +28,10 @@ class EE_API cUISprite : public cUIComplexControl { ~cUISprite(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void Draw(); virtual void Alpha( const eeFloat& alpha ); diff --git a/src/ui/cuitextbox.cpp b/src/ui/cuitextbox.cpp index 652986883..aec845af7 100644 --- a/src/ui/cuitextbox.cpp +++ b/src/ui/cuitextbox.cpp @@ -10,8 +10,6 @@ cUITextBox::cUITextBox( const cUITextBox::CreateParams& Params ) : mFontShadowColor( Params.FontShadowColor ), mAlignOffset( 0.f, 0.f ) { - mType = UI_TYPE_TEXTBOX; - mTextCache = eeNew( cTextCache, () ); mTextCache->Font( Params.Font ); mTextCache->Color( mFontColor ); @@ -31,6 +29,14 @@ cUITextBox::~cUITextBox() { eeSAFE_DELETE( mTextCache ); } +Uint32 cUITextBox::Type() const { + return UI_TYPE_TEXTBOX; +} + +bool cUITextBox::IsType( const Uint32& type ) const { + return cUITextBox::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUITextBox::Draw() { if ( mVisible && 0.f != mAlpha ) { cUIControlAnim::Draw(); diff --git a/src/ui/cuitextbox.hpp b/src/ui/cuitextbox.hpp index c01aab2d5..eb0ce6d90 100644 --- a/src/ui/cuitextbox.hpp +++ b/src/ui/cuitextbox.hpp @@ -38,6 +38,10 @@ class EE_API cUITextBox : public cUIComplexControl { ~cUITextBox(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void Draw(); virtual void Alpha( const eeFloat& alpha ); diff --git a/src/ui/cuitextedit.cpp b/src/ui/cuitextedit.cpp index 4ae7220be..56c10d7eb 100644 --- a/src/ui/cuitextedit.cpp +++ b/src/ui/cuitextedit.cpp @@ -12,8 +12,6 @@ cUITextEdit::cUITextEdit( cUITextEdit::CreateParams& Params ) : mVScrollBarMode( Params.VScrollBar ), mSkipValueChange( false ) { - mType = UI_TYPE_TEXTEDIT; - Uint32 extraFlags = 0; if ( mFlags & UI_ANCHOR_LEFT ) @@ -78,6 +76,14 @@ cUITextEdit::cUITextEdit( cUITextEdit::CreateParams& Params ) : cUITextEdit::~cUITextEdit() { } +Uint32 cUITextEdit::Type() const { + return UI_TYPE_TEXTEDIT; +} + +bool cUITextEdit::IsType( const Uint32& type ) const { + return cUITextEdit::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUITextEdit::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "textedit" ); diff --git a/src/ui/cuitextedit.hpp b/src/ui/cuitextedit.hpp index 1708c0852..d29a0d0d6 100644 --- a/src/ui/cuitextedit.hpp +++ b/src/ui/cuitextedit.hpp @@ -29,6 +29,10 @@ class EE_API cUITextEdit : public cUIComplexControl { ~cUITextEdit(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); const String& Text() const; diff --git a/src/ui/cuitextinput.cpp b/src/ui/cuitextinput.cpp index d101e1569..02cb19040 100644 --- a/src/ui/cuitextinput.cpp +++ b/src/ui/cuitextinput.cpp @@ -10,8 +10,6 @@ cUITextInput::cUITextInput( const cUITextInput::CreateParams& Params ) : mAllowEditing( true ), mShowingWait( true ) { - mType = UI_TYPE_TEXTINPUT; - mTextBuffer.Start(); mTextBuffer.Active( false ); mTextBuffer.SupportFreeEditing( Params.SupportFreeEditing ); @@ -24,6 +22,14 @@ cUITextInput::cUITextInput( const cUITextInput::CreateParams& Params ) : cUITextInput::~cUITextInput() { } +Uint32 cUITextInput::Type() const { + return UI_TYPE_TEXTINPUT; +} + +bool cUITextInput::IsType( const Uint32& type ) const { + return cUITextInput::Type() == type ? true : cUITextBox::IsType( type ); +} + void cUITextInput::Update() { cUITextBox::Update(); diff --git a/src/ui/cuitextinput.hpp b/src/ui/cuitextinput.hpp index fe8e760e4..ee0115cea 100644 --- a/src/ui/cuitextinput.hpp +++ b/src/ui/cuitextinput.hpp @@ -28,6 +28,10 @@ class EE_API cUITextInput : public cUITextBox { ~cUITextInput(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void Update(); virtual void Draw(); diff --git a/src/ui/cuitooltip.cpp b/src/ui/cuitooltip.cpp index 6033e4427..72dd93e1e 100644 --- a/src/ui/cuitooltip.cpp +++ b/src/ui/cuitooltip.cpp @@ -12,8 +12,6 @@ cUITooltip::cUITooltip( cUITooltip::CreateParams& Params, cUIControl * TooltipOf mTooltipTime( 0.f ), mTooltipOf( TooltipOf ) { - mType = UI_TYPE_TOOLTIP; - mTextCache = eeNew( cTextCache, () ); mTextCache->Font( Params.Font ); mTextCache->Color( mFontColor ); @@ -42,6 +40,14 @@ cUITooltip::~cUITooltip() { } } +Uint32 cUITooltip::Type() const { + return UI_TYPE_TOOLTIP; +} + +bool cUITooltip::IsType( const Uint32& type ) const { + return cUITooltip::Type() == type ? true : cUIControlAnim::IsType( type ); +} + void cUITooltip::SetTheme( cUITheme * Theme ) { cUIControl::SetTheme( Theme, "tooltip" ); diff --git a/src/ui/cuitooltip.hpp b/src/ui/cuitooltip.hpp index f2399210e..1865795cf 100644 --- a/src/ui/cuitooltip.hpp +++ b/src/ui/cuitooltip.hpp @@ -38,6 +38,10 @@ class EE_API cUITooltip : public cUIControlAnim { ~cUITooltip(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void SetTheme( cUITheme * Theme ); void Show(); diff --git a/src/ui/cuiwindow.cpp b/src/ui/cuiwindow.cpp index 59c1ccfb3..f5c5e4210 100644 --- a/src/ui/cuiwindow.cpp +++ b/src/ui/cuiwindow.cpp @@ -24,8 +24,6 @@ cUIWindow::cUIWindow( const cUIWindow::CreateParams& Params ) : mDecoAutoSize( Params.DecorationAutoSize ), mBorderAutoSize( Params.BorderAutoSize ) { - mType = UI_TYPE_WINDOW; - cUIComplexControl::CreateParams tcParams; tcParams.Parent( this ); tcParams.Flags |= UI_REPORT_SIZE_CHANGE_TO_CHILDS; @@ -104,6 +102,14 @@ cUIWindow::~cUIWindow() { SendCommonEvent( cUIEvent::EventOnWindowClose ); } +Uint32 cUIWindow::Type() const { + return UI_TYPE_WINDOW; +} + +bool cUIWindow::IsType( const Uint32& type ) const { + return cUIWindow::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUIWindow::ContainerPosChange( const cUIEvent * Event ) { eeVector2i PosDiff = mContainer->Pos() - eeVector2i( mBorderLeft->Size().Width(), mWindowDecoration->Size().Height() ); diff --git a/src/ui/cuiwindow.hpp b/src/ui/cuiwindow.hpp index 526d68b47..fd3a59266 100644 --- a/src/ui/cuiwindow.hpp +++ b/src/ui/cuiwindow.hpp @@ -42,6 +42,10 @@ class cUIWindow : public cUIComplexControl { ~cUIWindow(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + virtual void Size( const eeSize& Size ); void Size( const Int32& Width, const Int32& Height ); diff --git a/src/ui/cuiwinmenu.cpp b/src/ui/cuiwinmenu.cpp index 4437d0368..7a0abbf1e 100644 --- a/src/ui/cuiwinmenu.cpp +++ b/src/ui/cuiwinmenu.cpp @@ -16,8 +16,6 @@ cUIWinMenu::cUIWinMenu( const cUIWinMenu::CreateParams& Params ) : mFirstButtonMargin( Params.FirstButtonMargin ), mMenuHeight( Params.MenuHeight ) { - mType = UI_TYPE_WINMENU; - if ( !(mFlags & UI_ANCHOR_RIGHT) ) mFlags |= UI_ANCHOR_RIGHT; @@ -32,6 +30,14 @@ cUIWinMenu::~cUIWinMenu() { } +Uint32 cUIWinMenu::Type() const { + return UI_TYPE_WINMENU; +} + +bool cUIWinMenu::IsType( const Uint32& type ) const { + return cUIWinMenu::Type() == type ? true : cUIComplexControl::IsType( type ); +} + void cUIWinMenu::AddMenuButton( const String& ButtonText, cUIPopUpMenu * Menu ) { eeASSERT( NULL != Menu ); @@ -162,7 +168,7 @@ Uint32 cUIWinMenu::OnMessage( const cUIMessage * Msg ) { case cUIMessage::MsgMouseUp: case cUIMessage::MsgMouseEnter: { - if ( Msg->Sender()->IsTypeOrInheritsFrom( UI_TYPE_SELECTBUTTON ) ) { + if ( Msg->Sender()->IsType( UI_TYPE_SELECTBUTTON ) ) { cUISelectButton * tbut = reinterpret_cast ( Msg->Sender() ); cUIPopUpMenu * tpop = GetMenuFromButton( tbut ); diff --git a/src/ui/cuiwinmenu.hpp b/src/ui/cuiwinmenu.hpp index 2c9f2b219..4aa9515ff 100644 --- a/src/ui/cuiwinmenu.hpp +++ b/src/ui/cuiwinmenu.hpp @@ -53,6 +53,10 @@ class EE_API cUIWinMenu : public cUIComplexControl { virtual ~cUIWinMenu(); + virtual Uint32 Type() const; + + virtual bool IsType( const Uint32& type ) const; + void AddMenuButton( const String& ButtonText, cUIPopUpMenu * Menu ); void RemoveMenuButton( const String& ButtonText ); diff --git a/src/ui/tools/ctexturegroupeditor.cpp b/src/ui/tools/ctexturegroupeditor.cpp index e2ba2a86f..f0c8dae4c 100644 --- a/src/ui/tools/ctexturegroupeditor.cpp +++ b/src/ui/tools/ctexturegroupeditor.cpp @@ -226,7 +226,7 @@ void cTextureGroupEditor::CreateWinMenu() { } void cTextureGroupEditor::FileMenuClick( const cUIEvent * Event ) { - if ( !Event->Ctrl()->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) + if ( !Event->Ctrl()->IsType( UI_TYPE_MENUITEM ) ) return; const String& txt = reinterpret_cast ( Event->Ctrl() )->Text();