]>
Commit | Line | Data |
---|---|---|
a24aff65 | 1 | ///////////////////////////////////////////////////////////////////////////// |
1b88201f | 2 | // Name: 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 |
1b88201f | 9 | // Licence: wxWindows licence |
a24aff65 DE |
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 | |
b5dbe15d VS |
18 | class WXDLLIMPEXP_FWD_CORE wxBitmap; |
19 | class WXDLLIMPEXP_FWD_CORE wxIcon; | |
20 | class WXDLLIMPEXP_FWD_CORE wxCursor; | |
21 | class WXDLLIMPEXP_FWD_CORE wxImage; | |
22 | class WXDLLIMPEXP_FWD_CORE 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 | |
d3c7fc99 | 46 | virtual ~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(); | |
d135b1a5 DE |
71 | // Initialize with raw data. |
72 | wxBitmap(const char bits[], int width, int height, int depth = 1); | |
73 | // Initialize with XPM data | |
452418c4 | 74 | wxBitmap(const char* const* bits); |
d135b1a5 DE |
75 | // Load a file or resource |
76 | wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); | |
77 | // Constructor for generalised creation from data | |
452418c4 | 78 | wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1); |
d135b1a5 DE |
79 | // If depth is omitted, will create a bitmap compatible with the display |
80 | wxBitmap(int width, int height, int depth = -1); | |
81 | // Convert from wxImage: | |
82 | wxBitmap(const wxImage& image, int depth = -1) | |
83 | { CreateFromImage(image, depth); } | |
b5df4fc7 DE |
84 | // Convert from wxIcon |
85 | wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); } | |
86 | ||
d135b1a5 | 87 | // destructor |
d3c7fc99 | 88 | virtual ~wxBitmap(); |
1b88201f | 89 | |
d135b1a5 DE |
90 | // ------------------------------------------------------------------------ |
91 | // Implementation | |
92 | // ------------------------------------------------------------------------ | |
a24aff65 | 93 | public: |
d135b1a5 DE |
94 | // Initialize from wxImage |
95 | bool CreateFromImage(const wxImage& image, int depth=-1); | |
96 | ||
97 | virtual bool Create(int width, int height, int depth = -1); | |
452418c4 | 98 | virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1); |
d135b1a5 DE |
99 | virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); |
100 | virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const; | |
101 | ||
102 | // copies the contents and mask of the given (colour) icon to the bitmap | |
103 | virtual bool CopyFromIcon(const wxIcon& icon); | |
104 | ||
105 | wxImage ConvertToImage() const; | |
106 | ||
107 | // get the given part of bitmap | |
108 | wxBitmap GetSubBitmap( const wxRect& rect ) const; | |
109 | ||
b7cacb43 VZ |
110 | bool Ok() const { return IsOk(); } |
111 | bool IsOk() const; | |
d135b1a5 DE |
112 | int GetWidth() const; |
113 | int GetHeight() const; | |
114 | int GetDepth() const; | |
115 | int GetQuality() const; | |
116 | void SetWidth(int w); | |
117 | void SetHeight(int h); | |
118 | void SetDepth(int d); | |
119 | void SetQuality(int q); | |
120 | void SetOk(bool isOk); | |
121 | ||
b60c6e97 DE |
122 | // raw bitmap access support functions |
123 | void *GetRawData(wxPixelDataBase& data, int bpp); | |
124 | void UngetRawData(wxPixelDataBase& data); | |
125 | ||
d135b1a5 DE |
126 | wxPalette* GetPalette() const; |
127 | void SetPalette(const wxPalette& palette); | |
128 | ||
129 | wxMask *GetMask() const; | |
130 | void SetMask(wxMask *mask) ; | |
131 | ||
132 | int GetBitmapType() const; | |
1b88201f | 133 | |
d135b1a5 DE |
134 | // wxObjectRefData |
135 | wxObjectRefData *CreateRefData() const; | |
136 | wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; | |
137 | ||
138 | // wxCocoa | |
139 | WX_NSBitmapImageRep GetNSBitmapImageRep(); | |
ab13160e | 140 | void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep); |
9c54e4ae | 141 | WX_NSImage GetNSImage(bool useMask) const; |
d135b1a5 DE |
142 | |
143 | static void InitStandardHandlers() { } | |
144 | static void CleanUpHandlers() { } | |
a24aff65 | 145 | }; |
d135b1a5 | 146 | |
452418c4 PC |
147 | class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase |
148 | { | |
149 | DECLARE_ABSTRACT_CLASS(wxBitmapHandler) | |
150 | }; | |
151 | ||
1b88201f WS |
152 | #endif |
153 | // __WX_COCOA_BITMAP_H__ |