]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/bitmap.h
6b3186d1b21111f2a2bdabb3208dc616c6d39a5d
[wxWidgets.git] / include / wx / cocoa / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/cocoa/bitmap.h
3 // Purpose: wxBitmap class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/07/19
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __WX_COCOA_BITMAP_H__
13 #define __WX_COCOA_BITMAP_H__
14
15 #include "wx/palette.h"
16
17 // Bitmap
18 class WXDLLEXPORT wxBitmap;
19 class WXDLLEXPORT wxIcon;
20 class WXDLLEXPORT wxCursor;
21 class WXDLLEXPORT wxImage;
22 class WXDLLEXPORT wxPixelDataBase;
23
24 // ========================================================================
25 // wxMask
26 // ========================================================================
27 /* DFE: wxMask is not implemented yet */
28
29 // A mask is a mono bitmap used for drawing bitmaps
30 // transparently.
31 class WXDLLEXPORT wxMask: public wxObject
32 {
33 DECLARE_DYNAMIC_CLASS(wxMask)
34 public:
35 wxMask();
36
37 // Construct a mask from a bitmap and a colour indicating
38 // the transparent area
39 wxMask(const wxBitmap& bitmap, const wxColour& colour);
40
41 // Construct a mask from a bitmap and a palette index indicating
42 // the transparent area
43 wxMask(const wxBitmap& bitmap, int paletteIndex);
44
45 // Construct a mask from a mono bitmap (copies the bitmap).
46 wxMask(const wxBitmap& bitmap);
47
48 ~wxMask();
49
50 bool Create(const wxBitmap& bitmap, const wxColour& colour);
51 bool Create(const wxBitmap& bitmap, int paletteIndex);
52 bool Create(const wxBitmap& bitmap);
53
54 // Implementation
55 // inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
56 // inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
57 protected:
58 // WXHBITMAP m_maskBitmap;
59 };
60
61 // ========================================================================
62 // wxBitmap
63 // ========================================================================
64 class WXDLLEXPORT wxBitmap: public wxGDIObject
65 {
66 DECLARE_DYNAMIC_CLASS(wxBitmap)
67 // ------------------------------------------------------------------------
68 // initialization
69 // ------------------------------------------------------------------------
70 public:
71 // Platform-specific default constructor
72 wxBitmap();
73 // Copy constructors
74 wxBitmap(const wxBitmap& bitmap)
75 : wxGDIObject()
76 { Ref(bitmap); }
77 // Initialize with raw data.
78 wxBitmap(const char bits[], int width, int height, int depth = 1);
79 // Initialize with XPM data
80 wxBitmap(const char **bits) { CreateFromXpm(bits); }
81 wxBitmap(char **bits) { CreateFromXpm((const char**)bits); }
82 // Load a file or resource
83 wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
84 // Constructor for generalised creation from data
85 wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1);
86 // If depth is omitted, will create a bitmap compatible with the display
87 wxBitmap(int width, int height, int depth = -1);
88 // Convert from wxImage:
89 wxBitmap(const wxImage& image, int depth = -1)
90 { CreateFromImage(image, depth); }
91 // destructor
92 ~wxBitmap();
93
94 // ------------------------------------------------------------------------
95 // Implementation
96 // ------------------------------------------------------------------------
97 public:
98 // Initialize with XPM data
99 bool CreateFromXpm(const char **bits);
100 // Initialize from wxImage
101 bool CreateFromImage(const wxImage& image, int depth=-1);
102
103 virtual bool Create(int width, int height, int depth = -1);
104 virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1);
105 virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
106 virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
107
108 // copies the contents and mask of the given (colour) icon to the bitmap
109 virtual bool CopyFromIcon(const wxIcon& icon);
110
111 wxImage ConvertToImage() const;
112
113 // get the given part of bitmap
114 wxBitmap GetSubBitmap( const wxRect& rect ) const;
115
116 bool Ok() const;
117 int GetWidth() const;
118 int GetHeight() const;
119 int GetDepth() const;
120 int GetQuality() const;
121 void SetWidth(int w);
122 void SetHeight(int h);
123 void SetDepth(int d);
124 void SetQuality(int q);
125 void SetOk(bool isOk);
126
127 // raw bitmap access support functions
128 void *GetRawData(wxPixelDataBase& data, int bpp);
129 void UngetRawData(wxPixelDataBase& data);
130
131 wxPalette* GetPalette() const;
132 void SetPalette(const wxPalette& palette);
133
134 wxMask *GetMask() const;
135 void SetMask(wxMask *mask) ;
136
137 int GetBitmapType() const;
138
139 inline wxBitmap& operator = (const wxBitmap& bitmap)
140 { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
141 inline bool operator == (const wxBitmap& bitmap) const
142 { return m_refData == bitmap.m_refData; }
143 inline bool operator != (const wxBitmap& bitmap) const
144 { return m_refData != bitmap.m_refData; }
145
146 // wxObjectRefData
147 wxObjectRefData *CreateRefData() const;
148 wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
149
150 // wxCocoa
151 WX_NSBitmapImageRep GetNSBitmapImageRep();
152 void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep);
153
154 static void InitStandardHandlers() { }
155 static void CleanUpHandlers() { }
156 };
157
158 #endif // __WX_COCOA_BITMAP_H__