~ubuntu-branches/debian/wheezy/vlc/wheezy

« back to all changes in this revision

Viewing changes to modules/gui/skins2/src/generic_window.cpp

Tags: upstream-0.7.2.final
Import upstream version 0.7.2.final

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 * generic_window.cpp
 
3
 *****************************************************************************
 
4
 * Copyright (C) 2003 VideoLAN
 
5
 * $Id: generic_window.cpp 7267 2004-04-03 20:17:06Z ipkiss $
 
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 
23
 *****************************************************************************/
 
24
 
 
25
#include "generic_window.hpp"
 
26
#include "os_window.hpp"
 
27
#include "os_factory.hpp"
 
28
#include "../events/evt_refresh.hpp"
 
29
 
 
30
 
 
31
GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
 
32
                              bool dragDrop, bool playOnDrop,
 
33
                              GenericWindow *pParent ):
 
34
    SkinObject( pIntf ), m_left( left ), m_top( top ), m_width( 0 ),
 
35
    m_height( 0 ), m_varVisible( pIntf )
 
36
{
 
37
   // Get the OSFactory
 
38
    OSFactory *pOsFactory = OSFactory::instance( getIntf() );
 
39
 
 
40
    // Get the parent OSWindow, if any
 
41
    OSWindow *pOSParent = NULL;
 
42
    if( pParent )
 
43
    {
 
44
        pOSParent = pParent->m_pOsWindow;
 
45
    }
 
46
 
 
47
    // Create an OSWindow to handle OS specific processing
 
48
    m_pOsWindow = pOsFactory->createOSWindow( *this, dragDrop, playOnDrop,
 
49
                                              pOSParent );
 
50
 
 
51
    // Observe the visibility variable
 
52
    m_varVisible.addObserver( this );
 
53
}
 
54
 
 
55
 
 
56
GenericWindow::~GenericWindow()
 
57
{
 
58
    m_varVisible.delObserver( this );
 
59
 
 
60
    if( m_pOsWindow )
 
61
    {
 
62
        delete m_pOsWindow;
 
63
    }
 
64
}
 
65
 
 
66
 
 
67
void GenericWindow::processEvent( EvtRefresh &rEvtRefresh )
 
68
{
 
69
    // Refresh the given area
 
70
    refresh( rEvtRefresh.getXStart(), rEvtRefresh.getYStart(),
 
71
             rEvtRefresh.getWidth(), rEvtRefresh.getHeight() );
 
72
}
 
73
 
 
74
 
 
75
void GenericWindow::show() const
 
76
{
 
77
    m_varVisible.set( true );
 
78
}
 
79
 
 
80
 
 
81
void GenericWindow::hide() const
 
82
{
 
83
    m_varVisible.set( false );
 
84
}
 
85
 
 
86
 
 
87
void GenericWindow::move( int left, int top )
 
88
{
 
89
    // Update the window coordinates
 
90
    m_left = left;
 
91
    m_top = top;
 
92
 
 
93
    m_pOsWindow->moveResize( left, top, m_width, m_height );
 
94
}
 
95
 
 
96
 
 
97
void GenericWindow::resize( int width, int height )
 
98
{
 
99
    // Update the window size
 
100
    m_width = width;
 
101
    m_height = height;
 
102
 
 
103
    m_pOsWindow->moveResize( m_left, m_top, width, height );
 
104
}
 
105
 
 
106
 
 
107
void GenericWindow::raise() const
 
108
{
 
109
    m_pOsWindow->raise();
 
110
}
 
111
 
 
112
 
 
113
void GenericWindow::setOpacity( uint8_t value )
 
114
{
 
115
    m_pOsWindow->setOpacity( value );
 
116
}
 
117
 
 
118
 
 
119
void GenericWindow::toggleOnTop( bool onTop ) const
 
120
{
 
121
    m_pOsWindow->toggleOnTop( onTop );
 
122
}
 
123
 
 
124
 
 
125
void GenericWindow::onUpdate( Subject<VarBool> &rVariable )
 
126
{
 
127
    if( m_varVisible.get() )
 
128
    {
 
129
        innerShow();
 
130
    }
 
131
    else
 
132
    {
 
133
        innerHide();
 
134
    }
 
135
}
 
136
 
 
137
 
 
138
void GenericWindow::innerShow()
 
139
{
 
140
    if( m_pOsWindow )
 
141
    {
 
142
        m_pOsWindow->show( m_left, m_top );
 
143
    }
 
144
}
 
145
 
 
146
 
 
147
void GenericWindow::innerHide()
 
148
{
 
149
    if( m_pOsWindow )
 
150
    {
 
151
        m_pOsWindow->hide();
 
152
    }
 
153
}
 
154