]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/generic_window.hpp
e75b733b7fda3ab91e12375263596ea5d900be59
[vlc] / modules / gui / skins2 / src / generic_window.hpp
1 /*****************************************************************************
2  * generic_window.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 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 EvtMenu;
36 class EvtMotion;
37 class EvtMouse;
38 class EvtKey;
39 class EvtRefresh;
40 class EvtScroll;
41 class WindowManager;
42
43
44 /// Generic window class
45 class GenericWindow: public SkinObject, public Observer<VarBool>
46 {
47     private:
48         friend class WindowManager;
49         friend class VoutManager;
50         friend class CtrlVideo;
51     public:
52         GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
53                        bool dragDrop, bool playOnDrop,
54                        GenericWindow *pParent = NULL );
55         virtual ~GenericWindow();
56
57         /// Methods to process OS events.
58         virtual void processEvent( EvtFocus &rEvtFocus ) {}
59         virtual void processEvent( EvtMenu &rEvtMenu ) {}
60         virtual void processEvent( EvtMotion &rEvtMotion ) {}
61         virtual void processEvent( EvtMouse &rEvtMouse ) {}
62         virtual void processEvent( EvtLeave &rEvtLeave ) {}
63         virtual void processEvent( EvtKey &rEvtKey ) {}
64         virtual void processEvent( EvtScroll &rEvtScroll ) {}
65
66         virtual void processEvent( EvtRefresh &rEvtRefresh );
67
68         /// Resize the window
69         virtual void resize( int width, int height );
70
71         /// Refresh an area of the window
72         virtual void refresh( int left, int top, int width, int height ) {}
73
74         /// Get the coordinates of the window
75         int getLeft() const { return m_left; }
76         int getTop() const { return m_top; }
77         int getWidth() const { return m_width; }
78         int getHeight() const { return m_height; }
79
80         /// Give access to the visibility variable
81         VarBool &getVisibleVar() { return *m_pVarVisible; }
82
83         /// Window type, mainly useful when overloaded (for VoutWindow)
84         virtual string getType() const { return "Generic"; }
85
86         /// windows handle
87         void* getOSHandle() const;
88
89         /// reparent
90         void setParent( GenericWindow* pParent, int x, int y, int w, int h );
91
92     protected:
93         /// Get the OS window
94         OSWindow *getOSWindow() const { return m_pOsWindow; }
95
96         /// These methods do not need to be public since they are accessed
97         /// only by the window manager or by inheritant classes.
98         //@{
99         /// Show the window
100         virtual void show() const;
101
102         /// Hide the window
103         virtual void hide() const;
104
105         /// Move the window
106         virtual void move( int left, int top );
107
108         /// Bring the window on top
109         virtual void raise() const;
110
111         /// Set the opacity of the window (0 = transparent, 255 = opaque)
112         virtual void setOpacity( uint8_t value );
113
114         /// Toggle the window on top
115         virtual void toggleOnTop( bool onTop ) const;
116         //@}
117
118         /// Actually show the window
119         virtual void innerShow();
120
121         /// Actually hide the window
122         virtual void innerHide();
123
124     private:
125         /// Window position and size
126         int m_left, m_top, m_width, m_height;
127         /// OS specific implementation
128         OSWindow *m_pOsWindow;
129         /// Variable for the visibility of the window
130         mutable VarBoolImpl *m_pVarVisible;
131
132         /// Method called when the observed variable is modified
133         virtual void onUpdate( Subject<VarBool> &rVariable , void*);
134 };
135
136
137 #endif