Logo ROOT  
Reference Guide
TGColorSelect.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Bertrand Bellenot + Fons Rademakers 22/08/02
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGColorSelect
13 #define ROOT_TGColorSelect
14 
15 
16 #include "TGFrame.h"
17 #include "TGButton.h"
18 
19 
20 //----------------------------------------------------------------------
21 
22 class TGColorFrame : public TGFrame {
23 
24 protected:
25  const TGWindow *fMsgWindow; // window handling container messages
26  Pixel_t fPixel; // color value of this cell
27  Bool_t fActive; // kTRUE if this color cell is active
28  GContext_t fGrayGC; // Shadow GC
29  Pixel_t fColor; // returned color value
30 
31 private:
32  TGColorFrame(const TGColorFrame&) = delete;
33  TGColorFrame& operator=(const TGColorFrame&) = delete;
34 
35 public:
36  TGColorFrame(const TGWindow *p = nullptr, Pixel_t c = 0, Int_t n = 1);
37  virtual ~TGColorFrame() { }
38 
39  virtual Bool_t HandleButton(Event_t *event);
40  virtual void DrawBorder();
41 
42  void SetActive(Bool_t in) { fActive = in; gClient->NeedRedraw(this); }
43  Pixel_t GetColor() const { return fColor; }
44 
45  ClassDef(TGColorFrame,0) // Frame for color cell
46 };
47 
48 //----------------------------------------------------------------------
49 
51 
52 protected:
53  Int_t fActive; // index of active color cell
54  const TGWindow *fMsgWindow; // window handling container messages
55  TGColorFrame *fCe[16]; // matrix of color cells
56 
57 private:
60 
61 public:
62  TG16ColorSelector(const TGWindow *p = nullptr);
63  virtual ~TG16ColorSelector();
64 
65  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
66 
67  void SetActive(Int_t newat);
68  Int_t GetActive() { return fActive; }
69 
70  ClassDef(TG16ColorSelector,0) // 16 color cells
71 };
72 
73 //----------------------------------------------------------------------
74 
76 
77 protected:
78  Int_t fActive; // active color index
79  Int_t fLaunchDialog; // flag used for launching color dialog
80  const TGWindow *fMsgWindow; // window handling container messages
81  Pixel_t fCurrentColor; // currently selected color value
82 
83 private:
84  TGColorPopup(const TGColorPopup&) = delete;
85  TGColorPopup& operator=(const TGColorPopup&) = delete;
86 
87 public:
88  TGColorPopup(const TGWindow *p = nullptr, const TGWindow *m = nullptr, Pixel_t color = 0);
89  virtual ~TGColorPopup();
90 
91  virtual Bool_t HandleButton(Event_t *event);
92  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
93 
94  void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
95  void EndPopup();
96  void PreviewColor(Pixel_t color);
97  void PreviewAlphaColor(ULong_t color);
98 
99  ClassDef(TGColorPopup,0) // Color selector popup
100 };
101 
102 //----------------------------------------------------------------------
103 
104 class TGColorSelect : public TGCheckButton {
105 
106 protected:
107  Pixel_t fColor; // color value of the button
108  TGGC fDrawGC; // drawing GC
109  TGColorPopup *fColorPopup; // color popup associated
110  TGPosition fPressPos; // psotion of frame on button press event
111 
112  virtual void DoRedraw();
113 
114  void DrawTriangle(GContext_t gc, Int_t x, Int_t y);
115 
116 private:
117  TGColorSelect(const TGColorSelect&) = delete;
119 
120 public:
121  TGColorSelect(const TGWindow *p = nullptr, Pixel_t color = 0,
122  Int_t id = -1);
123  virtual ~TGColorSelect();
124 
125  virtual Bool_t HandleButton(Event_t *event);
126  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
127 
128  void SetColor(Pixel_t color, Bool_t emit = kTRUE);
129  void SetAlphaColor(ULong_t color, Bool_t emit = kTRUE);
130  Pixel_t GetColor() const { return fColor; }
131  void Enable(Bool_t on = kTRUE); //*TOGGLE* *GETTER=IsEnabled
132  void Disable();
133 
134  // dummy methods just to remove from context menu
135  void SetDown(Bool_t on = kTRUE, Bool_t emit = kFALSE) { TGButton::SetDown(on, emit); }
136  void Rename(const char *title) { TGTextButton::SetTitle(title); }
138 
139  virtual TGDimension GetDefaultSize() const { return TGDimension(43, 21); }
140  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
141 
142  virtual void ColorSelected(Pixel_t color = 0)
143  { Emit("ColorSelected(Pixel_t)", color ? color : GetColor()); } //*SIGNAL*
144  virtual void AlphaColorSelected(ULong_t colptr = 0)
145  { Emit("AlphaColorSelected(ULong_t)", colptr); } //*SIGNAL*
146 
147  ClassDef(TGColorSelect,0) // Color selection checkbutton
148 };
149 
150 #endif
c
#define c(i)
Definition: RSha256.hxx:101
TGColorSelect::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a color select widget as a C++ statement(s) on output stream out.
Definition: TGColorSelect.cxx:677
m
auto * m
Definition: textangle.C:8
n
const Int_t n
Definition: legend1.C:16
TGButton::SetEnabled
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:459
TGColorPopup::~TGColorPopup
virtual ~TGColorPopup()
TGColorPopup destructor.
Definition: TGColorSelect.cxx:259
TGColorFrame
A small frame with border showing a specific color.
Definition: TGColorSelect.h:22
TGColorPopup::fActive
Int_t fActive
Definition: TGColorSelect.h:78
TGColorSelect::fColor
Pixel_t fColor
Definition: TGColorSelect.h:107
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
TGColorPopup::fLaunchDialog
Int_t fLaunchDialog
Definition: TGColorSelect.h:79
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:95
e
#define e(i)
Definition: RSha256.hxx:103
TGDimension
Definition: TGDimension.h:18
TG16ColorSelector
A composite frame with 16 TGColorFrames.
Definition: TGColorSelect.h:50
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGColorFrame::fActive
Bool_t fActive
Definition: TGColorSelect.h:27
TGTextButton::SetTitle
virtual void SetTitle(const char *label)
Definition: TGButton.h:196
TGButton::SetDown
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.cxx:310
TGColorSelect::Disable
void Disable()
Set state of widget as disabled.
Definition: TGColorSelect.cxx:531
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TG16ColorSelector::fCe
TGColorFrame * fCe[16]
Definition: TGColorSelect.h:55
TGColorSelect::GetColor
Pixel_t GetColor() const
Definition: TGColorSelect.h:130
TGColorPopup::PreviewColor
void PreviewColor(Pixel_t color)
Emit a signal to see preview.
Definition: TGColorSelect.cxx:380
x
Double_t x[n]
Definition: legend1.C:17
TGColorFrame::~TGColorFrame
virtual ~TGColorFrame()
Definition: TGColorSelect.h:37
TGColorSelect::SetDown
void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGColorSelect.h:135
TGColorFrame::fColor
Pixel_t fColor
Definition: TGColorSelect.h:29
TGColorPopup::EndPopup
void EndPopup()
Ungrab pointer and unmap window.
Definition: TGColorSelect.cxx:267
TGFrame
Definition: TGFrame.h:80
TGColorFrame::fPixel
Pixel_t fPixel
Definition: TGColorSelect.h:26
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGColorFrame::operator=
TGColorFrame & operator=(const TGColorFrame &)=delete
TGColorSelect::DrawTriangle
void DrawTriangle(GContext_t gc, Int_t x, Int_t y)
Draw triangle (arrow) on which user can click to open TGColorPopup.
Definition: TGColorSelect.cxx:625
bool
TG16ColorSelector::~TG16ColorSelector
virtual ~TG16ColorSelector()
TG16ColorSelector destructor.
Definition: TGColorSelect.cxx:164
TG16ColorSelector::fActive
Int_t fActive
Definition: TGColorSelect.h:53
TGColorSelect::~TGColorSelect
virtual ~TGColorSelect()
TGColorSelect destructor.
Definition: TGColorSelect.cxx:428
TGColorPopup::fCurrentColor
Pixel_t fCurrentColor
Definition: TGColorSelect.h:81
TGColorSelect::Enable
void Enable(Bool_t on=kTRUE)
Set state of widget as enabled.
Definition: TGColorSelect.cxx:518
GContext_t
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
TG16ColorSelector::GetActive
Int_t GetActive()
Definition: TGColorSelect.h:68
gClient
#define gClient
Definition: TGClient.h:157
TGColorSelect::TGColorSelect
TGColorSelect(const TGColorSelect &)=delete
TGCheckButton
Selects different options.
Definition: TGButton.h:264
TG16ColorSelector::TG16ColorSelector
TG16ColorSelector(const TG16ColorSelector &)=delete
TGColorFrame::fMsgWindow
const TGWindow * fMsgWindow
Definition: TGColorSelect.h:25
TG16ColorSelector::fMsgWindow
const TGWindow * fMsgWindow
Definition: TGColorSelect.h:54
TG16ColorSelector::operator=
TG16ColorSelector & operator=(const TG16ColorSelector &)=delete
TGColorSelect::DoRedraw
virtual void DoRedraw()
Redraw TGColorSelect widget.
Definition: TGColorSelect.cxx:540
TGColorPopup::operator=
TGColorPopup & operator=(const TGColorPopup &)=delete
TGColorPopup::TGColorPopup
TGColorPopup(const TGColorPopup &)=delete
h
#define h(i)
Definition: RSha256.hxx:106
TGGC
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
TGColorFrame::SetActive
void SetActive(Bool_t in)
Definition: TGColorSelect.h:42
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:96
TGColorSelect::ColorSelected
virtual void ColorSelected(Pixel_t color=0)
Definition: TGColorSelect.h:142
TGFrame.h
Long_t
long Long_t
Definition: RtypesCore.h:54
TGColorPopup::PreviewAlphaColor
void PreviewAlphaColor(ULong_t color)
Emit a signal to see preview.
Definition: TGColorSelect.cxx:391
y
Double_t y[n]
Definition: legend1.C:17
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TGColorPopup::ProcessMessage
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages for TGColorPopup.
Definition: TGColorSelect.cxx:347
TGColorFrame::fGrayGC
GContext_t fGrayGC
Definition: TGColorSelect.h:28
unsigned int
TGColorFrame::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle button events in TGColorFrame.
Definition: TGColorSelect.cxx:106
TGColorPopup::fMsgWindow
const TGWindow * fMsgWindow
Definition: TGColorSelect.h:80
TGColorSelect::AlphaColorSelected
virtual void AlphaColorSelected(ULong_t colptr=0)
Definition: TGColorSelect.h:144
TGColorSelect::SetAlphaColor
void SetAlphaColor(ULong_t color, Bool_t emit=kTRUE)
Set color.
Definition: TGColorSelect.cxx:666
TGColorFrame::DrawBorder
virtual void DrawBorder()
Draw TGColorFrame border.
Definition: TGColorSelect.cxx:120
TGColorSelect::fColorPopup
TGColorPopup * fColorPopup
Definition: TGColorSelect.h:109
TGColorPopup
A popup containing a TG16ColorSelector and a "More..." button which popups up a TGColorDialog allowin...
Definition: TGColorSelect.h:75
TGColorSelect::GetDefaultSize
virtual TGDimension GetDefaultSize() const
default size
Definition: TGColorSelect.h:139
TGColorSelect::fPressPos
TGPosition fPressPos
Definition: TGColorSelect.h:110
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGButton.h
Event_t
Event structure.
Definition: GuiTypes.h:174
TGColorFrame::GetColor
Pixel_t GetColor() const
Definition: TGColorSelect.h:43
TGColorFrame::TGColorFrame
TGColorFrame(const TGColorFrame &)=delete
TGColorSelect::SetColor
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
Definition: TGColorSelect.cxx:654
TGColorSelect::SetEnabled
void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGColorSelect.h:137
TGColorSelect
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
Definition: TGColorSelect.h:104
TGColorSelect::operator=
TGColorSelect & operator=(const TGColorSelect &)=delete
TGPosition
Definition: TGDimension.h:36
TG16ColorSelector::ProcessMessage
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages for TG16ColorSelector.
Definition: TGColorSelect.cxx:188
TGCompositeFrame
The base class for composite widgets (menu bars, list boxes, etc.).
Definition: TGFrame.h:287
TGColorSelect::ProcessMessage
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages for TGColorSelect.
Definition: TGColorSelect.cxx:436
TGColorSelect::Rename
void Rename(const char *title)
Definition: TGColorSelect.h:136
TGColorPopup::PlacePopup
void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
Popup TGColorPopup at x,y position.
Definition: TGColorSelect.cxx:276
TGColorSelect::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle button events for TGColorSelect.
Definition: TGColorSelect.cxx:469
TGColorSelect::fDrawGC
TGGC fDrawGC
Definition: TGColorSelect.h:108
TG16ColorSelector::SetActive
void SetActive(Int_t newat)
Set active color frame.
Definition: TGColorSelect.cxx:172
TGColorPopup::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events for TGColorPopup.
Definition: TGColorSelect.cxx:328
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
int