]>
Commit | Line | Data |
---|---|---|
83df96d6 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/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 | ||
b5dbe15d VS |
25 | class WXDLLIMPEXP_FWD_CORE wxMask; |
26 | class WXDLLIMPEXP_FWD_CORE wxBitmap; | |
27 | class WXDLLIMPEXP_FWD_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(); | |
04a8da5f | 37 | wxMask(const wxMask& mask); |
a11672a4 RR |
38 | wxMask( const wxBitmap& bitmap, const wxColour& colour ); |
39 | wxMask( const wxBitmap& bitmap, int paletteIndex ); | |
40 | wxMask( const wxBitmap& bitmap ); | |
d3c7fc99 | 41 | virtual ~wxMask(); |
6298b8d0 | 42 | |
a11672a4 RR |
43 | bool Create( const wxBitmap& bitmap, const wxColour& colour ); |
44 | bool Create( const wxBitmap& bitmap, int paletteIndex ); | |
45 | bool Create( const wxBitmap& bitmap ); | |
83df96d6 | 46 | |
a11672a4 RR |
47 | // implementation |
48 | WXPixmap GetBitmap() const { return m_bitmap; } | |
49 | void SetBitmap( WXPixmap bitmap ) { m_bitmap = bitmap; } | |
6298b8d0 | 50 | |
a11672a4 RR |
51 | WXDisplay *GetDisplay() const { return m_display; } |
52 | void SetDisplay( WXDisplay *display ) { m_display = display; } | |
6298b8d0 | 53 | |
a11672a4 RR |
54 | private: |
55 | WXPixmap m_bitmap; | |
56 | WXDisplay *m_display; | |
04a8da5f | 57 | wxSize m_size; |
6298b8d0 | 58 | |
a11672a4 RR |
59 | private: |
60 | DECLARE_DYNAMIC_CLASS(wxMask) | |
83df96d6 JS |
61 | }; |
62 | ||
a11672a4 RR |
63 | //----------------------------------------------------------------------------- |
64 | // wxBitmap | |
65 | //----------------------------------------------------------------------------- | |
83df96d6 | 66 | |
968eb2ef | 67 | class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase |
83df96d6 | 68 | { |
83df96d6 | 69 | public: |
732d8c74 FM |
70 | wxBitmap() {} |
71 | wxBitmap( int width, int height, int depth = -1 ) { Create( width, height, depth ); } | |
72 | wxBitmap( const wxSize& sz, int depth = -1 ) { Create( sz, depth ); } | |
03647350 | 73 | |
a11672a4 | 74 | wxBitmap( const char bits[], int width, int height, int depth = 1 ); |
452418c4 | 75 | wxBitmap( const char* const* bits ); |
459f812b | 76 | #ifdef wxNEEDS_CHARPP |
4a4bf7ee SN |
77 | // needed for old GCC |
78 | wxBitmap(char** data) | |
79 | { | |
5c33522f | 80 | *this = wxBitmap(const_cast<const char* const*>(data)); |
4a4bf7ee SN |
81 | } |
82 | #endif | |
cbea3ec6 | 83 | wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE ); |
6298b8d0 VZ |
84 | virtual ~wxBitmap(); |
85 | ||
62ad3cb3 MB |
86 | static void InitStandardHandlers(); |
87 | ||
732d8c74 FM |
88 | bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); |
89 | bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) | |
90 | { return Create(sz.GetWidth(), sz.GetHeight(), depth); } | |
91 | ||
452418c4 | 92 | bool Create(const void* data, wxBitmapType type, |
62ad3cb3 | 93 | int width, int height, int depth = -1); |
dd38c875 MB |
94 | // create the wxBitmap using a _copy_ of the pixmap |
95 | bool Create(WXPixmap pixmap); | |
62ad3cb3 | 96 | |
a11672a4 RR |
97 | int GetHeight() const; |
98 | int GetWidth() const; | |
99 | int GetDepth() const; | |
6298b8d0 VZ |
100 | |
101 | #if wxUSE_IMAGE | |
102 | wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } | |
a11672a4 | 103 | wxImage ConvertToImage() const; |
6298b8d0 VZ |
104 | bool CreateFromImage(const wxImage& image, int depth = -1); |
105 | #endif // wxUSE_IMAGE | |
83df96d6 | 106 | |
a11672a4 RR |
107 | // copies the contents and mask of the given (colour) icon to the bitmap |
108 | virtual bool CopyFromIcon(const wxIcon& icon); | |
83df96d6 | 109 | |
a11672a4 RR |
110 | wxMask *GetMask() const; |
111 | void SetMask( wxMask *mask ); | |
6298b8d0 | 112 | |
83df96d6 | 113 | wxBitmap GetSubBitmap( const wxRect& rect ) const; |
7266b672 | 114 | |
d3b9f782 | 115 | bool SaveFile( const wxString &name, wxBitmapType type, const wxPalette *palette = NULL ) const; |
cbea3ec6 | 116 | bool LoadFile( const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE ); |
a11672a4 RR |
117 | |
118 | wxPalette *GetPalette() const; | |
119 | wxPalette *GetColourMap() const | |
120 | { return GetPalette(); }; | |
62ad3cb3 | 121 | virtual void SetPalette(const wxPalette& palette); |
a11672a4 RR |
122 | |
123 | // implementation | |
124 | // -------------- | |
125 | ||
126 | void SetHeight( int height ); | |
127 | void SetWidth( int width ); | |
128 | void SetDepth( int depth ); | |
129 | void SetPixmap( WXPixmap pixmap ); | |
130 | void SetBitmap( WXPixmap bitmap ); | |
131 | ||
132 | WXPixmap GetPixmap() const; | |
133 | WXPixmap GetBitmap() const; | |
a29c6824 MB |
134 | |
135 | WXPixmap GetDrawable() const; | |
136 | ||
a11672a4 | 137 | WXDisplay *GetDisplay() const; |
6298b8d0 | 138 | |
dd21c826 | 139 | protected: |
8f884a0d VZ |
140 | virtual wxGDIRefData *CreateGDIRefData() const; |
141 | virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; | |
dd21c826 | 142 | |
a11672a4 RR |
143 | private: |
144 | DECLARE_DYNAMIC_CLASS(wxBitmap) | |
145 | }; | |
83df96d6 | 146 | |
dd21c826 | 147 | #endif // _WX_BITMAP_H_ |