]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/bitmap.h
c34381159820dafa61e6eb338ae35d7addbf0807
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"
25 typedef struct _GdkPixbuf GdkPixbuf
;
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 class wxMask
: public wxObject
44 wxMask( const wxBitmap
& bitmap
, const wxColour
& colour
);
45 wxMask( const wxBitmap
& bitmap
, int paletteIndex
);
46 wxMask( const wxBitmap
& bitmap
);
49 bool Create( const wxBitmap
& bitmap
, const wxColour
& colour
);
50 bool Create( const wxBitmap
& bitmap
, int paletteIndex
);
51 bool Create( const wxBitmap
& bitmap
);
56 GdkBitmap
*GetBitmap() const;
59 DECLARE_DYNAMIC_CLASS(wxMask
)
62 //-----------------------------------------------------------------------------
64 //-----------------------------------------------------------------------------
66 class wxBitmap
: public wxBitmapBase
70 wxBitmap( int width
, int height
, int depth
= -1 );
71 wxBitmap( const char bits
[], int width
, int height
, int depth
= 1 );
72 wxBitmap( const char **bits
) { (void)CreateFromXpm(bits
); }
73 wxBitmap( char **bits
) { (void)CreateFromXpm((const char **)bits
); }
74 wxBitmap( const wxBitmap
& bmp
);
75 wxBitmap( const wxString
&filename
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
76 wxBitmap( const wxImage
& image
, int depth
= -1 ) { (void)CreateFromImage(image
, depth
); }
78 wxBitmap
& operator = ( const wxBitmap
& bmp
);
79 bool operator == ( const wxBitmap
& bmp
) const;
80 bool operator != ( const wxBitmap
& bmp
) const;
83 bool Create(int width
, int height
, int depth
= -1);
85 int GetHeight() const;
89 wxImage
ConvertToImage() const;
91 // copies the contents and mask of the given (colour) icon to the bitmap
92 virtual bool CopyFromIcon(const wxIcon
& icon
);
94 wxMask
*GetMask() const;
95 void SetMask( wxMask
*mask
);
97 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
99 bool SaveFile(const wxString
&name
, wxBitmapType type
,
100 const wxPalette
*palette
= (wxPalette
*)NULL
) const;
101 bool LoadFile(const wxString
&name
, wxBitmapType type
= wxBITMAP_TYPE_XPM
);
104 wxPalette
*GetPalette() const;
105 void SetPalette(const wxPalette
& palette
);
106 wxPalette
*GetColourMap() const { return GetPalette(); };
107 #endif // wxUSE_PALETTE
109 static void InitStandardHandlers();
114 void SetHeight( int height
);
115 void SetWidth( int width
);
116 void SetDepth( int depth
);
117 void SetPixmap( GdkPixmap
*pixmap
);
118 void SetBitmap( GdkBitmap
*bitmap
);
120 void SetPixbuf(GdkPixbuf
*pixbuf
);
123 GdkPixmap
*GetPixmap() const;
124 GdkBitmap
*GetBitmap() const;
125 bool HasPixmap() const;
127 bool HasPixbuf() const;
128 GdkPixbuf
*GetPixbuf() const;
131 // Basically, this corresponds to Win32 StretchBlt()
132 wxBitmap
Rescale( int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
);
134 bool CreateFromXpm(const char **bits
);
135 bool CreateFromImage(const wxImage
& image
, int depth
);
138 // to be called from CreateFromImage only!
139 bool CreateFromImageAsBitmap(const wxImage
& image
);
140 bool CreateFromImageAsPixmap(const wxImage
& image
);
143 bool CreateFromImageAsPixbuf(const wxImage
& image
);
150 // removes other representations from memory, keeping only 'keep'
151 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
152 void PurgeOtherRepresentations(Representation keep
);
154 friend class wxMemoryDC
;
156 friend class wxBitmapHandler
;
159 DECLARE_DYNAMIC_CLASS(wxBitmap
)
162 //-----------------------------------------------------------------------------
164 //-----------------------------------------------------------------------------
166 class wxBitmapHandler
: public wxBitmapHandlerBase
169 wxBitmapHandler() { }
170 virtual ~wxBitmapHandler();
172 virtual bool Create(wxBitmap
*bitmap
, void *data
, long flags
, int width
, int height
, int depth
= 1);
173 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
174 int desiredWidth
, int desiredHeight
);
175 virtual bool SaveFile(const wxBitmap
*bitmap
, const wxString
& name
, int type
, const wxPalette
*palette
= NULL
);
178 DECLARE_DYNAMIC_CLASS(wxBitmapHandler
)
182 #endif // __GTKBITMAPH__