]>
Commit | Line | Data |
---|---|---|
83df96d6 | 1 | ///////////////////////////////////////////////////////////////////////////// |
6298b8d0 | 2 | // Name: x11/bitmap.h |
83df96d6 | 3 | // Purpose: wxBitmap class |
a11672a4 | 4 | // Author: Julian Smart, Robert Roebling |
83df96d6 JS |
5 | // Modified by: |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
a11672a4 | 8 | // Copyright: (c) Julian Smart, Robert Roebling |
65571936 | 9 | // Licence: wxWindows licence |
83df96d6 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_BITMAP_H_ | |
13 | #define _WX_BITMAP_H_ | |
14 | ||
a11672a4 RR |
15 | #include "wx/defs.h" |
16 | #include "wx/object.h" | |
17 | #include "wx/string.h" | |
83df96d6 | 18 | #include "wx/palette.h" |
a11672a4 RR |
19 | #include "wx/gdiobj.h" |
20 | ||
21 | //----------------------------------------------------------------------------- | |
22 | // classes | |
23 | //----------------------------------------------------------------------------- | |
24 | ||
968eb2ef MW |
25 | class WXDLLIMPEXP_CORE wxMask; |
26 | class WXDLLIMPEXP_CORE wxBitmap; | |
27 | class WXDLLIMPEXP_CORE wxImage; | |
83df96d6 | 28 | |
a11672a4 RR |
29 | //----------------------------------------------------------------------------- |
30 | // wxMask | |
31 | //----------------------------------------------------------------------------- | |
32 | ||
968eb2ef | 33 | class WXDLLIMPEXP_CORE wxMask: public wxObject |
83df96d6 | 34 | { |
83df96d6 JS |
35 | public: |
36 | wxMask(); | |
a11672a4 RR |
37 | wxMask( const wxBitmap& bitmap, const wxColour& colour ); |
38 | wxMask( const wxBitmap& bitmap, int paletteIndex ); | |
39 | wxMask( const wxBitmap& bitmap ); | |
83df96d6 | 40 | ~wxMask(); |
6298b8d0 | 41 | |
a11672a4 RR |
42 | bool Create( const wxBitmap& bitmap, const wxColour& colour ); |
43 | bool Create( const wxBitmap& bitmap, int paletteIndex ); | |
44 | bool Create( const wxBitmap& bitmap ); | |
83df96d6 | 45 | |
a11672a4 RR |
46 | // implementation |
47 | WXPixmap GetBitmap() const { return m_bitmap; } | |
48 | void SetBitmap( WXPixmap bitmap ) { m_bitmap = bitmap; } | |
6298b8d0 | 49 | |
a11672a4 RR |
50 | WXDisplay *GetDisplay() const { return m_display; } |
51 | void SetDisplay( WXDisplay *display ) { m_display = display; } | |
6298b8d0 | 52 | |
a11672a4 RR |
53 | private: |
54 | WXPixmap m_bitmap; | |
55 | WXDisplay *m_display; | |
6298b8d0 | 56 | |
a11672a4 RR |
57 | private: |
58 | DECLARE_DYNAMIC_CLASS(wxMask) | |
83df96d6 JS |
59 | }; |
60 | ||
a11672a4 RR |
61 | //----------------------------------------------------------------------------- |
62 | // wxBitmap | |
63 | //----------------------------------------------------------------------------- | |
83df96d6 | 64 | |
62ad3cb3 MB |
65 | class WXDLLEXPORT wxBitmapHandler : public wxBitmapHandlerBase |
66 | { | |
67 | public: | |
68 | wxBitmapHandler() : wxBitmapHandlerBase() {} | |
69 | private: | |
70 | DECLARE_DYNAMIC_CLASS(wxBitmapHandler) | |
71 | }; | |
72 | ||
968eb2ef | 73 | class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase |
83df96d6 | 74 | { |
83df96d6 | 75 | public: |
a11672a4 RR |
76 | wxBitmap(); |
77 | wxBitmap( int width, int height, int depth = -1 ); | |
78 | wxBitmap( const char bits[], int width, int height, int depth = 1 ); | |
79 | wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); } | |
80 | wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); } | |
81 | wxBitmap( const wxBitmap& bmp ); | |
62ad3cb3 | 82 | wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM ); |
6298b8d0 VZ |
83 | virtual ~wxBitmap(); |
84 | ||
a11672a4 RR |
85 | wxBitmap& operator = ( const wxBitmap& bmp ); |
86 | bool operator == ( const wxBitmap& bmp ) const; | |
87 | bool operator != ( const wxBitmap& bmp ) const; | |
88 | bool Ok() const; | |
89 | ||
62ad3cb3 MB |
90 | static void InitStandardHandlers(); |
91 | ||
a11672a4 | 92 | bool Create(int width, int height, int depth = -1); |
62ad3cb3 MB |
93 | bool Create(void* data, wxBitmapType type, |
94 | int width, int height, int depth = -1); | |
dd38c875 MB |
95 | // create the wxBitmap using a _copy_ of the pixmap |
96 | bool Create(WXPixmap pixmap); | |
62ad3cb3 | 97 | |
a11672a4 RR |
98 | int GetHeight() const; |
99 | int GetWidth() const; | |
100 | int GetDepth() const; | |
6298b8d0 VZ |
101 | |
102 | #if wxUSE_IMAGE | |
103 | wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } | |
a11672a4 | 104 | wxImage ConvertToImage() const; |
6298b8d0 VZ |
105 | bool CreateFromImage(const wxImage& image, int depth = -1); |
106 | #endif // wxUSE_IMAGE | |
83df96d6 | 107 | |
a11672a4 RR |
108 | // copies the contents and mask of the given (colour) icon to the bitmap |
109 | virtual bool CopyFromIcon(const wxIcon& icon); | |
83df96d6 | 110 | |
a11672a4 RR |
111 | wxMask *GetMask() const; |
112 | void SetMask( wxMask *mask ); | |
6298b8d0 | 113 | |
83df96d6 | 114 | wxBitmap GetSubBitmap( const wxRect& rect ) const; |
7266b672 | 115 | |
62ad3cb3 MB |
116 | bool SaveFile( const wxString &name, wxBitmapType type, const wxPalette *palette = (wxPalette *) NULL ) const; |
117 | bool LoadFile( const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM ); | |
a11672a4 RR |
118 | |
119 | wxPalette *GetPalette() const; | |
120 | wxPalette *GetColourMap() const | |
121 | { return GetPalette(); }; | |
62ad3cb3 | 122 | virtual void SetPalette(const wxPalette& palette); |
a11672a4 RR |
123 | |
124 | // implementation | |
125 | // -------------- | |
126 | ||
127 | void SetHeight( int height ); | |
128 | void SetWidth( int width ); | |
129 | void SetDepth( int depth ); | |
130 | void SetPixmap( WXPixmap pixmap ); | |
131 | void SetBitmap( WXPixmap bitmap ); | |
132 | ||
133 | WXPixmap GetPixmap() const; | |
134 | WXPixmap GetBitmap() const; | |
a29c6824 MB |
135 | |
136 | WXPixmap GetDrawable() const; | |
137 | ||
a11672a4 | 138 | WXDisplay *GetDisplay() const; |
6298b8d0 | 139 | |
83df96d6 | 140 | protected: |
a11672a4 | 141 | bool CreateFromXpm(const char **bits); |
83df96d6 | 142 | |
a11672a4 RR |
143 | private: |
144 | DECLARE_DYNAMIC_CLASS(wxBitmap) | |
145 | }; | |
83df96d6 JS |
146 | |
147 | #endif | |
148 | // _WX_BITMAP_H_ |