Mercurial > LightClone
view LightClone/Source/GuiElement.cpp @ 18:33cb6979ac51
More work on GUI system
author | koryspansel |
---|---|
date | Wed, 14 Sep 2011 17:24:49 -0700 |
parents | 4951acfe92fc |
children | 51718795f019 |
line wrap: on
line source
/* * GuiElement */ #include "GuiElement.h" /* * GuiElement */ GuiElement::GuiElement() { } /* * ~GuiElement */ GuiElement::~GuiElement() { } /* * Attach */ void GuiElement::Attach(GuiElement* pInstance) { pContainer = pInstance; } /* * Detach */ GuiElement* GuiElement::Detach() { GuiElement* pInstance = pContainer; pContainer = NULL; return pInstance; } /* * GetContainer */ GuiElement* GuiElement::GetContainer() { return pContainer; } /* * SetPosition */ void GuiElement::SetPosition(float fX, float fY) { kPosition.x = fX; kPosition.y = fY; } /* * SetPosition */ void GuiElement::SetPosition(const D3DXVECTOR2& kValue) { kPosition = kValue; } /* * GetPosition */ const D3DXVECTOR2 GuiElement::GetPosition() const { return pContainer ? pContainer->GetPosition() + kPosition : kPosition; } /* * SetDimensions */ void GuiElement::SetDimensions(float fWidth, float fHeight) { kDimensions.x = fWidth; kDimensions.y = fHeight; } /* * SetDimensions */ void GuiElement::SetDimensions(const D3DXVECTOR2& kValue) { kDimensions = kValue; } /* * GetDimensions */ const D3DXVECTOR2 GuiElement::GetDimensions() const { return kDimensions; } /* * Pick */ GuiElement* GuiElement::Pick(float fX, float fY) { const D3DXVECTOR2& kLocation = GetPosition(); return Rectangle2(kLocation.y, kLocation.y, kDimensions.x, kDimensions.y).Contains(fX, fY) ? this : NULL; }