1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/bitmap.h
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_BITMAP_H_
11 #define _WX_GTK_BITMAP_H_
13 typedef struct _GdkPixbuf GdkPixbuf
;
14 class WXDLLIMPEXP_FWD_CORE wxPixelDataBase
;
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 class WXDLLIMPEXP_CORE wxMask
: public wxObject
24 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
26 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
27 #endif // wxUSE_PALETTE
28 wxMask( const wxBitmap
& bitmap
);
31 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
33 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
34 #endif // wxUSE_PALETTE
35 bool Create( const wxBitmap
& bitmap
);
40 GdkBitmap
*GetBitmap() const;
43 DECLARE_DYNAMIC_CLASS(wxMask
)
46 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
50 class WXDLLIMPEXP_CORE wxBitmap
: public wxBitmapBase
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
);
61 *this = wxBitmap(wx_const_cast(const char* const*, data
));
64 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
66 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
70 bool Create(int width
, int height
, int depth
= -1);
72 virtual int GetHeight() const;
73 virtual int GetWidth() const;
74 virtual int GetDepth() const;
77 wxImage
ConvertToImage() const;
80 // copies the contents and mask of the given (colour) icon to the bitmap
81 virtual bool CopyFromIcon(const wxIcon
& icon
);
83 wxMask
*GetMask() const;
84 void SetMask( wxMask
*mask
);
86 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
88 bool SaveFile(const wxString
&name
, wxBitmapType type
,
89 const wxPalette
*palette
= (wxPalette
*)NULL
) const;
90 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
93 wxPalette
*GetPalette() const;
94 void SetPalette(const wxPalette
& palette
);
95 wxPalette
*GetColourMap() const { return GetPalette(); };
96 #endif // wxUSE_PALETTE
98 static void InitStandardHandlers();
103 void SetHeight( int height
);
104 void SetWidth( int width
);
105 void SetDepth( int depth
);
106 void SetPixmap( GdkPixmap
*pixmap
);
107 void SetPixbuf(GdkPixbuf
* pixbuf
, int depth
= 0);
109 GdkPixmap
*GetPixmap() const;
110 bool HasPixmap() const;
111 bool HasPixbuf() const;
112 GdkPixbuf
*GetPixbuf() const;
114 // Basically, this corresponds to Win32 StretchBlt()
115 wxBitmap
Rescale(int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
) const;
117 // raw bitmap access support functions
118 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
119 void UngetRawData(wxPixelDataBase
& data
);
121 bool HasAlpha() const;
125 bool CreateFromImage(const wxImage
& image
, int depth
);
126 #endif // wxUSE_IMAGE
128 virtual wxGDIRefData
* CreateGDIRefData() const;
129 virtual wxGDIRefData
* CloneGDIRefData(const wxGDIRefData
* data
) const;
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
139 // implementation only
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
);
150 DECLARE_DYNAMIC_CLASS(wxBitmap
)
153 //-----------------------------------------------------------------------------
155 //-----------------------------------------------------------------------------
157 class WXDLLIMPEXP_CORE wxBitmapHandler
: public wxBitmapHandlerBase
159 DECLARE_ABSTRACT_CLASS(wxBitmapHandler
)
162 #endif // _WX_GTK_BITMAP_H_