1 /***************************************************************************** 2 * win32_factory.hpp 3 ***************************************************************************** 4 * Copyright (C) 2003 the VideoLAN team 5 * $Id: c5bf1b08decba27a19e1c97501000697de4b3dee $ 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 #ifdef HAVE_CONFIG_H 29 # include "config.h" 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 getDirSeparator() const94 virtual const std::string &getDirSeparator() const { return m_dirSep; } 95 96 /// Get the resource path getResourcePath() const97 virtual const std::list<std::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 Monitor Information 105 virtual void getMonitorInfo( const GenericWindow &rWindow, 106 int* x, int* y, 107 int* width, int* height ) const; 108 virtual void getMonitorInfo( int numScreen, 109 int* x, int* y, 110 int* width, int* height ) const; 111 112 /// Get the work area (screen area without taskbars) 113 virtual SkinsRect getWorkArea() const; 114 115 /// Get the position of the mouse 116 virtual void getMousePos( int &rXPos, int &rYPos ) const; 117 118 /// Change the cursor 119 virtual void changeCursor( CursorType_t type ) const; 120 121 /// Delete a directory recursively 122 virtual void rmDir( const std::string &rPath ); 123 124 /// Map to find the GenericWindow associated with a Win32Window 125 std::map<HWND, GenericWindow*> m_windowMap; 126 getParentWindow()127 HWND getParentWindow() { return m_hParentWindow; } 128 129 /// Callback function (Windows Procedure) 130 static LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, 131 WPARAM wParam, LPARAM lParam ); 132 133 /// Callback (enumerate multiple screens) 134 static BOOL CALLBACK MonitorEnumProc( HMONITOR hMonitor, HDC hdcMonitor, 135 LPRECT lprcMonitor, LPARAM dwData ); 136 private: 137 /// Handle of the instance 138 HINSTANCE m_hInst; 139 /// Handle of the parent window 140 HWND m_hParentWindow; 141 /// Structure for the system tray 142 NOTIFYICONDATA m_trayIcon; 143 /// Handle on msimg32.dll (for TransparentBlt) 144 HINSTANCE m_hMsimg32; 145 /// Handle on user32.dll (for SetLayeredWindowAttributes) 146 HINSTANCE m_hUser32; 147 /// Directory separator 148 const std::string m_dirSep; 149 /// Resource path 150 std::list<std::string> m_resourcePath; 151 /// Monitors detected 152 std::list<HMONITOR> m_monitorList; 153 }; 154 155 156 #endif 157