]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/bitmap.h
Set svn properties on recently added files.
[wxWidgets.git] / include / wx / cocoa / bitmap.h
CommitLineData
a24aff65 1/////////////////////////////////////////////////////////////////////////////
1b88201f 2// Name: 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
1b88201f 9// Licence: wxWindows licence
a24aff65
DE
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
b5dbe15d
VS
18class WXDLLIMPEXP_FWD_CORE wxBitmap;
19class WXDLLIMPEXP_FWD_CORE wxIcon;
20class WXDLLIMPEXP_FWD_CORE wxCursor;
21class WXDLLIMPEXP_FWD_CORE wxImage;
22class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
a24aff65 23
d135b1a5
DE
24// ========================================================================
25// wxMask
26// ========================================================================
d135b1a5 27
016b0643 28// A mask is a 1-bit alpha bitmap used for drawing bitmaps transparently.
53a2db12 29class WXDLLIMPEXP_CORE wxMask: public wxObject
a24aff65
DE
30{
31 DECLARE_DYNAMIC_CLASS(wxMask)
a24aff65 32public:
016b0643 33 wxMask();
a24aff65 34
016b0643
DE
35 // Construct a mask from a bitmap and a colour indicating
36 // the transparent area
37 wxMask(const wxBitmap& bitmap, const wxColour& colour);
a24aff65 38
016b0643
DE
39 // Construct a mask from a bitmap and a palette index indicating
40 // the transparent area
41 wxMask(const wxBitmap& bitmap, int paletteIndex);
a24aff65 42
016b0643
DE
43 // Construct a mask from a mono bitmap (copies the bitmap).
44 wxMask(const wxBitmap& bitmap);
a24aff65 45
319fe103
DE
46 // Copy constructor
47 wxMask(const wxMask& src);
48
d3c7fc99 49 virtual ~wxMask();
a24aff65 50
016b0643
DE
51 bool Create(const wxBitmap& bitmap, const wxColour& colour);
52 bool Create(const wxBitmap& bitmap, int paletteIndex);
53 bool Create(const wxBitmap& bitmap);
a24aff65 54
016b0643
DE
55 // wxCocoa
56 inline WX_NSBitmapImageRep GetNSBitmapImageRep()
57 { return m_cocoaNSBitmapImageRep; }
a24aff65 58protected:
016b0643 59 WX_NSBitmapImageRep m_cocoaNSBitmapImageRep;
a24aff65
DE
60};
61
732d8c74 62
d135b1a5
DE
63// ========================================================================
64// wxBitmap
65// ========================================================================
732d8c74 66
20e6714a
VZ
67class WXDLLIMPEXP_CORE wxBitmap: public wxGDIObject,
68 public wxBitmapHelpers
a24aff65 69{
d135b1a5
DE
70// ------------------------------------------------------------------------
71// initialization
72// ------------------------------------------------------------------------
a24aff65 73public:
d135b1a5
DE
74 // Platform-specific default constructor
75 wxBitmap();
d135b1a5
DE
76 // Initialize with raw data.
77 wxBitmap(const char bits[], int width, int height, int depth = 1);
78 // Initialize with XPM data
452418c4 79 wxBitmap(const char* const* bits);
d135b1a5 80 // Load a file or resource
cbea3ec6 81 wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
d381b7df
DE
82 // Construct from Cocoa's NSImage
83 wxBitmap(NSImage* cocoaNSImage);
84 // Construct from Cocoa's NSBitmapImageRep
85 wxBitmap(NSBitmapImageRep* cocoaNSBitmapImageRep);
d135b1a5 86 // Constructor for generalised creation from data
452418c4 87 wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1);
d135b1a5 88 // If depth is omitted, will create a bitmap compatible with the display
732d8c74
FM
89 wxBitmap(int width, int height, int depth = -1)
90 { (void)Create(width, height, depth); }
91 wxBitmap(const wxSize& sz, int depth = -1)
92 { (void)Create(sz, depth); }
d135b1a5
DE
93 // Convert from wxImage:
94 wxBitmap(const wxImage& image, int depth = -1)
732d8c74 95 { CreateFromImage(image, depth); }
b5df4fc7
DE
96 // Convert from wxIcon
97 wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
98
d135b1a5 99 // destructor
d3c7fc99 100 virtual ~wxBitmap();
1b88201f 101
d135b1a5
DE
102// ------------------------------------------------------------------------
103// Implementation
104// ------------------------------------------------------------------------
a24aff65 105public:
d135b1a5
DE
106 // Initialize from wxImage
107 bool CreateFromImage(const wxImage& image, int depth=-1);
108
732d8c74
FM
109 virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
110 virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
111 { return Create(sz.GetWidth(), sz.GetHeight(), depth); }
112
e82b00a7
DE
113 bool Create(NSImage* cocoaNSImage);
114 bool Create(NSBitmapImageRep* cocoaNSBitmapImageRep);
452418c4 115 virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
cbea3ec6 116 virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
d135b1a5
DE
117 virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
118
119 // copies the contents and mask of the given (colour) icon to the bitmap
120 virtual bool CopyFromIcon(const wxIcon& icon);
121
122 wxImage ConvertToImage() const;
123
124 // get the given part of bitmap
125 wxBitmap GetSubBitmap( const wxRect& rect ) const;
126
d135b1a5
DE
127 int GetWidth() const;
128 int GetHeight() const;
129 int GetDepth() const;
130 int GetQuality() const;
131 void SetWidth(int w);
132 void SetHeight(int h);
133 void SetDepth(int d);
134 void SetQuality(int q);
135 void SetOk(bool isOk);
136
b60c6e97
DE
137 // raw bitmap access support functions
138 void *GetRawData(wxPixelDataBase& data, int bpp);
139 void UngetRawData(wxPixelDataBase& data);
140
d135b1a5
DE
141 wxPalette* GetPalette() const;
142 void SetPalette(const wxPalette& palette);
143
144 wxMask *GetMask() const;
145 void SetMask(wxMask *mask) ;
146
e86f2cc8 147 wxBitmapType GetBitmapType() const;
1b88201f 148
d135b1a5
DE
149 // wxCocoa
150 WX_NSBitmapImageRep GetNSBitmapImageRep();
ab13160e 151 void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep);
9c54e4ae 152 WX_NSImage GetNSImage(bool useMask) const;
d135b1a5
DE
153
154 static void InitStandardHandlers() { }
155 static void CleanUpHandlers() { }
8f884a0d
VZ
156
157protected:
158 wxGDIRefData *CreateGDIRefData() const;
159 wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
160
161 DECLARE_DYNAMIC_CLASS(wxBitmap)
a24aff65 162};
d135b1a5 163
452418c4 164
8f884a0d 165#endif // __WX_COCOA_BITMAP_H__