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
22class TGColorFrame : public TGFrame {
23
24protected:
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
31private:
32 TGColorFrame(const TGColorFrame&) = delete;
34
35public:
36 TGColorFrame(const TGWindow *p = nullptr, Pixel_t c = 0, Int_t n = 1);
37 virtual ~TGColorFrame() { }
38
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
52protected:
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
57private:
60
61public:
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
77protected:
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
83private:
84 TGColorPopup(const TGColorPopup&) = delete;
86
87public:
88 TGColorPopup(const TGWindow *p = nullptr, const TGWindow *m = nullptr, Pixel_t color = 0);
89 virtual ~TGColorPopup();
90
92 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
93
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
105
106protected:
107 Pixel_t fColor; ///< color value of the button
108 TGGC fDrawGC; ///< drawing GC
109 TGColorPopup *fColorPopup; ///< color popup associated
110 TGPosition fPressPos; ///< position of frame on button press event
111
112 virtual void DoRedraw();
113
115
116private:
117 TGColorSelect(const TGColorSelect&) = delete;
119
120public:
121 TGColorSelect(const TGWindow *p = nullptr, Pixel_t color = 0,
122 Int_t id = -1);
123 virtual ~TGColorSelect();
124
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
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
#define c(i)
Definition: RSha256.hxx:101
#define h(i)
Definition: RSha256.hxx:106
#define e(i)
Definition: RSha256.hxx:103
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
const Bool_t kFALSE
Definition: RtypesCore.h:101
unsigned long ULong_t
Definition: RtypesCore.h:55
long Long_t
Definition: RtypesCore.h:54
bool Bool_t
Definition: RtypesCore.h:63
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:325
#define gClient
Definition: TGClient.h:157
A composite frame with 16 TGColorFrames.
Definition: TGColorSelect.h:50
void SetActive(Int_t newat)
Set active color frame.
TG16ColorSelector & operator=(const TG16ColorSelector &)=delete
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages for TG16ColorSelector.
TGColorFrame * fCe[16]
matrix of color cells
Definition: TGColorSelect.h:55
Int_t fActive
index of active color cell
Definition: TGColorSelect.h:53
virtual ~TG16ColorSelector()
TG16ColorSelector destructor.
const TGWindow * fMsgWindow
window handling container messages
Definition: TGColorSelect.h:54
TG16ColorSelector(const TG16ColorSelector &)=delete
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.cxx:310
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:459
Selects different options.
Definition: TGButton.h:264
A small frame with border showing a specific color.
Definition: TGColorSelect.h:22
virtual Bool_t HandleButton(Event_t *event)
Handle button events in TGColorFrame.
TGColorFrame(const TGColorFrame &)=delete
GContext_t fGrayGC
Shadow GC.
Definition: TGColorSelect.h:28
TGColorFrame & operator=(const TGColorFrame &)=delete
Pixel_t GetColor() const
Definition: TGColorSelect.h:43
const TGWindow * fMsgWindow
window handling container messages
Definition: TGColorSelect.h:25
virtual ~TGColorFrame()
Definition: TGColorSelect.h:37
virtual void DrawBorder()
Draw TGColorFrame border.
void SetActive(Bool_t in)
Definition: TGColorSelect.h:42
Bool_t fActive
kTRUE if this color cell is active
Definition: TGColorSelect.h:27
Pixel_t fPixel
color value of this cell
Definition: TGColorSelect.h:26
Pixel_t fColor
returned color value
Definition: TGColorSelect.h:29
A popup containing a TG16ColorSelector and a "More..." button which popups up a TGColorDialog allowin...
Definition: TGColorSelect.h:75
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events for TGColorPopup.
const TGWindow * fMsgWindow
window handling container messages
Definition: TGColorSelect.h:80
TGColorPopup & operator=(const TGColorPopup &)=delete
virtual ~TGColorPopup()
TGColorPopup destructor.
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages for TGColorPopup.
void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
Popup TGColorPopup at x,y position.
void EndPopup()
Ungrab pointer and unmap window.
void PreviewAlphaColor(ULong_t color)
Emit a signal to see preview.
TGColorPopup(const TGColorPopup &)=delete
Pixel_t fCurrentColor
currently selected color value
Definition: TGColorSelect.h:81
Int_t fLaunchDialog
flag used for launching color dialog
Definition: TGColorSelect.h:79
void PreviewColor(Pixel_t color)
Emit a signal to see preview.
Int_t fActive
active color index
Definition: TGColorSelect.h:78
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
TGColorPopup * fColorPopup
color popup associated
TGGC fDrawGC
drawing GC
TGColorSelect & operator=(const TGColorSelect &)=delete
virtual void AlphaColorSelected(ULong_t colptr=0)
void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
virtual TGDimension GetDefaultSize() const
default size
Pixel_t fColor
color value of the button
virtual ~TGColorSelect()
TGColorSelect destructor.
TGColorSelect(const TGColorSelect &)=delete
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages for TGColorSelect.
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
TGPosition fPressPos
position of frame on button press event
void Enable(Bool_t on=kTRUE)
Set state of widget as enabled.
virtual void ColorSelected(Pixel_t color=0)
void Rename(const char *title)
void SetAlphaColor(ULong_t color, Bool_t emit=kTRUE)
Set color.
void Disable()
Set state of widget as disabled.
virtual Bool_t HandleButton(Event_t *event)
Handle button events for TGColorSelect.
Pixel_t GetColor() const
void DrawTriangle(GContext_t gc, Int_t x, Int_t y)
Draw triangle (arrow) on which user can click to open TGColorPopup.
virtual void DoRedraw()
Redraw TGColorSelect widget.
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a color select widget as a C++ statement(s) on output stream out.
The base class for composite widgets (menu bars, list boxes, etc.).
Definition: TGFrame.h:287
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition: TGFrame.h:80
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
virtual void SetTitle(const char *label)
Definition: TGButton.h:196
ROOT GUI Window base class.
Definition: TGWindow.h:23
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
Event structure.
Definition: GuiTypes.h:174
auto * m
Definition: textangle.C:8