From 419430a0c006cd6830c2c8a768ba850531ec6a18 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 15 Sep 2003 08:55:19 +0000 Subject: [PATCH] WinCE bitmap patch from Johannes Schindelin git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23592 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/wince/helpwce.h | 3 +- src/msw/dc.cpp | 8 +-- src/msw/gdiimage.cpp | 93 ++++++++++++++++++++++++++++++++++ src/msw/wince/helpwce.cpp | 3 +- src/msw/window.cpp | 2 + 5 files changed, 104 insertions(+), 5 deletions(-) diff --git a/include/wx/msw/wince/helpwce.h b/include/wx/msw/wince/helpwce.h index f3ccfc4410..2076ee2090 100644 --- a/include/wx/msw/wince/helpwce.h +++ b/include/wx/msw/wince/helpwce.h @@ -37,7 +37,8 @@ public: virtual bool DisplayBlock(long blockNo); virtual bool DisplayContextPopup(int contextId); virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos); - virtual bool KeywordSearch(const wxString& k); + virtual bool KeywordSearch(const wxString& k, + wxHelpSearchMode mode = wxHELP_SEARCH_ALL); virtual bool Quit(); wxString GetHelpFile() const { return m_helpFile; } diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 2f2d0e54a5..f3c558bf11 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -572,7 +572,7 @@ bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) } CalcBoundingBox(x, y); - + return success; #endif } @@ -2047,8 +2047,12 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, } if ( !success && (caps & RC_STRETCHBLT) ) +#endif + // __WXWINCE__ { +#ifndef __WXWINCE__ StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR); +#endif if ( !::StretchBlt ( @@ -2086,8 +2090,6 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, success = TRUE; } } -#endif - // __WXWINCE__ } ::SetTextColor(GetHdc(), old_textground); diff --git a/src/msw/gdiimage.cpp b/src/msw/gdiimage.cpp index 2e6ae1b7f5..d5b356119e 100644 --- a/src/msw/gdiimage.cpp +++ b/src/msw/gdiimage.cpp @@ -49,9 +49,20 @@ #include #endif +#include "wx/file.h" + #include "wx/listimpl.cpp" WX_DEFINE_LIST(wxGDIImageHandlerList); +// ---------------------------------------------------------------------------- +// auxiliary functions +// ---------------------------------------------------------------------------- + +#ifdef __WXWINCE__ +// Used in wxBMPFileHandler::LoadFile +HBITMAP wxLoadBMP(const wxString& filename) ; +#endif + // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- @@ -360,6 +371,11 @@ bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap, return dib.IsOk() && bitmap->CopyFromDIB(dib); #else + WXHBITMAP hBitmap = (WXHBITMAP)wxLoadBMP(name); + if(hBitmap) { + bitmap->SetHBITMAP(hBitmap); + return TRUE; + } return FALSE; #endif } @@ -597,3 +613,80 @@ wxSize wxGetHiconSize(HICON hicon) #endif // __WXMICROWIN__ +#ifdef __WXWINCE__ +// Used in wxBMPFileHandler::LoadFile +HBITMAP wxLoadBMP(const wxString& filename) +{ + wxFile file; + if(!file.Open(filename)) + return 0; + + // The first part of the file contains the file header. + // This will tell us if it is a bitmap, how big the header is, and how big + // the file is. The header size in the file header includes the color table. + BITMAPFILEHEADER BmpFileHdr; + BITMAPINFO *pBmpInfo = (BITMAPINFO*)malloc(sizeof(BITMAPINFO)+255*sizeof(RGBQUAD)); + BYTE* pBits = 0; + HBITMAP hBitmap = 0; + + if(file.Read(&BmpFileHdr, sizeof(BmpFileHdr))==sizeof(BmpFileHdr) + && !strncmp((char*)&BmpFileHdr.bfType,"BM",2) + && file.Read(pBmpInfo, sizeof(BITMAPINFOHEADER))==sizeof(BITMAPINFOHEADER) + && pBmpInfo->bmiHeader.biSize == sizeof(BITMAPINFOHEADER)) { + + + unsigned int nColors = pBmpInfo->bmiHeader.biClrUsed ? + pBmpInfo->bmiHeader.biClrUsed : 1 << pBmpInfo->bmiHeader.biBitCount; + if (nColors < 1 + || file.Read(pBmpInfo->bmiColors, nColors * sizeof(RGBQUAD)) + == (off_t)(nColors * sizeof(RGBQUAD))) { + + // So how big the bitmap surface is. + int nBitsSize = BmpFileHdr.bfSize - BmpFileHdr.bfOffBits; + + // Allocate the memory for the bits and read the bits from the file. + pBits = (BYTE*) malloc(nBitsSize*2); + if (pBits) { + // Seek to the bits in the file. + file.Seek(BmpFileHdr.bfOffBits); + + // read the bits + if(file.Read(pBits, nBitsSize)==nBitsSize) { + // Everything went OK. + pBmpInfo->bmiHeader.biSizeImage = nBitsSize; + + //HBITMAP hBitmap=SetBitmap((LPBITMAPINFO)pBmpInfo, pBits); + DWORD dwBitmapInfoSize = sizeof(BITMAPINFO) + nColors*sizeof(RGBQUAD); + + // Create a DC which will be used to get DIB, then create DIBsection + HDC hDC = ::GetDC(NULL); + if (hDC) { + LPVOID bits; + hBitmap = CreateDIBSection(hDC, (const BITMAPINFO*) pBmpInfo, + DIB_RGB_COLORS, &bits, NULL, 0); + ReleaseDC(0,hDC); + + if (hBitmap) { + DWORD dwImageSize = pBmpInfo->bmiHeader.biSizeImage; + if (dwImageSize == 0) { + int nBytesPerLine = pBmpInfo->bmiHeader.biWidth * pBmpInfo->bmiHeader.biBitCount; + nBytesPerLine = ( (nBytesPerLine + 31) & (~31) ) / 8; + dwImageSize = nBytesPerLine * pBmpInfo->bmiHeader.biHeight; + } + memcpy(bits, pBits, dwImageSize); + } + } + } + } + } + } + + if(pBmpInfo) + free(pBmpInfo); + if(pBits) + free(pBits); + + return hBitmap; +} +#endif + diff --git a/src/msw/wince/helpwce.cpp b/src/msw/wince/helpwce.cpp index 72154634e4..904d4dba72 100644 --- a/src/msw/wince/helpwce.cpp +++ b/src/msw/wince/helpwce.cpp @@ -79,7 +79,8 @@ bool wxWinceHelpController::DisplayBlock(long block) return TRUE; } -bool wxWinceHelpController::KeywordSearch(const wxString& k) +bool wxWinceHelpController::KeywordSearch(const wxString& k, + wxHelpSearchMode mode) { return TRUE; } diff --git a/src/msw/window.cpp b/src/msw/window.cpp index bb30e91849..c1be9a6860 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2360,6 +2360,7 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam break; } +#ifndef __WXWINCE__ case WM_PRINT: { // Don't call the wx handlers in this case @@ -2373,6 +2374,7 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam processed = HandlePaint(); } break; +#endif case WM_CLOSE: #ifdef __WXUNIVERSAL__ -- 2.47.2