]> git.saurik.com Git - wxWidgets.git/blame - interface/palette.h
More interface header reviews by Azriel Fasten, and added skeleton docs for wxBookCtr...
[wxWidgets.git] / interface / 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
11 @wxheader{palette.h}
7c913512 12
23324ae1
FM
13 A palette is a table that maps pixel values to RGB colours. It allows the
14 colours of a low-depth bitmap, for example, to be mapped to the available
15 colours in a display. The notion of palettes is becoming more and more
16 obsolete nowadays and only the MSW port is still using a native palette.
17 All other ports use generic code which is basically just an array of
7c913512
FM
18 colours.
19
23324ae1
FM
20 It is likely that in the future the only use for palettes within wxWidgets
21 will be for representing colour indeces from images (such as GIF or PNG).
22 The image handlers for these formats have been modified to create a palette
23 if there is such information in the original image file (usually 256 or less
24 colour images). See wxImage for more information.
7c913512 25
23324ae1
FM
26 @library{wxcore}
27 @category{gdi}
7c913512 28
23324ae1 29 @stdobjects
74bf4e64 30 ::wxNullPalette
7c913512 31
74bf4e64 32 @see wxDC::SetPalette(), wxBitmap
23324ae1
FM
33*/
34class wxPalette : public wxGDIObject
35{
36public:
74bf4e64
FM
37
38 /**
39 Default constructor.
40 */
41 wxPalette();
65874118 42
74bf4e64
FM
43 /**
44 Copy constructor, uses @ref overview_refcount.
45 */
46 wxPalette(const wxPalette& palette);
65874118 47
23324ae1 48 /**
65874118 49 Creates a palette from arrays of size @a n, one for each red, blue or
74bf4e64 50 green component.
3c4f71cc 51
7c913512 52 @param palette
4cc4bfaf 53 A pointer or reference to the palette to copy.
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
FM
73 */
74 ~wxPalette();
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 */
328f5751 100 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 */
4cc4bfaf
FM
135 bool GetRGB(int pixel, const unsigned char* red,
136 const unsigned char* green,
328f5751 137 const unsigned char* blue) const;
23324ae1
FM
138
139 /**
140 Returns @true if palette data is present.
141 */
328f5751 142 bool IsOk() const;
23324ae1
FM
143
144 /**
74bf4e64 145 Assignment operator, using @ref overview_refcount.
23324ae1 146 */
74bf4e64 147 wxPalette& operator =(const wxPalette& palette);
23324ae1 148};
e54c96f1
FM
149
150
e54c96f1 151/**
65874118 152 An empty palette.
e54c96f1
FM
153*/
154wxPalette wxNullPalette;
155
156