]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/generic_window.hpp
* include/vlc_keys.h: mouse wheel events now considered as hotkeys
[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/pointer.hpp"
30 #include "../utils/var_bool.hpp"
31 #include <list>
32
33 class Anchor;
34 class OSWindow;
35 class OSGraphics;
36 class GenericLayout;
37 class CtrlGeneric;
38 class EvtGeneric;
39 class EvtFocus;
40 class EvtLeave;
41 class EvtMotion;
42 class EvtMouse;
43 class EvtKey;
44 class EvtRefresh;
45 class EvtScroll;
46 class WindowManager;
47
48
49 /// Generic window class
50 class GenericWindow: public SkinObject, public Observer<VarBool>
51 {
52     public:
53         GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
54                        WindowManager &rWindowManager,
55                        bool dragDrop, bool playOnDrop );
56         virtual ~GenericWindow();
57
58         /// Methods to process OS events.
59         virtual void processEvent( EvtFocus &rEvtFocus );
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( EvtRefresh &rEvtRefresh );
65         virtual void processEvent( EvtScroll &rEvtScroll );
66
67         /// Forward an event to a control
68         virtual void forwardEvent( EvtGeneric &rEvt, CtrlGeneric &rCtrl );
69
70         // Show the window
71         virtual void show();
72
73         // Hide the window
74         virtual void hide();
75
76         // Refresh an area of the window
77         virtual void refresh( int left, int top, int width, int height );
78
79         /// Move the window
80         virtual void move( int left, int top );
81
82         /// Resize the window
83         virtual void resize( int width, int height );
84
85         /// Bring the window on top
86         virtual void raise() const;
87
88         /// Set the opacity of the window (0 = transparent, 255 = opaque)
89         virtual void setOpacity( uint8_t value );
90
91         /// Toggle the window on top
92         virtual void toggleOnTop( bool onTop ) const;
93
94         /// Change the active layout
95         virtual void setActiveLayout( GenericLayout *pLayout );
96
97         /// Update the shape of the window from the active layout
98         virtual void updateShape();
99
100         /// Called by a control that wants to capture the mouse
101         virtual void onControlCapture( const CtrlGeneric &rCtrl );
102
103         /// Called by a control that wants to release the mouse
104         virtual void onControlRelease( const CtrlGeneric &rCtrl );
105
106         /// Called by a control when its tooltip changed
107         virtual void onTooltipChange( const CtrlGeneric &rCtrl );
108
109         /// Get the coordinates of the window
110         virtual int getLeft() const { return m_left; }
111         virtual int getTop() const { return m_top; }
112         virtual int getWidth() const { return m_width; }
113         virtual int getHeight() const { return m_height; }
114
115         /// Give access to the visibility variable
116         VarBool &getVisibleVar() { return m_varVisible; }
117
118         /// Get the list of the anchors of this window
119         virtual const list<Anchor*> getAnchorList() const;
120
121         /// Add an anchor to this window
122         virtual void addAnchor( Anchor *pAnchor );
123
124     private:
125         /// Window manager
126         WindowManager &m_rWindowManager;
127         /// Window position and size
128         int m_left, m_top, m_width, m_height;
129         /// OS specific implementation
130         OSWindow *m_pOsWindow;
131         /// Current active layout of the window
132         GenericLayout *m_pActiveLayout;
133         /// Last control on which the mouse was over
134         CtrlGeneric *m_pLastHitControl;
135         /// Control that has captured the mouse
136         CtrlGeneric *m_pCapturingControl;
137         /// Control that has the focus
138         CtrlGeneric *m_pFocusControl;
139         /// List of the anchors of this window
140         list<Anchor*> m_anchorList;
141         /// Variable for the visibility of the window
142         VarBoolImpl m_varVisible;
143         /// Current key modifier (also used for mouse)
144         int m_currModifier;
145
146         /// Method called when the observed variable is modified
147         virtual void onUpdate( Subject<VarBool> &rVariable );
148
149         // Actually show the window
150         virtual void innerShow();
151
152         // Actually hide the window
153         virtual void innerHide();
154
155         /// Find the uppest control in the layout hit by the mouse, and send
156         /// it an enter event if needed
157         CtrlGeneric *findHitControl( int xPos, int yPos );
158
159         /// Update the lastHitControl pointer and send a leave event to the
160         /// right control
161         void setLastHit( CtrlGeneric *pNewHitControl );
162 };
163
164 typedef CountedPtr<GenericWindow> GenericWindowPtr;
165
166
167 #endif