]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/bitmap.h
declare future-deprecated SetStyle(int) in wxPen/Brush and not wxPen/BrushBase as...
[wxWidgets.git] / include / wx / cocoa / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 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;
23
24 // ========================================================================
25 // wxMask
26 // ========================================================================
27
28 // A mask is a 1-bit alpha bitmap used for drawing bitmaps transparently.
29 class WXDLLIMPEXP_CORE wxMask: public wxObject
30 {
31 DECLARE_DYNAMIC_CLASS(wxMask)
32 public:
33 wxMask();
34
35 // Construct a mask from a bitmap and a colour indicating
36 // the transparent area
37 wxMask(const wxBitmap& bitmap, const wxColour& colour);
38
39 // Construct a mask from a bitmap and a palette index indicating
40 // the transparent area
41 wxMask(const wxBitmap& bitmap, int paletteIndex);
42
43 // Construct a mask from a mono bitmap (copies the bitmap).
44 wxMask(const wxBitmap& bitmap);
45
46 // Copy constructor
47 wxMask(const wxMask& src);
48
49 virtual ~wxMask();
50
51 bool Create(const wxBitmap& bitmap, const wxColour& colour);
52 bool Create(const wxBitmap& bitmap, int paletteIndex);
53 bool Create(const wxBitmap& bitmap);
54
55 // wxCocoa
56 inline WX_NSBitmapImageRep GetNSBitmapImageRep()
57 { return m_cocoaNSBitmapImageRep; }
58 protected:
59 WX_NSBitmapImageRep m_cocoaNSBitmapImageRep;
60 };
61
62 // ========================================================================
63 // wxBitmap
64 // ========================================================================
65 class WXDLLIMPEXP_CORE wxBitmap: public wxGDIObject
66 {
67 // ------------------------------------------------------------------------
68 // initialization
69 // ------------------------------------------------------------------------
70 public:
71 // Platform-specific default constructor
72 wxBitmap();
73 // Initialize with raw data.
74 wxBitmap(const char bits[], int width, int height, int depth = 1);
75 // Initialize with XPM data
76 wxBitmap(const char* const* bits);
77 // Load a file or resource
78 wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
79 // Construct from Cocoa's NSImage
80 wxBitmap(NSImage* cocoaNSImage);
81 // Construct from Cocoa's NSBitmapImageRep
82 wxBitmap(NSBitmapImageRep* cocoaNSBitmapImageRep);
83 // Constructor for generalised creation from data
84 wxBitmap(const 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); }
90 // Convert from wxIcon
91 wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
92
93 // destructor
94 virtual ~wxBitmap();
95
96 // ------------------------------------------------------------------------
97 // Implementation
98 // ------------------------------------------------------------------------
99 public:
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 bool Create(NSImage* cocoaNSImage);
105 bool Create(NSBitmapImageRep* cocoaNSBitmapImageRep);
106 virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
107 virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
108 virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
109
110 // copies the contents and mask of the given (colour) icon to the bitmap
111 virtual bool CopyFromIcon(const wxIcon& icon);
112
113 wxImage ConvertToImage() const;
114
115 // get the given part of bitmap
116 wxBitmap GetSubBitmap( const wxRect& rect ) const;
117
118 int GetWidth() const;
119 int GetHeight() const;
120 int GetDepth() const;
121 int GetQuality() const;
122 void SetWidth(int w);
123 void SetHeight(int h);
124 void SetDepth(int d);
125 void SetQuality(int q);
126 void SetOk(bool isOk);
127
128 // raw bitmap access support functions
129 void *GetRawData(wxPixelDataBase& data, int bpp);
130 void UngetRawData(wxPixelDataBase& data);
131
132 wxPalette* GetPalette() const;
133 void SetPalette(const wxPalette& palette);
134
135 wxMask *GetMask() const;
136 void SetMask(wxMask *mask) ;
137
138 wxBitmapType GetBitmapType() const;
139
140 // wxCocoa
141 WX_NSBitmapImageRep GetNSBitmapImageRep();
142 void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep);
143 WX_NSImage GetNSImage(bool useMask) const;
144
145 static void InitStandardHandlers() { }
146 static void CleanUpHandlers() { }
147
148 protected:
149 wxGDIRefData *CreateGDIRefData() const;
150 wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
151
152 DECLARE_DYNAMIC_CLASS(wxBitmap)
153 };
154
155
156 #endif // __WX_COCOA_BITMAP_H__