00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _BUTTON_
00019 #define _BUTTON_
00020
00021 #include <string>
00022
00023 #include "input/InputListener.h"
00024
00025 #include "sound/AbstractSoundEffect.h"
00026
00027 #include "ui/AbstractButtonListener.h"
00028 #include "ui/AbstractScreenElement.h"
00029
00030 #include "util/Colour.h"
00031 #include "util/Rect.h"
00032 #include "util/Vector2.h"
00033
00034 class Engine;
00035 class Label;
00036
00037 class Button : public AbstractScreenElement, public AbstractMouseListener
00038 {
00039 private:
00040 Engine* m_pEngine;
00041 Rect m_bounds;
00042 Label* m_pLabel;
00043 int m_nStartTextSize;
00044 float m_fHighlightStatus;
00045 bool m_bHighlighted;
00046 AbstractButtonListenerPtr m_pListener;
00047 AbstractSoundEffectPtr m_pHighlightSound;
00048 AbstractSoundEffectPtr m_pSelectSound;
00049 public:
00050 Button(const std::wstring& label, const std::string& labelFont, const int nLabelFontSize, const Colour& fontColour, const Vector2& labelPosition, int nLabelAlignment, Engine* pEngine);
00051 virtual ~Button();
00052
00053 void SetButtonListener(AbstractButtonListenerPtr pListener) { m_pListener = pListener; }
00054 void RecalculateBounds();
00055
00056 Label * GetLabel() const { return m_pLabel; }
00057 const Rect & GetBounds() const { return m_bounds; }
00058
00059 virtual void Update(const int nDelta);
00060 virtual void Render(AbstractRenderer* pRenderer, const int nDelta);
00061
00062 virtual void OnMouseMove(const MouseEvent& e);
00063 virtual void OnMouseButtonPressed(const MouseEvent& e);
00064 virtual void OnMouseButtonReleased(const MouseEvent& e) { }
00065 };
00066
00067 #endif