CMS 3D CMS Logo

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

 ClassDefOverride (FWGUIValidatingTextEntry, 0)
 
 FWGUIValidatingTextEntry (const TGWindow *parent=nullptr, const char *text=nullptr, Int_t id=-1)
 
TGListBox * getListBox () const
 
void hideOptions ()
 
void keyPressedInPopup (TGFrame *, UInt_t keysym, UInt_t mask)
 
Bool_t ProcessMessage (Long_t msg, Long_t parm1, Long_t parm2) override
 
void setMaxListBoxHeight (UInt_t x)
 
void setValidator (FWValidatorBase *)
 
void showOptions ()
 
 ~FWGUIValidatingTextEntry () override
 

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< std::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 35 of file FWGUIValidatingTextEntry.h.

Constructor & Destructor Documentation

◆ FWGUIValidatingTextEntry() [1/2]

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

Definition at line 36 of file FWGUIValidatingTextEntry.cc.

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

References hcaldqm::fClient, m_list, m_listHeight, and m_popup.

◆ ~FWGUIValidatingTextEntry()

FWGUIValidatingTextEntry::~FWGUIValidatingTextEntry ( )
override

Definition at line 61 of file FWGUIValidatingTextEntry.cc.

61 {}

◆ FWGUIValidatingTextEntry() [2/2]

FWGUIValidatingTextEntry::FWGUIValidatingTextEntry ( const FWGUIValidatingTextEntry )
private

Member Function Documentation

◆ ClassDefOverride()

FWGUIValidatingTextEntry::ClassDefOverride ( FWGUIValidatingTextEntry  ,
 
)

◆ getListBox()

TGListBox* FWGUIValidatingTextEntry::getListBox ( ) const
inline

Definition at line 50 of file FWGUIValidatingTextEntry.h.

50 { return m_list; }

References m_list.

Referenced by FWGeometryTableView::FWGeometryTableView().

◆ hideOptions()

void FWGUIValidatingTextEntry::hideOptions ( )

Definition at line 182 of file FWGUIValidatingTextEntry.cc.

182  {
183  m_popup->EndPopup();
184  fClient->NeedRedraw(this);
185 }

References hcaldqm::fClient, and m_popup.

Referenced by keyPressedInPopup(), and ProcessMessage().

◆ insertTextOption()

void FWGUIValidatingTextEntry::insertTextOption ( const std::string &  iOption)
private

Definition at line 187 of file FWGUIValidatingTextEntry.cc.

187  {
188  long pos = GetCursorPosition();
189  InsertText(iOption.c_str(), pos);
190  SetCursorPosition(pos + iOption.size());
191 }

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

◆ keyPressedInPopup()

void FWGUIValidatingTextEntry::keyPressedInPopup ( TGFrame *  f,
UInt_t  keysym,
UInt_t  mask 
)

Definition at line 99 of file FWGUIValidatingTextEntry.cc.

99  {
100  switch (keysym) {
101  case kKey_Tab:
102  case kKey_Escape:
103  RequestFocus();
104  hideOptions();
105  break;
106  case kKey_Return:
107  RequestFocus();
108  //NOTE: If chosen from the keyboard, m_list->GetSelected() does not work, however
109  // m_list->GetSelectedEntries does work
110 
111  //AMT NOTE: TGListEntry does not select entry on key return event, it has to be selected here.
112  // Code stolen from TGComboBox::KeyPressed
113 
114  const TGLBEntry* entry = dynamic_cast<TGLBEntry*>(f);
115  if (entry) {
116  insertTextOption(m_options[entry->EntryId()].second);
117  m_list->Selected(entry->EntryId());
118  }
119  hideOptions();
120  break;
121  }
122 }

References mps_splice::entry, f, hideOptions(), insertTextOption(), m_list, and m_options.

◆ operator=()

const FWGUIValidatingTextEntry& FWGUIValidatingTextEntry::operator= ( const FWGUIValidatingTextEntry )
private

◆ ProcessMessage()

Bool_t FWGUIValidatingTextEntry::ProcessMessage ( Long_t  msg,
Long_t  parm1,
Long_t  parm2 
)
override

Definition at line 80 of file FWGUIValidatingTextEntry.cc.

80  {
81  //STOLEN FROM TGComboBox.cxx
82  switch (GET_MSG(msg)) {
83  case kC_COMMAND:
84  switch (GET_SUBMSG(msg)) {
85  case kCM_LISTBOX:
86  RequestFocus();
87  insertTextOption(m_options[m_list->GetSelected()].second);
88  hideOptions();
89  break;
90  }
91  break;
92 
93  default:
94  break;
95  }
96  return kTRUE;
97 }

References hideOptions(), insertTextOption(), m_list, m_options, and mps_check::msg.

◆ setMaxListBoxHeight()

void FWGUIValidatingTextEntry::setMaxListBoxHeight ( UInt_t  x)
inline

Definition at line 51 of file FWGUIValidatingTextEntry.h.

51 { m_listHeight = x; }

References m_listHeight, and x.

Referenced by FWGeometryTableView::FWGeometryTableView().

◆ setValidator()

void FWGUIValidatingTextEntry::setValidator ( FWValidatorBase iValidator)

◆ showOptions()

void FWGUIValidatingTextEntry::showOptions ( )

Definition at line 139 of file FWGUIValidatingTextEntry.cc.

139  {
140  if (nullptr != m_validator) {
141  const char* text = GetText();
142  std::string subText(text, text + GetCursorPosition());
143  //std::cout <<subText<<std::endl;
144 
145  typedef std::vector<std::pair<std::shared_ptr<std::string>, std::string> > Options;
146  m_validator->fillOptions(text, text + GetCursorPosition(), m_options);
147  if (m_options.empty()) {
148  return;
149  }
150  if (m_options.size() == 1) {
151  insertTextOption(m_options.front().second);
152  return;
153  }
154  m_list->RemoveAll();
155  int index = 0;
156  for (Options::iterator it = m_options.begin(), itEnd = m_options.end(); it != itEnd; ++it, ++index) {
157  m_list->AddEntry(it->first->c_str(), index);
158  }
159  {
160  unsigned int h = m_list->GetNumberOfEntries() * m_list->GetItemVsize();
161  if (h && (h < m_listHeight)) {
162  m_list->Resize(m_list->GetWidth(), h);
163  } else {
164  m_list->Resize(m_list->GetWidth(), m_listHeight);
165  }
166  }
167  m_list->Select(0, kTRUE);
168 
169  int ax, ay;
170  Window_t wdummy;
171  gVirtualX->TranslateCoordinates(GetId(), m_popup->GetParent()->GetId(), 0, GetHeight(), ax, ay, wdummy);
172 
173  //Wait to change focus for when the popup has already openned
174  std::unique_ptr<TTimer> timer(new ChangeFocusTimer(m_list->GetContainer()));
175  timer->TurnOn();
176  //NOTE: this call has its own internal GUI event loop and will not return
177  // until the popup has been shut down
178  m_popup->PlacePopup(ax, ay, GetWidth() - 2, m_popup->GetDefaultHeight());
179  }
180 }

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

Member Data Documentation

◆ m_list

TGListBox* FWGUIValidatingTextEntry::m_list
private

◆ m_listHeight

UInt_t FWGUIValidatingTextEntry::m_listHeight
private

◆ m_options

std::vector<std::pair<std::shared_ptr<std::string>, std::string> > FWGUIValidatingTextEntry::m_options
private

Definition at line 72 of file FWGUIValidatingTextEntry.h.

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

◆ m_popup

TGComboBoxPopup* FWGUIValidatingTextEntry::m_popup
private

Definition at line 66 of file FWGUIValidatingTextEntry.h.

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

◆ m_validator

FWValidatorBase* FWGUIValidatingTextEntry::m_validator
private

Definition at line 68 of file FWGUIValidatingTextEntry.h.

Referenced by setValidator(), and showOptions().

FWGUIValidatingTextEntry::m_popup
TGComboBoxPopup * m_popup
Definition: FWGUIValidatingTextEntry.h:66
FWGUIValidatingTextEntry::m_validator
FWValidatorBase * m_validator
Definition: FWGUIValidatingTextEntry.h:68
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
Options
std::vector< std::shared_ptr< fireworks::OptionNode > > Options
Definition: FWExpressionValidator.cc:28
mps_splice.entry
entry
Definition: mps_splice.py:68
pos
Definition: PixelAliasList.h:18
FWGUIValidatingTextEntry::m_list
TGListBox * m_list
Definition: FWGUIValidatingTextEntry.h:67
mps_check.msg
tuple msg
Definition: mps_check.py:285
DDAxes::x
h
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
FWGUIValidatingTextEntry::m_options
std::vector< std::pair< std::shared_ptr< std::string >, std::string > > m_options
Definition: FWGUIValidatingTextEntry.h:72
FWValidatorBase::fillOptions
virtual void fillOptions(const char *iBegin, const char *iEnd, std::vector< std::pair< std::shared_ptr< std::string >, std::string > > &oOptions) const =0
h
hcaldqm::fClient
Definition: DQModule.h:24
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWGUIValidatingTextEntry::m_listHeight
UInt_t m_listHeight
Definition: FWGUIValidatingTextEntry.h:70
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
runonSM.text
text
Definition: runonSM.py:43
class-composition.parent
parent
Definition: class-composition.py:98
FWGUIValidatingTextEntry::hideOptions
void hideOptions()
Definition: FWGUIValidatingTextEntry.cc:182
FWGUIValidatingTextEntry::insertTextOption
void insertTextOption(const std::string &)
Definition: FWGUIValidatingTextEntry.cc:187