1 /* 2 3 Boost Software License - Version 1.0 - August 17th, 2003 4 5 Permission is hereby granted, free of charge, to any person or organization 6 obtaining a copy of the software and accompanying documentation covered by 7 this license ( the "Software" ) to use, reproduce, display, distribute, 8 execute, and transmit the Software, and to prepare derivative works of the 9 Software, and to permit third-parties to whom the Software is furnished to 10 do so, all subject to the following: 11 12 The copyright notices in the Software and this entire statement, including 13 the above license grant, this restriction and the following disclaimer, 14 must be included in all copies of the Software, in whole or in part, and 15 all derivative works of the Software, unless such copies or derivative 16 works are solely in the form of machine-executable object code generated by 17 a source language processor. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 DEALINGS IN THE SOFTWARE. 26 27 */ 28 module derelict.util.wintypes; 29 30 /* 31 This module is used internally to avoid any dependence upon external Win32 modules. 32 Considering that there are modules in Phobos, Tango, and the Bindings project at 33 DSource, we want to avoid any conflicts with whichever implementation Derelict users choose. 34 */ 35 version( Windows ) { 36 alias uint DWORD; 37 alias ushort WORD; 38 alias ushort USHORT; 39 alias uint UINT; 40 alias int INT; 41 alias int LONG; 42 alias ubyte BYTE; 43 alias float FLOAT; 44 alias int BOOL; 45 alias DWORD COLORREF; 46 47 alias const( char* ) LPCSTR; 48 alias void* LPVOID; 49 50 alias void* HANDLE; 51 alias HANDLE HDC; 52 alias HANDLE HGLRC; 53 alias HANDLE HINSTANCE; 54 alias HANDLE HMODULE; 55 alias HANDLE HWND; 56 alias HANDLE HLOCAL; 57 alias HANDLE HPALETTE; 58 alias HANDLE HBITMAP; 59 60 alias UINT WPARAM; 61 alias LONG LPARAM; 62 63 alias int function( ) FARPROC; 64 65 struct LAYERPLANEDESCRIPTOR { 66 WORD nSize; 67 WORD nVersion; 68 DWORD dwFlags; 69 BYTE iPixelType; 70 BYTE cColorBits; 71 BYTE cRedBits; 72 BYTE cRedShift; 73 BYTE cGreenBits; 74 BYTE cGreenShift; 75 BYTE cBlueBits; 76 BYTE cBlueShift; 77 BYTE cAlphaBits; 78 BYTE cAlphaShift; 79 BYTE cAccumBits; 80 BYTE cAccumRedBits; 81 BYTE cAccumGreenBits; 82 BYTE cAccumBlueBits; 83 BYTE cAccumAlphaBits; 84 BYTE cDepthBits; 85 BYTE cStencilBits; 86 BYTE cAuxBuffers; 87 BYTE iLayerPlane; 88 BYTE bReserved; 89 COLORREF crTransparent; 90 } 91 92 struct POINTFLOAT { 93 FLOAT x; 94 FLOAT y; 95 } 96 97 struct GLYPHMETRICSFLOAT { 98 FLOAT gmfBlackBoxX; 99 FLOAT gmfBlackBoxY; 100 POINTFLOAT gmfptGlyphOrigin; 101 FLOAT gmfCellIncX; 102 FLOAT gmfCellIncY; 103 } 104 105 struct PIXELFORMATDESCRIPTOR { 106 WORD nSize; 107 WORD nVersion; 108 DWORD dwFlags; 109 BYTE iPixelType; 110 BYTE cColorBits; 111 BYTE cRedBits; 112 BYTE cRedShift; 113 BYTE cGreenBits; 114 BYTE cGreenShift; 115 BYTE cBlueBits; 116 BYTE cBlueShift; 117 BYTE cAlphaBits; 118 BYTE cAlphaShift; 119 BYTE cAccumBits; 120 BYTE cAccumRedBits; 121 BYTE cAccumGreenBits; 122 BYTE cAccumBlueBits; 123 BYTE cAccumAlphaBits; 124 BYTE cDepthBits; 125 BYTE cStencilBits; 126 BYTE cAuxBuffers; 127 BYTE iLayerType; 128 BYTE bReserved; 129 DWORD dwLayerMask; 130 DWORD dwVisibleMask; 131 DWORD dwDamageMask; 132 } 133 134 struct VA_LIST {} 135 136 enum : BYTE { 137 PFD_TYPE_RGBA = 0, 138 PFD_TYPE_COLORINDEX = 1 139 } 140 141 enum { 142 PFD_MAIN_PLANE = 0, 143 PFD_OVERLAY_PLANE = 1, 144 PFD_UNDERLAY_PLANE = -1 145 } 146 147 enum { 148 PFD_DOUBLEBUFFER = 0x00000001, 149 PFD_STEREO = 0x00000002, 150 PFD_DRAW_TO_WINDOW = 0x00000004, 151 PFD_DRAW_TO_BITMAP = 0x00000008, 152 PFD_SUPPORT_GDI = 0x00000010, 153 PFD_SUPPORT_OPENGL = 0x00000020, 154 PFD_GENERIC_FORMAT = 0x00000040, 155 PFD_NEED_PALETTE = 0x00000080, 156 PFD_NEED_SYSTEM_PALETTE = 0x00000100, 157 PFD_SWAP_EXCHANGE = 0x00000200, 158 PFD_SWAP_COPY = 0x00000400, 159 PFD_SWAP_LAYER_BUFFERS = 0x00000800, 160 PFD_GENERIC_ACCELERATED = 0x00001000, 161 PFD_SUPPORT_DIRECTDRAW = 0x00002000, 162 PFD_DEPTH_DONTCARE = 0x20000000, 163 PFD_DOUBLBUFFER_DONTCARE = 0x40000000, 164 PFD_STEREO_DONTCARE = 0x80000000, 165 } 166 167 enum { 168 LANG_NEUTRAL = 0, 169 SUBLANG_DEFAULT = 1, 170 FORMAT_MESSAGE_ALLOCATE_BUFFER = 256, 171 FORMAT_MESSAGE_IGNORE_INSERTS = 512, 172 FORMAT_MESSAGE_FROM_SYSTEM = 4096 173 } 174 175 struct RGBQUAD { 176 BYTE rgbBlue; 177 BYTE rgbGreen; 178 BYTE rgbRed; 179 BYTE rgbReserved; 180 } 181 182 struct BITMAPINFOHEADER { 183 DWORD biSize; 184 LONG biWidth; 185 LONG biHeight; 186 WORD biPlanes; 187 WORD biBitCount; 188 DWORD biCompression; 189 DWORD biSizeImage; 190 LONG biXPelsPerMeter; 191 LONG biYPelsPerMeter; 192 DWORD biClrUsed; 193 DWORD biClrImportant; 194 } 195 196 struct BITMAPINFO { 197 BITMAPINFOHEADER bmiHeader; 198 RGBQUAD[1] bmiColors; 199 } 200 201 struct RECT { 202 LONG left; 203 LONG top; 204 LONG right; 205 LONG bottom; 206 } 207 208 extern( Windows ) nothrow { 209 HDC GetDC( HWND ); 210 int ChoosePixelFormat( HDC,PIXELFORMATDESCRIPTOR* ); 211 void SetPixelFormat( HDC,int,PIXELFORMATDESCRIPTOR* ); 212 int GetPixelFormat( HDC ); 213 int DescribePixelFormat( HDC,int,UINT,PIXELFORMATDESCRIPTOR* ); 214 BOOL SwapBuffers( HDC ); 215 216 HMODULE LoadLibraryA( LPCSTR ); 217 FARPROC GetProcAddress( HMODULE, LPCSTR ); 218 void FreeLibrary( HMODULE ); 219 DWORD GetLastError( ); 220 DWORD FormatMessageA( DWORD, in void*, DWORD, DWORD, LPCSTR, DWORD, VA_LIST* ); 221 HLOCAL LocalFree( HLOCAL ); 222 } 223 224 DWORD MAKELANGID( WORD p, WORD s ) { 225 return ( ( ( cast( WORD )s ) << 10 ) | cast( WORD )p ); 226 } 227 }