]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/generic_window.hpp
7276ce221a20768533c9e12c42c432a4ed653b92
[vlc] / modules / gui / skins2 / src / generic_window.hpp
1 /*****************************************************************************
2  * generic_window.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #ifndef GENERIC_WINDOW_HPP
26 #define GENERIC_WINDOW_HPP
27
28 #include "skin_common.hpp"
29 #include "../utils/var_bool.hpp"
30
31 class OSWindow;
32 class EvtGeneric;
33 class EvtFocus;
34 class EvtLeave;
35 class EvtMotion;
36 class EvtMouse;
37 class EvtKey;
38 class EvtRefresh;
39 class EvtScroll;
40 class WindowManager;
41
42
43 /// Generic window class
44 class GenericWindow: public SkinObject, public Observer<VarBool>
45 {
46     private:
47         friend class WindowManager;
48     public:
49         GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
50                        bool dragDrop, bool playOnDrop,
51                        GenericWindow *pParent = NULL );
52         virtual ~GenericWindow();
53
54         /// Methods to process OS events.
55         virtual void processEvent( EvtFocus &rEvtFocus ) {}
56         virtual void processEvent( EvtMotion &rEvtMotion ) {}
57         virtual void processEvent( EvtMouse &rEvtMouse ) {}
58         virtual void processEvent( EvtLeave &rEvtLeave ) {}
59         virtual void processEvent( EvtKey &rEvtKey ) {}
60         virtual void processEvent( EvtScroll &rEvtScroll ) {}
61
62         virtual void processEvent( EvtRefresh &rEvtRefresh );
63
64         /// Resize the window
65         virtual void resize( int width, int height );
66
67         /// Refresh an area of the window
68         virtual void refresh( int left, int top, int width, int height ) {}
69
70         /// Get the coordinates of the window
71         int getLeft() const { return m_left; }
72         int getTop() const { return m_top; }
73         int getWidth() const { return m_width; }
74         int getHeight() const { return m_height; }
75
76         /// Give access to the visibility variable
77         VarBool &getVisibleVar() { return m_varVisible; }
78
79     protected:
80         /// Get the OS window
81         OSWindow *getOSWindow() const { return m_pOsWindow; }
82
83         /// These methods do not need to be public since they are accessed
84         /// only by the window manager or by inheritant classes.
85         //@{
86         /// Show the window
87         virtual void show() const;
88
89         /// Hide the window
90         virtual void hide() const;
91
92         /// Move the window
93         virtual void move( int left, int top );
94
95         /// Bring the window on top
96         virtual void raise() const;
97
98         /// Set the opacity of the window (0 = transparent, 255 = opaque)
99         virtual void setOpacity( uint8_t value );
100
101         /// Toggle the window on top
102         virtual void toggleOnTop( bool onTop ) const;
103         //@}
104
105         /// Actually show the window
106         virtual void innerShow();
107
108         /// Actually hide the window
109         virtual void innerHide();
110
111     private:
112         /// Window position and size
113         int m_left, m_top, m_width, m_height;
114         /// OS specific implementation
115         OSWindow *m_pOsWindow;
116         /// Variable for the visibility of the window
117         mutable VarBoolImpl m_varVisible;
118
119         /// Method called when the observed variable is modified
120         virtual void onUpdate( Subject<VarBool> &rVariable );
121 };
122
123
124 #endif