]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/bitmap.h
Don't directly include GTK+ semi-public headers.
[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
RR
32 // implementation
33 GdkBitmap *m_bitmap;
8636aed8 34 GdkBitmap *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
8636aed8 41 DECLARE_DYNAMIC_CLASS(wxMask)
c801d85f
KB
42};
43
44//-----------------------------------------------------------------------------
45// wxBitmap
46//-----------------------------------------------------------------------------
47
20123d49 48class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
c801d85f 49{
fd0eed64 50public:
23656673 51 wxBitmap() { }
03647350 52 wxBitmap( int width, int height, int depth = wxBITMAP_SCREEN_DEPTH )
732d8c74 53 { Create(width, height, depth); }
03647350 54 wxBitmap( const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH )
732d8c74 55 { Create(sz, depth); }
8636aed8 56 wxBitmap( const char bits[], int width, int height, int depth = 1 );
452418c4 57 wxBitmap( const char* const* bits );
459f812b 58#ifdef wxNEEDS_CHARPP
4a4bf7ee
SN
59 // needed for old GCC
60 wxBitmap(char** data)
732d8c74 61 { *this = wxBitmap(const_cast<const char* const*>(data)); }
4a4bf7ee 62#endif
cbea3ec6 63 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
c0521644 64#if wxUSE_IMAGE
e86f2cc8
FM
65 wxBitmap( const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH )
66 { (void)CreateFromImage(image, depth); }
c0521644 67#endif // wxUSE_IMAGE
d3c7fc99 68 virtual ~wxBitmap();
8636aed8 69
e86f2cc8 70 bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
732d8c74
FM
71 bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
72 { return Create(sz.GetWidth(), sz.GetHeight(), depth); }
0b04c4e0 73
8f884a0d
VZ
74 virtual int GetHeight() const;
75 virtual int GetWidth() const;
76 virtual int GetDepth() const;
0b04c4e0 77
c0521644 78#if wxUSE_IMAGE
fd859211 79 wxImage ConvertToImage() const;
c0521644 80#endif // wxUSE_IMAGE
8636aed8 81
db0aec83
VS
82 // copies the contents and mask of the given (colour) icon to the bitmap
83 virtual bool CopyFromIcon(const wxIcon& icon);
84
8636aed8
RR
85 wxMask *GetMask() const;
86 void SetMask( wxMask *mask );
0b04c4e0 87
17bec151 88 wxBitmap GetSubBitmap( const wxRect& rect ) const;
8636aed8 89
4611dd06 90 bool SaveFile(const wxString &name, wxBitmapType type,
d3b9f782 91 const wxPalette *palette = NULL) const;
cbea3ec6 92 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
8636aed8 93
4611dd06 94#if wxUSE_PALETTE
8636aed8 95 wxPalette *GetPalette() const;
4611dd06 96 void SetPalette(const wxPalette& palette);
55e90a2e 97 wxPalette *GetColourMap() const { return GetPalette(); };
4611dd06 98#endif // wxUSE_PALETTE
55e90a2e 99
4b61c88d 100 static void InitStandardHandlers();
8bbe427f 101
8636aed8 102 // implementation
20e05ffb 103 // --------------
c801d85f 104
8636aed8
RR
105 void SetHeight( int height );
106 void SetWidth( int width );
107 void SetDepth( int depth );
06497cba 108 void SetPixbuf(GdkPixbuf* pixbuf);
8bbe427f 109
8636aed8 110 GdkPixmap *GetPixmap() const;
feac7937 111 bool HasPixmap() const;
feac7937
VS
112 bool HasPixbuf() const;
113 GdkPixbuf *GetPixbuf() const;
0b04c4e0 114
284f2b59
RR
115 // raw bitmap access support functions
116 void *GetRawData(wxPixelDataBase& data, int bpp);
117 void UngetRawData(wxPixelDataBase& data);
118
0ff2a74d 119 bool HasAlpha() const;
d2400c3f 120
e838cc14 121protected:
c0521644 122#if wxUSE_IMAGE
fd859211 123 bool CreateFromImage(const wxImage& image, int depth);
c0521644 124#endif // wxUSE_IMAGE
e838cc14 125
8f884a0d
VZ
126 virtual wxGDIRefData* CreateGDIRefData() const;
127 virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
4c44e0d0 128
8636aed8 129private:
06497cba 130 void SetPixmap(GdkPixmap* pixmap);
c0521644 131#if wxUSE_IMAGE
feac7937 132 // to be called from CreateFromImage only!
5ac1d44a 133 bool CreateFromImageAsPixmap(const wxImage& image, int depth);
feac7937 134 bool CreateFromImageAsPixbuf(const wxImage& image);
c0521644 135#endif // wxUSE_IMAGE
feac7937 136
ab171e95
RR
137public:
138 // implementation only
feac7937
VS
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
8636aed8 148 DECLARE_DYNAMIC_CLASS(wxBitmap)
c801d85f
KB
149};
150
0416c418 151#endif // _WX_GTK_BITMAP_H_