#ifndef ROOT_TGColorDialog
#define ROOT_TGColorDialog
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
#ifndef ROOT_TGWidget
#include "TGWidget.h"
#endif
class TGTextEntry;
class TGTextBuffer;
class TGTab;
class TRootEmbeddedCanvas;
class TColorWheel;
class TGLabel;
class TGTextButton;
class TGColorPalette : public TGFrame, public TGWidget {
private:
TGColorPalette(const TGColorPalette&);
TGColorPalette& operator=(const TGColorPalette&);
protected:
Int_t fCx;
Int_t fCy;
UInt_t fCw;
UInt_t fCh;
Int_t fRows;
Int_t fCols;
Pixel_t *fPixels;
TGGC fDrawGC;
virtual void DoRedraw();
virtual void GotFocus();
virtual void LostFocus();
void DrawFocusHilite(Int_t onoff);
public:
TGColorPalette(const TGWindow *p = 0, Int_t cols = 8, Int_t rows = 8, Int_t id = -1);
virtual ~TGColorPalette();
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleMotion(Event_t *event);
virtual Bool_t HandleKey(Event_t *event);
virtual TGDimension GetDefaultSize() const
{ return TGDimension((fCw + 5) * fCols, (fCh + 5) * fRows); }
void SetColors(Pixel_t colors[]);
void SetColor(Int_t ix, Pixel_t color);
void SetCurrentCellColor(Pixel_t color);
void SetCellSize(Int_t w = 20, Int_t h = 17);
Pixel_t GetColorByIndex(Int_t ix) const { return fPixels[ix]; }
Pixel_t GetCurrentColor() const;
virtual void ColorSelected(Pixel_t col = 0)
{ Emit("ColorSelected(Pixel_t)", col ? col : GetCurrentColor()); }
ClassDef(TGColorPalette,0)
};
class TGColorPick : public TGFrame, public TGWidget {
private:
Int_t fColormap[64][3];
Pixel_t fPixel[64];
protected:
Pixmap_t fHSimage;
Pixmap_t fLimage;
Int_t fNColors;
Int_t fClick;
Int_t fCx;
Int_t fCy;
Int_t fCz;
Pixel_t fCurrentColor;
Rectangle_t fColormapRect;
Rectangle_t fSliderRect;
TGGC fCursorGC;
virtual void DoRedraw();
void DrawHScursor(Int_t onoff);
void DrawLcursor(Int_t onoff);
void SetHScursor(Int_t x, Int_t y);
void SetLcursor(Int_t z);
void CreateImages();
void InitImages();
void SetSliderColor();
void UpdateCurrentColor();
void AllocColors();
void FreeColors();
void CreateDitheredImage(Pixmap_t image, Int_t which);
public:
TGColorPick(const TGWindow *p = 0, Int_t w = 1, Int_t h = 1, Int_t id = -1);
virtual ~TGColorPick();
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleMotion(Event_t *event);
void SetColor(Pixel_t color);
Pixel_t GetCurrentColor() const { return fCurrentColor; }
virtual void ColorSelected(Pixel_t col = 0)
{ Emit("ColorSelected(Pixel_t)", col ? col : GetCurrentColor()); }
ClassDef(TGColorPick,0)
};
class TGColorDialog : public TGTransientFrame {
private:
TGColorDialog(const TGColorDialog&);
TGColorDialog& operator=(const TGColorDialog&);
protected:
Pixel_t fCurrentColor;
Pixel_t fInitColor;
Int_t *fRetc;
Pixel_t *fRetColor;
TGColorPalette *fPalette;
TGColorPalette *fCpalette;
TGColorPick *fColors;
TGFrame *fSample;
TGFrame *fSampleOld;
TGTextEntry *fRte, *fGte, *fBte, *fHte, *fLte, *fSte;
TGTextBuffer *fRtb, *fGtb, *fBtb, *fHtb, *fLtb, *fStb;
Bool_t fWaitFor;
TGTab *fTab;
TRootEmbeddedCanvas *fEcanvas;
TColorWheel *fColorWheel;
TGLabel *fColorInfo;
TGTextButton *fPreview;
void UpdateRGBentries(Pixel_t *c);
void UpdateHLSentries(Pixel_t *c);
virtual void CloseWindow();
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
public:
TGColorDialog(const TGWindow *p = 0, const TGWindow *m = 0, Int_t *retc = 0,
Pixel_t *color = 0, Bool_t wait = kTRUE);
virtual ~TGColorDialog();
TGColorPalette *GetPalette() const { return fPalette; }
TGColorPalette *GetCustomPalette() const { return fCpalette; }
virtual void ColorSelected(Pixel_t);
void DoPreview();
virtual void SetCurrentColor(Pixel_t col);
void SetColorInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
ClassDef(TGColorDialog,0)
};
#endif