![]() |
![]() |
#include <FWColorSelect.h>
Public Member Functions | |
ClassDef (FWColorPopup, 0) | |
void | ColorSelected (Color_t) |
void | ColorWheelSelected (Pixel_t) |
FWColorPopup (const TGWindow *p=0, Color_t color=0) | |
virtual Bool_t | HandleButton (Event_t *event) |
void | InitContent (const char *name, const std::vector< Color_t > &colors, bool backgroundIsBlack=true) |
void | PlacePopup (Int_t x, Int_t y, UInt_t w, UInt_t h) |
void | PopupColorWheel () |
void | ResetColors (const std::vector< Color_t > &colors, bool backgroundIsBlack=true) |
void | SetColors (const std::vector< Color_t > &colors, bool backgroundIsBlack=true) |
void | SetName (const char *iName) |
void | SetSelection (Color_t) |
virtual | ~FWColorPopup () |
Static Public Member Functions | |
static void | EnableFreePalette () |
static Bool_t | HasFreePalette () |
Protected Attributes | |
FWColorRow * | fFirstRow |
TGLabel * | fLabel |
Int_t | fNumColors |
FWColorRow * | fSecondRow |
Color_t | fSelectedColor |
Bool_t | fShowWheel |
Static Protected Attributes | |
static Bool_t | fgFreePalette = kFALSE |
Private Member Functions | |
void | SetColors (const std::vector< Pixel_t > &colors, bool backgroundIsBlack) |
Definition at line 75 of file FWColorSelect.h.
FWColorPopup::FWColorPopup | ( | const TGWindow * | p = 0 , |
Color_t | color = 0 |
||
) |
Definition at line 153 of file FWColorSelect.cc.
References fFirstRow, fLabel, fNumColors, fSecondRow, and fSelectedColor.
: TGVerticalFrame(p, 10, 10, kDoubleBorder | kRaisedFrame | kOwnBackground, kColorPopupGray), fShowWheel(kFALSE) { SetWindowAttributes_t wattr; wattr.fMask = kWAOverrideRedirect; wattr.fOverrideRedirect = kTRUE; gVirtualX->ChangeWindowAttributes(fId, &wattr); AddInput(kStructureNotifyMask); // to notify the client for structure (i.e. unmap) changes fSelectedColor = color; fLabel = 0; fNumColors = 0; fFirstRow = new FWColorRow(this); fSecondRow = new FWColorRow(this); fFirstRow ->Connect("ColorChanged(Color_t)", "FWColorPopup", this, "ColorSelected(Color_t)"); fSecondRow->Connect("ColorChanged(Color_t)", "FWColorPopup", this, "ColorSelected(Color_t)"); }
FWColorPopup::~FWColorPopup | ( | ) | [virtual] |
Definition at line 173 of file FWColorSelect.cc.
{ Cleanup(); }
FWColorPopup::ClassDef | ( | FWColorPopup | , |
0 | |||
) |
void FWColorPopup::ColorSelected | ( | Color_t | ci | ) |
Definition at line 322 of file FWColorSelect.cc.
References fSelectedColor.
Referenced by ColorWheelSelected().
{ UnmapWindow(); fSelectedColor = ci; Emit("ColorSelected(Color_t)", ci); }
void FWColorPopup::ColorWheelSelected | ( | Pixel_t | pix | ) |
Definition at line 230 of file FWColorSelect.cc.
References ColorSelected().
{ ColorSelected(TColor::GetColor(pix)); }
void FWColorPopup::EnableFreePalette | ( | ) | [static] |
Definition at line 151 of file FWColorSelect.cc.
References fgFreePalette.
Referenced by CmsShowMain::CmsShowMain().
{ fgFreePalette = kTRUE; }
Bool_t FWColorPopup::HandleButton | ( | Event_t * | event | ) | [virtual] |
Definition at line 178 of file FWColorSelect.cc.
References f.
{ if (event->fX < 0 || event->fX >= (Int_t) fWidth || event->fY < 0 || event->fY >= (Int_t) fHeight) { if (event->fType == kButtonRelease) UnmapWindow(); } else { TGFrame *f = GetFrameFromPoint(event->fX, event->fY); if (f && f != this) { TranslateCoordinates(f, event->fX, event->fY, event->fX, event->fY); f->HandleButton(event); } } return kTRUE; }
Bool_t FWColorPopup::HasFreePalette | ( | ) | [static] |
Definition at line 150 of file FWColorSelect.cc.
References fgFreePalette.
{ return fgFreePalette; }
void FWColorPopup::InitContent | ( | const char * | name, |
const std::vector< Color_t > & | colors, | ||
bool | backgroundIsBlack = true |
||
) |
Definition at line 198 of file FWColorSelect.cc.
References b, fFirstRow, fgFreePalette, fLabel, fSecondRow, kCROffsetX, kCROffsetY, kCRPadAbove, kCRPadBelow, and SetColors().
Referenced by FWGeometryTableView::cellClicked(), FWModelContextMenuHandler::createColorPopup(), FWCollectionSummaryWidget::createColorPopup(), and FWColorSelect::FWColorSelect().
{ fLabel = new TGLabel(this, name); fLabel->SetBackgroundColor(GetBackground()); SetColors(colors, backgroundIsBlack); AddFrame(fLabel, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, kCROffsetX, kCROffsetY, kCRPadAbove + 1, kCRPadBelow - 1)); AddFrame(fFirstRow, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, kCROffsetX, kCROffsetY, kCRPadAbove, kCRPadBelow)); AddFrame(fSecondRow, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, kCROffsetX, kCROffsetY, kCRPadAbove, kCRPadBelow)); fFirstRow->MapSubwindows(); fFirstRow->Resize(fFirstRow->GetDefaultSize()); fSecondRow->MapSubwindows(); fSecondRow->Resize(fSecondRow->GetDefaultSize()); if (fgFreePalette) { TGTextButton *b = new TGTextButton(this, "Color wheel"); AddFrame(b, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, kCROffsetX, kCROffsetY, kCRPadAbove, 2 * kCRPadBelow)); b->Connect("Clicked()", "FWColorPopup", this, "PopupColorWheel()"); } }
void FWColorPopup::PlacePopup | ( | Int_t | x, |
Int_t | y, | ||
UInt_t | w, | ||
UInt_t | h | ||
) |
Definition at line 268 of file FWColorSelect.cc.
References fSelectedColor, fShowWheel, and WDecay::kNone.
Referenced by FWGeometryTableView::cellClicked(), FWModelContextMenuHandler::chosenItem(), FWCollectionSummaryWidget::colorClicked(), FWColorSelect::HandleButton(), and FWCollectionSummaryWidget::itemColorClicked().
{ // Popup TGColorPopup at x,y position Int_t rx, ry; UInt_t rw, rh; // Parent is root window for the popup: gVirtualX->GetWindowSize(fParent->GetId(), rx, ry, rw, rh); if (x < 0) x = 0; if (x + fWidth > rw) x = rw - fWidth; if (y < 0) y = 0; if (y + fHeight > rh) y = rh - fHeight; MoveResize(x, y, w, h); MapSubwindows(); Layout(); MapRaised(); // find out if this is necessary gVirtualX->GrabPointer(fId, kButtonPressMask | kButtonReleaseMask | kPointerMotionMask, kNone, kNone); gClient->WaitForUnmap(this); gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); if (fShowWheel) { Int_t retc; Pixel_t pixel = TColor::Number2Pixel(fSelectedColor); TGColorDialog *cd = new TGColorDialog(gClient->GetDefaultRoot(), this, &retc, &pixel, kFALSE); cd->Connect("ColorSelected(Pixel_t)", "FWColorPopup", this, "ColorWheelSelected(Pixel_t"); cd->MapWindow(); fClient->WaitForUnmap(cd); cd->DeleteWindow(); fShowWheel = kFALSE; } }
void FWColorPopup::PopupColorWheel | ( | ) |
Definition at line 224 of file FWColorSelect.cc.
References fShowWheel.
{ fShowWheel = kTRUE; UnmapWindow(); }
void FWColorPopup::ResetColors | ( | const std::vector< Color_t > & | colors, |
bool | backgroundIsBlack = true |
||
) |
Definition at line 252 of file FWColorSelect.cc.
References fFirstRow, fNumColors, fSecondRow, i, getHLTprescales::index, FWColorRow::ResetColor(), and FWColorRow::SetBackgroundToBlack().
Referenced by FWGeometryTableView::cellClicked(), FWModelContextMenuHandler::chosenItem(), FWCollectionSummaryWidget::colorClicked(), FWColorSelect::HandleButton(), and FWCollectionSummaryWidget::itemColorClicked().
{ fNumColors=colors.size(); for (UInt_t i = 0; i < colors.size() / 2; i++) { fFirstRow->ResetColor(i,colors.at(i)); } fFirstRow->SetBackgroundToBlack(backgroundIsBlack); UInt_t index = 0; for (UInt_t i = colors.size() / 2; i < colors.size(); i++, ++index) { fSecondRow->ResetColor(index,colors.at(i)); } fSecondRow->SetBackgroundToBlack(backgroundIsBlack); }
void FWColorPopup::SetColors | ( | const std::vector< Pixel_t > & | colors, |
bool | backgroundIsBlack | ||
) | [private] |
Referenced by InitContent().
void FWColorPopup::SetColors | ( | const std::vector< Color_t > & | colors, |
bool | backgroundIsBlack = true |
||
) |
Definition at line 237 of file FWColorSelect.cc.
References FWColorRow::AddColor(), fFirstRow, fNumColors, fSecondRow, i, and FWColorRow::SetBackgroundToBlack().
{ fNumColors = colors.size(); for (UInt_t i = 0; i < colors.size() / 2; i++) { fFirstRow->AddColor(colors.at(i)); } for (UInt_t i = colors.size() / 2; i < colors.size(); i++) { fSecondRow->AddColor(colors.at(i)); } fFirstRow->SetBackgroundToBlack(backgroundIsBlack); fSecondRow->SetBackgroundToBlack(backgroundIsBlack); }
void FWColorPopup::SetName | ( | const char * | iName | ) |
Definition at line 311 of file FWColorSelect.cc.
References fLabel.
Referenced by FWGeometryTableView::cellClicked(), FWModelContextMenuHandler::chosenItem(), FWCollectionSummaryWidget::colorClicked(), and FWCollectionSummaryWidget::itemColorClicked().
{ fLabel->SetText(iName); }
void FWColorPopup::SetSelection | ( | Color_t | iColor | ) |
Definition at line 316 of file FWColorSelect.cc.
References fFirstRow, FWColorRow::FindColorIndex(), fSecondRow, and FWColorRow::SetSelectedIndex().
Referenced by FWModelContextMenuHandler::chosenItem(), FWCollectionSummaryWidget::colorClicked(), FWColorSelect::HandleButton(), and FWCollectionSummaryWidget::itemColorClicked().
{ fFirstRow ->SetSelectedIndex(fFirstRow->FindColorIndex(iColor)); fSecondRow->SetSelectedIndex(fSecondRow->FindColorIndex(iColor)); }
FWColorRow* FWColorPopup::fFirstRow [protected] |
Definition at line 82 of file FWColorSelect.h.
Referenced by FWColorPopup(), InitContent(), ResetColors(), SetColors(), and SetSelection().
Bool_t FWColorPopup::fgFreePalette = kFALSE [static, protected] |
Definition at line 87 of file FWColorSelect.h.
Referenced by EnableFreePalette(), HasFreePalette(), and InitContent().
TGLabel* FWColorPopup::fLabel [protected] |
Definition at line 83 of file FWColorSelect.h.
Referenced by FWColorPopup(), InitContent(), and SetName().
Int_t FWColorPopup::fNumColors [protected] |
Definition at line 84 of file FWColorSelect.h.
Referenced by FWColorPopup(), ResetColors(), and SetColors().
FWColorRow * FWColorPopup::fSecondRow [protected] |
Definition at line 82 of file FWColorSelect.h.
Referenced by FWColorPopup(), InitContent(), ResetColors(), SetColors(), and SetSelection().
Color_t FWColorPopup::fSelectedColor [protected] |
Definition at line 81 of file FWColorSelect.h.
Referenced by ColorSelected(), FWColorPopup(), and PlacePopup().
Bool_t FWColorPopup::fShowWheel [protected] |
Definition at line 85 of file FWColorSelect.h.
Referenced by PlacePopup(), and PopupColorWheel().