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