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:
Vadim Zeitlin
1998-06-22 22:07:55 +00:00
parent 8abf40fbb9
commit 1d7929284e

View File

@@ -32,11 +32,13 @@
#endif
#include "wx/msw/private.h"
#include "wx/log.h"
#include "assert.h"
#if USE_XPM_IN_MSW
#define FOR_MSW 1
#include "..\..\contrib\wxxpm\libxpm.34b\lib\xpm34.h"
#include "../../contrib/wxxpm/libxpm.34b/lib/xpm34.h"
#endif
#include "wx/msw/dib.h"
@@ -212,12 +214,15 @@ bool wxBitmap::LoadFile(const wxString& filename, const long type)
wxBitmapHandler *handler = FindHandler(type);
if ( handler )
return handler->LoadFile(this, filename, type, -1, -1);
else
if ( handler == NULL ) {
wxLogWarning("no bitmap handler for type %d defined.", type);
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)
{
UnRef();
@@ -226,22 +231,28 @@ bool wxBitmap::Create(void *data, const long type, const int width, const int he
wxBitmapHandler *handler = FindHandler(type);
if ( handler )
return handler->Create(this, data, type, width, height, depth);
else
if ( handler == NULL ) {
wxLogWarning("no bitmap handler for type %d defined.", type);
return FALSE;
}
return handler->Create(this, data, type, width, height, depth);
}
bool wxBitmap::SaveFile(const wxString& filename, const int type, const wxPalette *palette)
{
wxBitmapHandler *handler = FindHandler(type);
if ( handler )
return handler->SaveFile(this, filename, type, palette);
else
if ( handler == NULL ) {
wxLogWarning("no bitmap handler for type %d defined.", type);
return FALSE;
}
return handler->SaveFile(this, filename, type, palette);
}
void wxBitmap::SetWidth(int w)
{
if (!M_BITMAPDATA)
@@ -565,6 +576,10 @@ bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, cons
M_BITMAPHANDLERDATA->m_depth = bm.bmPlanes;
return TRUE;
}
// it's probably not found
wxLogError("Can't load bitmap '%s' from ressources!", name.c_str());
return FALSE;
}
@@ -659,7 +674,7 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const lo
M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap;
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_height = (bm.bmHeight);
@@ -677,9 +692,9 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, const lo
return FALSE;
}
}
#else
return FALSE;
#endif
return FALSE;
}
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))
{ /* for following SetPixel */
/* fill the XImage struct 'by hand' */
ximage.width = M_BITMAPHANDLERDATA->m_width; ximage.height = M_BITMAPHANDLERDATA->m_height;
ximage.depth = M_BITMAPHANDLERDATA->m_depth; ximage.bitmap = M_BITMAPHANDLERDATA->m_hBitmap;
ximage.width = M_BITMAPHANDLERDATA->m_width;
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,
&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;
DeleteDC(dc);
} else
return TRUE;
}
else
{
M_BITMAPHANDLERDATA->m_ok = FALSE;
// XpmDebugError(ErrorStatus, NULL);
@@ -776,9 +795,9 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, const long flags, co
return FALSE;
}
}
#else
return FALSE;
#endif
return FALSE;
}
void wxBitmap::CleanUpHandlers(void)
@@ -803,6 +822,3 @@ void wxBitmap::InitStandardHandlers(void)
AddHandler(new wxICOResourceHandler);
AddHandler(new wxICOFileHandler);
}