Merge pull request #22816 from CastagnaIT/fix_tx3g
[xbmc.git] / xbmc / guilib / GUILabelControl.h
blobce7ba4ec87da84a52df62d39505755713df5ee6f
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 /*!
12 \file GUILabelControl.h
13 \brief
16 #include "GUIControl.h"
17 #include "GUILabel.h"
18 #include "guilib/guiinfo/GUIInfoLabel.h"
20 /*!
21 \ingroup controls
22 \brief
24 class CGUILabelControl :
25 public CGUIControl
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); }
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;
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);
53 protected:
54 bool UpdateColors(const CGUIListItem* item) override;
55 std::string ShortenPath(const std::string &path);
57 /*! \brief Return the maximum width of this label control.
58 \return Return the width of the control if available, else the width of the current text.
60 float GetMaxWidth() const { return m_width ? m_width : m_label.GetTextWidth(); }
62 CGUILabel m_label;
64 bool m_bHasPath;
65 bool m_bShowCursor;
66 int m_iCursorPos;
67 unsigned int m_dwCounter;
69 // stuff for autowidth
70 float m_minWidth;
72 // multi-info stuff
73 KODI::GUILIB::GUIINFO::CGUIInfoLabel m_infoLabel;
75 unsigned int m_startHighlight;
76 unsigned int m_endHighlight;
77 unsigned int m_startSelection;
78 unsigned int m_endSelection;