]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/bitmap.h
added a couple of base classes
[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;
f383c5b8
VZ
14class WXDLLEXPORT wxPixelDataBase;
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
RR
28 wxMask( const wxBitmap& bitmap );
29 ~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:
8636aed8
RR
53 wxBitmap();
54 wxBitmap( int width, int height, int depth = -1 );
55 wxBitmap( const char bits[], int width, int height, int depth = 1 );
e838cc14
VZ
56 wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); }
57 wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); }
4611dd06 58 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
fd859211 59 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
8636aed8 60 ~wxBitmap();
f6bcfd97
BP
61 bool operator == ( const wxBitmap& bmp ) const;
62 bool operator != ( const wxBitmap& bmp ) const;
8636aed8
RR
63 bool Ok() const;
64
c826213d 65 bool Create(int width, int height, int depth = -1);
0b04c4e0 66
8636aed8
RR
67 int GetHeight() const;
68 int GetWidth() const;
69 int GetDepth() const;
0b04c4e0 70
fd859211 71 wxImage ConvertToImage() const;
8636aed8 72
db0aec83
VS
73 // copies the contents and mask of the given (colour) icon to the bitmap
74 virtual bool CopyFromIcon(const wxIcon& icon);
75
8636aed8
RR
76 wxMask *GetMask() const;
77 void SetMask( wxMask *mask );
0b04c4e0 78
17bec151 79 wxBitmap GetSubBitmap( const wxRect& rect ) const;
8636aed8 80
4611dd06
RR
81 bool SaveFile(const wxString &name, wxBitmapType type,
82 const wxPalette *palette = (wxPalette *)NULL) const;
83 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
8636aed8 84
4611dd06 85#if wxUSE_PALETTE
8636aed8 86 wxPalette *GetPalette() const;
4611dd06 87 void SetPalette(const wxPalette& palette);
55e90a2e 88 wxPalette *GetColourMap() const { return GetPalette(); };
4611dd06 89#endif // wxUSE_PALETTE
55e90a2e 90
4b61c88d 91 static void InitStandardHandlers();
8bbe427f 92
8636aed8 93 // implementation
20e05ffb 94 // --------------
c801d85f 95
8636aed8
RR
96 void SetHeight( int height );
97 void SetWidth( int width );
98 void SetDepth( int depth );
99 void SetPixmap( GdkPixmap *pixmap );
feac7937 100 void SetPixbuf(GdkPixbuf *pixbuf);
8bbe427f 101
8636aed8 102 GdkPixmap *GetPixmap() const;
feac7937 103 bool HasPixmap() const;
feac7937
VS
104 bool HasPixbuf() const;
105 GdkPixbuf *GetPixbuf() const;
0b04c4e0 106
783da845
RR
107 // Basically, this corresponds to Win32 StretchBlt()
108 wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
0b04c4e0 109
284f2b59
RR
110 // raw bitmap access support functions
111 void *GetRawData(wxPixelDataBase& data, int bpp);
112 void UngetRawData(wxPixelDataBase& data);
113
0ff2a74d
RR
114 bool HasAlpha() const;
115 void UseAlpha();
d2400c3f 116
e838cc14
VZ
117protected:
118 bool CreateFromXpm(const char **bits);
fd859211 119 bool CreateFromImage(const wxImage& image, int depth);
e838cc14 120
8636aed8 121private:
feac7937 122 // to be called from CreateFromImage only!
5ac1d44a 123 bool CreateFromImageAsPixmap(const wxImage& image, int depth);
feac7937
VS
124 bool CreateFromImageAsPixbuf(const wxImage& image);
125
126 enum Representation
127 {
128 Pixmap,
129 Pixbuf
130 };
131 // removes other representations from memory, keeping only 'keep'
132 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
133 void PurgeOtherRepresentations(Representation keep);
134
135 friend class wxMemoryDC;
4b61c88d
RR
136 friend class wxBitmapHandler;
137
0b04c4e0 138private:
8636aed8 139 DECLARE_DYNAMIC_CLASS(wxBitmap)
c801d85f
KB
140};
141
4b61c88d
RR
142//-----------------------------------------------------------------------------
143// wxBitmapHandler
144//-----------------------------------------------------------------------------
145
20123d49 146class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
4b61c88d
RR
147{
148public:
149 wxBitmapHandler() { }
150 virtual ~wxBitmapHandler();
151
152 virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
153 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
154 int desiredWidth, int desiredHeight);
155 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
156
157private:
158 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
159};
160
0416c418 161#endif // _WX_GTK_BITMAP_H_