generic_window.hpp 4.13 KB
Newer Older
1
2
3
4
/*****************************************************************************
 * generic_window.hpp
 *****************************************************************************
 * Copyright (C) 2003 VideoLAN
5
 * $Id$
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 *
 * Authors: Cyril Deguet     <asmax@via.ecp.fr>
 *          Olivier Teulire <ipkiss@via.ecp.fr>
 *
 * 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
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

#ifndef GENERIC_WINDOW_HPP
#define GENERIC_WINDOW_HPP

#include "skin_common.hpp"
#include "../utils/var_bool.hpp"

class OSWindow;
class EvtGeneric;
class EvtFocus;
class EvtLeave;
class EvtMotion;
class EvtMouse;
class EvtKey;
class EvtRefresh;
class EvtScroll;
40
class WindowManager;
41
42
43
44
45


/// Generic window class
class GenericWindow: public SkinObject, public Observer<VarBool>
{
46
47
    private:
        friend class WindowManager;
48
49
    public:
        GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
50
51
                       bool dragDrop, bool playOnDrop,
                       GenericWindow *pParent = NULL );
52
53
54
        virtual ~GenericWindow();

        /// Methods to process OS events.
55
56
57
58
59
60
        virtual void processEvent( EvtFocus &rEvtFocus ) {}
        virtual void processEvent( EvtMotion &rEvtMotion ) {}
        virtual void processEvent( EvtMouse &rEvtMouse ) {}
        virtual void processEvent( EvtLeave &rEvtLeave ) {}
        virtual void processEvent( EvtKey &rEvtKey ) {}
        virtual void processEvent( EvtScroll &rEvtScroll ) {}
61

62
63
        virtual void processEvent( EvtRefresh &rEvtRefresh );

64
65
66
67
68
69
70
        /// Resize the window
        virtual void resize( int width, int height );

        /// Refresh an area of the window
        virtual void refresh( int left, int top, int width, int height ) {}

        /// Get the coordinates of the window
71
72
73
74
        int getLeft() const { return m_left; }
        int getTop() const { return m_top; }
        int getWidth() const { return m_width; }
        int getHeight() const { return m_height; }
75
76
77
78

        /// Give access to the visibility variable
        VarBool &getVisibleVar() { return m_varVisible; }

79
80
81
        /// Window type, mainly useful when overloaded (for VoutWindow)
        virtual string getType() const { return "Generic"; }

82
83
84
85
86
87
88
89
    protected:
        /// Get the OS window
        OSWindow *getOSWindow() const { return m_pOsWindow; }

        /// These methods do not need to be public since they are accessed
        /// only by the window manager or by inheritant classes.
        //@{
        /// Show the window
90
        virtual void show() const;
91

92
        /// Hide the window
93
        virtual void hide() const;
94
95
96
97
98

        /// Move the window
        virtual void move( int left, int top );

        /// Bring the window on top
99
        virtual void raise() const;
100
101
102
103
104

        /// Set the opacity of the window (0 = transparent, 255 = opaque)
        virtual void setOpacity( uint8_t value );

        /// Toggle the window on top
105
        virtual void toggleOnTop( bool onTop ) const;
106
        //@}
107

108
109
110
111
112
        /// Actually show the window
        virtual void innerShow();

        /// Actually hide the window
        virtual void innerHide();
113
114
115
116
117
118
119

    private:
        /// Window position and size
        int m_left, m_top, m_width, m_height;
        /// OS specific implementation
        OSWindow *m_pOsWindow;
        /// Variable for the visibility of the window
120
        mutable VarBoolImpl m_varVisible;
121
122
123
124
125
126
127

        /// Method called when the observed variable is modified
        virtual void onUpdate( Subject<VarBool> &rVariable );
};


#endif