183 if (cx >= 0 && cx < fCols && cy >= 0 && cy <
fRows) {
210 if (cx >= 0 && cx < fCols && cy >= 0 && cy <
fRows) {
236 gVirtualX->LookupString(event, input,
sizeof(input), keysym);
247 if (cx <
fCols - 1) ++cx;
255 if (cy <
fRows - 1) ++cy;
271 if (cx !=
fCx || cy !=
fCy) {
345 for (i = 0; i <
fRows; ++i) {
347 for (j = 0; j <
fCols; ++j) {
381 if (
fCx >= 0 &&
fCy >= 0) {
543 for (i = 0; i < 64; ++i) {
544 Int_t cc[4] = { 0, 21845, 43691, 65535 };
546 color.fRed = cc[i & 0x3];
547 color.fGreen = cc[(i >> 2) & 0x3];
548 color.fBlue = cc[(i >> 4) & 0x3];
564 for (i = 0; i < 27; ++i) {
565 Int_t cc[3] = { 0, 32768, 65535 };
567 color.fRed = cc[i % 3];
568 color.fGreen = cc[(i / 3) % 3];
569 color.fBlue = cc[(i / 9) % 3];
585 for (i = 0; i < 8; ++i) {
587 color.fRed = (i & 1) * 65535;
588 color.fGreen = ((i >> 1) & 1) * 65535;
589 color.fBlue = ((i >> 2) & 1) * 65535;
607 for (i = 0; i < 8; ++i) {
609 color.fRed = (i & 1) * 65535;
610 color.fGreen = ((i >> 1) & 1) * 65535;
611 color.fBlue = ((i >> 2) & 1) * 65535;
641 const Int_t kWidth = 20;
644 struct {
Int_t r,
g,
b; } ed[kWidth], ef;
653 for (
x = 0;
x < iw; ++
x) {
654 ed[
x].r = ed[
x].g = ed[
x].b = 0;
659 for (
y = 0;
y < ih; ++
y) {
663 for (
x = 0;
x < iw; ++
x) {
667 s = (ih -
y) * 255 / ih;
676 }
else if (which ==
kIMG_L) {
681 Int_t ll = (ih -
y) * 255 / ih;
685 for (
x = 0;
x < iw; ++
x) {
697 ef.r = ef.g = ef.b = 0;
699 for (
x = 0;
x < iw; ++
x) {
704 if (
v < 0)
v = 0;
else if (
v > 255)
v = 255;
708 if (
v < 0)
v = 0;
else if (
v > 255)
v = 255;
712 if (
v < 0)
v = 0;
else if (
v > 255)
v = 255;
717 for (
x = 0;
x < iw; ++
x) {
722 if (
v < 0)
v = 0;
else if (
v > 255)
v = 255;
725 v =
line[
x].fGreen + ef.g;
726 if (
v < 0)
v = 0;
else if (
v > 255)
v = 255;
730 if (
v < 0)
v = 0;
else if (
v > 255)
v = 255;
735 sdist = 255L * 255L * 255L;
742 dist = dr * dr + dg * dg + db * db;
752 e[0] = (7 * v) >> 4; \
754 e[2] = (5 * v) >> 4; \
761 if (
x < iw-1) ed[
x+1].r =
e[1];
762 if (
x == 0) ed[
x].r =
e[2];
else ed[
x].r +=
e[2];
763 if (
x > 0) ed[
x-1].r +=
e[3];
769 if (
x < iw-1) ed[
x+1].g =
e[1];
770 if (
x == 0) ed[
x].g =
e[2];
else ed[
x].g +=
e[2];
771 if (
x > 0) ed[
x-1].g +=
e[3];
777 if (
x < iw-1) ed[
x+1].b =
e[1];
778 if (
x == 0) ed[
x].b =
e[2];
else ed[
x].b +=
e[2];
779 if (
x > 0) ed[
x-1].b +=
e[3];
801 for (
Int_t y = 0;
y < height; ++
y) {
807 s = (height -
y) * 255 / height;
839 for (
Int_t y = 0;
y < height; ++
y) {
844 l = (height -
y) * 255 / height;
900 l =
Int_t((lheight -
fCz) * 255 / lheight);
901 s =
Int_t((sheight -
fCy) * 255 / sheight);
1013 x =
fCx - 9; w = 19;
1014 y =
fCy - 9;
h = 19;
1016 if (
x < 0) { w +=
x;
x = 0; }
1017 if (
y < 0) {
h +=
y;
y = 0; }
1019 if (
x + w > width) w = width -
x;
1020 if (
y +
h > height)
h = height -
y;
1063 const Int_t kC_X = 175;
1064 const Int_t kC_Y = 180;
1099 fRte->Resize(50,
fRte->GetDefaultHeight());
1102 fGte->Resize(50,
fGte->GetDefaultHeight());
1105 fBte->Resize(50,
fBte->GetDefaultHeight());
1108 fAle->Resize(50,
fAle->GetDefaultHeight());
1120 fHte->Resize(50,
fHte->GetDefaultHeight());
1123 fSte->Resize(50,
fSte->GetDefaultHeight());
1126 fLte->Resize(50,
fLte->GetDefaultHeight());
1128 fHte->Associate(
this);
1129 fLte->Associate(
this);
1130 fSte->Associate(
this);
1131 fRte->Associate(
this);
1132 fGte->Associate(
this);
1133 fBte->Associate(
this);
1134 fAle->Associate(
this);
1169 wcan->
Connect(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
"TGColorDialog",
this,
1170 "SetColorInfo(Int_t,Int_t,Int_t,TObject*)");
1172 tf =
fTab->AddTab(
"Basic Colors");
1192 for (i = 0; i < 48; ++i)
1243 if (
gUcolor[0] == 0xff000000) {
1244 for (i = 0; i < 24; i++)
1257 fPreview->Connect(
"Clicked()",
"TGColorDialog",
this,
"DoPreview()");
1330 fEcanvas->GetCanvas()->Disconnect(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)");
1347 fSample->SetBackgroundColor(col);
1356 Emit(
"ColorSelected(Pixel_t)", color);
1364 Emit(
"AlphaColorSelected(ULong_t)", color);
1373 for (
Int_t i = 0; i < 24; ++i)
1390 fEcanvas->GetCanvas()->DeleteCanvasPainter();
1404 alpha = color->GetAlpha();
1407 fAlb->AddText(0,tmp);
1425 fRtb->AddText(0, tmp);
1430 fGtb->AddText(0, tmp);
1435 fBtb->AddText(0, tmp);
1454 fHtb->AddText(0, tmp);
1459 fLtb->AddText(0, tmp);
1464 fStb->AddText(0, tmp);
1489 atoi(
fGtb->GetString()),
1490 atoi(
fBtb->GetString()));
1493 atof(
fAlb->GetString()))));
1514 color =
fPalette->GetCurrentColor();
1515 fSample->SetBackgroundColor(color);
1527 fSample->SetBackgroundColor(color);
1538 color =
fColors->GetCurrentColor();
1539 fSample->SetBackgroundColor(color);
1561 h = atoi(
fHtb->GetString());
1562 l = atoi(
fLtb->GetString());
1563 s = atoi(
fStb->GetString());
1567 fSample->SetBackgroundColor(color);
1579 atoi(
fGtb->GetString()),
1580 atoi(
fBtb->GetString()));
1581 fSample->SetBackgroundColor(color);
1608 ULong_t pcolor = color->GetPixel();
1613 fSample->SetBackgroundColor(pcolor);
const Mask_t kFocusChangeMask
const Mask_t kButtonPressMask
const Mask_t kKeyReleaseMask
const Mask_t kAnyModifier
Handle_t Pixmap_t
Pixmap handle.
const Mask_t kKeyPressMask
const Mask_t kPointerMotionMask
const Mask_t kLeaveWindowMask
const Mask_t kStructureNotifyMask
Handle_t GContext_t
Graphics context handle.
const Mask_t kButtonReleaseMask
const Mask_t kEnterWindowMask
ULong_t Pixel_t
Pixel value.
int Int_t
Signed integer 4 bytes (int).
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent).
char Char_t
Character 1 byte (char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
static ULong_t gUcolor[24]
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
void Update() override
Update canvas pad buffers.
static Int_t GetColor(const char *hexcolor)
static void HLS2RGB(Float_t h, Float_t l, Float_t s, Float_t &r, Float_t &g, Float_t &b)
static void Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b)
virtual void SetAlpha(Float_t a)
static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b)
static void RGB2HLS(Float_t r, Float_t g, Float_t b, Float_t &h, Float_t &l, Float_t &s)
static ULong_t Number2Pixel(Int_t ci)
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process messages for the color selection dialog.
TGColorPalette * fPalette
color palette
TGTab * fTab
tab widget holding the color selectors
TGLabel * fColorInfo
color info
virtual void SetCurrentColor(Pixel_t col)
Change current color.
void DoPreview()
Slot method called when Preview button is clicked.
Int_t * fRetc
return code (kMBOk, kMBCancel)
TColorWheel * fColorWheel
color wheel
TGTextBuffer * fAlb
RGB/HLS associated buffers.
TGTextButton * fPreview
preview button;
Pixel_t fCurrentColor
currently selected color
Pixel_t * fRetColor
return color
TGColorPick * fColors
color pick widget
TGColorDialog(const TGColorDialog &)=delete
TColor * fRetTColor
return TColor, needed for changed alpha
void SetColorInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
Set the color info in RGB and HLS parts.
TRootEmbeddedCanvas * fEcanvas
embedded canvas holding the color wheel
TGColorPalette * fCpalette
color palette
virtual void ColorSelected(Pixel_t)
Emit signal about selected color.
void CloseWindow() override
Called when window is closed via window manager.
TGTextEntry * fAle
RGB/HLS text entries.
TGFrame * fSample
color sample frame
virtual void AlphaColorSelected(ULongptr_t)
Emit signal about selected alpha and color.
Bool_t fWaitFor
call WaitFor method in constructor
Pixel_t fInitColor
initially set color
void UpdateRGBentries(Pixel_t *c)
Update RGB text entries with RGB values of color c.
void UpdateHLSentries(Pixel_t *c)
Update HLS text entries with HLS values of color c.
TGFrame * fSampleOld
color sample frame
~TGColorDialog() override
TGColorDialog destructor.
void UpdateAlpha(Pixel_t *c)
Update Opacity text entry with alpha value of color c.
A widget showing an matrix of color cells.
void SetCellSize(Int_t w=20, Int_t h=17)
Set color cell size.
Bool_t HandleButton(Event_t *event) override
Handle button events in color palette.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion events in color palette.
void SetColors(Pixel_t colors[])
Set color entries in color samples.
void DoRedraw() override
Redraw color palette.
Int_t fRows
number of color cell rows
Pixel_t GetColorByIndex(Int_t ix) const
virtual void LostFocus()
Remove keyboard input.
Pixel_t GetCurrentColor() const
Return currently selected color value.
UInt_t fCh
color cell height
void SetCurrentCellColor(Pixel_t color)
Set current cell color.
Int_t fCols
number of color cell columns
UInt_t fCw
color cell width
void DrawFocusHilite(Int_t onoff)
Draw a highlight rectangle around cell obtaining focus.
Pixel_t * fPixels
pixel value of colors
TGGC fDrawGC
graphics context used for drawing
virtual void GotFocus()
Add keyboard input.
void SetColor(Int_t ix, Pixel_t color)
Set color at index ix of color entries.
Int_t fCy
y coordinate of currently selected color cell
TGColorPalette(const TGColorPalette &)=delete
~TGColorPalette() override
Destructor.
virtual void ColorSelected(Pixel_t col=0)
Bool_t HandleKey(Event_t *event) override
Handle keyboard events in color palette.
Int_t fCx
x coordinate of currently selected color cell
A widget which allows a color to be picked from HLS color space.
Bool_t HandleButton(Event_t *event) override
Handle mouse button events in color pick widget.
void SetLcursor(Int_t z)
Set lightness slider cursor position.
void DoRedraw() override
Redraw the color pick widget.
Int_t fCx
x position in hs colormap
~TGColorPick() override
TGColorPick destructor.
Pixmap_t fLimage
color lightness slider pixmap
Int_t fNColors
number of color samples
Pixmap_t fHSimage
hue / saturation colormap pixmap
void UpdateCurrentColor()
Assign the current cursor position as currently selected color.
Int_t fClick
mouse click location (kCLICK_NONE, kCLICK_HS, kCLICK_L)
void CreateImages()
Create colormap and color slider images.
void SetColor(Pixel_t color)
Position the slider cursor on right color position.
virtual void ColorSelected(Pixel_t col=0)
Pixel_t fCurrentColor
currently selected color value
Int_t fCz
position in lightness slider
void SetSliderColor()
Set slider colors.
TGColorPick(const TGWindow *p=nullptr, Int_t w=1, Int_t h=1, Int_t id=-1)
TGColorPick constructor.
void AllocColors()
Try to allocate first a palette of 64 colors.
Rectangle_t fColormapRect
hue / saturation colormap rectangle
void FreeColors()
Free allocated colors.
void DrawHScursor(Int_t onoff)
Draw hue / saturation cursor.
void CreateDitheredImage(Pixmap_t image, Int_t which)
Create a dithered version of the color map and lightness images for display modes with reduced number...
void DrawLcursor(Int_t onoff)
Draw lightness slider cursor.
void InitImages()
Initialize color palette and slider images.
Rectangle_t fSliderRect
color lightness slider rectangle
void SetHScursor(Int_t x, Int_t y)
Set hue / saturation cursor position.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion events in color pick widget.
Int_t fCy
y position in hs colormap
TGGC fCursorGC
color lightness slider cursor GC
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
UInt_t GetDefaultHeight() const override
TGCompositeFrame(const TGCompositeFrame &)=delete
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
static const TGGC & GetBlackGC()
Get black graphics context.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
TGFrame(const TGFrame &)=delete
UInt_t fHeight
frame height
virtual UInt_t GetDefaultWidth() const
virtual void DrawBorder()
Draw frame border.
virtual void Draw3dRectangle(UInt_t type, Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw 3D rectangle on the frame border.
void MapWindow() override
map window
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
virtual void DeleteWindow()
Delete window.
void UnmapWindow() override
unmap window
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
static const TGGC & GetShadowGC()
Get shadow color graphics context.
static const TGGC & GetBckgndGC()
Get background color graphics context.
A composite frame that layout their children in horizontal way.
TGHotString is a string with a "hot" character underlined.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
void SetWMSizeHints(UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc)
Give the window manager minimum and maximum size hints.
This layout managers does not make use of TGLayoutHints.
TGClient * fClient
Connection to display server.
Handle_t fId
X11/Win32 Window identifier.
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
A TGTextEntry is a one line text input widget.
const TGWindow * GetMain() const
TGTransientFrame(const TGTransientFrame &)=delete
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
A composite frame that layout their children in vertical way.
ROOT GUI Window base class.
@ kEditDisable
disable edit of this window
UInt_t fEditDisabled
flags used for "guibuilding"
Mother of all ROOT objects.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
This class creates a TGCanvas in which a TCanvas is created.
int main(int argc, char **argv)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
EGEventType fType
of event (see EGEventType)
Int_t fY
pointer x, y coordinates in event window
UInt_t fCode
key or button code
Point structure (maps to the X11 XPoint structure).
Rectangle structure (maps to the X11 XRectangle structure).