Logo ROOT   6.14/05
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-2002, 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 
45 class TGColorFrame : public TGFrame {
46 
47 protected:
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 
54 private:
55  TGColorFrame(const TGColorFrame&); // not implemented
56  TGColorFrame& operator=(const TGColorFrame&); // not implemented
57 
58 public:
59  TGColorFrame(const TGWindow *p = 0, 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 
75 protected:
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 
80 private:
81  TG16ColorSelector(const TG16ColorSelector&); // not implemented
82  TG16ColorSelector& operator=(const TG16ColorSelector&); // not implemented
83 
84 public:
85  TG16ColorSelector(const TGWindow *p = 0);
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 
100 protected:
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 
106 private:
107  TGColorPopup(const TGColorPopup&); // not implemented
108  TGColorPopup& operator=(const TGColorPopup&); // not implemented
109 
110 public:
111  TGColorPopup(const TGWindow *p = 0, const TGWindow *m = 0, 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 
127 class TGColorSelect : public TGCheckButton {
128 
129 protected:
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 
137  void DrawTriangle(GContext_t gc, Int_t x, Int_t y);
138 
139 private:
140  TGColorSelect(const TGColorSelect&); // not implemented
141  TGColorSelect& operator=(const TGColorSelect&); // not implemented
142 
143 public:
144  TGColorSelect(const TGWindow *p = 0, 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
virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t)
Definition: TGFrame.h:230
void SetActive(Bool_t in)
Definition: TGColorSelect.h:65
auto * m
Definition: textangle.C:8
const char Option_t
Definition: RtypesCore.h:62
virtual Bool_t HandleButton(Event_t *event)
Handle button events in TGColorFrame.
void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Pixel_t fPixel
Definition: TGColorSelect.h:49
virtual void AlphaColorSelected(ULong_t colptr=0)
Handle_t GContext_t
Definition: GuiTypes.h:37
#define gClient
Definition: TGClient.h:166
Int_t fLaunchDialog
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Pixel_t fCurrentColor
void Rename(const char *title)
Pixel_t GetColor() const
Definition: TGColorSelect.h:66
TGColorPopup * fColorPopup
virtual void SetTitle(const char *label)
Definition: TGButton.h:196
virtual void DrawBorder()
Draw TGColorFrame border.
TGPosition fPressPos
Bool_t fActive
Definition: TGColorSelect.h:50
virtual void DoRedraw()
Redraw the frame.
Definition: TGFrame.cxx:412
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:320
ULong_t Pixel_t
Definition: GuiTypes.h:39
const TGWindow * fMsgWindow
const TGWindow * fMsgWindow
Definition: TGColorSelect.h:77
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a frame widget as a C++ statement(s) on output stream out.
Definition: TGFrame.cxx:3187
Pixel_t GetColor() const
TGColorFrame & operator=(const TGColorFrame &)
unsigned int UInt_t
Definition: RtypesCore.h:42
#define h(i)
Definition: RSha256.hxx:106
const Bool_t kFALSE
Definition: RtypesCore.h:88
TGColorFrame(const TGColorFrame &)
long Long_t
Definition: RtypesCore.h:50
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
unsigned long ULong_t
Definition: RtypesCore.h:51
Pixel_t fColor
Definition: TGColorSelect.h:52
Double_t y[n]
Definition: legend1.C:17
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
virtual ~TGColorFrame()
Definition: TGColorSelect.h:60
void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.cxx:260
GContext_t fGrayGC
Definition: TGColorSelect.h:51
virtual void ColorSelected(Pixel_t color=0)
#define c(i)
Definition: RSha256.hxx:101
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
virtual TGDimension GetDefaultSize() const
default size
const Bool_t kTRUE
Definition: RtypesCore.h:87
Definition: TGGC.h:31
const Int_t n
Definition: legend1.C:16
const TGWindow * fMsgWindow
Definition: TGColorSelect.h:48