now compiles with USE_XPM_IN_MSW on, added error messages if bitmap can't
be loaded/saved git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@129 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -32,11 +32,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
|
#include "wx/log.h"
|
||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
|
|
||||||
#if USE_XPM_IN_MSW
|
#if USE_XPM_IN_MSW
|
||||||
#define FOR_MSW 1
|
#define FOR_MSW 1
|
||||||
#include "..\..\contrib\wxxpm\libxpm.34b\lib\xpm34.h"
|
#include "../../contrib/wxxpm/libxpm.34b/lib/xpm34.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/dib.h"
|
#include "wx/msw/dib.h"
|
||||||
@@ -212,12 +214,15 @@ bool wxBitmap::LoadFile(const wxString& filename, const long type)
|
|||||||
|
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
wxBitmapHandler *handler = FindHandler(type);
|
||||||
|
|
||||||
if ( handler )
|
if ( handler == NULL ) {
|
||||||
return handler->LoadFile(this, filename, type, -1, -1);
|
wxLogWarning("no bitmap handler for type %d defined.", type);
|
||||||
else
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return handler->LoadFile(this, filename, type, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
bool wxBitmap::Create(void *data, const long type, const int width, const int height, const int depth)
|
bool wxBitmap::Create(void *data, const long type, const int width, const int height, const int depth)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
@@ -226,22 +231,28 @@ bool wxBitmap::Create(void *data, const long type, const int width, const int he
|
|||||||
|
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
wxBitmapHandler *handler = FindHandler(type);
|
||||||
|
|
||||||
if ( handler )
|
if ( handler == NULL ) {
|
||||||
return handler->Create(this, data, type, width, height, depth);
|
wxLogWarning("no bitmap handler for type %d defined.", type);
|
||||||
else
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return handler->Create(this, data, type, width, height, depth);
|
||||||
|
}
|
||||||
|
|
||||||
bool wxBitmap::SaveFile(const wxString& filename, const int type, const wxPalette *palette)
|
bool wxBitmap::SaveFile(const wxString& filename, const int type, const wxPalette *palette)
|
||||||
{
|
{
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
wxBitmapHandler *handler = FindHandler(type);
|
||||||
|
|
||||||
if ( handler )
|
if ( handler == NULL ) {
|
||||||
return handler->SaveFile(this, filename, type, palette);
|
wxLogWarning("no bitmap handler for type %d defined.", type);
|
||||||
else
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return handler->SaveFile(this, filename, type, palette);
|
||||||
|
}
|
||||||
|
|
||||||
void wxBitmap::SetWidth(int w)
|
void wxBitmap::SetWidth(int w)
|
||||||
{
|
{
|
||||||
if (!M_BITMAPDATA)
|
if (!M_BITMAPDATA)
|
||||||
@@ -565,6 +576,10 @@ bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, cons
|
|||||||
M_BITMAPHANDLERDATA->m_depth = bm.bmPlanes;
|
M_BITMAPHANDLERDATA->m_depth = bm.bmPlanes;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it's probably not found
|
||||||
|
wxLogError("Can't load bitmap '%s' from ressources!", name.c_str());
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,7 +674,7 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const lo
|
|||||||
M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap;
|
M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap;
|
||||||
|
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
GetObject((HBITMAP) m_hBitmap, sizeof(bm), (LPSTR) & bm);
|
GetObject((HBITMAP)M_BITMAPHANDLERDATA->m_hBitmap, sizeof(bm), (LPSTR) & bm);
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_width = (bm.bmWidth);
|
M_BITMAPHANDLERDATA->m_width = (bm.bmWidth);
|
||||||
M_BITMAPHANDLERDATA->m_height = (bm.bmHeight);
|
M_BITMAPHANDLERDATA->m_height = (bm.bmHeight);
|
||||||
@@ -677,9 +692,9 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const lo
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *palette)
|
bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, const int type, const wxPalette *palette)
|
||||||
@@ -696,8 +711,10 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, const in
|
|||||||
if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
|
if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
|
||||||
{ /* for following SetPixel */
|
{ /* for following SetPixel */
|
||||||
/* fill the XImage struct 'by hand' */
|
/* fill the XImage struct 'by hand' */
|
||||||
ximage.width = M_BITMAPHANDLERDATA->m_width; ximage.height = M_BITMAPHANDLERDATA->m_height;
|
ximage.width = M_BITMAPHANDLERDATA->m_width;
|
||||||
ximage.depth = M_BITMAPHANDLERDATA->m_depth; ximage.bitmap = M_BITMAPHANDLERDATA->m_hBitmap;
|
ximage.height = M_BITMAPHANDLERDATA->m_height;
|
||||||
|
ximage.depth = M_BITMAPHANDLERDATA->m_depth;
|
||||||
|
ximage.bitmap = (void *)M_BITMAPHANDLERDATA->m_hBitmap;
|
||||||
int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name,
|
int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name,
|
||||||
&ximage, (XImage *) NULL, (XpmAttributes *) NULL);
|
&ximage, (XImage *) NULL, (XpmAttributes *) NULL);
|
||||||
|
|
||||||
@@ -768,7 +785,9 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, const long flags, co
|
|||||||
M_BITMAPHANDLERDATA->m_ok = TRUE;
|
M_BITMAPHANDLERDATA->m_ok = TRUE;
|
||||||
DeleteDC(dc);
|
DeleteDC(dc);
|
||||||
|
|
||||||
} else
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
M_BITMAPHANDLERDATA->m_ok = FALSE;
|
M_BITMAPHANDLERDATA->m_ok = FALSE;
|
||||||
// XpmDebugError(ErrorStatus, NULL);
|
// XpmDebugError(ErrorStatus, NULL);
|
||||||
@@ -776,9 +795,9 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, const long flags, co
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::CleanUpHandlers(void)
|
void wxBitmap::CleanUpHandlers(void)
|
||||||
@@ -803,6 +822,3 @@ void wxBitmap::InitStandardHandlers(void)
|
|||||||
AddHandler(new wxICOResourceHandler);
|
AddHandler(new wxICOResourceHandler);
|
||||||
AddHandler(new wxICOFileHandler);
|
AddHandler(new wxICOFileHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user