]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
1e6feb95 | 2 | // Name: generic/colrdlgg.cpp |
c801d85f KB |
3 | // Purpose: Choice dialogs |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
6aa89a22 | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
c801d85f KB |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
1e6feb95 | 16 | #pragma hdrstop |
c801d85f KB |
17 | #endif |
18 | ||
853bbd9e | 19 | #if wxUSE_COLOURDLG && (!defined(__WXGTK20__) || defined(__WXUNIVERSAL__)) |
1e6feb95 | 20 | |
c801d85f | 21 | #ifndef WX_PRECOMP |
1e6feb95 VZ |
22 | #include "wx/utils.h" |
23 | #include "wx/intl.h" | |
24 | #include "wx/dialog.h" | |
25 | #include "wx/listbox.h" | |
26 | #include "wx/button.h" | |
27 | #include "wx/stattext.h" | |
28 | #include "wx/layout.h" | |
29 | #include "wx/dcclient.h" | |
1e6feb95 | 30 | #include "wx/sizer.h" |
4130b487 RR |
31 | #endif |
32 | ||
33 | #if wxUSE_STATLINE | |
34 | #include "wx/statline.h" | |
c801d85f KB |
35 | #endif |
36 | ||
6bb44116 WS |
37 | #if wxUSE_SLIDER |
38 | #include "wx/slider.h" | |
39 | #endif | |
40 | ||
c801d85f KB |
41 | #include "wx/generic/colrdlgg.h" |
42 | ||
c801d85f KB |
43 | IMPLEMENT_DYNAMIC_CLASS(wxGenericColourDialog, wxDialog) |
44 | ||
45 | BEGIN_EVENT_TABLE(wxGenericColourDialog, wxDialog) | |
c35414db | 46 | EVT_BUTTON(wxID_ADD_CUSTOM, wxGenericColourDialog::OnAddCustom) |
6bb44116 | 47 | #if wxUSE_SLIDER |
c35414db VZ |
48 | EVT_SLIDER(wxID_RED_SLIDER, wxGenericColourDialog::OnRedSlider) |
49 | EVT_SLIDER(wxID_GREEN_SLIDER, wxGenericColourDialog::OnGreenSlider) | |
50 | EVT_SLIDER(wxID_BLUE_SLIDER, wxGenericColourDialog::OnBlueSlider) | |
6bb44116 | 51 | #endif |
c35414db VZ |
52 | EVT_PAINT(wxGenericColourDialog::OnPaint) |
53 | EVT_MOUSE_EVENTS(wxGenericColourDialog::OnMouseEvent) | |
54 | EVT_CLOSE(wxGenericColourDialog::OnCloseWindow) | |
c801d85f KB |
55 | END_EVENT_TABLE() |
56 | ||
c801d85f KB |
57 | |
58 | /* | |
59 | * Generic wxColourDialog | |
60 | */ | |
61 | ||
61138de0 VZ |
62 | // don't change the number of elements (48) in this array, the code below is |
63 | // hardcoded to use it | |
64 | static const wxChar *wxColourDialogNames[] = | |
65 | { | |
66 | wxT("ORANGE"), | |
67 | wxT("GOLDENROD"), | |
68 | wxT("WHEAT"), | |
69 | wxT("SPRING GREEN"), | |
70 | wxT("SKY BLUE"), | |
71 | wxT("SLATE BLUE"), | |
72 | wxT("MEDIUM VIOLET RED"), | |
73 | wxT("PURPLE"), | |
74 | ||
75 | wxT("RED"), | |
76 | wxT("YELLOW"), | |
77 | wxT("MEDIUM SPRING GREEN"), | |
78 | wxT("PALE GREEN"), | |
79 | wxT("CYAN"), | |
80 | wxT("LIGHT STEEL BLUE"), | |
81 | wxT("ORCHID"), | |
82 | wxT("LIGHT MAGENTA"), | |
83 | ||
84 | wxT("BROWN"), | |
85 | wxT("YELLOW"), | |
86 | wxT("GREEN"), | |
87 | wxT("CADET BLUE"), | |
88 | wxT("MEDIUM BLUE"), | |
89 | wxT("MAGENTA"), | |
90 | wxT("MAROON"), | |
91 | wxT("ORANGE RED"), | |
92 | ||
93 | wxT("FIREBRICK"), | |
94 | wxT("CORAL"), | |
95 | wxT("FOREST GREEN"), | |
96 | wxT("AQUAMARINE"), | |
97 | wxT("BLUE"), | |
98 | wxT("NAVY"), | |
99 | wxT("THISTLE"), | |
100 | wxT("MEDIUM VIOLET RED"), | |
101 | ||
102 | wxT("INDIAN RED"), | |
103 | wxT("GOLD"), | |
104 | wxT("MEDIUM SEA GREEN"), | |
105 | wxT("MEDIUM BLUE"), | |
106 | wxT("MIDNIGHT BLUE"), | |
107 | wxT("GREY"), | |
108 | wxT("PURPLE"), | |
109 | wxT("KHAKI"), | |
110 | ||
111 | wxT("BLACK"), | |
112 | wxT("MEDIUM FOREST GREEN"), | |
113 | wxT("KHAKI"), | |
114 | wxT("DARK GREY"), | |
115 | wxT("SEA GREEN"), | |
116 | wxT("LIGHT GREY"), | |
117 | wxT("MEDIUM SLATE BLUE"), | |
118 | wxT("WHITE") | |
119 | }; | |
c801d85f | 120 | |
4130b487 | 121 | wxGenericColourDialog::wxGenericColourDialog() |
c801d85f KB |
122 | { |
123 | dialogParent = NULL; | |
124 | whichKind = 1; | |
ea8a9699 | 125 | colourSelection = -1; |
c801d85f KB |
126 | } |
127 | ||
f6bcfd97 BP |
128 | wxGenericColourDialog::wxGenericColourDialog(wxWindow *parent, |
129 | wxColourData *data) | |
c801d85f KB |
130 | { |
131 | whichKind = 1; | |
ea8a9699 | 132 | colourSelection = -1; |
c801d85f KB |
133 | Create(parent, data); |
134 | } | |
135 | ||
4130b487 | 136 | wxGenericColourDialog::~wxGenericColourDialog() |
c801d85f KB |
137 | { |
138 | } | |
139 | ||
74e3313b | 140 | void wxGenericColourDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) |
c801d85f | 141 | { |
e3065973 | 142 | EndModal(wxID_CANCEL); |
c801d85f KB |
143 | } |
144 | ||
145 | bool wxGenericColourDialog::Create(wxWindow *parent, wxColourData *data) | |
146 | { | |
ca65c044 | 147 | if ( !wxDialog::Create(parent, wxID_ANY, _("Choose colour"), |
c47addef | 148 | wxPoint(0,0), wxSize(900, 900)) ) |
ca65c044 | 149 | return false; |
c35414db | 150 | |
f6bcfd97 | 151 | dialogParent = parent; |
c801d85f | 152 | |
f6bcfd97 BP |
153 | if (data) |
154 | colourData = *data; | |
c35414db | 155 | |
f6bcfd97 BP |
156 | InitializeColours(); |
157 | CalculateMeasurements(); | |
158 | CreateWidgets(); | |
159 | ||
ca65c044 | 160 | return true; |
c801d85f KB |
161 | } |
162 | ||
4130b487 | 163 | int wxGenericColourDialog::ShowModal() |
c801d85f | 164 | { |
984b0d8b | 165 | return wxDialog::ShowModal(); |
c801d85f KB |
166 | } |
167 | ||
168 | ||
169 | // Internal functions | |
170 | void wxGenericColourDialog::OnMouseEvent(wxMouseEvent& event) | |
171 | { | |
172 | if (event.ButtonDown(1)) | |
173 | { | |
174 | int x = (int)event.GetX(); | |
175 | int y = (int)event.GetY(); | |
176 | ||
b1f9d7bf DW |
177 | #ifdef __WXPM__ |
178 | // Handle OS/2's reverse coordinate system and account for the dialog title | |
179 | int nClientHeight; | |
180 | ||
181 | GetClientSize(NULL, &nClientHeight); | |
182 | y = (nClientHeight - y) + 20; | |
183 | #endif | |
c801d85f KB |
184 | if ((x >= standardColoursRect.x && x <= (standardColoursRect.x + standardColoursRect.width)) && |
185 | (y >= standardColoursRect.y && y <= (standardColoursRect.y + standardColoursRect.height))) | |
186 | { | |
187 | int selX = (int)(x - standardColoursRect.x)/(smallRectangleSize.x + gridSpacing); | |
188 | int selY = (int)(y - standardColoursRect.y)/(smallRectangleSize.y + gridSpacing); | |
189 | int ptr = (int)(selX + selY*8); | |
190 | OnBasicColourClick(ptr); | |
191 | } | |
192 | else if ((x >= customColoursRect.x && x <= (customColoursRect.x + customColoursRect.width)) && | |
193 | (y >= customColoursRect.y && y <= (customColoursRect.y + customColoursRect.height))) | |
194 | { | |
195 | int selX = (int)(x - customColoursRect.x)/(smallRectangleSize.x + gridSpacing); | |
196 | int selY = (int)(y - customColoursRect.y)/(smallRectangleSize.y + gridSpacing); | |
197 | int ptr = (int)(selX + selY*8); | |
198 | OnCustomColourClick(ptr); | |
199 | } | |
c10920de VS |
200 | else |
201 | event.Skip(); | |
c801d85f | 202 | } |
c10920de VS |
203 | else |
204 | event.Skip(); | |
c801d85f KB |
205 | } |
206 | ||
207 | void wxGenericColourDialog::OnPaint(wxPaintEvent& event) | |
208 | { | |
1bf38b0e | 209 | #if !defined(__WXMOTIF__) && !defined(__WXPM__) && !defined(__WXCOCOA__) |
7a893a31 WS |
210 | wxDialog::OnPaint(event); |
211 | #else | |
212 | wxUnusedVar(event); | |
d75638f8 | 213 | #endif |
c801d85f | 214 | |
7a893a31 | 215 | wxPaintDC dc(this); |
c801d85f | 216 | |
7a893a31 WS |
217 | PaintBasicColours(dc); |
218 | PaintCustomColours(dc); | |
219 | PaintCustomColour(dc); | |
220 | PaintHighlight(dc, true); | |
c801d85f KB |
221 | } |
222 | ||
4130b487 | 223 | void wxGenericColourDialog::CalculateMeasurements() |
c801d85f KB |
224 | { |
225 | smallRectangleSize.x = 18; | |
226 | smallRectangleSize.y = 14; | |
227 | customRectangleSize.x = 40; | |
228 | customRectangleSize.y = 40; | |
229 | ||
230 | gridSpacing = 6; | |
231 | sectionSpacing = 15; | |
232 | ||
233 | standardColoursRect.x = 10; | |
b1f9d7bf DW |
234 | #ifdef __WXPM__ |
235 | standardColoursRect.y = 15 + 20; /* OS/2 needs to account for dialog titlebar */ | |
236 | #else | |
c801d85f | 237 | standardColoursRect.y = 15; |
b1f9d7bf | 238 | #endif |
c801d85f KB |
239 | standardColoursRect.width = (8*smallRectangleSize.x) + (7*gridSpacing); |
240 | standardColoursRect.height = (6*smallRectangleSize.y) + (5*gridSpacing); | |
241 | ||
242 | customColoursRect.x = standardColoursRect.x; | |
243 | customColoursRect.y = standardColoursRect.y + standardColoursRect.height + 20; | |
244 | customColoursRect.width = (8*smallRectangleSize.x) + (7*gridSpacing); | |
245 | customColoursRect.height = (2*smallRectangleSize.y) + (1*gridSpacing); | |
246 | ||
247 | singleCustomColourRect.x = customColoursRect.width + customColoursRect.x + sectionSpacing; | |
248 | singleCustomColourRect.y = 80; | |
249 | singleCustomColourRect.width = customRectangleSize.x; | |
250 | singleCustomColourRect.height = customRectangleSize.y; | |
251 | ||
252 | okButtonX = 10; | |
253 | customButtonX = singleCustomColourRect.x ; | |
254 | buttonY = customColoursRect.y + customColoursRect.height + 10; | |
255 | } | |
256 | ||
4130b487 | 257 | void wxGenericColourDialog::CreateWidgets() |
c801d85f | 258 | { |
4130b487 | 259 | wxBeginBusyCursor(); |
c801d85f | 260 | |
6bb44116 WS |
261 | wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); |
262 | ||
f79a46f8 | 263 | const int sliderHeight = 160; |
4130b487 | 264 | |
6bb44116 WS |
265 | #if wxUSE_SLIDER |
266 | const int sliderX = singleCustomColourRect.x + singleCustomColourRect.width + sectionSpacing; | |
267 | ||
984b0d8b | 268 | redSlider = new wxSlider(this, wxID_RED_SLIDER, colourData.m_dataColour.Red(), 0, 255, |
a3b8b891 | 269 | wxDefaultPosition, wxSize(wxDefaultCoord, sliderHeight), wxSL_VERTICAL|wxSL_LABELS|wxSL_INVERSE); |
984b0d8b | 270 | greenSlider = new wxSlider(this, wxID_GREEN_SLIDER, colourData.m_dataColour.Green(), 0, 255, |
a3b8b891 | 271 | wxDefaultPosition, wxSize(wxDefaultCoord, sliderHeight), wxSL_VERTICAL|wxSL_LABELS|wxSL_INVERSE); |
984b0d8b | 272 | blueSlider = new wxSlider(this, wxID_BLUE_SLIDER, colourData.m_dataColour.Blue(), 0, 255, |
a3b8b891 | 273 | wxDefaultPosition, wxSize(wxDefaultCoord, sliderHeight), wxSL_VERTICAL|wxSL_LABELS|wxSL_INVERSE); |
f79a46f8 WS |
274 | |
275 | wxBoxSizer *sliderSizer = new wxBoxSizer( wxHORIZONTAL ); | |
276 | ||
277 | // 1) space for sliders | |
278 | sliderSizer->Add( sliderX, sliderHeight ); | |
279 | sliderSizer->Add( redSlider, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 10 ); | |
280 | sliderSizer->Add( greenSlider, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 10 ); | |
281 | sliderSizer->Add( blueSlider, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 10 ); | |
4130b487 | 282 | |
f79a46f8 | 283 | topSizer->Add( sliderSizer, 0, wxCENTRE | wxALL, 10 ); |
6bb44116 WS |
284 | #else |
285 | topSizer->Add( 1, sliderHeight, 0, wxCENTRE | wxALL, 15 ); | |
286 | #endif // wxUSE_SLIDER | |
6c34d0ed | 287 | |
4130b487 RR |
288 | #if wxUSE_STATLINE |
289 | // 2) static line | |
f79a46f8 | 290 | topSizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); |
c801d85f | 291 | #endif |
c35414db | 292 | |
4130b487 RR |
293 | // 3) buttons |
294 | wxSizer *buttonsizer = CreateButtonSizer( wxOK|wxCANCEL ); | |
295 | buttonsizer->Add( new wxButton(this, wxID_ADD_CUSTOM, _("Add to custom colours") ), 0, wxLEFT|wxRIGHT, 10 ); | |
acf2ac37 | 296 | topSizer->Add( buttonsizer, 0, wxEXPAND | wxALL, 10 ); |
c801d85f | 297 | |
ca65c044 | 298 | SetAutoLayout( true ); |
f79a46f8 | 299 | SetSizer( topSizer ); |
6c34d0ed | 300 | |
f79a46f8 WS |
301 | topSizer->SetSizeHints( this ); |
302 | topSizer->Fit( this ); | |
c801d85f | 303 | |
4130b487 | 304 | Centre( wxBOTH ); |
c801d85f | 305 | |
4130b487 | 306 | wxEndBusyCursor(); |
c801d85f KB |
307 | } |
308 | ||
309 | void wxGenericColourDialog::InitializeColours(void) | |
310 | { | |
a4ba2eec | 311 | size_t i; |
ea8a9699 | 312 | |
61138de0 | 313 | for (i = 0; i < WXSIZEOF(wxColourDialogNames); i++) |
ea8a9699 | 314 | { |
564a150b VZ |
315 | wxColour col = wxTheColourDatabase->Find(wxColourDialogNames[i]); |
316 | if (col.Ok()) | |
317 | standardColours[i].Set(col.Red(), col.Green(), col.Blue()); | |
ea8a9699 VZ |
318 | else |
319 | standardColours[i].Set(0, 0, 0); | |
320 | } | |
c801d85f | 321 | |
564a150b | 322 | for (i = 0; i < WXSIZEOF(customColours); i++) |
ea8a9699 | 323 | { |
a2b99ff5 VS |
324 | wxColour c = colourData.GetCustomColour(i); |
325 | if (c.Ok()) | |
326 | customColours[i] = colourData.GetCustomColour(i); | |
327 | else | |
328 | customColours[i] = wxColour(255, 255, 255); | |
ea8a9699 | 329 | } |
c801d85f | 330 | |
ea8a9699 VZ |
331 | wxColour curr = colourData.GetColour(); |
332 | if ( curr.Ok() ) | |
333 | { | |
ca65c044 | 334 | bool initColourFound = false; |
ea8a9699 | 335 | |
61138de0 | 336 | for (i = 0; i < WXSIZEOF(wxColourDialogNames); i++) |
ea8a9699 VZ |
337 | { |
338 | if ( standardColours[i] == curr && !initColourFound ) | |
339 | { | |
340 | whichKind = 1; | |
341 | colourSelection = i; | |
ca65c044 | 342 | initColourFound = true; |
ea8a9699 VZ |
343 | break; |
344 | } | |
345 | } | |
346 | if ( !initColourFound ) | |
347 | { | |
564a150b | 348 | for ( i = 0; i < WXSIZEOF(customColours); i++ ) |
ea8a9699 VZ |
349 | { |
350 | if ( customColours[i] == curr ) | |
351 | { | |
352 | whichKind = 2; | |
353 | colourSelection = i; | |
ea8a9699 VZ |
354 | break; |
355 | } | |
356 | } | |
357 | } | |
984b0d8b | 358 | colourData.m_dataColour.Set( curr.Red(), curr.Green(), curr.Blue() ); |
ea8a9699 VZ |
359 | } |
360 | else | |
361 | { | |
362 | whichKind = 1; | |
363 | colourSelection = 0; | |
984b0d8b | 364 | colourData.m_dataColour.Set( 0, 0, 0 ); |
ea8a9699 | 365 | } |
c801d85f KB |
366 | } |
367 | ||
368 | void wxGenericColourDialog::PaintBasicColours(wxDC& dc) | |
369 | { | |
c801d85f KB |
370 | int i; |
371 | for (i = 0; i < 6; i++) | |
372 | { | |
373 | int j; | |
374 | for (j = 0; j < 8; j++) | |
375 | { | |
376 | int ptr = i*8 + j; | |
c35414db | 377 | |
c801d85f KB |
378 | int x = (j*(smallRectangleSize.x+gridSpacing) + standardColoursRect.x); |
379 | int y = (i*(smallRectangleSize.y+gridSpacing) + standardColoursRect.y); | |
380 | ||
381 | dc.SetPen(*wxBLACK_PEN); | |
382 | wxBrush brush(standardColours[ptr], wxSOLID); | |
383 | dc.SetBrush(brush); | |
384 | ||
385 | dc.DrawRectangle( x, y, smallRectangleSize.x, smallRectangleSize.y); | |
386 | } | |
387 | } | |
c801d85f KB |
388 | } |
389 | ||
390 | void wxGenericColourDialog::PaintCustomColours(wxDC& dc) | |
391 | { | |
c801d85f KB |
392 | int i; |
393 | for (i = 0; i < 2; i++) | |
394 | { | |
395 | int j; | |
396 | for (j = 0; j < 8; j++) | |
397 | { | |
398 | int ptr = i*8 + j; | |
c35414db | 399 | |
c801d85f KB |
400 | int x = (j*(smallRectangleSize.x+gridSpacing)) + customColoursRect.x; |
401 | int y = (i*(smallRectangleSize.y+gridSpacing)) + customColoursRect.y; | |
402 | ||
403 | dc.SetPen(*wxBLACK_PEN); | |
404 | ||
405 | wxBrush brush(customColours[ptr], wxSOLID); | |
406 | dc.SetBrush(brush); | |
407 | ||
408 | dc.DrawRectangle( x, y, smallRectangleSize.x, smallRectangleSize.y); | |
409 | } | |
410 | } | |
c801d85f KB |
411 | } |
412 | ||
413 | void wxGenericColourDialog::PaintHighlight(wxDC& dc, bool draw) | |
414 | { | |
ea8a9699 VZ |
415 | if ( colourSelection < 0 ) |
416 | return; | |
417 | ||
c801d85f KB |
418 | // Number of pixels bigger than the standard rectangle size |
419 | // for drawing a highlight | |
420 | int deltaX = 2; | |
421 | int deltaY = 2; | |
422 | ||
423 | if (whichKind == 1) | |
424 | { | |
425 | // Standard colours | |
426 | int y = (int)(colourSelection / 8); | |
427 | int x = (int)(colourSelection - (y*8)); | |
428 | ||
429 | x = (x*(smallRectangleSize.x + gridSpacing) + standardColoursRect.x) - deltaX; | |
430 | y = (y*(smallRectangleSize.y + gridSpacing) + standardColoursRect.y) - deltaY; | |
431 | ||
432 | if (draw) | |
433 | dc.SetPen(*wxBLACK_PEN); | |
434 | else | |
435 | dc.SetPen(*wxLIGHT_GREY_PEN); | |
436 | ||
437 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | |
438 | dc.DrawRectangle( x, y, (smallRectangleSize.x + (2*deltaX)), (smallRectangleSize.y + (2*deltaY))); | |
439 | } | |
440 | else | |
441 | { | |
442 | // User-defined colours | |
443 | int y = (int)(colourSelection / 8); | |
444 | int x = (int)(colourSelection - (y*8)); | |
445 | ||
446 | x = (x*(smallRectangleSize.x + gridSpacing) + customColoursRect.x) - deltaX; | |
447 | y = (y*(smallRectangleSize.y + gridSpacing) + customColoursRect.y) - deltaY; | |
448 | ||
449 | if (draw) | |
450 | dc.SetPen(*wxBLACK_PEN); | |
451 | else | |
452 | dc.SetPen(*wxLIGHT_GREY_PEN); | |
c35414db | 453 | |
c801d85f KB |
454 | dc.SetBrush(*wxTRANSPARENT_BRUSH); |
455 | dc.DrawRectangle( x, y, (smallRectangleSize.x + (2*deltaX)), (smallRectangleSize.y + (2*deltaY))); | |
456 | } | |
c801d85f KB |
457 | } |
458 | ||
459 | void wxGenericColourDialog::PaintCustomColour(wxDC& dc) | |
460 | { | |
c801d85f KB |
461 | dc.SetPen(*wxBLACK_PEN); |
462 | ||
984b0d8b | 463 | wxBrush *brush = new wxBrush(colourData.m_dataColour, wxSOLID); |
c801d85f KB |
464 | dc.SetBrush(*brush); |
465 | ||
466 | dc.DrawRectangle( singleCustomColourRect.x, singleCustomColourRect.y, | |
467 | customRectangleSize.x, customRectangleSize.y); | |
468 | ||
469 | dc.SetBrush(wxNullBrush); | |
470 | delete brush; | |
c801d85f KB |
471 | } |
472 | ||
473 | void wxGenericColourDialog::OnBasicColourClick(int which) | |
474 | { | |
ca65c044 | 475 | wxClientDC dc(this); |
c801d85f | 476 | |
ca65c044 WS |
477 | PaintHighlight(dc, false); |
478 | whichKind = 1; | |
479 | colourSelection = which; | |
2997ca30 | 480 | |
6bb44116 | 481 | #if wxUSE_SLIDER |
ca65c044 | 482 | redSlider->SetValue( standardColours[colourSelection].Red() ); |
ea8a9699 VZ |
483 | greenSlider->SetValue( standardColours[colourSelection].Green() ); |
484 | blueSlider->SetValue( standardColours[colourSelection].Blue() ); | |
6bb44116 | 485 | #endif // wxUSE_SLIDER |
2997ca30 WS |
486 | |
487 | colourData.m_dataColour.Set(standardColours[colourSelection].Red(), | |
488 | standardColours[colourSelection].Green(), | |
984b0d8b | 489 | standardColours[colourSelection].Blue()); |
c801d85f | 490 | |
ca65c044 WS |
491 | PaintCustomColour(dc); |
492 | PaintHighlight(dc, true); | |
c801d85f KB |
493 | } |
494 | ||
495 | void wxGenericColourDialog::OnCustomColourClick(int which) | |
496 | { | |
ca65c044 WS |
497 | wxClientDC dc(this); |
498 | PaintHighlight(dc, false); | |
499 | whichKind = 2; | |
500 | colourSelection = which; | |
2997ca30 | 501 | |
6bb44116 | 502 | #if wxUSE_SLIDER |
ca65c044 | 503 | redSlider->SetValue( customColours[colourSelection].Red() ); |
ea8a9699 VZ |
504 | greenSlider->SetValue( customColours[colourSelection].Green() ); |
505 | blueSlider->SetValue( customColours[colourSelection].Blue() ); | |
6bb44116 | 506 | #endif // wxUSE_SLIDER |
2997ca30 WS |
507 | |
508 | colourData.m_dataColour.Set(customColours[colourSelection].Red(), | |
509 | customColours[colourSelection].Green(), | |
984b0d8b | 510 | customColours[colourSelection].Blue()); |
2997ca30 | 511 | |
ca65c044 WS |
512 | PaintCustomColour(dc); |
513 | PaintHighlight(dc, true); | |
c801d85f KB |
514 | } |
515 | ||
516 | /* | |
517 | void wxGenericColourDialog::OnOk(void) | |
518 | { | |
ca65c044 | 519 | Show(false); |
c801d85f KB |
520 | } |
521 | ||
522 | void wxGenericColourDialog::OnCancel(void) | |
523 | { | |
ca65c044 WS |
524 | colourDialogCancelled = true; |
525 | Show(false); | |
c801d85f KB |
526 | } |
527 | */ | |
528 | ||
529 | void wxGenericColourDialog::OnAddCustom(wxCommandEvent& WXUNUSED(event)) | |
530 | { | |
531 | wxClientDC dc(this); | |
532 | if (whichKind != 2) | |
533 | { | |
ca65c044 | 534 | PaintHighlight(dc, false); |
c801d85f KB |
535 | whichKind = 2; |
536 | colourSelection = 0; | |
ca65c044 | 537 | PaintHighlight(dc, true); |
c801d85f KB |
538 | } |
539 | ||
2997ca30 WS |
540 | customColours[colourSelection].Set(colourData.m_dataColour.Red(), |
541 | colourData.m_dataColour.Green(), | |
984b0d8b | 542 | colourData.m_dataColour.Blue()); |
2997ca30 | 543 | |
c801d85f | 544 | colourData.SetCustomColour(colourSelection, customColours[colourSelection]); |
c35414db | 545 | |
c801d85f KB |
546 | PaintCustomColours(dc); |
547 | } | |
548 | ||
6bb44116 WS |
549 | #if wxUSE_SLIDER |
550 | ||
c801d85f KB |
551 | void wxGenericColourDialog::OnRedSlider(wxCommandEvent& WXUNUSED(event)) |
552 | { | |
553 | if (!redSlider) | |
554 | return; | |
c35414db | 555 | |
c801d85f | 556 | wxClientDC dc(this); |
984b0d8b | 557 | colourData.m_dataColour.Set((unsigned char)redSlider->GetValue(), colourData.m_dataColour.Green(), colourData.m_dataColour.Blue()); |
c801d85f KB |
558 | PaintCustomColour(dc); |
559 | } | |
560 | ||
561 | void wxGenericColourDialog::OnGreenSlider(wxCommandEvent& WXUNUSED(event)) | |
562 | { | |
563 | if (!greenSlider) | |
564 | return; | |
565 | ||
566 | wxClientDC dc(this); | |
984b0d8b | 567 | colourData.m_dataColour.Set(colourData.m_dataColour.Red(), (unsigned char)greenSlider->GetValue(), colourData.m_dataColour.Blue()); |
c801d85f KB |
568 | PaintCustomColour(dc); |
569 | } | |
570 | ||
571 | void wxGenericColourDialog::OnBlueSlider(wxCommandEvent& WXUNUSED(event)) | |
572 | { | |
573 | if (!blueSlider) | |
574 | return; | |
575 | ||
576 | wxClientDC dc(this); | |
984b0d8b | 577 | colourData.m_dataColour.Set(colourData.m_dataColour.Red(), colourData.m_dataColour.Green(), (unsigned char)blueSlider->GetValue()); |
c801d85f KB |
578 | PaintCustomColour(dc); |
579 | } | |
580 | ||
6bb44116 WS |
581 | #endif // wxUSE_SLIDER |
582 | ||
a2b99ff5 | 583 | #endif // wxUSE_COLOURDLG && !defined(__WXGTK20__) |