]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/generic_window.hpp
e1b5033d62a5ee2108c02dfe8c5f77c83c7be37e
[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
41
42 /// Generic window class
43 class GenericWindow: public SkinObject, public Observer<VarBool>
44 {
45     public:
46         GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
47                        bool dragDrop, bool playOnDrop,
48                        GenericWindow *pParent = NULL );
49         virtual ~GenericWindow();
50
51         /// Methods to process OS events.
52         virtual void processEvent( EvtFocus &rEvtFocus ) {}
53         virtual void processEvent( EvtMotion &rEvtMotion ) {}
54         virtual void processEvent( EvtMouse &rEvtMouse ) {}
55         virtual void processEvent( EvtLeave &rEvtLeave ) {}
56         virtual void processEvent( EvtKey &rEvtKey ) {}
57         virtual void processEvent( EvtRefresh &rEvtRefresh ) {}
58         virtual void processEvent( EvtScroll &rEvtScroll ) {}
59
60         // Show the window
61         virtual void show();
62
63         // Hide the window
64         virtual void hide();
65
66         // Refresh an area of the window
67         virtual void refresh( int left, int top, int width, int height ) {}
68
69         /// Move the window
70         virtual void move( int left, int top );
71
72         /// Resize the window
73         virtual void resize( int width, int height );
74
75         /// Bring the window on top
76         virtual void raise() const;
77
78         /// Set the opacity of the window (0 = transparent, 255 = opaque)
79         virtual void setOpacity( uint8_t value );
80
81         /// Toggle the window on top
82         virtual void toggleOnTop( bool onTop ) const;
83
84         /// Get the coordinates of the window
85         virtual int getLeft() const { return m_left; }
86         virtual int getTop() const { return m_top; }
87         virtual int getWidth() const { return m_width; }
88         virtual int getHeight() const { return m_height; }
89
90         /// Give access to the visibility variable
91         VarBool &getVisibleVar() { return m_varVisible; }
92
93     protected:
94         /// Actually show the window
95         virtual void innerShow();
96
97         /// Actually hide the window
98         virtual void innerHide();
99
100         /// Get the OS window
101         OSWindow *getOSWindow() const { return m_pOsWindow; }
102
103     private:
104         /// Window position and size
105         int m_left, m_top, m_width, m_height;
106         /// OS specific implementation
107         OSWindow *m_pOsWindow;
108         /// Variable for the visibility of the window
109         VarBoolImpl m_varVisible;
110
111         /// Method called when the observed variable is modified
112         virtual void onUpdate( Subject<VarBool> &rVariable );
113 };
114
115
116 #endif