6 #ifndef GUILIB_GUIEditControl_H
7 #define GUILIB_GUIEditControl_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 "GUIButtonControl.h"
32 #include "utils/Stopwatch.h"
33 #include "utils/StringValidation.h"
40 class CGUIEditControl : public CGUIButtonControl
44 INPUT_TYPE_READONLY = -1,
52 INPUT_TYPE_PASSWORD_MD5,
55 INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW
58 CGUIEditControl(int parentID, int controlID, float posX, float posY,
59 float width, float height, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus,
60 const CLabelInfo& labelInfo, const std::string &text);
61 CGUIEditControl(const CGUIButtonControl &button);
62 virtual ~CGUIEditControl(void);
63 virtual CGUIEditControl *Clone() const { return new CGUIEditControl(*this); };
65 virtual bool OnMessage(CGUIMessage &message);
66 virtual bool OnAction(const CAction &action);
67 virtual void OnClick();
69 virtual void SetLabel(const std::string &text);
70 virtual void SetLabel2(const std::string &text);
71 void SetHint(const CGUIInfoLabel& hint);
73 virtual CStdString GetLabel2() const;
75 unsigned int GetCursorPosition() const;
76 void SetCursorPosition(unsigned int iPosition);
78 void SetInputType(INPUT_TYPE type, int heading);
80 void SetTextChangeActions(const CGUIAction& textChangeActions) { m_textChangeActions = textChangeActions; };
82 bool HasTextChangeActions() const { return m_textChangeActions.HasActionsMeetingCondition(); };
84 virtual bool HasInvalidInput() const { return m_invalidInput; }
85 virtual void SetInputValidation(StringValidation::Validator inputValidator, void *data = NULL);
88 virtual void ProcessText(unsigned int currentTime);
89 virtual void RenderText();
90 virtual CGUILabel::COLOR GetTextColor() const;
91 CStdStringW GetDisplayedText() const;
92 void RecalcLabelPosition();
93 void ValidateCursor();
94 void UpdateText(bool sendUpdate = true);
95 void OnPasteClipboard();
96 void OnSMSCharacter(unsigned int key);
97 void DefaultConstructor();
99 virtual bool ValidateInput(const CStdStringW &data) const;
100 void ValidateInput();
102 /*! \brief Clear out the current text input if it's an MD5 password.
103 \return true if the password is cleared, false otherwise.
109 CGUIInfoLabel m_hintInfo;
112 CRect m_clipRect; ///< clipping rect for the second label
114 static const int spaceWidth = 5;
116 unsigned int m_cursorPos;
117 unsigned int m_cursorBlink;
120 INPUT_TYPE m_inputType;
123 CGUIAction m_textChangeActions;
126 StringValidation::Validator m_inputValidator;
127 void *m_inputValidatorData;
129 unsigned int m_smsKeyIndex;
130 unsigned int m_smsLastKey;
131 CStopWatch m_smsTimer;
133 static const char* smsLetters[10];
134 static const unsigned int smsDelay;