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
;
23 // ========================================================================
25 // ========================================================================
26 /* DFE: wxMask is not implemented yet */
28 // A mask is a mono bitmap used for drawing bitmaps
30 class WXDLLEXPORT wxMask
: public wxObject
32 DECLARE_DYNAMIC_CLASS(wxMask
)
36 // Construct a mask from a bitmap and a colour indicating
37 // the transparent area
38 wxMask(const wxBitmap
& bitmap
, const wxColour
& colour
);
40 // Construct a mask from a bitmap and a palette index indicating
41 // the transparent area
42 wxMask(const wxBitmap
& bitmap
, int paletteIndex
);
44 // Construct a mask from a mono bitmap (copies the bitmap).
45 wxMask(const wxBitmap
& bitmap
);
49 bool Create(const wxBitmap
& bitmap
, const wxColour
& colour
);
50 bool Create(const wxBitmap
& bitmap
, int paletteIndex
);
51 bool Create(const wxBitmap
& bitmap
);
54 // inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
55 // inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
57 // WXHBITMAP m_maskBitmap;
60 // ========================================================================
62 // ========================================================================
63 class WXDLLEXPORT wxBitmap
: public wxGDIObject
65 DECLARE_DYNAMIC_CLASS(wxBitmap
)
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
70 // Platform-specific default constructor
73 wxBitmap(const wxBitmap
& bitmap
)
76 // Initialize with raw data.
77 wxBitmap(const char bits
[], int width
, int height
, int depth
= 1);
78 // Initialize with XPM data
79 wxBitmap(const char **bits
) { CreateFromXpm(bits
); }
80 wxBitmap(char **bits
) { CreateFromXpm((const char**)bits
); }
81 // Load a file or resource
82 wxBitmap(const wxString
& name
, wxBitmapType type
= wxBITMAP_TYPE_BMP_RESOURCE
);
83 // Constructor for generalised creation from data
84 wxBitmap(void *data
, wxBitmapType type
, int width
, int height
, int depth
= 1);
85 // If depth is omitted, will create a bitmap compatible with the display
86 wxBitmap(int width
, int height
, int depth
= -1);
87 // Convert from wxImage:
88 wxBitmap(const wxImage
& image
, int depth
= -1)
89 { CreateFromImage(image
, depth
); }
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
97 // Initialize with XPM data
98 bool CreateFromXpm(const char **bits
);
99 // Initialize from wxImage
100 bool CreateFromImage(const wxImage
& image
, int depth
=-1);
102 virtual bool Create(int width
, int height
, int depth
= -1);
103 virtual bool Create(void *data
, wxBitmapType type
, int width
, int height
, int depth
= 1);
104 virtual bool LoadFile(const wxString
& name
, wxBitmapType type
= wxBITMAP_TYPE_BMP_RESOURCE
);
105 virtual bool SaveFile(const wxString
& name
, wxBitmapType type
, const wxPalette
*cmap
= NULL
) const;
107 // copies the contents and mask of the given (colour) icon to the bitmap
108 virtual bool CopyFromIcon(const wxIcon
& icon
);
110 wxImage
ConvertToImage() const;
112 // get the given part of bitmap
113 wxBitmap
GetSubBitmap( const wxRect
& rect
) const;
116 int GetWidth() const;
117 int GetHeight() const;
118 int GetDepth() const;
119 int GetQuality() const;
120 void SetWidth(int w
);
121 void SetHeight(int h
);
122 void SetDepth(int d
);
123 void SetQuality(int q
);
124 void SetOk(bool isOk
);
126 wxPalette
* GetPalette() const;
127 void SetPalette(const wxPalette
& palette
);
129 wxMask
*GetMask() const;
130 void SetMask(wxMask
*mask
) ;
132 int GetBitmapType() const;
134 inline wxBitmap
& operator = (const wxBitmap
& bitmap
)
135 { if (*this == bitmap
) return (*this); Ref(bitmap
); return *this; }
136 inline bool operator == (const wxBitmap
& bitmap
) const
137 { return m_refData
== bitmap
.m_refData
; }
138 inline bool operator != (const wxBitmap
& bitmap
) const
139 { return m_refData
!= bitmap
.m_refData
; }
142 wxObjectRefData
*CreateRefData() const;
143 wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
146 WX_NSBitmapImageRep
GetNSBitmapImageRep();
147 void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep
);
149 static void InitStandardHandlers() { }
150 static void CleanUpHandlers() { }
153 #endif // __WX_COCOA_BITMAP_H__