1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
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.
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.
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 *****************************************************************************/
25 #ifndef TOP_WINDOW_HPP
26 #define TOP_WINDOW_HPP
28 #include "generic_window.hpp"
29 #include "../utils/pointer.hpp"
39 /// Class to handle top-level windows
40 class TopWindow: public GenericWindow
43 friend class WindowManager;
45 TopWindow( intf_thread_t *pIntf, int xPos, int yPos,
46 WindowManager &rWindowManager,
47 bool dragDrop, bool playOnDrop, bool visible );
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 );
60 /// Forward an event to a control
61 virtual void forwardEvent( EvtGeneric &rEvt, CtrlGeneric &rCtrl );
63 // Refresh an area of the window
64 virtual void refresh( int left, int top, int width, int height );
66 /// Get the active layout
67 virtual const GenericLayout& getActiveLayout() const;
69 /// Update the shape of the window from the active layout
70 virtual void updateShape();
72 /// Called by a control that wants to capture the mouse
73 virtual void onControlCapture( const CtrlGeneric &rCtrl );
75 /// Called by a control that wants to release the mouse
76 virtual void onControlRelease( const CtrlGeneric &rCtrl );
78 /// Called by a control when its tooltip changed
79 virtual void onTooltipChange( const CtrlGeneric &rCtrl );
81 /// Get the initial visibility status
82 bool isVisible() const { return m_visible; }
85 /// Actually show the window
86 virtual void innerShow();
89 /// Change the active layout
90 virtual void setActiveLayout( GenericLayout *pLayout );
92 /// Initial visibility status
95 WindowManager &m_rWindowManager;
96 /// Current active layout of the window
97 GenericLayout *m_pActiveLayout;
98 /// Last control on which the mouse was over
99 CtrlGeneric *m_pLastHitControl;
100 /// Control that has captured the mouse
101 CtrlGeneric *m_pCapturingControl;
102 /// Control that has the focus
103 CtrlGeneric *m_pFocusControl;
104 /// Current key modifier (also used for mouse)
107 /// Find the uppest control in the layout hit by the mouse, and send
108 /// it an enter event if needed
109 CtrlGeneric *findHitControl( int xPos, int yPos );
111 /// Update the lastHitControl pointer and send a leave event to the
113 void setLastHit( CtrlGeneric *pNewHitControl );
116 typedef CountedPtr<TopWindow> TopWindowPtr;