CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions
FWColorPopup Class Reference

#include <FWColorSelect.h>

Inheritance diagram for FWColorPopup:

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

FWColorRowfFirstRow
 
TGLabel * fLabel
 
Int_t fNumColors
 
FWColorRowfSecondRow
 
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)
 

Detailed Description

Definition at line 75 of file FWColorSelect.h.

Constructor & Destructor Documentation

FWColorPopup::FWColorPopup ( const TGWindow *  p = 0,
Color_t  color = 0 
)

Definition at line 153 of file FWColorSelect.cc.

References create_public_lumi_plots::color, fFirstRow, fLabel, fNumColors, fSecondRow, and fSelectedColor.

153  :
154  TGVerticalFrame(p, 10, 10, kDoubleBorder | kRaisedFrame | kOwnBackground, kColorPopupGray),
155  fShowWheel(kFALSE)
156 {
157  SetWindowAttributes_t wattr;
158  wattr.fMask = kWAOverrideRedirect;
159  wattr.fOverrideRedirect = kTRUE;
160  gVirtualX->ChangeWindowAttributes(fId, &wattr);
161  AddInput(kStructureNotifyMask); // to notify the client for structure (i.e. unmap) changes
162 
164  fLabel = 0;
165  fNumColors = 0;
166 
167  fFirstRow = new FWColorRow(this);
168  fSecondRow = new FWColorRow(this);
169  fFirstRow ->Connect("ColorChanged(Color_t)", "FWColorPopup", this, "ColorSelected(Color_t)");
170  fSecondRow->Connect("ColorChanged(Color_t)", "FWColorPopup", this, "ColorSelected(Color_t)");
171 }
Bool_t fShowWheel
Definition: FWColorSelect.h:85
FWColorRow * fFirstRow
Definition: FWColorSelect.h:82
TGLabel * fLabel
Definition: FWColorSelect.h:83
FWColorRow * fSecondRow
Definition: FWColorSelect.h:82
Int_t fNumColors
Definition: FWColorSelect.h:84
Color_t fSelectedColor
Definition: FWColorSelect.h:81
FWColorPopup::~FWColorPopup ( )
virtual

Definition at line 173 of file FWColorSelect.cc.

174 {
175  Cleanup();
176 }

Member Function Documentation

FWColorPopup::ClassDef ( FWColorPopup  ,
 
)
void FWColorPopup::ColorSelected ( Color_t  ci)

Definition at line 322 of file FWColorSelect.cc.

References fSelectedColor.

Referenced by ColorWheelSelected().

323 {
324  UnmapWindow();
325  fSelectedColor = ci;
326  Emit("ColorSelected(Color_t)", ci);
327 }
Color_t fSelectedColor
Definition: FWColorSelect.h:81
void FWColorPopup::ColorWheelSelected ( Pixel_t  pix)

Definition at line 230 of file FWColorSelect.cc.

References ColorSelected().

231 {
232  ColorSelected(TColor::GetColor(pix));
233 }
void ColorSelected(Color_t)
void FWColorPopup::EnableFreePalette ( )
static

Definition at line 151 of file FWColorSelect.cc.

References fgFreePalette.

Referenced by CmsShowMain::CmsShowMain().

151 { fgFreePalette = kTRUE; }
static Bool_t fgFreePalette
Definition: FWColorSelect.h:87
Bool_t FWColorPopup::HandleButton ( Event_t *  event)
virtual

Definition at line 178 of file FWColorSelect.cc.

References f.

179 {
180  if (event->fX < 0 || event->fX >= (Int_t) fWidth ||
181  event->fY < 0 || event->fY >= (Int_t) fHeight)
182  {
183  if (event->fType == kButtonRelease)
184  UnmapWindow();
185  }
186  else
187  {
188  TGFrame *f = GetFrameFromPoint(event->fX, event->fY);
189  if (f && f != this)
190  {
191  TranslateCoordinates(f, event->fX, event->fY, event->fX, event->fY);
192  f->HandleButton(event);
193  }
194  }
195  return kTRUE;
196 }
double f[11][100]
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
Bool_t FWColorPopup::HasFreePalette ( )
static

Definition at line 150 of file FWColorSelect.cc.

References fgFreePalette.

150 { return fgFreePalette; }
static Bool_t fgFreePalette
Definition: FWColorSelect.h:87
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 FWGeometryTableViewBase::cellClicked(), FWModelContextMenuHandler::createColorPopup(), FWCollectionSummaryWidget::createColorPopup(), and FWColorSelect::FWColorSelect().

199 {
200  fLabel = new TGLabel(this, name);
201  fLabel->SetBackgroundColor(GetBackground());
202  SetColors(colors, backgroundIsBlack);
203 
204  AddFrame(fLabel, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, kCROffsetX, kCROffsetY, kCRPadAbove + 1, kCRPadBelow - 1));
205  AddFrame(fFirstRow, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, kCROffsetX, kCROffsetY, kCRPadAbove, kCRPadBelow));
206  AddFrame(fSecondRow, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, kCROffsetX, kCROffsetY, kCRPadAbove, kCRPadBelow));
207 
208  fFirstRow->MapSubwindows();
209  fFirstRow->Resize(fFirstRow->GetDefaultSize());
210 
211  fSecondRow->MapSubwindows();
212  fSecondRow->Resize(fSecondRow->GetDefaultSize());
213 
214  if (fgFreePalette)
215  {
216  TGTextButton *b = new TGTextButton(this, "Color wheel");
217  AddFrame(b, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, kCROffsetX, kCROffsetY, kCRPadAbove, 2 * kCRPadBelow));
218  b->Connect("Clicked()", "FWColorPopup", this, "PopupColorWheel()");
219  }
220 }
FWColorRow * fFirstRow
Definition: FWColorSelect.h:82
TGLabel * fLabel
Definition: FWColorSelect.h:83
FWColorRow * fSecondRow
Definition: FWColorSelect.h:82
vector< Color_t > colors
static Bool_t fgFreePalette
Definition: FWColorSelect.h:87
void SetColors(const std::vector< Pixel_t > &colors, bool backgroundIsBlack)
double b
Definition: hdecay.h:120
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, WDecay::kNone, corrVsCorr::rx, and corrVsCorr::ry.

Referenced by FWGeometryTableViewBase::cellClicked(), FWModelContextMenuHandler::chosenItem(), FWCollectionSummaryWidget::colorClicked(), FWColorSelect::HandleButton(), and FWCollectionSummaryWidget::itemColorClicked().

269 {
270  // Popup TGColorPopup at x,y position
271 
272  Int_t rx, ry;
273  UInt_t rw, rh;
274 
275  // Parent is root window for the popup:
276  gVirtualX->GetWindowSize(fParent->GetId(), rx, ry, rw, rh);
277 
278  if (x < 0) x = 0;
279  if (x + fWidth > rw) x = rw - fWidth;
280  if (y < 0) y = 0;
281  if (y + fHeight > rh) y = rh - fHeight;
282 
283  MoveResize(x, y, w, h);
284  MapSubwindows();
285  Layout();
286  MapRaised();
287 
288  // find out if this is necessary
289  gVirtualX->GrabPointer(fId, kButtonPressMask | kButtonReleaseMask | kPointerMotionMask, kNone, kNone);
290 
291  gClient->WaitForUnmap(this);
292  gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
293 
294  if (fShowWheel)
295  {
296  Int_t retc;
297  Pixel_t pixel = TColor::Number2Pixel(fSelectedColor);
298 
299  TGColorDialog *cd = new TGColorDialog(gClient->GetDefaultRoot(), this, &retc, &pixel, kFALSE);
300 
301  cd->Connect("ColorSelected(Pixel_t)", "FWColorPopup", this, "ColorWheelSelected(Pixel_t");
302 
303  cd->MapWindow();
304  fClient->WaitForUnmap(cd);
305  cd->DeleteWindow();
306 
307  fShowWheel = kFALSE;
308  }
309 }
Bool_t fShowWheel
Definition: FWColorSelect.h:85
const double w
Definition: UKUtility.cc:23
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Color_t fSelectedColor
Definition: FWColorSelect.h:81
void FWColorPopup::PopupColorWheel ( )

Definition at line 224 of file FWColorSelect.cc.

References fShowWheel.

225 {
226  fShowWheel = kTRUE;
227  UnmapWindow();
228 }
Bool_t fShowWheel
Definition: FWColorSelect.h:85
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, cmsHarvester::index, FWColorRow::ResetColor(), and FWColorRow::SetBackgroundToBlack().

Referenced by FWGeometryTableViewBase::cellClicked(), FWModelContextMenuHandler::chosenItem(), FWCollectionSummaryWidget::colorClicked(), FWColorSelect::HandleButton(), and FWCollectionSummaryWidget::itemColorClicked().

253 {
254  fNumColors=colors.size();
255  for (UInt_t i = 0; i < colors.size() / 2; i++)
256  {
257  fFirstRow->ResetColor(i,colors.at(i));
258  }
259  fFirstRow->SetBackgroundToBlack(backgroundIsBlack);
260  UInt_t index = 0;
261  for (UInt_t i = colors.size() / 2; i < colors.size(); i++, ++index)
262  {
263  fSecondRow->ResetColor(index,colors.at(i));
264  }
265  fSecondRow->SetBackgroundToBlack(backgroundIsBlack);
266 }
int i
Definition: DBlmapReader.cc:9
void SetBackgroundToBlack(Bool_t)
FWColorRow * fFirstRow
Definition: FWColorSelect.h:82
FWColorRow * fSecondRow
Definition: FWColorSelect.h:82
vector< Color_t > colors
Int_t fNumColors
Definition: FWColorSelect.h:84
void ResetColor(Int_t, Color_t)
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().

238 {
239  fNumColors = colors.size();
240  for (UInt_t i = 0; i < colors.size() / 2; i++)
241  {
242  fFirstRow->AddColor(colors.at(i));
243  }
244  for (UInt_t i = colors.size() / 2; i < colors.size(); i++)
245  {
246  fSecondRow->AddColor(colors.at(i));
247  }
248  fFirstRow->SetBackgroundToBlack(backgroundIsBlack);
249  fSecondRow->SetBackgroundToBlack(backgroundIsBlack);
250 }
int i
Definition: DBlmapReader.cc:9
void SetBackgroundToBlack(Bool_t)
FWColorRow * fFirstRow
Definition: FWColorSelect.h:82
FWColorRow * fSecondRow
Definition: FWColorSelect.h:82
vector< Color_t > colors
Int_t fNumColors
Definition: FWColorSelect.h:84
virtual void AddColor(Color_t color)
void FWColorPopup::SetName ( const char *  iName)
void FWColorPopup::SetSelection ( Color_t  iColor)

Member Data Documentation

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
staticprotected

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().