6 #ifndef GUILIB_SPINCONTROL_H
7 #define GUILIB_SPINCONTROL_H
12 * Copyright (C) 2005-2013 Team XBMC
15 * This Program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option)
20 * This Program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with XBMC; see the file COPYING. If not, see
27 * <http://www.gnu.org/licenses/>.
31 #include "GUIControl.h"
32 #include "GUITexture.h"
35 #define SPIN_CONTROL_TYPE_INT 1
36 #define SPIN_CONTROL_TYPE_FLOAT 2
37 #define SPIN_CONTROL_TYPE_TEXT 3
38 #define SPIN_CONTROL_TYPE_PAGE 4
44 class CGUISpinControl : public CGUIControl
47 CGUISpinControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& textureUp, const CTextureInfo& textureDown, const CTextureInfo& textureUpFocus, const CTextureInfo& textureDownFocus, const CLabelInfo& labelInfo, int iType);
48 virtual ~CGUISpinControl(void);
49 virtual CGUISpinControl *Clone() const { return new CGUISpinControl(*this); };
51 virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
52 virtual void Render();
53 virtual bool OnAction(const CAction &action);
54 virtual void OnLeft();
55 virtual void OnRight();
56 virtual bool HitTest(const CPoint &point) const;
57 virtual bool OnMouseOver(const CPoint &point);
58 virtual bool OnMessage(CGUIMessage& message);
59 virtual void AllocResources();
60 virtual void FreeResources(bool immediately = false);
61 virtual void DynamicResourceAlloc(bool bOnOff);
62 virtual void SetInvalid();
63 virtual void SetPosition(float posX, float posY);
64 virtual float GetWidth() const;
65 void SetRange(int iStart, int iEnd);
66 void SetFloatRange(float fStart, float fEnd);
67 void SetValue(int iValue);
68 void SetValueFromLabel(const CStdString &label);
69 void SetFloatValue(float fValue);
70 void SetStringValue(const std::string& strValue);
72 float GetFloatValue() const;
73 std::string GetStringValue() const;
74 void AddLabel(const std::string& strLabel, int iValue);
75 void AddLabel(const std::string& strLabel, const std::string& strValue);
76 const std::string GetLabel() const;
77 void SetReverse(bool bOnOff);
78 int GetMaximum() const;
79 int GetMinimum() const;
80 void SetSpinAlign(uint32_t align, float offsetX) { m_label.GetLabelInfo().align = align; m_label.GetLabelInfo().offsetX = offsetX; };
81 void SetType(int iType) { m_iType = iType; };
82 float GetSpinWidth() const { return m_imgspinUp.GetWidth(); };
83 float GetSpinHeight() const { return m_imgspinUp.GetHeight(); };
84 void SetFloatInterval(float fInterval);
85 void SetShowRange(bool bOnoff) ;
86 void SetShowOnePage(bool showOnePage) { m_showOnePage = showOnePage; };
88 virtual CStdString GetDescription() const;
89 bool IsFocusedOnUp() const;
91 virtual bool IsVisible() const;
94 virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
95 virtual bool UpdateColors();
96 /*! \brief Render the spinner text
97 \param posX position of the left edge of the text
98 \param posY positing of the top edge of the text
99 \param width width of the text
100 \param height height of the text
102 virtual void RenderText(float posX, float posY, float width, float height);
103 CGUILabel::COLOR GetTextColor() const;
106 bool CanMoveDown(bool bTestReverse = true);
107 bool CanMoveUp(bool bTestReverse = true);
108 void MoveUp(bool bTestReverse = true);
109 void MoveDown(bool bTestReverse = true);
110 void ChangePage(int amount);
121 std::vector<std::string> m_vecLabels;
122 std::vector<int> m_vecValues;
123 std::vector<std::string> m_vecStrValues;
124 CGUITexture m_imgspinUp;
125 CGUITexture m_imgspinDown;
126 CGUITexture m_imgspinUpFocus;
127 CGUITexture m_imgspinDownFocus;