]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/bitmap.h
added support for 2 extra mouse buttons (patch 1757630)
[wxWidgets.git] / include / wx / x11 / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: x11/bitmap.h
3 // Purpose: wxBitmap class
4 // Author: Julian Smart, Robert Roebling
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart, Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_BITMAP_H_
13 #define _WX_BITMAP_H_
14
15 #include "wx/defs.h"
16 #include "wx/object.h"
17 #include "wx/string.h"
18 #include "wx/palette.h"
19 #include "wx/gdiobj.h"
20
21 //-----------------------------------------------------------------------------
22 // classes
23 //-----------------------------------------------------------------------------
24
25 class WXDLLIMPEXP_FWD_CORE wxMask;
26 class WXDLLIMPEXP_FWD_CORE wxBitmap;
27 class WXDLLIMPEXP_FWD_CORE wxImage;
28
29 //-----------------------------------------------------------------------------
30 // wxMask
31 //-----------------------------------------------------------------------------
32
33 class WXDLLIMPEXP_CORE wxMask: public wxObject
34 {
35 public:
36 wxMask();
37 wxMask( const wxBitmap& bitmap, const wxColour& colour );
38 wxMask( const wxBitmap& bitmap, int paletteIndex );
39 wxMask( const wxBitmap& bitmap );
40 virtual ~wxMask();
41
42 bool Create( const wxBitmap& bitmap, const wxColour& colour );
43 bool Create( const wxBitmap& bitmap, int paletteIndex );
44 bool Create( const wxBitmap& bitmap );
45
46 // implementation
47 WXPixmap GetBitmap() const { return m_bitmap; }
48 void SetBitmap( WXPixmap bitmap ) { m_bitmap = bitmap; }
49
50 WXDisplay *GetDisplay() const { return m_display; }
51 void SetDisplay( WXDisplay *display ) { m_display = display; }
52
53 private:
54 WXPixmap m_bitmap;
55 WXDisplay *m_display;
56
57 private:
58 DECLARE_DYNAMIC_CLASS(wxMask)
59 };
60
61 //-----------------------------------------------------------------------------
62 // wxBitmap
63 //-----------------------------------------------------------------------------
64
65 class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
66 {
67 DECLARE_ABSTRACT_CLASS(wxBitmapHandler)
68 };
69
70 class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
71 {
72 public:
73 wxBitmap();
74 wxBitmap( int width, int height, int depth = -1 );
75 wxBitmap( const char bits[], int width, int height, int depth = 1 );
76 wxBitmap( const char* const* bits );
77 #ifdef wxNEEDS_CHARPP
78 // needed for old GCC
79 wxBitmap(char** data)
80 {
81 *this = wxBitmap(wx_const_cast(const char* const*, data));
82 }
83 #endif
84 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
85 virtual ~wxBitmap();
86
87 bool Ok() const { return IsOk(); }
88 bool IsOk() const;
89
90 static void InitStandardHandlers();
91
92 bool Create(int width, int height, int depth = -1);
93 bool Create(const void* data, wxBitmapType type,
94 int width, int height, int depth = -1);
95 // create the wxBitmap using a _copy_ of the pixmap
96 bool Create(WXPixmap pixmap);
97
98 int GetHeight() const;
99 int GetWidth() const;
100 int GetDepth() const;
101
102 #if wxUSE_IMAGE
103 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
104 wxImage ConvertToImage() const;
105 bool CreateFromImage(const wxImage& image, int depth = -1);
106 #endif // wxUSE_IMAGE
107
108 // copies the contents and mask of the given (colour) icon to the bitmap
109 virtual bool CopyFromIcon(const wxIcon& icon);
110
111 wxMask *GetMask() const;
112 void SetMask( wxMask *mask );
113
114 wxBitmap GetSubBitmap( const wxRect& rect ) const;
115
116 bool SaveFile( const wxString &name, wxBitmapType type, const wxPalette *palette = (wxPalette *) NULL ) const;
117 bool LoadFile( const wxString &name, wxBitmapType type = wxBITMAP_TYPE_XPM );
118
119 wxPalette *GetPalette() const;
120 wxPalette *GetColourMap() const
121 { return GetPalette(); };
122 virtual void SetPalette(const wxPalette& palette);
123
124 // implementation
125 // --------------
126
127 void SetHeight( int height );
128 void SetWidth( int width );
129 void SetDepth( int depth );
130 void SetPixmap( WXPixmap pixmap );
131 void SetBitmap( WXPixmap bitmap );
132
133 WXPixmap GetPixmap() const;
134 WXPixmap GetBitmap() const;
135
136 WXPixmap GetDrawable() const;
137
138 WXDisplay *GetDisplay() const;
139
140 protected:
141 virtual wxObjectRefData *CreateRefData() const;
142 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
143
144 private:
145 DECLARE_DYNAMIC_CLASS(wxBitmap)
146 };
147
148 #endif // _WX_BITMAP_H_