]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/bitmap.h
added \newsince command
[wxWidgets.git] / include / wx / gtk / 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
12028905 14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
15#pragma interface
16#endif
17
18#include "wx/defs.h"
19#include "wx/object.h"
20#include "wx/string.h"
21#include "wx/palette.h"
58c837a4 22#include "wx/gdiobj.h"
c801d85f 23
feac7937
VS
24#ifdef __WXGTK20__
25typedef struct _GdkPixbuf GdkPixbuf;
26#endif
27
c801d85f
KB
28//-----------------------------------------------------------------------------
29// classes
30//-----------------------------------------------------------------------------
31
c801d85f
KB
32class wxMask;
33class wxBitmap;
fd859211 34class wxImage;
c801d85f
KB
35
36//-----------------------------------------------------------------------------
37// wxMask
38//-----------------------------------------------------------------------------
39
40class wxMask: public wxObject
41{
fd0eed64 42public:
8636aed8
RR
43 wxMask();
44 wxMask( const wxBitmap& bitmap, const wxColour& colour );
45 wxMask( const wxBitmap& bitmap, int paletteIndex );
46 wxMask( const wxBitmap& bitmap );
47 ~wxMask();
91b8de8d 48
8636aed8
RR
49 bool Create( const wxBitmap& bitmap, const wxColour& colour );
50 bool Create( const wxBitmap& bitmap, int paletteIndex );
51 bool Create( const wxBitmap& bitmap );
52
53 // implementation
54 GdkBitmap *m_bitmap;
55
56 GdkBitmap *GetBitmap() const;
57
58private:
59 DECLARE_DYNAMIC_CLASS(wxMask)
c801d85f
KB
60};
61
62//-----------------------------------------------------------------------------
63// wxBitmap
64//-----------------------------------------------------------------------------
65
58c837a4 66class wxBitmap: public wxGDIObject
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
RR
74 wxBitmap( const wxBitmap& bmp );
75 wxBitmap( const wxString &filename, int 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
RR
83 bool Create(int width, int height, int depth = -1);
84
8636aed8
RR
85 int GetHeight() const;
86 int GetWidth() const;
87 int GetDepth() const;
fd859211
VS
88
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 );
17bec151
RR
96
97 wxBitmap GetSubBitmap( const wxRect& rect ) const;
8636aed8
RR
98
99 bool SaveFile( const wxString &name, int type, wxPalette *palette = (wxPalette *) NULL );
100 bool LoadFile( const wxString &name, int type = wxBITMAP_TYPE_XPM );
101
102 wxPalette *GetPalette() const;
55e90a2e
VZ
103 wxPalette *GetColourMap() const { return GetPalette(); };
104
105 static void InitStandardHandlers() { }
106 static void CleanUpHandlers() { }
8bbe427f 107
8636aed8 108 // implementation
20e05ffb 109 // --------------
c801d85f 110
8636aed8
RR
111 void SetHeight( int height );
112 void SetWidth( int width );
113 void SetDepth( int depth );
114 void SetPixmap( GdkPixmap *pixmap );
82ea63e6 115 void SetBitmap( GdkBitmap *bitmap );
feac7937
VS
116#ifdef __WXGTK20__
117 void SetPixbuf(GdkPixbuf *pixbuf);
118#endif
8bbe427f 119
8636aed8
RR
120 GdkPixmap *GetPixmap() const;
121 GdkBitmap *GetBitmap() const;
feac7937
VS
122 bool HasPixmap() const;
123#ifdef __WXGTK20__
124 bool HasPixbuf() const;
125 GdkPixbuf *GetPixbuf() const;
126#endif
8636aed8 127
783da845
RR
128 // Basically, this corresponds to Win32 StretchBlt()
129 wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
e838cc14
VZ
130protected:
131 bool CreateFromXpm(const char **bits);
fd859211 132 bool CreateFromImage(const wxImage& image, int depth);
e838cc14 133
8636aed8 134private:
feac7937
VS
135 // to be called from CreateFromImage only!
136 bool CreateFromImageAsBitmap(const wxImage& image);
137 bool CreateFromImageAsPixmap(const wxImage& image);
138
139#ifdef __WXGTK20__
140 bool CreateFromImageAsPixbuf(const wxImage& image);
141
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
151 friend class wxMemoryDC;
152#endif
153
8636aed8 154 DECLARE_DYNAMIC_CLASS(wxBitmap)
c801d85f
KB
155};
156
157#endif // __GTKBITMAPH__