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