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