1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 #ifndef GENERIC_WINDOW_HPP
26 #define GENERIC_WINDOW_HPP
28 #include "skin_common.hpp"
29 #include "../utils/pointer.hpp"
30 #include "../utils/var_bool.hpp"
49 /// Generic window class
50 class GenericWindow: public SkinObject, public Observer<VarBool>
53 GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
54 WindowManager &rWindowManager,
55 bool dragDrop, bool playOnDrop );
56 virtual ~GenericWindow();
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 );
67 /// Forward an event to a control
68 virtual void forwardEvent( EvtGeneric &rEvt, CtrlGeneric &rCtrl );
76 // Refresh an area of the window
77 virtual void refresh( int left, int top, int width, int height );
80 virtual void move( int left, int top );
83 virtual void resize( int width, int height );
85 /// Bring the window on top
86 virtual void raise() const;
88 /// Set the opacity of the window (0 = transparent, 255 = opaque)
89 virtual void setOpacity( uint8_t value );
91 /// Toggle the window on top
92 virtual void toggleOnTop( bool onTop ) const;
94 /// Change the active layout
95 virtual void setActiveLayout( GenericLayout *pLayout );
97 /// Update the shape of the window from the active layout
98 virtual void updateShape();
100 /// Called by a control that wants to capture the mouse
101 virtual void onControlCapture( const CtrlGeneric &rCtrl );
103 /// Called by a control that wants to release the mouse
104 virtual void onControlRelease( const CtrlGeneric &rCtrl );
106 /// Called by a control when its tooltip changed
107 virtual void onTooltipChange( const CtrlGeneric &rCtrl );
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; }
115 /// Give access to the visibility variable
116 VarBool &getVisibleVar() { return m_varVisible; }
118 /// Get the list of the anchors of this window
119 virtual const list<Anchor*> getAnchorList() const;
121 /// Add an anchor to this window
122 virtual void addAnchor( Anchor *pAnchor );
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;
144 /// Method called when the observed variable is modified
145 virtual void onUpdate( Subject<VarBool> &rVariable );
147 // Actually show the window
148 virtual void innerShow();
150 // Actually hide the window
151 virtual void innerHide();
153 /// Find the uppest control in the layout hit by the mouse, and send
154 /// it an enter event if needed
155 CtrlGeneric *findHitControl( int xPos, int yPos );
157 /// Update the lastHitControl pointer and send a leave event to the
159 void setLastHit( CtrlGeneric *pNewHitControl );
162 typedef CountedPtr<GenericWindow> GenericWindowPtr;