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