12 EnableTextInput(kTRUE);
13 GetTextEntry()->Connect(
"ProcessedEvent(Event_t*)",
"QGDropDownBox",
this,
14 "QGHandleEvent(Event_t*)");
23 TGComboBox::AddEntry(entry.c_str(), GetNumberOfEntries());
29 fTextEntry->Connect(
"TabPressed()",
"QGDropDownBox",
this,
"TabComplete()");
34 vector<string> matches;
35 vector<string>::const_iterator iter;
37 if ((*iter).find(s) == 0) matches.push_back(*iter);
44 string commonText = v[0];
45 string::size_type
N = commonText.size();
46 for (
unsigned int i =
N; i != 0; --i) {
48 commonText = commonText.substr(0, i);
49 vector<string>::const_iterator iter;
50 for (iter = v.begin(); iter != v.end(); ++iter) {
51 if (iter->find(commonText) != 0) common =
false;
67 if (event->fType == kFocusOut) {
68 GetTextEntry()->Deselect();
76 GetTextEntry()->Disconnect(
"ReturnPressed()");
77 GetTextEntry()->Connect(
"ReturnPressed()",
"QGDropDownBox",
this,
78 "HandleReturnPressed()");
83 returnTarget->SetShiftTabTarget( GetTextEntry() );
89 if (fTextEntry->GetBuffer()->GetTextLength() > 0) {
90 string currentText = fTextEntry->GetText();
93 string separators =
" ()*/+-&|=!";
94 string::size_type pos = currentText.find_last_of(separators);
95 if (pos != string::npos && pos != currentText.size() - 1) {
96 currentText = currentText.substr(pos+1);
100 if (matches.size() > 0) {
102 fTextEntry->AppendText(commonText.substr(currentText.size()).c_str());
Drop down box with tab-complete.
void QGHandleEvent(Event_t *event)
Handle event.
TGTextEntry * fReturnTarget
Text box to change to when return is pressed.
void SetReturnTarget(TGTextEntry *textBox)
Set return target.
QGDropDownBox(const TGWindow *p=0)
Constructor.
std::vector< std::string > FindMatches(const std::string &s)
Find a match to a string.
virtual ~QGDropDownBox()
Destructor.
void AddEntryS(const std::string &entry)
Add entry.
std::vector< std::string > fEntries
Collection of entries.
void TabComplete()
Tab complete.
std::string GetCommonText(const std::vector< std::string > &v)
Get common text.
void EnableTabCompletion()
Enable tab completion.
void HandleReturnPressed()
Handle tab pressed.
Extension of ROOT's basic text box TGTextEntry.