X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/57c208c5759da71a637f0f0f5b7d3dc3eda09c02..e7300ec6d9ebbd1cfa2fcf12c0ce6e5aee85a152:/src/msw/curico.cpp?ds=sidebyside diff --git a/src/msw/curico.cpp b/src/msw/curico.cpp index 4811882fac..34b895da03 100644 --- a/src/msw/curico.cpp +++ b/src/msw/curico.cpp @@ -19,14 +19,19 @@ #include #include -#ifndef __TWIN32__ -#ifdef __GNUWIN32__ -#include "wx/msw/gnuwin32/extra.h" +#if defined(__MWERKS__) +#include +#include #endif + +#ifdef __GNUWIN32_OLD__ + #include "wx/msw/gnuwin32/extra.h" #endif +#include "wx/wxchar.h" #include "wx/msw/curicop.h" #include "wx/msw/curico.h" +#include "wx/string.h" //***************************************************************************** //* Function : ReadIconFile() * @@ -37,7 +42,7 @@ //* be created for any reason. * //***************************************************************************** -HICON ReadIconFile( char *szFileName, HINSTANCE hInst, int *W, int *H) +HICON ReadIconFile( wxChar *szFileName, HINSTANCE hInst, int *W, int *H) { HICON hIcon; HANDLE hDIB; @@ -60,7 +65,7 @@ HICON ReadIconFile( char *szFileName, HINSTANCE hInst, int *W, int *H) //* monochrome. * //***************************************************************************** -HICON CursorToIcon( char *szFileName, HINSTANCE hInst, int *W, int *H) +HICON CursorToIcon( wxChar *szFileName, HINSTANCE hInst, int *W, int *H) { HANDLE hDIB; // Handle to DIB memory HICON hIcon; // Handle to Icon @@ -80,10 +85,10 @@ HICON CursorToIcon( char *szFileName, HINSTANCE hInst, int *W, int *H) //* is corrupt or if memory cannot be allocated for the DIB info. * //***************************************************************************** -HANDLE ReadIcon( char *szFileName, int *W, int *H) +HANDLE ReadIcon( wxChar *szFileName, int *W, int *H) { ICONFILEHEADER iconFileHead; // ICON file header structure ICONFILERES iconFileRes; // ICON file resource - WORD cbHead, + UINT cbHead, cbRes, cbBits; // Used for reading in file int hFile; // File handle @@ -94,7 +99,7 @@ HANDLE ReadIcon( char *szFileName, int *W, int *H) nDirEntries = 0; // Open and read the .ICO file header and the first ICONFILERES - hFile = _lopen( szFileName, OF_READ); + hFile = _lopen( wxConvertWX2MB(szFileName), OF_READ); cbHead = _lread( hFile, (LPSTR)&iconFileHead, sizeof(ICONFILEHEADER)); cbRes = _lread( hFile, (LPSTR)&iconFileRes, sizeof(ICONFILERES)); ++nDirEntries; @@ -170,7 +175,7 @@ HANDLE ReadIcon( char *szFileName, int *W, int *H) //* bitmaps. So, no need to convert the AND bitmask. * //* 7) Since a DIB is stored upside down, flip the monochrome AND bits* //* by scanlines. * -//* 8) Use the XOR and AND bits and create an icon with CreateIcon. * +//* 8) Use the XOR and AND bits and create an icon with CreateIcon. * //***************************************************************************** HICON MakeIcon( HANDLE hDIB, HINSTANCE hInst) @@ -211,7 +216,7 @@ HICON MakeIcon( HANDLE hDIB, HINSTANCE hInst) lpDIB->bmiHeader.biBitCount))); // Get a hDC so we can create a bitmap compatible with it - hDC = CreateDC( "DISPLAY", NULL, NULL, NULL); + hDC = CreateDC( wxT("DISPLAY"), NULL, NULL, NULL); // 5) Create a device dependent bitmap with the XOR bits. hbmXor = CreateDIBitmap( hDC, (LPBITMAPINFOHEADER)&(lpDIB->bmiHeader), @@ -248,8 +253,8 @@ HICON MakeIcon( HANDLE hDIB, HINSTANCE hInst) szFlip[(k - 1) - j] = *(DWORD FAR *)lpANDbits; // 8) Use the XOR and AND bits and create an icon with CreateIcon. - hIcon = CreateIcon( hInst, bmpXor.bmWidth, bmpXor.bmHeight, bmpXor.bmPlanes, - bmpXor.bmBitsPixel, (const BYTE *)szFlip, (const BYTE *)lpXorDDB); + hIcon = CreateIcon( hInst, bmpXor.bmWidth, bmpXor.bmHeight, (BYTE)bmpXor.bmPlanes, + (BYTE)bmpXor.bmBitsPixel, (const BYTE *)szFlip, (const BYTE *)lpXorDDB); // Clean up before exiting. DeleteObject( hbmXor); @@ -272,7 +277,7 @@ HICON MakeIcon( HANDLE hDIB, HINSTANCE hInst) //* be created for any reason. * //***************************************************************************** -HCURSOR ReadCursorFile( char *szFileName, HINSTANCE hInst, int *W, int *H, +HCURSOR ReadCursorFile( wxChar *szFileName, HINSTANCE hInst, int *W, int *H, int *XHot, int *YHot) { HANDLE hDIB; // Handle to DIB memory HCURSOR hCursor; @@ -301,7 +306,7 @@ HCURSOR ReadCursorFile( char *szFileName, HINSTANCE hInst, int *W, int *H, //* monochrome. * //***************************************************************************** -HCURSOR IconToCursor( char *szFileName, HINSTANCE hInst, int XHot, int YHot, +HCURSOR IconToCursor( wxChar *szFileName, HINSTANCE hInst, int XHot, int YHot, int *W, int *H) { HCURSOR hCursor; HANDLE hDIB; @@ -327,10 +332,10 @@ HCURSOR IconToCursor( char *szFileName, HINSTANCE hInst, int XHot, int YHot, //* is corrupt or if memory cannot be allocated for the DIB info. * //***************************************************************************** -HANDLE ReadCur( char *szFileName, LPPOINT lpptHotSpot, int *W, int *H) +HANDLE ReadCur( wxChar *szFileName, LPPOINT lpptHotSpot, int *W, int *H) { CURFILEHEADER curFileHead; // CURSOR file header structure CURFILERES curFileRes; // CURSOR file resource - WORD cbHead, + UINT cbHead, cbRes, cbBits; // Used for reading in file LPBITMAPINFO lpDIB; // Pointer to DIB memory @@ -341,7 +346,7 @@ HANDLE ReadCur( char *szFileName, LPPOINT lpptHotSpot, int *W, int *H) nDirEntries = 0; // Open and read the .ICO file header and the first ICONFILERES - hFile = _lopen( szFileName, OF_READ); + hFile = _lopen( wxConvertWX2MB(szFileName), OF_READ); cbHead = _lread( hFile, (LPSTR )&curFileHead, sizeof( CURFILEHEADER)); cbRes = _lread( hFile, (LPSTR )&curFileRes, sizeof( CURFILERES)); ++nDirEntries; @@ -572,7 +577,7 @@ HCURSOR MakeCursor( HANDLE hDIB, LPPOINT lpptHotSpot, HINSTANCE hInst) lpDIB->bmiHeader.biBitCount))); // Get a hDC so we can create a bitmap compatible with it - hDC = CreateDC( "DISPLAY", NULL, NULL, NULL); + hDC = CreateDC( wxT("DISPLAY"), NULL, NULL, NULL); // 5) Create a device dependent bitmap with the XOR bits. hbmXor = CreateBitmap( (int )lpDIB->bmiHeader.biWidth, @@ -639,9 +644,9 @@ WORD PaletteSize( LPSTR pv) NumColors = DIBNumColors((LPSTR )lpbi); if(lpbi->biSize == sizeof( BITMAPCOREHEADER)) // OS/2 style DIBs - return NumColors * sizeof( RGBTRIPLE); + return (WORD)(NumColors * sizeof( RGBTRIPLE)); else - return NumColors * sizeof( RGBQUAD); + return (WORD)(NumColors * sizeof( RGBQUAD)); } //***************************************************************************** @@ -667,7 +672,7 @@ WORD DIBNumColors ( LPSTR pv) // is in biClrUsed, whereas in the BITMAPCORE - style headers, it // is dependent on the bits per pixel ( = 2 raised to the power of // bits/pixel). - + if(lpbi->biSize != sizeof( BITMAPCOREHEADER)) { if(lpbi->biClrUsed != 0) @@ -693,7 +698,7 @@ WORD DIBNumColors ( LPSTR pv) #if 0 // ****************************************************************** -BOOL fGetXPixmap( BOOL fIsIcon, char *szFileName, HINSTANCE hInst, +BOOL fGetXPixmap( BOOL fIsIcon, wxChar *szFileName, HINSTANCE hInst, char cData[], int &width, int &height) { HDC hdc, hdcMemory; @@ -815,10 +820,17 @@ HCURSOR MakeCursorFromBitmap(HINSTANCE hInst, HBITMAP hBitmap, POINT *pPoint) DeleteObject(hXorBmp); ReleaseDC(NULL, hDC); #ifndef __WIN32__ +#ifdef STRICT + LocalUnlock(LocalHandle((void NEAR*) andBits)); + LocalUnlock(LocalHandle((void NEAR*) xorBits)); + LocalFree(LocalHandle((void NEAR*) andBits)); + LocalFree(LocalHandle((void NEAR*) xorBits)); +#else LocalUnlock(LocalHandle((WORD) andBits)); LocalUnlock(LocalHandle((WORD) xorBits)); LocalFree(LocalHandle((WORD) andBits)); LocalFree(LocalHandle((WORD) xorBits)); +#endif #else LocalUnlock(LocalHandle((LPCVOID) andBits)); LocalUnlock(LocalHandle((LPCVOID) xorBits)); @@ -831,7 +843,7 @@ HCURSOR MakeCursorFromBitmap(HINSTANCE hInst, HBITMAP hBitmap, POINT *pPoint) /* * This doesn't work: just gives us a grey square. Ideas, anyone? */ - + HICON MakeIconFromBitmap(HINSTANCE hInst, HBITMAP hBitmap) { HDC hDCColor, hDCMono; @@ -886,10 +898,17 @@ HICON MakeIconFromBitmap(HINSTANCE hInst, HBITMAP hBitmap) DeleteObject(hXorBmp); ReleaseDC((HWND) NULL, hDC); #ifndef __WIN32__ +#ifdef STRICT + LocalUnlock(LocalHandle((void NEAR*) andBits)); + LocalUnlock(LocalHandle((void NEAR*) xorBits)); + LocalFree(LocalHandle((void NEAR*) andBits)); + LocalFree(LocalHandle((void NEAR*) xorBits)); +#else LocalUnlock(LocalHandle((WORD) andBits)); LocalUnlock(LocalHandle((WORD) xorBits)); LocalFree(LocalHandle((WORD) andBits)); LocalFree(LocalHandle((WORD) xorBits)); +#endif #else LocalUnlock(LocalHandle((LPCVOID) andBits)); LocalUnlock(LocalHandle((LPCVOID) xorBits));