compilation fixes for wxUSE_IMAGE==0

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47324 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-07-11 00:02:11 +00:00
parent 3c029873c6
commit c052164410
5 changed files with 36 additions and 4 deletions

View File

@@ -140,7 +140,9 @@ public:
virtual int GetWidth() const = 0; virtual int GetWidth() const = 0;
virtual int GetDepth() const = 0; virtual int GetDepth() const = 0;
#if wxUSE_IMAGE
virtual wxImage ConvertToImage() const = 0; virtual wxImage ConvertToImage() const = 0;
#endif // wxUSE_IMAGE
virtual wxMask *GetMask() const = 0; virtual wxMask *GetMask() const = 0;
virtual void SetMask(wxMask *mask) = 0; virtual void SetMask(wxMask *mask) = 0;

View File

@@ -62,7 +62,9 @@ public:
} }
#endif #endif
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM ); wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
#if wxUSE_IMAGE
wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
#endif // wxUSE_IMAGE
virtual ~wxBitmap(); virtual ~wxBitmap();
bool Ok() const { return IsOk(); } bool Ok() const { return IsOk(); }
bool IsOk() const; bool IsOk() const;
@@ -73,7 +75,9 @@ public:
int GetWidth() const; int GetWidth() const;
int GetDepth() const; int GetDepth() const;
#if wxUSE_IMAGE
wxImage ConvertToImage() const; wxImage ConvertToImage() const;
#endif // wxUSE_IMAGE
// copies the contents and mask of the given (colour) icon to the bitmap // copies the contents and mask of the given (colour) icon to the bitmap
virtual bool CopyFromIcon(const wxIcon& icon); virtual bool CopyFromIcon(const wxIcon& icon);
@@ -119,15 +123,19 @@ public:
bool HasAlpha() const; bool HasAlpha() const;
protected: protected:
#if wxUSE_IMAGE
bool CreateFromImage(const wxImage& image, int depth); bool CreateFromImage(const wxImage& image, int depth);
#endif // wxUSE_IMAGE
virtual wxObjectRefData* CreateRefData() const; virtual wxObjectRefData* CreateRefData() const;
virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const; virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
private: private:
#if wxUSE_IMAGE
// to be called from CreateFromImage only! // to be called from CreateFromImage only!
bool CreateFromImageAsPixmap(const wxImage& image, int depth); bool CreateFromImageAsPixmap(const wxImage& image, int depth);
bool CreateFromImageAsPixbuf(const wxImage& image); bool CreateFromImageAsPixbuf(const wxImage& image);
#endif // wxUSE_IMAGE
enum Representation enum Representation
{ {

View File

@@ -37,6 +37,7 @@ public:
wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
#if wxUSE_IMAGE
wxRegion( const wxBitmap& bmp) wxRegion( const wxBitmap& bmp)
{ {
Union(bmp); Union(bmp);
@@ -46,6 +47,7 @@ public:
{ {
Union(bmp, transColour, tolerance); Union(bmp, transColour, tolerance);
} }
#endif // wxUSE_IMAGE
virtual ~wxRegion(); virtual ~wxRegion();

View File

@@ -363,6 +363,8 @@ wxBitmap wxBitmap::Rescale(int clipx, int clipy, int clipwidth, int clipheight,
return bmp; return bmp;
} }
#if wxUSE_IMAGE
bool wxBitmap::CreateFromImage(const wxImage& image, int depth) bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
{ {
UnRef(); UnRef();
@@ -593,6 +595,8 @@ wxImage wxBitmap::ConvertToImage() const
return image; return image;
} }
#endif // wxUSE_IMAGE
bool wxBitmap::IsOk() const bool wxBitmap::IsOk() const
{ {
return (m_refData != NULL) && return (m_refData != NULL) &&
@@ -692,9 +696,13 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett
{ {
wxCHECK_MSG( Ok(), false, wxT("invalid bitmap") ); wxCHECK_MSG( Ok(), false, wxT("invalid bitmap") );
#if wxUSE_IMAGE
// Try to save the bitmap via wxImage handlers: // Try to save the bitmap via wxImage handlers:
wxImage image = ConvertToImage(); wxImage image = ConvertToImage();
return image.Ok() && image.SaveFile(name, type); return image.Ok() && image.SaveFile(name, type);
#else // !wxUSE_IMAGE
return false;
#endif // wxUSE_IMAGE
} }
bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type ) bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
@@ -712,12 +720,14 @@ bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
M_BMPDATA->m_mask->m_bitmap = mask; M_BMPDATA->m_mask->m_bitmap = mask;
} }
} }
#if wxUSE_IMAGE
else // try if wxImage can load it else // try if wxImage can load it
{ {
wxImage image; wxImage image;
if (image.LoadFile(name, type) && image.Ok()) if (image.LoadFile(name, type) && image.Ok())
CreateFromImage(image, -1); CreateFromImage(image, -1);
} }
#endif // wxUSE_IMAGE
return Ok(); return Ok();
} }
@@ -786,7 +796,7 @@ GdkPixmap *wxBitmap::GetPixmap() const
gdk_pixbuf_render_pixmap_and_mask(M_BMPDATA->m_pixbuf, gdk_pixbuf_render_pixmap_and_mask(M_BMPDATA->m_pixbuf,
&M_BMPDATA->m_pixmap, &M_BMPDATA->m_pixmap,
pmask, pmask,
wxIMAGE_ALPHA_THRESHOLD); 0x80 /* alpha threshold */);
} }
return M_BMPDATA->m_pixmap; return M_BMPDATA->m_pixmap;

View File

@@ -448,17 +448,22 @@ void wxGTKWindowImplDC::DoGetSize( int* width, int* height ) const
m_owner->GetSize(width, height); m_owner->GetSize(width, height);
} }
extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
const wxColour & col, int style);
bool wxGTKWindowImplDC::DoFloodFill(wxCoord x, wxCoord y, bool wxGTKWindowImplDC::DoFloodFill(wxCoord x, wxCoord y,
const wxColour& col, int style) const wxColour& col, int style)
{ {
#if wxUSE_IMAGE
extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
const wxColour & col, int style);
return wxDoFloodFill(this, x, y, col, style); return wxDoFloodFill(this, x, y, col, style);
#else
return false;
#endif
} }
bool wxGTKWindowImplDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const bool wxGTKWindowImplDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
{ {
#if wxUSE_IMAGE
// Generic (and therefore rather inefficient) method. // Generic (and therefore rather inefficient) method.
// Could be improved. // Could be improved.
wxMemoryDC memdc; wxMemoryDC memdc;
@@ -470,6 +475,9 @@ bool wxGTKWindowImplDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) cons
wxImage image = bitmap.ConvertToImage(); wxImage image = bitmap.ConvertToImage();
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0)); col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
return true; return true;
#else // !wxUSE_IMAGE
return false;
#endif // wxUSE_IMAGE/!wxUSE_IMAGE
} }
void wxGTKWindowImplDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) void wxGTKWindowImplDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
@@ -1619,6 +1627,7 @@ void wxGTKWindowImplDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
void wxGTKWindowImplDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle ) void wxGTKWindowImplDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle )
{ {
#if wxUSE_IMAGE
if (!m_window || text.empty()) if (!m_window || text.empty())
return; return;
@@ -1717,6 +1726,7 @@ void wxGTKWindowImplDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCo
// update the bounding box // update the bounding box
CalcBoundingBox(x + minX, y + minY); CalcBoundingBox(x + minX, y + minY);
CalcBoundingBox(x + maxX, y + maxY); CalcBoundingBox(x + maxX, y + maxY);
#endif // wxUSE_IMAGE
} }
void wxGTKWindowImplDC::DoGetTextExtent(const wxString &string, void wxGTKWindowImplDC::DoGetTextExtent(const wxString &string,