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