]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/bitmap.h
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 wxGDIObject
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
, int 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
, int type
, wxPalette
*palette
= (wxPalette
*) NULL
);
100 bool LoadFile( const wxString
&name
, int type
= wxBITMAP_TYPE_XPM
);
102 wxPalette
*GetPalette() const;
103 wxPalette
*GetColourMap() const { return GetPalette(); };
105 static void InitStandardHandlers() { }
106 static void CleanUpHandlers() { }
111 void SetHeight( int height
);
112 void SetWidth( int width
);
113 void SetDepth( int depth
);
114 void SetPixmap( GdkPixmap
*pixmap
);
115 void SetBitmap( GdkBitmap
*bitmap
);
117 void SetPixbuf(GdkPixbuf
*pixbuf
);
120 GdkPixmap
*GetPixmap() const;
121 GdkBitmap
*GetBitmap() const;
122 bool HasPixmap() const;
124 bool HasPixbuf() const;
125 GdkPixbuf
*GetPixbuf() const;
128 // Basically, this corresponds to Win32 StretchBlt()
129 wxBitmap
Rescale( int clipx
, int clipy
, int clipwidth
, int clipheight
, int width
, int height
);
131 bool CreateFromXpm(const char **bits
);
132 bool CreateFromImage(const wxImage
& image
, int depth
);
135 // to be called from CreateFromImage only!
136 bool CreateFromImageAsBitmap(const wxImage
& image
);
137 bool CreateFromImageAsPixmap(const wxImage
& image
);
140 bool CreateFromImageAsPixbuf(const wxImage
& image
);
147 // removes other representations from memory, keeping only 'keep'
148 // (wxBitmap may keep same bitmap e.g. as both pixmap and pixbuf):
149 void PurgeOtherRepresentations(Representation keep
);
151 friend class wxMemoryDC
;
154 DECLARE_DYNAMIC_CLASS(wxBitmap
)
157 #endif // __GTKBITMAPH__