Logo ROOT   6.08/07
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 #ifndef ROOT_TGFrame
40 #include "TGFrame.h"
41 #endif
42 #ifndef ROOT_TGButton
43 #include "TGButton.h"
44 #endif
45 
46 
47 //----------------------------------------------------------------------
48 
49 class TGColorFrame : public TGFrame {
50 
51 protected:
52  const TGWindow *fMsgWindow; // window handling container messages
53  Pixel_t fPixel; // color value of this cell
54  Bool_t fActive; // kTRUE if this color cell is active
55  GContext_t fGrayGC; // Shadow GC
56  Pixel_t fColor; // returned color value
57 
58 private:
59  TGColorFrame(const TGColorFrame&); // not implemented
60  TGColorFrame& operator=(const TGColorFrame&); // not implemented
61 
62 public:
63  TGColorFrame(const TGWindow *p = 0, Pixel_t c = 0, Int_t n = 1);
64  virtual ~TGColorFrame() { }
65 
66  virtual Bool_t HandleButton(Event_t *event);
67  virtual void DrawBorder();
68 
69  void SetActive(Bool_t in) { fActive = in; gClient->NeedRedraw(this); }
70  Pixel_t GetColor() const { return fColor; }
71 
72  ClassDef(TGColorFrame,0) // Frame for color cell
73 };
74 
75 //----------------------------------------------------------------------
76 
78 
79 protected:
80  Int_t fActive; // index of active color cell
81  const TGWindow *fMsgWindow; // window handling container messages
82  TGColorFrame *fCe[16]; // matrix of color cells
83 
84 private:
85  TG16ColorSelector(const TG16ColorSelector&); // not implemented
86  TG16ColorSelector& operator=(const TG16ColorSelector&); // not implemented
87 
88 public:
89  TG16ColorSelector(const TGWindow *p = 0);
90  virtual ~TG16ColorSelector();
91 
92  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
93 
94  void SetActive(Int_t newat);
95  Int_t GetActive() { return fActive; }
96 
97  ClassDef(TG16ColorSelector,0) // 16 color cells
98 };
99 
100 //----------------------------------------------------------------------
101 
103 
104 protected:
105  Int_t fActive; // active color index
106  Int_t fLaunchDialog; // flag used for launching color dialog
107  const TGWindow *fMsgWindow; // window handling container messages
108  Pixel_t fCurrentColor; // currently selected color value
109 
110 private:
111  TGColorPopup(const TGColorPopup&); // not implemented
112  TGColorPopup& operator=(const TGColorPopup&); // not implemented
113 
114 public:
115  TGColorPopup(const TGWindow *p = 0, const TGWindow *m = 0, Pixel_t color = 0);
116  virtual ~TGColorPopup();
117 
118  virtual Bool_t HandleButton(Event_t *event);
119  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
120 
121  void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
122  void EndPopup();
123  void PreviewColor(Pixel_t color);
124  void PreviewAlphaColor(ULong_t color);
125 
126  ClassDef(TGColorPopup,0) // Color selector popup
127 };
128 
129 //----------------------------------------------------------------------
130 
131 class TGColorSelect : public TGCheckButton {
132 
133 protected:
134  Pixel_t fColor; // color value of the button
135  TGGC fDrawGC; // drawing GC
136  TGColorPopup *fColorPopup; // color popup associated
137  TGPosition fPressPos; // psotion of frame on button press event
138 
139  virtual void DoRedraw();
140 
141  void DrawTriangle(GContext_t gc, Int_t x, Int_t y);
142 
143 private:
144  TGColorSelect(const TGColorSelect&); // not implemented
145  TGColorSelect& operator=(const TGColorSelect&); // not implemented
146 
147 public:
148  TGColorSelect(const TGWindow *p = 0, Pixel_t color = 0,
149  Int_t id = -1);
150  virtual ~TGColorSelect();
151 
152  virtual Bool_t HandleButton(Event_t *event);
153  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
154 
155  void SetColor(Pixel_t color, Bool_t emit = kTRUE);
156  void SetAlphaColor(ULong_t color, Bool_t emit = kTRUE);
157  Pixel_t GetColor() const { return fColor; }
158  void Enable(Bool_t on = kTRUE); //*TOGGLE* *GETTER=IsEnabled
159  void Disable();
160 
161  // dummy methods just to remove from context menu
162  void SetDown(Bool_t on = kTRUE, Bool_t emit = kFALSE) { TGButton::SetDown(on, emit); }
163  void Rename(const char *title) { TGTextButton::SetTitle(title); }
165 
166  virtual TGDimension GetDefaultSize() const { return TGDimension(43, 21); }
167  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
168 
169  virtual void ColorSelected(Pixel_t color = 0)
170  { Emit("ColorSelected(Pixel_t)", color ? color : GetColor()); } //*SIGNAL*
171  virtual void AlphaColorSelected(ULong_t colptr = 0)
172  { Emit("AlphaColorSelected(ULong_t)", colptr); } //*SIGNAL*
173 
174  ClassDef(TGColorSelect,0) // Color selection checkbutton
175 };
176 
177 #endif
virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t)
Definition: TGFrame.h:246
void SetActive(Bool_t in)
Definition: TGColorSelect.h:69
return c
const char Option_t
Definition: RtypesCore.h:62
virtual Bool_t HandleButton(Event_t *event)
Handle button events in TGColorFrame.
TH1 * h
Definition: legend2.C:5
void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Pixel_t fPixel
Definition: TGColorSelect.h:53
virtual void AlphaColorSelected(ULong_t colptr=0)
Handle_t GContext_t
Definition: GuiTypes.h:39
#define gClient
Definition: TGClient.h:174
Int_t fLaunchDialog
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Pixel_t fCurrentColor
const Bool_t kFALSE
Definition: Rtypes.h:92
void Rename(const char *title)
Pixel_t GetColor() const
Definition: TGColorSelect.h:70
TGColorPopup * fColorPopup
virtual void SetTitle(const char *label)
Definition: TGButton.h:200
virtual void DrawBorder()
Draw TGColorFrame border.
TGPosition fPressPos
Bool_t fActive
Definition: TGColorSelect.h:54
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:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:561
const TGWindow * fMsgWindow
const TGWindow * fMsgWindow
Definition: TGColorSelect.h:81
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:3188
Pixel_t GetColor() const
TGColorFrame & operator=(const TGColorFrame &)
unsigned int UInt_t
Definition: RtypesCore.h:42
TMarker * m
Definition: textangle.C:8
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:56
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:64
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:55
virtual void ColorSelected(Pixel_t color=0)
virtual TGDimension GetDefaultSize() const
default size
const Bool_t kTRUE
Definition: Rtypes.h:91
Definition: TGGC.h:35
const Int_t n
Definition: legend1.C:16
const TGWindow * fMsgWindow
Definition: TGColorSelect.h:52