Merge pull request #3146 from FernetMenta/aefixes
[vuplus_xbmc] / xbmc / guilib / GUIEditControl.h
1 /*!
2 \file GUIEditControl.h
3 \brief
4 */
5
6 #ifndef GUILIB_GUIEditControl_H
7 #define GUILIB_GUIEditControl_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 "GUIButtonControl.h"
32 #include "utils/Stopwatch.h"
33
34 /*!
35  \ingroup controls
36  \brief
37  */
38
39 class CGUIEditControl : public CGUIButtonControl
40 {
41 public:
42   enum INPUT_TYPE {
43                     INPUT_TYPE_READONLY = -1,
44                     INPUT_TYPE_TEXT = 0,
45                     INPUT_TYPE_NUMBER,
46                     INPUT_TYPE_SECONDS,
47                     INPUT_TYPE_TIME,
48                     INPUT_TYPE_DATE,
49                     INPUT_TYPE_IPADDRESS,
50                     INPUT_TYPE_PASSWORD,
51                     INPUT_TYPE_PASSWORD_MD5,
52                     INPUT_TYPE_SEARCH,
53                     INPUT_TYPE_FILTER,
54                     INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW
55                   };
56
57   CGUIEditControl(int parentID, int controlID, float posX, float posY,
58                   float width, float height, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus,
59                   const CLabelInfo& labelInfo, const std::string &text);
60   CGUIEditControl(const CGUIButtonControl &button);
61   virtual ~CGUIEditControl(void);
62   virtual CGUIEditControl *Clone() const { return new CGUIEditControl(*this); };
63
64   virtual bool OnMessage(CGUIMessage &message);
65   virtual bool OnAction(const CAction &action);
66   virtual void OnClick();
67
68   virtual void SetLabel(const std::string &text);
69   virtual void SetLabel2(const std::string &text);
70   void SetHint(const CGUIInfoLabel& hint);
71
72   virtual CStdString GetLabel2() const;
73
74   unsigned int GetCursorPosition() const;
75   void SetCursorPosition(unsigned int iPosition);
76
77   void SetInputType(INPUT_TYPE type, int heading);
78
79   void SetTextChangeActions(const CGUIAction& textChangeActions) { m_textChangeActions = textChangeActions; };
80
81   bool HasTextChangeActions() { return m_textChangeActions.HasActionsMeetingCondition(); };
82
83 protected:
84   virtual void ProcessText(unsigned int currentTime);
85   virtual void RenderText();
86   CStdStringW GetDisplayedText() const;
87   void RecalcLabelPosition();
88   void ValidateCursor();
89   void UpdateText(bool sendUpdate = true);
90   void OnPasteClipboard();
91   void OnSMSCharacter(unsigned int key);
92   void DefaultConstructor();  
93
94   /*! \brief Clear out the current text input if it's an MD5 password.
95    \return true if the password is cleared, false otherwise.
96    */
97   bool ClearMD5();
98   
99   CStdStringW m_text2;
100   CStdString  m_text;
101   CGUIInfoLabel m_hintInfo;
102   float m_textOffset;
103   float m_textWidth;
104   CRect m_clipRect; ///< clipping rect for the second label
105
106   static const int spaceWidth = 5;
107
108   unsigned int m_cursorPos;
109   unsigned int m_cursorBlink;
110
111   int m_inputHeading;
112   INPUT_TYPE m_inputType;
113   bool m_isMD5;
114
115   CGUIAction m_textChangeActions;
116
117   unsigned int m_smsKeyIndex;
118   unsigned int m_smsLastKey;
119   CStopWatch   m_smsTimer;
120
121   static const char*        smsLetters[10];
122   static const unsigned int smsDelay;
123 };
124 #endif