00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <iostream>
00016 #include <vector>
00017 #include <boost/bind.hpp>
00018 #include "TGButton.h"
00019 #include "TGResourcePool.h"
00020 #include "Fireworks/Core/src/FWColorSelect.h"
00021 #include "Fireworks/Core/src/FWBoxIconButton.h"
00022 #include "Fireworks/Core/src/FWCheckBoxIcon.h"
00023 #include "Fireworks/Core/src/FWColorBoxIcon.h"
00024
00025
00026 #include "Fireworks/Core/src/FWCollectionSummaryWidget.h"
00027 #include "Fireworks/Core/interface/FWEventItem.h"
00028 #include "Fireworks/Core/interface/FWCustomIconsButton.h"
00029
00030 #include "Fireworks/Core/src/FWCollectionSummaryTableManager.h"
00031 #include "Fireworks/TableWidget/interface/FWTableWidget.h"
00032
00033 #include "Fireworks/Core/interface/FWSelectionManager.h"
00034 #include "Fireworks/Core/interface/FWModelChangeManager.h"
00035 #include "Fireworks/Core/interface/FWColorManager.h"
00036
00037
00038
00039
00040 struct FWCollectionSummaryWidgetConnectionHolder {
00041 std::vector<sigc::connection> m_connections;
00042
00043 ~FWCollectionSummaryWidgetConnectionHolder() {
00044 for_each(m_connections.begin(),m_connections.end(), boost::bind(&sigc::connection::disconnect,_1));
00045 }
00046 void push_back(const sigc::connection& iC) {
00047 m_connections.push_back(iC);
00048 }
00049 void reserve(size_t iSize) {
00050 m_connections.reserve(iSize);
00051 }
00052 };
00053
00054
00055
00056
00057
00058 namespace {
00059 class BorderlessTextButton : public TGTextButton {
00060 public:
00061 BorderlessTextButton(const TGWindow *p = 0, const char *s = 0, Int_t id = -1,
00062 GContext_t norm = GetDefaultGC()(),
00063 FontStruct_t font = GetDefaultFontStruct()):
00064 TGTextButton(p,s,id,norm,font,0){
00065
00066 fMTop = -3;
00067 fMBottom = -3;
00068 }
00069
00070 void DoRedraw();
00071 };
00072
00073 void BorderlessTextButton::DoRedraw() {
00074 gVirtualX->ClearArea(fId, fBorderWidth, fBorderWidth,
00075 fWidth - (fBorderWidth << 1), fHeight - (fBorderWidth << 1));
00076
00077
00078 int x, y;
00079 if (fTMode & kTextLeft) {
00080 x = fMLeft + 4;
00081 } else if (fTMode & kTextRight) {
00082 x = fWidth - fTWidth - fMRight - 4;
00083 } else {
00084 x = (fWidth - fTWidth + fMLeft - fMRight) >> 1;
00085 }
00086
00087 if (fTMode & kTextTop) {
00088 y = fMTop + 3;
00089 } else if (fTMode & kTextBottom) {
00090 y = fHeight - fTHeight - fMBottom - 3;
00091 } else {
00092 y = (fHeight - fTHeight + fMTop - fMBottom) >> 1;
00093 }
00094
00095 Int_t hotpos = fLabel->GetHotPos();
00096
00097 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
00098 if (hotpos) fTLayout->UnderlineChar(fId, fNormGC, x, y, hotpos - 1);
00099 }
00100 }
00101
00102
00103 static
00104 const TGPicture* filtered(bool iBackgroundIsBlack)
00105 {
00106 if(iBackgroundIsBlack) {
00107 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"filtered-blackbg.png");
00108 return s;
00109 }
00110 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"filtered-whitebg.png");
00111 return s;
00112
00113 }
00114
00115 static
00116 const TGPicture* filtered_over(bool iBackgroundIsBlack)
00117 {
00118 if(iBackgroundIsBlack) {
00119 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"filtered-whitebg-over.png");
00120 return s;
00121 }
00122 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"filtered-whitebg-over.png");
00123 return s;
00124 }
00125
00126 static
00127 const TGPicture* alert_over(bool iBackgroundIsBlack)
00128 {
00129 if(iBackgroundIsBlack) {
00130 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"icon-alert-blackbg-over.png");
00131 return s;
00132 }
00133 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"icon-alert-whitebg-over.png");
00134 return s;
00135 }
00136
00137 static
00138 const TGPicture* alert(bool iBackgroundIsBlack)
00139 {
00140
00141 if(iBackgroundIsBlack) {
00142 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"icon-alert-blackbg.png");
00143 return s;
00144 }
00145 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"icon-alert-whitebg.png");
00146 return s;
00147 }
00148
00149 static
00150 const TGPicture* unfiltered(bool iBackgroundIsBlack)
00151 {
00152 if(iBackgroundIsBlack) {
00153 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"unfiltered-blackbg.png");
00154 return s;
00155 }
00156 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"unfiltered-whitebg.png");
00157 return s;
00158 }
00159 static
00160 const TGPicture* unfiltered_over(bool iBackgroundIsBlack)
00161 {
00162 if(iBackgroundIsBlack) {
00163 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"unfiltered-blackbg-over.png");
00164 return s;
00165 }
00166 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"unfiltered-whitebg-over.png");
00167 return s;
00168 }
00169
00170 static
00171 const TGPicture* info(bool iBackgroundIsBlack)
00172 {
00173 if(iBackgroundIsBlack) {
00174 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"info2-blackbg.png");
00175 return s;
00176 }
00177 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"info2-whitebg.png");
00178 return s;
00179 }
00180
00181 static
00182 const TGPicture* info_over(bool iBackgroundIsBlack)
00183 {
00184 if(iBackgroundIsBlack) {
00185 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"info2-blackbg-over.png");
00186 return s;
00187 }
00188 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"info2-whitebg-over.png");
00189 return s;
00190 }
00191
00192 static
00193 const TGPicture* info_disabled(bool iBackgroundIsBlack)
00194 {
00195 if(iBackgroundIsBlack) {
00196 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"info2-blackbg-disabled.png");
00197 return s;
00198 }
00199 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"info2-whitebg-disabled.png");
00200 return s;
00201 }
00202
00203 static
00204 const TGPicture* arrow_right(bool iBackgroundIsBlack)
00205 {
00206 if(iBackgroundIsBlack) {
00207 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"arrow-white-right-blackbg.png");
00208 return s;
00209 }
00210 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"arrow-black-right-whitebg.png");
00211 return s;
00212 }
00213
00214 static
00215 const TGPicture* arrow_right_disabled(bool iBackgroundIsBlack)
00216 {
00217 if(iBackgroundIsBlack) {
00218 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"arrow-white-right-disabled-blackbg.png");
00219 return s;
00220 }
00221 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"arrow-black-right-disabled-whitebg.png");
00222 return s;
00223 }
00224
00225 static
00226 const TGPicture* arrow_down(bool iBackgroundIsBlack)
00227 {
00228 if(iBackgroundIsBlack) {
00229 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"arrow-white-down-blackbg.png");
00230 return s;
00231 }
00232 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"arrow-black-down-whitebg.png");
00233 return s;
00234 }
00235
00236 static
00237 const TGPicture* arrow_down_disabled(bool iBackgroundIsBlack)
00238 {
00239 if(iBackgroundIsBlack) {
00240 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"arrow-white-down-disabled-blackbg.png");
00241 return s;
00242 }
00243 static const TGPicture* s = gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"arrow-black-down-disabled-whitebg.png");
00244 return s;
00245 }
00246
00247
00248 static const unsigned long kWidgetColor = 0x2f2f2f;
00249 static const unsigned long kWidgetColorLight = 0xdfdfdf;
00250
00251
00252
00253 FWCollectionSummaryWidget::FWCollectionSummaryWidget(TGFrame* iParent, FWEventItem& iItem, TGLayoutHints* iHints):
00254 TGCompositeFrame(iParent),
00255 m_collection(&iItem),
00256 m_hints(iHints),
00257 m_parent(iParent),
00258 m_collectionShown(false),
00259 m_tableContext(0),
00260 m_indexForColor(-1),
00261 m_colorPopup(0),
00262 m_tableManager(0),
00263 m_tableWidget(0),
00264 m_backgroundIsWhite(false),
00265 m_connectionHolder( new FWCollectionSummaryWidgetConnectionHolder)
00266 {
00267 SetBackgroundColor(kWidgetColor);
00268 const unsigned int backgroundColor=kBlack;
00269
00270 TGCompositeFrame* hFrame = new TGHorizontalFrame(this, 10, 10, 0, backgroundColor);
00271 m_holder = hFrame;
00272 this->AddFrame(hFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX) );
00273
00274 m_showHideButton = new FWCustomIconsButton(this,
00275 arrow_right(!m_backgroundIsWhite),
00276 arrow_right_disabled(!m_backgroundIsWhite),
00277 arrow_right_disabled(!m_backgroundIsWhite));
00278 m_showHideButton->Connect("Clicked()","FWCollectionSummaryWidget",this,"toggleShowHide()");
00279 m_showHideButton->SetToolTipText("show/hide individual collection items");
00280 m_collectionShown = false;
00281 hFrame->AddFrame(m_showHideButton,new TGLayoutHints(kLHintsCenterY | kLHintsLeft,6,10));
00282
00283
00284
00285 m_isVisibleCheckBox = new FWCheckBoxIcon(12);
00286 m_isVisibleButton = new FWBoxIconButton(this, m_isVisibleCheckBox,-1,GetWhiteGC()());
00287 m_isVisibleButton->SetBackgroundColor(backgroundColor);
00288 m_isVisibleButton->SetToolTipText("make all items in collection visible/invisible");
00289 hFrame->AddFrame(m_isVisibleButton,new TGLayoutHints(kLHintsCenterY | kLHintsLeft,0,1));
00290 m_isVisibleButton->Connect("Clicked()", "FWCollectionSummaryWidget", this, "toggleItemVisible()");
00291
00292 m_colorSelectBox = new FWColorBoxIcon(12);
00293 m_colorSelectWidget = new FWBoxIconButton(this,m_colorSelectBox,-1,GetWhiteGC()());
00294 hFrame->AddFrame(m_colorSelectWidget,new TGLayoutHints(kLHintsCenterY | kLHintsLeft,1));
00295
00296 m_colorSelectWidget->Connect("Clicked()", "FWCollectionSummaryWidget",this,"colorClicked()");
00297 m_colorSelectWidget->SetBackgroundColor(backgroundColor);
00298 m_colorSelectWidget->SetToolTipText("set default color of items in collection");
00299 GCValues_t t = *( GetWhiteGC().GetAttributes());
00300 m_graphicsContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&t,kTRUE);
00301 m_colorSelectBox->setColor(m_graphicsContext->GetGC());
00302
00303
00304 m_label = new BorderlessTextButton(this,
00305 m_collection->name().c_str());
00306 m_label->SetBackgroundColor(backgroundColor);
00307 m_label->SetTextJustify(kTextLeft|kTextCenterY);
00308 m_label->SetTextColor(static_cast<Pixel_t>(gVirtualX->GetPixel(kWhite)));
00309 hFrame->AddFrame(m_label, new TGLayoutHints(kLHintsCenterY | kLHintsLeft | kLHintsExpandX,5,5));
00310 m_label->Connect("Clicked()","FWCollectionSummaryWidget",this,"labelClicked()");
00311 m_label->SetToolTipText("select collection and show controller");
00312
00313 m_stateButton = new FWCustomIconsButton(this,unfiltered(!m_backgroundIsWhite),
00314 unfiltered_over(!m_backgroundIsWhite),
00315 unfiltered_over(!m_backgroundIsWhite));
00316 hFrame->AddFrame(m_stateButton, new TGLayoutHints(kLHintsCenterY| kLHintsLeft));
00317 itemChanged();
00318 displayChanged();
00319 m_stateButton->Connect("Clicked()","FWCollectionSummaryWidget",this,"stateClicked()");
00320 m_stateButton->SetToolTipText("select collection and show filter");
00321
00322 m_infoButton = new FWCustomIconsButton(this,
00323 info(!m_backgroundIsWhite),
00324 info_over(!m_backgroundIsWhite),
00325 info_disabled(!m_backgroundIsWhite)
00326 );
00327 hFrame->AddFrame(m_infoButton, new TGLayoutHints(kLHintsCenterY| kLHintsRight,2,2));
00328 m_infoButton->Connect("Clicked()","FWCollectionSummaryWidget",this,"infoClicked()");
00329 m_infoButton->SetToolTipText("select collection and show data info");
00330
00331 m_connectionHolder->reserve(3);
00332 m_connectionHolder->push_back(m_collection->defaultDisplayPropertiesChanged_.connect(boost::bind(&FWCollectionSummaryWidget::displayChanged, this)));
00333 m_connectionHolder->push_back(m_collection->itemChanged_.connect(boost::bind(&FWCollectionSummaryWidget::itemChanged,this)));
00334 m_connectionHolder->push_back(m_collection->filterChanged_.connect(boost::bind(&FWCollectionSummaryWidget::itemChanged,this)));
00335
00336 MapSubwindows();
00337 Layout();
00338 MapWindow();
00339 }
00340
00341
00342
00343
00344
00345
00346 FWCollectionSummaryWidget::~FWCollectionSummaryWidget()
00347 {
00348 delete m_colorPopup;
00349
00350
00351
00352
00353
00354
00355
00356
00357 gClient->GetResourcePool()->GetGCPool()->FreeGC(m_graphicsContext->GetGC());
00358 delete m_connectionHolder;
00359 }
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376 static
00377 void
00378 setLabelBackgroundColor(TGTextButton* iLabel, bool iIsSelected, bool iBackgroundIsWhite)
00379 {
00380 if(iIsSelected) {
00381 if(iBackgroundIsWhite) {
00382 iLabel->SetBackgroundColor(0x7777FF);
00383 } else {
00384 iLabel->SetBackgroundColor(0x0000FF);
00385 }
00386 } else {
00387 if(iBackgroundIsWhite) {
00388 iLabel->SetBackgroundColor(0xFFFFFF);
00389 } else {
00390 iLabel->SetBackgroundColor(0x000000);
00391 }
00392 }
00393 }
00394
00395 void
00396 FWCollectionSummaryWidget::displayChanged()
00397 {
00398 m_graphicsContext->SetForeground(gVirtualX->GetPixel(m_collection->defaultDisplayProperties().color()));
00399 fClient->NeedRedraw(m_colorSelectWidget);
00400 m_isVisibleCheckBox->setChecked(m_collection->defaultDisplayProperties().isVisible());
00401 fClient->NeedRedraw(m_isVisibleButton);
00402 setLabelBackgroundColor(m_label,m_collection->itemIsSelected(),m_backgroundIsWhite);
00403 fClient->NeedRedraw(m_label);
00404 }
00405
00406 void
00407 FWCollectionSummaryWidget::itemChanged()
00408 {
00409 const TGPicture* picture = 0;
00410 const TGPicture* down = 0;
00411 const TGPicture* disabled=0;
00412 if(m_collection->hasError()) {
00413 picture = alert(!m_backgroundIsWhite);
00414 down = alert_over(!m_backgroundIsWhite);
00415 disabled = alert_over(!m_backgroundIsWhite);
00416 m_stateButton->SetToolTipText(m_collection->errorMessage().c_str());
00417 } else {
00418 if(m_collection->filterExpression().size()) {
00419 picture = filtered(!m_backgroundIsWhite);
00420 down = filtered_over(!m_backgroundIsWhite);
00421 disabled = filtered_over(!m_backgroundIsWhite);
00422 } else {
00423 picture = unfiltered(!m_backgroundIsWhite);
00424 down = unfiltered_over(!m_backgroundIsWhite);
00425 disabled = unfiltered_over(!m_backgroundIsWhite);
00426 }
00427 m_stateButton->SetToolTipText("select collection and show filter");
00428 }
00429 m_stateButton->swapIcons(picture,down,disabled);
00430 }
00431
00432 void
00433 FWCollectionSummaryWidget::colorChangeRequested(Color_t color)
00434 {
00435 if(-1 == m_indexForColor) {
00436 FWDisplayProperties changeProperties = m_collection->defaultDisplayProperties();
00437 changeProperties.setColor(color);
00438 m_collection->setDefaultDisplayProperties(changeProperties);
00439 return;
00440 }
00441
00442 FWDisplayProperties changeProperties = m_collection->modelInfo(m_indexForColor).displayProperties();
00443 changeProperties.setColor(color);
00444 m_collection->setDisplayProperties(m_indexForColor,changeProperties);
00445 }
00446
00447 void
00448 FWCollectionSummaryWidget::toggleItemVisible()
00449 {
00450 m_isVisibleCheckBox->setChecked(!m_isVisibleCheckBox->isChecked());
00451 FWDisplayProperties changeProperties = m_collection->defaultDisplayProperties();
00452 changeProperties.setIsVisible(m_isVisibleCheckBox->isChecked());
00453 m_collection->setDefaultDisplayProperties(changeProperties);
00454 fClient->NeedRedraw(m_isVisibleButton);
00455 }
00456
00457 static
00458 TGGC* selectContext()
00459 {
00460 static TGGC* s_context = 0;
00461 if(0==s_context) {
00462 GCValues_t hT = *(gClient->GetResourcePool()->GetSelectedGC()->GetAttributes());
00463 s_context = gClient->GetResourcePool()->GetGCPool()->GetGC(&hT,kTRUE);
00464 s_context->SetForeground(s_context->GetBackground());
00465
00466 }
00467 return s_context;
00468 }
00469
00470 void
00471 FWCollectionSummaryWidget::toggleShowHide()
00472 {
00473 const TGPicture* picture = 0;
00474 const TGPicture* down = 0;
00475 const TGPicture* disabled=0;
00476
00477 if(m_collectionShown) {
00478 picture = arrow_right(!m_backgroundIsWhite);
00479 down = arrow_right_disabled(!m_backgroundIsWhite);
00480 disabled = arrow_right_disabled(!m_backgroundIsWhite);
00481 m_collectionShown = false;
00482 HideFrame(m_tableWidget);
00483 m_hints->SetLayoutHints(kLHintsExpandX);
00484 } else {
00485 picture = arrow_down(!m_backgroundIsWhite);
00486 down = arrow_down_disabled(!m_backgroundIsWhite);
00487 disabled = arrow_down_disabled(!m_backgroundIsWhite);
00488 m_collectionShown = true;
00489
00490 if(0 == m_tableManager) {
00491 GCValues_t t = *(GetWhiteGC().GetAttributes());
00492 t.fFont = gClient->GetResourcePool()->GetIconFont()->GetFontHandle();
00493 m_tableContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&t,kTRUE);
00494
00495 TGGC* hilightContext=selectContext();
00496 m_tableManager= new FWCollectionSummaryTableManager(m_collection,m_tableContext,hilightContext,this);
00497 m_tableWidget = new FWTableWidget(m_tableManager,this);
00498 m_tableWidget->SetHeaderBackgroundColor(fClient->GetResourcePool()->GetFrameGC()->GetBackground());
00499 colorTable();
00500 AddFrame(m_tableWidget, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY));
00501 m_tableWidget->Connect("rowClicked(Int_t,Int_t,Int_t,Int_t,Int_t)","FWCollectionSummaryWidget",this,"modelSelected(Int_t,Int_t,Int_t,Int_t,Int_t)");
00502
00503 MapSubwindows();
00504 Layout();
00505 }
00506 ShowFrame(m_tableWidget);
00507 m_hints->SetLayoutHints(kLHintsExpandX|kLHintsExpandY);
00508
00509
00510
00511 m_tableWidget->Resize(m_tableWidget->GetWidth(),m_tableWidget->GetHeight());
00512 }
00513
00514 if(0!=m_parent) {
00515 m_parent->Layout();
00516 }
00517 m_showHideButton->swapIcons(picture,down,disabled);
00518 }
00519
00520
00521
00522 void
00523 FWCollectionSummaryWidget::createColorPopup()
00524 {
00525 if (0==m_colorPopup)
00526 {
00527 std::vector<Color_t> colors;
00528 m_collection->colorManager()->fillLimitedColors(colors);
00529
00530 m_colorPopup = new FWColorPopup(gClient->GetDefaultRoot(), m_collection->defaultDisplayProperties().color());
00531 m_colorPopup->InitContent(m_collection->name().c_str(), colors);
00532 m_colorPopup->Connect("ColorSelected(Color_t)","FWCollectionSummaryWidget", this, "colorChangeRequested(Color_t)");
00533 }
00534 }
00535
00536 void
00537 FWCollectionSummaryWidget::colorClicked()
00538 {
00539 FWColorManager* cm = m_collection->colorManager();
00540 m_indexForColor=-1;
00541
00542 createColorPopup();
00543 Window_t wdummy;
00544 Int_t ax, ay;
00545 gVirtualX->TranslateCoordinates(m_colorSelectWidget->GetId(), gClient->GetDefaultRoot()->GetId(), 0,
00546 m_colorSelectWidget->GetHeight(), ax, ay, wdummy);
00547 m_colorPopup->SetName(m_collection->name().c_str());
00548 std::vector<Color_t> colors;
00549 cm->fillLimitedColors(colors);
00550 m_colorPopup->ResetColors(colors, cm->backgroundColorIndex()==FWColorManager::kBlackIndex);
00551 m_colorPopup->SetSelection(m_collection->defaultDisplayProperties().color());
00552 m_colorPopup->PlacePopup(ax, ay, m_colorPopup->GetDefaultWidth(), m_colorPopup->GetDefaultHeight());
00553 }
00554
00555 void
00556 FWCollectionSummaryWidget::itemColorClicked(int iIndex, Int_t iRootX, Int_t iRootY)
00557 {
00558 FWColorManager* cm = m_collection->colorManager();
00559 m_indexForColor=iIndex;
00560
00561 createColorPopup();
00562 std::vector<Color_t> colors;
00563 cm->fillLimitedColors(colors);
00564 m_colorPopup->ResetColors(colors, cm->backgroundColorIndex()==FWColorManager::kBlackIndex);
00565 m_colorPopup->SetName(m_collection->modelName(iIndex).c_str());
00566 m_colorPopup->SetSelection(m_collection->modelInfo(iIndex).displayProperties().color());
00567 m_colorPopup->PlacePopup(iRootX, iRootY, m_colorPopup->GetDefaultWidth(), m_colorPopup->GetDefaultHeight());
00568 }
00569
00570 void
00571 FWCollectionSummaryWidget::modelSelected(Int_t iRow,Int_t iButton,Int_t iKeyMod,Int_t iGlobalX, Int_t iGlobalY)
00572 {
00573 if(iKeyMod & kKeyControlMask) {
00574 m_collection->toggleSelect(iRow);
00575 } else {
00576 FWChangeSentry sentry(*(m_collection->changeManager()));
00577 m_collection->selectionManager()->clearSelection();
00578 m_collection->select(iRow);
00579 }
00580 if(iButton==kButton3) {
00581 requestForModelContextMenu(iGlobalX,iGlobalY);
00582 }
00583 }
00584
00585
00586 void
00587 FWCollectionSummaryWidget::requestForInfo(FWEventItem* iItem)
00588 {
00589 Emit("requestForInfo(FWEventItem*)",reinterpret_cast<long>(iItem));
00590 }
00591
00592 void
00593 FWCollectionSummaryWidget::requestForFilter(FWEventItem* iItem)
00594 {
00595 Emit("requestForFilter(FWEventItem*)", reinterpret_cast<long>(iItem));
00596 }
00597
00598 void
00599 FWCollectionSummaryWidget::requestForErrorInfo(FWEventItem* iItem)
00600 {
00601 Emit("requestForErrorInfo(FWEventItem*)",reinterpret_cast<long>(iItem));
00602 }
00603
00604 void
00605 FWCollectionSummaryWidget::requestForController(FWEventItem* iItem)
00606 {
00607 Emit("requestForController(FWEventItem*)",reinterpret_cast<long>(iItem));
00608 }
00609
00610 void
00611 FWCollectionSummaryWidget::requestForModelContextMenu(Int_t iGlobalX,Int_t iGlobalY)
00612 {
00613 Long_t args[2];
00614 args[0]=static_cast<Long_t>(iGlobalX);
00615 args[1]=static_cast<Long_t> (iGlobalY);
00616 Emit("requestForModelContextMenu(Int_t,Int_t)",args);
00617 }
00618
00619 void
00620 FWCollectionSummaryWidget::infoClicked()
00621 {
00622 if(!m_collection->itemIsSelected()) {
00623
00624 m_collection->selectionManager()->clearSelection();
00625 m_collection->selectItem();
00626 }
00627 requestForInfo(m_collection);
00628 }
00629
00630 void
00631 FWCollectionSummaryWidget::stateClicked()
00632 {
00633 if(!m_collection->itemIsSelected()) {
00634
00635 m_collection->selectionManager()->clearSelection();
00636 m_collection->selectItem();
00637 }
00638 requestForFilter(m_collection);
00639 }
00640
00641 void
00642 FWCollectionSummaryWidget::labelClicked()
00643 {
00644 if(!m_collection->itemIsSelected()) {
00645
00646 m_collection->selectionManager()->clearSelection();
00647 m_collection->selectItem();
00648 }
00649 requestForController(m_collection);
00650 }
00651
00652 void
00653 FWCollectionSummaryWidget::setBackgroundToWhite(bool iToWhite)
00654 {
00655 if(iToWhite == m_backgroundIsWhite) {
00656 return;
00657 }
00658 Pixel_t bc = 0x000000;
00659 Pixel_t fg = 0xffffff;
00660 if(iToWhite) {
00661 bc = 0xffffff;
00662 fg = 0x000000;
00663 m_backgroundIsWhite=true;
00664 SetBackgroundColor(kWidgetColorLight);
00665 m_isVisibleButton->setNormCG(GetBlackGC()());
00666 m_colorSelectWidget->setNormCG(GetBlackGC()());
00667 selectContext()->SetForeground(0xafafFF);
00668 } else {
00669 m_backgroundIsWhite=false;
00670 SetBackgroundColor(kWidgetColor);
00671 m_isVisibleButton->setNormCG(GetWhiteGC()());
00672 m_colorSelectWidget->setNormCG(GetWhiteGC()());
00673 selectContext()->SetForeground(gClient->GetResourcePool()->GetSelectedGC()->GetBackground());
00674 }
00675
00676 itemChanged();
00677 m_graphicsContext->SetForeground(gVirtualX->GetPixel(m_collection->defaultDisplayProperties().color()));
00678 {
00679 const TGPicture* picture = info(!m_backgroundIsWhite);
00680 const TGPicture* over = info_over(!m_backgroundIsWhite);
00681 const TGPicture* disabled = info_disabled(!m_backgroundIsWhite);
00682 m_infoButton->swapIcons(picture,
00683 over,
00684 disabled);
00685 }
00686 if(m_collectionShown) {
00687 const TGPicture* picture = arrow_down(!m_backgroundIsWhite);
00688 const TGPicture* down = arrow_down_disabled(!m_backgroundIsWhite);
00689 const TGPicture* disabled = arrow_down_disabled(!m_backgroundIsWhite);
00690 m_showHideButton->swapIcons(picture,down,disabled);
00691 } else {
00692 const TGPicture* picture = arrow_right(!m_backgroundIsWhite);
00693 const TGPicture* down = arrow_right_disabled(!m_backgroundIsWhite);
00694 const TGPicture* disabled = arrow_right_disabled(!m_backgroundIsWhite);
00695 m_showHideButton->swapIcons(picture,down,disabled);
00696 }
00697 colorTable();
00698 m_holder->SetBackgroundColor(bc);
00699 setLabelBackgroundColor(m_label,m_collection->itemIsSelected(),m_backgroundIsWhite);
00700 m_label->SetTextColor(fg);
00701 m_isVisibleButton->SetBackgroundColor(bc);
00702 m_colorSelectWidget->SetBackgroundColor(bc);
00703 fClient->NeedRedraw(m_isVisibleButton);
00704 fClient->NeedRedraw(m_colorSelectWidget);
00705 fClient->NeedRedraw(m_holder);
00706 fClient->NeedRedraw(this);
00707 }
00708
00709 void
00710 FWCollectionSummaryWidget::colorTable()
00711 {
00712 if(0==m_tableWidget) {
00713 return;
00714 }
00715 if(m_backgroundIsWhite) {
00716 m_tableWidget->SetBackgroundColor(kWidgetColorLight);
00717 m_tableWidget->SetLineSeparatorColor(0x000000);
00718 m_tableContext->SetForeground(0x000000);
00719 } else {
00720 m_tableWidget->SetBackgroundColor(kWidgetColor);
00721 m_tableWidget->SetLineSeparatorColor(0xffffff);
00722 m_tableContext->SetForeground(0xffffff);
00723 }
00724 }
00725
00726
00727
00728
00729
00730
00731
00732
00733 ClassImp(FWCollectionSummaryWidget)
00734