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 WXDLLIMPEXP_FWD_CORE wxPixelDataBase
;
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 class WXDLLIMPEXP_FWD_CORE wxMask
;
27 class WXDLLIMPEXP_FWD_CORE wxBitmap
;
28 class WXDLLIMPEXP_FWD_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 ) { Create( width
, height
, depth
); }
69 wxBitmap( const wxSize
& sz
, int depth
= -1 ) { Create( sz
, depth
); }
70 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
71 wxBitmap( const char* const* bits
);
76 *this = wxBitmap(const_cast<const char* const*>(data
));
79 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
80 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
83 bool Create(int width
, int height
, int depth
= wxBITMAP_SCREEN_DEPTH
);
84 bool Create(const wxSize
& sz
, int depth
= wxBITMAP_SCREEN_DEPTH
)
85 { return Create(sz
.GetWidth(), sz
.GetHeight(), depth
); }
86 bool Create(int width
, int height
, const wxDC
& WXUNUSED(dc
))
87 { return Create(width
,height
); }
89 virtual int GetHeight() const;
90 virtual int GetWidth() const;
91 virtual int GetDepth() const;
93 wxImage
ConvertToImage() const;
95 // copies the contents and mask of the given (colour) icon to the bitmap
96 virtual bool CopyFromIcon(const wxIcon
& icon
);
98 wxMask
*GetMask() const;
99 void SetMask( wxMask
*mask
);
101 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
103 bool SaveFile(const wxString
&name
, wxBitmapType type
,
104 const wxPalette
*palette
= NULL
) const;
105 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_DEFAULT_TYPE
);
108 wxPalette
*GetPalette() const;
109 void SetPalette(const wxPalette
& palette
);
110 wxPalette
*GetColourMap() const { return GetPalette(); }
111 #endif // wxUSE_PALETTE
113 static void InitStandardHandlers();
118 void SetHeight( int height
);
119 void SetWidth( int width
);
120 void SetDepth( int depth
);
121 void SetPixmap( GdkPixmap
*pixmap
);
122 void SetBitmap( GdkBitmap
*bitmap
);
124 GdkPixmap
*GetPixmap() const;
125 GdkBitmap
*GetBitmap() const;
126 bool HasPixmap() const;
128 // Basically, this corresponds to Win32 StretchBlt()
129 wxBitmap
Rescale( int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
);
131 // raw bitmap access support functions
132 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
133 void UngetRawData(wxPixelDataBase
& data
);
135 bool HasAlpha() const;
138 bool CreateFromImage(const wxImage
& image
, int depth
);
140 virtual wxGDIRefData
*CreateGDIRefData() const;
141 virtual wxGDIRefData
*CloneGDIRefData(const wxGDIRefData
*data
) const;
144 // to be called from CreateFromImage only!
145 bool CreateFromImageAsBitmap(const wxImage
& image
);
146 bool CreateFromImageAsPixmap(const wxImage
& image
);
148 friend class wxBitmapHandler
;
151 DECLARE_DYNAMIC_CLASS(wxBitmap
)
155 #endif // __GTKBITMAPH__