]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/palette.h
Remove left over conflict markers from documentation.
[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$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
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
1058f652
MB
63 @beginWxPerlOnly
64 In wxPerl this method takes as parameters
65 3 array references (they must be of the same length).
66 @endWxPerlOnly
67
4cc4bfaf 68 @see Create()
23324ae1 69 */
7c913512
FM
70 wxPalette(int n, const unsigned char* red,
71 const unsigned char* green,
72 const unsigned char* blue);
23324ae1
FM
73
74 /**
75 Destructor.
74bf4e64
FM
76
77 @see @ref overview_refcount_destruct "reference-counted object destruction"
23324ae1 78 */
adaaa686 79 virtual ~wxPalette();
23324ae1
FM
80
81 /**
65874118 82 Creates a palette from arrays of size @a n, one for each red, blue or
74bf4e64 83 green component.
3c4f71cc 84
7c913512 85 @param n
4cc4bfaf 86 The number of indices in the palette.
7c913512 87 @param red
4cc4bfaf 88 An array of red values.
7c913512 89 @param green
4cc4bfaf 90 An array of green values.
7c913512 91 @param blue
4cc4bfaf 92 An array of blue values.
3c4f71cc 93
d29a9a8a 94 @return @true if the creation was successful, @false otherwise.
3c4f71cc 95
4cc4bfaf 96 @see wxPalette()
23324ae1
FM
97 */
98 bool Create(int n, const unsigned char* red,
99 const unsigned char* green,
100 const unsigned char* blue);
101
102 /**
103 Returns number of entries in palette.
104 */
adaaa686 105 virtual int GetColoursCount() const;
23324ae1
FM
106
107 /**
108 Returns a pixel value (index into the palette) for the given RGB values.
3c4f71cc 109
7c913512 110 @param red
4cc4bfaf 111 Red value.
7c913512 112 @param green
4cc4bfaf 113 Green value.
7c913512 114 @param blue
4cc4bfaf 115 Blue value.
3c4f71cc 116
d29a9a8a 117 @return The nearest palette index or @c wxNOT_FOUND for unexpected errors.
3c4f71cc 118
4cc4bfaf 119 @see GetRGB()
23324ae1
FM
120 */
121 int GetPixel(unsigned char red, unsigned char green,
328f5751 122 unsigned char blue) const;
23324ae1
FM
123
124 /**
125 Returns RGB values for a given palette index.
3c4f71cc 126
7c913512 127 @param pixel
4cc4bfaf 128 The palette index.
7c913512 129 @param red
4cc4bfaf 130 Receives the red value.
7c913512 131 @param green
4cc4bfaf 132 Receives the green value.
7c913512 133 @param blue
4cc4bfaf 134 Receives the blue value.
3c4f71cc 135
d29a9a8a 136 @return @true if the operation was successful.
3c4f71cc 137
1058f652
MB
138 @beginWxPerlOnly
139 In wxPerl this method takes only the @a pixel parameter and
140 returns a 3-element list (or the empty list upon failure).
141 @endWxPerlOnly
142
4cc4bfaf 143 @see GetPixel()
23324ae1 144 */
43c48e1e
FM
145 bool GetRGB(int pixel, unsigned char* red, unsigned char* green,
146 unsigned char* blue) const;
23324ae1
FM
147
148 /**
149 Returns @true if palette data is present.
150 */
0004982c 151 virtual bool IsOk() const;
23324ae1
FM
152
153 /**
74bf4e64 154 Assignment operator, using @ref overview_refcount.
23324ae1 155 */
74bf4e64 156 wxPalette& operator =(const wxPalette& palette);
23324ae1 157};
e54c96f1
FM
158
159
e54c96f1 160/**
65874118 161 An empty palette.
e54c96f1
FM
162*/
163wxPalette wxNullPalette;
164
165