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