]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/palette.h
even more interface fixes
[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.
44 */
45 wxPalette(const wxPalette& palette);
65874118 46
23324ae1 47 /**
65874118 48 Creates a palette from arrays of size @a n, one for each red, blue or
74bf4e64 49 green component.
3c4f71cc 50
7c913512 51 @param palette
4cc4bfaf 52 A pointer or reference to the palette to copy.
7c913512 53 @param n
4cc4bfaf 54 The number of indices in the palette.
7c913512 55 @param red
4cc4bfaf 56 An array of red values.
7c913512 57 @param green
4cc4bfaf 58 An array of green values.
7c913512 59 @param blue
4cc4bfaf 60 An array of blue values.
3c4f71cc 61
4cc4bfaf 62 @see Create()
23324ae1 63 */
7c913512
FM
64 wxPalette(int n, const unsigned char* red,
65 const unsigned char* green,
66 const unsigned char* blue);
23324ae1
FM
67
68 /**
69 Destructor.
74bf4e64
FM
70
71 @see @ref overview_refcount_destruct "reference-counted object destruction"
23324ae1 72 */
adaaa686 73 virtual ~wxPalette();
23324ae1
FM
74
75 /**
65874118 76 Creates a palette from arrays of size @a n, one for each red, blue or
74bf4e64 77 green component.
3c4f71cc 78
7c913512 79 @param n
4cc4bfaf 80 The number of indices in the palette.
7c913512 81 @param red
4cc4bfaf 82 An array of red values.
7c913512 83 @param green
4cc4bfaf 84 An array of green values.
7c913512 85 @param blue
4cc4bfaf 86 An array of blue values.
3c4f71cc 87
d29a9a8a 88 @return @true if the creation was successful, @false otherwise.
3c4f71cc 89
4cc4bfaf 90 @see wxPalette()
23324ae1
FM
91 */
92 bool Create(int n, const unsigned char* red,
93 const unsigned char* green,
94 const unsigned char* blue);
95
96 /**
97 Returns number of entries in palette.
98 */
adaaa686 99 virtual int GetColoursCount() const;
23324ae1
FM
100
101 /**
102 Returns a pixel value (index into the palette) for the given RGB values.
3c4f71cc 103
7c913512 104 @param red
4cc4bfaf 105 Red value.
7c913512 106 @param green
4cc4bfaf 107 Green value.
7c913512 108 @param blue
4cc4bfaf 109 Blue value.
3c4f71cc 110
d29a9a8a 111 @return The nearest palette index or @c wxNOT_FOUND for unexpected errors.
3c4f71cc 112
4cc4bfaf 113 @see GetRGB()
23324ae1
FM
114 */
115 int GetPixel(unsigned char red, unsigned char green,
328f5751 116 unsigned char blue) const;
23324ae1
FM
117
118 /**
119 Returns RGB values for a given palette index.
3c4f71cc 120
7c913512 121 @param pixel
4cc4bfaf 122 The palette index.
7c913512 123 @param red
4cc4bfaf 124 Receives the red value.
7c913512 125 @param green
4cc4bfaf 126 Receives the green value.
7c913512 127 @param blue
4cc4bfaf 128 Receives the blue value.
3c4f71cc 129
d29a9a8a 130 @return @true if the operation was successful.
3c4f71cc 131
4cc4bfaf 132 @see GetPixel()
23324ae1 133 */
4cc4bfaf
FM
134 bool GetRGB(int pixel, const unsigned char* red,
135 const unsigned char* green,
328f5751 136 const unsigned char* blue) const;
23324ae1
FM
137
138 /**
139 Returns @true if palette data is present.
140 */
328f5751 141 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