skins2: cosmetics
[vlc.git] / modules / gui / skins2 / src / generic_window.hpp
blob5753b7162ba05516818c2998919e1e1313fbf516
1 /*****************************************************************************
2 * generic_window.hpp
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
5 * $Id$
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 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 *****************************************************************************/
25 #ifndef GENERIC_WINDOW_HPP
26 #define GENERIC_WINDOW_HPP
28 #include "skin_common.hpp"
29 #include "../utils/var_bool.hpp"
30 #include "vlc_vout_window.h"
32 class OSWindow;
33 class EvtGeneric;
34 class EvtFocus;
35 class EvtLeave;
36 class EvtMenu;
37 class EvtMotion;
38 class EvtMouse;
39 class EvtKey;
40 class EvtRefresh;
41 class EvtScroll;
42 class EvtDragEnter;
43 class EvtDragLeave;
44 class EvtDragOver;
45 class EvtDragDrop;
46 class WindowManager;
49 /// Generic window class
50 class GenericWindow: public SkinObject, public Observer<VarBool>
52 private:
53 friend class WindowManager;
54 friend class VoutManager;
55 friend class CtrlVideo;
56 public:
58 enum WindowType_t
60 TopWindow,
61 VoutWindow,
62 FullscreenWindow,
63 FscWindow,
66 GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
67 bool dragDrop, bool playOnDrop,
68 GenericWindow *pParent = NULL,
69 WindowType_t type = TopWindow );
70 virtual ~GenericWindow();
72 /// Methods to process OS events.
73 virtual void processEvent( EvtFocus &rEvtFocus ) { (void)rEvtFocus; }
74 virtual void processEvent( EvtMenu &rEvtMenu ) { (void)rEvtMenu; }
75 virtual void processEvent( EvtMotion &rEvtMotion ) { (void)rEvtMotion; }
76 virtual void processEvent( EvtMouse &rEvtMouse ) { (void)rEvtMouse; }
77 virtual void processEvent( EvtLeave &rEvtLeave ) { (void)rEvtLeave; }
78 virtual void processEvent( EvtKey &rEvtKey ) { (void)rEvtKey; }
79 virtual void processEvent( EvtScroll &rEvtScroll ) { (void)rEvtScroll; }
81 virtual void processEvent( EvtDragEnter &rEvtDragEnter )
82 { (void)rEvtDragEnter; }
83 virtual void processEvent( EvtDragLeave &rEvtDragLeave )
84 { (void)rEvtDragLeave; }
85 virtual void processEvent( EvtDragOver &rEvtDragOver )
86 { (void)rEvtDragOver; }
87 virtual void processEvent( EvtDragDrop &rEvtDragDrop )
88 { (void)rEvtDragDrop; }
90 virtual void processEvent( EvtRefresh &rEvtRefresh );
92 /// Resize the window
93 virtual void resize( int width, int height );
95 /// Refresh an area of the window
96 virtual void refresh( int left, int top, int width, int height )
97 { (void)left; (void)top; (void)width; (void)height; }
99 /// Invalidate an area of the window
100 virtual void invalidateRect( int left, int top, int width, int height );
102 /// Get the coordinates of the window
103 int getLeft() const { return m_left; }
104 int getTop() const { return m_top; }
105 int getWidth() const { return m_width; }
106 int getHeight() const { return m_height; }
107 void getMonitorInfo( int* x, int* y, int* width, int* height ) const;
109 /// Give access to the visibility variable
110 VarBool &getVisibleVar() { return *m_pVarVisible; }
112 /// Window type, mainly useful when overloaded (for VoutWindow)
113 virtual std::string getType() const { return "Generic"; }
115 /// window handle
116 void updateWindowConfiguration( vout_window_t *pWnd ) const;
118 /// window type
119 WindowType_t getType() { return m_type; }
121 /// reparent
122 void setParent( GenericWindow* pParent,
123 int x = 0, int y = 0, int w = -1, int h = -1 );
125 /// Get the OS window
126 OSWindow *getOSWindow() const { return m_pOsWindow; }
128 protected:
130 /// These methods do not need to be public since they are accessed
131 /// only by the window manager or by inheritant classes.
132 //@{
133 /// Show the window
134 virtual void show() const;
136 /// Hide the window
137 virtual void hide() const;
139 /// Move the window
140 virtual void move( int left, int top );
142 /// Bring the window on top
143 virtual void raise() const;
145 /// Set the opacity of the window (0 = transparent, 255 = opaque)
146 virtual void setOpacity( uint8_t value );
148 /// Toggle the window on top
149 virtual void toggleOnTop( bool onTop ) const;
150 //@}
152 /// Actually show the window
153 virtual void innerShow();
155 /// Actually hide the window
156 virtual void innerHide();
159 bool isVisible() const { return m_pVarVisible->get(); }
161 /// Method called when the observed variable is modified
162 virtual void onUpdate( Subject<VarBool> &rVariable , void*);
164 private:
165 WindowType_t m_type;
166 /// Window position and size
167 int m_left, m_top, m_width, m_height;
168 /// OS specific implementation
169 OSWindow *m_pOsWindow;
170 /// Variable for the visibility of the window
171 mutable VarBoolImpl *m_pVarVisible;
175 #endif