WinCE bitmap patch from Johannes Schindelin <Johannes.Schindelin@gmx.de>

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23592 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-09-15 08:55:19 +00:00
parent de07d2004f
commit 419430a0c0
5 changed files with 104 additions and 5 deletions

View File

@@ -37,7 +37,8 @@ public:
virtual bool DisplayBlock(long blockNo); virtual bool DisplayBlock(long blockNo);
virtual bool DisplayContextPopup(int contextId); virtual bool DisplayContextPopup(int contextId);
virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos); 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(); virtual bool Quit();
wxString GetHelpFile() const { return m_helpFile; } wxString GetHelpFile() const { return m_helpFile; }

View File

@@ -572,7 +572,7 @@ bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
} }
CalcBoundingBox(x, y); CalcBoundingBox(x, y);
return success; return success;
#endif #endif
} }
@@ -2047,8 +2047,12 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
} }
if ( !success && (caps & RC_STRETCHBLT) ) if ( !success && (caps & RC_STRETCHBLT) )
#endif
// __WXWINCE__
{ {
#ifndef __WXWINCE__
StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR); StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
#endif
if ( !::StretchBlt if ( !::StretchBlt
( (
@@ -2086,8 +2090,6 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
success = TRUE; success = TRUE;
} }
} }
#endif
// __WXWINCE__
} }
::SetTextColor(GetHdc(), old_textground); ::SetTextColor(GetHdc(), old_textground);

View File

@@ -49,9 +49,20 @@
#include <shellapi.h> #include <shellapi.h>
#endif #endif
#include "wx/file.h"
#include "wx/listimpl.cpp" #include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxGDIImageHandlerList); WX_DEFINE_LIST(wxGDIImageHandlerList);
// ----------------------------------------------------------------------------
// auxiliary functions
// ----------------------------------------------------------------------------
#ifdef __WXWINCE__
// Used in wxBMPFileHandler::LoadFile
HBITMAP wxLoadBMP(const wxString& filename) ;
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private classes // private classes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -360,6 +371,11 @@ bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap,
return dib.IsOk() && bitmap->CopyFromDIB(dib); return dib.IsOk() && bitmap->CopyFromDIB(dib);
#else #else
WXHBITMAP hBitmap = (WXHBITMAP)wxLoadBMP(name);
if(hBitmap) {
bitmap->SetHBITMAP(hBitmap);
return TRUE;
}
return FALSE; return FALSE;
#endif #endif
} }
@@ -597,3 +613,80 @@ wxSize wxGetHiconSize(HICON hicon)
#endif // __WXMICROWIN__ #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

View File

@@ -79,7 +79,8 @@ bool wxWinceHelpController::DisplayBlock(long block)
return TRUE; return TRUE;
} }
bool wxWinceHelpController::KeywordSearch(const wxString& k) bool wxWinceHelpController::KeywordSearch(const wxString& k,
wxHelpSearchMode mode)
{ {
return TRUE; return TRUE;
} }

View File

@@ -2360,6 +2360,7 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
break; break;
} }
#ifndef __WXWINCE__
case WM_PRINT: case WM_PRINT:
{ {
// Don't call the wx handlers in this case // Don't call the wx handlers in this case
@@ -2373,6 +2374,7 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
processed = HandlePaint(); processed = HandlePaint();
} }
break; break;
#endif
case WM_CLOSE: case WM_CLOSE:
#ifdef __WXUNIVERSAL__ #ifdef __WXUNIVERSAL__