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