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