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