wxWidgets/include/wx/qt/bitmap.h
Vadim Zeitlin 41b1ba3c9e Replace many identical wxBitmap::CopyFromIcon() with a single one
Define CopyFromIcon() directly in wxBitmapBase for the non-MSW ports, as
it was implemented exactly in the same way in all ports using this class
anyhow.

This means this function is not virtual any longer, but this shouldn't
be a problem as it was never supposed to be overridden in application
code and this couldn't be done with wxMSW, where it never was virtual in
the first place, anyhow.

No real changes, just a simplification.
2021-10-25 23:36:45 +02:00

128 lines
4.0 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: wx/qt/bitmap.h
// Author: Peter Most, Javier Torres, Mariano Reingart
// Copyright: (c) 2010 wxWidgets dev team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_QT_BITMAP_H_
#define _WX_QT_BITMAP_H_
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
class WXDLLIMPEXP_FWD_CORE wxImage;
class WXDLLIMPEXP_FWD_CORE wxCursor;
class QImage;
class QPixmap;
class QBitmap;
class WXDLLIMPEXP_CORE wxBitmap : public wxBitmapBase
{
public:
wxBitmap();
wxBitmap(QPixmap pix);
wxBitmap(const char bits[], int width, int height, int depth = 1);
wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH);
wxBitmap(const char* const* bits);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH, double scale = 1.0);
// Convert from wxIcon / wxCursor
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
explicit wxBitmap(const wxCursor& cursor);
static void InitStandardHandlers();
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) wxOVERRIDE;
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) wxOVERRIDE;
virtual bool Create(int width, int height, const wxDC& WXUNUSED(dc));
virtual int GetHeight() const wxOVERRIDE;
virtual int GetWidth() const wxOVERRIDE;
virtual int GetDepth() const wxOVERRIDE;
#if wxUSE_IMAGE
virtual wxImage ConvertToImage() const wxOVERRIDE;
#endif // wxUSE_IMAGE
virtual wxMask *GetMask() const wxOVERRIDE;
virtual void SetMask(wxMask *mask) wxOVERRIDE;
virtual wxBitmap GetSubBitmap(const wxRect& rect) const wxOVERRIDE;
virtual bool SaveFile(const wxString &name, wxBitmapType type,
const wxPalette *palette = NULL) const wxOVERRIDE;
virtual bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE) wxOVERRIDE;
#if wxUSE_PALETTE
virtual wxPalette *GetPalette() const wxOVERRIDE;
virtual void SetPalette(const wxPalette& palette) wxOVERRIDE;
#endif // wxUSE_PALETTE
// implementation:
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED(virtual void SetHeight(int height) wxOVERRIDE);
wxDEPRECATED(virtual void SetWidth(int width) wxOVERRIDE);
wxDEPRECATED(virtual void SetDepth(int depth) wxOVERRIDE);
#endif
void *GetRawData(wxPixelDataBase& data, int bpp);
void UngetRawData(wxPixelDataBase& data);
// these functions are internal and shouldn't be used, they risk to
// disappear in the future
bool HasAlpha() const;
QPixmap *GetHandle() const;
protected:
virtual wxGDIRefData *CreateGDIRefData() const wxOVERRIDE;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const wxOVERRIDE;
wxDECLARE_DYNAMIC_CLASS(wxBitmap);
};
class WXDLLIMPEXP_CORE wxMask : public wxMaskBase
{
public:
wxMask();
// Copy constructor
wxMask(const wxMask &mask);
wxMask& operator=(const wxMask &mask);
// Construct a mask from a bitmap and a colour indicating the transparent
// area
wxMask(const wxBitmap& bitmap, const wxColour& colour);
// Construct a mask from a bitmap and a palette index indicating the
// transparent area
wxMask(const wxBitmap& bitmap, int paletteIndex);
// Construct a mask from a mono bitmap (copies the bitmap).
wxMask(const wxBitmap& bitmap);
virtual ~wxMask();
wxBitmap GetBitmap() const;
// Implementation
QBitmap *GetHandle() const;
protected:
// this function is called from Create() to free the existing mask data
void FreeData() wxOVERRIDE;
// by the public wrappers
bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour) wxOVERRIDE;
bool InitFromMonoBitmap(const wxBitmap& bitmap) wxOVERRIDE;
protected:
wxDECLARE_DYNAMIC_CLASS(wxMask);
private:
QBitmap *m_qtBitmap;
};
#endif // _WX_QT_BITMAP_H_