]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk/bitmap.h
return values of overloaded virtuals should match the base class version
[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 WXDLLEXPORT 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 = -1 );
55 wxBitmap( const char bits[], int width, int height, int depth = 1 );
56 wxBitmap( const char* const* bits ) { CreateFromXpm(bits); }
57 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
58 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
59 virtual ~wxBitmap();
60 bool operator == ( const wxBitmap& bmp ) const;
61 bool operator != ( const wxBitmap& bmp ) const { return !(*this == bmp); }
62 bool Ok() const;
63
64 bool Create(int width, int height, int depth = -1);
65
66 int GetHeight() const;
67 int GetWidth() const;
68 int GetDepth() const;
69
70 wxImage ConvertToImage() const;
71
72 // copies the contents and mask of the given (colour) icon to the bitmap
73 virtual bool CopyFromIcon(const wxIcon& icon);
74
75 wxMask *GetMask() const;
76 void SetMask( wxMask *mask );
77
78 wxBitmap GetSubBitmap( const wxRect& rect ) const;
79
80 bool SaveFile(const wxString &name, wxBitmapType type,
81 const wxPalette *palette = (wxPalette *)NULL) const;
82 bool LoadFile(const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
83
84#if wxUSE_PALETTE
85 wxPalette *GetPalette() const;
86 void SetPalette(const wxPalette& palette);
87 wxPalette *GetColourMap() const { return GetPalette(); };
88#endif // wxUSE_PALETTE
89
90 static void InitStandardHandlers();
91
92 // implementation
93 // --------------
94
95 void SetHeight( int height );
96 void SetWidth( int width );
97 void SetDepth( int depth );
98 void SetPixmap( GdkPixmap *pixmap );
99 void SetPixbuf(GdkPixbuf* pixbuf, int depth = 0);
100
101 GdkPixmap *GetPixmap() const;
102 bool HasPixmap() const;
103 bool HasPixbuf() const;
104 GdkPixbuf *GetPixbuf() const;
105
106 // Basically, this corresponds to Win32 StretchBlt()
107 wxBitmap Rescale(int clipx, int clipy, int clipwidth, int clipheight, int width, int height) const;
108
109 // raw bitmap access support functions
110 void *GetRawData(wxPixelDataBase& data, int bpp);
111 void UngetRawData(wxPixelDataBase& data);
112
113 bool HasAlpha() const;
114 void UseAlpha();
115
116protected:
117 bool CreateFromXpm(const char* const* bits);
118 bool CreateFromImage(const wxImage& image, int depth);
119
120private:
121 // to be called from CreateFromImage only!
122 bool CreateFromImageAsPixmap(const wxImage& image, int depth);
123 bool CreateFromImageAsPixbuf(const wxImage& image);
124
125 enum Representation
126 {
127 Pixmap,
128 Pixbuf
129 };
130 // removes other representations from memory, keeping only 'keep'
131 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
132 void PurgeOtherRepresentations(Representation keep);
133
134 friend class wxMemoryDC;
135 friend class wxBitmapHandler;
136
137private:
138 DECLARE_DYNAMIC_CLASS(wxBitmap)
139};
140
141//-----------------------------------------------------------------------------
142// wxBitmapHandler
143//-----------------------------------------------------------------------------
144
145class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
146{
147public:
148 wxBitmapHandler() { }
149 virtual ~wxBitmapHandler();
150
151 virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
152 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
153 int desiredWidth, int desiredHeight);
154 virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
155
156private:
157 DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
158};
159
160#endif // _WX_GTK_BITMAP_H_