1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/cocoa/bitmap.h
3 // Purpose: wxBitmap class
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __WX_COCOA_BITMAP_H__
13 #define __WX_COCOA_BITMAP_H__
15 #include "wx/palette.h"
18 class WXDLLEXPORT wxBitmap
;
19 class WXDLLEXPORT wxIcon
;
20 class WXDLLEXPORT wxCursor
;
21 class WXDLLEXPORT wxImage
;
22 class WXDLLEXPORT wxPixelDataBase
;
24 // ========================================================================
26 // ========================================================================
27 /* DFE: wxMask is not implemented yet */
29 // A mask is a mono bitmap used for drawing bitmaps
31 class WXDLLEXPORT wxMask
: public wxObject
33 DECLARE_DYNAMIC_CLASS(wxMask
)
37 // Construct a mask from a bitmap and a colour indicating
38 // the transparent area
39 wxMask(const wxBitmap
& bitmap
, const wxColour
& colour
);
41 // Construct a mask from a bitmap and a palette index indicating
42 // the transparent area
43 wxMask(const wxBitmap
& bitmap
, int paletteIndex
);
45 // Construct a mask from a mono bitmap (copies the bitmap).
46 wxMask(const wxBitmap
& bitmap
);
50 bool Create(const wxBitmap
& bitmap
, const wxColour
& colour
);
51 bool Create(const wxBitmap
& bitmap
, int paletteIndex
);
52 bool Create(const wxBitmap
& bitmap
);
55 // inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
56 // inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
58 // WXHBITMAP m_maskBitmap;
61 // ========================================================================
63 // ========================================================================
64 class WXDLLEXPORT wxBitmap
: public wxGDIObject
66 DECLARE_DYNAMIC_CLASS(wxBitmap
)
67 // ------------------------------------------------------------------------
69 // ------------------------------------------------------------------------
71 // Platform-specific default constructor
74 wxBitmap(const wxBitmap
& 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
); }
94 // ------------------------------------------------------------------------
96 // ------------------------------------------------------------------------
98 // Initialize with XPM data
99 bool CreateFromXpm(const char **bits
);
100 // Initialize from wxImage
101 bool CreateFromImage(const wxImage
& image
, int depth
=-1);
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;
108 // copies the contents and mask of the given (colour) icon to the bitmap
109 virtual bool CopyFromIcon(const wxIcon
& icon
);
111 wxImage
ConvertToImage() const;
113 // get the given part of bitmap
114 wxBitmap
GetSubBitmap( const wxRect
& rect
) 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
);
127 // raw bitmap access support functions
128 void *GetRawData(wxPixelDataBase
& data
, int bpp
);
129 void UngetRawData(wxPixelDataBase
& data
);
131 wxPalette
* GetPalette() const;
132 void SetPalette(const wxPalette
& palette
);
134 wxMask
*GetMask() const;
135 void SetMask(wxMask
*mask
) ;
137 int GetBitmapType() const;
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
; }
147 wxObjectRefData
*CreateRefData() const;
148 wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
151 WX_NSBitmapImageRep
GetNSBitmapImageRep();
152 void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep
);
154 static void InitStandardHandlers() { }
155 static void CleanUpHandlers() { }
158 #endif // __WX_COCOA_BITMAP_H__