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.h Header file for the Dk4WxColourPalette module.
15 */
16 
17 #ifndef DK4WXCOLOURPALETTE_H_INCLUDED
18 /** Avoid multiple inclusions. */
19 #define DK4WXCOLOURPALETTE_H_INCLUDED 1
20 
21 
22 #ifndef DK4CONF_H_INCLUDED
23 #if DK4_BUILDING_DKTOOLS4
24 #include "dk4conf.h"
25 #else
26 #include <dktools-4/dk4conf.h>
27 #endif
28 #endif
29 
30 #ifndef WX_WXPREC_H_INCLUDED
31 #include <wx/wxprec.h>
32 #define	WX_WXPREC_H_INCLUDED 1
33 #endif
34 
35 #ifdef __BORLANDC__
36 #pragma hdrstop
37 #endif
38 
39 #ifndef WX_PRECOMP
40 #ifndef WX_WX_H_INCLUDED
41 #include <wx/wx.h>
42 #define	WX_WX_H_INCLUDED 1
43 #endif
44 #endif
45 
46 #ifndef WX_GBSIZER_H_INCLUDED
47 #include <wx/gbsizer.h>
48 #define	WX_GBSIZER_H_INCLUDED 1
49 #endif
50 
51 #ifndef	WX_BOOKCTRL_H_INCLUDED
52 #include <wx/bookctrl.h>
53 #define	WX_BOOKCTRL_H_INCLUDED 1
54 #endif
55 
56 #ifndef	WX_CHOICEBK_H_INCLUDED
57 #include <wx/choicebk.h>
58 #define	WX_CHOICEBK_H_INCLUDED 1
59 #endif
60 
61 #ifndef	WX_STATBOX_H_INCLUDED
62 #include <wx/statbox.h>
63 #define	WX_STATBOX_H_INCLUDED 1
64 #endif
65 
66 #ifndef DK4WXAPPLICTIONHELPER_H_INCLUDED
67 #if DK4_BUILDING_DKTOOLS4
68 #include <libdk4wx/Dk4WxApplicationHelper.h>
69 #else
70 #include <dktools-4/Dk4WxApplicationHelper.h>
71 #endif
72 #endif
73 
74 #ifndef	DK4WXCOLOURVIEW_H_INCLUDED
75 #if DK4_BUILDING_DKTOOLS4
76 #include <libdk4wx/Dk4WxColourView.h>
77 #else
78 #include <dktools-4/Dk4WxColourView.h>
79 #endif
80 #endif
81 
82 
83 /**	Color palette allowing to choose between predefined colours.
84 */
85 class Dk4WxColourPalette : public wxDialog
86 {
87 	/**	Item in a colour palette.
88 	*/
89 	class Dk4WxColourPaletteItem : public wxControl
90 	{
91 		/**	Class is dynamic.
92 		*/
93 #if	wxCHECK_VERSION(3,0,0)
94 		wxDECLARE_DYNAMIC_CLASS(Dk4WxColourPaletteItem);
95 #else
96 		DECLARE_DYNAMIC_CLASS(Dk4WxColourPaletteItem)
97 #endif
98 
99 		/**	Event table for control.
100 		*/
101 #if wxCHECK_VERSION(3,0,0)
102 		wxDECLARE_EVENT_TABLE();
103 #else
104 		DECLARE_EVENT_TABLE()
105 #endif
106 
107 	protected:
108 
109 		/**	Parent dialog we have to notify about color change.
110 		*/
111 		Dk4WxColourPalette		*pParentWindow;
112 
113 		/**	Application helper.
114 		*/
115 		Dk4WxApplicationHelper	*pAppHelp;
116 
117 		/**	Class name, used in constructor and Create().
118 		*/
119 		static wxChar const		 Dk4WxColourPaletteItemName[];
120 
121 		/**	Height.
122 		*/
123 		int						 w;
124 
125 		/**	Width.
126 		*/
127 		int						 h;
128 
129 		/**	Red component of color to show.
130 		*/
131 		int						 r;
132 
133 		/**	Green component of color to show.
134 		*/
135 		int						 g;
136 
137 		/**	Blue component of color to show.
138 		*/
139 		int						 b;
140 
141 	public:
142 
143 		/**	Default constructor.
144 		*/
145 		Dk4WxColourPaletteItem();
146 
147 		/**	Constructor.
148 			@param	pParent		Parent window.
149 			@param	wxid		Window ID.
150 			@param	appHelper	Application helper.
151 			@param	red	Red 	component of color to show.
152 			@param	green		Green component of color to show.
153 			@param	blue		Blue component of color to show.
154 			@param	pos			Object position.
155 			@param	size		Object minimum size.
156 			@param	style		Style for control.
157 			@param	name		Class name.
158 		*/
159 		Dk4WxColourPaletteItem(
160 			wxWindow				*pParent,
161 			wxWindowID				 wxid,
162 			Dk4WxColourPalette		*pal,
163 			Dk4WxApplicationHelper	*appHelper,
164 			int						 red,
165 			int						 green,
166 			int						 blue,
167 			wxPoint const &			 pos	= wxDefaultPosition,
168 			wxSize  const &			 size	= wxDefaultSize,
169 			long					 style	= wxBORDER_NONE,
170 			wxChar const			*name	= Dk4WxColourPaletteItemName
171 		);
172 
173 		/**	Create object after using default constructor.
174 			@param	pParent		Parent window.
175 			@param	wxid		Window ID.
176 			@param	appHelper	Application helper.
177 			@param	red	Red 	component of color to show.
178 			@param	green		Green component of color to show.
179 			@param	blue		Blue component of color to show.
180 			@param	pos			Object position.
181 			@param	size		Object minimum size.
182 			@param	style		Style for control.
183 			@param	name		Class name.
184 			@return	true on success, false on error.
185 		*/
186 		bool
187 		Create(
188 			wxWindow				*pParent,
189 			wxWindowID				 wxid,
190 			Dk4WxColourPalette		*pal,
191 			Dk4WxApplicationHelper	*appHelper,
192 			int						 red	= 255,
193 			int						 green	= 255,
194 			int						 blue	= 255,
195 			wxPoint const &			 pos	= wxDefaultPosition,
196 			wxSize  const &			 size	= wxDefaultSize,
197 			long					 style	= wxBORDER_NONE,
198 			wxChar const			*name	= Dk4WxColourPaletteItemName
199 		);
200 
201 		/**	Find minimum size.
202 		*/
203 		wxSize
204 		DoGetBestSize() const;
205 
206 		/**	Handler for erase event.
207 			@param	event	Event to process.
208 		*/
209 		void
210 		OnErase(wxEraseEvent & event);
211 
212 		/**	Handler for paint event.
213 			@param	event	Event to process.
214 		*/
215 		void
216 		OnPaint(wxPaintEvent & event);
217 
218 		/**	Handler for mouse click event.
219 			@param	event	Event to process.
220 		*/
221 		void
222 		OnLeftMouseButtonDown(wxMouseEvent & event);
223 
224 	};
225 
226 private:
227 
228 	/**	Events we have to respond to.
229 	*/
230 #if	wxCHECK_VERSION(3,0,0)
231 	wxDECLARE_EVENT_TABLE();
232 #else
233 	DECLARE_EVENT_TABLE()
234 #endif
235 
236 protected:
237 
238 	/**	Red colour for text labels.
239 	*/
240 	wxColour				 colourRed;
241 
242 	/**	Green colour for text labels.
243 	*/
244 	wxColour				 colourGreen;
245 
246 	/**	Blue colour for text labels.
247 	*/
248 	wxColour				 colourBlue;
249 
250 	/**	Application helper.
251 	*/
252 	Dk4WxApplicationHelper	*pAppHelp;
253 
254 	/**	Localized texts.
255 	*/
256 	wxChar const * const	*localizedTexts;
257 
258 	/**	Shade slider value -20 to 20.
259 	*/
260 	int						 slvshade;
261 
262 	/**	Red slider value 0 to 5.
263 	*/
264 	int						 slvred;
265 
266 	/**	Green slider value 0 to 5.
267 	*/
268 	int						 slvgreen;
269 
270 	/**	Blue slider value 0 to 5.
271 	*/
272 	int						 slvblue;
273 
274 	/**	Index of selected list item.
275 	*/
276 	int						 listSelection;
277 
278 	/**	Base red component, not shaded.
279 	*/
280 	int						 rb;
281 
282 	/**	Base green component, not shaded.
283 	*/
284 	int						 gb;
285 
286 	/**	Base blue component, not shaded.
287 	*/
288 	int						 bb;
289 
290 	/**	Result red component.
291 	*/
292 	int						 r;
293 
294 	/**	Result green component.
295 	*/
296 	int						 g;
297 
298 	/**	Result blue component.
299 	*/
300 	int						 b;
301 
302 	/**	Flag: Already in correction process.
303 	*/
304 	bool					 bIsCorrecting;
305 
306     /**	Flag: GUI ok.
307     */
308     bool dkctGUILayoutOK;
309 
310     /**	GUI element mainSizerHorizontal.
311     */
312     wxBoxSizer *mainSizerHorizontal;
313 
314     /**	GUI element mainSizerVertical.
315     */
316     wxBoxSizer *mainSizerVertical;
317 
318     /**	GUI element choiceBookInput.
319     */
320     wxChoicebook *choiceBookInput;
321 
322     /**	GUI element resultSizerHexadecimal.
323     */
324     wxBoxSizer *resultSizerHexadecimal;
325 
326     /**	GUI element resultSizerDecimal.
327     */
328     wxBoxSizer *resultSizerDecimal;
329 
330     /**	GUI element colourViewResult.
331     */
332     Dk4WxColourView *colourViewResult;
333 
334     /**	GUI element buttonsDialog.
335     */
336     wxStdDialogButtonSizer *buttonsDialog;
337 
338     /**	GUI element panelFig.
339     */
340     wxPanel *panelFig;
341 
342     /**	GUI element panelHtmlNamed.
343     */
344     wxPanel *panelHtmlNamed;
345 
346     /**	GUI element panelHtml216.
347     */
348     wxPanel *panelHtml216;
349 
350     /**	GUI element figSizerHorizontal.
351     */
352     wxBoxSizer *figSizerHorizontal;
353 
354     /**	GUI element figSizerVertical.
355     */
356     wxBoxSizer *figSizerVertical;
357 
358     /**	GUI element figButtonRow0.
359     */
360     wxBoxSizer *figButtonRow0;
361 
362     /**	GUI element figButtonRow1.
363     */
364     wxBoxSizer *figButtonRow1;
365 
366     /**	GUI element figButtonRow2.
367     */
368     wxBoxSizer *figButtonRow2;
369 
370     /**	GUI element figButtonRow3.
371     */
372     wxBoxSizer *figButtonRow3;
373 
374     /**	GUI element figShaderLabelSizer.
375     */
376     wxBoxSizer *figShaderLabelSizer;
377 
378     /**	GUI element figShaderSlider.
379     */
380     wxSlider *figShaderSlider;
381 
382     /**	GUI element b00.
383     */
384     Dk4WxColourPaletteItem *b00;
385 
386     /**	GUI element b01.
387     */
388     Dk4WxColourPaletteItem *b01;
389 
390     /**	GUI element b02.
391     */
392     Dk4WxColourPaletteItem *b02;
393 
394     /**	GUI element b03.
395     */
396     Dk4WxColourPaletteItem *b03;
397 
398     /**	GUI element b04.
399     */
400     Dk4WxColourPaletteItem *b04;
401 
402     /**	GUI element b05.
403     */
404     Dk4WxColourPaletteItem *b05;
405 
406     /**	GUI element b06.
407     */
408     Dk4WxColourPaletteItem *b06;
409 
410     /**	GUI element b07.
411     */
412     Dk4WxColourPaletteItem *b07;
413 
414     /**	GUI element b08.
415     */
416     Dk4WxColourPaletteItem *b08;
417 
418     /**	GUI element b09.
419     */
420     Dk4WxColourPaletteItem *b09;
421 
422     /**	GUI element b10.
423     */
424     Dk4WxColourPaletteItem *b10;
425 
426     /**	GUI element b11.
427     */
428     Dk4WxColourPaletteItem *b11;
429 
430     /**	GUI element b12.
431     */
432     Dk4WxColourPaletteItem *b12;
433 
434     /**	GUI element b13.
435     */
436     Dk4WxColourPaletteItem *b13;
437 
438     /**	GUI element b14.
439     */
440     Dk4WxColourPaletteItem *b14;
441 
442     /**	GUI element b15.
443     */
444     Dk4WxColourPaletteItem *b15;
445 
446     /**	GUI element b16.
447     */
448     Dk4WxColourPaletteItem *b16;
449 
450     /**	GUI element b17.
451     */
452     Dk4WxColourPaletteItem *b17;
453 
454     /**	GUI element b18.
455     */
456     Dk4WxColourPaletteItem *b18;
457 
458     /**	GUI element b19.
459     */
460     Dk4WxColourPaletteItem *b19;
461 
462     /**	GUI element b20.
463     */
464     Dk4WxColourPaletteItem *b20;
465 
466     /**	GUI element b21.
467     */
468     Dk4WxColourPaletteItem *b21;
469 
470     /**	GUI element b22.
471     */
472     Dk4WxColourPaletteItem *b22;
473 
474     /**	GUI element b23.
475     */
476     Dk4WxColourPaletteItem *b23;
477 
478     /**	GUI element b24.
479     */
480     Dk4WxColourPaletteItem *b24;
481 
482     /**	GUI element b25.
483     */
484     Dk4WxColourPaletteItem *b25;
485 
486     /**	GUI element b26.
487     */
488     Dk4WxColourPaletteItem *b26;
489 
490     /**	GUI element b27.
491     */
492     Dk4WxColourPaletteItem *b27;
493 
494     /**	GUI element b28.
495     */
496     Dk4WxColourPaletteItem *b28;
497 
498     /**	GUI element b29.
499     */
500     Dk4WxColourPaletteItem *b29;
501 
502     /**	GUI element b30.
503     */
504     Dk4WxColourPaletteItem *b30;
505 
506     /**	GUI element b31.
507     */
508     Dk4WxColourPaletteItem *b31;
509 
510     /**	GUI element figShaderLabelText.
511     */
512     wxStaticText *figShaderLabelText;
513 
514     /**	GUI element htmlNamedSizerHorizontal.
515     */
516     wxBoxSizer *htmlNamedSizerHorizontal;
517 
518     /**	GUI element htmlNamedSizerVertical.
519     */
520     wxBoxSizer *htmlNamedSizerVertical;
521 
522     /**	GUI element listHtmlNames.
523     */
524     wxListBox *listHtmlNames;
525 
526     /**	GUI element html216SizerHorizontal.
527     */
528     wxBoxSizer *html216SizerHorizontal;
529 
530     /**	GUI element html216SizerVertical.
531     */
532     wxBoxSizer *html216SizerVertical;
533 
534     /**	GUI element labelHtml216Red.
535     */
536     wxStaticText *labelHtml216Red;
537 
538     /**	GUI element sliderHtml216Red.
539     */
540     wxSlider *sliderHtml216Red;
541 
542     /**	GUI element labelHtml216Green.
543     */
544     wxStaticText *labelHtml216Green;
545 
546     /**	GUI element sliderHtml216Green.
547     */
548     wxSlider *sliderHtml216Green;
549 
550     /**	GUI element labelHtml216Blue.
551     */
552     wxStaticText *labelHtml216Blue;
553 
554     /**	GUI element sliderHtml216Blue.
555     */
556     wxSlider *sliderHtml216Blue;
557 
558     /**	GUI element hexRed.
559     */
560     wxStaticText *hexRed;
561 
562     /**	GUI element hexGreen.
563     */
564     wxStaticText *hexGreen;
565 
566     /**	GUI element hexBlue.
567     */
568     wxStaticText *hexBlue;
569 
570     /**	GUI element decRed.
571     */
572     wxStaticText *decRed;
573 
574     /**	GUI element decGreen.
575     */
576     wxStaticText *decGreen;
577 
578     /**	GUI element decBlue.
579     */
580     wxStaticText *decBlue;
581 
582     /**	GUI element buttonOK.
583     */
584     wxButton *buttonOK;
585 
586     /**	GUI element buttonCancel.
587     */
588     wxButton *buttonCancel;
589 
590 
591 protected:
592 
593 	/**	Correct shade label.
594 	*/
595 	void
596 	CorrectShadeLabel(void);
597 
598 	/**	Shade a color.
599 		@param	val	Original value.
600 		@return	Shaded color value.
601 	*/
602 	int
603 	ShadeColour(int val);
604 
605 	/**	Correct appearance after using controls.
606 		@param	reason	Which control was used.
607 	*/
608 	void
609 	CorrectGui(int reason);
610 
611 	/**	Set the R, G, B text labels for the r, g, b variables.
612 	*/
613 	void
614 	SetRgbTextLabels(void);
615 
616 	/**	Find RGB slider value next to a given color value.
617 	*/
618 	int
619 	FindSliderValue(int colval);
620 
621 	/**	Find slider values next to the r, g, b variables.
622 	*/
623 	void
624 	FindRgbSliderValues(void);
625 
626 	/**	Find list box entry next to the r, g, b variables.
627 	*/
628 	void
629 	FindListBoxEntry(void);
630 
631 public:
632 
633 	/**	Our IDs.
634 	*/
635 	enum {
636 
637 		/**	ID of choicebook change.
638 		*/
639 		ID_CHOICEBOOK	=	((wxID_HIGHEST) + 1) ,
640 
641 		/**	ID of XFig shade slider.
642 		*/
643 		ID_SLIDER_SHADE ,
644 
645 		/**	ID of HTML named colors list control.
646 		*/
647 		ID_HTML_NAMED_LIST ,
648 
649 		/**	ID of HTML 216 red slider.
650 		*/
651 		ID_SLIDER_RED ,
652 
653 		/**	ID of HTML 216 green slider.
654 		*/
655 		ID_SLIDER_GREEN ,
656 
657 		/**	ID of HTML 216 blue slider.
658 		*/
659 		ID_SLIDER_BLUE
660 	};
661 
662 	/**	Reasons for GUI corrections.
663 	*/
664 	enum {
665 							/**	New page selected in choice book.
666 							*/
667 		REASON_CHOICEBOOK	= 0 ,
668 
669 							/**	Base colors changed.
670 							*/
671 		REASON_BASE_COLOR ,
672 
673 							/**	Shade slider changed.
674 							*/
675 		REASON_SHADE_SLIDER ,
676 
677 							/**	List selection changed.
678 							*/
679 		REASON_LIST_SELECT ,
680 
681 							/**	RGB slider changed.
682 							*/
683 		REASON_RGB_SLIDER
684 	};
685 
686 	/**	Default constructor.
687 	*/
688 	Dk4WxColourPalette();
689 
690 	/**	Real constructor.
691 		@param	pParent		Parent window.
692 		@param	pAppHelper	Application helper.
693 		@param	red			Initial red component.
694 		@param	green		Initial green component.
695 		@param	blue		Initial blue component.
696 		@param	withborder	Flag: Show border around dialog box.
697 	*/
698 	Dk4WxColourPalette(
699 		wxWindow				*pParent,
700 		Dk4WxApplicationHelper	*pAppHelper,
701 		int						 red,
702 		int						 green,
703 		int						 blue,
704 		bool					 withborder = true
705 	);
706 
707 	/**	Handler for OK button.
708 		@param	event	Event to respond to, unused.
709 	*/
710 	void
711 	OnOK(wxCommandEvent & event);
712 
713 	/**	Handler for Cancel button.
714 		@param	event	Event to respond to, unused.
715 	*/
716 	void
717 	OnCancel(wxCommandEvent & event);
718 
719 	/**	Handler for shade slider events.
720 		@param	event	Event to respond to, unused.
721 	*/
722 	void
723 	OnShadeSlider(wxCommandEvent & event);
724 
725 	/**	Handler for RGB slider events.
726 		@param	event	Event to respond to, unused.
727 	*/
728 	void
729 	OnRgbSlider(wxCommandEvent & event);
730 
731 #if	wxCHECK_VERSION(3,0,0)
732 	/**	Handler for changed choicebook page.
733 		@param	event	Event to respond to, unused
734 	*/
735 	void
736 	OnChoicebookChanged(wxBookCtrlEvent & event);
737 #else
738 	/**	Handler for changed choicebook page.
739 		@param	event	Event to respond to, unused
740 	*/
741 	void
742 	OnChoicebookChanged(wxChoicebookEvent & event);
743 #endif
744 
745 	/**	Handler for changed selection on list box.
746 		@param	event	Event to respond to, unused.
747 	*/
748 	void
749 	OnListBoxChanged(wxCommandEvent & event);
750 
751 	/**	Retrieve red component.
752 		@return	Red value.
753 	*/
754 	int
755 	Red(void) const;
756 
757 	/**	Retrieve green component.
758 		@return	Green value.
759 	*/
760 	int
761 	Green(void) const;
762 
763 	/**	Retrieve blue component.
764 		@return	Blue value.
765 	*/
766 	int
767 	Blue(void) const;
768 
769 	/**	React on Dk4WxColourPaletteItem click.
770 		@param	red		New base red component.
771 		@param	green	New base green component.
772 		@param	blue	New base blue component.
773 	*/
774 	void
775 	SetBaseRGB(int red, int green, int blue);
776 
777 	/**	Construct a dialog style value.
778 		@param	bBorder	Flag: Draw border.
779 		@param	bTitle	Flag: Title bar on dialog.
780 	*/
781 	static
782 	int
783 	GetDialogStyle(bool bBorder = true, bool bTitle = true);
784 
785 };
786 
787 
788 
789 
790 #endif
791