PageRenderTime 36ms CodeModel.GetById 19ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/xbmc/guilib/GUIEditControl.h

http://github.com/xbmc/xbmc
C Header | 128 lines | 84 code | 26 blank | 18 comment | 0 complexity | 33523943d9464230f62e4e39d57f799b MD5 | raw file
  1/*
  2 *  Copyright (C) 2005-2018 Team Kodi
  3 *  This file is part of Kodi - https://kodi.tv
  4 *
  5 *  SPDX-License-Identifier: GPL-2.0-or-later
  6 *  See LICENSES/README.md for more information.
  7 */
  8
  9#pragma once
 10
 11/*!
 12\file GUIEditControl.h
 13\brief
 14*/
 15
 16#include "GUIButtonControl.h"
 17#include "utils/Stopwatch.h"
 18#include "utils/StringValidation.h"
 19#include "utils/Variant.h"
 20
 21/*!
 22 \ingroup controls
 23 \brief
 24 */
 25
 26class CGUIEditControl : public CGUIButtonControl
 27{
 28public:
 29  enum INPUT_TYPE {
 30                    INPUT_TYPE_READONLY = -1,
 31                    INPUT_TYPE_TEXT = 0,
 32                    INPUT_TYPE_NUMBER,
 33                    INPUT_TYPE_SECONDS,
 34                    INPUT_TYPE_TIME,
 35                    INPUT_TYPE_DATE,
 36                    INPUT_TYPE_IPADDRESS,
 37                    INPUT_TYPE_PASSWORD,
 38                    INPUT_TYPE_PASSWORD_MD5,
 39                    INPUT_TYPE_SEARCH,
 40                    INPUT_TYPE_FILTER,
 41                    INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW
 42                  };
 43
 44  CGUIEditControl(int parentID, int controlID, float posX, float posY,
 45                  float width, float height, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus,
 46                  const CLabelInfo& labelInfo, const std::string &text);
 47  explicit CGUIEditControl(const CGUIButtonControl &button);
 48  ~CGUIEditControl(void) override;
 49  CGUIEditControl *Clone() const override { return new CGUIEditControl(*this); };
 50
 51  bool OnMessage(CGUIMessage &message) override;
 52  bool OnAction(const CAction &action) override;
 53  void OnClick() override;
 54
 55  void SetLabel(const std::string &text) override;
 56  void SetLabel2(const std::string &text) override;
 57  void SetHint(const KODI::GUILIB::GUIINFO::CGUIInfoLabel& hint);
 58
 59  std::string GetLabel2() const override;
 60
 61  unsigned int GetCursorPosition() const;
 62  void SetCursorPosition(unsigned int iPosition);
 63
 64  void SetInputType(INPUT_TYPE type, CVariant heading);
 65
 66  void SetTextChangeActions(const CGUIAction& textChangeActions) { m_textChangeActions = textChangeActions; };
 67
 68  bool HasTextChangeActions() const { return m_textChangeActions.HasActionsMeetingCondition(); };
 69
 70  virtual bool HasInvalidInput() const { return m_invalidInput; }
 71  virtual void SetInputValidation(StringValidation::Validator inputValidator, void *data = NULL);
 72
 73protected:
 74  void SetFocus(bool focus) override;
 75  void ProcessText(unsigned int currentTime) override;
 76  void RenderText() override;
 77  CGUILabel::COLOR GetTextColor() const override;
 78  std::wstring GetDisplayedText() const;
 79  std::string GetDescriptionByIndex(int index) const override;
 80  bool SetStyledText(const std::wstring &text);
 81  void RecalcLabelPosition();
 82  void ValidateCursor();
 83  void UpdateText(bool sendUpdate = true);
 84  void OnPasteClipboard();
 85  void OnSMSCharacter(unsigned int key);
 86  void DefaultConstructor();
 87
 88  virtual bool ValidateInput(const std::wstring &data) const;
 89  void ValidateInput();
 90
 91  /*! \brief Clear out the current text input if it's an MD5 password.
 92   \return true if the password is cleared, false otherwise.
 93   */
 94  bool ClearMD5();
 95
 96  std::wstring m_text2;
 97  std::string  m_text;
 98  KODI::GUILIB::GUIINFO::CGUIInfoLabel m_hintInfo;
 99  float m_textOffset;
100  float m_textWidth;
101  CRect m_clipRect; ///< clipping rect for the second label
102
103  static const int spaceWidth = 5;
104
105  unsigned int m_cursorPos;
106  unsigned int m_cursorBlink;
107
108  std::string m_inputHeading;
109  INPUT_TYPE m_inputType;
110  bool m_isMD5;
111
112  CGUIAction m_textChangeActions;
113
114  bool m_invalidInput;
115  StringValidation::Validator m_inputValidator;
116  void *m_inputValidatorData;
117
118  unsigned int m_smsKeyIndex;
119  unsigned int m_smsLastKey;
120  CStopWatch   m_smsTimer;
121
122  std::wstring m_edit;
123  int          m_editOffset;
124  int          m_editLength;
125
126  static const char*        smsLetters[10];
127  static const unsigned int smsDelay;
128};