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