CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
FWColorSelect Class Reference

#include <FWColorSelect.h>

Inheritance diagram for FWColorSelect:

Public Member Functions

 ClassDefOverride (FWColorSelect, 0)
 
void ColorChosen (Color_t)
 
 FWColorSelect (const TGWindow *p, const char *label, Color_t colorIndex, const FWColorManager *, Int_t id)
 
Bool_t HandleButton (Event_t *event) override
 
const std::string & label () const
 
void SetColorByIndex (Color_t iColor)
 
void SetColorByIndex (Color_t iColor, Bool_t iSendSignal)
 
void UpdateColors ()
 
 ~FWColorSelect () override
 

Private Attributes

const FWColorManagerfColorManager
 
FWColorPopupfFireworksPopup
 
std::string fLabel
 
Color_t fSelectedColor
 

Detailed Description

Definition at line 116 of file FWColorSelect.h.

Constructor & Destructor Documentation

FWColorSelect::FWColorSelect ( const TGWindow *  p,
const char *  label,
Color_t  colorIndex,
const FWColorManager iManager,
Int_t  id 
)

Definition at line 332 of file FWColorSelect.cc.

References colors, FWColorManager::colorsHaveChanged_, fColorManager, fFireworksPopup, FWColorManager::fillLimitedColors(), fLabel, FWColorPopup::InitContent(), and UpdateColors().

333  :
334  TGColorSelect(p, TColor::Number2Pixel(index), id),
335  fLabel(label),
337  fFireworksPopup(nullptr),
338  fColorManager(iManager)
339 {
340  std::vector<Color_t> colors;
342 
343  fFireworksPopup = new FWColorPopup(gClient->GetDefaultRoot(), fColor);
345  fFireworksPopup->Connect("ColorSelected(Color_t)","FWColorSelect", this, "SetColorByIndex(Color_t)");
346 
347  fColorManager->colorsHaveChanged_.connect(boost::bind(&FWColorSelect::UpdateColors,this));
348 }
void InitContent(const char *name, const std::vector< Color_t > &colors, bool backgroundIsBlack=true)
FWColorPopup * fFireworksPopup
void fillLimitedColors(std::vector< Color_t > &cv) const
vector< Color_t > colors
const std::string & label() const
Color_t fSelectedColor
const FWColorManager * fColorManager
std::string fLabel
sigc::signal< void > colorsHaveChanged_
FWColorSelect::~FWColorSelect ( )
override

Definition at line 350 of file FWColorSelect.cc.

References fFireworksPopup.

351 {
352  delete fFireworksPopup;
353 }
FWColorPopup * fFireworksPopup

Member Function Documentation

FWColorSelect::ClassDefOverride ( FWColorSelect  ,
 
)
void FWColorSelect::ColorChosen ( Color_t  iColor)

Definition at line 425 of file FWColorSelect.cc.

Referenced by SetColorByIndex().

426 {
427  Emit("ColorChosen(Color_t)", iColor);
428 }
Bool_t FWColorSelect::HandleButton ( Event_t *  event)
override

Definition at line 355 of file FWColorSelect.cc.

References create_public_lumi_plots::ax, FWColorManager::backgroundColorIndex(), colors, fColorManager, fFireworksPopup, FWColorManager::fillLimitedColors(), fSelectedColor, hcaldqm::quantity::fState, FWColorManager::kBlackIndex, FWColorPopup::PlacePopup(), FWColorPopup::ResetColors(), and FWColorPopup::SetSelection().

356 {
357  TGFrame::HandleButton(event);
358  if (!IsEnabled()) return kTRUE;
359 
360  if (event->fCode != kButton1) return kFALSE;
361 
362  if ((event->fType == kButtonPress) && HasFocus()) WantFocus();
363 
364  if (event->fType == kButtonPress)
365  {
366  fPressPos.fX = fX;
367  fPressPos.fY = fY;
368 
369  if (fState != kButtonDown) {
370  fPrevState = fState;
371  SetState(kButtonDown);
372  }
373  }
374  else
375  {
376  if (fState != kButtonUp)
377  {
378  SetState(kButtonUp);
379 
380  // case when it was dragged during guibuilding
381  if ((fPressPos.fX != fX) || (fPressPos.fY != fY))
382  {
383  return kFALSE;
384  }
385 
386  Window_t wdummy;
387  Int_t ax, ay;
388 
389  std::vector<Color_t> colors;
391 
394 
395  gVirtualX->TranslateCoordinates(fId, gClient->GetDefaultRoot()->GetId(), 0, fHeight, ax, ay, wdummy);
396  fFireworksPopup->PlacePopup(ax, ay, fFireworksPopup->GetDefaultWidth(), fFireworksPopup->GetDefaultHeight());
397  }
398  }
399  return kTRUE;
400 }
FWColorPopup * fFireworksPopup
void fillLimitedColors(std::vector< Color_t > &cv) const
void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
vector< Color_t > colors
BackgroundColorIndex backgroundColorIndex() const
void ResetColors(const std::vector< Color_t > &colors, bool backgroundIsBlack=true)
void SetSelection(Color_t)
Color_t fSelectedColor
const FWColorManager * fColorManager
Definition: event.py:1
const std::string& FWColorSelect::label ( ) const
inline
void FWColorSelect::SetColorByIndex ( Color_t  iColor)
void FWColorSelect::SetColorByIndex ( Color_t  iColor,
Bool_t  iSendSignal 
)

Definition at line 409 of file FWColorSelect.cc.

References ColorChosen(), and fSelectedColor.

410 {
411  fSelectedColor = iColor;
412  SetColor(TColor::Number2Pixel(iColor), kFALSE);
413  if (iSendSignal)
414  {
416  }
417 }
void ColorChosen(Color_t)
Color_t fSelectedColor
void FWColorSelect::UpdateColors ( )

Definition at line 419 of file FWColorSelect.cc.

References fSelectedColor.

Referenced by FWColorSelect().

420 {
421  SetColor(fSelectedColor, kFALSE);
422 }
Color_t fSelectedColor

Member Data Documentation

const FWColorManager* FWColorSelect::fColorManager
private

Definition at line 122 of file FWColorSelect.h.

Referenced by FWColorSelect(), and HandleButton().

FWColorPopup* FWColorSelect::fFireworksPopup
private

Definition at line 121 of file FWColorSelect.h.

Referenced by FWColorSelect(), HandleButton(), and ~FWColorSelect().

std::string FWColorSelect::fLabel
private

Definition at line 119 of file FWColorSelect.h.

Referenced by FWColorSelect().

Color_t FWColorSelect::fSelectedColor
private

Definition at line 120 of file FWColorSelect.h.

Referenced by HandleButton(), SetColorByIndex(), and UpdateColors().