]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/bitmap.h
define WX_XTI_TEMPLATE_FIX in case it is not yet
[wxWidgets.git] / include / wx / cocoa / bitmap.h
CommitLineData
a24aff65 1/////////////////////////////////////////////////////////////////////////////
d135b1a5 2// Name: include/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
a24aff65
DE
9// Licence: wxWindows licence
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
18class WXDLLEXPORT wxBitmap;
a24aff65
DE
19class WXDLLEXPORT wxIcon;
20class WXDLLEXPORT wxCursor;
21class WXDLLEXPORT wxImage;
22
d135b1a5
DE
23// ========================================================================
24// wxMask
25// ========================================================================
26/* DFE: wxMask is not implemented yet */
27
a24aff65
DE
28// A mask is a mono bitmap used for drawing bitmaps
29// transparently.
30class WXDLLEXPORT wxMask: public wxObject
31{
32 DECLARE_DYNAMIC_CLASS(wxMask)
a24aff65
DE
33public:
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; }
56protected:
57// WXHBITMAP m_maskBitmap;
58};
59
d135b1a5
DE
60// ========================================================================
61// wxBitmap
62// ========================================================================
63class WXDLLEXPORT wxBitmap: public wxGDIObject
a24aff65 64{
d135b1a5
DE
65 DECLARE_DYNAMIC_CLASS(wxBitmap)
66// ------------------------------------------------------------------------
67// initialization
68// ------------------------------------------------------------------------
a24aff65 69public:
d135b1a5
DE
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();
a24aff65 92
d135b1a5
DE
93// ------------------------------------------------------------------------
94// Implementation
95// ------------------------------------------------------------------------
a24aff65 96public:
d135b1a5
DE
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;
a24aff65 133
d135b1a5
DE
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();
ab13160e 147 void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep);
d135b1a5
DE
148
149 static void InitStandardHandlers() { }
150 static void CleanUpHandlers() { }
a24aff65 151};
d135b1a5
DE
152
153#endif // __WX_COCOA_BITMAP_H__