#include <Fireworks/Core/interface/FWGUIValidatingTextEntry.h>
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 FWGUIValidatingTextEntry & | operator= (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 |
FWValidatorBase * | m_validator |
Description: <one line="" class="" summary>="">
Usage: <usage>
Definition at line 36 of file FWGUIValidatingTextEntry.h.
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.
: TGTextEntry(parent,text,id), m_popup(0), m_list(0), m_validator(0), m_listHeight(100) { m_popup = new TGComboBoxPopup(fClient->GetDefaultRoot(), 100, 100, kVerticalFrame); m_list = new TGListBox(m_popup, 1 /*widget id*/, kChildFrame); m_list->Resize(100,m_listHeight); m_list->Associate(this); m_list->GetScrollBar()->GrabPointer(kFALSE); m_popup->AddFrame(m_list, new TGLayoutHints(kLHintsExpandX| kLHintsExpandY)); m_popup->MapSubwindows(); m_popup->Resize(m_popup->GetDefaultSize()); m_list->GetContainer()->AddInput(kButtonPressMask | kButtonReleaseMask | kPointerMotionMask); m_list->SetEditDisabled(kEditDisable); m_list->GetContainer()->Connect("KeyPressed(TGFrame*,UInt_t,UInt_t)", "FWGUIValidatingTextEntry", this, "keyPressedInPopup(TGFrame*,UInt_t,UInt_t)"); m_list->GetContainer()->SetEditDisabled(kEditDisable); Connect("TabPressed()", "FWGUIValidatingTextEntry", this, "showOptions()"); }
FWGUIValidatingTextEntry::~FWGUIValidatingTextEntry | ( | ) | [virtual] |
Definition at line 67 of file FWGUIValidatingTextEntry.cc.
{ }
FWGUIValidatingTextEntry::FWGUIValidatingTextEntry | ( | const FWGUIValidatingTextEntry & | ) | [private] |
FWGUIValidatingTextEntry::ClassDef | ( | FWGUIValidatingTextEntry | , |
0 | |||
) |
TGListBox* FWGUIValidatingTextEntry::getListBox | ( | ) | const [inline] |
Definition at line 52 of file FWGUIValidatingTextEntry.h.
References m_list.
Referenced by FWGeometryTableView::filterListCallback(), and FWGeometryTableView::FWGeometryTableView().
{ return m_list; }
void FWGUIValidatingTextEntry::hideOptions | ( | ) |
Definition at line 209 of file FWGUIValidatingTextEntry.cc.
References m_popup.
Referenced by keyPressedInPopup(), and ProcessMessage().
{ m_popup->EndPopup(); fClient->NeedRedraw(this); }
void FWGUIValidatingTextEntry::insertTextOption | ( | const std::string & | iOption | ) | [private] |
Definition at line 215 of file FWGUIValidatingTextEntry.cc.
References pos.
Referenced by keyPressedInPopup(), ProcessMessage(), and showOptions().
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.
{ switch(keysym) { case kKey_Tab: case kKey_Escape: RequestFocus(); hideOptions(); break; case kKey_Return: RequestFocus(); //NOTE: If chosen from the keyboard, m_list->GetSelected() does not work, however // m_list->GetSelectedEntries does work //AMT NOTE: TGListEntry does not select entry on key return event, it has to be selected here. // Code stolen from TGComboBox::KeyPressed const TGLBEntry* entry = dynamic_cast<TGLBEntry*> (f); if (entry) { insertTextOption(m_options[entry->EntryId()].second); m_list->Selected(entry->EntryId()); } hideOptions(); break; } }
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.
{ //STOLEN FROM TGComboBox.cxx switch (GET_MSG(msg)) { case kC_COMMAND: switch (GET_SUBMSG(msg)) { case kCM_LISTBOX: RequestFocus(); insertTextOption(m_options[m_list->GetSelected()].second); hideOptions(); break; } break; default: break; } return kTRUE; }
void FWGUIValidatingTextEntry::setMaxListBoxHeight | ( | UInt_t | x | ) | [inline] |
Definition at line 53 of file FWGUIValidatingTextEntry.h.
References m_listHeight, and x.
Referenced by FWGeometryTableView::FWGeometryTableView().
{ m_listHeight = x; }
void FWGUIValidatingTextEntry::setValidator | ( | FWValidatorBase * | iValidator | ) |
Definition at line 87 of file FWGUIValidatingTextEntry.cc.
References m_validator.
Referenced by CmsShowEDI::CmsShowEDI(), FWGeometryTableView::FWGeometryTableView(), FWGUIEventSelector::FWGUIEventSelector(), and FWTableView::FWTableView().
{ m_validator = iValidator; }
void FWGUIValidatingTextEntry::showOptions | ( | ) |
Definition at line 162 of file FWGUIValidatingTextEntry.cc.
References FWValidatorBase::fillOptions(), h, getHLTprescales::index, insertTextOption(), m_list, m_listHeight, m_options, m_popup, m_validator, and runonSM::text.
{ if(0!=m_validator) { const char* text = GetText(); std::string subText(text,text+GetCursorPosition()); //std::cout <<subText<<std::endl; typedef std::vector<std::pair<boost::shared_ptr<std::string>, std::string> > Options; m_validator->fillOptions(text, text+GetCursorPosition(), m_options); if(m_options.empty()) { return;} if(m_options.size()==1) { insertTextOption(m_options.front().second); return; } m_list->RemoveAll(); int index = 0; for(Options::iterator it = m_options.begin(), itEnd = m_options.end(); it != itEnd; ++it,++index) { m_list->AddEntry(it->first->c_str(),index); } { unsigned int h = m_list->GetNumberOfEntries()* m_list->GetItemVsize(); if(h && (h<m_listHeight)) { m_list->Resize(m_list->GetWidth(),h); } else { m_list->Resize(m_list->GetWidth(),m_listHeight); } } m_list->Select(0,kTRUE); int ax,ay; Window_t wdummy; gVirtualX->TranslateCoordinates(GetId(), m_popup->GetParent()->GetId(), 0, GetHeight(), ax, ay, wdummy); //Wait to change focus for when the popup has already openned std::auto_ptr<TTimer> timer( new ChangeFocusTimer(m_list->GetContainer()) ); timer->TurnOn(); //NOTE: this call has its own internal GUI event loop and will not return // until the popup has been shut down m_popup->PlacePopup(ax, ay, GetWidth()-2, m_popup->GetDefaultHeight()); } }
TGListBox* FWGUIValidatingTextEntry::m_list [private] |
Definition at line 69 of file FWGUIValidatingTextEntry.h.
Referenced by FWGUIValidatingTextEntry(), getListBox(), keyPressedInPopup(), ProcessMessage(), and showOptions().
UInt_t FWGUIValidatingTextEntry::m_listHeight [private] |
Definition at line 72 of file FWGUIValidatingTextEntry.h.
Referenced by FWGUIValidatingTextEntry(), setMaxListBoxHeight(), and showOptions().
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().
Definition at line 70 of file FWGUIValidatingTextEntry.h.
Referenced by setValidator(), and showOptions().