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)
 
TGListBox * getListBox () const
 
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 setMaxListBoxHeight (UInt_t x)
 
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
 
UInt_t m_listHeight
 
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, m_listHeight, and m_popup.

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

Definition at line 67 of file FWGUIValidatingTextEntry.cc.

68 {
69 }
FWGUIValidatingTextEntry::FWGUIValidatingTextEntry ( const FWGUIValidatingTextEntry )
private

Member Function Documentation

FWGUIValidatingTextEntry::ClassDef ( FWGUIValidatingTextEntry  ,
 
)
TGListBox* FWGUIValidatingTextEntry::getListBox ( ) const
inline

Definition at line 52 of file FWGUIValidatingTextEntry.h.

References m_list.

Referenced by FWGeometryTableView::FWGeometryTableView().

52 { return m_list; }
void FWGUIValidatingTextEntry::hideOptions ( )

Definition at line 209 of file FWGUIValidatingTextEntry.cc.

References m_popup.

Referenced by keyPressedInPopup(), and ProcessMessage().

209  {
210  m_popup->EndPopup();
211  fClient->NeedRedraw(this);
212 }
void FWGUIValidatingTextEntry::insertTextOption ( const std::string &  iOption)
private

Definition at line 215 of file FWGUIValidatingTextEntry.cc.

References pos.

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

216 {
217  long pos = GetCursorPosition();
218  InsertText(iOption.c_str(), pos);
219  SetCursorPosition(pos + iOption.size());
220 }
void FWGUIValidatingTextEntry::keyPressedInPopup ( TGFrame *  f,
UInt_t  keysym,
UInt_t  mask 
)

Definition at line 116 of file FWGUIValidatingTextEntry.cc.

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

117 {
118  switch(keysym) {
119  case kKey_Tab:
120  case kKey_Escape:
121  RequestFocus();
122  hideOptions();
123  break;
124  case kKey_Return:
125  RequestFocus();
126  //NOTE: If chosen from the keyboard, m_list->GetSelected() does not work, however
127  // m_list->GetSelectedEntries does work
128 
129  //AMT NOTE: TGListEntry does not select entry on key return event, it has to be selected here.
130  // Code stolen from TGComboBox::KeyPressed
131 
132  const TGLBEntry* entry = dynamic_cast<TGLBEntry*> (f);
133  if (entry)
134  {
135  insertTextOption(m_options[entry->EntryId()].second);
136  m_list->Selected(entry->EntryId());
137  }
138  hideOptions();
139  break;
140  }
141 }
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
double f[11][100]
const FWGUIValidatingTextEntry& FWGUIValidatingTextEntry::operator= ( const FWGUIValidatingTextEntry )
private
Bool_t FWGUIValidatingTextEntry::ProcessMessage ( Long_t  msg,
Long_t  parm1,
Long_t  parm2 
)
virtual

Definition at line 94 of file FWGUIValidatingTextEntry.cc.

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

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

Definition at line 53 of file FWGUIValidatingTextEntry.h.

References m_listHeight, and x.

Referenced by FWGeometryTableView::FWGeometryTableView().

void FWGUIValidatingTextEntry::setValidator ( FWValidatorBase iValidator)
void FWGUIValidatingTextEntry::showOptions ( )

Definition at line 162 of file FWGUIValidatingTextEntry.cc.

References create_public_lumi_plots::ax, FWValidatorBase::fillOptions(), h, getHLTprescales::index, insertTextOption(), m_list, m_listHeight, m_options, m_popup, m_validator, AlCaHLTBitMon_QueryRunRegistry::string, and runonSM::text.

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

Member Data Documentation

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

Definition at line 74 of file FWGUIValidatingTextEntry.h.

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

TGComboBoxPopup* FWGUIValidatingTextEntry::m_popup
private

Definition at line 68 of file FWGUIValidatingTextEntry.h.

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

FWValidatorBase* FWGUIValidatingTextEntry::m_validator
private

Definition at line 70 of file FWGUIValidatingTextEntry.h.

Referenced by setValidator(), and showOptions().