]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/bitmap.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / gtk / bitmap.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
0b04c4e0 2// Name: wx/gtk/bitmap.h
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
01111366 5// Copyright: (c) 1998 Robert Roebling
65571936 6// Licence: wxWindows licence
c801d85f
KB
7/////////////////////////////////////////////////////////////////////////////
8
0416c418
PC
9#ifndef _WX_GTK_BITMAP_H_
10#define _WX_GTK_BITMAP_H_
c801d85f 11
9dc44eff
PC
12#ifdef __WXGTK3__
13typedef struct _cairo cairo_t;
14typedef struct _cairo_surface cairo_surface_t;
15#endif
feac7937 16typedef struct _GdkPixbuf GdkPixbuf;
b5dbe15d 17class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
f383c5b8 18
c801d85f
KB
19//-----------------------------------------------------------------------------
20// wxMask
21//-----------------------------------------------------------------------------
22
60a3d1c6 23class WXDLLIMPEXP_CORE wxMask: public wxMaskBase
c801d85f 24{
fd0eed64 25public:
8636aed8 26 wxMask();
27297c82 27 wxMask(const wxMask& mask);
8636aed8 28 wxMask( const wxBitmap& bitmap, const wxColour& colour );
0b04c4e0 29#if wxUSE_PALETTE
8636aed8 30 wxMask( const wxBitmap& bitmap, int paletteIndex );
0b04c4e0 31#endif // wxUSE_PALETTE
8636aed8 32 wxMask( const wxBitmap& bitmap );
d3c7fc99 33 virtual ~wxMask();
5ca21fe7 34 wxBitmap GetBitmap() const;
0b04c4e0 35
8636aed8 36 // implementation
9dc44eff
PC
37#ifdef __WXGTK3__
38 wxMask(cairo_surface_t*);
5ca21fe7 39 operator cairo_surface_t*() const;
9dc44eff 40#else
2d13e22f 41 wxMask(GdkPixmap*);
5ca21fe7 42 operator GdkPixmap*() const;
9dc44eff 43#endif
0b04c4e0 44
60a3d1c6
PC
45protected:
46 virtual void FreeData();
47 virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour);
48 virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
49
2d13e22f 50private:
9dc44eff
PC
51#ifdef __WXGTK3__
52 cairo_surface_t* m_bitmap;
53#else
2d13e22f 54 GdkPixmap* m_bitmap;
9dc44eff 55#endif
2d13e22f 56
8636aed8 57 DECLARE_DYNAMIC_CLASS(wxMask)
c801d85f
KB
58};
59
60//-----------------------------------------------------------------------------
61// wxBitmap
62//-----------------------------------------------------------------------------
63
20123d49 64class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
c801d85f 65{
fd0eed64 66public:
23656673 67 wxBitmap() { }
03647350 68 wxBitmap( int width, int height, int depth = wxBITMAP_SCREEN_DEPTH )
732d8c74 69 { Create(width, height, depth); }
03647350 70 wxBitmap( const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH )
732d8c74 71 { Create(sz, depth); }
8636aed8 72 wxBitmap( const char bits[], int width, int height, int depth = 1 );
452418c4 73 wxBitmap( const char* const* bits );
459f812b 74#ifdef wxNEEDS_CHARPP
4a4bf7ee
SN
75 // needed for old GCC
76 wxBitmap(char** data)
732d8c74 77 { *this = wxBitmap(const_cast<const char* const*>(data)); }
4a4bf7ee 78#endif
cbea3ec6 79 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
c0521644 80#if wxUSE_IMAGE
9dc44eff 81 wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH);
c0521644 82#endif // wxUSE_IMAGE
5ca21fe7 83 wxBitmap(GdkPixbuf* pixbuf, int depth = 0);
d3c7fc99 84 virtual ~wxBitmap();
8636aed8 85
e86f2cc8 86 bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
732d8c74
FM
87 bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
88 { return Create(sz.GetWidth(), sz.GetHeight(), depth); }
cfcab929
SC
89 bool Create(int width, int height, const wxDC& WXUNUSED(dc))
90 { return Create(width,height); }
91
0b04c4e0 92
8f884a0d
VZ
93 virtual int GetHeight() const;
94 virtual int GetWidth() const;
95 virtual int GetDepth() const;
0b04c4e0 96
c0521644 97#if wxUSE_IMAGE
fd859211 98 wxImage ConvertToImage() const;
c0521644 99#endif // wxUSE_IMAGE
8636aed8 100
db0aec83
VS
101 // copies the contents and mask of the given (colour) icon to the bitmap
102 virtual bool CopyFromIcon(const wxIcon& icon);
103
8636aed8
RR
104 wxMask *GetMask() const;
105 void SetMask( wxMask *mask );
9dc44eff 106 wxBitmap GetMaskBitmap() const;
0b04c4e0 107
17bec151 108 wxBitmap GetSubBitmap( const wxRect& rect ) const;
8636aed8 109
4611dd06 110 bool SaveFile(const wxString &name, wxBitmapType type,
d3b9f782 111 const wxPalette *palette = NULL) const;
cbea3ec6 112 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
8636aed8 113
4611dd06 114#if wxUSE_PALETTE
8636aed8 115 wxPalette *GetPalette() const;
4611dd06 116 void SetPalette(const wxPalette& palette);
6dd0883d 117 wxPalette *GetColourMap() const { return GetPalette(); }
4611dd06 118#endif // wxUSE_PALETTE
55e90a2e 119
4b61c88d 120 static void InitStandardHandlers();
8bbe427f 121
8636aed8 122 // implementation
20e05ffb 123 // --------------
c801d85f 124
8636aed8
RR
125 void SetHeight( int height );
126 void SetWidth( int width );
127 void SetDepth( int depth );
8bbe427f 128
9dc44eff
PC
129#ifdef __WXGTK3__
130 GdkPixbuf* GetPixbufNoMask() const;
131 cairo_t* CairoCreate() const;
132 void Draw(cairo_t* cr, int x, int y, bool useMask = true, const wxColour* fg = NULL, const wxColour* bg = NULL) const;
133 void SetSourceSurface(cairo_t* cr, int x, int y, const wxColour* fg = NULL, const wxColour* bg = NULL) const;
134#else
8636aed8 135 GdkPixmap *GetPixmap() const;
feac7937 136 bool HasPixmap() const;
feac7937 137 bool HasPixbuf() const;
5ca21fe7 138 wxBitmap(GdkPixmap* pixmap);
9dc44eff 139#endif
feac7937 140 GdkPixbuf *GetPixbuf() const;
0b04c4e0 141
284f2b59
RR
142 // raw bitmap access support functions
143 void *GetRawData(wxPixelDataBase& data, int bpp);
144 void UngetRawData(wxPixelDataBase& data);
145
0ff2a74d 146 bool HasAlpha() const;
d2400c3f 147
e838cc14 148protected:
9dc44eff 149#ifndef __WXGTK3__
c0521644 150#if wxUSE_IMAGE
fd859211 151 bool CreateFromImage(const wxImage& image, int depth);
c0521644 152#endif // wxUSE_IMAGE
9dc44eff 153#endif
e838cc14 154
8f884a0d
VZ
155 virtual wxGDIRefData* CreateGDIRefData() const;
156 virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
4c44e0d0 157
8636aed8 158private:
9dc44eff 159#ifndef __WXGTK3__
06497cba 160 void SetPixmap(GdkPixmap* pixmap);
c0521644 161#if wxUSE_IMAGE
feac7937 162 // to be called from CreateFromImage only!
5ac1d44a 163 bool CreateFromImageAsPixmap(const wxImage& image, int depth);
feac7937 164 bool CreateFromImageAsPixbuf(const wxImage& image);
c0521644 165#endif // wxUSE_IMAGE
feac7937 166
ab171e95
RR
167public:
168 // implementation only
feac7937
VS
169 enum Representation
170 {
171 Pixmap,
172 Pixbuf
173 };
174 // removes other representations from memory, keeping only 'keep'
175 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
176 void PurgeOtherRepresentations(Representation keep);
9dc44eff 177#endif
feac7937 178
8636aed8 179 DECLARE_DYNAMIC_CLASS(wxBitmap)
c801d85f
KB
180};
181
0416c418 182#endif // _WX_GTK_BITMAP_H_