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 WXDLLEXPORT 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
);
57 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
58 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
60 bool operator == ( const wxBitmap
& bmp
) const;
61 bool operator != ( const wxBitmap
& bmp
) const { return !(*this == bmp
); }
62 bool Ok() const { return IsOk(); }
65 bool Create(int width
, int height
, int depth
= -1);
67 int GetHeight() const;
71 wxImage
ConvertToImage() const;
73 // copies the contents and mask of the given (colour) icon to the bitmap
74 virtual bool CopyFromIcon(const wxIcon
& icon
);
76 wxMask
*GetMask() const;
77 void SetMask( wxMask
*mask
);
79 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
81 bool SaveFile(const wxString
&name
, wxBitmapType type
,
82 const wxPalette
*palette
= (wxPalette
*)NULL
) const;
83 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
86 wxPalette
*GetPalette() const;
87 void SetPalette(const wxPalette
& palette
);
88 wxPalette
*GetColourMap() const { return GetPalette(); };
89 #endif // wxUSE_PALETTE
91 static void InitStandardHandlers();
96 void SetHeight( int height
);
97 void SetWidth( int width
);
98 void SetDepth( int depth
);
99 void SetPixmap( GdkPixmap
*pixmap
);
100 void SetPixbuf(GdkPixbuf
* pixbuf
, int depth
= 0);
102 GdkPixmap
*GetPixmap() const;
103 bool HasPixmap() const;
104 bool HasPixbuf() const;
105 GdkPixbuf
*GetPixbuf() const;
107 // Basically, this corresponds to Win32 StretchBlt()
108 wxBitmap
Rescale(int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
) const;
110 // raw bitmap access support functions
111 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
112 void UngetRawData(wxPixelDataBase
& data
);
114 bool HasAlpha() const;
118 bool CreateFromImage(const wxImage
& image
, int depth
);
121 // to be called from CreateFromImage only!
122 bool CreateFromImageAsPixmap(const wxImage
& image
, int depth
);
123 bool CreateFromImageAsPixbuf(const wxImage
& image
);
125 virtual wxObjectRefData
* CreateRefData() const;
126 virtual wxObjectRefData
* CloneRefData(const wxObjectRefData
* data
) const;
133 // removes other representations from memory, keeping only 'keep'
134 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
135 void PurgeOtherRepresentations(Representation keep
);
137 friend class wxMemoryDC
;
138 friend class wxBitmapHandler
;
141 DECLARE_DYNAMIC_CLASS(wxBitmap
)
144 //-----------------------------------------------------------------------------
146 //-----------------------------------------------------------------------------
148 class WXDLLIMPEXP_CORE wxBitmapHandler
: public wxBitmapHandlerBase
150 DECLARE_ABSTRACT_CLASS(wxBitmapHandler
)
153 #endif // _WX_GTK_BITMAP_H_