CMS 3D CMS Logo

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

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

Inheritance diagram for FWGUIValidatingTextEntry:

Public Member Functions

 ClassDef (FWGUIValidatingTextEntry, 0)
 
 FWGUIValidatingTextEntry (const TGWindow *parent=0, const char *text=0, Int_t id=-1)
 
void hideOptions ()
 
void keyPressedInPopup (TGFrame *, UInt_t keysym, UInt_t mask)
 
virtual Bool_t ProcessMessage (Long_t msg, Long_t parm1, Long_t parm2)
 
void setValidator (FWValidatorBase *)
 
void showOptions ()
 
virtual ~FWGUIValidatingTextEntry ()
 

Private Member Functions

 FWGUIValidatingTextEntry (const FWGUIValidatingTextEntry &)
 
void insertTextOption (const std::string &)
 
const FWGUIValidatingTextEntryoperator= (const FWGUIValidatingTextEntry &)
 

Private Attributes

TGListBox * m_list
 
std::vector< std::pair
< boost::shared_ptr
< std::string >, std::string > > 
m_options
 
TGComboBoxPopup * m_popup
 
FWValidatorBasem_validator
 

Detailed Description

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

Usage: <usage>

Definition at line 36 of file FWGUIValidatingTextEntry.h.

Constructor & Destructor Documentation

FWGUIValidatingTextEntry::FWGUIValidatingTextEntry ( const TGWindow *  parent = 0,
const char *  text = 0,
Int_t  id = -1 
)

Definition at line 37 of file FWGUIValidatingTextEntry.cc.

References m_list, and m_popup.

37  :
38  TGTextEntry(parent,text,id),
39  m_validator(0)
40 {
41  m_popup = new TGComboBoxPopup(fClient->GetDefaultRoot(), 100, 100, kVerticalFrame);
42  m_list = new TGListBox(m_popup, 1 /*widget id*/, kChildFrame);
43  m_list->Resize(100,100);
44  m_list->Associate(this);
45  m_list->GetScrollBar()->GrabPointer(kFALSE);
46  m_popup->AddFrame(m_list, new TGLayoutHints(kLHintsExpandX| kLHintsExpandY));
47  m_popup->MapSubwindows();
48  m_popup->Resize(m_popup->GetDefaultSize());
49  m_list->GetContainer()->AddInput(kButtonPressMask | kButtonReleaseMask | kPointerMotionMask);
50  m_list->SetEditDisabled(kEditDisable);
51  m_list->GetContainer()->Connect("KeyPressed(TGFrame*,UInt_t,UInt_t)",
52  "FWGUIValidatingTextEntry", this,
53  "keyPressedInPopup(TGFrame*,UInt_t,UInt_t)");
54  m_list->GetContainer()->SetEditDisabled(kEditDisable);
55  Connect("TabPressed()", "FWGUIValidatingTextEntry", this, "showOptions()");
56 
57 }
list parent
Definition: dbtoconf.py:74
tuple text
Definition: runonSM.py:42
FWGUIValidatingTextEntry::~FWGUIValidatingTextEntry ( )
virtual

Definition at line 64 of file FWGUIValidatingTextEntry.cc.

65 {
66 }
FWGUIValidatingTextEntry::FWGUIValidatingTextEntry ( const FWGUIValidatingTextEntry )
private

Member Function Documentation

FWGUIValidatingTextEntry::ClassDef ( FWGUIValidatingTextEntry  ,
 
)
void FWGUIValidatingTextEntry::hideOptions ( )

Definition at line 202 of file FWGUIValidatingTextEntry.cc.

References m_popup.

Referenced by keyPressedInPopup(), and ProcessMessage().

202  {
203  m_popup->EndPopup();
204  fClient->NeedRedraw(this);
205 }
void FWGUIValidatingTextEntry::insertTextOption ( const std::string &  iOption)
private

Definition at line 208 of file FWGUIValidatingTextEntry.cc.

References pos.

Referenced by keyPressedInPopup(), ProcessMessage(), and showOptions().

209 {
210  long pos = GetCursorPosition();
211  InsertText(iOption.c_str(), pos);
212  SetCursorPosition(pos + iOption.size());
213 
214 }
void FWGUIValidatingTextEntry::keyPressedInPopup ( TGFrame *  ,
UInt_t  keysym,
UInt_t  mask 
)

Definition at line 113 of file FWGUIValidatingTextEntry.cc.

References hideOptions(), insertTextOption(), m_list, and m_options.

114 {
115  switch(keysym) {
116  case kKey_Tab:
117  case kKey_Escape:
118  RequestFocus();
119  hideOptions();
120  break;
121  case kKey_Return:
122  RequestFocus();
123  //NOTE: If chosen from the keyboard, m_list->GetSelected() does not work, however
124  // m_list->GetSelectedEntries does work
125  TList selected;
126  m_list->GetSelectedEntries(&selected);
127  assert(selected.GetEntries() == 1);
128  const TGLBEntry* entry = dynamic_cast<TGLBEntry*> (selected.First());
129  assert(0!=entry);
130  insertTextOption(m_options[entry->EntryId()].second);
131  hideOptions();
132  break;
133  }
134 }
std::vector< std::pair< boost::shared_ptr< std::string >, std::string > > m_options
void insertTextOption(const std::string &)
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
const FWGUIValidatingTextEntry& FWGUIValidatingTextEntry::operator= ( const FWGUIValidatingTextEntry )
private
Bool_t FWGUIValidatingTextEntry::ProcessMessage ( Long_t  msg,
Long_t  parm1,
Long_t  parm2 
)
virtual

Definition at line 91 of file FWGUIValidatingTextEntry.cc.

References hideOptions(), insertTextOption(), m_list, and m_options.

92 {
93  //STOLEN FROM TGComboBox.cxx
94  switch (GET_MSG(msg)) {
95  case kC_COMMAND:
96  switch (GET_SUBMSG(msg)) {
97  case kCM_LISTBOX:
98  RequestFocus();
99  insertTextOption(m_options[m_list->GetSelected()].second);
100  hideOptions();
101  break;
102  }
103  break;
104 
105  default:
106  break;
107  }
108  return kTRUE;
109 
110 }
std::vector< std::pair< boost::shared_ptr< std::string >, std::string > > m_options
void insertTextOption(const std::string &)
void FWGUIValidatingTextEntry::setValidator ( FWValidatorBase iValidator)

Definition at line 84 of file FWGUIValidatingTextEntry.cc.

References m_validator.

Referenced by CmsShowEDI::CmsShowEDI(), FWGUIEventSelector::FWGUIEventSelector(), and FWTableView::FWTableView().

85 {
86  m_validator = iValidator;
87 }
void FWGUIValidatingTextEntry::showOptions ( )

Definition at line 155 of file FWGUIValidatingTextEntry.cc.

References FWValidatorBase::fillOptions(), h, getHLTprescales::index, insertTextOption(), m_list, m_options, m_popup, m_validator, and runonSM::text.

155  {
156 
157  if(0!=m_validator) {
158  const char* text = GetText();
159  std::string subText(text,text+GetCursorPosition());
160  //std::cout <<subText<<std::endl;
161 
162  typedef std::vector<std::pair<boost::shared_ptr<std::string>, std::string> > Options;
163  m_validator->fillOptions(text, text+GetCursorPosition(), m_options);
164  if(m_options.empty()) { return;}
165  if(m_options.size()==1) {
166  insertTextOption(m_options.front().second);
167  return;
168  }
169  m_list->RemoveAll();
170  int index = 0;
171  for(Options::iterator it = m_options.begin(), itEnd = m_options.end();
172  it != itEnd; ++it,++index) {
173  m_list->AddEntry(it->first->c_str(),index);
174  }
175  {
176  unsigned int h = m_list->GetNumberOfEntries()*
177  m_list->GetItemVsize();
178  if(h && (h<100)) {
179  m_list->Resize(m_list->GetWidth(),h);
180  } else {
181  m_list->Resize(m_list->GetWidth(),100);
182  }
183  }
184  m_list->Select(0,kTRUE);
185 
186  int ax,ay;
187  Window_t wdummy;
188  gVirtualX->TranslateCoordinates(GetId(), m_popup->GetParent()->GetId(),
189  0, GetHeight(), ax, ay, wdummy);
190 
191  //Wait to change focus for when the popup has already openned
192  std::auto_ptr<TTimer> timer( new ChangeFocusTimer(m_list->GetContainer()) );
193  timer->TurnOn();
194  //NOTE: this call has its own internal GUI event loop and will not return
195  // until the popup has been shut down
196  m_popup->PlacePopup(ax, ay,
197  GetWidth()-2, m_popup->GetDefaultHeight());
198  }
199 }
std::vector< std::pair< boost::shared_ptr< std::string >, std::string > > m_options
virtual void fillOptions(const char *iBegin, const char *iEnd, std::vector< std::pair< boost::shared_ptr< std::string >, std::string > > &oOptions) const =0
void insertTextOption(const std::string &)
tuple text
Definition: runonSM.py:42
std::vector< boost::shared_ptr< fireworks::OptionNode > > Options
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

Member Data Documentation

TGListBox* FWGUIValidatingTextEntry::m_list
private
std::vector<std::pair<boost::shared_ptr<std::string>, std::string> > FWGUIValidatingTextEntry::m_options
private

Definition at line 69 of file FWGUIValidatingTextEntry.h.

Referenced by keyPressedInPopup(), ProcessMessage(), and showOptions().

TGComboBoxPopup* FWGUIValidatingTextEntry::m_popup
private

Definition at line 64 of file FWGUIValidatingTextEntry.h.

Referenced by FWGUIValidatingTextEntry(), hideOptions(), and showOptions().

FWValidatorBase* FWGUIValidatingTextEntry::m_validator
private

Definition at line 67 of file FWGUIValidatingTextEntry.h.

Referenced by setValidator(), and showOptions().