]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/bitmap.h
wxWinCE fixes.
[wxWidgets.git] / include / wx / gtk / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: bitmap.h
3 // Purpose:
4 // Author: Robert Roebling
5 // RCS-ID: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10
11 #ifndef __GTKBITMAPH__
12 #define __GTKBITMAPH__
13
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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"
22 #include "wx/gdiobj.h"
23
24 #ifdef __WXGTK20__
25 typedef struct _GdkPixbuf GdkPixbuf;
26 #endif
27
28 //-----------------------------------------------------------------------------
29 // classes
30 //-----------------------------------------------------------------------------
31
32 class wxMask;
33 class wxBitmap;
34 class wxImage;
35
36 //-----------------------------------------------------------------------------
37 // wxMask
38 //-----------------------------------------------------------------------------
39
40 class wxMask: public wxObject
41 {
42 public:
43 wxMask();
44 wxMask( const wxBitmap& bitmap, const wxColour& colour );
45 wxMask( const wxBitmap& bitmap, int paletteIndex );
46 wxMask( const wxBitmap& bitmap );
47 ~wxMask();
48
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
58 private:
59 DECLARE_DYNAMIC_CLASS(wxMask)
60 };
61
62 //-----------------------------------------------------------------------------
63 // wxBitmap
64 //-----------------------------------------------------------------------------
65
66 class wxBitmap: public wxGDIObject
67 {
68 public:
69 wxBitmap();
70 wxBitmap( int width, int height, int depth = -1 );
71 wxBitmap( const char bits[], int width, int height, int depth = 1 );
72 wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); }
73 wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); }
74 wxBitmap( const wxBitmap& bmp );
75 wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM );
76 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
77 ~wxBitmap();
78 wxBitmap& operator = ( const wxBitmap& bmp );
79 bool operator == ( const wxBitmap& bmp ) const;
80 bool operator != ( const wxBitmap& bmp ) const;
81 bool Ok() const;
82
83 bool Create(int width, int height, int depth = -1);
84
85 int GetHeight() const;
86 int GetWidth() const;
87 int GetDepth() const;
88
89 wxImage ConvertToImage() const;
90
91 // copies the contents and mask of the given (colour) icon to the bitmap
92 virtual bool CopyFromIcon(const wxIcon& icon);
93
94 wxMask *GetMask() const;
95 void SetMask( wxMask *mask );
96
97 wxBitmap GetSubBitmap( const wxRect& rect ) const;
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;
103 wxPalette *GetColourMap() const { return GetPalette(); };
104
105 static void InitStandardHandlers() { }
106 static void CleanUpHandlers() { }
107
108 // implementation
109 // --------------
110
111 void SetHeight( int height );
112 void SetWidth( int width );
113 void SetDepth( int depth );
114 void SetPixmap( GdkPixmap *pixmap );
115 void SetBitmap( GdkBitmap *bitmap );
116 #ifdef __WXGTK20__
117 void SetPixbuf(GdkPixbuf *pixbuf);
118 #endif
119
120 GdkPixmap *GetPixmap() const;
121 GdkBitmap *GetBitmap() const;
122 bool HasPixmap() const;
123 #ifdef __WXGTK20__
124 bool HasPixbuf() const;
125 GdkPixbuf *GetPixbuf() const;
126 #endif
127
128 // Basically, this corresponds to Win32 StretchBlt()
129 wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
130 protected:
131 bool CreateFromXpm(const char **bits);
132 bool CreateFromImage(const wxImage& image, int depth);
133
134 private:
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
154 DECLARE_DYNAMIC_CLASS(wxBitmap)
155 };
156
157 #endif // __GTKBITMAPH__