Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGColorDialog.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id: c1ecfb3a4b91442ae3b6fe3059ae838e463f2f56 $
2// Author: Bertrand Bellenot + Fons Rademakers 22/08/02
3// Author: Ilka Antcheva (color wheel support) 16/03/07
4
5/*************************************************************************
6 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12/**************************************************************************
13
14 This source is based on Xclass95, a Win95-looking GUI toolkit.
15 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
16
17 Xclass95 is free software; you can redistribute it and/or
18 modify it under the terms of the GNU Library General Public
19 License as published by the Free Software Foundation; either
20 version 2 of the License, or (at your option) any later version.
21
22**************************************************************************/
23
24
25/** \class TGColorPalette
26 \ingroup guiwidgets
27
28A widget showing an matrix of color cells. The colors can be set and selected.
29
30*/
31
32
33/** \class TGColorPick
34 \ingroup guiwidgets
35
36A widget which allows a color to be picked from HLS color space.
37It consists of two elements: a color map window from
38where the user can select the hue and saturation level of a color,
39and a slider to select color's lightness.
40
41Selecting a color in these two widgets will generate the event:
42 - kC_COLORSEL, kCOL_CLICK, widget id, 0.
43
44and the signal:
45 - ColorSelected(Pixel_t color)
46
47*/
48
49
50/** \class TGColorDialog
51 \ingroup guiwidgets
52
53A full featured color selection dialog.
54It uses 2 TGColorPalette's and the TGColorPick widgets.
55
56*/
57
58#include "TGLabel.h"
59#include "TGMsgBox.h" // for ID_OK, ID_CANCEL
60#include "TGLayout.h"
61#include "TGGC.h"
62#include "KeySymbols.h"
63#include "TGColorDialog.h"
64#include "TGTextEntry.h"
65#include "TGButton.h"
66#include "TGResourcePool.h"
67#include "TColor.h"
68#include "TColorWheel.h"
69#include "TGColorSelect.h"
70#include "TGTab.h"
71#include "TRootEmbeddedCanvas.h"
72#include "TCanvas.h"
73#include "TROOT.h"
74#include "TMath.h"
75#include "TVirtualX.h"
76
77#include <cstdio>
78#include <cstdlib>
79
80// TODO:
81// - implement "custom" colors.
82// - optimize the code, specially the one handling the fColormap image
83// and dithering in pseudo-color modes; remove duplicated code.
84// - improve the color allocation routine.
85// - use a buffering pixmap for the fColormap image.
86
105
111
116
117// "User" defined colors
118
119static ULong_t gUcolor[24] = { 0xff000000 };
120
121
122////////////////////////////////////////////////////////////////////////////////
123/// TGColorPalette widget: this is just a grid of color cells of the
124/// specified size. Colors can be selected by clicking on them or by
125/// using the arrow keys.
126
128 TGFrame(p, 10, 10, kChildFrame)
129{
130 fWidgetId = id;
132 fMsgWindow = p;
133 fDrawGC = *fClient->GetResourcePool()->GetFrameGC();
134
135 fCw = 20;
136 fCh = 17;
137
138 fRows = rows;
139 fCols = cols;
140
141 fCx = fCy = 0;
142
143 fPixels = new ULong_t[fRows * fCols];
144
145 for (Int_t i = 0; i < fRows * fCols; ++i) {
146 fPixels[i] = TColor::RGB2Pixel(255, 255, 255);
147 }
148
149 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
152
156}
157
158////////////////////////////////////////////////////////////////////////////////
159/// Destructor.
160
162{
163 delete [] fPixels;
164}
165
166////////////////////////////////////////////////////////////////////////////////
167/// Handle button events in color palette
168
170{
171 if (event->fCode != kButton1)
172 return kFALSE;
173
174 if ((event->fType == kButtonPress) && HasFocus())
175 WantFocus();
176
177 Int_t cx = event->fX / (fCw + 5);
178 Int_t cy = event->fY / (fCh + 5);
179
180 if (cx >= 0 && cx < fCols && cy >= 0 && cy < fRows) {
181
183
184 fCx = cx;
185 fCy = cy;
186
188
191 }
192
193 return kTRUE;
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Handle mouse motion events in color palette.
198
200{
201 if (!IsEnabled())
202 return kTRUE;
203
204 Int_t cx = event->fX / (fCw + 5);
205 Int_t cy = event->fY / (fCh + 5);
206
207 if (cx >= 0 && cx < fCols && cy >= 0 && cy < fRows) {
208
210
211 fCx = cx;
212 fCy = cy;
213
215
218 }
219
220 return kTRUE;
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Handle keyboard events in color palette.
225
227{
228 Char_t input[10];
230
231 if (event->fType == kGKeyPress) {
232
233 gVirtualX->LookupString(event, input, sizeof(input), keysym);
234
235 Int_t cx = fCx;
236 Int_t cy = fCy;
237
238 switch ((EKeySym)keysym) {
239 case kKey_Left:
240 if (cx > 0) --cx;
241 break;
242
243 case kKey_Right:
244 if (cx < fCols - 1) ++cx;
245 break;
246
247 case kKey_Up:
248 if (cy > 0) --cy;
249 break;
250
251 case kKey_Down:
252 if (cy < fRows - 1) ++cy;
253 break;
254
255 case kKey_Home:
256 cx = cy = 0;
257 break;
258
259 case kKey_End:
260 cx = fCols - 1;
261 cy = fRows - 1;
262 break;
263
264 default:
265 break;
266 }
267
268 if (cx != fCx || cy != fCy) {
269
271
272 fCx = cx;
273 fCy = cy;
274
276
279 }
280 }
281
282 return kTRUE;
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Set color entries in color samples.
287
289{
290 for (Int_t i = 0; i < fRows * fCols; ++i)
291 SetColor(i, colors[i]);
292 gClient->NeedRedraw(this);
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Set color at index ix of color entries.
297
299{
300 fPixels[ix] = color;
301 gClient->NeedRedraw(this);
302}
303
304////////////////////////////////////////////////////////////////////////////////
305/// Set current cell color.
306
308{
309 SetColor(fCy * fCols + fCx, color);
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Set color cell size.
314
316{
317 fCw = w;
318 fCh = h;
319 gClient->NeedRedraw(this);
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Return currently selected color value.
324
326{
327 if (fCx >= 0 && fCy >= 0)
328 return GetColorByIndex(fCy * fCols + fCx);
329 else
330 return TColor::RGB2Pixel(0, 0, 0);
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Redraw color palette.
335
337{
338 Int_t i, j, k, x, y;
339
340 k = 0;
341 y = 2;
342 for (i = 0; i < fRows; ++i) {
343 x = 2;
344 for (j = 0; j < fCols; ++j) {
347 gVirtualX->FillRectangle(fId, fDrawGC(), x + 2, y + 2, fCw - 4, fCh - 4);
348 x += fCw + 5;
349 }
350 y += fCh + 5;
351 }
352
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Add keyboard input.
358
363
364////////////////////////////////////////////////////////////////////////////////
365/// Remove keyboard input.
366
368{
370 gClient->NeedRedraw(this);
371}
372
373////////////////////////////////////////////////////////////////////////////////
374/// Draw a highlight rectangle around cell obtaining focus.
375
377{
378 if (fCx >= 0 && fCy >= 0) {
380 gVirtualX->DrawRectangle(fId, gc, fCx * (fCw + 5) + 0, fCy * (fCh + 5) + 0,
381 fCw + 3, fCh + 3);
382 }
383}
384
385
386////////////////////////////////////////////////////////////////////////////////
387/// TGColorPick constructor.
388/// TGColorPick is a widget which allows a color to be picked from HLS space.
389/// It consists of two elements: a color map window from where the user can
390/// select the hue and saturation level of a color, and a slider to select
391/// color's lightness.
392
394 TGFrame(p, w, h, kChildFrame), fCursorGC(GetBlackGC())
395{
396 UInt_t iw, ih;
397
398 fWidgetId = id;
400 fMsgWindow = p;
401
402 fColormapRect.fX = 1;
403 fColormapRect.fY = 1;
404 fColormapRect.fWidth = w - 33 - 2;
405 fColormapRect.fHeight = h - 2;
406 fSliderRect.fX = w - 18 - 2;
407 fSliderRect.fY = 1;
408 fSliderRect.fWidth = 10;
409 fSliderRect.fHeight = h - 2;
410
411 fNColors = 0;
412
413 if (!p) {
414 MakeZombie();
415 // coverity[uninit_member]
416 return;
417 }
418 CreateImages();
419 gVirtualX->GetImageSize(fLimage, iw, ih);
420
421 fCx = 0;
422 fCy = 0;
423 fCz = (Int_t)ih / 2;
424
426
428 InitImages();
429
430 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
433
437}
438
439////////////////////////////////////////////////////////////////////////////////
440/// TGColorPick destructor.
441
443{
444 if (IsZombie()) return;
445 gVirtualX->DeleteImage(fHSimage);
446 gVirtualX->DeleteImage(fLimage);
447 FreeColors();
448}
449
450////////////////////////////////////////////////////////////////////////////////
451/// Handle mouse button events in color pick widget.
452
454{
455 if (event->fCode != kButton1) return kFALSE;
456
457 if (event->fType == kButtonPress) {
458 if ((event->fX > fColormapRect.fX) && (event->fX < fColormapRect.fX + fColormapRect.fWidth) &&
460
463
464 } else if (event->fX > fSliderRect.fX) {
465
468
469 }
470 } else { // ButtonRelease
471
473
474 }
475
478
481
482 return kTRUE;
483}
484
485////////////////////////////////////////////////////////////////////////////////
486/// Handle mouse motion events in color pick widget.
487
489{
490 if (!IsEnabled())
491 return kTRUE;
492
493 if (fClick == kCLICK_HS) {
494
496
497 } else if (fClick == kCLICK_L) {
498
500
501 } else {
502
503 return kTRUE;
504
505 }
506
509
512
513 return kTRUE;
514}
515
516////////////////////////////////////////////////////////////////////////////////
517/// Create colormap and color slider images.
518
530
531////////////////////////////////////////////////////////////////////////////////
532/// Try to allocate first a palette of 64 colors. Used by the dithered
533/// version of the color maps.
534
536{
537 ColorStruct_t color;
538 Int_t i;
539
540 for (i = 0; i < 64; ++i) {
541 Int_t cc[4] = { 0, 21845, 43691, 65535 };
542 color.fPixel = 0;
543 color.fRed = cc[i & 0x3];
544 color.fGreen = cc[(i >> 2) & 0x3];
545 color.fBlue = cc[(i >> 4) & 0x3];
546 if (gVirtualX->AllocColor(gVirtualX->GetColormap(), color) == 0)
547 break;
548 fColormap[i][0] = color.fRed / 256;
549 fColormap[i][1] = color.fGreen / 256;
550 fColormap[i][2] = color.fBlue / 256;
551 fPixel[i] = color.fPixel;
552 }
553
554 fNColors = i;
555 if (fNColors == 64) return; // success
556
557 // Failed, try a simpler 27-color.
558
559 FreeColors();
560
561 for (i = 0; i < 27; ++i) {
562 Int_t cc[3] = { 0, 32768, 65535 };
563 color.fPixel = 0;
564 color.fRed = cc[i % 3];
565 color.fGreen = cc[(i / 3) % 3];
566 color.fBlue = cc[(i / 9) % 3];
567 if (gVirtualX->AllocColor(gVirtualX->GetColormap(), color) == 0)
568 break;
569 fColormap[i][0] = color.fRed / 256;
570 fColormap[i][1] = color.fGreen / 256;
571 fColormap[i][2] = color.fBlue / 256;
572 fPixel[i] = color.fPixel;
573 }
574
575 fNColors = i;
576 if (fNColors == 27) return; // success
577
578 // Failed, try then a much simpler 8-color.
579
580 FreeColors();
581
582 for (i = 0; i < 8; ++i) {
583 color.fPixel = 0;
584 color.fRed = (i & 1) * 65535;
585 color.fGreen = ((i >> 1) & 1) * 65535;
586 color.fBlue = ((i >> 2) & 1) * 65535;
587 if (gVirtualX->AllocColor(gVirtualX->GetColormap(), color) == 0)
588 break;
589 fColormap[i][0] = color.fRed / 256;
590 fColormap[i][1] = color.fGreen / 256;
591 fColormap[i][2] = color.fBlue / 256;
592 fPixel[i] = color.fPixel;
593 }
594
595 fNColors = i;
596 if (fNColors == 8) return; // success
597
598 // Failed, try to get at least 8 closest colors...
599 // (TODO: search for closest colors in the colormap, right now we just
600 // get as many as exact colors we can for the 8-color palette)
601
602 FreeColors();
603
604 for (i = 0; i < 8; ++i) {
605 color.fPixel = 0;
606 color.fRed = (i & 1) * 65535;
607 color.fGreen = ((i >> 1) & 1) * 65535;
608 color.fBlue = ((i >> 2) & 1) * 65535;
609 if (gVirtualX->AllocColor(gVirtualX->GetColormap(), color) != 0) {
610 fColormap[fNColors][0] = color.fRed / 256;
611 fColormap[fNColors][1] = color.fGreen / 256;
612 fColormap[fNColors][2] = color.fBlue / 256;
613 fPixel[fNColors++] = color.fPixel;
614 }
615 }
616
617 // continue with what we got...
618}
619
620////////////////////////////////////////////////////////////////////////////////
621/// Free allocated colors.
622
624{
625 for (Int_t i = 0; i < fNColors; i++)
626 gVirtualX->FreeColor(gVirtualX->GetColormap(), fPixel[i]);
627 fNColors = 0;
628}
629
630////////////////////////////////////////////////////////////////////////////////
631/// Create a dithered version of the color map and lightness images for
632/// display modes with reduced number of colors. The Floyd-Steinberg error
633/// diffusion dithering algorithm is used.
634/// This routine is called in PseudoColor modes only.
635
637{
638 const Int_t kWidth = 20;
639
641 struct { Int_t r, g, b; } ed[kWidth], ef;
642 Int_t x, y, c, v, e[4], nc = 0;
643 Int_t r, g, b;
644 Int_t h, l, s;
645 Long_t dist, sdist;
646 Int_t iw, ih;
647
648 gVirtualX->GetImageSize(image, (UInt_t&) iw, (UInt_t&) ih);
649
650 for (x = 0; x < iw; ++x) {
651 ed[x].r = ed[x].g = ed[x].b = 0;
652 }
653
654 if (fNColors == 0) AllocColors();
655
656 for (y = 0; y < ih; ++y) {
657
658 if (which == kIMG_HS) {
659
660 for (x = 0; x < iw; ++x) {
661
662 h = x * 255 / iw;
663 l = 128;
664 s = (ih - y) * 255 / ih;
665
666 TColor::HLS2RGB(h, l, s, r, g, b);
667
668 line[x].fRed = r;
669 line[x].fGreen = g;
670 line[x].fBlue = b;
671 }
672
673 } else if (which == kIMG_L) {
674
676 TColor::RGB2HLS(r, g, b, h, l, s);
677
678 Int_t ll = (ih - y) * 255 / ih;
679
680 TColor::HLS2RGB(h, ll, s, r, g, b);
681
682 for (x = 0; x < iw; ++x) {
683 line[x].fRed = r;
684 line[x].fGreen = g;
685 line[x].fBlue = b;
686 }
687
688 } else {
689
690 return;
691
692 }
693
694 ef.r = ef.g = ef.b = 0; // no forward error for first pixel
695
696 for (x = 0; x < iw; ++x) {
697
698 // add errors from previous line
699
700 v = line[x].fRed + ed[x].r;
701 if (v < 0) v = 0; else if (v > 255) v = 255;
702 line[x].fRed = v;
703
704 v = line[x].fGreen + ed[x].g;
705 if (v < 0) v = 0; else if (v > 255) v = 255;
706 line[x].fGreen = v;
707
708 v = line[x].fBlue + ed[x].b;
709 if (v < 0) v = 0; else if (v > 255) v = 255;
710 line[x].fBlue = v;
711
712 }
713
714 for (x = 0; x < iw; ++x) {
715
716 // add forward errors
717
718 v = line[x].fRed + ef.r;
719 if (v < 0) v = 0; else if (v > 255) v = 255;
720 line[x].fRed = v;
721
722 v = line[x].fGreen + ef.g;
723 if (v < 0) v = 0; else if (v > 255) v = 255;
724 line[x].fGreen = v;
725
726 v = line[x].fBlue + ef.b;
727 if (v < 0) v = 0; else if (v > 255) v = 255;
728 line[x].fBlue = v;
729
730 // find the nearest color in colormap[]
731
732 sdist = 255L * 255L * 255L;
733 for (c = 0; c < fNColors; ++c) {
734
735 Int_t dr = line[x].fRed - fColormap[c][0];
736 Int_t dg = line[x].fGreen - fColormap[c][1];
737 Int_t db = line[x].fBlue - fColormap[c][2];
738
739 dist = dr * dr + dg * dg + db * db;
740 if (dist < sdist) {
741 nc = c;
742 sdist = dist;
743 }
744 }
745
746 gVirtualX->PutPixel(image, x, y, fPixel[nc]);
747
748#define FILTER(v) \
749 e[0] = (7 * v) >> 4; \
750 e[1] = v >> 4; \
751 e[2] = (5 * v) >> 4; \
752 e[3] = (3 * v) >> 4;
753
754 v = line[x].fRed - fColormap[nc][0];
755 FILTER(v)
756
757 ef.r = e[0];
758 if (x < iw-1) ed[x+1].r = e[1];
759 if (x == 0) ed[x].r = e[2]; else ed[x].r += e[2];
760 if (x > 0) ed[x-1].r += e[3];
761
762 v = line[x].fGreen - fColormap[nc][1];
763 FILTER(v)
764
765 ef.g = e[0];
766 if (x < iw-1) ed[x+1].g = e[1];
767 if (x == 0) ed[x].g = e[2]; else ed[x].g += e[2];
768 if (x > 0) ed[x-1].g += e[3];
769
770 v = line[x].fBlue - fColormap[nc][2];
771 FILTER(v)
772
773 ef.b = e[0];
774 if (x < iw-1) ed[x+1].b = e[1];
775 if (x == 0) ed[x].b = e[2]; else ed[x].b += e[2];
776 if (x > 0) ed[x-1].b += e[3];
777
778 }
779 }
780}
781
782////////////////////////////////////////////////////////////////////////////////
783/// Initialize color palette and slider images.
784
786{
788 Int_t h, l, s;
789 Int_t r, g, b;
790
791 gVirtualX->GetImageSize(fHSimage, (UInt_t&) width, (UInt_t&) height);
792
793 // initialize fHSimage
794
795 Int_t ncolors = gVirtualX->GetDepth();
796
797 if (ncolors > 8) {
798 for (Int_t y = 0; y < height; ++y) {
799 for (Int_t x = 0; x < width; ++x) {
800
801 r = g = b = 0;
802 h = x * 255 / width;
803 l = 128;
804 s = (height - y) * 255 / height;
805
806 TColor::HLS2RGB(h, l, s, r, g, b);
807
809 gVirtualX->PutPixel(fHSimage, x, y, pixel);
810 }
811 }
812 } else {
814 }
815
816 // initialize fLimage
817
819}
820
821////////////////////////////////////////////////////////////////////////////////
822/// Set slider colors.
823
825{
827 Int_t h, l, s;
828 Int_t r, g, b;
829
830 gVirtualX->GetImageSize(fLimage, (UInt_t&) width, (UInt_t&) height);
831
832 Int_t ncolors = gVirtualX->GetDepth();
833
834 if (ncolors > 8) {
835
836 for (Int_t y = 0; y < height; ++y) {
837
839 TColor::RGB2HLS(r, g, b, h, l, s);
840
841 l = (height - y) * 255 / height;
842
843 TColor::HLS2RGB(h, l, s, r, g, b);
844
846
847 for (Int_t x = 0; x < width; ++x) {
848 gVirtualX->PutPixel(fLimage, x, y, pixel);
849 }
850 }
851 } else {
853 }
854
855 gClient->NeedRedraw(this);
856}
857
858////////////////////////////////////////////////////////////////////////////////
859/// Position the slider cursor on right color position.
860
862{
864 Int_t h, l, s;
865 Int_t r, g, b;
866
867 gVirtualX->GetImageSize(fHSimage, width, height);
868
869 fCurrentColor = color;
870
872 TColor::RGB2HLS(r, g, b, h, l, s);
873
874 SetHScursor(h * (Int_t)width / 256, (255 - s) * (Int_t)height / 256);
875
876 gVirtualX->GetImageSize(fLimage, width, height);
877
878 SetLcursor((255 - l) * (Int_t)height / 256);
879
881}
882
883////////////////////////////////////////////////////////////////////////////////
884/// Assign the current cursor position as currently selected color.
885
887{
890 Int_t r, g, b;
891 Int_t h, l, s;
892
893 gVirtualX->GetImageSize(fLimage, lwidth, lheight);
894 gVirtualX->GetImageSize(fHSimage, swidth, sheight);
895
896 h = Int_t(fCx * 255 / swidth);
897 l = Int_t((lheight - fCz) * 255 / lheight);
898 s = Int_t((sheight - fCy) * 255 / sheight);
899
900 TColor::HLS2RGB(h, l, s, r, g, b);
902}
903
904////////////////////////////////////////////////////////////////////////////////
905/// Redraw the color pick widget.
906
930
931////////////////////////////////////////////////////////////////////////////////
932/// Set hue / saturation cursor position.
933
935{
937
938 gVirtualX->GetImageSize(fHSimage, width, height);
939
941
942 fCx = x;
943 fCy = y;
944
945 if (fCx < 0)
946 fCx = 0;
947 else if (fCx >= (Int_t)width)
948 fCx = (Int_t)width - 1;
949
950 if (fCy < 0)
951 fCy = 0;
952 else if (fCy >= (Int_t)height)
953 fCy = (Int_t)height - 1;
954
956}
957
958////////////////////////////////////////////////////////////////////////////////
959/// Set lightness slider cursor position.
960
962{
964
965 gVirtualX->GetImageSize(fLimage, width, height);
966
968
969 fCz = z - fSliderRect.fY;
970
971 if (fCz < 0)
972 fCz = 0;
973 else if (fCz >= (Int_t)height)
974 fCz = (Int_t)height - 1;
975
977}
978
979////////////////////////////////////////////////////////////////////////////////
980/// Draw hue / saturation cursor
981
983{
985
986 gVirtualX->GetImageSize(fHSimage, width, height);
987
988 if (onoff) {
989 Int_t x, y;
991
992 x = fCx + fColormapRect.fX;
993 y = fCy + fColormapRect.fY;
994
997 rect.fWidth = fColormapRect.fWidth;
998 rect.fHeight = fColormapRect.fHeight;
999 gVirtualX->SetClipRectangles(fCursorGC(), 0, 0, &rect, 1);
1000
1001 gVirtualX->FillRectangle(fId, fCursorGC(), x - 9, y - 1, 5, 3);
1002 gVirtualX->FillRectangle(fId, fCursorGC(), x - 1, y - 9, 3, 5);
1003 gVirtualX->FillRectangle(fId, fCursorGC(), x + 5, y - 1, 5, 3);
1004 gVirtualX->FillRectangle(fId, fCursorGC(), x - 1, y + 5, 3, 5);
1005
1006 } else {
1007 Int_t x, y;
1008 UInt_t w, h;
1009
1010 x = fCx - 9; w = 19;
1011 y = fCy - 9; h = 19;
1012
1013 if (x < 0) { w += x; x = 0; }
1014 if (y < 0) { h += y; y = 0; }
1015
1016 if (x + w > width) w = width - x;
1017 if (y + h > height) h = height - y;
1018
1019 gVirtualX->PutImage(fId, GetBckgndGC()(), fHSimage, x, y,
1021 }
1022}
1023
1024////////////////////////////////////////////////////////////////////////////////
1025/// Draw lightness slider cursor
1026
1028{
1030 Int_t r = l + 5;
1031 Int_t t = fCz - 5 + fSliderRect.fY;
1032 Int_t b = t + 10;
1033
1034 Point_t points[3];
1035
1036 Int_t m = (t + b) >> 1;
1037
1038 points[0].fX = r;
1039 points[0].fY = t;
1040 points[1].fX = r;
1041 points[1].fY = b;
1042 points[2].fX = l;
1043 points[2].fY = m;
1044
1046
1047 gVirtualX->FillPolygon(fId, gc, points, 3);
1048}
1049
1050
1051////////////////////////////////////////////////////////////////////////////////
1052/// Color selection dialog constructor.
1053/// The TGColorDialog presents a full featured color selection dialog.
1054/// It uses 2 TGColorPalette's and the TGColorPick widgets.
1055
1057 Int_t *retc, Pixel_t *color, Bool_t wait) :
1058 TGTransientFrame(p, m, 200, 150)
1059{
1060 const Int_t kC_X = 175; // Win95: 177
1061 const Int_t kC_Y = 180; // Win95: 189
1062
1063 Int_t i;
1064
1065 fRetc = retc;
1066 fRetColor = 0;
1067 fRetTColor = 0;
1068 fInitColor = 0;
1069 if (color) {
1070 fRetColor = color;
1073 }
1074 fWaitFor = wait;
1075
1076 if (fRetc) *fRetc = kMBCancel;
1077
1078 TGHorizontalFrame *hftop = new TGHorizontalFrame(this, 10, 10);
1079 hftop->SetCleanup();
1080 AddFrame(hftop, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 10, 5));
1081
1082 fTab = new TGTab(hftop, 300, 300);
1083 hftop->AddFrame(fTab);
1084
1085 TGCompositeFrame *cf = new TGCompositeFrame(hftop, 10, 10);
1086 cf->SetCleanup();
1087 hftop->AddFrame(cf, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 0, 30, 0));
1088
1089 TGCompositeFrame *cf1 = new TGCompositeFrame(cf, 10, 10);
1090 cf1->SetCleanup();
1091 cf->AddFrame(cf1, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 0, 30, 0));
1092 cf1->SetLayoutManager(new TGMatrixLayout(cf1, 0, 2, 4));
1093
1094 cf1->AddFrame(new TGLabel(cf1, new TGHotString("Red:")));
1095 cf1->AddFrame(fRte = new TGTextEntry(cf1, fRtb = new TGTextBuffer(5), kCDLG_RTE),0);
1097 cf1->AddFrame(new TGLabel(cf1, new TGHotString("Green:")),0);
1098 cf1->AddFrame(fGte = new TGTextEntry(cf1, fGtb = new TGTextBuffer(5), kCDLG_GTE),0);
1100 cf1->AddFrame(new TGLabel(cf1, new TGHotString("Blue:")));
1101 cf1->AddFrame(fBte = new TGTextEntry(cf1, fBtb = new TGTextBuffer(5), kCDLG_BTE),0);
1103 cf1->AddFrame(new TGLabel(cf1, new TGHotString("Opacity:")),0);
1104 cf1->AddFrame(fAle = new TGTextEntry(cf1, fAlb = new TGTextBuffer(5), kCDLG_ALE),0);
1106
1107 if (!TCanvas::SupportAlpha()) {
1109 }
1110
1111 TGCompositeFrame *cf2 = new TGCompositeFrame(cf, 10, 10);
1112 cf2->SetCleanup();
1113 cf->AddFrame(cf2, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 0, 30, 0));
1114 cf2->SetLayoutManager(new TGMatrixLayout(cf2, 0, 2, 4));
1115 cf2->AddFrame(new TGLabel(cf2, new TGHotString("Hue:")),0);
1116 cf2->AddFrame(fHte = new TGTextEntry(cf2, fHtb = new TGTextBuffer(5), kCDLG_HTE),0);
1118 cf2->AddFrame(new TGLabel(cf2, new TGHotString("Sat:")),0);
1119 cf2->AddFrame(fSte = new TGTextEntry(cf2, fStb = new TGTextBuffer(5), kCDLG_STE),0);
1121 cf2->AddFrame(new TGLabel(cf2, new TGHotString("Lum:")),0);
1122 cf2->AddFrame(fLte = new TGTextEntry(cf2, fLtb = new TGTextBuffer(5), kCDLG_LTE),0);
1124
1125 fHte->Associate(this);
1126 fLte->Associate(this);
1127 fSte->Associate(this);
1128 fRte->Associate(this);
1129 fGte->Associate(this);
1130 fBte->Associate(this);
1131 fAle->Associate(this);
1132
1133 if (color) {
1134 UpdateRGBentries(color);
1135 UpdateHLSentries(color);
1136 UpdateAlpha(color);
1137 fCurrentColor = *color;
1138 } else {
1139 gClient->GetColorByName("red", fCurrentColor);
1140 }
1141
1142 // color sample
1143 TGCompositeFrame *cf3 = new TGCompositeFrame(cf, 10, 10);
1144 cf3->SetCleanup();
1145 cf3->SetLayoutManager(new TGMatrixLayout(cf3, 0, 1, 0));
1146 cf3->AddFrame(fColorInfo = new TGLabel(cf3, new TGString("New: not set ")),0);
1148 cf3->AddFrame(fSample = new TGFrame(cf3, 50, 25, kOwnBackground),0);
1149 cf3->AddFrame(fSampleOld = new TGFrame(cf3, 50, 25, kOwnBackground),0);
1150 cf3->AddFrame(new TGLabel(cf3, new TGString("Current")),0);
1151 cf->AddFrame(cf3, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 20, 0));
1154
1155 TGCompositeFrame *tf = fTab->AddTab("Color Wheel");
1157 tf->AddFrame(tf1);
1158 fEcanvas = new TRootEmbeddedCanvas("wheel", tf1, 360, 360);
1159 tf1->AddFrame(fEcanvas);
1161 wcan->SetBit(kNoContextMenu);
1162 fColorWheel = new TColorWheel();
1164 fColorWheel->Draw();
1165 wcan->Update();
1166 wcan->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","TGColorDialog",this,
1167 "SetColorInfo(Int_t,Int_t,Int_t,TObject*)");
1168
1169 tf = fTab->AddTab("Basic Colors");
1171 tf->AddFrame(tf2);
1172
1173 TGVerticalFrame *vf1 = new TGVerticalFrame(tf2, 20, 20);
1174 vf1->SetCleanup();
1175 TGVerticalFrame *vf2 = new TGVerticalFrame(tf2, 20, 20);
1176 vf2->SetCleanup();
1177
1178 tf2->AddFrame(vf1, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));
1179 tf2->AddFrame(vf2, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));
1180
1181 //----------------------------------------- Left panel
1182
1183 // basic colors
1184
1186 vf1->AddFrame(fPalette, new TGLayoutHints(kLHintsNormal, 5, 5, 15, 0));
1187 fPalette->Associate(this);
1188
1189 for (i = 0; i < 48; ++i)
1190 fPalette->SetColor(i, TColor::Number2Pixel(i+10)); // root colors
1191 // the basic colors were set via bcolor
1192 //fPalette->SetColor(i, TColor::GetPixel(bcolor[i][0], bcolor[i][1], bcolor[i][2]));
1193
1194 // add some default colors
1196
1197 Float_t r, g, b;
1198
1199 r = 232./255;
1200 g = 232./255;
1201 b = 222./255;
1202
1203 // Gui Builder background
1205 fPalette->SetColor(46, pixel);
1206
1207 r = 230./255;
1208 g = 230./255;
1209 b = 230./255;
1210
1211 // a la MAC background
1213 fPalette->SetColor(45, pixel);
1214
1215 r = 172./255;
1216 g = 174./255;
1217 b = 205./255;
1218
1219 // a la CDE background
1221 fPalette->SetColor(44, pixel);
1222
1223 r = 205./255;
1224 g = 195./255;
1225 b = 175./255;
1226
1227 // a la FOX background
1229 fPalette->SetColor(43, pixel);
1230
1231 // custom colors
1232
1233 vf1->AddFrame(new TGLabel(vf1, new TGHotString("&Custom Colors:")),
1234 new TGLayoutHints(kLHintsNormal, 5, 0, 15, 2));
1235
1237 vf1->AddFrame(fCpalette, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 0));
1238 fCpalette->Associate(this);
1239
1240 if (gUcolor[0] == 0xff000000) {
1241 for (i = 0; i < 24; i++)
1242 gUcolor[i] = TColor::RGB2Pixel(255, 255, 255);
1243 }
1245
1246 // button frame - OK, Cancel
1247 TGHorizontalFrame *hf = new TGHorizontalFrame(this, 10, 10, kFixedWidth);
1248 hf->SetCleanup();
1249 AddFrame(hf, new TGLayoutHints(kLHintsBottom | kLHintsRight, 5, 5, 10, 5));
1250
1251 TGTextButton *ok = new TGTextButton(hf, new TGHotString("OK"), kCDLG_OK);
1253 fPreview = new TGTextButton(hf, new TGHotString("&Preview"), kCDLG_PREVIEW);
1254 fPreview->Connect("Clicked()", "TGColorDialog", this, "DoPreview()");
1255
1256 hf->AddFrame(ok, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 0, 3, 0, 0));
1257 hf->AddFrame(cancel, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,3, 0, 0, 0));
1258 hf->AddFrame(fPreview, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,3, 0, 0, 0));
1259
1260 UInt_t w = ok->GetDefaultWidth();
1261 w = TMath::Max(w, cancel->GetDefaultWidth());
1262 hf->Resize(3 * (w + 30), hf->GetDefaultHeight());
1263
1264 ok->Associate(this);
1265 cancel->Associate(this);
1266
1267 //----------------------------------------- Right panel
1268
1269 // fColormap frame
1270
1272 vf2->AddFrame(fColors, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 0, 15, 5));
1273 fColors->Associate(this);
1274
1275 if (color)
1276 fColors->SetColor(*color);
1277
1278 TGTextButton *add = new TGTextButton(vf2, new TGHotString("&Add to Custom Colors"),
1279 kCDLG_ADD);
1280 vf2->AddFrame(add, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,
1281 5, 10, 0, 5));
1282 add->Associate(this);
1283
1284 MapSubwindows();
1287
1288 //---- make the message box non-resizable
1289
1292
1293 SetWindowName("Color Selector");
1294 SetIconName("Color Selector");
1295 SetClassHints("ROOT", "ColorSelector");
1296
1302
1303
1304 //---- position relative to the parent's window
1305
1306 if (fClient->IsEditable()) {
1307 const TGWindow *main = fMain;
1308 fMain = fClient->GetRoot();
1310 fMain = main;
1311 } else {
1313 }
1314
1315 if (fWaitFor) {
1316 MapWindow();
1317 fClient->WaitForUnmap(this);
1318 DeleteWindow();
1319 }
1320}
1321
1322////////////////////////////////////////////////////////////////////////////////
1323/// TGColorDialog destructor.
1324
1326{
1327 fEcanvas->GetCanvas()->Disconnect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)");
1328 delete fEcanvas;
1329 Cleanup();
1330}
1331
1332////////////////////////////////////////////////////////////////////////////////
1333/// Change current color.
1334
1336{
1337 if (fCurrentColor == col) {
1338 return;
1339 }
1346}
1347
1348////////////////////////////////////////////////////////////////////////////////
1349/// Emit signal about selected color.
1350
1352{
1353 Emit("ColorSelected(Pixel_t)", color);
1354}
1355
1356////////////////////////////////////////////////////////////////////////////////
1357/// Emit signal about selected alpha and color.
1358
1360{
1361 Emit("AlphaColorSelected(ULong_t)", color);
1362}
1363
1364////////////////////////////////////////////////////////////////////////////////
1365/// Called when window is closed via window manager.
1366
1368{
1369 // save user set colors
1370 for (Int_t i = 0; i < 24; ++i)
1372
1373 if (*fRetc != kMBOk) {
1375 ULongptr_t ptr;
1376 if((ptr = (ULongptr_t)gROOT->GetColor(TColor::GetColor(fInitColor)))) AlphaColorSelected(ptr);
1377 } else {
1380 }
1381 // don't call DeleteWindow() here since that will cause access
1382 // to the deleted dialog in the WaitFor() method (see ctor)
1383
1384 //OpenGL + XQuartz on Mac: gl context and related resources
1385 //must be deleted _before_ UnmapWindow.
1386 if (gVirtualX->InheritsFrom("TGX11") && fEcanvas->GetCanvas()->UseGL())
1388
1389 UnmapWindow();
1390}
1391
1392////////////////////////////////////////////////////////////////////////////////
1393/// Update Opacity text entry with alpha value of color c.
1394
1396{
1397 Char_t tmp[20];
1398 Double_t alpha;
1399
1400 if (TColor *color = gROOT->GetColor(TColor::GetColor(*c))) {
1401 alpha = color->GetAlpha();
1402 snprintf(tmp, 20, "%.1f", alpha);
1403 fAlb->Clear();
1404 fAlb->AddText(0,tmp);
1405 gClient->NeedRedraw(fAle);
1406 }
1407}
1408
1409
1410////////////////////////////////////////////////////////////////////////////////
1411/// Update RGB text entries with RGB values of color c.
1412
1414{
1415 Char_t tmp[20];
1416
1417 Int_t r, g, b;
1418 TColor::Pixel2RGB(*c, r, g, b);
1419
1420 snprintf(tmp, 20, "%d", r);
1421 fRtb->Clear();
1422 fRtb->AddText(0, tmp);
1423 gClient->NeedRedraw(fRte);
1424
1425 snprintf(tmp, 20, "%d", g);
1426 fGtb->Clear();
1427 fGtb->AddText(0, tmp);
1428 gClient->NeedRedraw(fGte);
1429
1430 snprintf(tmp, 20, "%d", b);
1431 fBtb->Clear();
1432 fBtb->AddText(0, tmp);
1433 gClient->NeedRedraw(fBte);
1434}
1435
1436////////////////////////////////////////////////////////////////////////////////
1437/// Update HLS text entries with HLS values of color c.
1438
1440{
1441 Char_t tmp[20];
1442
1443 Int_t h, l, s;
1444 Int_t r, g, b;
1445
1446 TColor::Pixel2RGB(*c, r, g, b);
1447 TColor::RGB2HLS(r, g, b, h, l, s);
1448
1449 snprintf(tmp, 20, "%d", h);
1450 fHtb->Clear();
1451 fHtb->AddText(0, tmp);
1452 gClient->NeedRedraw(fHte);
1453
1454 snprintf(tmp, 20, "%d", l);
1455 fLtb->Clear();
1456 fLtb->AddText(0, tmp);
1457 gClient->NeedRedraw(fLte);
1458
1459 snprintf(tmp, 20, "%d", s);
1460 fStb->Clear();
1461 fStb->AddText(0, tmp);
1462 gClient->NeedRedraw(fSte);
1463}
1464
1465////////////////////////////////////////////////////////////////////////////////
1466/// Process messages for the color selection dialog.
1467
1469{
1470 ULong_t color;
1471 Int_t h, l, s;
1472 Int_t r, g, b;
1473
1474 switch (GET_MSG(msg)) {
1475 case kC_COMMAND:
1476 switch (GET_SUBMSG(msg)) {
1477 case kCM_BUTTON:
1478 switch(parm1) {
1479 case kCDLG_ADD:
1481 break;
1482
1483 case kCDLG_OK:
1484 *fRetc = kMBOk;
1486 atoi(fGtb->GetString()),
1487 atoi(fBtb->GetString()));
1490 atof(fAlb->GetString()))));
1491 }
1492 CloseWindow();
1493 break;
1494 case kCDLG_CANCEL:
1495 if (!fClient->IsEditable()) {
1497 if (p && p->InheritsFrom("TGColorPopup"))
1498 p->PreviewColor(fSampleOld->GetBackground());
1499 }
1500 CloseWindow();
1501 break;
1502 }
1503 break;
1504 }
1505 break;
1506 case kC_COLORSEL:
1507 switch (GET_SUBMSG(msg)) {
1508 case kCOL_CLICK:
1509 switch (parm1) {
1510 case kCDLG_SPALETTE:
1511 color = fPalette->GetCurrentColor();
1513 ColorSelected(color);
1514 gClient->NeedRedraw(fSample);
1515 fCurrentColor = color;
1516 fColors->SetColor(color);
1517 UpdateRGBentries(&color);
1518 UpdateHLSentries(&color);
1519 UpdateAlpha(&color);
1520 break;
1521
1522 case kCDLG_CPALETTE:
1523 color = fCpalette->GetCurrentColor();
1525 ColorSelected(color);
1526 gClient->NeedRedraw(fSample);
1527 fCurrentColor = color;
1528 fColors->SetColor(color);
1529 UpdateRGBentries(&color);
1530 UpdateHLSentries(&color);
1531 UpdateAlpha(&color);
1532 break;
1533
1534 case kCDLG_COLORPICK:
1535 color = fColors->GetCurrentColor();
1537 ColorSelected(color);
1538 gClient->NeedRedraw(fSample);
1539 fCurrentColor = color;
1540 UpdateRGBentries(&color);
1541 UpdateHLSentries(&color);
1542 UpdateAlpha(&color);
1543 break;
1544
1545 }
1546 break;
1547 }
1548 break;
1549
1550 case kC_TEXTENTRY:
1551 switch (GET_SUBMSG(msg)) {
1552 case kTE_TEXTCHANGED:
1553 switch (parm1) {
1554 case kCDLG_HTE:
1555 case kCDLG_LTE:
1556 case kCDLG_STE:
1557
1558 h = atoi(fHtb->GetString());
1559 l = atoi(fLtb->GetString());
1560 s = atoi(fStb->GetString());
1561 TColor::HLS2RGB(h, l, s, r, g, b);
1562
1563 color = TColor::RGB2Pixel(r, g, b);
1565 ColorSelected(color);
1566 gClient->NeedRedraw(fSample);
1567 fCurrentColor = color;
1568 fColors->SetColor(color);
1569 UpdateRGBentries(&color);
1570 break;
1571
1572 case kCDLG_RTE:
1573 case kCDLG_GTE:
1574 case kCDLG_BTE:
1575 color = TColor::RGB2Pixel(atoi(fRtb->GetString()),
1576 atoi(fGtb->GetString()),
1577 atoi(fBtb->GetString()));
1579 ColorSelected(color);
1580 gClient->NeedRedraw(fSample);
1581 fCurrentColor = color;
1582 fColors->SetColor(color);
1583 UpdateHLSentries(&color);
1584 break;
1585
1586 }
1587 break;
1588 }
1589 break;
1590 }
1591
1592 return kTRUE;
1593}
1594
1595////////////////////////////////////////////////////////////////////////////////
1596/// Set the color info in RGB and HLS parts
1597
1599{
1600 if (object == fColorWheel) {
1601 Int_t n = fColorWheel->GetColor(px,py);
1602 if (n < 0) return;
1603 TColor *color = gROOT->GetColor(n);
1604 if (!color) return;
1605 ULong_t pcolor = color->GetPixel();
1606 if (event == kButton1Down) {
1611 fColorInfo->SetText(Form("New: %s",color->GetName()));
1612 gClient->NeedRedraw(fSample);
1613 gClient->NeedRedraw(fColorInfo);
1617 }
1618 }
1619}
1620
1621////////////////////////////////////////////////////////////////////////////////
1622/// Slot method called when Preview button is clicked.
1623
1625{
1626 TColor *tcolor;
1627 if ((tcolor = gROOT->GetColor(TColor::GetColor(fSample->GetBackground())))) {
1628 tcolor->SetAlpha(TMath::Max((Double_t)0, TMath::Min((Double_t)1, atof(fAlb->GetString()))));
1629 }
1630
1631 if (fClient->IsEditable()) {
1634 return;
1635 }
1637 if (p && p->InheritsFrom("TGColorPopup")) {
1638 if (tcolor) p->PreviewAlphaColor((ULongptr_t)tcolor);
1639 else p->PreviewColor(fSample->GetBackground());
1640 }
1641}
@ kButton1Down
Definition Buttons.h:17
@ kGKeyPress
Definition GuiTypes.h:61
@ kButtonPress
Definition GuiTypes.h:61
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:31
const Mask_t kFocusChangeMask
Definition GuiTypes.h:170
const Mask_t kButtonPressMask
Definition GuiTypes.h:162
const Mask_t kKeyReleaseMask
Definition GuiTypes.h:161
const Mask_t kAnyModifier
Definition GuiTypes.h:211
const Mask_t kKeyPressMask
Definition GuiTypes.h:160
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:39
const Mask_t kPointerMotionMask
Definition GuiTypes.h:164
@ kChildFrame
Definition GuiTypes.h:380
@ kSunkenFrame
Definition GuiTypes.h:384
@ kDoubleBorder
Definition GuiTypes.h:386
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kOwnBackground
Definition GuiTypes.h:392
const Handle_t kNone
Definition GuiTypes.h:89
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:169
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:167
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:163
const Mask_t kEnterWindowMask
Definition GuiTypes.h:168
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
@ kButton1
Definition GuiTypes.h:215
@ kAnyButton
Definition GuiTypes.h:215
EKeySym
Definition KeySymbols.h:25
@ kKey_Right
Definition KeySymbols.h:42
@ kKey_Down
Definition KeySymbols.h:43
@ kKey_Up
Definition KeySymbols.h:41
@ kKey_Left
Definition KeySymbols.h:40
@ kKey_Home
Definition KeySymbols.h:38
@ kKey_End
Definition KeySymbols.h:39
int main()
Definition Prototype.cxx:12
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
cudaEvent_t event
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:52
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:70
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:91
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gClient
Definition TGClient.h:157
EColorPick
@ kCLICK_NONE
@ kCLICK_HS
@ kCLICK_L
#define FILTER(v)
EColorImage
@ kIMG_HS
@ kIMG_L
EColorDialog
@ kCDLG_OK
@ kCDLG_RTE
@ kCDLG_SPALETTE
@ kCDLG_LTE
@ kCDLG_BTE
@ kCDLG_ALE
@ kCDLG_STE
@ kCDLG_CANCEL
@ kCDLG_ADD
@ kCDLG_PREVIEW
@ kCDLG_GTE
@ kCDLG_COLORPICK
@ kCDLG_HTE
@ kCDLG_CPALETTE
static ULong_t gUcolor[24]
@ kMWMDecorResizeH
Definition TGFrame.h:65
@ kMWMFuncAll
Definition TGFrame.h:49
@ kMWMFuncResize
Definition TGFrame.h:50
@ kMWMDecorMaximize
Definition TGFrame.h:69
@ kMWMDecorMinimize
Definition TGFrame.h:68
@ kMWMDecorMenu
Definition TGFrame.h:67
@ kMWMDecorAll
Definition TGFrame.h:63
@ kMWMFuncMaximize
Definition TGFrame.h:53
@ kMWMInputModeless
Definition TGFrame.h:57
@ kMWMFuncMinimize
Definition TGFrame.h:52
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
@ kMBCancel
Definition TGMsgBox.h:37
@ kMBOk
Definition TGMsgBox.h:33
@ kTextLeft
Definition TGWidget.h:23
@ kWidgetIsEnabled
Definition TGWidget.h:37
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize UnmapWindow
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t rect
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetMWMHints
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t SetWMSizeHints
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
@ kNoContextMenu
Definition TObject.h:381
#define gROOT
Definition TROOT.h:417
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2570
#define gVirtualX
Definition TVirtualX.h:379
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Int_t GET_MSG(Long_t val)
@ kTE_TEXTCHANGED
@ kCOL_CLICK
@ kC_COLORSEL
@ kC_COMMAND
@ kCM_BUTTON
@ kC_TEXTENTRY
Int_t GET_SUBMSG(Long_t val)
The Canvas class.
Definition TCanvas.h:23
void DeleteCanvasPainter()
assert on IsBatch() == false?
Definition TCanvas.cxx:2665
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
Definition TCanvas.cxx:2490
Bool_t UseGL() const
Definition TCanvas.h:234
Draw the ROOT Color Wheel.
Definition TColorWheel.h:23
virtual void SetCanvas(TCanvas *can)
Definition TColorWheel.h:61
virtual Int_t GetColor(Int_t px, Int_t py) const
Return the color number pointed by the mouse.
void Draw(Option_t *option="") override
Paint the color wheel.
The color creation and management class.
Definition TColor.h:22
static void HLS2RGB(Float_t h, Float_t l, Float_t s, Float_t &r, Float_t &g, Float_t &b)
Static method to compute RGB from HLS.
Definition TColor.cxx:1594
static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b)
Convert r,g,b to graphics system dependent pixel value.
Definition TColor.cxx:2496
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition TColor.cxx:2458
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1939
static void Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b)
Convert machine dependent pixel value (obtained via RGB2Pixel or via Number2Pixel() or via TColor::Ge...
Definition TColor.cxx:2534
ULong_t GetPixel() const
Return pixel value corresponding to this color.
Definition TColor.cxx:1577
virtual void SetAlpha(Float_t a)
Definition TColor.h:71
static void RGB2HLS(Float_t r, Float_t g, Float_t b, Float_t &h, Float_t &l, Float_t &s)
Static method to compute HLS from RGB.
Definition TColor.cxx:1734
Bool_t IsEditable() const
Definition TGClient.h:89
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:224
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition TGClient.cxx:746
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
TGTextEntry * fLte
TGTextEntry * fBte
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process messages for the color selection dialog.
TGColorPalette * fPalette
color palette
TGTab * fTab
tab widget holding the color selectors
TGLabel * fColorInfo
color info
virtual void SetCurrentColor(Pixel_t col)
Change current color.
void DoPreview()
Slot method called when Preview button is clicked.
TGTextEntry * fRte
Int_t * fRetc
return code (kMBOk, kMBCancel)
TColorWheel * fColorWheel
color wheel
TGTextBuffer * fStb
TGTextBuffer * fAlb
RGB/HLS associated buffers.
TGTextButton * fPreview
preview button;
Pixel_t fCurrentColor
currently selected color
Pixel_t * fRetColor
return color
TGColorPick * fColors
color pick widget
TGColorDialog(const TGColorDialog &)=delete
TColor * fRetTColor
return TColor, needed for changed alpha
TGTextEntry * fHte
void SetColorInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
Set the color info in RGB and HLS parts.
TRootEmbeddedCanvas * fEcanvas
embedded canvas holding the color wheel
TGColorPalette * fCpalette
color palette
TGTextBuffer * fLtb
virtual void ColorSelected(Pixel_t)
Emit signal about selected color.
void CloseWindow() override
Called when window is closed via window manager.
TGTextEntry * fAle
RGB/HLS text entries.
TGFrame * fSample
color sample frame
TGTextBuffer * fBtb
TGTextBuffer * fHtb
virtual void AlphaColorSelected(ULongptr_t)
Emit signal about selected alpha and color.
TGTextBuffer * fRtb
Bool_t fWaitFor
call WaitFor method in constructor
Pixel_t fInitColor
initially set color
void UpdateRGBentries(Pixel_t *c)
Update RGB text entries with RGB values of color c.
void UpdateHLSentries(Pixel_t *c)
Update HLS text entries with HLS values of color c.
TGFrame * fSampleOld
color sample frame
TGTextEntry * fGte
~TGColorDialog() override
TGColorDialog destructor.
void UpdateAlpha(Pixel_t *c)
Update Opacity text entry with alpha value of color c.
TGTextEntry * fSte
TGTextBuffer * fGtb
A widget showing an matrix of color cells.
void SetCellSize(Int_t w=20, Int_t h=17)
Set color cell size.
Bool_t HandleButton(Event_t *event) override
Handle button events in color palette.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion events in color palette.
void SetColors(Pixel_t colors[])
Set color entries in color samples.
void DoRedraw() override
Redraw color palette.
Int_t fRows
number of color cell rows
Pixel_t GetColorByIndex(Int_t ix) const
virtual void LostFocus()
Remove keyboard input.
Pixel_t GetCurrentColor() const
Return currently selected color value.
UInt_t fCh
color cell height
void SetCurrentCellColor(Pixel_t color)
Set current cell color.
Int_t fCols
number of color cell columns
UInt_t fCw
color cell width
void DrawFocusHilite(Int_t onoff)
Draw a highlight rectangle around cell obtaining focus.
Pixel_t * fPixels
pixel value of colors
TGGC fDrawGC
graphics context used for drawing
virtual void GotFocus()
Add keyboard input.
void SetColor(Int_t ix, Pixel_t color)
Set color at index ix of color entries.
Int_t fCy
y coordinate of currently selected color cell
TGColorPalette(const TGColorPalette &)=delete
~TGColorPalette() override
Destructor.
virtual void ColorSelected(Pixel_t col=0)
Bool_t HandleKey(Event_t *event) override
Handle keyboard events in color palette.
Int_t fCx
x coordinate of currently selected color cell
A widget which allows a color to be picked from HLS color space.
Bool_t HandleButton(Event_t *event) override
Handle mouse button events in color pick widget.
void SetLcursor(Int_t z)
Set lightness slider cursor position.
void DoRedraw() override
Redraw the color pick widget.
Int_t fCx
x position in hs colormap
~TGColorPick() override
TGColorPick destructor.
Pixmap_t fLimage
color lightness slider pixmap
Int_t fNColors
number of color samples
Pixmap_t fHSimage
hue / saturation colormap pixmap
void UpdateCurrentColor()
Assign the current cursor position as currently selected color.
Int_t fClick
mouse click location (kCLICK_NONE, kCLICK_HS, kCLICK_L)
void CreateImages()
Create colormap and color slider images.
void SetColor(Pixel_t color)
Position the slider cursor on right color position.
virtual void ColorSelected(Pixel_t col=0)
Pixel_t fCurrentColor
currently selected color value
Int_t fCz
position in lightness slider
void SetSliderColor()
Set slider colors.
TGColorPick(const TGWindow *p=nullptr, Int_t w=1, Int_t h=1, Int_t id=-1)
TGColorPick constructor.
void AllocColors()
Try to allocate first a palette of 64 colors.
Rectangle_t fColormapRect
hue / saturation colormap rectangle
void FreeColors()
Free allocated colors.
Pixel_t GetCurrentColor() const
Int_t fColormap[64][3]
void DrawHScursor(Int_t onoff)
Draw hue / saturation cursor.
void CreateDitheredImage(Pixmap_t image, Int_t which)
Create a dithered version of the color map and lightness images for display modes with reduced number...
void DrawLcursor(Int_t onoff)
Draw lightness slider cursor.
void InitImages()
Initialize color palette and slider images.
Rectangle_t fSliderRect
color lightness slider rectangle
void SetHScursor(Int_t x, Int_t y)
Set hue / saturation cursor position.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion events in color pick widget.
Pixel_t fPixel[64]
Int_t fCy
y position in hs colormap
TGGC fCursorGC
color lightness slider cursor GC
A popup containing a TG16ColorSelector and a "More..." button which popups up a TGColorDialog allowin...
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1110
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:960
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1157
TGCompositeFrame(const TGCompositeFrame &)=delete
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1015
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:332
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:598
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
Definition TGFrame.cxx:341
TGFrame(const TGFrame &)=delete
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:192
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:414
virtual void Draw3dRectangle(UInt_t type, Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw 3D rectangle on the frame border.
Definition TGFrame.cxx:350
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:305
void MapWindow() override
map window
Definition TGFrame.h:206
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:676
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:269
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:638
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:758
UInt_t fWidth
frame width
Definition TGFrame.h:87
virtual Pixel_t GetBackground() const
Definition TGFrame.h:194
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:768
void SetForeground(Pixel_t v)
Set foreground color.
Definition TGGC.cxx:270
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
TGHotString is a string with a "hot" character underlined.
Definition TGString.h:42
This class handles GUI labels.
Definition TGLabel.h:24
void SetTextJustify(Int_t tmode)
Set text justification.
Definition TGLabel.cxx:395
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:179
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition TGFrame.cxx:1853
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1796
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition TGFrame.cxx:1888
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1783
This layout managers does not make use of TGLayoutHints.
Definition TGLayout.h:269
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition TGTab.cxx:373
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
void AddText(Int_t pos, const char *text)
const char * GetString() const
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
void SetEnabled(Bool_t flag=kTRUE)
Defines transient windows that typically are used for dialogs windows.
Definition TGFrame.h:500
const TGWindow * GetMain() const
Definition TGFrame.h:524
const TGWindow * fMain
Definition TGFrame.h:503
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
Definition TGFrame.cxx:1952
A composite frame that layout their children in vertical way.
Definition TGFrame.h:376
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
Bool_t HasFocus() const
Definition TGWidget.h:70
Int_t fWidgetFlags
widget status flags (OR of EWidgetStatus)
Definition TGWidget.h:47
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
Bool_t IsEnabled() const
Definition TGWidget.h:69
Bool_t WantFocus() const
Definition TGWidget.h:71
ROOT GUI Window base class.
Definition TGWindow.h:23
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Mother of all ROOT objects.
Definition TObject.h:42
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:161
void MakeZombie()
Definition TObject.h:55
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
This class creates a TGCanvas in which a TCanvas is created.
TCanvas * GetCanvas() const
TLine * line
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
ULong_t fPixel
color pixel value (index in color table)
Definition GuiTypes.h:312
UShort_t fRed
red component (0..65535)
Definition GuiTypes.h:313
UShort_t fGreen
green component (0..65535)
Definition GuiTypes.h:314
UShort_t fBlue
blue component (0..65535)
Definition GuiTypes.h:315
Event structure.
Definition GuiTypes.h:175
Point structure (maps to the X11 XPoint structure)
Definition GuiTypes.h:357
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:362
Short_t fX
Definition GuiTypes.h:363
UShort_t fHeight
Definition GuiTypes.h:364
Short_t fY
Definition GuiTypes.h:363
UShort_t fWidth
Definition GuiTypes.h:364
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4