]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/bitmap.h
No changes, just refactor wxGrid::DrawAllGridLines().
[wxWidgets.git] / include / wx / gtk / bitmap.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
0b04c4e0 2// Name: wx/gtk/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
0416c418
PC
10#ifndef _WX_GTK_BITMAP_H_
11#define _WX_GTK_BITMAP_H_
c801d85f 12
feac7937 13typedef struct _GdkPixbuf GdkPixbuf;
b5dbe15d 14class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
f383c5b8 15
c801d85f
KB
16//-----------------------------------------------------------------------------
17// wxMask
18//-----------------------------------------------------------------------------
19
60a3d1c6 20class WXDLLIMPEXP_CORE wxMask: public wxMaskBase
c801d85f 21{
fd0eed64 22public:
8636aed8 23 wxMask();
27297c82 24 wxMask(const wxMask& mask);
8636aed8 25 wxMask( const wxBitmap& bitmap, const wxColour& colour );
0b04c4e0 26#if wxUSE_PALETTE
8636aed8 27 wxMask( const wxBitmap& bitmap, int paletteIndex );
0b04c4e0 28#endif // wxUSE_PALETTE
8636aed8 29 wxMask( const wxBitmap& bitmap );
d3c7fc99 30 virtual ~wxMask();
0b04c4e0 31
8636aed8 32 // implementation
2d13e22f 33 wxMask(GdkPixmap*);
29e461a2 34 GdkPixmap* GetBitmap() const;
0b04c4e0 35
60a3d1c6
PC
36protected:
37 virtual void FreeData();
38 virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour);
39 virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
40
2d13e22f
PC
41private:
42 GdkPixmap* m_bitmap;
43
8636aed8 44 DECLARE_DYNAMIC_CLASS(wxMask)
c801d85f
KB
45};
46
47//-----------------------------------------------------------------------------
48// wxBitmap
49//-----------------------------------------------------------------------------
50
20123d49 51class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
c801d85f 52{
fd0eed64 53public:
23656673 54 wxBitmap() { }
03647350 55 wxBitmap( int width, int height, int depth = wxBITMAP_SCREEN_DEPTH )
732d8c74 56 { Create(width, height, depth); }
03647350 57 wxBitmap( const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH )
732d8c74 58 { Create(sz, depth); }
8636aed8 59 wxBitmap( const char bits[], int width, int height, int depth = 1 );
452418c4 60 wxBitmap( const char* const* bits );
459f812b 61#ifdef wxNEEDS_CHARPP
4a4bf7ee
SN
62 // needed for old GCC
63 wxBitmap(char** data)
732d8c74 64 { *this = wxBitmap(const_cast<const char* const*>(data)); }
4a4bf7ee 65#endif
cbea3ec6 66 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
c0521644 67#if wxUSE_IMAGE
e86f2cc8
FM
68 wxBitmap( const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH )
69 { (void)CreateFromImage(image, depth); }
c0521644 70#endif // wxUSE_IMAGE
54195d23 71 wxBitmap(GdkPixbuf* pixbuf);
d3c7fc99 72 virtual ~wxBitmap();
8636aed8 73
e86f2cc8 74 bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
732d8c74
FM
75 bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
76 { return Create(sz.GetWidth(), sz.GetHeight(), depth); }
0b04c4e0 77
8f884a0d
VZ
78 virtual int GetHeight() const;
79 virtual int GetWidth() const;
80 virtual int GetDepth() const;
0b04c4e0 81
c0521644 82#if wxUSE_IMAGE
fd859211 83 wxImage ConvertToImage() const;
c0521644 84#endif // wxUSE_IMAGE
8636aed8 85
db0aec83
VS
86 // copies the contents and mask of the given (colour) icon to the bitmap
87 virtual bool CopyFromIcon(const wxIcon& icon);
88
8636aed8
RR
89 wxMask *GetMask() const;
90 void SetMask( wxMask *mask );
0b04c4e0 91
17bec151 92 wxBitmap GetSubBitmap( const wxRect& rect ) const;
8636aed8 93
4611dd06 94 bool SaveFile(const wxString &name, wxBitmapType type,
d3b9f782 95 const wxPalette *palette = NULL) const;
cbea3ec6 96 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
8636aed8 97
4611dd06 98#if wxUSE_PALETTE
8636aed8 99 wxPalette *GetPalette() const;
4611dd06 100 void SetPalette(const wxPalette& palette);
6dd0883d 101 wxPalette *GetColourMap() const { return GetPalette(); }
4611dd06 102#endif // wxUSE_PALETTE
55e90a2e 103
4b61c88d 104 static void InitStandardHandlers();
8bbe427f 105
8636aed8 106 // implementation
20e05ffb 107 // --------------
c801d85f 108
8636aed8
RR
109 void SetHeight( int height );
110 void SetWidth( int width );
111 void SetDepth( int depth );
8bbe427f 112
8636aed8 113 GdkPixmap *GetPixmap() const;
feac7937 114 bool HasPixmap() const;
feac7937
VS
115 bool HasPixbuf() const;
116 GdkPixbuf *GetPixbuf() const;
0b04c4e0 117
284f2b59
RR
118 // raw bitmap access support functions
119 void *GetRawData(wxPixelDataBase& data, int bpp);
120 void UngetRawData(wxPixelDataBase& data);
121
0ff2a74d 122 bool HasAlpha() const;
d2400c3f 123
e838cc14 124protected:
c0521644 125#if wxUSE_IMAGE
fd859211 126 bool CreateFromImage(const wxImage& image, int depth);
c0521644 127#endif // wxUSE_IMAGE
e838cc14 128
8f884a0d
VZ
129 virtual wxGDIRefData* CreateGDIRefData() const;
130 virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
4c44e0d0 131
8636aed8 132private:
06497cba 133 void SetPixmap(GdkPixmap* pixmap);
c0521644 134#if wxUSE_IMAGE
feac7937 135 // to be called from CreateFromImage only!
5ac1d44a 136 bool CreateFromImageAsPixmap(const wxImage& image, int depth);
feac7937 137 bool CreateFromImageAsPixbuf(const wxImage& image);
c0521644 138#endif // wxUSE_IMAGE
feac7937 139
ab171e95
RR
140public:
141 // implementation only
feac7937
VS
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
8636aed8 151 DECLARE_DYNAMIC_CLASS(wxBitmap)
c801d85f
KB
152};
153
0416c418 154#endif // _WX_GTK_BITMAP_H_