]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/top_window.hpp
Skins2: Cosmetics, 100% pure. We don't indent for labels in C, we don't in C++.
[vlc] / modules / gui / skins2 / src / top_window.hpp
1 /*****************************************************************************
2  * top_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 along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef TOP_WINDOW_HPP
26 #define TOP_WINDOW_HPP
27
28 #include "generic_window.hpp"
29 #include "../utils/pointer.hpp"
30 #include <list>
31
32 class OSWindow;
33 class OSGraphics;
34 class GenericLayout;
35 class CtrlGeneric;
36 class WindowManager;
37
38
39 /// Class to handle top-level windows
40 class TopWindow: public GenericWindow
41 {
42 private:
43     friend class WindowManager;
44 public:
45     TopWindow( intf_thread_t *pIntf, int xPos, int yPos,
46                WindowManager &rWindowManager,
47                bool dragDrop, bool playOnDrop, bool visible );
48     virtual ~TopWindow();
49
50     /// Methods to process OS events.
51     virtual void processEvent( EvtRefresh &rEvtRefresh );
52     virtual void processEvent( EvtFocus &rEvtFocus );
53     virtual void processEvent( EvtMenu &rEvtMenu );
54     virtual void processEvent( EvtMotion &rEvtMotion );
55     virtual void processEvent( EvtMouse &rEvtMouse );
56     virtual void processEvent( EvtLeave &rEvtLeave );
57     virtual void processEvent( EvtKey &rEvtKey );
58     virtual void processEvent( EvtScroll &rEvtScroll );
59
60     /// Forward an event to a control
61     virtual void forwardEvent( EvtGeneric &rEvt, CtrlGeneric &rCtrl );
62
63     // Refresh an area of the window
64     virtual void refresh( int left, int top, int width, int height );
65
66     /// Get the active layout
67     virtual const GenericLayout& getActiveLayout() const;
68
69     /// Update the shape of the window from the active layout
70     virtual void updateShape();
71
72     /// Called by a control that wants to capture the mouse
73     virtual void onControlCapture( const CtrlGeneric &rCtrl );
74
75     /// Called by a control that wants to release the mouse
76     virtual void onControlRelease( const CtrlGeneric &rCtrl );
77
78     /// Called by a control when its tooltip changed
79     virtual void onTooltipChange( const CtrlGeneric &rCtrl );
80
81     /// Get the "maximized" variable
82     VarBool &getMaximizedVar() { return *m_pVarMaximized; }
83
84     /// Get the initial visibility status
85     bool isVisible() const { return m_visible; }
86
87 protected:
88     /// Actually show the window
89     virtual void innerShow();
90
91     /// Actually hide the window
92     virtual void innerHide();
93
94 private:
95     /**
96      * These methods are only used by the window manager
97      */
98     //@{
99     /// Change the active layout
100     virtual void setActiveLayout( GenericLayout *pLayout );
101     //@}
102
103     /// Initial visibility status
104     bool m_visible;
105     /// Window manager
106     WindowManager &m_rWindowManager;
107     /// Current active layout of the window
108     GenericLayout *m_pActiveLayout;
109     /// Last control on which the mouse was over
110     CtrlGeneric *m_pLastHitControl;
111     /// Control that has captured the mouse
112     CtrlGeneric *m_pCapturingControl;
113     /// Control that has the focus
114     CtrlGeneric *m_pFocusControl;
115     /// Current key modifier (also used for mouse)
116     int m_currModifier;
117
118     /// Variable for the visibility of the window
119     VarBoolImpl *m_pVarMaximized;
120
121     /**
122      * Find the uppest control in the layout hit by the mouse, and send
123      * it an enter event if needed
124      */
125     CtrlGeneric *findHitControl( int xPos, int yPos );
126
127     /**
128      * Update the lastHitControl pointer and send a leave event to the
129      * right control
130      */
131     void setLastHit( CtrlGeneric *pNewHitControl );
132 };
133
134 typedef CountedPtr<TopWindow> TopWindowPtr;
135
136
137 #endif