]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/bitmap.h
Remove GTK2 specific prototypes from wx/include/gtk1. wx/gtk1/hdr into the header...
[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 WXDLLEXPORT wxPixelDataBase;
21
22 //-----------------------------------------------------------------------------
23 // classes
24 //-----------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_CORE wxMask;
27 class WXDLLIMPEXP_CORE wxBitmap;
28 class WXDLLIMPEXP_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 ~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 **bits ) { (void)CreateFromXpm(bits); }
71 wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); }
72 wxBitmap( const wxBitmap& bmp );
73 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
74 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
75 ~wxBitmap();
76 wxBitmap& operator = ( const wxBitmap& bmp );
77 bool operator == ( const wxBitmap& bmp ) const;
78 bool operator != ( const wxBitmap& bmp ) const;
79 bool Ok() const;
80
81 bool Create(int width, int height, int depth = -1);
82
83 int GetHeight() const;
84 int GetWidth() const;
85 int GetDepth() const;
86
87 wxImage ConvertToImage() const;
88
89 // copies the contents and mask of the given (colour) icon to the bitmap
90 virtual bool CopyFromIcon(const wxIcon& icon);
91
92 wxMask *GetMask() const;
93 void SetMask( wxMask *mask );
94
95 wxBitmap GetSubBitmap( const wxRect& rect ) const;
96
97 bool SaveFile(const wxString &name, wxBitmapType type,
98 const wxPalette *palette = (wxPalette *)NULL) const;
99 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
100
101 #if wxUSE_PALETTE
102 wxPalette *GetPalette() const;
103 void SetPalette(const wxPalette& palette);
104 wxPalette *GetColourMap() const { return GetPalette(); };
105 #endif // wxUSE_PALETTE
106
107 static void InitStandardHandlers();
108
109 // implementation
110 // --------------
111
112 void SetHeight( int height );
113 void SetWidth( int width );
114 void SetDepth( int depth );
115 void SetPixmap( GdkPixmap *pixmap );
116 void SetBitmap( GdkBitmap *bitmap );
117
118 GdkPixmap *GetPixmap() const;
119 GdkBitmap *GetBitmap() const;
120 bool HasPixmap() const;
121
122 // Basically, this corresponds to Win32 StretchBlt()
123 wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
124
125 // raw bitmap access support functions
126 void *GetRawData(wxPixelDataBase& data, int bpp);
127 void UngetRawData(wxPixelDataBase& data);
128
129 bool HasAlpha() const;
130 void UseAlpha();
131
132 protected:
133 bool CreateFromXpm(const char **bits);
134 bool CreateFromImage(const wxImage& image, int depth);
135
136 private:
137 // to be called from CreateFromImage only!
138 bool CreateFromImageAsBitmap(const wxImage& image);
139 bool CreateFromImageAsPixmap(const wxImage& image);
140
141 friend class wxBitmapHandler;
142
143 private:
144 DECLARE_DYNAMIC_CLASS(wxBitmap)
145 };
146
147 //-----------------------------------------------------------------------------
148 // wxBitmapHandler
149 //-----------------------------------------------------------------------------
150
151 class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
152 {
153 public:
154 wxBitmapHandler() { }
155 virtual ~wxBitmapHandler();
156
157 virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
158 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
159 int desiredWidth, int desiredHeight);
160 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
161
162 private:
163 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
164 };
165
166
167 #endif // __GTKBITMAPH__