kodi
GUILabelControl.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"
19 
25  public CGUIControl
26 {
27 public:
28  CGUILabelControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, bool wrapMultiLine, bool bHasPath);
29  ~CGUILabelControl(void) override;
30  CGUILabelControl* Clone() const override { return new CGUILabelControl(*this); }
31 
32  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
33  void Render() override;
34  void UpdateInfo(const CGUIListItem *item = NULL) override;
35  bool CanFocus() const override;
36  bool OnMessage(CGUIMessage& message) override;
37  std::string GetDescription() const override;
38  float GetWidth() const override;
39  void SetWidth(float width) override;
40  CRect CalcRenderRegion() const override;
41 
42  const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); }
43  void SetLabel(const std::string &strLabel);
44  void ShowCursor(bool bShow = true);
45  void SetCursorPos(int iPos);
46  int GetCursorPos() const { return m_iCursorPos; }
47  void SetInfo(const KODI::GUILIB::GUIINFO::CGUIInfoLabel&labelInfo);
48  void SetWidthControl(float minWidth, bool bScroll);
49  void SetAlignment(uint32_t align);
50  void SetHighlight(unsigned int start, unsigned int end);
51  void SetSelection(unsigned int start, unsigned int end);
52 
53 protected:
54  bool UpdateColors(const CGUIListItem* item) override;
55  std::string ShortenPath(const std::string &path);
56 
60  float GetMaxWidth() const { return m_width ? m_width : m_label.GetTextWidth(); }
61 
62  CGUILabel m_label;
63 
64  bool m_bHasPath;
65  bool m_bShowCursor;
66  int m_iCursorPos;
67  unsigned int m_dwCounter;
68 
69  // stuff for autowidth
70  float m_minWidth;
71 
72  // multi-info stuff
74 
75  unsigned int m_startHighlight;
76  unsigned int m_endHighlight;
77  unsigned int m_startSelection;
78  unsigned int m_endSelection;
79 };
80 
Class for rendering text labels. Handles alignment and rendering of text within a control...
Definition: GUILabel.h:69
Definition: GUIListItem.h:29
Definition: GUIInfoLabel.h:31
CRect CalcRenderRegion() const override
calculate the render region in parentcontrol coordinates of this control Called during process to upd...
Definition: GUILabelControl.cpp:135
Base class for controls.
Definition: GUIControl.h:83
Definition: GUILabelControl.h:24
float GetTextWidth() const
Returns the precalculated full width of the current text, regardless of layout.
Definition: GUILabel.h:181
Definition: GUIMessage.h:365
Definition: GUILabel.h:22
float GetMaxWidth() const
Return the maximum width of this label control.
Definition: GUILabelControl.h:60