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#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 ~TGColorFrame() override { }
38
39 Bool_t HandleButton(Event_t *event) override;
40 void DrawBorder() override;
41
42 void SetActive(Bool_t in) { fActive = in; gClient->NeedRedraw(this); }
43 Pixel_t GetColor() const { return fColor; }
44
45 ClassDefOverride(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 ~TG16ColorSelector() override;
64
65 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
66
67 void SetActive(Int_t newat);
68 Int_t GetActive() { return fActive; }
69
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 ~TGColorPopup() override;
90
91 Bool_t HandleButton(Event_t *event) override;
92 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
93
95 void EndPopup();
96 void PreviewColor(Pixel_t color);
97 void PreviewAlphaColor(ULongptr_t color);
98
99 ClassDefOverride(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 void DoRedraw() override;
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 ~TGColorSelect() override;
124
125 Bool_t HandleButton(Event_t *event) override;
126 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
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) override { TGButton::SetDown(on, emit); }
136 void Rename(const char *title) { TGTextButton::SetTitle(title); }
138
139 TGDimension GetDefaultSize() const override { return TGDimension(43, 21); }
140 void SavePrimitive(std::ostream &out, Option_t * = "") override;
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 ClassDefOverride(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
bool Bool_t
Definition RtypesCore.h:63
long Longptr_t
Definition RtypesCore.h:82
unsigned long ULong_t
Definition RtypesCore.h:55
unsigned long ULongptr_t
Definition RtypesCore.h:83
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
#define gClient
Definition TGClient.h:156
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
A composite frame with 16 TGColorFrames.
void SetActive(Int_t newat)
Set active color frame.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process messages for TG16ColorSelector.
TG16ColorSelector & operator=(const TG16ColorSelector &)=delete
~TG16ColorSelector() override
TG16ColorSelector destructor.
TGColorFrame * fCe[16]
matrix of color cells
Int_t fActive
index of active color cell
const TGWindow * fMsgWindow
window handling container messages
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.
Bool_t HandleButton(Event_t *event) override
Handle button events in TGColorFrame.
TGColorFrame(const TGColorFrame &)=delete
~TGColorFrame() override
GContext_t fGrayGC
Shadow GC.
TGColorFrame & operator=(const TGColorFrame &)=delete
Pixel_t GetColor() const
const TGWindow * fMsgWindow
window handling container messages
void SetActive(Bool_t in)
void DrawBorder() override
Draw TGColorFrame border.
Bool_t fActive
kTRUE if this color cell is active
Pixel_t fPixel
color value of this cell
Pixel_t fColor
returned color value
A popup containing a TG16ColorSelector and a "More..." button which popups up a TGColorDialog allowin...
~TGColorPopup() override
TGColorPopup destructor.
const TGWindow * fMsgWindow
window handling container messages
Bool_t HandleButton(Event_t *event) override
Handle mouse button events for TGColorPopup.
TGColorPopup & operator=(const TGColorPopup &)=delete
void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
Popup TGColorPopup at x,y position.
void PreviewAlphaColor(ULongptr_t color)
Emit a signal to see preview.
void EndPopup()
Ungrab pointer and unmap window.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process messages for TGColorPopup.
TGColorPopup(const TGColorPopup &)=delete
Pixel_t fCurrentColor
currently selected color value
Int_t fLaunchDialog
flag used for launching color dialog
void PreviewColor(Pixel_t color)
Emit a signal to see preview.
Int_t fActive
active color index
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
TGColorPopup * fColorPopup
color popup associated
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process messages for TGColorSelect.
TGGC fDrawGC
drawing GC
TGColorSelect & operator=(const TGColorSelect &)=delete
virtual void AlphaColorSelected(ULong_t colptr=0)
void DoRedraw() override
Redraw TGColorSelect widget.
TGDimension GetDefaultSize() const override
default size
void SavePrimitive(std::ostream &out, Option_t *="") override
Save a color select widget as a C++ statement(s) on output stream out.
Pixel_t fColor
color value of the button
TGColorSelect(const TGColorSelect &)=delete
void SetEnabled(Bool_t e=kTRUE) override
Set enabled or disabled state of button.
void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE) override
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
TGPosition fPressPos
position of frame on button press event
Bool_t HandleButton(Event_t *event) override
Handle button events for TGColorSelect.
void Enable(Bool_t on=kTRUE)
Set state of widget as enabled.
virtual void ColorSelected(Pixel_t color=0)
void Rename(const char *title)
~TGColorSelect() override
TGColorSelect destructor.
void SetAlphaColor(ULong_t color, Bool_t emit=kTRUE)
Set color.
void Disable()
Set state of widget as disabled.
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.
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
TMarker m
Definition textangle.C:8