]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/bitmap.h
Make SaveFile and LoadFile virtual so they can be overridden
[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
feac7937 13typedef struct _GdkPixbuf GdkPixbuf;
b5dbe15d 14class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
f383c5b8 15
c801d85f
KB
16//-----------------------------------------------------------------------------
17// wxMask
18//-----------------------------------------------------------------------------
19
20123d49 20class WXDLLIMPEXP_CORE wxMask: public wxObject
c801d85f 21{
fd0eed64 22public:
8636aed8
RR
23 wxMask();
24 wxMask( const wxBitmap& bitmap, const wxColour& colour );
0b04c4e0 25#if wxUSE_PALETTE
8636aed8 26 wxMask( const wxBitmap& bitmap, int paletteIndex );
0b04c4e0 27#endif // wxUSE_PALETTE
8636aed8 28 wxMask( const wxBitmap& bitmap );
d3c7fc99 29 virtual ~wxMask();
0b04c4e0 30
8636aed8 31 bool Create( const wxBitmap& bitmap, const wxColour& colour );
0b04c4e0 32#if wxUSE_PALETTE
8636aed8 33 bool Create( const wxBitmap& bitmap, int paletteIndex );
0b04c4e0 34#endif // wxUSE_PALETTE
8636aed8
RR
35 bool Create( const wxBitmap& bitmap );
36
37 // implementation
38 GdkBitmap *m_bitmap;
0b04c4e0 39
8636aed8 40 GdkBitmap *GetBitmap() const;
0b04c4e0 41
8636aed8
RR
42private:
43 DECLARE_DYNAMIC_CLASS(wxMask)
c801d85f
KB
44};
45
46//-----------------------------------------------------------------------------
47// wxBitmap
48//-----------------------------------------------------------------------------
49
20123d49 50class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
c801d85f 51{
fd0eed64 52public:
23656673 53 wxBitmap() { }
8636aed8
RR
54 wxBitmap( int width, int height, int depth = -1 );
55 wxBitmap( const char bits[], int width, int height, int depth = 1 );
452418c4 56 wxBitmap( const char* const* bits );
459f812b 57#ifdef wxNEEDS_CHARPP
4a4bf7ee
SN
58 // needed for old GCC
59 wxBitmap(char** data)
60 {
61 *this = wxBitmap(wx_const_cast(const char* const*, data));
62 }
63#endif
4611dd06 64 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
c0521644 65#if wxUSE_IMAGE
fd859211 66 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
c0521644 67#endif // wxUSE_IMAGE
d3c7fc99 68 virtual ~wxBitmap();
b7cacb43
VZ
69 bool Ok() const { return IsOk(); }
70 bool IsOk() const;
8636aed8 71
c826213d 72 bool Create(int width, int height, int depth = -1);
0b04c4e0 73
8636aed8
RR
74 int GetHeight() const;
75 int GetWidth() const;
76 int GetDepth() const;
0b04c4e0 77
c0521644 78#if wxUSE_IMAGE
fd859211 79 wxImage ConvertToImage() const;
c0521644 80#endif // wxUSE_IMAGE
8636aed8 81
db0aec83
VS
82 // copies the contents and mask of the given (colour) icon to the bitmap
83 virtual bool CopyFromIcon(const wxIcon& icon);
84
8636aed8
RR
85 wxMask *GetMask() const;
86 void SetMask( wxMask *mask );
0b04c4e0 87
17bec151 88 wxBitmap GetSubBitmap( const wxRect& rect ) const;
8636aed8 89
4611dd06
RR
90 bool SaveFile(const wxString &name, wxBitmapType type,
91 const wxPalette *palette = (wxPalette *)NULL) const;
92 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
8636aed8 93
4611dd06 94#if wxUSE_PALETTE
8636aed8 95 wxPalette *GetPalette() const;
4611dd06 96 void SetPalette(const wxPalette& palette);
55e90a2e 97 wxPalette *GetColourMap() const { return GetPalette(); };
4611dd06 98#endif // wxUSE_PALETTE
55e90a2e 99
4b61c88d 100 static void InitStandardHandlers();
8bbe427f 101
8636aed8 102 // implementation
20e05ffb 103 // --------------
c801d85f 104
8636aed8
RR
105 void SetHeight( int height );
106 void SetWidth( int width );
107 void SetDepth( int depth );
108 void SetPixmap( GdkPixmap *pixmap );
23656673 109 void SetPixbuf(GdkPixbuf* pixbuf, int depth = 0);
8bbe427f 110
8636aed8 111 GdkPixmap *GetPixmap() const;
feac7937 112 bool HasPixmap() const;
feac7937
VS
113 bool HasPixbuf() const;
114 GdkPixbuf *GetPixbuf() const;
0b04c4e0 115
783da845 116 // Basically, this corresponds to Win32 StretchBlt()
23656673 117 wxBitmap Rescale(int clipx, int clipy, int clipwidth, int clipheight, int width, int height) const;
0b04c4e0 118
284f2b59
RR
119 // raw bitmap access support functions
120 void *GetRawData(wxPixelDataBase& data, int bpp);
121 void UngetRawData(wxPixelDataBase& data);
122
0ff2a74d 123 bool HasAlpha() const;
d2400c3f 124
e838cc14 125protected:
c0521644 126#if wxUSE_IMAGE
fd859211 127 bool CreateFromImage(const wxImage& image, int depth);
c0521644 128#endif // wxUSE_IMAGE
e838cc14 129
4c44e0d0
PC
130 virtual wxObjectRefData* CreateRefData() const;
131 virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
132
8636aed8 133private:
c0521644 134#if wxUSE_IMAGE
feac7937 135 // to be called from CreateFromImage only!
5ac1d44a 136 bool CreateFromImageAsPixmap(const wxImage& image, int depth);
feac7937 137 bool CreateFromImageAsPixbuf(const wxImage& image);
c0521644 138#endif // wxUSE_IMAGE
feac7937 139
ab171e95
RR
140public:
141 // implementation only
feac7937
VS
142 enum Representation
143 {
144 Pixmap,
145 Pixbuf
146 };
147 // removes other representations from memory, keeping only 'keep'
148 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
149 void PurgeOtherRepresentations(Representation keep);
150
0b04c4e0 151private:
8636aed8 152 DECLARE_DYNAMIC_CLASS(wxBitmap)
c801d85f
KB
153};
154
4b61c88d
RR
155//-----------------------------------------------------------------------------
156// wxBitmapHandler
157//-----------------------------------------------------------------------------
158
20123d49 159class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
4b61c88d 160{
452418c4 161 DECLARE_ABSTRACT_CLASS(wxBitmapHandler)
4b61c88d
RR
162};
163
0416c418 164#endif // _WX_GTK_BITMAP_H_