]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/bitmap.h
simplify the test, don't reuse the same macro for different things
[wxWidgets.git] / include / wx / gtk1 / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/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 #include "wx/defs.h"
15 #include "wx/object.h"
16 #include "wx/string.h"
17 #include "wx/palette.h"
18 #include "wx/gdiobj.h"
19
20 class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
21
22 //-----------------------------------------------------------------------------
23 // classes
24 //-----------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_FWD_CORE wxMask;
27 class WXDLLIMPEXP_FWD_CORE wxBitmap;
28 class WXDLLIMPEXP_FWD_CORE wxImage;
29
30 //-----------------------------------------------------------------------------
31 // wxMask
32 //-----------------------------------------------------------------------------
33
34 class WXDLLIMPEXP_CORE wxMask: public wxObject
35 {
36 public:
37 wxMask();
38 wxMask( const wxBitmap& bitmap, const wxColour& colour );
39 #if wxUSE_PALETTE
40 wxMask( const wxBitmap& bitmap, int paletteIndex );
41 #endif // wxUSE_PALETTE
42 wxMask( const wxBitmap& bitmap );
43 virtual ~wxMask();
44
45 bool Create( const wxBitmap& bitmap, const wxColour& colour );
46 #if wxUSE_PALETTE
47 bool Create( const wxBitmap& bitmap, int paletteIndex );
48 #endif // wxUSE_PALETTE
49 bool Create( const wxBitmap& bitmap );
50
51 // implementation
52 GdkBitmap *m_bitmap;
53
54 GdkBitmap *GetBitmap() const;
55
56 private:
57 DECLARE_DYNAMIC_CLASS(wxMask)
58 };
59
60 //-----------------------------------------------------------------------------
61 // wxBitmap
62 //-----------------------------------------------------------------------------
63
64 class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
65 {
66 public:
67 wxBitmap();
68 wxBitmap( int width, int height, int depth = -1 );
69 wxBitmap( const char bits[], int width, int height, int depth = 1 );
70 wxBitmap( const char* const* bits );
71 #ifdef wxNEEDS_CHARPP
72 // needed for old GCC
73 wxBitmap(char** data)
74 {
75 *this = wxBitmap(wx_const_cast(const char* const*, data));
76 }
77 #endif
78 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
79 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
80 virtual ~wxBitmap();
81
82 bool Create(int width, int height, int depth = -1);
83
84 virtual int GetHeight() const;
85 virtual int GetWidth() const;
86 virtual int GetDepth() const;
87
88 wxImage ConvertToImage() const;
89
90 // copies the contents and mask of the given (colour) icon to the bitmap
91 virtual bool CopyFromIcon(const wxIcon& icon);
92
93 wxMask *GetMask() const;
94 void SetMask( wxMask *mask );
95
96 wxBitmap GetSubBitmap( const wxRect& rect ) const;
97
98 bool SaveFile(const wxString &name, wxBitmapType type,
99 const wxPalette *palette = (wxPalette *)NULL) const;
100 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
101
102 #if wxUSE_PALETTE
103 wxPalette *GetPalette() const;
104 void SetPalette(const wxPalette& palette);
105 wxPalette *GetColourMap() const { return GetPalette(); };
106 #endif // wxUSE_PALETTE
107
108 static void InitStandardHandlers();
109
110 // implementation
111 // --------------
112
113 void SetHeight( int height );
114 void SetWidth( int width );
115 void SetDepth( int depth );
116 void SetPixmap( GdkPixmap *pixmap );
117 void SetBitmap( GdkBitmap *bitmap );
118
119 GdkPixmap *GetPixmap() const;
120 GdkBitmap *GetBitmap() const;
121 bool HasPixmap() const;
122
123 // Basically, this corresponds to Win32 StretchBlt()
124 wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
125
126 // raw bitmap access support functions
127 void *GetRawData(wxPixelDataBase& data, int bpp);
128 void UngetRawData(wxPixelDataBase& data);
129
130 bool HasAlpha() const;
131
132 protected:
133 bool CreateFromImage(const wxImage& image, int depth);
134
135 virtual wxGDIRefData *CreateGDIRefData() const;
136 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
137
138 private:
139 // to be called from CreateFromImage only!
140 bool CreateFromImageAsBitmap(const wxImage& image);
141 bool CreateFromImageAsPixmap(const wxImage& image);
142
143 friend class wxBitmapHandler;
144
145 private:
146 DECLARE_DYNAMIC_CLASS(wxBitmap)
147 };
148
149
150 #endif // __GTKBITMAPH__