]>
Commit | Line | Data |
---|---|---|
88ef3a57 WS |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: palette.tex | |
3 | %% Purpose: wxPalette docs | |
4 | %% Author: | |
5 | %% Modified by: | |
6 | %% Created: | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) wxWidgets | |
9 | %% License: wxWindows license | |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 | ||
a660d684 KB |
12 | \section{\class{wxPalette}}\label{wxpalette} |
13 | ||
df816ad9 RR |
14 | A palette is a table that maps pixel values to RGB colours. It allows the |
15 | colours of a low-depth bitmap, for example, to be mapped to the available | |
16 | colours in a display. The notion of palettes is becoming more and more | |
17 | obsolete nowadays and only the MSW port is still using a native palette. | |
18 | All other ports use generic code which is basically just an array of | |
19 | colours. | |
20 | ||
21 | It is likely that in the future the only use for palettes within wxWidgets | |
22 | will be for representing colour indeces from images (such as GIF or PNG). | |
23 | The image handlers for these formats have been modified to create a palette | |
24 | if there is such information in the original image file (usually 256 or less | |
25 | colour images). See \helpref{wxImage}{wximage} for more information. | |
a660d684 | 26 | |
5b6aa0ff | 27 | %TODO: topic overview for wxPalette. |
a660d684 KB |
28 | \wxheading{Derived from} |
29 | ||
30 | \helpref{wxGDIObject}{wxgdiobject}\\ | |
31 | \helpref{wxObject}{wxobject} | |
32 | ||
954b8ae6 JS |
33 | \wxheading{Include files} |
34 | ||
35 | <wx/palette.h> | |
36 | ||
20e85460 JS |
37 | \wxheading{Predefined objects} |
38 | ||
39 | Objects: | |
40 | ||
41 | {\bf wxNullPalette} | |
42 | ||
a660d684 KB |
43 | \wxheading{See also} |
44 | ||
45 | \helpref{wxDC::SetPalette}{wxdcsetpalette}, \helpref{wxBitmap}{wxbitmap} | |
46 | ||
47 | \latexignore{\rtfignore{\wxheading{Members}}} | |
48 | ||
dcbd177f | 49 | \membersection{wxPalette::wxPalette}\label{wxpalettector} |
a660d684 KB |
50 | |
51 | \func{}{wxPalette}{\void} | |
52 | ||
53 | Default constructor. | |
54 | ||
55 | \func{}{wxPalette}{\param{const wxPalette\&}{ palette}} | |
56 | ||
a91225b2 | 57 | Copy constructor, uses \helpref{reference counting}{trefcount}. |
a660d684 | 58 | |
eaaa6a06 | 59 | \func{}{wxPalette}{\param{int}{ n}, \param{const unsigned char* }{red},\\ |
a660d684 KB |
60 | \param{const unsigned char* }{green}, \param{const unsigned char* }{blue}} |
61 | ||
62 | Creates a palette from arrays of size {\it n}, one for each | |
63 | red, blue or green component. | |
64 | ||
65 | \wxheading{Parameters} | |
66 | ||
67 | \docparam{palette}{A pointer or reference to the palette to copy.} | |
68 | ||
69 | \docparam{n}{The number of indices in the palette.} | |
70 | ||
71 | \docparam{red}{An array of red values.} | |
72 | ||
73 | \docparam{green}{An array of green values.} | |
74 | ||
75 | \docparam{blue}{An array of blue values.} | |
76 | ||
77 | \wxheading{See also} | |
78 | ||
79 | \helpref{wxPalette::Create}{wxpalettecreate} | |
80 | ||
f3539882 VZ |
81 | \perlnote{In wxPerl the third constructor form takes as parameters |
82 | 3 array references ( they must be of the same length ).} | |
83 | ||
dcbd177f | 84 | \membersection{wxPalette::\destruct{wxPalette}}\label{wxpalettedtor} |
a660d684 KB |
85 | |
86 | \func{}{\destruct{wxPalette}}{\void} | |
87 | ||
88 | Destructor. | |
89 | ||
90 | \membersection{wxPalette::Create}\label{wxpalettecreate} | |
91 | ||
eaaa6a06 | 92 | \func{bool}{Create}{\param{int}{ n}, \param{const unsigned char* }{red},\rtfsp |
a660d684 KB |
93 | \param{const unsigned char* }{green}, \param{const unsigned char* }{blue}} |
94 | ||
95 | Creates a palette from arrays of size {\it n}, one for each | |
96 | red, blue or green component. | |
97 | ||
98 | \wxheading{Parameters} | |
99 | ||
100 | \docparam{n}{The number of indices in the palette.} | |
101 | ||
102 | \docparam{red}{An array of red values.} | |
103 | ||
104 | \docparam{green}{An array of green values.} | |
105 | ||
106 | \docparam{blue}{An array of blue values.} | |
107 | ||
108 | \wxheading{Return value} | |
109 | ||
cc81d32f | 110 | true if the creation was successful, false otherwise. |
a660d684 KB |
111 | |
112 | \wxheading{See also} | |
113 | ||
dcbd177f | 114 | \helpref{wxPalette::wxPalette}{wxpalettector} |
a660d684 | 115 | |
917be7ed WS |
116 | \membersection{wxPalette::GetColoursCount}\label{wxpalettegetcolourscount} |
117 | ||
118 | \constfunc{int}{GetColoursCount}{\void} | |
119 | ||
120 | Returns number of entries in palette. | |
121 | ||
a660d684 KB |
122 | \membersection{wxPalette::GetPixel}\label{wxpalettegetpixel} |
123 | ||
88ef3a57 WS |
124 | \constfunc{int}{GetPixel}{\param{unsigned char }{red}, \param{unsigned char }{green},\rtfsp |
125 | \param{unsigned char }{blue}} | |
a660d684 KB |
126 | |
127 | Returns a pixel value (index into the palette) for the given RGB values. | |
128 | ||
129 | \wxheading{Parameters} | |
130 | ||
131 | \docparam{red}{Red value.} | |
132 | ||
133 | \docparam{green}{Green value.} | |
134 | ||
135 | \docparam{blue}{Blue value.} | |
136 | ||
137 | \wxheading{Return value} | |
138 | ||
88ef3a57 | 139 | The nearest palette index or {\tt wxNOT\_FOUND} for unexpected errors. |
a660d684 KB |
140 | |
141 | \wxheading{See also} | |
142 | ||
143 | \helpref{wxPalette::GetRGB}{wxpalettegetrgb} | |
144 | ||
145 | \membersection{wxPalette::GetRGB}\label{wxpalettegetrgb} | |
146 | ||
0f353563 | 147 | \constfunc{bool}{GetRGB}{\param{int}{ pixel}, \param{const unsigned char* }{red}, \param{const unsigned char* }{green},\rtfsp |
a660d684 KB |
148 | \param{const unsigned char* }{blue}} |
149 | ||
150 | Returns RGB values for a given palette index. | |
151 | ||
152 | \wxheading{Parameters} | |
153 | ||
154 | \docparam{pixel}{The palette index.} | |
155 | ||
156 | \docparam{red}{Receives the red value.} | |
157 | ||
158 | \docparam{green}{Receives the green value.} | |
159 | ||
160 | \docparam{blue}{Receives the blue value.} | |
161 | ||
162 | \wxheading{Return value} | |
163 | ||
cc81d32f | 164 | true if the operation was successful. |
a660d684 KB |
165 | |
166 | \wxheading{See also} | |
167 | ||
168 | \helpref{wxPalette::GetPixel}{wxpalettegetpixel} | |
169 | ||
f3539882 VZ |
170 | \perlnote{In wxPerl this method takes only the {\tt pixel} parameter and |
171 | returns a 3-element list ( or the empty list upon failure ).} | |
172 | ||
b7cacb43 | 173 | \membersection{wxPalette::IsOk}\label{wxpaletteisok} |
a660d684 | 174 | |
b7cacb43 | 175 | \constfunc{bool}{IsOk}{\void} |
a660d684 | 176 | |
cc81d32f | 177 | Returns true if palette data is present. |
a660d684 KB |
178 | |
179 | \membersection{wxPalette::operator $=$}\label{wxpaletteassignment} | |
180 | ||
181 | \func{wxPalette\&}{operator $=$}{\param{const wxPalette\& }{palette}} | |
182 | ||
a91225b2 | 183 | Assignment operator, using \helpref{reference counting}{trefcount}. |
a660d684 KB |
184 | |
185 | \membersection{wxPalette::operator $==$}\label{wxpaletteequals} | |
186 | ||
187 | \func{bool}{operator $==$}{\param{const wxPalette\& }{palette}} | |
188 | ||
189 | Equality operator. Two palettes are equal if they contain pointers | |
190 | to the same underlying palette data. It does not compare each attribute, | |
191 | so two independently-created palettes using the same parameters will | |
192 | fail the test. | |
193 | ||
194 | \membersection{wxPalette::operator $!=$}\label{wxpalettenotequals} | |
195 | ||
196 | \func{bool}{operator $!=$}{\param{const wxPalette\& }{palette}} | |
197 | ||
198 | Inequality operator. Two palettes are not equal if they contain pointers | |
199 | to different underlying palette data. It does not compare each attribute. | |
b67a86d5 | 200 |