]> git.sesse.net Git - vlc/blob - modules/gui/skins2/utils/var_text.hpp
19aea6dd99658fd6d93370471af890e099a67e42
[vlc] / modules / gui / skins2 / utils / var_text.hpp
1 /*****************************************************************************
2  * var_text.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef VAR_TEXT_HPP
26 #define VAR_TEXT_HPP
27
28 #include "variable.hpp"
29 #include "var_percent.hpp"
30 #include "observer.hpp"
31 #include "ustring.hpp"
32
33
34 /// String variable
35 class VarText: public Variable, public Subject<VarText, void*>,
36                public Observer<VarPercent, void*>,
37                public Observer< VarText,void*>
38 {
39     public:
40         // Set substVars to true to replace "$X" variables in the text
41         VarText( intf_thread_t *pIntf, bool substVars = true );
42         virtual ~VarText();
43
44         /// Get the variable type
45         virtual const string &getType() const { return m_type; }
46
47         /// Set the internal value
48         virtual void set( const UString &rText );
49         virtual const UString get() const;
50
51         /// Methods called when an observed variable is modified
52         virtual void onUpdate( Subject<VarPercent, void*> &rVariable, void* );
53         virtual void onUpdate( Subject<VarText, void*> &rVariable, void* );
54
55     private:
56         /// Variable type
57         static const string m_type;
58         /// The text of the variable
59         UString m_text;
60         /// Actual text after having replaced the variables
61         UString m_lastText;
62         /// Flag to activate or not "$X" variables substitution
63         bool m_substVars;
64 };
65
66 #endif