CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes

CSGAction Class Reference

#include <Fireworks/Core/interface/CSGAction.h>

Inheritance diagram for CSGAction:
CSGContinuousAction

List of all members.

Public Member Functions

void activate ()
void addSCToMenu ()
void createCheckButton (TGCompositeFrame *p, TGLayoutHints *l=0, Bool_t state=true, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), FontStruct_t font=TGTextButton::GetDefaultFontStruct())
FWCustomIconsButtoncreateCustomIconsButton (TGCompositeFrame *p, const TGPicture *upPic, const TGPicture *downPic, const TGPicture *disabledPic, TGLayoutHints *l=0, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), UInt_t option=0)
void createMenuEntry (TGPopupMenu *menu)
void createPictureButton (TGCompositeFrame *p, const TGPicture *pic, TGLayoutHints *l=0, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), UInt_t option=kRaisedFrame|kDoubleBorder)
void createShortcut (UInt_t key, const char *mod, int windowID)
void createTextButton (TGCompositeFrame *p, TGLayoutHints *l=0, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), FontStruct_t font=TGTextButton::GetDefaultFontStruct(), UInt_t option=kRaisedFrame|kDoubleBorder)
 CSGAction (CSGActionSupervisor *supervisor, const char *name)
void disable ()
void enable ()
Int_t getKeycode () const
TGPopupMenu * getMenu () const
int getMenuEntry () const
Int_t getModcode () const
const std::string & getName () const
TString getSCCombo () const
TGToolBar * getToolBar () const
ToolBarData_t * getToolBarData () const
const std::string & getToolTip () const
virtual void globalDisable ()
virtual void globalEnable ()
virtual Bool_t isEnabled () const
Bool_t resizeMenuEntry ()
void setMenuLabel (const std::string &label)
void setName (const std::string &name)
void setToolTip (const std::string &tip)
virtual ~CSGAction ()

Static Public Member Functions

static TString keycodeToString (Int_t keycode)

Public Attributes

sigc::signal< void > activated

Private Member Functions

 CSGAction (const CSGAction &)
void disableImp ()
void enableImp ()
const CSGActionoperator= (const CSGAction &)

Private Attributes

std::vector< TGButton * > m_buttons
CSGConnectorm_connector
Bool_t m_enabled
int m_entry
Bool_t m_globalEnabled
Int_t m_keycode
TGPopupMenu * m_menu
Int_t m_modcode
std::string m_name
TString m_scCombo
CSGActionSupervisorm_supervisor
TGToolBar * m_toolBar
ToolBarData_t * m_tools
std::string m_toolTip
int m_windowID

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 39 of file CSGAction.h.


Constructor & Destructor Documentation

CSGAction::CSGAction ( CSGActionSupervisor supervisor,
const char *  name 
)
CSGAction::~CSGAction ( ) [virtual]

Definition at line 61 of file CSGAction.cc.

References m_connector.

{
   delete m_connector;
   //Don't delete GUI parts since they are owned by their GUI parent
}
CSGAction::CSGAction ( const CSGAction ) [private]

Member Function Documentation

void CSGAction::activate ( ) [inline]

Definition at line 85 of file CSGAction.h.

References activated.

                  {
      activated.emit();
   }
void CSGAction::addSCToMenu ( )

Definition at line 213 of file CSGAction.cc.

References m_menu, m_supervisor, CSGActionSupervisor::resizeMenu(), and resizeMenuEntry().

Referenced by createMenuEntry(), and createShortcut().

                            {
   Bool_t widthChanged = resizeMenuEntry();
   if (widthChanged) m_supervisor->resizeMenu(m_menu);
}
void CSGAction::createCheckButton ( TGCompositeFrame *  p,
TGLayoutHints *  l = 0,
Bool_t  state = true,
Int_t  id = -1,
GContext_t  norm = TGButton::GetDefaultGC() (),
FontStruct_t  font = TGTextButton::GetDefaultFontStruct() 
)

Definition at line 127 of file CSGAction.cc.

References CSGActionSupervisor::getToolTipDelay(), isEnabled(), m_buttons, m_name, m_supervisor, and m_toolTip.

                                                                                                                                   {
   TGCheckButton* checkButton = new TGCheckButton(p, m_name.c_str(), id, norm, font);
   if (m_toolTip != "") checkButton->SetToolTipText(m_toolTip.c_str(), m_supervisor->getToolTipDelay());
   p->AddFrame(checkButton, l);

   if (state)   checkButton->SetState(kButtonDown, false);
   TQObject::Connect(checkButton, "Clicked()", "CSGAction", this, "activate()");
   m_buttons.push_back(checkButton);
   if(!isEnabled()) {
      checkButton->SetEnabled(kFALSE);
   }
}
FWCustomIconsButton * CSGAction::createCustomIconsButton ( TGCompositeFrame *  p,
const TGPicture *  upPic,
const TGPicture *  downPic,
const TGPicture *  disabledPic,
TGLayoutHints *  l = 0,
Int_t  id = -1,
GContext_t  norm = TGButton::GetDefaultGC() (),
UInt_t  option = 0 
)

Definition at line 152 of file CSGAction.cc.

References CSGActionSupervisor::getToolTipDelay(), isEnabled(), m_buttons, m_supervisor, and m_toolTip.

Referenced by CmsShowMainFrame::CmsShowMainFrame().

{
   FWCustomIconsButton* picButton = new FWCustomIconsButton(p, upPic, downPic, disabledPic, 0, id, norm, option);
   if (m_toolTip != "") picButton->SetToolTipText(m_toolTip.c_str(), m_supervisor->getToolTipDelay());
   p->AddFrame(picButton, l);
   TQObject::Connect(picButton, "Clicked()", "CSGAction", this, "activate()");
   m_buttons.push_back(picButton);
   if(!isEnabled()) {
      picButton->SetEnabled(kFALSE);
   }
   return picButton;
}
void CSGAction::createMenuEntry ( TGPopupMenu *  menu)

Definition at line 203 of file CSGAction.cc.

References addSCToMenu(), isEnabled(), m_connector, m_entry, m_keycode, m_menu, and m_name.

Referenced by CmsShowMainFrame::CmsShowMainFrame(), and CmsShowMainFrame::createNewViewerAction().

                                                 {
   m_menu = menu;
   if (!(menu->HasConnection("Activated(Int_t)"))) TQObject::Connect(menu, "Activated(Int_t)", "CSGConnector", m_connector, "handleMenu(Int_t)");
   menu->AddEntry(m_name.c_str(), m_entry);
   if (m_keycode != 0) addSCToMenu();
   if(!isEnabled()) {
      m_menu->DisableEntry(m_entry);
   }
}
void CSGAction::createPictureButton ( TGCompositeFrame *  p,
const TGPicture *  pic,
TGLayoutHints *  l = 0,
Int_t  id = -1,
GContext_t  norm = TGButton::GetDefaultGC() (),
UInt_t  option = kRaisedFrame|kDoubleBorder 
)

Definition at line 140 of file CSGAction.cc.

References CSGActionSupervisor::getToolTipDelay(), isEnabled(), m_buttons, m_supervisor, and m_toolTip.

                                                                                                                                         {
   TGPictureButton* picButton = new TGPictureButton(p, pic, id, norm, option);
   if (m_toolTip != "") picButton->SetToolTipText(m_toolTip.c_str(), m_supervisor->getToolTipDelay());
   p->AddFrame(picButton, l);
   TQObject::Connect(picButton, "Clicked()", "CSGAction", this, "activate()");
   m_buttons.push_back(picButton);
   if(!isEnabled()) {
      picButton->SetEnabled(kFALSE);
   }
}
void CSGAction::createShortcut ( UInt_t  key,
const char *  mod,
int  windowID 
)

Definition at line 172 of file CSGAction.cc.

References addSCToMenu(), keycodeToString(), m_keycode, m_menu, m_modcode, m_scCombo, and m_windowID.

Referenced by CmsShowMainFrame::CmsShowMainFrame().

                                                                        {
   Int_t keycode = gVirtualX->KeysymToKeycode((int)key);
   m_windowID = windowID;
   Int_t modcode;
   TString scText;
   if (strcmp(mod, "CTRL") == 0) {
      modcode = kKeyControlMask;
      scText = "<ctrl> ";
   }
   else if (strcmp(mod, "CTRL+SHIFT") == 0) {
      modcode = kKeyControlMask | kKeyShiftMask;
      scText = "<ctrl> <shift> ";
   }
   else {
      // Default to ALT for now
      modcode = kKeyMod1Mask;
      scText = "<alt> ";
   }
   scText += keycodeToString(keycode);
   m_scCombo = scText;

   gVirtualX->GrabKey(m_windowID, keycode, modcode, kTRUE);
   gVirtualX->GrabKey(m_windowID, keycode, modcode | kKeyMod2Mask, kTRUE);
   gVirtualX->GrabKey(m_windowID, keycode, modcode | kKeyLockMask, kTRUE);
   gVirtualX->GrabKey(m_windowID, keycode, modcode | kKeyMod2Mask | kKeyLockMask, kTRUE);

   m_keycode = keycode;
   m_modcode = modcode;
   if (m_menu != 0) addSCToMenu();
}
void CSGAction::createTextButton ( TGCompositeFrame *  p,
TGLayoutHints *  l = 0,
Int_t  id = -1,
GContext_t  norm = TGButton::GetDefaultGC() (),
FontStruct_t  font = TGTextButton::GetDefaultFontStruct(),
UInt_t  option = kRaisedFrame|kDoubleBorder 
)

Definition at line 116 of file CSGAction.cc.

References CSGActionSupervisor::getToolTipDelay(), isEnabled(), m_buttons, m_name, m_supervisor, and m_toolTip.

Referenced by FWConvTrackHitsDetailView::build(), and FWTrackHitsDetailView::build().

                                                                                                                                   {
   TGTextButton* textButton = new TGTextButton(p, m_name.c_str(), id, norm, font, option);
   if (m_toolTip != "") textButton->SetToolTipText(m_toolTip.c_str(), m_supervisor->getToolTipDelay());
   p->AddFrame(textButton, l);
   TQObject::Connect(textButton, "Clicked()", "CSGAction", this, "activate()");
   m_buttons.push_back(textButton);
   if(!isEnabled()) {
      textButton->SetEnabled(kFALSE);
   }
}
void CSGAction::disable ( )
void CSGAction::disableImp ( ) [private]

Definition at line 321 of file CSGAction.cc.

References isEnabled(), m_buttons, m_entry, m_keycode, m_menu, m_modcode, m_toolBar, and m_windowID.

Referenced by disable(), and globalDisable().

                           {
   if(!isEnabled()) {
      if (m_menu != 0) m_menu->DisableEntry(m_entry);
      for(std::vector<TGButton*>::iterator it = m_buttons.begin(), itEnd = m_buttons.end();
          it != itEnd;
          ++it) {
         (*it)->SetEnabled(kFALSE);
      }
      if (m_toolBar != 0) m_toolBar->GetButton(m_entry)->SetEnabled(kFALSE);
      if (m_keycode != 0) {
         gVirtualX->GrabKey(m_windowID, m_keycode, m_modcode, kFALSE);
         gVirtualX->GrabKey(m_windowID, m_keycode, m_modcode | kKeyMod2Mask, kFALSE);
         gVirtualX->GrabKey(m_windowID, m_keycode, m_modcode | kKeyLockMask, kFALSE);
         gVirtualX->GrabKey(m_windowID, m_keycode, m_modcode | kKeyMod2Mask | kKeyLockMask, kFALSE);
      }
   }
}
void CSGAction::enable ( )
void CSGAction::enableImp ( ) [private]

Definition at line 302 of file CSGAction.cc.

References isEnabled(), m_buttons, m_entry, m_keycode, m_menu, m_modcode, m_toolBar, and m_windowID.

Referenced by enable(), and globalEnable().

                          {
   if(isEnabled()) {
      if (m_menu != 0) m_menu->EnableEntry(m_entry);
      for(std::vector<TGButton*>::iterator it = m_buttons.begin(), itEnd = m_buttons.end();
          it != itEnd;
          ++it) {
         (*it)->SetEnabled(kTRUE);
      }

      if (m_toolBar != 0) m_toolBar->GetButton(m_entry)->SetEnabled(kTRUE);
      if (m_keycode != 0) {
         gVirtualX->GrabKey(m_windowID, m_keycode, m_modcode, kTRUE);
         gVirtualX->GrabKey(m_windowID, m_keycode, m_modcode | kKeyMod2Mask, kTRUE);
         gVirtualX->GrabKey(m_windowID, m_keycode, m_modcode | kKeyLockMask, kTRUE);
         gVirtualX->GrabKey(m_windowID, m_keycode, m_modcode | kKeyMod2Mask | kKeyLockMask, kTRUE);
      }
   }
}
Int_t CSGAction::getKeycode ( ) const

Definition at line 258 of file CSGAction.cc.

References m_keycode.

                                  {
   return m_keycode;
}
TGPopupMenu * CSGAction::getMenu ( ) const

Definition at line 250 of file CSGAction.cc.

References m_menu.

Referenced by CSGContinuousAction::stop(), and CSGContinuousAction::switchMode().

                                      {
   return m_menu;
}
int CSGAction::getMenuEntry ( ) const

Definition at line 254 of file CSGAction.cc.

References m_entry.

Referenced by CSGContinuousAction::stop(), and CSGContinuousAction::switchMode().

                                  {
   return m_entry;
}
Int_t CSGAction::getModcode ( ) const

Definition at line 262 of file CSGAction.cc.

References m_modcode.

                                  {
   return m_modcode;
}
const std::string & CSGAction::getName ( void  ) const

Definition at line 82 of file CSGAction.cc.

References m_name.

                                          {
   return m_name;
}
TString CSGAction::getSCCombo ( ) const

Definition at line 90 of file CSGAction.cc.

References m_scCombo.

                                    {
   return m_scCombo;
}
TGToolBar * CSGAction::getToolBar ( ) const

Definition at line 270 of file CSGAction.cc.

References m_toolBar.

Referenced by CSGContinuousAction::stop(), and CSGContinuousAction::switchMode().

                                       {
   return m_toolBar;
}
ToolBarData_t * CSGAction::getToolBarData ( ) const

Definition at line 266 of file CSGAction.cc.

References m_tools.

Referenced by CSGContinuousAction::stop(), and CSGContinuousAction::switchMode().

                                               {
   return m_tools;
}
const std::string & CSGAction::getToolTip ( ) const

Definition at line 86 of file CSGAction.cc.

References m_toolTip.

                                             {
   return m_toolTip;
}
void CSGAction::globalDisable ( ) [virtual]

Reimplemented in CSGContinuousAction.

Definition at line 292 of file CSGAction.cc.

References disableImp(), and m_globalEnabled.

void CSGAction::globalEnable ( ) [virtual]

Reimplemented in CSGContinuousAction.

Definition at line 285 of file CSGAction.cc.

References enableImp(), and m_globalEnabled.

Bool_t CSGAction::isEnabled ( ) const [virtual]
TString CSGAction::keycodeToString ( Int_t  keycode) [static]

Definition at line 345 of file CSGAction.cc.

References i.

Referenced by createShortcut().

                                        {
   int i;
   char letter;
   TString rep;
   for (i = kKey_a; i < kKey_a + 26; i++) {
      if (gVirtualX->KeysymToKeycode(i) == keycode) {
         letter = (char)(i - kKey_a + 'a');
         rep = TString(letter);
         return rep;
      }
   }
   for (i = kKey_A; i < kKey_A + 26; i++) {
      if(gVirtualX->KeysymToKeycode(i) == keycode) {
         letter = (char)(i - kKey_A + 'a');
         rep = TString(letter);
         return rep;
      }
   }
   if (keycode == gVirtualX->KeysymToKeycode(kKey_Left)) {
      rep = TString("<-");
      return rep;
   }
   if (keycode == gVirtualX->KeysymToKeycode(kKey_Right)) {
      rep = TString("->");
      return rep;
   }
   rep = TString("");
   return rep;
}
const CSGAction& CSGAction::operator= ( const CSGAction ) [private]
Bool_t CSGAction::resizeMenuEntry ( )

Definition at line 218 of file CSGAction.cc.

References cond::rpcobimon::current, m_entry, m_menu, m_name, m_scCombo, and tablePrinter::width.

Referenced by addSCToMenu().

                                  {
   FontStruct_t font = gClient->GetResourcePool()->GetMenuHiliteFont()->GetFontStruct();
   Bool_t widthChanged = kTRUE;
   UInt_t width = m_menu->GetWidth();
   TString realName(m_name);
   if (realName.Contains("->")) {
      // Should make function to do this and store in member data...
      while (!(realName.BeginsWith("->")) && realName.Length() > 0) {
         realName.Replace(0,1,0,0);
      }
      realName.Replace(0,2,0,0);
   }
   TString scText = m_scCombo;
   while (gVirtualX->TextWidth(font, realName.Data(), realName.Length()) + gVirtualX->TextWidth(font, scText.Data(), scText.Length()) + 53 < (Int_t)width) {
      widthChanged = kFALSE;
      realName += " ";
   }
   realName += "\t";
   realName += scText;
   TIter next(m_menu->GetListOfEntries());
   TGMenuEntry *current;
   while (0 != (current = (TGMenuEntry *)next())) {
      if (current == m_menu->GetEntry(m_entry)) {
         break;
      }
   }
   current = (TGMenuEntry *)next();
   m_menu->DeleteEntry(m_entry);
   m_menu->AddEntry(realName, m_entry, 0, 0, current);
   return widthChanged;
}
void CSGAction::setMenuLabel ( const std::string &  label)

Definition at line 100 of file CSGAction.cc.

References m_entry, and m_menu.

                                              {
   if(m_menu) {
      m_menu->GetEntry(m_entry)->GetLabel()->SetString(label.c_str());
   }
}
void CSGAction::setName ( const std::string &  name)

Definition at line 94 of file CSGAction.cc.

References m_name, and mergeVDriftHistosByStation::name.

                                             {
   // Does not update menu yet
   m_name = name;
}
void CSGAction::setToolTip ( const std::string &  tip)

Definition at line 106 of file CSGAction.cc.

References CSGActionSupervisor::getToolTipDelay(), m_buttons, m_supervisor, m_tools, and m_toolTip.

Referenced by FWConvTrackHitsDetailView::build(), FWTrackHitsDetailView::build(), and CmsShowMainFrame::CmsShowMainFrame().

                                               {
   m_toolTip = tip;
   for(std::vector<TGButton*>::iterator it = m_buttons.begin(), itEnd = m_buttons.end();
       it != itEnd;
       ++it) {
      (*it)->SetToolTipText(tip.c_str(), m_supervisor->getToolTipDelay());
   }
   if (m_tools != 0) m_tools->fTipText = tip.c_str();
}

Member Data Documentation

sigc::signal<void> CSGAction::activated
std::vector<TGButton*> CSGAction::m_buttons [private]

Definition at line 110 of file CSGAction.h.

Referenced by createMenuEntry(), CSGAction(), and ~CSGAction().

Bool_t CSGAction::m_enabled [private]

Definition at line 111 of file CSGAction.h.

Referenced by CSGAction(), disable(), enable(), and isEnabled().

int CSGAction::m_entry [private]
Bool_t CSGAction::m_globalEnabled [private]

Definition at line 112 of file CSGAction.h.

Referenced by CSGAction(), globalDisable(), globalEnable(), and isEnabled().

Int_t CSGAction::m_keycode [private]
TGPopupMenu* CSGAction::m_menu [private]
Int_t CSGAction::m_modcode [private]

Definition at line 105 of file CSGAction.h.

Referenced by createShortcut(), CSGAction(), disableImp(), enableImp(), and getModcode().

std::string CSGAction::m_name [private]
TString CSGAction::m_scCombo [private]

Definition at line 102 of file CSGAction.h.

Referenced by createShortcut(), getSCCombo(), and resizeMenuEntry().

TGToolBar* CSGAction::m_toolBar [private]

Definition at line 108 of file CSGAction.h.

Referenced by CSGAction(), disableImp(), enableImp(), and getToolBar().

ToolBarData_t* CSGAction::m_tools [private]

Definition at line 109 of file CSGAction.h.

Referenced by CSGAction(), getToolBarData(), and setToolTip().

std::string CSGAction::m_toolTip [private]
int CSGAction::m_windowID [private]

Definition at line 113 of file CSGAction.h.

Referenced by createShortcut(), CSGAction(), disableImp(), and enableImp().