File indexing completed on 2025-01-18 10:11:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGColorSelect
0013 #define ROOT_TGColorSelect
0014
0015
0016 #include "TGFrame.h"
0017 #include "TGButton.h"
0018
0019
0020
0021
0022 class TGColorFrame : public TGFrame {
0023
0024 protected:
0025 const TGWindow *fMsgWindow;
0026 Pixel_t fPixel;
0027 Bool_t fActive;
0028 GContext_t fGrayGC;
0029 Pixel_t fColor;
0030
0031 private:
0032 TGColorFrame(const TGColorFrame&) = delete;
0033 TGColorFrame& operator=(const TGColorFrame&) = delete;
0034
0035 public:
0036 TGColorFrame(const TGWindow *p = nullptr, Pixel_t c = 0, Int_t n = 1);
0037 ~TGColorFrame() override { }
0038
0039 Bool_t HandleButton(Event_t *event) override;
0040 void DrawBorder() override;
0041
0042 void SetActive(Bool_t in) { fActive = in; gClient->NeedRedraw(this); }
0043 Pixel_t GetColor() const { return fColor; }
0044
0045 ClassDefOverride(TGColorFrame,0)
0046 };
0047
0048
0049
0050 class TG16ColorSelector : public TGCompositeFrame {
0051
0052 protected:
0053 Int_t fActive;
0054 const TGWindow *fMsgWindow;
0055 TGColorFrame *fCe[16];
0056
0057 private:
0058 TG16ColorSelector(const TG16ColorSelector&) = delete;
0059 TG16ColorSelector& operator=(const TG16ColorSelector&) = delete;
0060
0061 public:
0062 TG16ColorSelector(const TGWindow *p = nullptr);
0063 ~TG16ColorSelector() override;
0064
0065 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0066
0067 void SetActive(Int_t newat);
0068 Int_t GetActive() { return fActive; }
0069
0070 ClassDefOverride(TG16ColorSelector,0)
0071 };
0072
0073
0074
0075 class TGColorPopup : public TGCompositeFrame {
0076
0077 protected:
0078 Int_t fActive;
0079 Int_t fLaunchDialog;
0080 const TGWindow *fMsgWindow;
0081 Pixel_t fCurrentColor;
0082
0083 private:
0084 TGColorPopup(const TGColorPopup&) = delete;
0085 TGColorPopup& operator=(const TGColorPopup&) = delete;
0086
0087 public:
0088 TGColorPopup(const TGWindow *p = nullptr, const TGWindow *m = nullptr, Pixel_t color = 0);
0089 ~TGColorPopup() override;
0090
0091 Bool_t HandleButton(Event_t *event) override;
0092 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0093
0094 void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
0095 void EndPopup();
0096 void PreviewColor(Pixel_t color);
0097 void PreviewAlphaColor(ULongptr_t color);
0098
0099 ClassDefOverride(TGColorPopup,0)
0100 };
0101
0102
0103
0104 class TGColorSelect : public TGCheckButton {
0105
0106 protected:
0107 Pixel_t fColor;
0108 TGGC fDrawGC;
0109 TGColorPopup *fColorPopup;
0110 TGPosition fPressPos;
0111
0112 void DoRedraw() override;
0113
0114 void DrawTriangle(GContext_t gc, Int_t x, Int_t y);
0115
0116 private:
0117 TGColorSelect(const TGColorSelect&) = delete;
0118 TGColorSelect& operator=(const TGColorSelect&) = delete;
0119
0120 public:
0121 TGColorSelect(const TGWindow *p = nullptr, Pixel_t color = 0,
0122 Int_t id = -1);
0123 ~TGColorSelect() override;
0124
0125 Bool_t HandleButton(Event_t *event) override;
0126 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0127
0128 void SetColor(Pixel_t color, Bool_t emit = kTRUE);
0129 void SetAlphaColor(ULong_t color, Bool_t emit = kTRUE);
0130 Pixel_t GetColor() const { return fColor; }
0131 void Enable(Bool_t on = kTRUE);
0132 void Disable();
0133
0134
0135 void SetDown(Bool_t on = kTRUE, Bool_t emit = kFALSE) override { TGButton::SetDown(on, emit); }
0136 void Rename(const char *title) { TGTextButton::SetTitle(title); }
0137 void SetEnabled(Bool_t e = kTRUE) override { TGButton::SetEnabled(e); }
0138
0139 TGDimension GetDefaultSize() const override { return TGDimension(43, 21); }
0140 void SavePrimitive(std::ostream &out, Option_t * = "") override;
0141
0142 virtual void ColorSelected(Pixel_t color = 0)
0143 { Emit("ColorSelected(Pixel_t)", color ? color : GetColor()); }
0144 virtual void AlphaColorSelected(ULong_t colptr = 0)
0145 { Emit("AlphaColorSelected(ULong_t)", colptr); }
0146
0147 ClassDefOverride(TGColorSelect,0)
0148 };
0149
0150 #endif