]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/bitmap.h
Add a helper wxApp::GetValidTraits() method.
[wxWidgets.git] / include / wx / x11 / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/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 wxMask& mask);
38 wxMask( const wxBitmap& bitmap, const wxColour& colour );
39 wxMask( const wxBitmap& bitmap, int paletteIndex );
40 wxMask( const wxBitmap& bitmap );
41 virtual ~wxMask();
42
43 bool Create( const wxBitmap& bitmap, const wxColour& colour );
44 bool Create( const wxBitmap& bitmap, int paletteIndex );
45 bool Create( const wxBitmap& bitmap );
46
47 // implementation
48 WXPixmap GetBitmap() const { return m_bitmap; }
49 void SetBitmap( WXPixmap bitmap ) { m_bitmap = bitmap; }
50
51 WXDisplay *GetDisplay() const { return m_display; }
52 void SetDisplay( WXDisplay *display ) { m_display = display; }
53
54 private:
55 WXPixmap m_bitmap;
56 WXDisplay *m_display;
57 wxSize m_size;
58
59 private:
60 DECLARE_DYNAMIC_CLASS(wxMask)
61 };
62
63 //-----------------------------------------------------------------------------
64 // wxBitmap
65 //-----------------------------------------------------------------------------
66
67 class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
68 {
69 public:
70 wxBitmap() {}
71 wxBitmap( int width, int height, int depth = -1 ) { Create( width, height, depth ); }
72 wxBitmap( const wxSize& sz, int depth = -1 ) { Create( sz, depth ); }
73
74 wxBitmap( const char bits[], int width, int height, int depth = 1 );
75 wxBitmap( const char* const* bits );
76 #ifdef wxNEEDS_CHARPP
77 // needed for old GCC
78 wxBitmap(char** data)
79 {
80 *this = wxBitmap(const_cast<const char* const*>(data));
81 }
82 #endif
83 wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
84 virtual ~wxBitmap();
85
86 static void InitStandardHandlers();
87
88 bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
89 bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
90 { return Create(sz.GetWidth(), sz.GetHeight(), depth); }
91 bool Create(int width, int height, const wxDC& WXUNUSED(dc))
92 { return Create(width,height); }
93
94 bool Create(const void* data, wxBitmapType type,
95 int width, int height, int depth = -1);
96 // create the wxBitmap using a _copy_ of the pixmap
97 bool Create(WXPixmap pixmap);
98
99 int GetHeight() const;
100 int GetWidth() const;
101 int GetDepth() const;
102
103 #if wxUSE_IMAGE
104 wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
105 wxImage ConvertToImage() const;
106 bool CreateFromImage(const wxImage& image, int depth = -1);
107 #endif // wxUSE_IMAGE
108
109 // copies the contents and mask of the given (colour) icon to the bitmap
110 virtual bool CopyFromIcon(const wxIcon& icon);
111
112 wxMask *GetMask() const;
113 void SetMask( wxMask *mask );
114
115 wxBitmap GetSubBitmap( const wxRect& rect ) const;
116
117 bool SaveFile( const wxString &name, wxBitmapType type, const wxPalette *palette = NULL ) const;
118 bool LoadFile( const wxString &name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE );
119
120 wxPalette *GetPalette() const;
121 wxPalette *GetColourMap() const
122 { return GetPalette(); }
123 virtual void SetPalette(const wxPalette& palette);
124
125 // implementation
126 // --------------
127
128 void SetHeight( int height );
129 void SetWidth( int width );
130 void SetDepth( int depth );
131 void SetPixmap( WXPixmap pixmap );
132 void SetBitmap( WXPixmap bitmap );
133
134 WXPixmap GetPixmap() const;
135 WXPixmap GetBitmap() const;
136
137 WXPixmap GetDrawable() const;
138
139 WXDisplay *GetDisplay() const;
140
141 protected:
142 virtual wxGDIRefData *CreateGDIRefData() const;
143 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
144
145 private:
146 DECLARE_DYNAMIC_CLASS(wxBitmap)
147 };
148
149 #endif // _WX_BITMAP_H_