Fix keymap.
[vuplus_xbmc] / xbmc / guilib / GUIInfoTypes.h
1 /*!
2 \file GUIInfoTypes.h
3 \brief
4 */
5
6 #ifndef GUILIB_GUIINFOTYPES_H
7 #define GUILIB_GUIINFOTYPES_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 "utils/StdString.h"
32 #include "interfaces/info/InfoBool.h"
33
34 class CGUIListItem;
35
36 class CGUIInfoBool
37 {
38 public:
39   CGUIInfoBool(bool value = false);
40   virtual ~CGUIInfoBool();
41
42   operator bool() const { return m_value; };
43
44   void Update(const CGUIListItem *item = NULL);
45   void Parse(const CStdString &expression, int context);
46 private:
47   INFO::InfoPtr m_info;
48   bool m_value;
49 };
50
51 typedef uint32_t color_t;
52
53 class CGUIInfoColor
54 {
55 public:
56   CGUIInfoColor(color_t color = 0);
57
58   CGUIInfoColor& operator=(const CGUIInfoColor &color);
59   CGUIInfoColor& operator=(color_t color);
60   operator color_t() const { return m_color; };
61
62   bool Update();
63   void Parse(const CStdString &label, int context);
64
65 private:
66   color_t GetColor() const;
67   int     m_info;
68   color_t m_color;
69 };
70
71 class CGUIInfoLabel
72 {
73 public:
74   CGUIInfoLabel();
75   CGUIInfoLabel(const CStdString &label, const CStdString &fallback = "", int context = 0);
76
77   void SetLabel(const CStdString &label, const CStdString &fallback, int context = 0);
78
79   /*!
80    \brief Gets a label (or image) for a given window context from the info manager.
81    \param contextWindow the context in which to evaluate the expression.
82    \param preferImage caller is specifically wanting an image rather than a label. Defaults to false.
83    \param fallback if non-NULL, is set to an alternate value to use should the actual value be not appropriate. Defaults to NULL.
84    \return label (or image).
85    */  
86   CStdString GetLabel(int contextWindow, bool preferImage = false, CStdString *fallback = NULL) const;
87
88   /*!
89    \brief Gets a label (or image) for a given listitem from the info manager.
90    \param item listitem in question.
91    \param preferImage caller is specifically wanting an image rather than a label. Defaults to false.
92    \param fallback if non-NULL, is set to an alternate value to use should the actual value be not appropriate. Defaults to NULL.
93    \return label (or image).
94    */
95   CStdString GetItemLabel(const CGUIListItem *item, bool preferImage = false, CStdString *fallback = NULL) const;
96
97   bool IsConstant() const;
98   bool IsEmpty() const;
99
100   const CStdString GetFallback() const { return m_fallback; };
101
102   static CStdString GetLabel(const CStdString &label, int contextWindow = 0, bool preferImage = false);
103
104   /*!
105    \brief Replaces instances of $LOCALIZE[number] with the appropriate localized string
106    \param label text to replace
107    \return text with any localized strings filled in.
108    */
109   static CStdString ReplaceLocalize(const CStdString &label);
110
111   /*!
112    \brief Replaces instances of $ADDON[id number] with the appropriate localized addon string
113    \param label text to replace
114    \return text with any localized strings filled in.
115    */
116   static CStdString ReplaceAddonStrings(const CStdString &label);
117
118 private:
119   void Parse(const CStdString &label, int context);
120
121   class CInfoPortion
122   {
123   public:
124     CInfoPortion(int info, const CStdString &prefix, const CStdString &postfix, bool escaped = false);
125     CStdString GetLabel(const CStdString &info) const;
126     int m_info;
127     CStdString m_prefix;
128     CStdString m_postfix;
129   private:
130     bool m_escaped;
131   };
132
133   CStdString m_fallback;
134   std::vector<CInfoPortion> m_info;
135 };
136
137 #endif