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