1 /*
2 Copyright (C) 2018-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5
6 /*
7 WARNING: This file was generated by the dkct program (see
8 http://dktools.sourceforge.net/ for details).
9 Changes you make here will be lost if dkct is run again!
10 You should modify the original source and run dkct on it.
11 Original source: Dk4WxColourPalette.wxc
12 */
13
14 /** @file Dk4WxColourPalette.cpp The Dk4WxColourPalette module.
15 */
16
17
18 #include <libdk4wx/Dk4WxColourPalette.h>
19
20 #ifndef WX_CONFIG_H_INCLUDED
21 #include <wx/config.h>
22 #define WX_CONFIG_H_INCLUDED 1
23 #endif
24
25 #ifndef WX_ARRSTR_H_INCLUDED
26 #include <wx/arrstr.h>
27 #define WX_ARRSTR_H_INCLUDED 1
28 #endif
29
30 #ifndef WX_DCBUFFER_H_INCLUDED
31 #include <wx/dcbuffer.h>
32 #define WX_DCBUFFER_H_INCLUDED 1
33 #endif
34
35
36
37
38
39
40
41 /** HTML named color type.
42 */
43 typedef struct {
44 const wxChar *name; /**< Color name. */
45 unsigned long rgb; /**< 16*R+8*G+B. */
46 } html_color_t;
47
48
49
50 /** The named HTML colors.
51 */
52 static const html_color_t html_colors[] = {
53 { wxT("AliceBlue"), 0xF0F8FFUL },
54 { wxT("AntiqueWhite"), 0xFAEBD7UL },
55 { wxT("Aqua"), 0x00FFFFUL },
56 { wxT("Aquamarine"), 0x7FFFD4UL },
57 { wxT("Azure"), 0xF0FFFFUL },
58 { wxT("Beige"), 0xF5F5DCUL },
59 { wxT("Bisque"), 0xFFE4C4UL },
60 { wxT("Black"), 0x000000UL },
61 { wxT("BlanchedAlmond"), 0xFFEBCDUL },
62 { wxT("Blue"), 0x0000FFUL },
63 { wxT("BlueViolet"), 0x8A2BE2UL },
64 { wxT("Brown"), 0xA52A2AUL },
65 { wxT("BurlyWood"), 0xDEB887UL },
66 { wxT("CadetBlue"), 0x5F9EA0UL },
67 { wxT("Chartreuse"), 0x7FFF00UL },
68 { wxT("Chocolate"), 0xD2691EUL },
69 { wxT("Coral"), 0xFF7F50UL },
70 { wxT("CornflowerBlue"), 0x6495EDUL },
71 { wxT("Cornsilk"), 0xFFF8DCUL },
72 { wxT("Crimson"), 0xDC143CUL },
73 { wxT("Cyan"), 0x00FFFFUL },
74 { wxT("DarkBlue"), 0x00008BUL },
75 { wxT("DarkCyan"), 0x008B8BUL },
76 { wxT("DarkGoldenRod"), 0xB8860BUL },
77 { wxT("DarkGray"), 0xA9A9A9UL },
78 { wxT("DarkGrey"), 0xA9A9A9UL },
79 { wxT("DarkGreen"), 0x006400UL },
80 { wxT("DarkKhaki"), 0xBDB76BUL },
81 { wxT("DarkMagenta"), 0x8B008BUL },
82 { wxT("DarkOliveGreen"), 0x556B2FUL },
83 { wxT("DarkOrange"), 0xFF8C00UL },
84 { wxT("DarkOrchid"), 0x9932CCUL },
85 { wxT("DarkRed"), 0x8B0000UL },
86 { wxT("DarkSalmon"), 0xE9967AUL },
87 { wxT("DarkSeaGreen"), 0x8FBC8FUL },
88 { wxT("DarkSlateBlue"), 0x483D8BUL },
89 { wxT("DarkSlateGray"), 0x2F4F4FUL },
90 { wxT("DarkSlateGrey"), 0x2F4F4FUL },
91 { wxT("DarkTurquoise"), 0x00CED1UL },
92 { wxT("DarkViolet"), 0x9400D3UL },
93 { wxT("DeepPink"), 0xFF1493UL },
94 { wxT("DeepSkyBlue"), 0x00BFFFUL },
95 { wxT("DimGray"), 0x696969UL },
96 { wxT("DimGrey"), 0x696969UL },
97 { wxT("DodgerBlue"), 0x1E90FFUL },
98 { wxT("FireBrick"), 0xB22222UL },
99 { wxT("FloralWhite"), 0xFFFAF0UL },
100 { wxT("ForestGreen"), 0x228B22UL },
101 { wxT("Fuchsia"), 0xFF00FFUL },
102 { wxT("Gainsboro"), 0xDCDCDCUL },
103 { wxT("GhostWhite"), 0xF8F8FFUL },
104 { wxT("Gold"), 0xFFD700UL },
105 { wxT("GoldenRod"), 0xDAA520UL },
106 { wxT("Gray"), 0x808080UL },
107 { wxT("Grey"), 0x808080UL },
108 { wxT("Green"), 0x008000UL },
109 { wxT("GreenYellow"), 0xADFF2FUL },
110 { wxT("HoneyDew"), 0xF0FFF0UL },
111 { wxT("HotPink"), 0xFF69B4UL },
112 { wxT("IndianRed"), 0xCD5C5CUL },
113 { wxT("Indigo"), 0x4B0082UL },
114 { wxT("Ivory"), 0xFFFFF0UL },
115 { wxT("Khaki"), 0xF0E68CUL },
116 { wxT("Lavender"), 0xE6E6FAUL },
117 { wxT("LavenderBlush"), 0xFFF0F5UL },
118 { wxT("LawnGreen"), 0x7CFC00UL },
119 { wxT("LemonChiffon"), 0xFFFACDUL },
120 { wxT("LightBlue"), 0xADD8E6UL },
121 { wxT("LightCoral"), 0xF08080UL },
122 { wxT("LightCyan"), 0xE0FFFFUL },
123 { wxT("LightGoldenRodYellow"), 0xFAFAD2UL },
124 { wxT("LightGray"), 0xD3D3D3UL },
125 { wxT("LightGrey"), 0xD3D3D3UL },
126 { wxT("LightGreen"), 0x90EE90UL },
127 { wxT("LightPink"), 0xFFB6C1UL },
128 { wxT("LightSalmon"), 0xFFA07AUL },
129 { wxT("LightSeaGreen"), 0x20B2AAUL },
130 { wxT("LightSkyBlue"), 0x87CEFAUL },
131 { wxT("LightSlateGray"), 0x778899UL },
132 { wxT("LightSlateGrey"), 0x778899UL },
133 { wxT("LightSteelBlue"), 0xB0C4DEUL },
134 { wxT("LightYellow"), 0xFFFFE0UL },
135 { wxT("Lime"), 0x00FF00UL },
136 { wxT("LimeGreen"), 0x32CD32UL },
137 { wxT("Linen"), 0xFAF0E6UL },
138 { wxT("Magenta"), 0xFF00FFUL },
139 { wxT("Maroon"), 0x800000UL },
140 { wxT("MediumAquaMarine"), 0x66CDAAUL },
141 { wxT("MediumBlue"), 0x0000CDUL },
142 { wxT("MediumOrchid"), 0xBA55D3UL },
143 { wxT("MediumPurple"), 0x9370DBUL },
144 { wxT("MediumSeaGreen"), 0x3CB371UL },
145 { wxT("MediumSlateBlue"), 0x7B68EEUL },
146 { wxT("MediumSpringGreen"), 0x00FA9AUL },
147 { wxT("MediumTurquoise"), 0x48D1CCUL },
148 { wxT("MediumVioletRed"), 0xC71585UL },
149 { wxT("MidnightBlue"), 0x191970UL },
150 { wxT("MintCream"), 0xF5FFFAUL },
151 { wxT("MistyRose"), 0xFFE4E1UL },
152 { wxT("Moccasin"), 0xFFE4B5UL },
153 { wxT("NavajoWhite"), 0xFFDEADUL },
154 { wxT("Navy"), 0x000080UL },
155 { wxT("OldLace"), 0xFDF5E6UL },
156 { wxT("Olive"), 0x808000UL },
157 { wxT("OliveDrab"), 0x6B8E23UL },
158 { wxT("Orange"), 0xFFA500UL },
159 { wxT("OrangeRed"), 0xFF4500UL },
160 { wxT("Orchid"), 0xDA70D6UL },
161 { wxT("PaleGoldenRod"), 0xEEE8AAUL },
162 { wxT("PaleGreen"), 0x98FB98UL },
163 { wxT("PaleTurquoise"), 0xAFEEEEUL },
164 { wxT("PaleVioletRed"), 0xDB7093UL },
165 { wxT("PapayaWhip"), 0xFFEFD5UL },
166 { wxT("PeachPuff"), 0xFFDAB9UL },
167 { wxT("Peru"), 0xCD853FUL },
168 { wxT("Pink"), 0xFFC0CBUL },
169 { wxT("Plum"), 0xDDA0DDUL },
170 { wxT("PowderBlue"), 0xB0E0E6UL },
171 { wxT("Purple"), 0x800080UL },
172 { wxT("RebeccaPurple"), 0x663399UL },
173 { wxT("Red"), 0xFF0000UL },
174 { wxT("RosyBrown"), 0xBC8F8FUL },
175 { wxT("RoyalBlue"), 0x4169E1UL },
176 { wxT("SaddleBrown"), 0x8B4513UL },
177 { wxT("Salmon"), 0xFA8072UL },
178 { wxT("SandyBrown"), 0xF4A460UL },
179 { wxT("SeaGreen"), 0x2E8B57UL },
180 { wxT("SeaShell"), 0xFFF5EEUL },
181 { wxT("Sienna"), 0xA0522DUL },
182 { wxT("Silver"), 0xC0C0C0UL },
183 { wxT("SkyBlue"), 0x87CEEBUL },
184 { wxT("SlateBlue"), 0x6A5ACDUL },
185 { wxT("SlateGray"), 0x708090UL },
186 { wxT("SlateGrey"), 0x708090UL },
187 { wxT("Snow"), 0xFFFAFAUL },
188 { wxT("SpringGreen"), 0x00FF7FUL },
189 { wxT("SteelBlue"), 0x4682B4UL },
190 { wxT("Tan"), 0xD2B48CUL },
191 { wxT("Teal"), 0x008080UL },
192 { wxT("Thistle"), 0xD8BFD8UL },
193 { wxT("Tomato"), 0xFF6347UL },
194 { wxT("Turquoise"), 0x40E0D0UL },
195 { wxT("Violet"), 0xEE82EEUL },
196 { wxT("Wheat"), 0xF5DEB3UL },
197 { wxT("White"), 0xFFFFFFUL },
198 { wxT("WhiteSmoke"), 0xF5F5F5UL },
199 { wxT("Yellow"), 0xFFFF00UL },
200 { wxT("YellowGreen"), 0x9ACD32UL }
201 };
202
203
204
205 /** Number of elements in the html_colors array.
206 */
207 static const size_t sz_html_colors =
208 sizeof(html_colors)/sizeof(html_color_t);
209
210
211
212 /** Window type name.
213 */
214 wxChar const
215 Dk4WxColourPalette::Dk4WxColourPaletteItem::Dk4WxColourPaletteItemName[] = {
216 wxT("Dk4WxColourPaletteItem")
217 } ;
218
219
220
221 #if wxCHECK_VERSION(3,0,0)
222 wxBEGIN_EVENT_TABLE(Dk4WxColourPalette::Dk4WxColourPaletteItem,wxControl)
223 #else
224 BEGIN_EVENT_TABLE(Dk4WxColourPalette::Dk4WxColourPaletteItem,wxControl)
225 #endif
226 EVT_ERASE_BACKGROUND(Dk4WxColourPalette::Dk4WxColourPaletteItem::OnErase)
227 EVT_PAINT(Dk4WxColourPalette::Dk4WxColourPaletteItem::OnPaint)
228 EVT_LEFT_DOWN(Dk4WxColourPalette::Dk4WxColourPaletteItem::OnLeftMouseButtonDown)
229 #if wxCHECK_VERSION(3,0,0)
230 wxEND_EVENT_TABLE()
231 #else
232 END_EVENT_TABLE()
233 #endif
234
235
236 #if wxCHECK_VERSION(3,0,0)
237 wxIMPLEMENT_DYNAMIC_CLASS(Dk4WxColourPalette::Dk4WxColourPaletteItem,wxControl);
238 #else
239 IMPLEMENT_DYNAMIC_CLASS(Dk4WxColourPalette::Dk4WxColourPaletteItem,wxControl)
240 #endif
241
242
243
244 #if wxCHECK_VERSION(3,0,0)
245 wxBEGIN_EVENT_TABLE(Dk4WxColourPalette,wxDialog)
246 #else
247 BEGIN_EVENT_TABLE(Dk4WxColourPalette,wxDialog)
248 #endif
249 EVT_BUTTON(\
250 wxID_OK,\
251 Dk4WxColourPalette::OnOK\
252 )
253 EVT_BUTTON(\
254 wxID_CANCEL,\
255 Dk4WxColourPalette::OnCancel\
256 )
257 EVT_SLIDER(\
258 Dk4WxColourPalette::ID_SLIDER_SHADE,\
259 Dk4WxColourPalette::OnShadeSlider\
260 )
261 EVT_SLIDER(\
262 Dk4WxColourPalette::ID_SLIDER_RED,\
263 Dk4WxColourPalette::OnRgbSlider\
264 )
265 EVT_SLIDER(\
266 Dk4WxColourPalette::ID_SLIDER_GREEN,\
267 Dk4WxColourPalette::OnRgbSlider\
268 )
269 EVT_SLIDER(\
270 Dk4WxColourPalette::ID_SLIDER_BLUE,\
271 Dk4WxColourPalette::OnRgbSlider\
272 )
273 EVT_CHOICEBOOK_PAGE_CHANGED(\
274 Dk4WxColourPalette::ID_CHOICEBOOK,\
275 Dk4WxColourPalette::OnChoicebookChanged\
276 )
277 EVT_LISTBOX(\
278 Dk4WxColourPalette::ID_HTML_NAMED_LIST,\
279 Dk4WxColourPalette::OnListBoxChanged\
280 )
281 #if wxCHECK_VERSION(3,0,0)
282 wxEND_EVENT_TABLE()
283 #else
284 END_EVENT_TABLE()
285 #endif
286
287
288
289 /** Text fragments, replaced by localized versions if found.
290 */
291 static const wxChar * const message_texts[] = {
292 /* 0 */
293 wxT("Colour palettes"),
294
295 /* 1 */
296 wxT("Choose palette type"),
297
298 /* 2 */
299 wxT("Click palette item to choose color"),
300
301 /* 3 */
302 wxT("black"),
303
304 /* 4 */
305 wxT("pure"),
306
307 /* 5 */
308 wxT("white"),
309
310 /* 6 */
311 wxT("Shading level"),
312
313 /* 7 */
314 wxT("Modify shading (mix towards black or white)"),
315
316 /* 8 */
317 wxT("Select item to choose color"),
318
319 /* 9 */
320 wxT("Red"),
321
322 /* 10 */
323 wxT("Green"),
324
325 /* 11 */
326 wxT("Blue"),
327
328 /* 12 */
329 wxT("Modify red color component"),
330
331 /* 13 */
332 wxT("Modify green color component"),
333
334 /* 14 */
335 wxT("Modify blue color component"),
336
337 /* 15 */
338 wxT("Cancel"),
339
340 /* 16 */
341 wxT("Leave dialog, skip settings"),
342
343 /* 17 */
344 wxT("Red color component value, hexadecimal 00...FF"),
345
346 /* 18 */
347 wxT("Green color component value, hexadecimal 00...FF"),
348
349 /* 19 */
350 wxT("Blue color component value, hexadecimal 00...FF"),
351
352 /* 20 */
353 wxT("Red color component value, decimal 0...255"),
354
355 /* 21 */
356 wxT("Green color component value, decimal 0...255"),
357
358 /* 22 */
359 wxT("Blue color component value, decimal 0...255"),
360
361 /* 23 */
362 wxT("Result color"),
363
364 /* 24 */
365 wxT("OK"),
366
367 /* 25 */
368 wxT("Apply settings"),
369
370 /* 26 */
371 wxT("XFig"),
372
373 /* 27 */
374 wxT("HTML"),
375
376 /* 28 */
377 wxT("WEB 216"),
378
379 NULL
380
381 };
382
383
384 static const wxChar * const not_localized_texts[] = {
385 /* 0 */
386 wxT("FF"),
387
388 /* 1 */
389 wxT("255"),
390
391 /* 2 */
392 wxT("%+02d %%"),
393
394 /* 3 */
395 wxT("%03d"),
396
397 /* 4 */
398 wxT("%02X"),
399
400 NULL
401
402 };
403
404
405
406 /** String table file name.
407 */
408 static const dkChar sttfilename[] = { dkT("dk4colpal.str") };
409
410
411
412 /** Color component values corresponding to the RGB slider settings.
413 */
414 static const int rgbSliderValues[] = {
415 0, 0x0033, 0x0066, 0x0099, 0x00CC, 0x00FF
416 };
417
418
419
Dk4WxColourPalette()420 Dk4WxColourPalette::Dk4WxColourPalette()
421 {
422 pAppHelp = NULL;
423 slvshade = 0;
424 rb = gb = bb = r = g = b = 255;
425 slvred = slvgreen = slvblue = 5;
426 listSelection = 0;
427 bIsCorrecting = false;
428 }
429
430
431
432
Dk4WxColourPalette(wxWindow * pParent,Dk4WxApplicationHelper * pAppHelper,int red,int green,int blue,bool withborder)433 Dk4WxColourPalette::Dk4WxColourPalette(
434 wxWindow *pParent,
435 Dk4WxApplicationHelper *pAppHelper,
436 int red,
437 int green,
438 int blue,
439 bool withborder
440 )
441 : wxDialog(
442 pParent, wxID_ANY,
443 wxT("Colour palette"),
444 wxDefaultPosition, wxDefaultSize,
445 Dk4WxColourPalette::GetDialogStyle(false, withborder)
446 ),
447 colourRed(127, 0, 0),
448 colourGreen(0, 127, 0),
449 colourBlue(0, 0, 127)
450 {
451 wxArrayString saHtmlNames;
452 wxChar const * const *lTexts;
453 size_t i;
454
455
456
457
458
459 localizedTexts = lTexts =
460 pAppHelper->GetStringTable(sttfilename, message_texts);
461 if (NULL == localizedTexts) {
462 localizedTexts = lTexts = message_texts;
463 }
464 pAppHelp = pAppHelper;
465 slvshade = 0;
466 rb = r = red;
467 gb = g = green;
468 bb = b = blue;
469 slvred = slvgreen = slvblue = 5;
470 listSelection = 0;
471 bIsCorrecting = false;
472 for (i = 0; i < sz_html_colors; i++) {
473 saHtmlNames.Add(html_colors[i].name);
474 }
475 dkctGUILayoutOK = false;
476 mainSizerHorizontal = NULL;
477 mainSizerVertical = NULL;
478 choiceBookInput = NULL;
479 resultSizerHexadecimal = NULL;
480 resultSizerDecimal = NULL;
481 colourViewResult = NULL;
482 buttonsDialog = NULL;
483 panelFig = NULL;
484 panelHtmlNamed = NULL;
485 panelHtml216 = NULL;
486 figSizerHorizontal = NULL;
487 figSizerVertical = NULL;
488 figButtonRow0 = NULL;
489 figButtonRow1 = NULL;
490 figButtonRow2 = NULL;
491 figButtonRow3 = NULL;
492 figShaderLabelSizer = NULL;
493 figShaderSlider = NULL;
494 b00 = NULL;
495 b01 = NULL;
496 b02 = NULL;
497 b03 = NULL;
498 b04 = NULL;
499 b05 = NULL;
500 b06 = NULL;
501 b07 = NULL;
502 b08 = NULL;
503 b09 = NULL;
504 b10 = NULL;
505 b11 = NULL;
506 b12 = NULL;
507 b13 = NULL;
508 b14 = NULL;
509 b15 = NULL;
510 b16 = NULL;
511 b17 = NULL;
512 b18 = NULL;
513 b19 = NULL;
514 b20 = NULL;
515 b21 = NULL;
516 b22 = NULL;
517 b23 = NULL;
518 b24 = NULL;
519 b25 = NULL;
520 b26 = NULL;
521 b27 = NULL;
522 b28 = NULL;
523 b29 = NULL;
524 b30 = NULL;
525 b31 = NULL;
526 figShaderLabelText = NULL;
527 htmlNamedSizerHorizontal = NULL;
528 htmlNamedSizerVertical = NULL;
529 listHtmlNames = NULL;
530 html216SizerHorizontal = NULL;
531 html216SizerVertical = NULL;
532 labelHtml216Red = NULL;
533 sliderHtml216Red = NULL;
534 labelHtml216Green = NULL;
535 sliderHtml216Green = NULL;
536 labelHtml216Blue = NULL;
537 sliderHtml216Blue = NULL;
538 hexRed = NULL;
539 hexGreen = NULL;
540 hexBlue = NULL;
541 decRed = NULL;
542 decGreen = NULL;
543 decBlue = NULL;
544 buttonOK = NULL;
545 buttonCancel = NULL;
546 mainSizerHorizontal = new wxBoxSizer(
547 wxHORIZONTAL
548 );
549 if(!(mainSizerHorizontal)) {
550 goto dkctGUILayoutFinished;
551 }
552 mainSizerHorizontal->Add(10, 10, 0);
553 mainSizerVertical = new wxBoxSizer(
554 wxVERTICAL
555 );
556 if(!(mainSizerVertical)) {
557 goto dkctGUILayoutFinished;
558 }
559 mainSizerVertical->Add(10, 10, 0);
560 choiceBookInput = new wxChoicebook(
561 this,
562 ID_CHOICEBOOK
563 );
564 if(!(choiceBookInput)) {
565 goto dkctGUILayoutFinished;
566 }
567 panelFig = new wxPanel(
568 choiceBookInput,
569 wxID_ANY
570 );
571 if(!(panelFig)) {
572 goto dkctGUILayoutFinished;
573 }
574 figSizerHorizontal = new wxBoxSizer(
575 wxHORIZONTAL
576 );
577 if(!(figSizerHorizontal)) {
578 goto dkctGUILayoutFinished;
579 }
580 figSizerHorizontal->Add(5, 5, 1);
581 figSizerVertical = new wxBoxSizer(
582 wxVERTICAL
583 );
584 if(!(figSizerVertical)) {
585 goto dkctGUILayoutFinished;
586 }
587 figSizerVertical->Add(5, 5, 1);
588 figButtonRow0 = new wxBoxSizer(
589 wxHORIZONTAL
590 );
591 if(!(figButtonRow0)) {
592 goto dkctGUILayoutFinished;
593 }
594 b00 = new Dk4WxColourPaletteItem(
595 panelFig,wxID_ANY,this, pAppHelper, 0, 0, 0
596 );
597 if(!(b00)) {
598 goto dkctGUILayoutFinished;
599 }
600 b00->SetToolTip(lTexts[2]);
601 figButtonRow0->Add(
602 b00
603 );
604 figButtonRow0->Add(5, 5, 0);
605 b01 = new Dk4WxColourPaletteItem(
606 panelFig,wxID_ANY,this, pAppHelper, 0, 0, 255
607 );
608 if(!(b01)) {
609 goto dkctGUILayoutFinished;
610 }
611 b01->SetToolTip(lTexts[2]);
612 figButtonRow0->Add(
613 b01
614 );
615 figButtonRow0->Add(5, 5, 0);
616 b02 = new Dk4WxColourPaletteItem(
617 panelFig,wxID_ANY,this, pAppHelper, 0, 255, 0
618 );
619 if(!(b02)) {
620 goto dkctGUILayoutFinished;
621 }
622 b02->SetToolTip(lTexts[2]);
623 figButtonRow0->Add(
624 b02
625 );
626 figButtonRow0->Add(5, 5, 0);
627 b03 = new Dk4WxColourPaletteItem(
628 panelFig,wxID_ANY,this, pAppHelper, 0, 255, 255
629 );
630 if(!(b03)) {
631 goto dkctGUILayoutFinished;
632 }
633 b03->SetToolTip(lTexts[2]);
634 figButtonRow0->Add(
635 b03
636 );
637 figButtonRow0->Add(5, 5, 0);
638 b04 = new Dk4WxColourPaletteItem(
639 panelFig,wxID_ANY,this, pAppHelper, 255, 0, 0
640 );
641 if(!(b04)) {
642 goto dkctGUILayoutFinished;
643 }
644 b04->SetToolTip(lTexts[2]);
645 figButtonRow0->Add(
646 b04
647 );
648 figButtonRow0->Add(5, 5, 0);
649 b05 = new Dk4WxColourPaletteItem(
650 panelFig,wxID_ANY,this, pAppHelper, 255, 0, 255
651 );
652 if(!(b05)) {
653 goto dkctGUILayoutFinished;
654 }
655 b05->SetToolTip(lTexts[2]);
656 figButtonRow0->Add(
657 b05
658 );
659 figButtonRow0->Add(5, 5, 0);
660 b06 = new Dk4WxColourPaletteItem(
661 panelFig,wxID_ANY,this, pAppHelper, 255, 255, 0
662 );
663 if(!(b06)) {
664 goto dkctGUILayoutFinished;
665 }
666 b06->SetToolTip(lTexts[2]);
667 figButtonRow0->Add(
668 b06
669 );
670 figButtonRow0->Add(5, 5, 0);
671 b07 = new Dk4WxColourPaletteItem(
672 panelFig,wxID_ANY,this, pAppHelper, 255, 255, 255
673 );
674 if(!(b07)) {
675 goto dkctGUILayoutFinished;
676 }
677 b07->SetToolTip(lTexts[2]);
678 figButtonRow0->Add(
679 b07
680 );
681 figSizerVertical->Add(
682 figButtonRow0
683 );
684 figSizerVertical->Add(5, 5, 0);
685 figButtonRow1 = new wxBoxSizer(
686 wxHORIZONTAL
687 );
688 if(!(figButtonRow1)) {
689 goto dkctGUILayoutFinished;
690 }
691 b08 = new Dk4WxColourPaletteItem(
692 panelFig,wxID_ANY,this, pAppHelper, 0, 0, 143
693 );
694 if(!(b08)) {
695 goto dkctGUILayoutFinished;
696 }
697 b08->SetToolTip(lTexts[2]);
698 figButtonRow1->Add(
699 b08
700 );
701 figButtonRow1->Add(5, 5, 0);
702 b09 = new Dk4WxColourPaletteItem(
703 panelFig,wxID_ANY,this, pAppHelper, 0, 0, 176
704 );
705 if(!(b09)) {
706 goto dkctGUILayoutFinished;
707 }
708 b09->SetToolTip(lTexts[2]);
709 figButtonRow1->Add(
710 b09
711 );
712 figButtonRow1->Add(5, 5, 0);
713 b10 = new Dk4WxColourPaletteItem(
714 panelFig,wxID_ANY,this, pAppHelper, 0, 0, 209
715 );
716 if(!(b10)) {
717 goto dkctGUILayoutFinished;
718 }
719 b10->SetToolTip(lTexts[2]);
720 figButtonRow1->Add(
721 b10
722 );
723 figButtonRow1->Add(5, 5, 0);
724 b11 = new Dk4WxColourPaletteItem(
725 panelFig,wxID_ANY,this, pAppHelper, 135, 207, 255
726 );
727 if(!(b11)) {
728 goto dkctGUILayoutFinished;
729 }
730 b11->SetToolTip(lTexts[2]);
731 figButtonRow1->Add(
732 b11
733 );
734 figButtonRow1->Add(5, 5, 0);
735 b12 = new Dk4WxColourPaletteItem(
736 panelFig,wxID_ANY,this, pAppHelper, 0, 143, 0
737 );
738 if(!(b12)) {
739 goto dkctGUILayoutFinished;
740 }
741 b12->SetToolTip(lTexts[2]);
742 figButtonRow1->Add(
743 b12
744 );
745 figButtonRow1->Add(5, 5, 0);
746 b13 = new Dk4WxColourPaletteItem(
747 panelFig,wxID_ANY,this, pAppHelper, 0, 176, 0
748 );
749 if(!(b13)) {
750 goto dkctGUILayoutFinished;
751 }
752 b13->SetToolTip(lTexts[2]);
753 figButtonRow1->Add(
754 b13
755 );
756 figButtonRow1->Add(5, 5, 0);
757 b14 = new Dk4WxColourPaletteItem(
758 panelFig,wxID_ANY,this, pAppHelper, 0, 209, 0
759 );
760 if(!(b14)) {
761 goto dkctGUILayoutFinished;
762 }
763 b14->SetToolTip(lTexts[2]);
764 figButtonRow1->Add(
765 b14
766 );
767 figButtonRow1->Add(5, 5, 0);
768 b15 = new Dk4WxColourPaletteItem(
769 panelFig,wxID_ANY,this, pAppHelper, 0, 143, 143
770 );
771 if(!(b15)) {
772 goto dkctGUILayoutFinished;
773 }
774 b15->SetToolTip(lTexts[2]);
775 figButtonRow1->Add(
776 b15
777 );
778 figSizerVertical->Add(
779 figButtonRow1
780 );
781 figSizerVertical->Add(5, 5, 0);
782 figButtonRow2 = new wxBoxSizer(
783 wxHORIZONTAL
784 );
785 if(!(figButtonRow2)) {
786 goto dkctGUILayoutFinished;
787 }
788 b16 = new Dk4WxColourPaletteItem(
789 panelFig,wxID_ANY,this, pAppHelper, 0, 176, 176
790 );
791 if(!(b16)) {
792 goto dkctGUILayoutFinished;
793 }
794 b16->SetToolTip(lTexts[2]);
795 figButtonRow2->Add(
796 b16
797 );
798 figButtonRow2->Add(5, 5, 0);
799 b17 = new Dk4WxColourPaletteItem(
800 panelFig,wxID_ANY,this, pAppHelper, 0, 209, 209
801 );
802 if(!(b17)) {
803 goto dkctGUILayoutFinished;
804 }
805 b17->SetToolTip(lTexts[2]);
806 figButtonRow2->Add(
807 b17
808 );
809 figButtonRow2->Add(5, 5, 0);
810 b18 = new Dk4WxColourPaletteItem(
811 panelFig,wxID_ANY,this, pAppHelper, 143, 0, 0
812 );
813 if(!(b18)) {
814 goto dkctGUILayoutFinished;
815 }
816 b18->SetToolTip(lTexts[2]);
817 figButtonRow2->Add(
818 b18
819 );
820 figButtonRow2->Add(5, 5, 0);
821 b19 = new Dk4WxColourPaletteItem(
822 panelFig,wxID_ANY,this, pAppHelper, 176, 0, 0
823 );
824 if(!(b19)) {
825 goto dkctGUILayoutFinished;
826 }
827 b19->SetToolTip(lTexts[2]);
828 figButtonRow2->Add(
829 b19
830 );
831 figButtonRow2->Add(5, 5, 0);
832 b20 = new Dk4WxColourPaletteItem(
833 panelFig,wxID_ANY,this, pAppHelper, 209, 0, 0
834 );
835 if(!(b20)) {
836 goto dkctGUILayoutFinished;
837 }
838 b20->SetToolTip(lTexts[2]);
839 figButtonRow2->Add(
840 b20
841 );
842 figButtonRow2->Add(5, 5, 0);
843 b21 = new Dk4WxColourPaletteItem(
844 panelFig,wxID_ANY,this, pAppHelper, 143, 0, 143
845 );
846 if(!(b21)) {
847 goto dkctGUILayoutFinished;
848 }
849 b21->SetToolTip(lTexts[2]);
850 figButtonRow2->Add(
851 b21
852 );
853 figButtonRow2->Add(5, 5, 0);
854 b22 = new Dk4WxColourPaletteItem(
855 panelFig,wxID_ANY,this, pAppHelper, 176, 0, 176
856 );
857 if(!(b22)) {
858 goto dkctGUILayoutFinished;
859 }
860 b22->SetToolTip(lTexts[2]);
861 figButtonRow2->Add(
862 b22
863 );
864 figButtonRow2->Add(5, 5, 0);
865 b23 = new Dk4WxColourPaletteItem(
866 panelFig,wxID_ANY,this, pAppHelper, 209, 0, 209
867 );
868 if(!(b23)) {
869 goto dkctGUILayoutFinished;
870 }
871 b23->SetToolTip(lTexts[2]);
872 figButtonRow2->Add(
873 b23
874 );
875 figSizerVertical->Add(
876 figButtonRow2
877 );
878 figSizerVertical->Add(5, 5, 0);
879 figButtonRow3 = new wxBoxSizer(
880 wxHORIZONTAL
881 );
882 if(!(figButtonRow3)) {
883 goto dkctGUILayoutFinished;
884 }
885 b24 = new Dk4WxColourPaletteItem(
886 panelFig,wxID_ANY,this, pAppHelper, 127, 48, 0
887 );
888 if(!(b24)) {
889 goto dkctGUILayoutFinished;
890 }
891 b24->SetToolTip(lTexts[2]);
892 figButtonRow3->Add(
893 b24
894 );
895 figButtonRow3->Add(5, 5, 0);
896 b25 = new Dk4WxColourPaletteItem(
897 panelFig,wxID_ANY,this, pAppHelper, 160, 63, 0
898 );
899 if(!(b25)) {
900 goto dkctGUILayoutFinished;
901 }
902 b25->SetToolTip(lTexts[2]);
903 figButtonRow3->Add(
904 b25
905 );
906 figButtonRow3->Add(5, 5, 0);
907 b26 = new Dk4WxColourPaletteItem(
908 panelFig,wxID_ANY,this, pAppHelper, 191, 97, 0
909 );
910 if(!(b26)) {
911 goto dkctGUILayoutFinished;
912 }
913 b26->SetToolTip(lTexts[2]);
914 figButtonRow3->Add(
915 b26
916 );
917 figButtonRow3->Add(5, 5, 0);
918 b27 = new Dk4WxColourPaletteItem(
919 panelFig,wxID_ANY,this, pAppHelper, 255, 127, 127
920 );
921 if(!(b27)) {
922 goto dkctGUILayoutFinished;
923 }
924 b27->SetToolTip(lTexts[2]);
925 figButtonRow3->Add(
926 b27
927 );
928 figButtonRow3->Add(5, 5, 0);
929 b28 = new Dk4WxColourPaletteItem(
930 panelFig,wxID_ANY,this, pAppHelper, 255, 160, 160
931 );
932 if(!(b28)) {
933 goto dkctGUILayoutFinished;
934 }
935 b28->SetToolTip(lTexts[2]);
936 figButtonRow3->Add(
937 b28
938 );
939 figButtonRow3->Add(5, 5, 0);
940 b29 = new Dk4WxColourPaletteItem(
941 panelFig,wxID_ANY,this, pAppHelper, 255, 191, 191
942 );
943 if(!(b29)) {
944 goto dkctGUILayoutFinished;
945 }
946 b29->SetToolTip(lTexts[2]);
947 figButtonRow3->Add(
948 b29
949 );
950 figButtonRow3->Add(5, 5, 0);
951 b30 = new Dk4WxColourPaletteItem(
952 panelFig,wxID_ANY,this, pAppHelper, 255, 224, 224
953 );
954 if(!(b30)) {
955 goto dkctGUILayoutFinished;
956 }
957 b30->SetToolTip(lTexts[2]);
958 figButtonRow3->Add(
959 b30
960 );
961 figButtonRow3->Add(5, 5, 0);
962 b31 = new Dk4WxColourPaletteItem(
963 panelFig,wxID_ANY,this, pAppHelper, 255, 214, 0
964 );
965 if(!(b31)) {
966 goto dkctGUILayoutFinished;
967 }
968 b31->SetToolTip(lTexts[2]);
969 figButtonRow3->Add(
970 b31
971 );
972 figSizerVertical->Add(
973 figButtonRow3
974 );
975 figSizerVertical->Add(10, 10, 0);
976 figShaderLabelSizer = new wxBoxSizer(
977 wxHORIZONTAL
978 );
979 if(!(figShaderLabelSizer)) {
980 goto dkctGUILayoutFinished;
981 }
982 figShaderLabelSizer->Add(10, 10, 1);
983 figShaderLabelText = new wxStaticText(
984 panelFig,
985 wxID_ANY,
986 lTexts[4],
987 wxDefaultPosition,
988 wxDefaultSize,
989 wxALIGN_CENTRE
990 );
991 if(!(figShaderLabelText)) {
992 goto dkctGUILayoutFinished;
993 }
994 figShaderLabelText->SetToolTip(lTexts[6]);
995 figShaderLabelSizer->Add(
996 figShaderLabelText
997 );
998 figShaderLabelSizer->Add(10, 10, 1);
999 figSizerVertical->Add(
1000 figShaderLabelSizer,
1001 0,
1002 wxGROW
1003 );
1004 figSizerVertical->Add(5, 5, 0);
1005 figShaderSlider = new wxSlider(
1006 panelFig,
1007 ID_SLIDER_SHADE,
1008 0,
1009 -20,
1010 20
1011 );
1012 if(!(figShaderSlider)) {
1013 goto dkctGUILayoutFinished;
1014 }
1015 figShaderSlider->SetToolTip(lTexts[7]);
1016 figSizerVertical->Add(
1017 figShaderSlider,
1018 0,
1019 wxGROW
1020 );
1021 figSizerVertical->Add(5, 5, 1);
1022 figSizerHorizontal->Add(
1023 figSizerVertical
1024 );
1025 figSizerHorizontal->Add(5, 5, 1);
1026 panelFig->SetSizer(figSizerHorizontal);
1027 choiceBookInput->AddPage(panelFig, lTexts[26]);
1028 panelHtmlNamed = new wxPanel(
1029 choiceBookInput,
1030 wxID_ANY
1031 );
1032 if(!(panelHtmlNamed)) {
1033 goto dkctGUILayoutFinished;
1034 }
1035 htmlNamedSizerHorizontal = new wxBoxSizer(
1036 wxHORIZONTAL
1037 );
1038 if(!(htmlNamedSizerHorizontal)) {
1039 goto dkctGUILayoutFinished;
1040 }
1041 htmlNamedSizerHorizontal->Add(5, 5, 0);
1042 htmlNamedSizerVertical = new wxBoxSizer(
1043 wxHORIZONTAL
1044 );
1045 if(!(htmlNamedSizerVertical)) {
1046 goto dkctGUILayoutFinished;
1047 }
1048 htmlNamedSizerVertical->Add(5, 5, 0);
1049 listHtmlNames = new wxListBox(
1050 panelHtmlNamed,
1051 ID_HTML_NAMED_LIST,
1052 wxDefaultPosition,
1053 wxSize(200, 200),
1054 saHtmlNames,
1055 wxLB_SINGLE|wxLB_HSCROLL|wxLB_NEEDED_SB
1056 );
1057 if(!(listHtmlNames)) {
1058 goto dkctGUILayoutFinished;
1059 }
1060 listHtmlNames->SetToolTip(lTexts[8]);
1061 htmlNamedSizerVertical->Add(
1062 listHtmlNames
1063 );
1064 htmlNamedSizerVertical->Add(5, 5, 0);
1065 htmlNamedSizerHorizontal->Add(
1066 htmlNamedSizerVertical
1067 );
1068 htmlNamedSizerHorizontal->Add(5, 5, 0);
1069 panelHtmlNamed->SetSizer(htmlNamedSizerHorizontal);
1070 choiceBookInput->AddPage(panelHtmlNamed, lTexts[27]);
1071 panelHtml216 = new wxPanel(
1072 choiceBookInput,
1073 wxID_ANY
1074 );
1075 if(!(panelHtml216)) {
1076 goto dkctGUILayoutFinished;
1077 }
1078 html216SizerHorizontal = new wxBoxSizer(
1079 wxHORIZONTAL
1080 );
1081 if(!(html216SizerHorizontal)) {
1082 goto dkctGUILayoutFinished;
1083 }
1084 html216SizerHorizontal->Add(5, 5, 0);
1085 html216SizerVertical = new wxBoxSizer(
1086 wxVERTICAL
1087 );
1088 if(!(html216SizerVertical)) {
1089 goto dkctGUILayoutFinished;
1090 }
1091 html216SizerVertical->Add(250, 5, 0);
1092 labelHtml216Red = new wxStaticText(
1093 panelHtml216,
1094 wxID_ANY,
1095 lTexts[9]
1096 );
1097 if(!(labelHtml216Red)) {
1098 goto dkctGUILayoutFinished;
1099 }
1100 html216SizerVertical->Add(
1101 labelHtml216Red
1102 );
1103 sliderHtml216Red = new wxSlider(
1104 panelHtml216,
1105 ID_SLIDER_RED,
1106 0,
1107 0,
1108 5
1109 );
1110 if(!(sliderHtml216Red)) {
1111 goto dkctGUILayoutFinished;
1112 }
1113 sliderHtml216Red->SetToolTip(lTexts[12]);
1114 html216SizerVertical->Add(
1115 sliderHtml216Red,
1116 0,
1117 wxGROW
1118 );
1119 html216SizerVertical->Add(5, 5, 0);
1120 labelHtml216Green = new wxStaticText(
1121 panelHtml216,
1122 wxID_ANY,
1123 lTexts[10]
1124 );
1125 if(!(labelHtml216Green)) {
1126 goto dkctGUILayoutFinished;
1127 }
1128 html216SizerVertical->Add(
1129 labelHtml216Green
1130 );
1131 sliderHtml216Green = new wxSlider(
1132 panelHtml216,
1133 ID_SLIDER_GREEN,
1134 0,
1135 0,
1136 5
1137 );
1138 if(!(sliderHtml216Green)) {
1139 goto dkctGUILayoutFinished;
1140 }
1141 sliderHtml216Green->SetToolTip(lTexts[13]);
1142 html216SizerVertical->Add(
1143 sliderHtml216Green,
1144 0,
1145 wxGROW
1146 );
1147 html216SizerVertical->Add(5, 5, 0);
1148 labelHtml216Blue = new wxStaticText(
1149 panelHtml216,
1150 wxID_ANY,
1151 lTexts[11]
1152 );
1153 if(!(labelHtml216Blue)) {
1154 goto dkctGUILayoutFinished;
1155 }
1156 html216SizerVertical->Add(
1157 labelHtml216Blue
1158 );
1159 sliderHtml216Blue = new wxSlider(
1160 panelHtml216,
1161 ID_SLIDER_BLUE,
1162 0,
1163 0,
1164 5
1165 );
1166 if(!(sliderHtml216Blue)) {
1167 goto dkctGUILayoutFinished;
1168 }
1169 sliderHtml216Blue->SetToolTip(lTexts[14]);
1170 html216SizerVertical->Add(
1171 sliderHtml216Blue,
1172 0,
1173 wxGROW
1174 );
1175 html216SizerVertical->Add(5, 5, 0);
1176 html216SizerHorizontal->Add(
1177 html216SizerVertical
1178 );
1179 html216SizerHorizontal->Add(5, 5, 0);
1180 panelHtml216->SetSizer(html216SizerHorizontal);
1181 choiceBookInput->AddPage(panelHtml216, lTexts[28]);
1182 choiceBookInput->SetToolTip(lTexts[1]);
1183 mainSizerVertical->Add(
1184 choiceBookInput
1185 );
1186 mainSizerVertical->Add(10, 10, 0);
1187 resultSizerHexadecimal = new wxBoxSizer(
1188 wxHORIZONTAL
1189 );
1190 if(!(resultSizerHexadecimal)) {
1191 goto dkctGUILayoutFinished;
1192 }
1193 hexRed = new wxStaticText(
1194 this,
1195 wxID_ANY,
1196 not_localized_texts[0]
1197 );
1198 if(!(hexRed)) {
1199 goto dkctGUILayoutFinished;
1200 }
1201 hexRed->SetToolTip(lTexts[17]);
1202 resultSizerHexadecimal->Add(
1203 hexRed
1204 );
1205 resultSizerHexadecimal->Add(10, 10, 1);
1206 hexGreen = new wxStaticText(
1207 this,
1208 wxID_ANY,
1209 not_localized_texts[0],
1210 wxDefaultPosition,
1211 wxDefaultSize,
1212 wxALIGN_CENTRE
1213 );
1214 if(!(hexGreen)) {
1215 goto dkctGUILayoutFinished;
1216 }
1217 hexGreen->SetToolTip(lTexts[18]);
1218 resultSizerHexadecimal->Add(
1219 hexGreen
1220 );
1221 resultSizerHexadecimal->Add(10, 10, 1);
1222 hexBlue = new wxStaticText(
1223 this,
1224 wxID_ANY,
1225 not_localized_texts[0],
1226 wxDefaultPosition,
1227 wxDefaultSize,
1228 wxALIGN_RIGHT
1229 );
1230 if(!(hexBlue)) {
1231 goto dkctGUILayoutFinished;
1232 }
1233 hexBlue->SetToolTip(lTexts[19]);
1234 resultSizerHexadecimal->Add(
1235 hexBlue
1236 );
1237 mainSizerVertical->Add(
1238 resultSizerHexadecimal,
1239 0,
1240 wxGROW
1241 );
1242 resultSizerDecimal = new wxBoxSizer(
1243 wxHORIZONTAL
1244 );
1245 if(!(resultSizerDecimal)) {
1246 goto dkctGUILayoutFinished;
1247 }
1248 decRed = new wxStaticText(
1249 this,
1250 wxID_ANY,
1251 not_localized_texts[1]
1252 );
1253 if(!(decRed)) {
1254 goto dkctGUILayoutFinished;
1255 }
1256 decRed->SetToolTip(lTexts[20]);
1257 resultSizerDecimal->Add(
1258 decRed
1259 );
1260 resultSizerDecimal->Add(10, 10, 1);
1261 decGreen = new wxStaticText(
1262 this,
1263 wxID_ANY,
1264 not_localized_texts[1],
1265 wxDefaultPosition,
1266 wxDefaultSize,
1267 wxALIGN_CENTRE
1268 );
1269 if(!(decGreen)) {
1270 goto dkctGUILayoutFinished;
1271 }
1272 decGreen->SetToolTip(lTexts[21]);
1273 resultSizerDecimal->Add(
1274 decGreen
1275 );
1276 resultSizerDecimal->Add(10, 10, 1);
1277 decBlue = new wxStaticText(
1278 this,
1279 wxID_ANY,
1280 not_localized_texts[1],
1281 wxDefaultPosition,
1282 wxDefaultSize,
1283 wxALIGN_RIGHT
1284 );
1285 if(!(decBlue)) {
1286 goto dkctGUILayoutFinished;
1287 }
1288 decBlue->SetToolTip(lTexts[22]);
1289 resultSizerDecimal->Add(
1290 decBlue
1291 );
1292 mainSizerVertical->Add(
1293 resultSizerDecimal,
1294 0,
1295 wxGROW
1296 );
1297 mainSizerVertical->Add(5, 5, 0);
1298 colourViewResult = new Dk4WxColourView(
1299 this,wxID_ANY,pAppHelp, r, g, b
1300 );
1301 if(!(colourViewResult)) {
1302 goto dkctGUILayoutFinished;
1303 }
1304 colourViewResult->SetMinSize(wxSize(50, 50));
1305 colourViewResult->SetToolTip(lTexts[23]);
1306 mainSizerVertical->Add(
1307 colourViewResult,
1308 0,
1309 wxGROW
1310 );
1311 mainSizerVertical->Add(10, 10, 0);
1312 buttonsDialog = new wxStdDialogButtonSizer(
1313 );
1314 if(!(buttonsDialog)) {
1315 goto dkctGUILayoutFinished;
1316 }
1317 buttonOK = new wxButton(
1318 this,
1319 wxID_OK,
1320 lTexts[24]
1321 );
1322 if(!(buttonOK)) {
1323 goto dkctGUILayoutFinished;
1324 }
1325 buttonOK->SetToolTip(lTexts[25]);
1326 buttonsDialog->AddButton(
1327 buttonOK
1328 );
1329 buttonCancel = new wxButton(
1330 this,
1331 wxID_CANCEL,
1332 lTexts[15]
1333 );
1334 if(!(buttonCancel)) {
1335 goto dkctGUILayoutFinished;
1336 }
1337 buttonCancel->SetToolTip(lTexts[16]);
1338 buttonsDialog->AddButton(
1339 buttonCancel
1340 );
1341 buttonsDialog->Realize();
1342 mainSizerVertical->Add(
1343 buttonsDialog,
1344 0,
1345 wxALIGN_CENTER_HORIZONTAL
1346 );
1347 mainSizerVertical->Add(10, 10, 0);
1348 mainSizerHorizontal->Add(
1349 mainSizerVertical
1350 );
1351 mainSizerHorizontal->Add(10, 10, 0);
1352 SetSizer(mainSizerHorizontal);
1353 dkctGUILayoutOK = true;
1354 dkctGUILayoutFinished:
1355 if(dkctGUILayoutOK) {
1356 mainSizerHorizontal->Fit(this);
1357 mainSizerHorizontal->SetSizeHints(this);
1358 }
1359 if (dkctGUILayoutOK) {
1360 colourViewResult->SetActive(false);
1361 colourViewResult->SetMarkActiveInactive(false);
1362 decRed->SetForegroundColour(colourRed);
1363 decGreen->SetForegroundColour(colourGreen);
1364 decBlue->SetForegroundColour(colourBlue);
1365 hexRed->SetForegroundColour(colourRed);
1366 hexGreen->SetForegroundColour(colourGreen);
1367 hexBlue->SetForegroundColour(colourBlue);
1368 SetRgbTextLabels();
1369 FindRgbSliderValues();
1370 FindListBoxEntry();
1371 SetTitle(lTexts[0]);
1372 wxSize minsize = GetMinSize();
1373 SetMaxSize(minsize);
1374 }
1375
1376 }
1377
1378
1379
1380 void
OnOK(wxCommandEvent & WXUNUSED (event))1381 Dk4WxColourPalette::OnOK(wxCommandEvent & WXUNUSED(event))
1382 {
1383 if(IsModal()) {
1384 EndModal(wxID_OK);
1385 }
1386 else {
1387 SetReturnCode(wxID_OK);
1388 Show(false);
1389 }
1390 }
1391
1392
1393
1394 void
OnCancel(wxCommandEvent & WXUNUSED (event))1395 Dk4WxColourPalette::OnCancel(wxCommandEvent & WXUNUSED(event))
1396 {
1397 if(IsModal()) {
1398 EndModal(wxID_CANCEL);
1399 }
1400 else {
1401 SetReturnCode(wxID_CANCEL);
1402 Show(false);
1403 }
1404 }
1405
1406
1407
1408 #if wxCHECK_VERSION(3,0,0)
1409 void
OnChoicebookChanged(wxBookCtrlEvent & event)1410 Dk4WxColourPalette::OnChoicebookChanged(wxBookCtrlEvent & event)
1411 #else
1412 void
1413 Dk4WxColourPalette::OnChoicebookChanged(wxChoicebookEvent & event)
1414 #endif
1415 {
1416 int pn;
1417
1418 pn = event.GetSelection();
1419 if (1 == pn) {
1420 if (wxNOT_FOUND != listSelection) {
1421 listHtmlNames->SetSelection(listSelection);
1422 }
1423 }
1424
1425 }
1426
1427
1428
1429 int
ShadeColour(int val)1430 Dk4WxColourPalette::ShadeColour(int val)
1431 {
1432 int back;
1433
1434 back = val;
1435 if (0 < slvshade) {
1436 back = (((20 - slvshade) * val) + (slvshade * 255)) / 20;
1437 }
1438 else {
1439 if (0 > slvshade) {
1440 back = (val * (20 + slvshade)) / 20;
1441 }
1442 }
1443 return back;
1444 }
1445
1446
1447
1448 void
CorrectShadeLabel(void)1449 Dk4WxColourPalette::CorrectShadeLabel(void)
1450 {
1451 wxString lstr;
1452
1453 switch (slvshade) {
1454 case -20 : {
1455 figShaderLabelText->SetLabel(localizedTexts[3]);
1456 } break;
1457 case 0 : {
1458 figShaderLabelText->SetLabel(localizedTexts[4]);
1459 } break;
1460 case 20 : {
1461 figShaderLabelText->SetLabel(localizedTexts[5]);
1462 } break;
1463 default : {
1464 lstr.Printf(not_localized_texts[2], (5*slvshade));
1465 figShaderLabelText->SetLabel(lstr);
1466 } break;
1467 }
1468 }
1469
1470
1471
1472 void
SetBaseRGB(int red,int green,int blue)1473 Dk4WxColourPalette::SetBaseRGB(int red, int green, int blue)
1474 {
1475
1476 rb = red; gb = green; bb = blue;
1477 CorrectGui(REASON_BASE_COLOR);
1478
1479 }
1480
1481
1482
1483 void
OnShadeSlider(wxCommandEvent & WXUNUSED (event))1484 Dk4WxColourPalette::OnShadeSlider(wxCommandEvent & WXUNUSED(event))
1485 {
1486
1487 if (!(bIsCorrecting)) {
1488 slvshade = figShaderSlider->GetValue();
1489 CorrectGui(REASON_SHADE_SLIDER);
1490 }
1491
1492 }
1493
1494
1495
1496 void
OnListBoxChanged(wxCommandEvent & WXUNUSED (event))1497 Dk4WxColourPalette::OnListBoxChanged(wxCommandEvent & WXUNUSED(event))
1498 {
1499 int in;
1500 unsigned long ul;
1501
1502 if (!(bIsCorrecting)) {
1503 listSelection = in = listHtmlNames->GetSelection();
1504 if ((0 <= in) && (wxNOT_FOUND != in)) {
1505 ul = html_colors[in].rgb;
1506 r = rb = (int)((ul >> 16) & 0x000000FFUL);
1507 g = gb = (int)((ul >> 8) & 0x000000FFUL);
1508 b = bb = (int)( ul & 0x000000FFUL);
1509 CorrectGui(REASON_LIST_SELECT);
1510 }
1511 }
1512
1513 }
1514
1515
1516
1517 void
OnRgbSlider(wxCommandEvent & WXUNUSED (event))1518 Dk4WxColourPalette::OnRgbSlider(wxCommandEvent & WXUNUSED(event))
1519 {
1520
1521 if (!(bIsCorrecting)) {
1522 rb = r = rgbSliderValues[sliderHtml216Red->GetValue()];
1523 gb = g = rgbSliderValues[sliderHtml216Green->GetValue()];
1524 bb = b = rgbSliderValues[sliderHtml216Blue->GetValue()];
1525 CorrectGui(REASON_RGB_SLIDER);
1526 }
1527
1528 }
1529
1530
1531
1532 int
FindSliderValue(int colval)1533 Dk4WxColourPalette::FindSliderValue(int colval)
1534 {
1535 long mindiff = 0L;
1536 long curdiff;
1537 int back = 0;
1538 int i;
1539 for (i = 0; i < 6; i++) {
1540 curdiff = labs(colval - rgbSliderValues[i]);
1541 if ((0 == i) || (curdiff < mindiff)) {
1542 back = i;
1543 mindiff = curdiff;
1544 }
1545 }
1546 return back;
1547 }
1548
1549
1550
1551 void
FindRgbSliderValues(void)1552 Dk4WxColourPalette::FindRgbSliderValues(void)
1553 {
1554 int sl;
1555 sl = FindSliderValue(r);
1556 slvred = sl;
1557 sliderHtml216Red->SetValue(sl);
1558 sl = FindSliderValue(g);
1559 slvgreen = sl;
1560 sliderHtml216Green->SetValue(sl);
1561 sl = FindSliderValue(b);
1562 slvblue = sl;
1563 sliderHtml216Blue->SetValue(sl);
1564 }
1565
1566
1567
1568 void
FindListBoxEntry(void)1569 Dk4WxColourPalette::FindListBoxEntry(void)
1570 {
1571 size_t i;
1572 size_t mini;
1573 unsigned long ul;
1574 unsigned long curdiff;
1575 unsigned long mindiff;
1576 unsigned long r0;
1577 unsigned long g0;
1578 unsigned long b0;
1579
1580 mindiff = 0UL; mini = 0;
1581 for (i = 0; i < sz_html_colors; i++) {
1582 ul = html_colors[i].rgb;
1583 r0 = (ul >> 16) & 0x000000FFUL;
1584 g0 = (ul >> 8) & 0x000000FFUL;
1585 b0 = ul & 0x000000FFUL;
1586 r0 = labs((long)r0 - (long)r);
1587 g0 = labs((long)g0 - (long)g);
1588 b0 = labs((long)b0 - (long)b);
1589 r0 = r0 * r0;
1590 g0 = g0 * g0;
1591 b0 = b0 * b0;
1592 curdiff = r0 + g0 + b0;
1593 if ((0 == i) || (curdiff < mindiff)) {
1594 mindiff = curdiff;
1595 mini = i;
1596 }
1597 }
1598 /*
1599 Cast not dangerous as sz_html_colors is limited.
1600 */
1601 listSelection = (int)mini;
1602 listHtmlNames->SetSelection((int)mini);
1603 }
1604
1605
1606
1607 void
SetRgbTextLabels(void)1608 Dk4WxColourPalette::SetRgbTextLabels(void)
1609 {
1610 wxString valstr;
1611
1612 valstr.Printf(not_localized_texts[3], r);
1613 decRed->SetLabel(valstr);
1614 valstr.Printf(not_localized_texts[3], g);
1615 decGreen->SetLabel(valstr);
1616 valstr.Printf(not_localized_texts[3], b);
1617 decBlue->SetLabel(valstr);
1618 valstr.Printf(not_localized_texts[4], r);
1619 hexRed->SetLabel(valstr);
1620 valstr.Printf(not_localized_texts[4], g);
1621 hexGreen->SetLabel(valstr);
1622 valstr.Printf(not_localized_texts[4], b);
1623 hexBlue->SetLabel(valstr);
1624 }
1625
1626
1627
1628 void
CorrectGui(int reason)1629 Dk4WxColourPalette::CorrectGui(int reason)
1630 {
1631
1632 if(!(bIsCorrecting)) {
1633 /*
1634 Mark correction in progress
1635 */
1636 bIsCorrecting = true;
1637 /*
1638 Apply the changes
1639 */
1640 switch (reason) {
1641 case REASON_CHOICEBOOK : {
1642 } break;
1643 case REASON_BASE_COLOR : {
1644 r = ShadeColour(rb);
1645 g = ShadeColour(gb);
1646 b = ShadeColour(bb);
1647 FindListBoxEntry();
1648 FindRgbSliderValues();
1649 } break;
1650 case REASON_SHADE_SLIDER : {
1651 r = ShadeColour(rb);
1652 g = ShadeColour(gb);
1653 b = ShadeColour(bb);
1654 FindListBoxEntry();
1655 FindRgbSliderValues();
1656 CorrectShadeLabel();
1657 } break;
1658 case REASON_LIST_SELECT : {
1659 FindRgbSliderValues();
1660 slvshade = 0;
1661 figShaderSlider->SetValue(0);
1662 CorrectShadeLabel();
1663 } break;
1664 case REASON_RGB_SLIDER : {
1665 FindListBoxEntry();
1666 slvshade = 0;
1667 figShaderSlider->SetValue(0);
1668 CorrectShadeLabel();
1669 } break;
1670 }
1671 /*
1672 Mark correction as done
1673 */
1674 bIsCorrecting = false;
1675 /*
1676 Update result color viewer and dialog window
1677 */
1678 SetRgbTextLabels();
1679 colourViewResult->SetRGB(r, g, b);
1680 Refresh();
1681 Update();
1682 }
1683
1684 }
1685
1686
1687
1688 int
Red(void) const1689 Dk4WxColourPalette::Red(void) const
1690 {
1691 return r;
1692 }
1693
1694
1695
1696 int
Green(void) const1697 Dk4WxColourPalette::Green(void) const
1698 {
1699 return g;
1700 }
1701
1702
1703
1704 int
Blue(void) const1705 Dk4WxColourPalette::Blue(void) const
1706 {
1707 return b;
1708 }
1709
1710
1711
Dk4WxColourPaletteItem()1712 Dk4WxColourPalette::Dk4WxColourPaletteItem::Dk4WxColourPaletteItem()
1713 {
1714 pParentWindow = NULL;
1715 pAppHelp = NULL;
1716 w = h = -1;
1717 r = g = b = 255;
1718 }
1719
1720
1721
Dk4WxColourPaletteItem(wxWindow * pParent,wxWindowID wxid,Dk4WxColourPalette * pal,Dk4WxApplicationHelper * appHelper,int red,int green,int blue,wxPoint const & pos,wxSize const & size,long style,wxChar const * name)1722 Dk4WxColourPalette::Dk4WxColourPaletteItem::Dk4WxColourPaletteItem(
1723 wxWindow *pParent,
1724 wxWindowID wxid,
1725 Dk4WxColourPalette *pal,
1726 Dk4WxApplicationHelper *appHelper,
1727 int red,
1728 int green,
1729 int blue,
1730 wxPoint const & pos,
1731 wxSize const & size,
1732 long style,
1733 wxChar const *name
1734 )
1735 : wxControl(
1736 pParent, wxid, pos, size, style, wxDefaultValidator,
1737 wxString(name)
1738 )
1739 {
1740
1741 pParentWindow = pal;
1742 pAppHelp = appHelper;
1743 w = h = -1;
1744 r = red;
1745 g = green;
1746 b = blue;
1747 }
1748
1749
1750
1751 bool
Create(wxWindow * pParent,wxWindowID wxid,Dk4WxColourPalette * pal,Dk4WxApplicationHelper * appHelper,int red,int green,int blue,wxPoint const & pos,wxSize const & size,long style,wxChar const * name)1752 Dk4WxColourPalette::Dk4WxColourPaletteItem::Create(
1753 wxWindow *pParent,
1754 wxWindowID wxid,
1755 Dk4WxColourPalette *pal,
1756 Dk4WxApplicationHelper *appHelper,
1757 int red,
1758 int green,
1759 int blue,
1760 wxPoint const & pos,
1761 wxSize const & size,
1762 long style,
1763 wxChar const *name
1764 )
1765 {
1766 bool back = wxControl::Create(
1767 pParent, wxid, pos, size, style, wxDefaultValidator,
1768 wxString(name)
1769 );
1770 pParentWindow = pal;
1771 pAppHelp = appHelper;
1772 w = h = -1;
1773 r = red;
1774 g = green;
1775 b = blue;
1776 return back;
1777 }
1778
1779
1780
1781 wxSize
DoGetBestSize() const1782 Dk4WxColourPalette::Dk4WxColourPaletteItem::DoGetBestSize() const
1783 {
1784 wxSize back(((-1 < w) ? w : 25), ((-1 < h) ? h : 25));
1785 return back;
1786 }
1787
1788
1789
1790 void
OnErase(wxEraseEvent & WXUNUSED (event))1791 Dk4WxColourPalette::Dk4WxColourPaletteItem::OnErase(wxEraseEvent & WXUNUSED(event))
1792 {
1793
1794 }
1795
1796
1797
1798 void
OnPaint(wxPaintEvent & WXUNUSED (event))1799 Dk4WxColourPalette::Dk4WxColourPaletteItem::OnPaint(wxPaintEvent & WXUNUSED(event))
1800 {
1801 wxBufferedPaintDC useDC(this);
1802 wxSize sz = GetClientSize();
1803 wxColour mycolor(
1804 (unsigned char)r,
1805 (unsigned char)g,
1806 (unsigned char)b
1807 );
1808 #if wxCHECK_VERSION(3,0,0)
1809 wxBrush myBrush(mycolor, wxBRUSHSTYLE_SOLID);
1810 #else
1811 wxBrush myBrush(mycolor, wxSOLID);
1812 #endif
1813 const wxBrush oldBrus = useDC.GetBrush();
1814 useDC.SetBrush(myBrush);
1815 useDC.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight());
1816 useDC.SetBrush(wxNullBrush);
1817 }
1818
1819
1820
1821 void
OnLeftMouseButtonDown(wxMouseEvent & WXUNUSED (event))1822 Dk4WxColourPalette::Dk4WxColourPaletteItem::OnLeftMouseButtonDown(
1823 wxMouseEvent & WXUNUSED(event)
1824 )
1825 {
1826 if (NULL != pParentWindow) {
1827 pParentWindow->SetBaseRGB(r, g, b);
1828 }
1829 }
1830
1831
1832
1833 int
GetDialogStyle(bool bBorder,bool bTitle)1834 Dk4WxColourPalette::GetDialogStyle(bool bBorder, bool bTitle)
1835 {
1836 int back = wxDEFAULT_DIALOG_STYLE;
1837
1838 back &= (~(wxCLOSE_BOX));
1839 back &= (~(wxSYSTEM_MENU));
1840 if (!(bBorder)) {
1841 back &= (~(wxRESIZE_BORDER));
1842 }
1843 if (!(bTitle)) {
1844 back &= (~(wxCAPTION));
1845 }
1846 return back;
1847 }
1848
1849
1850
1851
1852
1853 /* vim: set ai sw=4 ts=4 : */
1854
1855