Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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// //
17// TGColorFrame, TG16ColorSelector, TGColorPopup and TGColorSelect. //
18// //
19// The TGColorFrame is a small frame with border showing a specific //
20// color. //
21// //
22// The TG16ColorSelector is a composite frame with 16 TGColorFrames. //
23// //
24// The TGColorPopup is a popup containing a TG16ColorSelector and a //
25// "More..." button which popups up a TGColorDialog allowing custom //
26// color selection. //
27// //
28// The TGColorSelect widget is like a checkbutton but instead of the //
29// check mark there is color area with a little down arrow. When //
30// clicked on the arrow the TGColorPopup pops up. //
31// //
32// Selecting a color in this widget will generate the event: //
33// kC_COLORSEL, kCOL_SELCHANGED, widget id, pixel. //
34// and the signal: //
35// ColorSelected(Pixel_t pixel) //
36// //
37//////////////////////////////////////////////////////////////////////////
38
39#include "TGFrame.h"
40#include "TGButton.h"
41
42
43//----------------------------------------------------------------------
44
45class TGColorFrame : public TGFrame {
46
47protected:
48 const TGWindow *fMsgWindow; // window handling container messages
49 Pixel_t fPixel; // color value of this cell
50 Bool_t fActive; // kTRUE if this color cell is active
51 GContext_t fGrayGC; // Shadow GC
52 Pixel_t fColor; // returned color value
53
54private:
55 TGColorFrame(const TGColorFrame&) = delete;
57
58public:
59 TGColorFrame(const TGWindow *p = nullptr, Pixel_t c = 0, Int_t n = 1);
60 virtual ~TGColorFrame() { }
61
62 virtual Bool_t HandleButton(Event_t *event);
63 virtual void DrawBorder();
64
65 void SetActive(Bool_t in) { fActive = in; gClient->NeedRedraw(this); }
66 Pixel_t GetColor() const { return fColor; }
67
68 ClassDef(TGColorFrame,0) // Frame for color cell
69};
70
71//----------------------------------------------------------------------
72
74
75protected:
76 Int_t fActive; // index of active color cell
77 const TGWindow *fMsgWindow; // window handling container messages
78 TGColorFrame *fCe[16]; // matrix of color cells
79
80private:
83
84public:
85 TG16ColorSelector(const TGWindow *p = nullptr);
86 virtual ~TG16ColorSelector();
87
88 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
89
90 void SetActive(Int_t newat);
91 Int_t GetActive() { return fActive; }
92
93 ClassDef(TG16ColorSelector,0) // 16 color cells
94};
95
96//----------------------------------------------------------------------
97
99
100protected:
101 Int_t fActive; // active color index
102 Int_t fLaunchDialog; // flag used for launching color dialog
103 const TGWindow *fMsgWindow; // window handling container messages
104 Pixel_t fCurrentColor; // currently selected color value
105
106private:
107 TGColorPopup(const TGColorPopup&) = delete;
109
110public:
111 TGColorPopup(const TGWindow *p = nullptr, const TGWindow *m = nullptr, Pixel_t color = 0);
112 virtual ~TGColorPopup();
113
114 virtual Bool_t HandleButton(Event_t *event);
115 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
116
117 void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
118 void EndPopup();
119 void PreviewColor(Pixel_t color);
120 void PreviewAlphaColor(ULong_t color);
121
122 ClassDef(TGColorPopup,0) // Color selector popup
123};
124
125//----------------------------------------------------------------------
126
128
129protected:
130 Pixel_t fColor; // color value of the button
131 TGGC fDrawGC; // drawing GC
132 TGColorPopup *fColorPopup; // color popup associated
133 TGPosition fPressPos; // psotion of frame on button press event
134
135 virtual void DoRedraw();
136
138
139private:
140 TGColorSelect(const TGColorSelect&) = delete;
142
143public:
144 TGColorSelect(const TGWindow *p = nullptr, Pixel_t color = 0,
145 Int_t id = -1);
146 virtual ~TGColorSelect();
147
148 virtual Bool_t HandleButton(Event_t *event);
149 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
150
151 void SetColor(Pixel_t color, Bool_t emit = kTRUE);
152 void SetAlphaColor(ULong_t color, Bool_t emit = kTRUE);
153 Pixel_t GetColor() const { return fColor; }
154 void Enable(Bool_t on = kTRUE); //*TOGGLE* *GETTER=IsEnabled
155 void Disable();
156
157 // dummy methods just to remove from context menu
158 void SetDown(Bool_t on = kTRUE, Bool_t emit = kFALSE) { TGButton::SetDown(on, emit); }
159 void Rename(const char *title) { TGTextButton::SetTitle(title); }
161
162 virtual TGDimension GetDefaultSize() const { return TGDimension(43, 21); }
163 virtual void SavePrimitive(std::ostream &out, Option_t * = "");
164
165 virtual void ColorSelected(Pixel_t color = 0)
166 { Emit("ColorSelected(Pixel_t)", color ? color : GetColor()); } //*SIGNAL*
167 virtual void AlphaColorSelected(ULong_t colptr = 0)
168 { Emit("AlphaColorSelected(ULong_t)", colptr); } //*SIGNAL*
169
170 ClassDef(TGColorSelect,0) // Color selection checkbutton
171};
172
173#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
const Bool_t kFALSE
Definition RtypesCore.h:92
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:91
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
#define gClient
Definition TGClient.h:166
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]
virtual ~TG16ColorSelector()
TG16ColorSelector destructor.
const TGWindow * fMsgWindow
TG16ColorSelector(const TG16ColorSelector &)=delete
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition TGButton.cxx:263
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:412
virtual Bool_t HandleButton(Event_t *event)
Handle button events in TGColorFrame.
TGColorFrame(const TGColorFrame &)=delete
GContext_t fGrayGC
TGColorFrame & operator=(const TGColorFrame &)=delete
Pixel_t GetColor() const
const TGWindow * fMsgWindow
virtual ~TGColorFrame()
virtual void DrawBorder()
Draw TGColorFrame border.
void SetActive(Bool_t in)
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events for TGColorPopup.
const TGWindow * fMsgWindow
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
void PreviewColor(Pixel_t color)
Emit a signal to see preview.
TGColorPopup * fColorPopup
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
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
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.
Definition TGGC.h:31
virtual void SetTitle(const char *label)
Definition TGButton.h:196
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