skin_common.hpp 3.95 KB
Newer Older
1
2
3
/*****************************************************************************
 * skin_common.hpp
 *****************************************************************************
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
11
12
13
14
15
16
17
18
19
20
21
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
dionoea's avatar
dionoea committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
24
25
26
27
28
29
 *****************************************************************************/

#ifndef SKIN_COMMON_HPP
#define SKIN_COMMON_HPP

#include <vlc/vlc.h>
#include <vlc/intf.h>
30
#include "charset.h"
31

32
#include <string>
33
34
35
36
37
using namespace std;

class AsyncQueue;
class Logger;
class Dialogs;
Cyril Deguet's avatar
Cyril Deguet committed
38
class Interpreter;
39
40
41
42
43
class OSFactory;
class OSLoop;
class VarManager;
class VlcProc;
class Theme;
44
class ThemeRepository;
45

46
47
48
#ifndef M_PI
#   define M_PI 3.14159265358979323846
#endif
49

50
#ifdef _MSC_VER
51
// turn off 'warning C4355: 'this' : used in base member initializer list'
52
#pragma warning ( disable:4355 )
53
54
// turn off 'identifier was truncated to '255' characters in the debug info'
#pragma warning ( disable:4786 )
55
56
#endif

57
58
59
60
61
62
63
64
65
66
67
68
69
// Useful macros
#define SKINS_DELETE( p ) \
   if( p ) \
   { \
       delete p; \
   } \
   else \
   { \
       msg_Err( getIntf(), "delete NULL pointer in %s at line %d", \
                __FILE__, __LINE__ ); \
   }


70
71
72
73
74
75
76
77
78
/// Wrapper around FromLocale, to avoid the need to call LocaleFree()
static inline string sFromLocale( const string &rLocale )
{
    char *s = FromLocale( rLocale.c_str() );
    string res = s;
    LocaleFree( s );
    return res;
}

79
80
81
82
83
84
85
86
/// Wrapper around FromWide, to avoid the need to call free()
static inline string sFromWide( const wstring &rWide )
{
    char *s = FromWide( rWide.c_str() );
    string res = s;
    free( s );
    return res;
}
87
88
89
90
91
92
93
94
95
96
97

/// Wrapper around ToLocale, to avoid the need to call LocaleFree()
static inline string sToLocale( const string &rUTF8 )
{
    char *s = ToLocale( rUTF8.c_str() );
    string res = s;
    LocaleFree( s );
    return res;
}


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//---------------------------------------------------------------------------
// intf_sys_t: description and status of skin interface
//---------------------------------------------------------------------------
struct intf_sys_t
{
    /// The input thread
    input_thread_t *p_input;

    /// The playlist thread
    playlist_t *p_playlist;

    /// Message bank subscription
    msg_subscription_t *p_sub;

    // "Singleton" objects: MUST be initialized to NULL !
    /// Logger
    Logger *p_logger;
    /// Asynchronous command queue
    AsyncQueue *p_queue;
    /// Dialog provider
    Dialogs *p_dialogs;
Cyril Deguet's avatar
Cyril Deguet committed
119
120
    /// Script interpreter
    Interpreter *p_interpreter;
121
122
123
124
125
126
127
128
    /// Factory for OS specific classes
    OSFactory *p_osFactory;
    /// Main OS specific message loop
    OSLoop *p_osLoop;
    /// Variable manager
    VarManager *p_varManager;
    /// VLC state handler
    VlcProc *p_vlcProc;
129
130
    /// Theme repository
    ThemeRepository *p_repository;
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

    /// Current theme
    Theme *p_theme;
};


/// Base class for all skin classes
class SkinObject
{
    public:
        SkinObject( intf_thread_t *pIntf ): m_pIntf( pIntf ) {}
        virtual ~SkinObject() {}

        /// Getter (public because it is used in C callbacks in the win32
        /// interface)
        intf_thread_t *getIntf() const { return m_pIntf; }

    private:
        intf_thread_t *m_pIntf;
};


#endif