]> git.sesse.net Git - vlc/blob - modules/gui/skins2/win32/win32_factory.hpp
skins(Win32): fix minimize not functioning (see #3300)
[vlc] / modules / gui / skins2 / win32 / win32_factory.hpp
1 /*****************************************************************************
2  * win32_factory.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 WIN32_FACTORY_HPP
26 #define WIN32_FACTORY_HPP
27
28 #ifndef _WIN32_WINNT
29 #   define _WIN32_WINNT 0x0500
30 #endif
31
32 #include <windows.h>
33 #include <shellapi.h>
34 // #include <wingdi.h>
35 #include "../src/os_factory.hpp"
36 #include "../src/generic_window.hpp"
37
38 #include <map>
39
40
41 /// Class used to instanciate Win32 specific objects
42 class Win32Factory: public OSFactory
43 {
44 public:
45     Win32Factory( intf_thread_t *pIntf );
46     virtual ~Win32Factory();
47
48     /// Initialization method
49     virtual bool init();
50
51     /// Instantiate an object OSGraphics
52     virtual OSGraphics *createOSGraphics( int width, int height );
53
54     /// Get the instance of the singleton OSLoop
55     virtual OSLoop *getOSLoop();
56
57     /// Destroy the instance of OSLoop
58     virtual void destroyOSLoop();
59
60     /// Minimize all the windows
61     virtual void minimize();
62
63     /// Restore the minimized windows
64     virtual void restore();
65
66     /// Add an icon in the system tray
67     virtual void addInTray();
68
69     /// Remove the icon from the system tray
70     virtual void removeFromTray();
71
72     /// Show the task in the task bar
73     virtual void addInTaskBar();
74
75     /// Remove the task from the task bar
76     virtual void removeFromTaskBar();
77
78     /// Instantiate an OSTimer with the given command
79     virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
80
81     /// Instantiate an OSWindow object
82     virtual OSWindow *createOSWindow( GenericWindow &rWindow,
83                                       bool dragDrop, bool playOnDrop,
84                                       OSWindow *pParent,
85                                       GenericWindow::WindowType_t type );
86
87     /// Instantiate an object OSTooltip
88     virtual OSTooltip *createOSTooltip();
89
90     /// Instantiate an object OSPopup
91     virtual OSPopup *createOSPopup();
92
93     /// Get the directory separator
94     virtual const string &getDirSeparator() const { return m_dirSep; }
95
96     /// Get the resource path
97     virtual const list<string> &getResourcePath() const
98         { return m_resourcePath; }
99
100     /// Get the screen size
101     virtual int getScreenWidth() const;
102     virtual int getScreenHeight() const;
103
104     /// Get the work area (screen area without taskbars)
105     virtual SkinsRect getWorkArea() const;
106
107     /// Get the position of the mouse
108     virtual void getMousePos( int &rXPos, int &rYPos ) const;
109
110     /// Change the cursor
111     virtual void changeCursor( CursorType_t type ) const;
112
113     /// Delete a directory recursively
114     virtual void rmDir( const string &rPath );
115
116     /// Map to find the GenericWindow associated with a Win32Window
117     map<HWND, GenericWindow*> m_windowMap;
118
119     /// Functions dynamically loaded from the dll, because they don't exist
120     /// on Win9x/NT4
121     // We dynamically load msimg32.dll to get a pointer to TransparentBlt()
122     BOOL (WINAPI *TransparentBlt)( HDC, int, int, int, int,
123                                    HDC, int, int, int, int, UINT );
124     BOOL (WINAPI *AlphaBlend)( HDC, int, int, int, int,
125                                HDC, int, int, int, int, BLENDFUNCTION );
126
127     // Idem for user32.dll and SetLayeredWindowAttributes()
128     BOOL (WINAPI *SetLayeredWindowAttributes)( HWND, COLORREF,
129                                                BYTE, DWORD );
130
131     HWND getParentWindow() { return m_hParentWindow; }
132
133 private:
134     /// Handle of the instance
135     HINSTANCE m_hInst;
136     /// Handle of the parent window
137     HWND m_hParentWindow;
138     /// Structure for the system tray
139     NOTIFYICONDATA m_trayIcon;
140     /// Handle on msimg32.dll (for TransparentBlt)
141     HINSTANCE m_hMsimg32;
142     /// Handle on user32.dll (for SetLayeredWindowAttributes)
143     HINSTANCE m_hUser32;
144     /// Directory separator
145     const string m_dirSep;
146     /// Resource path
147     list<string> m_resourcePath;
148 };
149
150
151 #endif