CMS 3D CMS Logo

FWColorSelect.h
Go to the documentation of this file.
1 #ifndef Fireworks_Core_FWColorSelect_h
2 #define Fireworks_Core_FWColorSelect_h
3 
4 #include "TGLabel.h"
5 #include "TGButton.h"
6 #include "TGColorSelect.h"
7 
8 #include <vector>
9 
10 class FWColorManager;
11 class TGColorPopup;
12 
13 
14 //------------------------------FWColorFrame------------------------------//
15 
16 class FWColorFrame : public TGFrame
17 {
18 protected:
19  Color_t fColor;
20 
21 public:
22  FWColorFrame(const TGWindow *p=nullptr, Color_t ci=0);
23  ~FWColorFrame() override {}
24 
25  Bool_t HandleButton(Event_t *event) override;
26  void DrawBorder() override {}
27 
28  void SetColor(Color_t);
29  Color_t GetColor() const { return fColor; }
30 
31  void ColorSelected(Color_t); // *SIGNAL*
32 
34 
35 };
36 
37 
38 //------------------------------FWColorRow------------------------------//
39 
40 class FWColorRow : public TGHorizontalFrame
41 {
42  void DrawHighlight();
43 
44 protected:
47  std::vector<FWColorFrame *> fCc;
48 
49  void DoRedraw() override;
50 
51 public:
52  FWColorRow(const TGWindow *p=nullptr);
53  ~FWColorRow() override;
54 
55  virtual void AddColor(Color_t color);
56 
57  void ResetColor(Int_t, Color_t);
58  void SetBackgroundToBlack(Bool_t);
59 
60  //if it can't find the color it returns -1
61  Int_t FindColorIndex(Color_t) const;
62 
63  Int_t GetSelectedIndex() const { return fSelectedIndex; }
64  void SetSelectedIndex(Int_t i) { fSelectedIndex = i; }
65 
66  void ColorChanged(Color_t); // *SIGNAL*
67 
69 
70 };
71 
72 
73 //------------------------------FWColorPopup------------------------------//
74 
75 class FWColorPopup : public TGVerticalFrame
76 {
77 private:
78  void SetColors(const std::vector<Pixel_t>& colors, bool backgroundIsBlack);
79 
80 protected:
81  Color_t fSelectedColor;
82  FWColorRow *fFirstRow, *fSecondRow;
83  TGLabel *fLabel;
84  Int_t fNumColors;
85  Bool_t fShowWheel;
86 
87  static Bool_t fgFreePalette;
88 
89 public:
90  FWColorPopup(const TGWindow *p=nullptr, Color_t color=0);
91  ~FWColorPopup() override;
92 
93  Bool_t HandleButton(Event_t *event) override;
94 
95  void InitContent(const char *name, const std::vector<Color_t>& colors, bool backgroundIsBlack=true);
96  void SetName(const char* iName) override;
97  void SetColors(const std::vector<Color_t>& colors, bool backgroundIsBlack=true);
98  void ResetColors(const std::vector<Color_t>& colors, bool backgroundIsBlack=true);
99  void SetSelection(Color_t);
100  void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
101 
102  void ColorSelected(Color_t); // *SIGNAL*
103 
104  void PopupColorWheel();
105  void ColorWheelSelected(Pixel_t);
106 
107  static Bool_t HasFreePalette();
108  static void EnableFreePalette();
109 
111 };
112 
113 
114 //------------------------------FWColorSelect------------------------------//
115 
116 class FWColorSelect : public TGColorSelect
117 {
118 private:
120  Color_t fSelectedColor;
123 
124 
125 public:
126  FWColorSelect(const TGWindow *p, const char *label, Color_t colorIndex,
127  const FWColorManager*, Int_t id);
128  ~FWColorSelect() override;
129 
130  Bool_t HandleButton(Event_t *event) override;
131 
132  void SetColorByIndex(Color_t iColor);
133  void SetColorByIndex(Color_t iColor, Bool_t iSendSignal);
134  void UpdateColors();
135  const std::string& label() const { return fLabel; }
136  void ColorChosen(Color_t); // *SIGNAL*
137 
139 
140 };
141 #endif
Int_t fSelectedIndex
Definition: FWColorSelect.h:46
ClassDefOverride(FWColorFrame, 0)
Bool_t fShowWheel
Definition: FWColorSelect.h:85
const double w
Definition: UKUtility.cc:23
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
FWColorPopup * fFireworksPopup
TGLabel * fLabel
Definition: FWColorSelect.h:83
void DrawBorder() override
Definition: FWColorSelect.h:26
char const * label
FWColorRow * fSecondRow
Definition: FWColorSelect.h:82
~FWColorFrame() override
Definition: FWColorSelect.h:23
static Bool_t fgFreePalette
Definition: FWColorSelect.h:87
const std::string & label() const
void ColorSelected(Color_t)
Int_t fNumColors
Definition: FWColorSelect.h:84
void SetColor(Color_t)
Color_t fSelectedColor
Color_t fSelectedColor
Definition: FWColorSelect.h:81
Bool_t HandleButton(Event_t *event) override
FWColorFrame(const TGWindow *p=nullptr, Color_t ci=0)
Color_t GetColor() const
Definition: FWColorSelect.h:29
const FWColorManager * fColorManager
Bool_t fBackgroundIsBlack
Definition: FWColorSelect.h:45
Int_t GetSelectedIndex() const
Definition: FWColorSelect.h:63
std::string fLabel
Definition: colors.py:1
void SetSelectedIndex(Int_t i)
Definition: FWColorSelect.h:64
Color_t fColor
Definition: FWColorSelect.h:19
std::vector< FWColorFrame * > fCc
Definition: FWColorSelect.h:47
Definition: event.py:1