]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/bitmap.h
no real change; just add the standard separator where it's missing
[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 wxObject
21 {
22 public:
23 wxMask();
24 wxMask( const wxBitmap& bitmap, const wxColour& colour );
25 #if wxUSE_PALETTE
26 wxMask( const wxBitmap& bitmap, int paletteIndex );
27 #endif // wxUSE_PALETTE
28 wxMask( const wxBitmap& bitmap );
29 virtual ~wxMask();
30
31 bool Create( const wxBitmap& bitmap, const wxColour& colour );
32 #if wxUSE_PALETTE
33 bool Create( const wxBitmap& bitmap, int paletteIndex );
34 #endif // wxUSE_PALETTE
35 bool Create( const wxBitmap& bitmap );
36
37 // implementation
38 GdkBitmap *m_bitmap;
39
40 GdkBitmap *GetBitmap() const;
41
42 private:
43 DECLARE_DYNAMIC_CLASS(wxMask)
44 };
45
46 //-----------------------------------------------------------------------------
47 // wxBitmap
48 //-----------------------------------------------------------------------------
49
50 class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
51 {
52 public:
53 wxBitmap() { }
54 wxBitmap( int width, int height, int depth = wxBITMAP_SCREEN_DEPTH )
55 { Create(width, height, depth); }
56 wxBitmap( const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH )
57 { Create(sz, depth); }
58 wxBitmap( const char bits[], int width, int height, int depth = 1 );
59 wxBitmap( const char* const* bits );
60 #ifdef wxNEEDS_CHARPP
61 // needed for old GCC
62 wxBitmap(char** data)
63 { *this = wxBitmap(const_cast<const char* const*>(data)); }
64 #endif
65 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
66 #if wxUSE_IMAGE
67 wxBitmap( const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH )
68 { (void)CreateFromImage(image, depth); }
69 #endif // wxUSE_IMAGE
70 virtual ~wxBitmap();
71
72 bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
73 bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
74 { return Create(sz.GetWidth(), sz.GetHeight(), depth); }
75
76 virtual int GetHeight() const;
77 virtual int GetWidth() const;
78 virtual int GetDepth() const;
79
80 #if wxUSE_IMAGE
81 wxImage ConvertToImage() const;
82 #endif // wxUSE_IMAGE
83
84 // copies the contents and mask of the given (colour) icon to the bitmap
85 virtual bool CopyFromIcon(const wxIcon& icon);
86
87 wxMask *GetMask() const;
88 void SetMask( wxMask *mask );
89
90 wxBitmap GetSubBitmap( const wxRect& rect ) const;
91
92 bool SaveFile(const wxString &name, wxBitmapType type,
93 const wxPalette *palette = NULL) const;
94 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
95
96 #if wxUSE_PALETTE
97 wxPalette *GetPalette() const;
98 void SetPalette(const wxPalette& palette);
99 wxPalette *GetColourMap() const { return GetPalette(); };
100 #endif // wxUSE_PALETTE
101
102 static void InitStandardHandlers();
103
104 // implementation
105 // --------------
106
107 void SetHeight( int height );
108 void SetWidth( int width );
109 void SetDepth( int depth );
110 void SetPixmap( GdkPixmap *pixmap );
111 void SetPixbuf(GdkPixbuf* pixbuf, int depth = 0);
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 #if wxUSE_IMAGE
134 // to be called from CreateFromImage only!
135 bool CreateFromImageAsPixmap(const wxImage& image, int depth);
136 bool CreateFromImageAsPixbuf(const wxImage& image);
137 #endif // wxUSE_IMAGE
138
139 public:
140 // implementation only
141 enum Representation
142 {
143 Pixmap,
144 Pixbuf
145 };
146 // removes other representations from memory, keeping only 'keep'
147 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
148 void PurgeOtherRepresentations(Representation keep);
149
150 private:
151 DECLARE_DYNAMIC_CLASS(wxBitmap)
152 };
153
154 #endif // _WX_GTK_BITMAP_H_