13 #include <boost/bind.hpp> 18 #include "TGColorDialog.h" 44 TGFrame(p, 20, 20, kOwnBackground)
52 if (event->fType == kButtonRelease)
63 SetBackgroundColor(TColor::Number2Pixel(
fColor));
68 Emit(
"ColorSelected(Color_t)", ci);
75 TGHorizontalFrame(p, 10, 10, kOwnBackground, TGFrame::GetBlackPixel()),
76 fBackgroundIsBlack(kTRUE)
90 SetBackgroundColor(TGFrame::GetBlackPixel());
92 SetBackgroundColor(TGFrame::GetWhitePixel());
98 TGCompositeFrame::DoRedraw();
118 fCc.back()->Connect(
"ColorSelected(Color_t)",
"FWColorRow",
this,
"ColorChanged(Color_t)");
123 fCc[iIndex]->SetColor(iColor);
129 Int_t returnValue = -1;
131 for(std::vector<FWColorFrame*>::const_iterator it =
fCc.begin(), itEnd =
fCc.end();
132 it != itEnd; ++it, ++
index)
134 if ((*it)->GetColor() == iColor)
142 Emit(
"ColorChanged(Color_t)", ci);
154 TGVerticalFrame(p, 10, 10, kDoubleBorder | kRaisedFrame | kOwnBackground,
kColorPopupGray),
157 SetWindowAttributes_t wattr;
158 wattr.fMask = kWAOverrideRedirect;
159 wattr.fOverrideRedirect = kTRUE;
160 gVirtualX->ChangeWindowAttributes(fId, &wattr);
161 AddInput(kStructureNotifyMask);
169 fFirstRow ->Connect(
"ColorChanged(Color_t)",
"FWColorPopup",
this,
"ColorSelected(Color_t)");
170 fSecondRow->Connect(
"ColorChanged(Color_t)",
"FWColorPopup",
this,
"ColorSelected(Color_t)");
180 if (event->fX < 0 || event->fX >= (Int_t) fWidth ||
181 event->fY < 0 || event->fY >= (Int_t) fHeight)
183 if (event->fType == kButtonRelease)
188 TGFrame *
f = GetFrameFromPoint(event->fX, event->fY);
191 TranslateCoordinates(f, event->fX, event->fY, event->fX, event->fY);
192 f->HandleButton(event);
200 fLabel =
new TGLabel(
this, name);
201 fLabel->SetBackgroundColor(GetBackground());
216 TGTextButton *
b =
new TGTextButton(
this,
"Color wheel");
218 b->Connect(
"Clicked()",
"FWColorPopup",
this,
"PopupColorWheel()");
240 for (UInt_t
i = 0;
i < colors.size() / 2;
i++)
244 for (UInt_t
i = colors.size() / 2;
i < colors.size();
i++)
255 for (UInt_t
i = 0;
i < colors.size() / 2;
i++)
261 for (UInt_t
i = colors.size() / 2;
i < colors.size();
i++, ++
index)
276 gVirtualX->GetWindowSize(fParent->GetId(),
rx,
ry, rw, rh);
279 if (x + fWidth > rw) x = rw - fWidth;
281 if (y + fHeight > rh) y = rh - fHeight;
283 MoveResize(x, y, w, h);
289 gVirtualX->GrabPointer(fId, kButtonPressMask | kButtonReleaseMask | kPointerMotionMask,
kNone,
kNone);
291 gClient->WaitForUnmap(
this);
292 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
299 TGColorDialog *
cd =
new TGColorDialog(gClient->GetDefaultRoot(),
this, &retc, &
pixel, kFALSE);
301 cd->Connect(
"ColorSelected(Pixel_t)",
"FWColorPopup",
this,
"ColorWheelSelected(Pixel_t");
326 Emit(
"ColorSelected(Color_t)", ci);
334 TGColorSelect(p, TColor::Number2Pixel(index), id),
338 fColorManager(iManager)
340 std::vector<Color_t>
colors;
345 fFireworksPopup->Connect(
"ColorSelected(Color_t)",
"FWColorSelect",
this,
"SetColorByIndex(Color_t)");
357 TGFrame::HandleButton(event);
358 if (!IsEnabled())
return kTRUE;
360 if (event->fCode != kButton1)
return kFALSE;
362 if ((event->fType == kButtonPress) && HasFocus()) WantFocus();
364 if (event->fType == kButtonPress)
369 if (
fState != kButtonDown) {
371 SetState(kButtonDown);
381 if ((fPressPos.fX != fX) || (fPressPos.fY != fY))
389 std::vector<Color_t>
colors;
395 gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(), 0, fHeight,
ax, ay, wdummy);
412 SetColor(TColor::Number2Pixel(iColor), kFALSE);
427 Emit(
"ColorChosen(Color_t)", iColor);
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void SetColorByIndex(Color_t iColor)
FWColorPopup * fFireworksPopup
void SetBackgroundToBlack(Bool_t)
void fillLimitedColors(std::vector< Color_t > &cv) const
void ColorChosen(Color_t)
void ColorSelected(Color_t)
BackgroundColorIndex backgroundColorIndex() const
FWColorSelect(const TGWindow *p, const char *label, Color_t colorIndex, const FWColorManager *, Int_t id)
void ColorChanged(Color_t)
Bool_t HandleButton(Event_t *event) override
FWColorFrame(const TGWindow *p=nullptr, Color_t ci=0)
const FWColorManager * fColorManager
~FWColorSelect() override
Bool_t fBackgroundIsBlack
FWColorRow(const TGWindow *p=nullptr)
virtual void AddColor(Color_t color)
void SetSelectedIndex(Int_t i)
void ResetColor(Int_t, Color_t)
Bool_t HandleButton(Event_t *event) override
sigc::signal< void > colorsHaveChanged_
std::vector< FWColorFrame * > fCc
Int_t FindColorIndex(Color_t) const