Fix keymap.
[vuplus_xbmc] / xbmc / guilib / GUISpinControl.h
1 /*!
2 \file GUISpinControl.h
3 \brief
4 */
5
6 #ifndef GUILIB_SPINCONTROL_H
7 #define GUILIB_SPINCONTROL_H
8
9 #pragma once
10
11 /*
12  *      Copyright (C) 2005-2013 Team XBMC
13  *      http://xbmc.org
14  *
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)
18  *  any later version.
19  *
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.
24  *
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/>.
28  *
29  */
30
31 #include "GUIControl.h"
32 #include "GUITexture.h"
33 #include "GUILabel.h"
34
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
39
40 /*!
41  \ingroup controls
42  \brief
43  */
44 class CGUISpinControl : public CGUIControl
45 {
46 public:
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); };
50
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);
71   int GetValue() const;
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; };
87   void Clear();
88   virtual CStdString GetDescription() const;
89   bool IsFocusedOnUp() const;
90
91   virtual bool IsVisible() const;
92
93 protected:
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
101    */
102   virtual void RenderText(float posX, float posY, float width, float height);
103   CGUILabel::COLOR GetTextColor() const;
104   void PageUp();
105   void PageDown();
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);
111   int m_iStart;
112   int m_iEnd;
113   float m_fStart;
114   float m_fEnd;
115   int m_iValue;
116   float m_fValue;
117   int m_iType;
118   int m_iSelect;
119   bool m_bReverse;
120   float m_fInterval;
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;
128   CGUILabel   m_label;
129   bool m_bShowRange;
130   char m_szTyped[10];
131   int m_iTypedPos;
132
133   int m_currentItem;
134   int m_itemsPerPage;
135   int m_numItems;
136   bool m_showOnePage;
137 };
138 #endif