]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/bitmap.h
Applied rowspan patch #15276 (dghart)
[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 ) { Create( width, height, depth ); }
69 wxBitmap( const wxSize& sz, int depth = -1 ) { Create( sz, depth ); }
70 wxBitmap( const char bits[], int width, int height, int depth = 1 );
71 wxBitmap( const char* const* bits );
72 #ifdef wxNEEDS_CHARPP
73 // needed for old GCC
74 wxBitmap(char** data)
75 {
76 *this = wxBitmap(const_cast<const char* const*>(data));
77 }
78 #endif
79 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
80 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
81 virtual ~wxBitmap();
82
83 bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
84 bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
85 { return Create(sz.GetWidth(), sz.GetHeight(), depth); }
86
87 virtual int GetHeight() const;
88 virtual int GetWidth() const;
89 virtual int GetDepth() const;
90
91 wxImage ConvertToImage() const;
92
93 // copies the contents and mask of the given (colour) icon to the bitmap
94 virtual bool CopyFromIcon(const wxIcon& icon);
95
96 wxMask *GetMask() const;
97 void SetMask( wxMask *mask );
98
99 wxBitmap GetSubBitmap( const wxRect& rect ) const;
100
101 bool SaveFile(const wxString &name, wxBitmapType type,
102 const wxPalette *palette = NULL) const;
103 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
104
105 #if wxUSE_PALETTE
106 wxPalette *GetPalette() const;
107 void SetPalette(const wxPalette& palette);
108 wxPalette *GetColourMap() const { return GetPalette(); }
109 #endif // wxUSE_PALETTE
110
111 static void InitStandardHandlers();
112
113 // implementation
114 // --------------
115
116 void SetHeight( int height );
117 void SetWidth( int width );
118 void SetDepth( int depth );
119 void SetPixmap( GdkPixmap *pixmap );
120 void SetBitmap( GdkBitmap *bitmap );
121
122 GdkPixmap *GetPixmap() const;
123 GdkBitmap *GetBitmap() const;
124 bool HasPixmap() const;
125
126 // Basically, this corresponds to Win32 StretchBlt()
127 wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
128
129 // raw bitmap access support functions
130 void *GetRawData(wxPixelDataBase& data, int bpp);
131 void UngetRawData(wxPixelDataBase& data);
132
133 bool HasAlpha() const;
134
135 protected:
136 bool CreateFromImage(const wxImage& image, int depth);
137
138 virtual wxGDIRefData *CreateGDIRefData() const;
139 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
140
141 private:
142 // to be called from CreateFromImage only!
143 bool CreateFromImageAsBitmap(const wxImage& image);
144 bool CreateFromImageAsPixmap(const wxImage& image);
145
146 friend class wxBitmapHandler;
147
148 private:
149 DECLARE_DYNAMIC_CLASS(wxBitmap)
150 };
151
152
153 #endif // __GTKBITMAPH__