1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/bitmap.h
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __GTKBITMAPH__
12 #define __GTKBITMAPH__
15 #include "wx/object.h"
16 #include "wx/string.h"
17 #include "wx/palette.h"
18 #include "wx/gdiobj.h"
20 class WXDLLEXPORT wxPixelDataBase
;
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 class WXDLLIMPEXP_CORE wxMask
;
27 class WXDLLIMPEXP_CORE wxBitmap
;
28 class WXDLLIMPEXP_CORE wxImage
;
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 class WXDLLIMPEXP_CORE wxMask
: public wxObject
38 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
40 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
41 #endif // wxUSE_PALETTE
42 wxMask( const wxBitmap
& bitmap
);
45 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
47 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
48 #endif // wxUSE_PALETTE
49 bool Create( const wxBitmap
& bitmap
);
54 GdkBitmap
*GetBitmap() const;
57 DECLARE_DYNAMIC_CLASS(wxMask
)
60 //-----------------------------------------------------------------------------
62 //-----------------------------------------------------------------------------
64 class WXDLLIMPEXP_CORE wxBitmap
: public wxBitmapBase
68 wxBitmap( int width
, int height
, int depth
= -1 );
69 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
70 wxBitmap( const char* const* bits
);
71 #if defined (__GNUC__) && __GNUC__ < 3
75 *this = wxBitmap(wx_const_cast(const char* const*, data
));
78 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
79 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
81 bool Ok() const { return IsOk(); }
84 bool Create(int width
, int height
, int depth
= -1);
86 int GetHeight() const;
90 wxImage
ConvertToImage() const;
92 // copies the contents and mask of the given (colour) icon to the bitmap
93 virtual bool CopyFromIcon(const wxIcon
& icon
);
95 wxMask
*GetMask() const;
96 void SetMask( wxMask
*mask
);
98 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
100 bool SaveFile(const wxString
&name
, wxBitmapType type
,
101 const wxPalette
*palette
= (wxPalette
*)NULL
) const;
102 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
105 wxPalette
*GetPalette() const;
106 void SetPalette(const wxPalette
& palette
);
107 wxPalette
*GetColourMap() const { return GetPalette(); };
108 #endif // wxUSE_PALETTE
110 static void InitStandardHandlers();
115 void SetHeight( int height
);
116 void SetWidth( int width
);
117 void SetDepth( int depth
);
118 void SetPixmap( GdkPixmap
*pixmap
);
119 void SetBitmap( GdkBitmap
*bitmap
);
121 GdkPixmap
*GetPixmap() const;
122 GdkBitmap
*GetBitmap() const;
123 bool HasPixmap() const;
125 // Basically, this corresponds to Win32 StretchBlt()
126 wxBitmap
Rescale( int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
);
128 // raw bitmap access support functions
129 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
130 void UngetRawData(wxPixelDataBase
& data
);
132 bool HasAlpha() const;
136 bool CreateFromImage(const wxImage
& image
, int depth
);
139 // to be called from CreateFromImage only!
140 bool CreateFromImageAsBitmap(const wxImage
& image
);
141 bool CreateFromImageAsPixmap(const wxImage
& image
);
143 friend class wxBitmapHandler
;
146 DECLARE_DYNAMIC_CLASS(wxBitmap
)
149 //-----------------------------------------------------------------------------
151 //-----------------------------------------------------------------------------
153 class WXDLLIMPEXP_CORE wxBitmapHandler
: public wxBitmapHandlerBase
155 DECLARE_ABSTRACT_CLASS(wxBitmapHandler
)
158 #endif // __GTKBITMAPH__