]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/bitmap.h
135805a5ae587e468d16fe818ba7f12d70290f7d
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __GTKBITMAPH__
12 #define __GTKBITMAPH__
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
19 #include "wx/object.h"
20 #include "wx/string.h"
21 #include "wx/palette.h"
22 #include "wx/gdiobj.h"
23 #include "wx/rawbmp.h"
26 typedef struct _GdkPixbuf GdkPixbuf
;
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
41 class wxMask
: public wxObject
45 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
46 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
47 wxMask( const wxBitmap
& bitmap
);
50 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
51 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
52 bool Create( const wxBitmap
& bitmap
);
57 GdkBitmap
*GetBitmap() const;
60 DECLARE_DYNAMIC_CLASS(wxMask
)
63 //-----------------------------------------------------------------------------
65 //-----------------------------------------------------------------------------
67 class wxBitmap
: public wxBitmapBase
71 wxBitmap( int width
, int height
, int depth
= -1 );
72 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
73 wxBitmap( const char **bits
) { (void)CreateFromXpm(bits
); }
74 wxBitmap( char **bits
) { (void)CreateFromXpm((const char **)bits
); }
75 wxBitmap( const wxBitmap
& bmp
);
76 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
77 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
79 wxBitmap
& operator = ( const wxBitmap
& bmp
);
80 bool operator == ( const wxBitmap
& bmp
) const;
81 bool operator != ( const wxBitmap
& bmp
) const;
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 void SetPixbuf(GdkPixbuf
*pixbuf
);
124 GdkPixmap
*GetPixmap() const;
125 GdkBitmap
*GetBitmap() const;
126 bool HasPixmap() const;
128 bool HasPixbuf() const;
129 GdkPixbuf
*GetPixbuf() const;
132 // Basically, this corresponds to Win32 StretchBlt()
133 wxBitmap
Rescale( int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
);
135 // raw bitmap access support functions
136 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
137 void UngetRawData(wxPixelDataBase
& data
);
140 bool CreateFromXpm(const char **bits
);
141 bool CreateFromImage(const wxImage
& image
, int depth
);
144 // to be called from CreateFromImage only!
145 bool CreateFromImageAsBitmap(const wxImage
& image
);
146 bool CreateFromImageAsPixmap(const wxImage
& image
);
149 bool CreateFromImageAsPixbuf(const wxImage
& image
);
156 // removes other representations from memory, keeping only 'keep'
157 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
158 void PurgeOtherRepresentations(Representation keep
);
160 friend class wxMemoryDC
;
162 friend class wxBitmapHandler
;
165 DECLARE_DYNAMIC_CLASS(wxBitmap
)
168 //-----------------------------------------------------------------------------
170 //-----------------------------------------------------------------------------
172 class wxBitmapHandler
: public wxBitmapHandlerBase
175 wxBitmapHandler() { }
176 virtual ~wxBitmapHandler();
178 virtual bool Create(wxBitmap
*bitmap
, void *data
, long flags
, int width
, int height
, int depth
= 1);
179 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
180 int desiredWidth
, int desiredHeight
);
181 virtual bool SaveFile(const wxBitmap
*bitmap
, const wxString
& name
, int type
, const wxPalette
*palette
= NULL
);
184 DECLARE_DYNAMIC_CLASS(wxBitmapHandler
)
188 #endif // __GTKBITMAPH__