]> git.saurik.com Git - wxWidgets.git/blame - interface/palette.h
store selected indices as unsigned int, not size_t, in wxSelectionStore, we don't...
[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
e54c96f1 30 ::Objects:, ::wxNullPalette,
7c913512 31
e54c96f1 32 @see wxDC::SetPalette, wxBitmap
23324ae1
FM
33*/
34class wxPalette : public wxGDIObject
35{
36public:
37 //@{
38 /**
39 Creates a palette from arrays of size @e n, one for each
40 red, blue or green component.
3c4f71cc 41
7c913512 42 @param palette
4cc4bfaf 43 A pointer or reference to the palette to copy.
7c913512 44 @param n
4cc4bfaf 45 The number of indices in the palette.
7c913512 46 @param red
4cc4bfaf 47 An array of red values.
7c913512 48 @param green
4cc4bfaf 49 An array of green values.
7c913512 50 @param blue
4cc4bfaf 51 An array of blue values.
3c4f71cc 52
4cc4bfaf 53 @see Create()
23324ae1
FM
54 */
55 wxPalette();
7c913512
FM
56 wxPalette(const wxPalette& palette);
57 wxPalette(int n, const unsigned char* red,
58 const unsigned char* green,
59 const unsigned char* blue);
23324ae1
FM
60 //@}
61
62 /**
63 Destructor.
64 See @ref overview_refcountdestruct "reference-counted object destruction" for
65 more info.
66 */
67 ~wxPalette();
68
69 /**
70 Creates a palette from arrays of size @e n, one for each
71 red, blue or green component.
3c4f71cc 72
7c913512 73 @param n
4cc4bfaf 74 The number of indices in the palette.
7c913512 75 @param red
4cc4bfaf 76 An array of red values.
7c913512 77 @param green
4cc4bfaf 78 An array of green values.
7c913512 79 @param blue
4cc4bfaf 80 An array of blue values.
3c4f71cc 81
23324ae1 82 @returns @true if the creation was successful, @false otherwise.
3c4f71cc 83
4cc4bfaf 84 @see wxPalette()
23324ae1
FM
85 */
86 bool Create(int n, const unsigned char* red,
87 const unsigned char* green,
88 const unsigned char* blue);
89
90 /**
91 Returns number of entries in palette.
92 */
328f5751 93 int GetColoursCount() const;
23324ae1
FM
94
95 /**
96 Returns a pixel value (index into the palette) for the given RGB values.
3c4f71cc 97
7c913512 98 @param red
4cc4bfaf 99 Red value.
7c913512 100 @param green
4cc4bfaf 101 Green value.
7c913512 102 @param blue
4cc4bfaf 103 Blue value.
3c4f71cc 104
23324ae1 105 @returns The nearest palette index or wxNOT_FOUND for unexpected errors.
3c4f71cc 106
4cc4bfaf 107 @see GetRGB()
23324ae1
FM
108 */
109 int GetPixel(unsigned char red, unsigned char green,
328f5751 110 unsigned char blue) const;
23324ae1
FM
111
112 /**
113 Returns RGB values for a given palette index.
3c4f71cc 114
7c913512 115 @param pixel
4cc4bfaf 116 The palette index.
7c913512 117 @param red
4cc4bfaf 118 Receives the red value.
7c913512 119 @param green
4cc4bfaf 120 Receives the green value.
7c913512 121 @param blue
4cc4bfaf 122 Receives the blue value.
3c4f71cc 123
23324ae1 124 @returns @true if the operation was successful.
3c4f71cc 125
4cc4bfaf 126 @see GetPixel()
23324ae1 127 */
4cc4bfaf
FM
128 bool GetRGB(int pixel, const unsigned char* red,
129 const unsigned char* green,
328f5751 130 const unsigned char* blue) const;
23324ae1
FM
131
132 /**
133 Returns @true if palette data is present.
134 */
328f5751 135 bool IsOk() const;
23324ae1
FM
136
137 /**
138 Assignment operator, using @ref overview_trefcount "reference counting".
139 */
140 wxPalette operator =(const wxPalette& palette);
141};
e54c96f1
FM
142
143
144/**
145 FIXME
146*/
147wxPalette Objects:
148;
149
150/**
151 FIXME
152*/
153wxPalette wxNullPalette;
154
155