Merge pull request #4689 from jmarshallnz/label_auto_width_fix
[vuplus_xbmc] / xbmc / guilib / GUILabelControl.h
1 /*!
2 \file GUILabelControl.h
3 \brief
4 */
5
6 #ifndef GUILIB_GUILABELCONTROL_H
7 #define GUILIB_GUILABELCONTROL_H
8
9 #pragma once
10
11 /*
12  *      Copyright (C) 2005-2013 Team XBMC
13  *      http://xbmc.org
14  *
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)
18  *  any later version.
19  *
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.
24  *
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/>.
28  *
29  */
30
31 #include "GUIControl.h"
32 #include "GUILabel.h"
33
34 /*!
35  \ingroup controls
36  \brief
37  */
38 class CGUILabelControl :
39       public CGUIControl
40 {
41 public:
42   CGUILabelControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, bool wrapMultiLine, bool bHasPath);
43   virtual ~CGUILabelControl(void);
44   virtual CGUILabelControl *Clone() const { return new CGUILabelControl(*this); };
45
46   virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
47   virtual void Render();
48   virtual void UpdateInfo(const CGUIListItem *item = NULL);
49   virtual bool CanFocus() const;
50   virtual bool OnMessage(CGUIMessage& message);
51   virtual CStdString GetDescription() const;
52   virtual float GetWidth() const;
53   virtual void SetWidth(float width);
54   virtual CRect CalcRenderRegion() const;
55  
56   const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); };
57   void SetLabel(const std::string &strLabel);
58   void ShowCursor(bool bShow = true);
59   void SetCursorPos(int iPos);
60   int GetCursorPos() const { return m_iCursorPos;};
61   void SetInfo(const CGUIInfoLabel&labelInfo);
62   void SetWidthControl(float minWidth, bool bScroll);
63   void SetAlignment(uint32_t align);
64   void SetHighlight(unsigned int start, unsigned int end);
65   void SetSelection(unsigned int start, unsigned int end);
66
67 protected:
68   bool UpdateColors();
69   CStdString ShortenPath(const CStdString &path);
70
71   /*! \brief Return the maximum width of this label control.
72    \return Return the width of the control if available, else the width of the current text.
73    */
74   float GetMaxWidth() const { return m_width ? m_width : m_label.GetTextWidth(); }
75
76   CGUILabel m_label;
77
78   bool m_bHasPath;
79   bool m_bShowCursor;
80   int m_iCursorPos;
81   unsigned int m_dwCounter;
82
83   // stuff for autowidth
84   float m_minWidth;
85
86   // multi-info stuff
87   CGUIInfoLabel m_infoLabel;
88
89   unsigned int m_startHighlight;
90   unsigned int m_endHighlight;
91   unsigned int m_startSelection;
92   unsigned int m_endSelection;
93 };
94 #endif