]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/palette.h
use wxEventType coherently with the docs
[wxWidgets.git] / interface / wx / palette.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: palette.h
e54c96f1 3// Purpose: interface of wxPalette
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxPalette
7c913512 11
23324ae1
FM
12 A palette is a table that maps pixel values to RGB colours. It allows the
13 colours of a low-depth bitmap, for example, to be mapped to the available
14 colours in a display. The notion of palettes is becoming more and more
15 obsolete nowadays and only the MSW port is still using a native palette.
16 All other ports use generic code which is basically just an array of
7c913512
FM
17 colours.
18
23324ae1
FM
19 It is likely that in the future the only use for palettes within wxWidgets
20 will be for representing colour indeces from images (such as GIF or PNG).
21 The image handlers for these formats have been modified to create a palette
22 if there is such information in the original image file (usually 256 or less
23 colour images). See wxImage for more information.
7c913512 24
23324ae1
FM
25 @library{wxcore}
26 @category{gdi}
7c913512 27
23324ae1 28 @stdobjects
74bf4e64 29 ::wxNullPalette
7c913512 30
74bf4e64 31 @see wxDC::SetPalette(), wxBitmap
23324ae1
FM
32*/
33class wxPalette : public wxGDIObject
34{
35public:
74bf4e64
FM
36
37 /**
38 Default constructor.
39 */
40 wxPalette();
65874118 41
74bf4e64
FM
42 /**
43 Copy constructor, uses @ref overview_refcount.
dd72e767
FM
44
45 @param palette
46 A reference to the palette to copy.
74bf4e64
FM
47 */
48 wxPalette(const wxPalette& palette);
65874118 49
23324ae1 50 /**
65874118 51 Creates a palette from arrays of size @a n, one for each red, blue or
74bf4e64 52 green component.
3c4f71cc 53
7c913512 54 @param n
4cc4bfaf 55 The number of indices in the palette.
7c913512 56 @param red
4cc4bfaf 57 An array of red values.
7c913512 58 @param green
4cc4bfaf 59 An array of green values.
7c913512 60 @param blue
4cc4bfaf 61 An array of blue values.
3c4f71cc 62
4cc4bfaf 63 @see Create()
23324ae1 64 */
7c913512
FM
65 wxPalette(int n, const unsigned char* red,
66 const unsigned char* green,
67 const unsigned char* blue);
23324ae1
FM
68
69 /**
70 Destructor.
74bf4e64
FM
71
72 @see @ref overview_refcount_destruct "reference-counted object destruction"
23324ae1 73 */
adaaa686 74 virtual ~wxPalette();
23324ae1
FM
75
76 /**
65874118 77 Creates a palette from arrays of size @a n, one for each red, blue or
74bf4e64 78 green component.
3c4f71cc 79
7c913512 80 @param n
4cc4bfaf 81 The number of indices in the palette.
7c913512 82 @param red
4cc4bfaf 83 An array of red values.
7c913512 84 @param green
4cc4bfaf 85 An array of green values.
7c913512 86 @param blue
4cc4bfaf 87 An array of blue values.
3c4f71cc 88
d29a9a8a 89 @return @true if the creation was successful, @false otherwise.
3c4f71cc 90
4cc4bfaf 91 @see wxPalette()
23324ae1
FM
92 */
93 bool Create(int n, const unsigned char* red,
94 const unsigned char* green,
95 const unsigned char* blue);
96
97 /**
98 Returns number of entries in palette.
99 */
adaaa686 100 virtual int GetColoursCount() const;
23324ae1
FM
101
102 /**
103 Returns a pixel value (index into the palette) for the given RGB values.
3c4f71cc 104
7c913512 105 @param red
4cc4bfaf 106 Red value.
7c913512 107 @param green
4cc4bfaf 108 Green value.
7c913512 109 @param blue
4cc4bfaf 110 Blue value.
3c4f71cc 111
d29a9a8a 112 @return The nearest palette index or @c wxNOT_FOUND for unexpected errors.
3c4f71cc 113
4cc4bfaf 114 @see GetRGB()
23324ae1
FM
115 */
116 int GetPixel(unsigned char red, unsigned char green,
328f5751 117 unsigned char blue) const;
23324ae1
FM
118
119 /**
120 Returns RGB values for a given palette index.
3c4f71cc 121
7c913512 122 @param pixel
4cc4bfaf 123 The palette index.
7c913512 124 @param red
4cc4bfaf 125 Receives the red value.
7c913512 126 @param green
4cc4bfaf 127 Receives the green value.
7c913512 128 @param blue
4cc4bfaf 129 Receives the blue value.
3c4f71cc 130
d29a9a8a 131 @return @true if the operation was successful.
3c4f71cc 132
4cc4bfaf 133 @see GetPixel()
23324ae1 134 */
43c48e1e
FM
135 bool GetRGB(int pixel, unsigned char* red, unsigned char* green,
136 unsigned char* blue) const;
23324ae1
FM
137
138 /**
139 Returns @true if palette data is present.
140 */
0004982c 141 virtual bool IsOk() const;
23324ae1
FM
142
143 /**
74bf4e64 144 Assignment operator, using @ref overview_refcount.
23324ae1 145 */
74bf4e64 146 wxPalette& operator =(const wxPalette& palette);
23324ae1 147};
e54c96f1
FM
148
149
e54c96f1 150/**
65874118 151 An empty palette.
e54c96f1
FM
152*/
153wxPalette wxNullPalette;
154
155