]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
8ef94bfc | 2 | // Name: wx/gtk1/bitmap.h |
c801d85f KB |
3 | // Purpose: |
4 | // Author: Robert Roebling | |
01111366 | 5 | // Copyright: (c) 1998 Robert Roebling |
65571936 | 6 | // Licence: wxWindows licence |
c801d85f KB |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
9 | ||
10 | #ifndef __GTKBITMAPH__ | |
11 | #define __GTKBITMAPH__ | |
12 | ||
c801d85f KB |
13 | #include "wx/defs.h" |
14 | #include "wx/object.h" | |
15 | #include "wx/string.h" | |
16 | #include "wx/palette.h" | |
58c837a4 | 17 | #include "wx/gdiobj.h" |
c801d85f | 18 | |
b5dbe15d | 19 | class WXDLLIMPEXP_FWD_CORE wxPixelDataBase; |
f383c5b8 | 20 | |
c801d85f KB |
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; | |
c801d85f KB |
28 | |
29 | //----------------------------------------------------------------------------- | |
30 | // wxMask | |
31 | //----------------------------------------------------------------------------- | |
32 | ||
20123d49 | 33 | class WXDLLIMPEXP_CORE wxMask: public wxObject |
c801d85f | 34 | { |
fd0eed64 | 35 | public: |
8636aed8 RR |
36 | wxMask(); |
37 | wxMask( const wxBitmap& bitmap, const wxColour& colour ); | |
0b04c4e0 | 38 | #if wxUSE_PALETTE |
8636aed8 | 39 | wxMask( const wxBitmap& bitmap, int paletteIndex ); |
0b04c4e0 | 40 | #endif // wxUSE_PALETTE |
8636aed8 | 41 | wxMask( const wxBitmap& bitmap ); |
d3c7fc99 | 42 | virtual ~wxMask(); |
0b04c4e0 | 43 | |
8636aed8 | 44 | bool Create( const wxBitmap& bitmap, const wxColour& colour ); |
0b04c4e0 | 45 | #if wxUSE_PALETTE |
8636aed8 | 46 | bool Create( const wxBitmap& bitmap, int paletteIndex ); |
0b04c4e0 | 47 | #endif // wxUSE_PALETTE |
8636aed8 RR |
48 | bool Create( const wxBitmap& bitmap ); |
49 | ||
50 | // implementation | |
51 | GdkBitmap *m_bitmap; | |
0b04c4e0 | 52 | |
8636aed8 | 53 | GdkBitmap *GetBitmap() const; |
0b04c4e0 | 54 | |
8636aed8 RR |
55 | private: |
56 | DECLARE_DYNAMIC_CLASS(wxMask) | |
c801d85f KB |
57 | }; |
58 | ||
59 | //----------------------------------------------------------------------------- | |
60 | // wxBitmap | |
61 | //----------------------------------------------------------------------------- | |
62 | ||
20123d49 | 63 | class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase |
c801d85f | 64 | { |
fd0eed64 | 65 | public: |
732d8c74 FM |
66 | wxBitmap() {} |
67 | wxBitmap( int width, int height, int depth = -1 ) { Create( width, height, depth ); } | |
68 | wxBitmap( const wxSize& sz, int depth = -1 ) { Create( sz, depth ); } | |
8636aed8 | 69 | wxBitmap( const char bits[], int width, int height, int depth = 1 ); |
452418c4 | 70 | wxBitmap( const char* const* bits ); |
459f812b | 71 | #ifdef wxNEEDS_CHARPP |
4a4bf7ee SN |
72 | // needed for old GCC |
73 | wxBitmap(char** data) | |
74 | { | |
5c33522f | 75 | *this = wxBitmap(const_cast<const char* const*>(data)); |
4a4bf7ee SN |
76 | } |
77 | #endif | |
cbea3ec6 | 78 | wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE ); |
fd859211 | 79 | wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } |
d3c7fc99 | 80 | virtual ~wxBitmap(); |
8636aed8 | 81 | |
732d8c74 FM |
82 | bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); |
83 | bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) | |
84 | { return Create(sz.GetWidth(), sz.GetHeight(), depth); } | |
7f74897f SC |
85 | bool Create(int width, int height, const wxDC& WXUNUSED(dc)) |
86 | { return Create(width,height); } | |
0b04c4e0 | 87 | |
8f884a0d VZ |
88 | virtual int GetHeight() const; |
89 | virtual int GetWidth() const; | |
90 | virtual int GetDepth() const; | |
0b04c4e0 | 91 | |
fd859211 | 92 | wxImage ConvertToImage() const; |
8636aed8 | 93 | |
db0aec83 VS |
94 | // copies the contents and mask of the given (colour) icon to the bitmap |
95 | virtual bool CopyFromIcon(const wxIcon& icon); | |
96 | ||
8636aed8 RR |
97 | wxMask *GetMask() const; |
98 | void SetMask( wxMask *mask ); | |
0b04c4e0 | 99 | |
17bec151 | 100 | wxBitmap GetSubBitmap( const wxRect& rect ) const; |
8636aed8 | 101 | |
4611dd06 | 102 | bool SaveFile(const wxString &name, wxBitmapType type, |
d3b9f782 | 103 | const wxPalette *palette = NULL) const; |
cbea3ec6 | 104 | bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); |
8636aed8 | 105 | |
4611dd06 | 106 | #if wxUSE_PALETTE |
8636aed8 | 107 | wxPalette *GetPalette() const; |
4611dd06 | 108 | void SetPalette(const wxPalette& palette); |
6dd0883d | 109 | wxPalette *GetColourMap() const { return GetPalette(); } |
4611dd06 | 110 | #endif // wxUSE_PALETTE |
55e90a2e | 111 | |
4b61c88d | 112 | static void InitStandardHandlers(); |
8bbe427f | 113 | |
8636aed8 | 114 | // implementation |
20e05ffb | 115 | // -------------- |
c801d85f | 116 | |
8636aed8 RR |
117 | void SetHeight( int height ); |
118 | void SetWidth( int width ); | |
119 | void SetDepth( int depth ); | |
120 | void SetPixmap( GdkPixmap *pixmap ); | |
82ea63e6 | 121 | void SetBitmap( GdkBitmap *bitmap ); |
8bbe427f | 122 | |
8636aed8 RR |
123 | GdkPixmap *GetPixmap() const; |
124 | GdkBitmap *GetBitmap() const; | |
feac7937 | 125 | bool HasPixmap() const; |
0b04c4e0 | 126 | |
783da845 RR |
127 | // Basically, this corresponds to Win32 StretchBlt() |
128 | wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height ); | |
0b04c4e0 | 129 | |
284f2b59 RR |
130 | // raw bitmap access support functions |
131 | void *GetRawData(wxPixelDataBase& data, int bpp); | |
132 | void UngetRawData(wxPixelDataBase& data); | |
133 | ||
0ff2a74d | 134 | bool HasAlpha() const; |
d2400c3f | 135 | |
e838cc14 | 136 | protected: |
fd859211 | 137 | bool CreateFromImage(const wxImage& image, int depth); |
e838cc14 | 138 | |
8f884a0d VZ |
139 | virtual wxGDIRefData *CreateGDIRefData() const; |
140 | virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; | |
39b0ab4a | 141 | |
8636aed8 | 142 | private: |
feac7937 VS |
143 | // to be called from CreateFromImage only! |
144 | bool CreateFromImageAsBitmap(const wxImage& image); | |
145 | bool CreateFromImageAsPixmap(const wxImage& image); | |
146 | ||
4b61c88d RR |
147 | friend class wxBitmapHandler; |
148 | ||
0b04c4e0 | 149 | private: |
8636aed8 | 150 | DECLARE_DYNAMIC_CLASS(wxBitmap) |
c801d85f KB |
151 | }; |
152 | ||
4b61c88d | 153 | |
c801d85f | 154 | #endif // __GTKBITMAPH__ |