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