1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/bitmap.h
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #ifndef __GTKBITMAPH__
11 #define __GTKBITMAPH__
14 #include "wx/object.h"
15 #include "wx/string.h"
16 #include "wx/palette.h"
17 #include "wx/gdiobj.h"
19 class WXDLLIMPEXP_FWD_CORE wxPixelDataBase
;
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 class WXDLLIMPEXP_FWD_CORE wxMask
;
26 class WXDLLIMPEXP_FWD_CORE wxBitmap
;
27 class WXDLLIMPEXP_FWD_CORE wxImage
;
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 class WXDLLIMPEXP_CORE wxMask
: public wxObject
37 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
39 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
40 #endif // wxUSE_PALETTE
41 wxMask( const wxBitmap
& bitmap
);
44 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
46 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
47 #endif // wxUSE_PALETTE
48 bool Create( const wxBitmap
& bitmap
);
53 GdkBitmap
*GetBitmap() const;
56 DECLARE_DYNAMIC_CLASS(wxMask
)
59 //-----------------------------------------------------------------------------
61 //-----------------------------------------------------------------------------
63 class WXDLLIMPEXP_CORE wxBitmap
: public wxBitmapBase
67 wxBitmap( int width
, int height
, int depth
= -1 ) { Create( width
, height
, depth
); }
68 wxBitmap( const wxSize
& sz
, int depth
= -1 ) { Create( sz
, depth
); }
69 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
70 wxBitmap( const char* const* bits
);
75 *this = wxBitmap(const_cast<const char* const*>(data
));
78 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
79 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
82 bool Create(int width
, int height
, int depth
= wxBITMAP_SCREEN_DEPTH
);
83 bool Create(const wxSize
& sz
, int depth
= wxBITMAP_SCREEN_DEPTH
)
84 { return Create(sz
.GetWidth(), sz
.GetHeight(), depth
); }
85 bool Create(int width
, int height
, const wxDC
& WXUNUSED(dc
))
86 { return Create(width
,height
); }
88 virtual int GetHeight() const;
89 virtual int GetWidth() const;
90 virtual int GetDepth() const;
92 wxImage
ConvertToImage() const;
94 // copies the contents and mask of the given (colour) icon to the bitmap
95 virtual bool CopyFromIcon(const wxIcon
& icon
);
97 wxMask
*GetMask() const;
98 void SetMask( wxMask
*mask
);
100 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
102 bool SaveFile(const wxString
&name
, wxBitmapType type
,
103 const wxPalette
*palette
= NULL
) const;
104 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
107 wxPalette
*GetPalette() const;
108 void SetPalette(const wxPalette
& palette
);
109 wxPalette
*GetColourMap() const { return GetPalette(); }
110 #endif // wxUSE_PALETTE
112 static void InitStandardHandlers();
117 void SetHeight( int height
);
118 void SetWidth( int width
);
119 void SetDepth( int depth
);
120 void SetPixmap( GdkPixmap
*pixmap
);
121 void SetBitmap( GdkBitmap
*bitmap
);
123 GdkPixmap
*GetPixmap() const;
124 GdkBitmap
*GetBitmap() const;
125 bool HasPixmap() const;
127 // Basically, this corresponds to Win32 StretchBlt()
128 wxBitmap
Rescale( int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
);
130 // raw bitmap access support functions
131 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
132 void UngetRawData(wxPixelDataBase
& data
);
134 bool HasAlpha() const;
137 bool CreateFromImage(const wxImage
& image
, int depth
);
139 virtual wxGDIRefData
*CreateGDIRefData() const;
140 virtual wxGDIRefData
*CloneGDIRefData(const wxGDIRefData
*data
) const;
143 // to be called from CreateFromImage only!
144 bool CreateFromImageAsBitmap(const wxImage
& image
);
145 bool CreateFromImageAsPixmap(const wxImage
& image
);
147 friend class wxBitmapHandler
;
150 DECLARE_DYNAMIC_CLASS(wxBitmap
)
154 #endif // __GTKBITMAPH__