xbmc
GUITextBox.h
Go to the documentation of this 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 
16 #include "GUIControl.h"
17 #include "GUILabel.h"
18 #include "GUITextLayout.h"
20 
26 class TiXmlNode;
27 
28 class CGUITextBox : public CGUIControl, public CGUITextLayout
29 {
30 public:
31  CGUITextBox(int parentID, int controlID, float posX, float posY, float width, float height,
32  const CLabelInfo &labelInfo, int scrollTime = 200,
33  const CLabelInfo* labelInfoMono = nullptr);
34  CGUITextBox(const CGUITextBox &from);
35  ~CGUITextBox(void) override;
36  CGUITextBox* Clone() const override { return new CGUITextBox(*this); }
37 
38  void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
39  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
40  void Render() override;
41  bool OnMessage(CGUIMessage& message) override;
42  float GetHeight() const override;
43  void SetMinHeight(float minHeight);
44 
45  void SetPageControl(int pageControl);
46 
47  bool CanFocus() const override;
48  void SetInfo(const KODI::GUILIB::GUIINFO::CGUIInfoLabel &info);
49  void SetAutoScrolling(const TiXmlNode *node);
50  void SetAutoScrolling(int delay, int time, int repeatTime, const std::string &condition = "");
51  void ResetAutoScrolling();
52 
53  bool GetCondition(int condition, int data) const override;
54  virtual std::string GetLabel(int info) const;
55  std::string GetDescription() const override;
56 
57  void Scroll(unsigned int offset);
58 
59 protected:
60  void UpdateVisibility(const CGUIListItem *item = NULL) override;
61  bool UpdateColors(const CGUIListItem* item) override;
62  void UpdateInfo(const CGUIListItem *item = NULL) override;
63  void UpdatePageControl();
64  void ScrollToOffset(int offset, bool autoScroll = false);
65  unsigned int GetRows() const;
66  int GetCurrentPage() const;
67  int GetNumPages() const;
68 
69  // auto-height
70  float m_minHeight;
71  float m_renderHeight;
72 
73  // offset of text in the control for scrolling
74  unsigned int m_offset;
75  float m_scrollOffset;
76  float m_scrollSpeed;
77  int m_scrollTime;
78  unsigned int m_itemsPerPage;
79  float m_itemHeight;
80  unsigned int m_lastRenderTime;
81 
82  CLabelInfo m_label;
83 
84  TransformMatrix m_cachedTextMatrix;
85 
86  // autoscrolling
87  INFO::InfoPtr m_autoScrollCondition;
88  int m_autoScrollTime; // time to scroll 1 line (ms)
89  int m_autoScrollDelay; // delay before scroll (ms)
90  unsigned int m_autoScrollDelayTime; // current offset into the delay
91  CAnimation *m_autoScrollRepeatAnim;
92 
93  int m_pageControl;
94 
96 };
97 
Definition: GUIListItem.h:30
Definition: GUIInfoLabel.h:31
Definition: GUITextBox.h:28
Definition: VisibleEffect.h:151
Base class for controls.
Definition: GUIControl.h:75
Definition: GUITextLayout.h:57
Definition: TransformMatrix.h:25
Definition: GUIMessage.h:365
Definition: GUILabel.h:22