]>
Commit | Line | Data |
---|---|---|
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 | |
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" |
f4da9a94 | 31 | #include "wx/slider.h" |
4130b487 RR |
32 | #endif |
33 | ||
34 | #if wxUSE_STATLINE | |
35 | #include "wx/statline.h" | |
c801d85f KB |
36 | #endif |
37 | ||
38 | #include "wx/generic/colrdlgg.h" | |
39 | ||
c801d85f KB |
40 | IMPLEMENT_DYNAMIC_CLASS(wxGenericColourDialog, wxDialog) |
41 | ||
42 | BEGIN_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 |
52 | END_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 | |
61 | static const wxChar *wxColourDialogNames[] = | |
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 | 118 | wxGenericColourDialog::wxGenericColourDialog() |
c801d85f | 119 | { |
f4da9a94 WS |
120 | dialogParent = NULL; |
121 | whichKind = 1; | |
122 | colourSelection = -1; | |
c801d85f KB |
123 | } |
124 | ||
f6bcfd97 BP |
125 | wxGenericColourDialog::wxGenericColourDialog(wxWindow *parent, |
126 | wxColourData *data) | |
c801d85f | 127 | { |
f4da9a94 WS |
128 | whichKind = 1; |
129 | colourSelection = -1; | |
130 | Create(parent, data); | |
c801d85f KB |
131 | } |
132 | ||
4130b487 | 133 | wxGenericColourDialog::~wxGenericColourDialog() |
c801d85f KB |
134 | { |
135 | } | |
136 | ||
74e3313b | 137 | void wxGenericColourDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) |
c801d85f | 138 | { |
f4da9a94 | 139 | EndModal(wxID_CANCEL); |
c801d85f KB |
140 | } |
141 | ||
142 | bool wxGenericColourDialog::Create(wxWindow *parent, wxColourData *data) | |
143 | { | |
ca65c044 | 144 | if ( !wxDialog::Create(parent, wxID_ANY, _("Choose colour"), |
c47addef | 145 | wxPoint(0,0), wxSize(900, 900)) ) |
ca65c044 | 146 | return false; |
c35414db | 147 | |
f6bcfd97 | 148 | dialogParent = parent; |
c801d85f | 149 | |
f6bcfd97 BP |
150 | if (data) |
151 | colourData = *data; | |
c35414db | 152 | |
f6bcfd97 BP |
153 | InitializeColours(); |
154 | CalculateMeasurements(); | |
155 | CreateWidgets(); | |
156 | ||
ca65c044 | 157 | return true; |
c801d85f KB |
158 | } |
159 | ||
4130b487 | 160 | int wxGenericColourDialog::ShowModal() |
c801d85f | 161 | { |
f4da9a94 | 162 | return wxDialog::ShowModal(); |
c801d85f KB |
163 | } |
164 | ||
165 | ||
166 | // Internal functions | |
167 | void wxGenericColourDialog::OnMouseEvent(wxMouseEvent& event) | |
168 | { | |
169 | if (event.ButtonDown(1)) | |
170 | { | |
171 | int x = (int)event.GetX(); | |
172 | int y = (int)event.GetY(); | |
173 | ||
b1f9d7bf DW |
174 | #ifdef __WXPM__ |
175 | // Handle OS/2's reverse coordinate system and account for the dialog title | |
176 | int nClientHeight; | |
177 | ||
178 | GetClientSize(NULL, &nClientHeight); | |
179 | y = (nClientHeight - y) + 20; | |
180 | #endif | |
c801d85f KB |
181 | if ((x >= standardColoursRect.x && x <= (standardColoursRect.x + standardColoursRect.width)) && |
182 | (y >= standardColoursRect.y && y <= (standardColoursRect.y + standardColoursRect.height))) | |
183 | { | |
184 | int selX = (int)(x - standardColoursRect.x)/(smallRectangleSize.x + gridSpacing); | |
185 | int selY = (int)(y - standardColoursRect.y)/(smallRectangleSize.y + gridSpacing); | |
186 | int ptr = (int)(selX + selY*8); | |
187 | OnBasicColourClick(ptr); | |
188 | } | |
189 | else if ((x >= customColoursRect.x && x <= (customColoursRect.x + customColoursRect.width)) && | |
190 | (y >= customColoursRect.y && y <= (customColoursRect.y + customColoursRect.height))) | |
191 | { | |
192 | int selX = (int)(x - customColoursRect.x)/(smallRectangleSize.x + gridSpacing); | |
193 | int selY = (int)(y - customColoursRect.y)/(smallRectangleSize.y + gridSpacing); | |
194 | int ptr = (int)(selX + selY*8); | |
195 | OnCustomColourClick(ptr); | |
196 | } | |
c10920de VS |
197 | else |
198 | event.Skip(); | |
c801d85f | 199 | } |
c10920de VS |
200 | else |
201 | event.Skip(); | |
c801d85f KB |
202 | } |
203 | ||
204 | void wxGenericColourDialog::OnPaint(wxPaintEvent& event) | |
205 | { | |
1bf38b0e | 206 | #if !defined(__WXMOTIF__) && !defined(__WXPM__) && !defined(__WXCOCOA__) |
7a893a31 WS |
207 | wxDialog::OnPaint(event); |
208 | #else | |
209 | wxUnusedVar(event); | |
d75638f8 | 210 | #endif |
c801d85f | 211 | |
7a893a31 | 212 | wxPaintDC dc(this); |
c801d85f | 213 | |
7a893a31 WS |
214 | PaintBasicColours(dc); |
215 | PaintCustomColours(dc); | |
216 | PaintCustomColour(dc); | |
217 | PaintHighlight(dc, true); | |
c801d85f KB |
218 | } |
219 | ||
4130b487 | 220 | void wxGenericColourDialog::CalculateMeasurements() |
c801d85f | 221 | { |
f4da9a94 WS |
222 | smallRectangleSize.x = 18; |
223 | smallRectangleSize.y = 14; | |
224 | customRectangleSize.x = 40; | |
225 | customRectangleSize.y = 40; | |
c801d85f | 226 | |
f4da9a94 WS |
227 | gridSpacing = 6; |
228 | sectionSpacing = 15; | |
c801d85f | 229 | |
f4da9a94 | 230 | standardColoursRect.x = 10; |
b1f9d7bf | 231 | #ifdef __WXPM__ |
f4da9a94 | 232 | standardColoursRect.y = 15 + 20; /* OS/2 needs to account for dialog titlebar */ |
b1f9d7bf | 233 | #else |
f4da9a94 | 234 | standardColoursRect.y = 15; |
b1f9d7bf | 235 | #endif |
f4da9a94 WS |
236 | standardColoursRect.width = (8*smallRectangleSize.x) + (7*gridSpacing); |
237 | standardColoursRect.height = (6*smallRectangleSize.y) + (5*gridSpacing); | |
238 | ||
239 | customColoursRect.x = standardColoursRect.x; | |
240 | customColoursRect.y = standardColoursRect.y + standardColoursRect.height + 20; | |
241 | customColoursRect.width = (8*smallRectangleSize.x) + (7*gridSpacing); | |
242 | customColoursRect.height = (2*smallRectangleSize.y) + (1*gridSpacing); | |
243 | ||
244 | singleCustomColourRect.x = customColoursRect.width + customColoursRect.x + sectionSpacing; | |
245 | singleCustomColourRect.y = 80; | |
246 | singleCustomColourRect.width = customRectangleSize.x; | |
247 | singleCustomColourRect.height = customRectangleSize.y; | |
248 | ||
249 | okButtonX = 10; | |
250 | customButtonX = singleCustomColourRect.x ; | |
251 | buttonY = customColoursRect.y + customColoursRect.height + 10; | |
c801d85f KB |
252 | } |
253 | ||
4130b487 | 254 | void wxGenericColourDialog::CreateWidgets() |
c801d85f | 255 | { |
4130b487 | 256 | wxBeginBusyCursor(); |
c801d85f | 257 | |
6bb44116 WS |
258 | wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); |
259 | ||
f79a46f8 | 260 | const int sliderHeight = 160; |
4130b487 | 261 | |
6bb44116 WS |
262 | #if wxUSE_SLIDER |
263 | const int sliderX = singleCustomColourRect.x + singleCustomColourRect.width + sectionSpacing; | |
264 | ||
984b0d8b | 265 | redSlider = new wxSlider(this, wxID_RED_SLIDER, colourData.m_dataColour.Red(), 0, 255, |
a3b8b891 | 266 | wxDefaultPosition, wxSize(wxDefaultCoord, sliderHeight), wxSL_VERTICAL|wxSL_LABELS|wxSL_INVERSE); |
984b0d8b | 267 | greenSlider = new wxSlider(this, wxID_GREEN_SLIDER, colourData.m_dataColour.Green(), 0, 255, |
a3b8b891 | 268 | wxDefaultPosition, wxSize(wxDefaultCoord, sliderHeight), wxSL_VERTICAL|wxSL_LABELS|wxSL_INVERSE); |
984b0d8b | 269 | blueSlider = new wxSlider(this, wxID_BLUE_SLIDER, colourData.m_dataColour.Blue(), 0, 255, |
a3b8b891 | 270 | wxDefaultPosition, wxSize(wxDefaultCoord, sliderHeight), wxSL_VERTICAL|wxSL_LABELS|wxSL_INVERSE); |
f79a46f8 WS |
271 | |
272 | wxBoxSizer *sliderSizer = new wxBoxSizer( wxHORIZONTAL ); | |
273 | ||
274 | // 1) space for sliders | |
275 | sliderSizer->Add( sliderX, sliderHeight ); | |
276 | sliderSizer->Add( redSlider, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 10 ); | |
277 | sliderSizer->Add( greenSlider, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 10 ); | |
278 | sliderSizer->Add( blueSlider, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 10 ); | |
4130b487 | 279 | |
f79a46f8 | 280 | topSizer->Add( sliderSizer, 0, wxCENTRE | wxALL, 10 ); |
6bb44116 WS |
281 | #else |
282 | topSizer->Add( 1, sliderHeight, 0, wxCENTRE | wxALL, 15 ); | |
283 | #endif // wxUSE_SLIDER | |
6c34d0ed | 284 | |
4130b487 RR |
285 | #if wxUSE_STATLINE |
286 | // 2) static line | |
f79a46f8 | 287 | topSizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); |
c801d85f | 288 | #endif |
c35414db | 289 | |
4130b487 RR |
290 | // 3) buttons |
291 | wxSizer *buttonsizer = CreateButtonSizer( wxOK|wxCANCEL ); | |
292 | buttonsizer->Add( new wxButton(this, wxID_ADD_CUSTOM, _("Add to custom colours") ), 0, wxLEFT|wxRIGHT, 10 ); | |
acf2ac37 | 293 | topSizer->Add( buttonsizer, 0, wxEXPAND | wxALL, 10 ); |
c801d85f | 294 | |
ca65c044 | 295 | SetAutoLayout( true ); |
f79a46f8 | 296 | SetSizer( topSizer ); |
6c34d0ed | 297 | |
f79a46f8 WS |
298 | topSizer->SetSizeHints( this ); |
299 | topSizer->Fit( this ); | |
c801d85f | 300 | |
4130b487 | 301 | Centre( wxBOTH ); |
c801d85f | 302 | |
4130b487 | 303 | wxEndBusyCursor(); |
c801d85f KB |
304 | } |
305 | ||
306 | void wxGenericColourDialog::InitializeColours(void) | |
307 | { | |
a4ba2eec | 308 | size_t i; |
ea8a9699 | 309 | |
61138de0 | 310 | for (i = 0; i < WXSIZEOF(wxColourDialogNames); i++) |
ea8a9699 | 311 | { |
564a150b VZ |
312 | wxColour col = wxTheColourDatabase->Find(wxColourDialogNames[i]); |
313 | if (col.Ok()) | |
314 | standardColours[i].Set(col.Red(), col.Green(), col.Blue()); | |
ea8a9699 VZ |
315 | else |
316 | standardColours[i].Set(0, 0, 0); | |
317 | } | |
c801d85f | 318 | |
564a150b | 319 | for (i = 0; i < WXSIZEOF(customColours); i++) |
ea8a9699 | 320 | { |
a2b99ff5 VS |
321 | wxColour c = colourData.GetCustomColour(i); |
322 | if (c.Ok()) | |
323 | customColours[i] = colourData.GetCustomColour(i); | |
324 | else | |
325 | customColours[i] = wxColour(255, 255, 255); | |
ea8a9699 | 326 | } |
c801d85f | 327 | |
ea8a9699 VZ |
328 | wxColour curr = colourData.GetColour(); |
329 | if ( curr.Ok() ) | |
330 | { | |
ca65c044 | 331 | bool initColourFound = false; |
ea8a9699 | 332 | |
61138de0 | 333 | for (i = 0; i < WXSIZEOF(wxColourDialogNames); i++) |
ea8a9699 VZ |
334 | { |
335 | if ( standardColours[i] == curr && !initColourFound ) | |
336 | { | |
337 | whichKind = 1; | |
338 | colourSelection = i; | |
ca65c044 | 339 | initColourFound = true; |
ea8a9699 VZ |
340 | break; |
341 | } | |
342 | } | |
343 | if ( !initColourFound ) | |
344 | { | |
564a150b | 345 | for ( i = 0; i < WXSIZEOF(customColours); i++ ) |
ea8a9699 VZ |
346 | { |
347 | if ( customColours[i] == curr ) | |
348 | { | |
349 | whichKind = 2; | |
350 | colourSelection = i; | |
ea8a9699 VZ |
351 | break; |
352 | } | |
353 | } | |
354 | } | |
984b0d8b | 355 | colourData.m_dataColour.Set( curr.Red(), curr.Green(), curr.Blue() ); |
ea8a9699 VZ |
356 | } |
357 | else | |
358 | { | |
359 | whichKind = 1; | |
360 | colourSelection = 0; | |
984b0d8b | 361 | colourData.m_dataColour.Set( 0, 0, 0 ); |
ea8a9699 | 362 | } |
c801d85f KB |
363 | } |
364 | ||
365 | void wxGenericColourDialog::PaintBasicColours(wxDC& dc) | |
366 | { | |
f4da9a94 WS |
367 | int i; |
368 | for (i = 0; i < 6; i++) | |
c801d85f | 369 | { |
f4da9a94 WS |
370 | int j; |
371 | for (j = 0; j < 8; j++) | |
372 | { | |
373 | int ptr = i*8 + j; | |
c35414db | 374 | |
f4da9a94 WS |
375 | int x = (j*(smallRectangleSize.x+gridSpacing) + standardColoursRect.x); |
376 | int y = (i*(smallRectangleSize.y+gridSpacing) + standardColoursRect.y); | |
c801d85f | 377 | |
f4da9a94 WS |
378 | dc.SetPen(*wxBLACK_PEN); |
379 | wxBrush brush(standardColours[ptr], wxSOLID); | |
380 | dc.SetBrush(brush); | |
c801d85f | 381 | |
f4da9a94 WS |
382 | dc.DrawRectangle( x, y, smallRectangleSize.x, smallRectangleSize.y); |
383 | } | |
c801d85f | 384 | } |
c801d85f KB |
385 | } |
386 | ||
387 | void wxGenericColourDialog::PaintCustomColours(wxDC& dc) | |
388 | { | |
c801d85f KB |
389 | int i; |
390 | for (i = 0; i < 2; i++) | |
391 | { | |
392 | int j; | |
393 | for (j = 0; j < 8; j++) | |
394 | { | |
395 | int ptr = i*8 + j; | |
c35414db | 396 | |
c801d85f KB |
397 | int x = (j*(smallRectangleSize.x+gridSpacing)) + customColoursRect.x; |
398 | int y = (i*(smallRectangleSize.y+gridSpacing)) + customColoursRect.y; | |
399 | ||
400 | dc.SetPen(*wxBLACK_PEN); | |
401 | ||
402 | wxBrush brush(customColours[ptr], wxSOLID); | |
403 | dc.SetBrush(brush); | |
404 | ||
405 | dc.DrawRectangle( x, y, smallRectangleSize.x, smallRectangleSize.y); | |
406 | } | |
407 | } | |
c801d85f KB |
408 | } |
409 | ||
410 | void wxGenericColourDialog::PaintHighlight(wxDC& dc, bool draw) | |
411 | { | |
ea8a9699 VZ |
412 | if ( colourSelection < 0 ) |
413 | return; | |
414 | ||
c801d85f KB |
415 | // Number of pixels bigger than the standard rectangle size |
416 | // for drawing a highlight | |
417 | int deltaX = 2; | |
418 | int deltaY = 2; | |
419 | ||
420 | if (whichKind == 1) | |
421 | { | |
422 | // Standard colours | |
423 | int y = (int)(colourSelection / 8); | |
424 | int x = (int)(colourSelection - (y*8)); | |
425 | ||
426 | x = (x*(smallRectangleSize.x + gridSpacing) + standardColoursRect.x) - deltaX; | |
427 | y = (y*(smallRectangleSize.y + gridSpacing) + standardColoursRect.y) - deltaY; | |
428 | ||
429 | if (draw) | |
430 | dc.SetPen(*wxBLACK_PEN); | |
431 | else | |
432 | dc.SetPen(*wxLIGHT_GREY_PEN); | |
433 | ||
434 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | |
435 | dc.DrawRectangle( x, y, (smallRectangleSize.x + (2*deltaX)), (smallRectangleSize.y + (2*deltaY))); | |
436 | } | |
437 | else | |
438 | { | |
439 | // User-defined colours | |
440 | int y = (int)(colourSelection / 8); | |
441 | int x = (int)(colourSelection - (y*8)); | |
442 | ||
443 | x = (x*(smallRectangleSize.x + gridSpacing) + customColoursRect.x) - deltaX; | |
444 | y = (y*(smallRectangleSize.y + gridSpacing) + customColoursRect.y) - deltaY; | |
445 | ||
446 | if (draw) | |
447 | dc.SetPen(*wxBLACK_PEN); | |
448 | else | |
449 | dc.SetPen(*wxLIGHT_GREY_PEN); | |
c35414db | 450 | |
c801d85f KB |
451 | dc.SetBrush(*wxTRANSPARENT_BRUSH); |
452 | dc.DrawRectangle( x, y, (smallRectangleSize.x + (2*deltaX)), (smallRectangleSize.y + (2*deltaY))); | |
453 | } | |
c801d85f KB |
454 | } |
455 | ||
456 | void wxGenericColourDialog::PaintCustomColour(wxDC& dc) | |
457 | { | |
f4da9a94 | 458 | dc.SetPen(*wxBLACK_PEN); |
c801d85f | 459 | |
f4da9a94 WS |
460 | wxBrush *brush = new wxBrush(colourData.m_dataColour, wxSOLID); |
461 | dc.SetBrush(*brush); | |
c801d85f | 462 | |
f4da9a94 WS |
463 | dc.DrawRectangle( singleCustomColourRect.x, singleCustomColourRect.y, |
464 | customRectangleSize.x, customRectangleSize.y); | |
c801d85f | 465 | |
f4da9a94 WS |
466 | dc.SetBrush(wxNullBrush); |
467 | delete brush; | |
c801d85f KB |
468 | } |
469 | ||
470 | void wxGenericColourDialog::OnBasicColourClick(int which) | |
471 | { | |
ca65c044 | 472 | wxClientDC dc(this); |
c801d85f | 473 | |
ca65c044 WS |
474 | PaintHighlight(dc, false); |
475 | whichKind = 1; | |
476 | colourSelection = which; | |
2997ca30 | 477 | |
6bb44116 | 478 | #if wxUSE_SLIDER |
ca65c044 | 479 | redSlider->SetValue( standardColours[colourSelection].Red() ); |
ea8a9699 VZ |
480 | greenSlider->SetValue( standardColours[colourSelection].Green() ); |
481 | blueSlider->SetValue( standardColours[colourSelection].Blue() ); | |
6bb44116 | 482 | #endif // wxUSE_SLIDER |
2997ca30 WS |
483 | |
484 | colourData.m_dataColour.Set(standardColours[colourSelection].Red(), | |
485 | standardColours[colourSelection].Green(), | |
984b0d8b | 486 | standardColours[colourSelection].Blue()); |
c801d85f | 487 | |
ca65c044 WS |
488 | PaintCustomColour(dc); |
489 | PaintHighlight(dc, true); | |
c801d85f KB |
490 | } |
491 | ||
492 | void wxGenericColourDialog::OnCustomColourClick(int which) | |
493 | { | |
ca65c044 WS |
494 | wxClientDC dc(this); |
495 | PaintHighlight(dc, false); | |
496 | whichKind = 2; | |
497 | colourSelection = which; | |
2997ca30 | 498 | |
6bb44116 | 499 | #if wxUSE_SLIDER |
ca65c044 | 500 | redSlider->SetValue( customColours[colourSelection].Red() ); |
ea8a9699 VZ |
501 | greenSlider->SetValue( customColours[colourSelection].Green() ); |
502 | blueSlider->SetValue( customColours[colourSelection].Blue() ); | |
6bb44116 | 503 | #endif // wxUSE_SLIDER |
2997ca30 WS |
504 | |
505 | colourData.m_dataColour.Set(customColours[colourSelection].Red(), | |
506 | customColours[colourSelection].Green(), | |
984b0d8b | 507 | customColours[colourSelection].Blue()); |
2997ca30 | 508 | |
ca65c044 WS |
509 | PaintCustomColour(dc); |
510 | PaintHighlight(dc, true); | |
c801d85f KB |
511 | } |
512 | ||
513 | /* | |
514 | void wxGenericColourDialog::OnOk(void) | |
515 | { | |
ca65c044 | 516 | Show(false); |
c801d85f KB |
517 | } |
518 | ||
519 | void wxGenericColourDialog::OnCancel(void) | |
520 | { | |
ca65c044 WS |
521 | colourDialogCancelled = true; |
522 | Show(false); | |
c801d85f KB |
523 | } |
524 | */ | |
525 | ||
526 | void wxGenericColourDialog::OnAddCustom(wxCommandEvent& WXUNUSED(event)) | |
527 | { | |
528 | wxClientDC dc(this); | |
529 | if (whichKind != 2) | |
530 | { | |
ca65c044 | 531 | PaintHighlight(dc, false); |
c801d85f KB |
532 | whichKind = 2; |
533 | colourSelection = 0; | |
ca65c044 | 534 | PaintHighlight(dc, true); |
c801d85f KB |
535 | } |
536 | ||
2997ca30 WS |
537 | customColours[colourSelection].Set(colourData.m_dataColour.Red(), |
538 | colourData.m_dataColour.Green(), | |
984b0d8b | 539 | colourData.m_dataColour.Blue()); |
2997ca30 | 540 | |
c801d85f | 541 | colourData.SetCustomColour(colourSelection, customColours[colourSelection]); |
c35414db | 542 | |
c801d85f KB |
543 | PaintCustomColours(dc); |
544 | } | |
545 | ||
6bb44116 WS |
546 | #if wxUSE_SLIDER |
547 | ||
c801d85f KB |
548 | void wxGenericColourDialog::OnRedSlider(wxCommandEvent& WXUNUSED(event)) |
549 | { | |
550 | if (!redSlider) | |
551 | return; | |
c35414db | 552 | |
c801d85f | 553 | wxClientDC dc(this); |
984b0d8b | 554 | colourData.m_dataColour.Set((unsigned char)redSlider->GetValue(), colourData.m_dataColour.Green(), colourData.m_dataColour.Blue()); |
c801d85f KB |
555 | PaintCustomColour(dc); |
556 | } | |
557 | ||
558 | void wxGenericColourDialog::OnGreenSlider(wxCommandEvent& WXUNUSED(event)) | |
559 | { | |
560 | if (!greenSlider) | |
561 | return; | |
562 | ||
563 | wxClientDC dc(this); | |
984b0d8b | 564 | colourData.m_dataColour.Set(colourData.m_dataColour.Red(), (unsigned char)greenSlider->GetValue(), colourData.m_dataColour.Blue()); |
c801d85f KB |
565 | PaintCustomColour(dc); |
566 | } | |
567 | ||
568 | void wxGenericColourDialog::OnBlueSlider(wxCommandEvent& WXUNUSED(event)) | |
569 | { | |
570 | if (!blueSlider) | |
571 | return; | |
572 | ||
573 | wxClientDC dc(this); | |
984b0d8b | 574 | colourData.m_dataColour.Set(colourData.m_dataColour.Red(), colourData.m_dataColour.Green(), (unsigned char)blueSlider->GetValue()); |
c801d85f KB |
575 | PaintCustomColour(dc); |
576 | } | |
577 | ||
6bb44116 WS |
578 | #endif // wxUSE_SLIDER |
579 | ||
a2b99ff5 | 580 | #endif // wxUSE_COLOURDLG && !defined(__WXGTK20__) |