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// //
26// TGColorPalette, TGColorPick and TGColorDialog. //
27// //
28// The TGColorPalette is a widget showing an matrix of color cells. The //
29// colors can be set and selected. //
30// //
31// The TGColorPick is a widget which allows a color to be picked from //
32// HLS space. It consists of two elements: a color map window from //
33// where the user can select the hue and saturation level of a color, //
34// and a slider to select color's lightness. //
35// //
36// Selecting a color in these two widgets will generate the event: //
37// kC_COLORSEL, kCOL_CLICK, widget id, 0. //
38// and the signal: //
39// ColorSelected(Pixel_t color) //
40// //
41// The TGColorDialog presents a full featured color selection dialog. //
42// It uses 2 TGColorPalette's and the TGColorPick widgets. //
43// //
44//////////////////////////////////////////////////////////////////////////
45
46#include <cstdlib>
47
48#include "TGLabel.h"
49#include "TGMsgBox.h" // for ID_OK, ID_CANCEL
50#include "TGLayout.h"
51#include "TGGC.h"
52#include "KeySymbols.h"
53#include "TGColorDialog.h"
54#include "TGTextEntry.h"
55#include "TGButton.h"
56#include "TGResourcePool.h"
57#include "TColor.h"
58#include "TColorWheel.h"
59#include "TGColorSelect.h"
60#include "TGTab.h"
61#include "TRootEmbeddedCanvas.h"
62#include "TCanvas.h"
63#include "TROOT.h"
64#include "TMath.h"
65#include "TVirtualX.h"
66#include "snprintf.h"
67
71
72
73// TODO:
74// - implement "custom" colors.
75// - optimize the code, specially the one handling the fColormap image
76// and dithering in pseudo-color modes; remove duplicated code.
77// - improve the color allocation routine.
78// - use a buffering pixmap for the fColormap image.
79
81 kCDLG_OK = 100,
85
89
90 kCDLG_HTE = 300,
97};
98
104
107 kIMG_L
109
110// "User" defined colors
111
112static ULong_t gUcolor[24] = { 0xff000000 };
113
114
115////////////////////////////////////////////////////////////////////////////////
116/// TGColorPalette widget: this is just a grid of color cells of the
117/// specified size. Colors can be selected by clicking on them or by
118/// using the arrow keys.
119
121 TGFrame(p, 10, 10, kChildFrame)
122{
123 fWidgetId = id;
125 fMsgWindow = p;
127
128 fCw = 20;
129 fCh = 17;
130
131 fRows = rows;
132 fCols = cols;
133
134 fCx = fCy = 0;
135
136 fPixels = new ULong_t[fRows * fCols];
137
138 for (Int_t i = 0; i < fRows * fCols; ++i) {
139 fPixels[i] = TColor::RGB2Pixel(255, 255, 255);
140 }
141
142 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
145
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Destructor.
153
155{
156 delete [] fPixels;
157}
158
159////////////////////////////////////////////////////////////////////////////////
160/// Handle button events in color palette
161
163{
164 if (event->fCode != kButton1)
165 return kFALSE;
166
167 if ((event->fType == kButtonPress) && HasFocus())
168 WantFocus();
169
170 Int_t cx = event->fX / (fCw + 5);
171 Int_t cy = event->fY / (fCh + 5);
172
173 if (cx >= 0 && cx < fCols && cy >= 0 && cy < fRows) {
174
176
177 fCx = cx;
178 fCy = cy;
179
181
184 }
185
186 return kTRUE;
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// Handle mouse motion events in color palette.
191
193{
194 if (!IsEnabled())
195 return kTRUE;
196
197 Int_t cx = event->fX / (fCw + 5);
198 Int_t cy = event->fY / (fCh + 5);
199
200 if (cx >= 0 && cx < fCols && cy >= 0 && cy < fRows) {
201
203
204 fCx = cx;
205 fCy = cy;
206
208
211 }
212
213 return kTRUE;
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// Handle keyboard events in color palette.
218
220{
221 Char_t input[10];
222 UInt_t keysym;
223
224 if (event->fType == kGKeyPress) {
225
226 gVirtualX->LookupString(event, input, sizeof(input), keysym);
227
228 Int_t cx = fCx;
229 Int_t cy = fCy;
230
231 switch ((EKeySym)keysym) {
232 case kKey_Left:
233 if (cx > 0) --cx;
234 break;
235
236 case kKey_Right:
237 if (cx < fCols - 1) ++cx;
238 break;
239
240 case kKey_Up:
241 if (cy > 0) --cy;
242 break;
243
244 case kKey_Down:
245 if (cy < fRows - 1) ++cy;
246 break;
247
248 case kKey_Home:
249 cx = cy = 0;
250 break;
251
252 case kKey_End:
253 cx = fCols - 1;
254 cy = fRows - 1;
255 break;
256
257 default:
258 break;
259 }
260
261 if (cx != fCx || cy != fCy) {
262
264
265 fCx = cx;
266 fCy = cy;
267
269
272 }
273 }
274
275 return kTRUE;
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Set color entries in color samples.
280
282{
283 for (Int_t i = 0; i < fRows * fCols; ++i)
284 SetColor(i, colors[i]);
285 gClient->NeedRedraw(this);
286}
287
288////////////////////////////////////////////////////////////////////////////////
289/// Set color at index ix of color entries.
290
292{
293 fPixels[ix] = color;
294 gClient->NeedRedraw(this);
295}
296
297////////////////////////////////////////////////////////////////////////////////
298/// Set current cell color.
299
301{
302 SetColor(fCy * fCols + fCx, color);
303}
304
305////////////////////////////////////////////////////////////////////////////////
306/// Set color cell size.
307
309{
310 fCw = w;
311 fCh = h;
312 gClient->NeedRedraw(this);
313}
314
315////////////////////////////////////////////////////////////////////////////////
316/// Return currently selected color value.
317
319{
320 if (fCx >= 0 && fCy >= 0)
321 return GetColorByIndex(fCy * fCols + fCx);
322 else
323 return TColor::RGB2Pixel(0, 0, 0);
324}
325
326////////////////////////////////////////////////////////////////////////////////
327/// Redraw color palette.
328
330{
331 Int_t i, j, k, x, y;
332
333 k = 0;
334 y = 2;
335 for (i = 0; i < fRows; ++i) {
336 x = 2;
337 for (j = 0; j < fCols; ++j) {
340 gVirtualX->FillRectangle(fId, fDrawGC(), x + 2, y + 2, fCw - 4, fCh - 4);
341 x += fCw + 5;
342 }
343 y += fCh + 5;
344 }
345
347}
348
349////////////////////////////////////////////////////////////////////////////////
350/// Add keyboard input.
351
353{
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Remove keyboard input.
359
361{
363 gClient->NeedRedraw(this);
364}
365
366////////////////////////////////////////////////////////////////////////////////
367/// Draw a highlight rectangle around cell obtaining focus.
368
370{
371 if (fCx >= 0 && fCy >= 0) {
372 GContext_t gc = onoff ? GetShadowGC()() : GetBckgndGC()();
373 gVirtualX->DrawRectangle(fId, gc, fCx * (fCw + 5) + 0, fCy * (fCh + 5) + 0,
374 fCw + 3, fCh + 3);
375 }
376}
377
378
379////////////////////////////////////////////////////////////////////////////////
380/// TGColorPick constructor.
381/// TGColorPick is a widget which allows a color to be picked from HLS space.
382/// It consists of two elements: a color map window from where the user can
383/// select the hue and saturation level of a color, and a slider to select
384/// color's lightness.
385
387 TGFrame(p, w, h, kChildFrame), fCursorGC(GetBlackGC())
388{
389 UInt_t iw, ih;
390
391 fWidgetId = id;
393 fMsgWindow = p;
394
395 fColormapRect.fX = 1;
396 fColormapRect.fY = 1;
397 fColormapRect.fWidth = w - 33 - 2;
398 fColormapRect.fHeight = h - 2;
399 fSliderRect.fX = w - 18 - 2;
400 fSliderRect.fY = 1;
401 fSliderRect.fWidth = 10;
402 fSliderRect.fHeight = h - 2;
403
404 fNColors = 0;
405
406 if (!p) {
407 MakeZombie();
408 // coverity[uninit_member]
409 return;
410 }
411 CreateImages();
412 gVirtualX->GetImageSize(fLimage, iw, ih);
413
414 fCx = 0;
415 fCy = 0;
416 fCz = (Int_t)ih / 2;
417
419
421 InitImages();
422
423 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
426
430}
431
432////////////////////////////////////////////////////////////////////////////////
433/// TGColorPick destructor.
434
436{
437 if (IsZombie()) return;
438 gVirtualX->DeleteImage(fHSimage);
439 gVirtualX->DeleteImage(fLimage);
440 FreeColors();
441}
442
443////////////////////////////////////////////////////////////////////////////////
444/// Handle mouse button events in color pick widget.
445
447{
448 if (event->fCode != kButton1) return kFALSE;
449
450 if (event->fType == kButtonPress) {
451 if ((event->fX > fColormapRect.fX) && (event->fX < fColormapRect.fX + fColormapRect.fWidth) &&
452 (event->fY > fColormapRect.fY) && (event->fY < fColormapRect.fY + fColormapRect.fHeight)) {
453
455 SetHScursor(event->fX - fColormapRect.fX, event->fY - fColormapRect.fY);
456
457 } else if (event->fX > fSliderRect.fX) {
458
460 SetLcursor(event->fY - fSliderRect.fY);
461
462 }
463 } else { // ButtonRelease
464
466
467 }
468
471
474
475 return kTRUE;
476}
477
478////////////////////////////////////////////////////////////////////////////////
479/// Handle mouse motion events in color pick widget.
480
482{
483 if (!IsEnabled())
484 return kTRUE;
485
486 if (fClick == kCLICK_HS) {
487
488 SetHScursor(event->fX - fColormapRect.fX, event->fY - fColormapRect.fY);
489
490 } else if (fClick == kCLICK_L) {
491
492 SetLcursor(event->fY - fSliderRect.fY);
493
494 } else {
495
496 return kTRUE;
497
498 }
499
502
505
506 return kTRUE;
507}
508
509////////////////////////////////////////////////////////////////////////////////
510/// Create colormap and color slider images.
511
513{
514 UInt_t width, height;
515
517 height = fColormapRect.fHeight;
518 fHSimage = gVirtualX->CreateImage(width, height);
520 height = fSliderRect.fHeight;
521 fLimage = gVirtualX->CreateImage(width, height);
522}
523
524////////////////////////////////////////////////////////////////////////////////
525/// Try to allocate first a palette of 64 colors. Used by the dithered
526/// version of the color maps.
527
529{
530 ColorStruct_t color;
531 Int_t i;
532
533 for (i = 0; i < 64; ++i) {
534 Int_t cc[4] = { 0, 21845, 43691, 65535 };
535 color.fPixel = 0;
536 color.fRed = cc[i & 0x3];
537 color.fGreen = cc[(i >> 2) & 0x3];
538 color.fBlue = cc[(i >> 4) & 0x3];
539 if (gVirtualX->AllocColor(gVirtualX->GetColormap(), color) == 0)
540 break;
541 fColormap[i][0] = color.fRed / 256;
542 fColormap[i][1] = color.fGreen / 256;
543 fColormap[i][2] = color.fBlue / 256;
544 fPixel[i] = color.fPixel;
545 }
546
547 fNColors = i;
548 if (fNColors == 64) return; // success
549
550 // Failed, try a simpler 27-color.
551
552 FreeColors();
553
554 for (i = 0; i < 27; ++i) {
555 Int_t cc[3] = { 0, 32768, 65535 };
556 color.fPixel = 0;
557 color.fRed = cc[i % 3];
558 color.fGreen = cc[(i / 3) % 3];
559 color.fBlue = cc[(i / 9) % 3];
560 if (gVirtualX->AllocColor(gVirtualX->GetColormap(), color) == 0)
561 break;
562 fColormap[i][0] = color.fRed / 256;
563 fColormap[i][1] = color.fGreen / 256;
564 fColormap[i][2] = color.fBlue / 256;
565 fPixel[i] = color.fPixel;
566 }
567
568 fNColors = i;
569 if (fNColors == 27) return; // success
570
571 // Failed, try then a much simpler 8-color.
572
573 FreeColors();
574
575 for (i = 0; i < 8; ++i) {
576 color.fPixel = 0;
577 color.fRed = (i & 1) * 65535;
578 color.fGreen = ((i >> 1) & 1) * 65535;
579 color.fBlue = ((i >> 2) & 1) * 65535;
580 if (gVirtualX->AllocColor(gVirtualX->GetColormap(), color) == 0)
581 break;
582 fColormap[i][0] = color.fRed / 256;
583 fColormap[i][1] = color.fGreen / 256;
584 fColormap[i][2] = color.fBlue / 256;
585 fPixel[i] = color.fPixel;
586 }
587
588 fNColors = i;
589 if (fNColors == 8) return; // success
590
591 // Failed, try to get at least 8 closest colors...
592 // (TODO: search for closest colors in the colormap, right now we just
593 // get as many as exact colors we can for the 8-color palette)
594
595 FreeColors();
596
597 for (i = 0; i < 8; ++i) {
598 color.fPixel = 0;
599 color.fRed = (i & 1) * 65535;
600 color.fGreen = ((i >> 1) & 1) * 65535;
601 color.fBlue = ((i >> 2) & 1) * 65535;
602 if (gVirtualX->AllocColor(gVirtualX->GetColormap(), color) != 0) {
603 fColormap[fNColors][0] = color.fRed / 256;
604 fColormap[fNColors][1] = color.fGreen / 256;
605 fColormap[fNColors][2] = color.fBlue / 256;
606 fPixel[fNColors++] = color.fPixel;
607 }
608 }
609
610 // continue with what we got...
611}
612
613////////////////////////////////////////////////////////////////////////////////
614/// Free allocated colors.
615
617{
618 for (Int_t i = 0; i < fNColors; i++)
619 gVirtualX->FreeColor(gVirtualX->GetColormap(), fPixel[i]);
620 fNColors = 0;
621}
622
623////////////////////////////////////////////////////////////////////////////////
624/// Create a dithered version of the color map and lightness images for
625/// display modes with reduced number of colors. The Floyd-Steinberg error
626/// diffusion dithering algorithm is used.
627/// This routine is called in PseudoColor modes only.
628
630{
631 const Int_t kWidth = 20;
632
633 ColorStruct_t line[kWidth];
634 struct { Int_t r, g, b; } ed[kWidth], ef;
635 Int_t x, y, c, v, e[4], nc = 0;
636 Int_t r, g, b;
637 Int_t h, l, s;
638 Long_t dist, sdist;
639 Int_t iw, ih;
640
641 gVirtualX->GetImageSize(image, (UInt_t&) iw, (UInt_t&) ih);
642
643 for (x = 0; x < iw; ++x) {
644 ed[x].r = ed[x].g = ed[x].b = 0;
645 }
646
647 if (fNColors == 0) AllocColors();
648
649 for (y = 0; y < ih; ++y) {
650
651 if (which == kIMG_HS) {
652
653 for (x = 0; x < iw; ++x) {
654
655 h = x * 255 / iw;
656 l = 128;
657 s = (ih - y) * 255 / ih;
658
659 TColor::HLS2RGB(h, l, s, r, g, b);
660
661 line[x].fRed = r;
662 line[x].fGreen = g;
663 line[x].fBlue = b;
664 }
665
666 } else if (which == kIMG_L) {
667
669 TColor::RGB2HLS(r, g, b, h, l, s);
670
671 Int_t ll = (ih - y) * 255 / ih;
672
673 TColor::HLS2RGB(h, ll, s, r, g, b);
674
675 for (x = 0; x < iw; ++x) {
676 line[x].fRed = r;
677 line[x].fGreen = g;
678 line[x].fBlue = b;
679 }
680
681 } else {
682
683 return;
684
685 }
686
687 ef.r = ef.g = ef.b = 0; // no forward error for first pixel
688
689 for (x = 0; x < iw; ++x) {
690
691 // add errors from previous line
692
693 v = line[x].fRed + ed[x].r;
694 if (v < 0) v = 0; else if (v > 255) v = 255;
695 line[x].fRed = v;
696
697 v = line[x].fGreen + ed[x].g;
698 if (v < 0) v = 0; else if (v > 255) v = 255;
699 line[x].fGreen = v;
700
701 v = line[x].fBlue + ed[x].b;
702 if (v < 0) v = 0; else if (v > 255) v = 255;
703 line[x].fBlue = v;
704
705 }
706
707 for (x = 0; x < iw; ++x) {
708
709 // add forward errors
710
711 v = line[x].fRed + ef.r;
712 if (v < 0) v = 0; else if (v > 255) v = 255;
713 line[x].fRed = v;
714
715 v = line[x].fGreen + ef.g;
716 if (v < 0) v = 0; else if (v > 255) v = 255;
717 line[x].fGreen = v;
718
719 v = line[x].fBlue + ef.b;
720 if (v < 0) v = 0; else if (v > 255) v = 255;
721 line[x].fBlue = v;
722
723 // find the nearest color in colormap[]
724
725 sdist = 255L * 255L * 255L;
726 for (c = 0; c < fNColors; ++c) {
727
728 Int_t dr = line[x].fRed - fColormap[c][0];
729 Int_t dg = line[x].fGreen - fColormap[c][1];
730 Int_t db = line[x].fBlue - fColormap[c][2];
731
732 dist = dr * dr + dg * dg + db * db;
733 if (dist < sdist) {
734 nc = c;
735 sdist = dist;
736 }
737 }
738
739 gVirtualX->PutPixel(image, x, y, fPixel[nc]);
740
741#define FILTER(v) \
742 e[0] = (7 * v) >> 4; \
743 e[1] = v >> 4; \
744 e[2] = (5 * v) >> 4; \
745 e[3] = (3 * v) >> 4;
746
747 v = line[x].fRed - fColormap[nc][0];
748 FILTER(v)
749
750 ef.r = e[0];
751 if (x < iw-1) ed[x+1].r = e[1];
752 if (x == 0) ed[x].r = e[2]; else ed[x].r += e[2];
753 if (x > 0) ed[x-1].r += e[3];
754
755 v = line[x].fGreen - fColormap[nc][1];
756 FILTER(v)
757
758 ef.g = e[0];
759 if (x < iw-1) ed[x+1].g = e[1];
760 if (x == 0) ed[x].g = e[2]; else ed[x].g += e[2];
761 if (x > 0) ed[x-1].g += e[3];
762
763 v = line[x].fBlue - fColormap[nc][2];
764 FILTER(v)
765
766 ef.b = e[0];
767 if (x < iw-1) ed[x+1].b = e[1];
768 if (x == 0) ed[x].b = e[2]; else ed[x].b += e[2];
769 if (x > 0) ed[x-1].b += e[3];
770
771 }
772 }
773}
774
775////////////////////////////////////////////////////////////////////////////////
776/// Initialize color palette and slider images.
777
779{
780 Int_t width, height;
781 Int_t h, l, s;
782 Int_t r, g, b;
783
784 gVirtualX->GetImageSize(fHSimage, (UInt_t&) width, (UInt_t&) height);
785
786 // initialize fHSimage
787
788 Int_t ncolors = gVirtualX->GetDepth();
789
790 if (ncolors > 8) {
791 for (Int_t y = 0; y < height; ++y) {
792 for (Int_t x = 0; x < width; ++x) {
793
794 r = g = b = 0;
795 h = x * 255 / width;
796 l = 128;
797 s = (height - y) * 255 / height;
798
799 TColor::HLS2RGB(h, l, s, r, g, b);
800
801 ULong_t pixel = TColor::RGB2Pixel(r, g, b);
802 gVirtualX->PutPixel(fHSimage, x, y, pixel);
803 }
804 }
805 } else {
807 }
808
809 // initialize fLimage
810
812}
813
814////////////////////////////////////////////////////////////////////////////////
815/// Set slider colors.
816
818{
819 Int_t width, height;
820 Int_t h, l, s;
821 Int_t r, g, b;
822
823 gVirtualX->GetImageSize(fLimage, (UInt_t&) width, (UInt_t&) height);
824
825 Int_t ncolors = gVirtualX->GetDepth();
826
827 if (ncolors > 8) {
828
829 for (Int_t y = 0; y < height; ++y) {
830
832 TColor::RGB2HLS(r, g, b, h, l, s);
833
834 l = (height - y) * 255 / height;
835
836 TColor::HLS2RGB(h, l, s, r, g, b);
837
838 ULong_t pixel = TColor::RGB2Pixel(r, g, b);
839
840 for (Int_t x = 0; x < width; ++x) {
841 gVirtualX->PutPixel(fLimage, x, y, pixel);
842 }
843 }
844 } else {
846 }
847
848 gClient->NeedRedraw(this);
849}
850
851////////////////////////////////////////////////////////////////////////////////
852/// Position the slider cursor on right color position.
853
855{
856 UInt_t width, height;
857 Int_t h, l, s;
858 Int_t r, g, b;
859
860 gVirtualX->GetImageSize(fHSimage, width, height);
861
862 fCurrentColor = color;
863
865 TColor::RGB2HLS(r, g, b, h, l, s);
866
867 SetHScursor(h * (Int_t)width / 256, (255 - s) * (Int_t)height / 256);
868
869 gVirtualX->GetImageSize(fLimage, width, height);
870
871 SetLcursor((255 - l) * (Int_t)height / 256);
872
874}
875
876////////////////////////////////////////////////////////////////////////////////
877/// Assign the current cursor position as currently selected color.
878
880{
881 UInt_t lwidth, lheight;
882 UInt_t swidth, sheight;
883 Int_t r, g, b;
884 Int_t h, l, s;
885
886 gVirtualX->GetImageSize(fLimage, lwidth, lheight);
887 gVirtualX->GetImageSize(fHSimage, swidth, sheight);
888
889 h = Int_t(fCx * 255 / swidth);
890 l = Int_t((lheight - fCz) * 255 / lheight);
891 s = Int_t((sheight - fCy) * 255 / sheight);
892
893 TColor::HLS2RGB(h, l, s, r, g, b);
895}
896
897////////////////////////////////////////////////////////////////////////////////
898/// Redraw the color pick widget.
899
901{
902 UInt_t lwidth, lheight;
903 UInt_t swidth, sheight;
904
905 gVirtualX->GetImageSize(fLimage, lwidth, lheight);
906 gVirtualX->GetImageSize(fHSimage, swidth, sheight);
907
908 DrawBorder();
909
912 gVirtualX->PutImage(fId, GetBckgndGC()(), fHSimage,
913 fColormapRect.fX, fColormapRect.fY, 0, 0, swidth, sheight);
914
917 gVirtualX->PutImage(fId, GetBckgndGC()(), fLimage,
918 fSliderRect.fX, fSliderRect.fY, 0, 0, lwidth, lheight);
919
922}
923
924////////////////////////////////////////////////////////////////////////////////
925/// Set hue / saturation cursor position.
926
928{
929 UInt_t width, height;
930
931 gVirtualX->GetImageSize(fHSimage, width, height);
932
934
935 fCx = x;
936 fCy = y;
937
938 if (fCx < 0)
939 fCx = 0;
940 else if (fCx >= (Int_t)width)
941 fCx = (Int_t)width - 1;
942
943 if (fCy < 0)
944 fCy = 0;
945 else if (fCy >= (Int_t)height)
946 fCy = (Int_t)height - 1;
947
949}
950
951////////////////////////////////////////////////////////////////////////////////
952/// Set lightness slider cursor position.
953
955{
956 UInt_t width, height;
957
958 gVirtualX->GetImageSize(fLimage, width, height);
959
961
962 fCz = z - fSliderRect.fY;
963
964 if (fCz < 0)
965 fCz = 0;
966 else if (fCz >= (Int_t)height)
967 fCz = (Int_t)height - 1;
968
970}
971
972////////////////////////////////////////////////////////////////////////////////
973/// Draw hue / saturation cursor
974
976{
977 UInt_t width, height;
978
979 gVirtualX->GetImageSize(fHSimage, width, height);
980
981 if (onoff) {
982 Int_t x, y;
983 Rectangle_t rect;
984
985 x = fCx + fColormapRect.fX;
986 y = fCy + fColormapRect.fY;
987
988 rect.fX = fColormapRect.fX;
989 rect.fY = fColormapRect.fX;
992 gVirtualX->SetClipRectangles(fCursorGC(), 0, 0, &rect, 1);
993
994 gVirtualX->FillRectangle(fId, fCursorGC(), x - 9, y - 1, 5, 3);
995 gVirtualX->FillRectangle(fId, fCursorGC(), x - 1, y - 9, 3, 5);
996 gVirtualX->FillRectangle(fId, fCursorGC(), x + 5, y - 1, 5, 3);
997 gVirtualX->FillRectangle(fId, fCursorGC(), x - 1, y + 5, 3, 5);
998
999 } else {
1000 Int_t x, y;
1001 UInt_t w, h;
1002
1003 x = fCx - 9; w = 19;
1004 y = fCy - 9; h = 19;
1005
1006 if (x < 0) { w += x; x = 0; }
1007 if (y < 0) { h += y; y = 0; }
1008
1009 if (x + w > width) w = width - x;
1010 if (y + h > height) h = height - y;
1011
1012 gVirtualX->PutImage(fId, GetBckgndGC()(), fHSimage, x, y,
1013 fColormapRect.fX + x, fColormapRect.fY + y, w, h);
1014 }
1015}
1016
1017////////////////////////////////////////////////////////////////////////////////
1018/// Draw lightness slider cursor
1019
1021{
1023 Int_t r = l + 5;
1024 Int_t t = fCz - 5 + fSliderRect.fY;
1025 Int_t b = t + 10;
1026
1027 Point_t points[3];
1028
1029 Int_t m = (t + b) >> 1;
1030
1031 points[0].fX = r;
1032 points[0].fY = t;
1033 points[1].fX = r;
1034 points[1].fY = b;
1035 points[2].fX = l;
1036 points[2].fY = m;
1037
1038 GContext_t gc = onoff ? GetShadowGC()() : GetBckgndGC()();
1039
1040 gVirtualX->FillPolygon(fId, gc, points, 3);
1041}
1042
1043
1044////////////////////////////////////////////////////////////////////////////////
1045/// Color selection dialog constructor.
1046/// The TGColorDialog presents a full featured color selection dialog.
1047/// It uses 2 TGColorPalette's and the TGColorPick widgets.
1048
1050 Int_t *retc, ULong_t *color, Bool_t wait) :
1051 TGTransientFrame(p, m, 200, 150)
1052{
1053 const Int_t kC_X = 175; // Win95: 177
1054 const Int_t kC_Y = 180; // Win95: 189
1055
1056 Int_t i;
1057
1058 fRetc = retc;
1059 fRetColor = 0;
1060 fRetTColor = 0;
1061 fInitColor = 0;
1062 if (color) {
1063 fRetColor = color;
1066 }
1067 fWaitFor = wait;
1068
1069 if (fRetc) *fRetc = kMBCancel;
1070
1071 TGHorizontalFrame *hftop = new TGHorizontalFrame(this, 10, 10);
1072 hftop->SetCleanup();
1073 AddFrame(hftop, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 10, 5));
1074
1075 fTab = new TGTab(hftop, 300, 300);
1076 hftop->AddFrame(fTab);
1077
1078 TGCompositeFrame *cf = new TGCompositeFrame(hftop, 10, 10);
1079 cf->SetCleanup();
1080 hftop->AddFrame(cf, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 0, 30, 0));
1081
1082 TGCompositeFrame *cf1 = new TGCompositeFrame(cf, 10, 10);
1083 cf1->SetCleanup();
1084 cf->AddFrame(cf1, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 0, 30, 0));
1085 cf1->SetLayoutManager(new TGMatrixLayout(cf1, 0, 2, 4));
1086
1087 cf1->AddFrame(new TGLabel(cf1, new TGHotString("Red:")));
1088 cf1->AddFrame(fRte = new TGTextEntry(cf1, fRtb = new TGTextBuffer(5), kCDLG_RTE),0);
1090 cf1->AddFrame(new TGLabel(cf1, new TGHotString("Green:")),0);
1091 cf1->AddFrame(fGte = new TGTextEntry(cf1, fGtb = new TGTextBuffer(5), kCDLG_GTE),0);
1093 cf1->AddFrame(new TGLabel(cf1, new TGHotString("Blue:")));
1094 cf1->AddFrame(fBte = new TGTextEntry(cf1, fBtb = new TGTextBuffer(5), kCDLG_BTE),0);
1096 cf1->AddFrame(new TGLabel(cf1, new TGHotString("Opacity:")),0);
1097 cf1->AddFrame(fAle = new TGTextEntry(cf1, fAlb = new TGTextBuffer(5), kCDLG_ALE),0);
1099
1100 if (!TCanvas::SupportAlpha()) {
1102 }
1103
1104 TGCompositeFrame *cf2 = new TGCompositeFrame(cf, 10, 10);
1105 cf2->SetCleanup();
1106 cf->AddFrame(cf2, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 0, 30, 0));
1107 cf2->SetLayoutManager(new TGMatrixLayout(cf2, 0, 2, 4));
1108 cf2->AddFrame(new TGLabel(cf2, new TGHotString("Hue:")),0);
1109 cf2->AddFrame(fHte = new TGTextEntry(cf2, fHtb = new TGTextBuffer(5), kCDLG_HTE),0);
1111 cf2->AddFrame(new TGLabel(cf2, new TGHotString("Sat:")),0);
1112 cf2->AddFrame(fSte = new TGTextEntry(cf2, fStb = new TGTextBuffer(5), kCDLG_STE),0);
1114 cf2->AddFrame(new TGLabel(cf2, new TGHotString("Lum:")),0);
1115 cf2->AddFrame(fLte = new TGTextEntry(cf2, fLtb = new TGTextBuffer(5), kCDLG_LTE),0);
1117
1118 fHte->Associate(this);
1119 fLte->Associate(this);
1120 fSte->Associate(this);
1121 fRte->Associate(this);
1122 fGte->Associate(this);
1123 fBte->Associate(this);
1124 fAle->Associate(this);
1125
1126 if (color) {
1127 UpdateRGBentries(color);
1128 UpdateHLSentries(color);
1129 UpdateAlpha(color);
1130 fCurrentColor = *color;
1131 } else {
1132 gClient->GetColorByName("red", fCurrentColor);
1133 }
1134
1135 // color sample
1136 TGCompositeFrame *cf3 = new TGCompositeFrame(cf, 10, 10);
1137 cf3->SetCleanup();
1138 cf3->SetLayoutManager(new TGMatrixLayout(cf3, 0, 1, 0));
1139 cf3->AddFrame(fColorInfo = new TGLabel(cf3, new TGString("New: not set ")),0);
1141 cf3->AddFrame(fSample = new TGFrame(cf3, 50, 25, kOwnBackground),0);
1142 cf3->AddFrame(fSampleOld = new TGFrame(cf3, 50, 25, kOwnBackground),0);
1143 cf3->AddFrame(new TGLabel(cf3, new TGString("Current")),0);
1144 cf->AddFrame(cf3, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 20, 0));
1147
1148 TGCompositeFrame *tf = fTab->AddTab("Color Wheel");
1149 TGCompositeFrame *tf1 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame);
1150 tf->AddFrame(tf1);
1151 fEcanvas = new TRootEmbeddedCanvas("wheel", tf1, 360, 360);
1152 tf1->AddFrame(fEcanvas);
1153 TCanvas *wcan = fEcanvas->GetCanvas();
1154 wcan->SetBit(kNoContextMenu);
1155 fColorWheel = new TColorWheel();
1156 fColorWheel->SetCanvas(wcan);
1157 fColorWheel->Draw();
1158 wcan->Update();
1159 wcan->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","TGColorDialog",this,
1160 "SetColorInfo(Int_t,Int_t,Int_t,TObject*)");
1161
1162 tf = fTab->AddTab("Basic Colors");
1163 TGCompositeFrame *tf2 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame);
1164 tf->AddFrame(tf2);
1165
1166 TGVerticalFrame *vf1 = new TGVerticalFrame(tf2, 20, 20);
1167 vf1->SetCleanup();
1168 TGVerticalFrame *vf2 = new TGVerticalFrame(tf2, 20, 20);
1169 vf2->SetCleanup();
1170
1173
1174 //----------------------------------------- Left panel
1175
1176 // basic colors
1177
1178 fPalette = new TGColorPalette(vf1, 6, 8, kCDLG_SPALETTE);
1179 vf1->AddFrame(fPalette, new TGLayoutHints(kLHintsNormal, 5, 5, 15, 0));
1180 fPalette->Associate(this);
1181
1182 for (i = 0; i < 48; ++i)
1183 fPalette->SetColor(i, TColor::Number2Pixel(i+10)); // root colors
1184 // the basic colors were set via bcolor
1185 //fPalette->SetColor(i, TColor::GetPixel(bcolor[i][0], bcolor[i][1], bcolor[i][2]));
1186
1187 // add some default colors
1189
1190 Float_t r, g, b;
1191
1192 r = 232./255;
1193 g = 232./255;
1194 b = 222./255;
1195
1196 // Gui Builder background
1197 Pixel_t pixel = TColor::RGB2Pixel(r, g, b);
1198 fPalette->SetColor(46, pixel);
1199
1200 r = 230./255;
1201 g = 230./255;
1202 b = 230./255;
1203
1204 // a la MAC background
1205 pixel = TColor::RGB2Pixel(r, g, b);
1206 fPalette->SetColor(45, pixel);
1207
1208 r = 172./255;
1209 g = 174./255;
1210 b = 205./255;
1211
1212 // a la CDE background
1213 pixel = TColor::RGB2Pixel(r, g, b);
1214 fPalette->SetColor(44, pixel);
1215
1216 r = 205./255;
1217 g = 195./255;
1218 b = 175./255;
1219
1220 // a la FOX background
1221 pixel = TColor::RGB2Pixel(r, g, b);
1222 fPalette->SetColor(43, pixel);
1223
1224 // custom colors
1225
1226 vf1->AddFrame(new TGLabel(vf1, new TGHotString("&Custom Colors:")),
1227 new TGLayoutHints(kLHintsNormal, 5, 0, 15, 2));
1228
1229 fCpalette = new TGColorPalette(vf1, 6, 4, kCDLG_CPALETTE);
1230 vf1->AddFrame(fCpalette, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 0));
1231 fCpalette->Associate(this);
1232
1233 if (gUcolor[0] == 0xff000000) {
1234 for (i = 0; i < 24; i++)
1235 gUcolor[i] = TColor::RGB2Pixel(255, 255, 255);
1236 }
1238
1239 // button frame - OK, Cancel
1240 TGHorizontalFrame *hf = new TGHorizontalFrame(this, 10, 10, kFixedWidth);
1241 hf->SetCleanup();
1242 AddFrame(hf, new TGLayoutHints(kLHintsBottom | kLHintsRight, 5, 5, 10, 5));
1243
1244 TGTextButton *ok = new TGTextButton(hf, new TGHotString("OK"), kCDLG_OK);
1245 TGTextButton *cancel = new TGTextButton(hf, new TGHotString("Cancel"), kCDLG_CANCEL);
1246 fPreview = new TGTextButton(hf, new TGHotString("&Preview"), kCDLG_PREVIEW);
1247 fPreview->Connect("Clicked()", "TGColorDialog", this, "DoPreview()");
1248
1249 hf->AddFrame(ok, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 0, 3, 0, 0));
1250 hf->AddFrame(cancel, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,3, 0, 0, 0));
1252
1253 UInt_t w = ok->GetDefaultWidth();
1254 w = TMath::Max(w, cancel->GetDefaultWidth());
1255 hf->Resize(3 * (w + 30), hf->GetDefaultHeight());
1256
1257 ok->Associate(this);
1258 cancel->Associate(this);
1259
1260 //----------------------------------------- Right panel
1261
1262 // fColormap frame
1263
1264 fColors = new TGColorPick(vf2, kC_X + 23, kC_Y, kCDLG_COLORPICK);
1265 vf2->AddFrame(fColors, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 0, 15, 5));
1266 fColors->Associate(this);
1267
1268 if (color)
1269 fColors->SetColor(*color);
1270
1271 TGTextButton *add = new TGTextButton(vf2, new TGHotString("&Add to Custom Colors"),
1272 kCDLG_ADD);
1274 5, 10, 0, 5));
1275 add->Associate(this);
1276
1277 MapSubwindows();
1280
1281 //---- make the message box non-resizable
1282
1285
1286 SetWindowName("Color Selector");
1287 SetIconName("Color Selector");
1288 SetClassHints("ROOT", "ColorSelector");
1289
1295
1296
1297 //---- position relative to the parent's window
1298
1299 if (fClient->IsEditable()) {
1300 const TGWindow *main = fMain;
1301 fMain = fClient->GetRoot();
1303 fMain = main;
1304 } else {
1306 }
1307
1308 if (fWaitFor) {
1309 MapWindow();
1310 fClient->WaitForUnmap(this);
1311 DeleteWindow();
1312 }
1313}
1314
1315////////////////////////////////////////////////////////////////////////////////
1316/// TGColorDialog destructor.
1317
1319{
1320 fEcanvas->GetCanvas()->Disconnect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)");
1321 delete fEcanvas;
1322 Cleanup();
1323}
1324
1325////////////////////////////////////////////////////////////////////////////////
1326/// Change current color.
1327
1329{
1330 if (fCurrentColor == col) {
1331 return;
1332 }
1333 fInitColor = *fRetColor = col;
1334 if((fRetTColor = gROOT->GetColor(TColor::GetColor(col)))) {};
1335 fCurrentColor = col;
1336 fColors->SetColor(col);
1338 ColorSelected(col);
1339}
1340
1341////////////////////////////////////////////////////////////////////////////////
1342/// Emit signal about selected color.
1343
1345{
1346 Emit("ColorSelected(Pixel_t)", color);
1347}
1348
1349////////////////////////////////////////////////////////////////////////////////
1350/// Emit signal about selected alpha and color.
1351
1353{
1354 Emit("AlphaColorSelected(ULong_t)", color);
1355}
1356
1357////////////////////////////////////////////////////////////////////////////////
1358/// Called when window is closed via window manager.
1359
1361{
1362 // save user set colors
1363 for (Int_t i = 0; i < 24; ++i)
1365
1366 if (*fRetc != kMBOk) {
1368 ULong_t ptr;
1369 if((ptr = (ULong_t)gROOT->GetColor(TColor::GetColor(fInitColor)))) AlphaColorSelected(ptr);
1370 } else {
1373 }
1374 // don't call DeleteWindow() here since that will cause access
1375 // to the deleted dialog in the WaitFor() method (see ctor)
1376
1377 //OpenGL + XQuartz on Mac: gl context and related resources
1378 //must be deleted _before_ UnmapWindow.
1379 if (gVirtualX->InheritsFrom("TGX11") && fEcanvas->GetCanvas()->UseGL())
1381
1382 UnmapWindow();
1383}
1384
1385////////////////////////////////////////////////////////////////////////////////
1386/// Upadate Opacity text entry with alpha value of color c.
1387
1389{
1390 Char_t tmp[20];
1391 Double_t alpha;
1392
1393 if (TColor *color = gROOT->GetColor(TColor::GetColor(*c))) {
1394 alpha = color->GetAlpha();
1395 snprintf(tmp, 20, "%.1f", alpha);
1396 fAlb->Clear();
1397 fAlb->AddText(0,tmp);
1398 gClient->NeedRedraw(fAle);
1399 }
1400}
1401
1402
1403////////////////////////////////////////////////////////////////////////////////
1404/// Update RGB text entries with RGB values of color c.
1405
1407{
1408 Char_t tmp[20];
1409
1410 Int_t r, g, b;
1411 TColor::Pixel2RGB(*c, r, g, b);
1412
1413 snprintf(tmp, 20, "%d", r);
1414 fRtb->Clear();
1415 fRtb->AddText(0, tmp);
1416 gClient->NeedRedraw(fRte);
1417
1418 snprintf(tmp, 20, "%d", g);
1419 fGtb->Clear();
1420 fGtb->AddText(0, tmp);
1421 gClient->NeedRedraw(fGte);
1422
1423 snprintf(tmp, 20, "%d", b);
1424 fBtb->Clear();
1425 fBtb->AddText(0, tmp);
1426 gClient->NeedRedraw(fBte);
1427}
1428
1429////////////////////////////////////////////////////////////////////////////////
1430/// Update HLS text entries with HLS values of color c.
1431
1433{
1434 Char_t tmp[20];
1435
1436 Int_t h, l, s;
1437 Int_t r, g, b;
1438
1439 TColor::Pixel2RGB(*c, r, g, b);
1440 TColor::RGB2HLS(r, g, b, h, l, s);
1441
1442 snprintf(tmp, 20, "%d", h);
1443 fHtb->Clear();
1444 fHtb->AddText(0, tmp);
1445 gClient->NeedRedraw(fHte);
1446
1447 snprintf(tmp, 20, "%d", l);
1448 fLtb->Clear();
1449 fLtb->AddText(0, tmp);
1450 gClient->NeedRedraw(fLte);
1451
1452 snprintf(tmp, 20, "%d", s);
1453 fStb->Clear();
1454 fStb->AddText(0, tmp);
1455 gClient->NeedRedraw(fSte);
1456}
1457
1458////////////////////////////////////////////////////////////////////////////////
1459/// Process messages for the color selection dialog.
1460
1462{
1463 ULong_t color;
1464 Int_t h, l, s;
1465 Int_t r, g, b;
1466
1467 switch (GET_MSG(msg)) {
1468 case kC_COMMAND:
1469 switch (GET_SUBMSG(msg)) {
1470 case kCM_BUTTON:
1471 switch(parm1) {
1472 case kCDLG_ADD:
1474 break;
1475
1476 case kCDLG_OK:
1477 *fRetc = kMBOk;
1479 atoi(fGtb->GetString()),
1480 atoi(fBtb->GetString()));
1483 atof(fAlb->GetString()))));
1484 }
1485 CloseWindow();
1486 break;
1487 case kCDLG_CANCEL:
1488 if (!fClient->IsEditable()) {
1490 if (p && p->InheritsFrom("TGColorPopup"))
1492 }
1493 CloseWindow();
1494 break;
1495 }
1496 break;
1497 }
1498 break;
1499 case kC_COLORSEL:
1500 switch (GET_SUBMSG(msg)) {
1501 case kCOL_CLICK:
1502 switch (parm1) {
1503 case kCDLG_SPALETTE:
1504 color = fPalette->GetCurrentColor();
1506 ColorSelected(color);
1507 gClient->NeedRedraw(fSample);
1508 fCurrentColor = color;
1509 fColors->SetColor(color);
1510 UpdateRGBentries(&color);
1511 UpdateHLSentries(&color);
1512 UpdateAlpha(&color);
1513 break;
1514
1515 case kCDLG_CPALETTE:
1516 color = fCpalette->GetCurrentColor();
1518 ColorSelected(color);
1519 gClient->NeedRedraw(fSample);
1520 fCurrentColor = color;
1521 fColors->SetColor(color);
1522 UpdateRGBentries(&color);
1523 UpdateHLSentries(&color);
1524 UpdateAlpha(&color);
1525 break;
1526
1527 case kCDLG_COLORPICK:
1528 color = fColors->GetCurrentColor();
1530 ColorSelected(color);
1531 gClient->NeedRedraw(fSample);
1532 fCurrentColor = color;
1533 UpdateRGBentries(&color);
1534 UpdateHLSentries(&color);
1535 UpdateAlpha(&color);
1536 break;
1537
1538 }
1539 break;
1540 }
1541 break;
1542
1543 case kC_TEXTENTRY:
1544 switch (GET_SUBMSG(msg)) {
1545 case kTE_TEXTCHANGED:
1546 switch (parm1) {
1547 case kCDLG_HTE:
1548 case kCDLG_LTE:
1549 case kCDLG_STE:
1550
1551 h = atoi(fHtb->GetString());
1552 l = atoi(fLtb->GetString());
1553 s = atoi(fStb->GetString());
1554 TColor::HLS2RGB(h, l, s, r, g, b);
1555
1556 color = TColor::RGB2Pixel(r, g, b);
1558 ColorSelected(color);
1559 gClient->NeedRedraw(fSample);
1560 fCurrentColor = color;
1561 fColors->SetColor(color);
1562 UpdateRGBentries(&color);
1563 break;
1564
1565 case kCDLG_RTE:
1566 case kCDLG_GTE:
1567 case kCDLG_BTE:
1568 color = TColor::RGB2Pixel(atoi(fRtb->GetString()),
1569 atoi(fGtb->GetString()),
1570 atoi(fBtb->GetString()));
1572 ColorSelected(color);
1573 gClient->NeedRedraw(fSample);
1574 fCurrentColor = color;
1575 fColors->SetColor(color);
1576 UpdateHLSentries(&color);
1577 break;
1578
1579 }
1580 break;
1581 }
1582 break;
1583 }
1584
1585 return kTRUE;
1586}
1587
1588////////////////////////////////////////////////////////////////////////////////
1589/// Set the color info in RGB and HLS parts
1590
1592{
1593 if (object == fColorWheel) {
1594 Int_t n = fColorWheel->GetColor(px,py);
1595 if (n < 0) return;
1596 TColor *color = gROOT->GetColor(n);
1597 if (!color) return;
1598 ULong_t pcolor = color->GetPixel();
1599 if (event == kButton1Down) {
1600 UpdateRGBentries(&pcolor);
1601 UpdateHLSentries(&pcolor);
1602 UpdateAlpha(&pcolor);
1603 fSample->SetBackgroundColor(pcolor);
1604 fColorInfo->SetText(Form("New: %s",color->GetName()));
1605 gClient->NeedRedraw(fSample);
1606 gClient->NeedRedraw(fColorInfo);
1607 fCurrentColor = pcolor;
1608 fColors->SetColor(pcolor);
1609 ColorSelected(pcolor);
1610 }
1611 }
1612}
1613
1614////////////////////////////////////////////////////////////////////////////////
1615/// Slot method called when Preview button is clicked.
1616
1618{
1619 TColor *tcolor;
1620 if ((tcolor = gROOT->GetColor(TColor::GetColor(fSample->GetBackground())))) {
1621 tcolor->SetAlpha(TMath::Max((Double_t)0, TMath::Min((Double_t)1, atof(fAlb->GetString()))));
1622 }
1623
1624 if (fClient->IsEditable()) {
1626 AlphaColorSelected((ULong_t)tcolor);
1627 return;
1628 }
1630 if (p && p->InheritsFrom("TGColorPopup")) {
1631 if (tcolor) p->PreviewAlphaColor((ULong_t)tcolor);
1633 }
1634}
@ kButton1Down
Definition Buttons.h:17
@ kGKeyPress
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
const Mask_t kFocusChangeMask
Definition GuiTypes.h:169
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kKeyReleaseMask
Definition GuiTypes.h:160
const Mask_t kAnyModifier
Definition GuiTypes.h:210
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
const Mask_t kKeyPressMask
Definition GuiTypes.h:159
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
@ kChildFrame
Definition GuiTypes.h:379
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:168
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:166
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
const Mask_t kEnterWindowMask
Definition GuiTypes.h:167
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton1
Definition GuiTypes.h:214
@ kAnyButton
Definition GuiTypes.h:214
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
ROOT::R::TRInterface & r
Definition Object.C:4
#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
int Int_t
Definition RtypesCore.h:45
char Char_t
Definition RtypesCore.h:37
const Bool_t kFALSE
Definition RtypesCore.h:92
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
#define gClient
Definition TGClient.h:166
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:73
@ kMWMFuncAll
Definition TGFrame.h:57
@ kMWMFuncResize
Definition TGFrame.h:58
@ kMWMDecorMaximize
Definition TGFrame.h:77
@ kMWMDecorMinimize
Definition TGFrame.h:76
@ kMWMDecorMenu
Definition TGFrame.h:75
@ kMWMDecorAll
Definition TGFrame.h:71
@ kMWMFuncMaximize
Definition TGFrame.h:61
@ kMWMInputModeless
Definition TGFrame.h:65
@ kMWMFuncMinimize
Definition TGFrame.h:60
@ kLHintsRight
Definition TGLayout.h:33
@ kLHintsExpandY
Definition TGLayout.h:38
@ kLHintsLeft
Definition TGLayout.h:31
@ kLHintsNormal
Definition TGLayout.h:39
@ kLHintsBottom
Definition TGLayout.h:36
@ kLHintsTop
Definition TGLayout.h:34
@ kLHintsExpandX
Definition TGLayout.h:37
@ kMBCancel
Definition TGMsgBox.h:44
@ kMBOk
Definition TGMsgBox.h:40
@ kTextLeft
Definition TGWidget.h:33
@ kWidgetIsEnabled
Definition TGWidget.h:47
XFontStruct * id
Definition TGX11.cxx:109
@ kNoContextMenu
Definition TObject.h:360
#define gROOT
Definition TROOT.h:406
char * Form(const char *fmt,...)
#define gVirtualX
Definition TVirtualX.h:338
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)
point * points
Definition X3DBuffer.c:22
Color * colors
Definition X3DBuffer.c:21
#define snprintf
Definition civetweb.c:1540
The Canvas class.
Definition TCanvas.h:23
void DeleteCanvasPainter()
assert on IsBatch() == false?
Definition TCanvas.cxx:2617
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
Definition TCanvas.cxx:2491
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2504
Bool_t UseGL() const
Definition TCanvas.h:223
Draw the ROOT Color Wheel.
Definition TColorWheel.h:23
virtual void Draw(Option_t *option="")
Paint the color wheel.
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.
The color creation and management class.
Definition TColor.h:19
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:1454
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:2054
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition TColor.cxx:2016
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:1769
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:2092
ULong_t GetPixel() const
Return pixel value corresponding to this color.
Definition TColor.cxx:1437
virtual void SetAlpha(Float_t a)
Definition TColor.h:67
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:1594
Bool_t IsEditable() const
Definition TGClient.h:98
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:223
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition TGClient.cxx:736
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:133
TGTextEntry * fLte
TGTextEntry * fBte
TGColorPalette * fPalette
TGLabel * fColorInfo
virtual void SetCurrentColor(Pixel_t col)
Change current color.
void DoPreview()
Slot method called when Preview button is clicked.
virtual void CloseWindow()
Called when window is closed via window manager.
TGTextEntry * fRte
TColorWheel * fColorWheel
TGTextBuffer * fStb
TGTextBuffer * fAlb
TGTextButton * fPreview
Pixel_t fCurrentColor
Pixel_t * fRetColor
TGColorPick * fColors
TGColorDialog(const TGColorDialog &)=delete
TColor * fRetTColor
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
TGColorPalette * fCpalette
TGTextBuffer * fLtb
virtual void ColorSelected(Pixel_t)
Emit signal about selected color.
TGTextEntry * fAle
TGFrame * fSample
TGTextBuffer * fBtb
TGTextBuffer * fHtb
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages for the color selection dialog.
TGTextBuffer * fRtb
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
virtual ~TGColorDialog()
TGColorDialog destructor.
TGTextEntry * fGte
void UpdateAlpha(Pixel_t *c)
Upadate Opacity text entry with alpha value of color c.
virtual void AlphaColorSelected(ULong_t)
Emit signal about selected alpha and color.
TGTextEntry * fSte
TGTextBuffer * fGtb
virtual Bool_t HandleKey(Event_t *event)
Handle keyboard events in color palette.
void SetCellSize(Int_t w=20, Int_t h=17)
Set color cell size.
virtual ~TGColorPalette()
Destructor.
virtual Bool_t HandleButton(Event_t *event)
Handle button events in color palette.
void SetColors(Pixel_t colors[])
Set color entries in color samples.
virtual void DoRedraw()
Redraw color palette.
Pixel_t GetColorByIndex(Int_t ix) const
virtual void LostFocus()
Remove keyboard input.
Pixel_t GetCurrentColor() const
Return currently selected color value.
void SetCurrentCellColor(Pixel_t color)
Set current cell color.
void DrawFocusHilite(Int_t onoff)
Draw a highlight rectangle around cell obtaining focus.
Pixel_t * fPixels
virtual void GotFocus()
Add keyboard input.
void SetColor(Int_t ix, Pixel_t color)
Set color at index ix of color entries.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion events in color palette.
TGColorPalette(const TGColorPalette &)=delete
virtual void ColorSelected(Pixel_t col=0)
void SetLcursor(Int_t z)
Set lightness slider cursor position.
Pixmap_t fLimage
Pixmap_t fHSimage
void UpdateCurrentColor()
Assign the current cursor position as currently selected color.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion events in color pick widget.
virtual ~TGColorPick()
TGColorPick destructor.
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
void SetSliderColor()
Set slider colors.
void AllocColors()
Try to allocate first a palette of 64 colors.
Rectangle_t fColormapRect
TGColorPick(const TGWindow *p=0, Int_t w=1, Int_t h=1, Int_t id=-1)
TGColorPick constructor.
void FreeColors()
Free allocated colors.
Pixel_t GetCurrentColor() const
Int_t fColormap[64][3]
void DrawHScursor(Int_t onoff)
Draw hue / saturation cursor.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events in color pick widget.
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.
virtual void DoRedraw()
Redraw the color pick widget.
void InitImages()
Initialize color palette and slider images.
Rectangle_t fSliderRect
void SetHScursor(Int_t x, Int_t y)
Set hue / saturation cursor position.
Pixel_t fPixel[64]
void PreviewAlphaColor(ULong_t color)
Emit a signal to see preview.
void PreviewColor(Pixel_t color)
Emit a signal to see preview.
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:985
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:952
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1057
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:352
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1149
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:350
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1007
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:324
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
Definition TGFrame.cxx:333
UInt_t fHeight
Definition TGFrame.h:112
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:214
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:215
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:406
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:342
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:297
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition TGFrame.cxx:630
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:668
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:261
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:750
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
UInt_t fWidth
Definition TGFrame.h:111
virtual Pixel_t GetBackground() const
Definition TGFrame.h:216
virtual void MapWindow()
map window
Definition TGFrame.h:228
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:760
virtual void UnmapWindow()
unmap window
Definition TGFrame.h:230
void SetForeground(Pixel_t v)
Set foreground color.
Definition TGGC.cxx:277
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
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition TGFrame.cxx:1817
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1762
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition TGFrame.cxx:1852
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
Definition TGFrame.cxx:1827
void SetWMSizeHints(UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc)
Give the window manager minimum and maximum size hints.
Definition TGFrame.cxx:1865
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1749
TGClient * fClient
Definition TGObject.h:37
Handle_t fId
Definition TGObject.h:36
const TGGC * GetFrameGC() const
Definition TGTab.h:62
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition TGTab.cxx:343
void AddText(Int_t pos, const char *text)
const char * GetString() const
void SetEnabled(Bool_t flag=kTRUE)
const TGWindow * GetMain() const
Definition TGFrame.h:568
const TGWindow * fMain
Definition TGFrame.h:555
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
Definition TGFrame.cxx:1916
Int_t fWidgetId
Definition TGWidget.h:56
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:82
Bool_t HasFocus() const
Definition TGWidget.h:80
Int_t fWidgetFlags
Definition TGWidget.h:57
const TGWindow * fMsgWindow
Definition TGWidget.h:58
Bool_t IsEnabled() const
Definition TGWidget.h:79
Bool_t WantFocus() const
Definition TGWidget.h:81
@ kEditDisable
Definition TGWindow.h:58
UInt_t fEditDisabled
Definition TGWindow.h:40
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:37
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:149
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:696
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:445
void MakeZombie()
Definition TObject.h:49
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:866
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
TCanvas * GetCanvas() const
TLine * line
int main()
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)
Definition TMathBase.h:212
Short_t Min(Short_t a, Short_t b)
Definition TMathBase.h:180
ULong_t fPixel
color pixel value (index in color table)
Definition GuiTypes.h:311
UShort_t fRed
red component (0..65535)
Definition GuiTypes.h:312
UShort_t fGreen
green component (0..65535)
Definition GuiTypes.h:313
UShort_t fBlue
blue component (0..65535)
Definition GuiTypes.h:314
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Int_t fX
Definition GuiTypes.h:178
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Point structure (maps to the X11 XPoint structure)
Definition GuiTypes.h:356
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:361
Short_t fX
Definition GuiTypes.h:362
UShort_t fHeight
Definition GuiTypes.h:363
Short_t fY
Definition GuiTypes.h:362
UShort_t fWidth
Definition GuiTypes.h:363
auto * m
Definition textangle.C:8
auto * l
Definition textangle.C:4