]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/gtk/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 | #ifndef _WX_GTK_BITMAP_H_ | |
11 | #define _WX_GTK_BITMAP_H_ | |
12 | ||
13 | typedef struct _GdkPixbuf GdkPixbuf; | |
14 | class WXDLLIMPEXP_FWD_CORE wxPixelDataBase; | |
15 | ||
16 | //----------------------------------------------------------------------------- | |
17 | // wxMask | |
18 | //----------------------------------------------------------------------------- | |
19 | ||
20 | class WXDLLIMPEXP_CORE wxMask: public wxMaskBase | |
21 | { | |
22 | public: | |
23 | wxMask(); | |
24 | wxMask(const wxMask& mask); | |
25 | wxMask( const wxBitmap& bitmap, const wxColour& colour ); | |
26 | #if wxUSE_PALETTE | |
27 | wxMask( const wxBitmap& bitmap, int paletteIndex ); | |
28 | #endif // wxUSE_PALETTE | |
29 | wxMask( const wxBitmap& bitmap ); | |
30 | virtual ~wxMask(); | |
31 | ||
32 | // implementation | |
33 | wxMask(GdkPixmap*); | |
34 | GdkPixmap* GetBitmap() const; | |
35 | ||
36 | protected: | |
37 | virtual void FreeData(); | |
38 | virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour); | |
39 | virtual bool InitFromMonoBitmap(const wxBitmap& bitmap); | |
40 | ||
41 | private: | |
42 | GdkPixmap* m_bitmap; | |
43 | ||
44 | DECLARE_DYNAMIC_CLASS(wxMask) | |
45 | }; | |
46 | ||
47 | //----------------------------------------------------------------------------- | |
48 | // wxBitmap | |
49 | //----------------------------------------------------------------------------- | |
50 | ||
51 | class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase | |
52 | { | |
53 | public: | |
54 | wxBitmap() { } | |
55 | wxBitmap( int width, int height, int depth = wxBITMAP_SCREEN_DEPTH ) | |
56 | { Create(width, height, depth); } | |
57 | wxBitmap( const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH ) | |
58 | { Create(sz, depth); } | |
59 | wxBitmap( const char bits[], int width, int height, int depth = 1 ); | |
60 | wxBitmap( const char* const* bits ); | |
61 | #ifdef wxNEEDS_CHARPP | |
62 | // needed for old GCC | |
63 | wxBitmap(char** data) | |
64 | { *this = wxBitmap(const_cast<const char* const*>(data)); } | |
65 | #endif | |
66 | wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE ); | |
67 | #if wxUSE_IMAGE | |
68 | wxBitmap( const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH ) | |
69 | { (void)CreateFromImage(image, depth); } | |
70 | #endif // wxUSE_IMAGE | |
71 | wxBitmap(GdkPixbuf* pixbuf); | |
72 | virtual ~wxBitmap(); | |
73 | ||
74 | bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); | |
75 | bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) | |
76 | { return Create(sz.GetWidth(), sz.GetHeight(), depth); } | |
77 | ||
78 | virtual int GetHeight() const; | |
79 | virtual int GetWidth() const; | |
80 | virtual int GetDepth() const; | |
81 | ||
82 | #if wxUSE_IMAGE | |
83 | wxImage ConvertToImage() const; | |
84 | #endif // wxUSE_IMAGE | |
85 | ||
86 | // copies the contents and mask of the given (colour) icon to the bitmap | |
87 | virtual bool CopyFromIcon(const wxIcon& icon); | |
88 | ||
89 | wxMask *GetMask() const; | |
90 | void SetMask( wxMask *mask ); | |
91 | ||
92 | wxBitmap GetSubBitmap( const wxRect& rect ) const; | |
93 | ||
94 | bool SaveFile(const wxString &name, wxBitmapType type, | |
95 | const wxPalette *palette = NULL) const; | |
96 | bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); | |
97 | ||
98 | #if wxUSE_PALETTE | |
99 | wxPalette *GetPalette() const; | |
100 | void SetPalette(const wxPalette& palette); | |
101 | wxPalette *GetColourMap() const { return GetPalette(); } | |
102 | #endif // wxUSE_PALETTE | |
103 | ||
104 | static void InitStandardHandlers(); | |
105 | ||
106 | // implementation | |
107 | // -------------- | |
108 | ||
109 | void SetHeight( int height ); | |
110 | void SetWidth( int width ); | |
111 | void SetDepth( int depth ); | |
112 | ||
113 | GdkPixmap *GetPixmap() const; | |
114 | bool HasPixmap() const; | |
115 | bool HasPixbuf() const; | |
116 | GdkPixbuf *GetPixbuf() const; | |
117 | ||
118 | // raw bitmap access support functions | |
119 | void *GetRawData(wxPixelDataBase& data, int bpp); | |
120 | void UngetRawData(wxPixelDataBase& data); | |
121 | ||
122 | bool HasAlpha() const; | |
123 | ||
124 | protected: | |
125 | #if wxUSE_IMAGE | |
126 | bool CreateFromImage(const wxImage& image, int depth); | |
127 | #endif // wxUSE_IMAGE | |
128 | ||
129 | virtual wxGDIRefData* CreateGDIRefData() const; | |
130 | virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const; | |
131 | ||
132 | private: | |
133 | void SetPixmap(GdkPixmap* pixmap); | |
134 | #if wxUSE_IMAGE | |
135 | // to be called from CreateFromImage only! | |
136 | bool CreateFromImageAsPixmap(const wxImage& image, int depth); | |
137 | bool CreateFromImageAsPixbuf(const wxImage& image); | |
138 | #endif // wxUSE_IMAGE | |
139 | ||
140 | public: | |
141 | // implementation only | |
142 | enum Representation | |
143 | { | |
144 | Pixmap, | |
145 | Pixbuf | |
146 | }; | |
147 | // removes other representations from memory, keeping only 'keep' | |
148 | // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf): | |
149 | void PurgeOtherRepresentations(Representation keep); | |
150 | ||
151 | DECLARE_DYNAMIC_CLASS(wxBitmap) | |
152 | }; | |
153 | ||
154 | #endif // _WX_GTK_BITMAP_H_ |