]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/bitmap.h
fix unused parameter warning
[wxWidgets.git] / include / wx / gtk1 / bitmap.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: bitmap.h
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
10
11#ifndef __GTKBITMAPH__
12#define __GTKBITMAPH__
13
c801d85f
KB
14#include "wx/defs.h"
15#include "wx/object.h"
16#include "wx/string.h"
17#include "wx/palette.h"
58c837a4 18#include "wx/gdiobj.h"
c801d85f 19
feac7937
VS
20#ifdef __WXGTK20__
21typedef struct _GdkPixbuf GdkPixbuf;
22#endif
23
f383c5b8
VZ
24class WXDLLEXPORT wxPixelDataBase;
25
c801d85f
KB
26//-----------------------------------------------------------------------------
27// classes
28//-----------------------------------------------------------------------------
29
20123d49
MW
30class WXDLLIMPEXP_CORE wxMask;
31class WXDLLIMPEXP_CORE wxBitmap;
32class WXDLLIMPEXP_CORE wxImage;
c801d85f
KB
33
34//-----------------------------------------------------------------------------
35// wxMask
36//-----------------------------------------------------------------------------
37
20123d49 38class WXDLLIMPEXP_CORE wxMask: public wxObject
c801d85f 39{
fd0eed64 40public:
8636aed8
RR
41 wxMask();
42 wxMask( const wxBitmap& bitmap, const wxColour& colour );
43 wxMask( const wxBitmap& bitmap, int paletteIndex );
44 wxMask( const wxBitmap& bitmap );
45 ~wxMask();
91b8de8d 46
8636aed8
RR
47 bool Create( const wxBitmap& bitmap, const wxColour& colour );
48 bool Create( const wxBitmap& bitmap, int paletteIndex );
49 bool Create( const wxBitmap& bitmap );
50
51 // implementation
52 GdkBitmap *m_bitmap;
53
54 GdkBitmap *GetBitmap() const;
55
56private:
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:
8636aed8
RR
67 wxBitmap();
68 wxBitmap( int width, int height, int depth = -1 );
69 wxBitmap( const char bits[], int width, int height, int depth = 1 );
e838cc14
VZ
70 wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); }
71 wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); }
8636aed8 72 wxBitmap( const wxBitmap& bmp );
4611dd06 73 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
fd859211 74 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
8636aed8
RR
75 ~wxBitmap();
76 wxBitmap& operator = ( const wxBitmap& bmp );
f6bcfd97
BP
77 bool operator == ( const wxBitmap& bmp ) const;
78 bool operator != ( const wxBitmap& bmp ) const;
8636aed8
RR
79 bool Ok() const;
80
c826213d
RR
81 bool Create(int width, int height, int depth = -1);
82
8636aed8
RR
83 int GetHeight() const;
84 int GetWidth() const;
85 int GetDepth() const;
fd859211
VS
86
87 wxImage ConvertToImage() const;
8636aed8 88
db0aec83
VS
89 // copies the contents and mask of the given (colour) icon to the bitmap
90 virtual bool CopyFromIcon(const wxIcon& icon);
91
8636aed8
RR
92 wxMask *GetMask() const;
93 void SetMask( wxMask *mask );
17bec151
RR
94
95 wxBitmap GetSubBitmap( const wxRect& rect ) const;
8636aed8 96
4611dd06
RR
97 bool SaveFile(const wxString &name, wxBitmapType type,
98 const wxPalette *palette = (wxPalette *)NULL) const;
99 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
8636aed8 100
4611dd06 101#if wxUSE_PALETTE
8636aed8 102 wxPalette *GetPalette() const;
4611dd06 103 void SetPalette(const wxPalette& palette);
55e90a2e 104 wxPalette *GetColourMap() const { return GetPalette(); };
4611dd06 105#endif // wxUSE_PALETTE
55e90a2e 106
4b61c88d 107 static void InitStandardHandlers();
8bbe427f 108
8636aed8 109 // implementation
20e05ffb 110 // --------------
c801d85f 111
8636aed8
RR
112 void SetHeight( int height );
113 void SetWidth( int width );
114 void SetDepth( int depth );
115 void SetPixmap( GdkPixmap *pixmap );
82ea63e6 116 void SetBitmap( GdkBitmap *bitmap );
feac7937
VS
117#ifdef __WXGTK20__
118 void SetPixbuf(GdkPixbuf *pixbuf);
119#endif
8bbe427f 120
8636aed8
RR
121 GdkPixmap *GetPixmap() const;
122 GdkBitmap *GetBitmap() const;
feac7937
VS
123 bool HasPixmap() const;
124#ifdef __WXGTK20__
125 bool HasPixbuf() const;
126 GdkPixbuf *GetPixbuf() const;
127#endif
8636aed8 128
783da845
RR
129 // Basically, this corresponds to Win32 StretchBlt()
130 wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
284f2b59
RR
131
132 // raw bitmap access support functions
133 void *GetRawData(wxPixelDataBase& data, int bpp);
134 void UngetRawData(wxPixelDataBase& data);
135
0ff2a74d
RR
136 bool HasAlpha() const;
137 void UseAlpha();
d2400c3f 138
e838cc14
VZ
139protected:
140 bool CreateFromXpm(const char **bits);
fd859211 141 bool CreateFromImage(const wxImage& image, int depth);
e838cc14 142
8636aed8 143private:
feac7937
VS
144 // to be called from CreateFromImage only!
145 bool CreateFromImageAsBitmap(const wxImage& image);
146 bool CreateFromImageAsPixmap(const wxImage& image);
147
148#ifdef __WXGTK20__
149 bool CreateFromImageAsPixbuf(const wxImage& image);
150
151 enum Representation
152 {
153 Pixmap,
154 Pixbuf
155 };
156 // removes other representations from memory, keeping only 'keep'
157 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
158 void PurgeOtherRepresentations(Representation keep);
159
160 friend class wxMemoryDC;
161#endif
4b61c88d
RR
162 friend class wxBitmapHandler;
163
164private:
8636aed8 165 DECLARE_DYNAMIC_CLASS(wxBitmap)
c801d85f
KB
166};
167
4b61c88d
RR
168//-----------------------------------------------------------------------------
169// wxBitmapHandler
170//-----------------------------------------------------------------------------
171
20123d49 172class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
4b61c88d
RR
173{
174public:
175 wxBitmapHandler() { }
176 virtual ~wxBitmapHandler();
177
178 virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
179 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
180 int desiredWidth, int desiredHeight);
181 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
182
183private:
184 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
185};
186
187
c801d85f 188#endif // __GTKBITMAPH__