]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/bitmap.h
Override CocoaSetEnabled() to do nothing. Although static lines are
[wxWidgets.git] / include / wx / cocoa / bitmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/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 WXDLLEXPORT wxBitmap;
19 class WXDLLEXPORT wxIcon;
20 class WXDLLEXPORT wxCursor;
21 class WXDLLEXPORT wxImage;
22
23 // ========================================================================
24 // wxMask
25 // ========================================================================
26 /* DFE: wxMask is not implemented yet */
27
28 // A mask is a mono bitmap used for drawing bitmaps
29 // transparently.
30 class WXDLLEXPORT wxMask: public wxObject
31 {
32 DECLARE_DYNAMIC_CLASS(wxMask)
33 public:
34 wxMask();
35
36 // Construct a mask from a bitmap and a colour indicating
37 // the transparent area
38 wxMask(const wxBitmap& bitmap, const wxColour& colour);
39
40 // Construct a mask from a bitmap and a palette index indicating
41 // the transparent area
42 wxMask(const wxBitmap& bitmap, int paletteIndex);
43
44 // Construct a mask from a mono bitmap (copies the bitmap).
45 wxMask(const wxBitmap& bitmap);
46
47 ~wxMask();
48
49 bool Create(const wxBitmap& bitmap, const wxColour& colour);
50 bool Create(const wxBitmap& bitmap, int paletteIndex);
51 bool Create(const wxBitmap& bitmap);
52
53 // Implementation
54 // inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
55 // inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
56 protected:
57 // WXHBITMAP m_maskBitmap;
58 };
59
60 // ========================================================================
61 // wxBitmap
62 // ========================================================================
63 class WXDLLEXPORT wxBitmap: public wxGDIObject
64 {
65 DECLARE_DYNAMIC_CLASS(wxBitmap)
66 // ------------------------------------------------------------------------
67 // initialization
68 // ------------------------------------------------------------------------
69 public:
70 // Platform-specific default constructor
71 wxBitmap();
72 // Copy constructors
73 wxBitmap(const wxBitmap& bitmap)
74 : wxGDIObject()
75 { Ref(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); }
90 // destructor
91 ~wxBitmap();
92
93 // ------------------------------------------------------------------------
94 // Implementation
95 // ------------------------------------------------------------------------
96 public:
97 // Initialize with XPM data
98 bool CreateFromXpm(const char **bits);
99 // Initialize from wxImage
100 bool CreateFromImage(const wxImage& image, int depth=-1);
101
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;
106
107 // copies the contents and mask of the given (colour) icon to the bitmap
108 virtual bool CopyFromIcon(const wxIcon& icon);
109
110 wxImage ConvertToImage() const;
111
112 // get the given part of bitmap
113 wxBitmap GetSubBitmap( const wxRect& rect ) const;
114
115 bool Ok() 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);
125
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;
133
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; }
140
141 // wxObjectRefData
142 wxObjectRefData *CreateRefData() const;
143 wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
144
145 // wxCocoa
146 WX_NSBitmapImageRep GetNSBitmapImageRep();
147 void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep);
148
149 static void InitStandardHandlers() { }
150 static void CleanUpHandlers() { }
151 };
152
153 #endif // __WX_COCOA_BITMAP_H__