added wxTextEntry::SetHint() (a.k.a. cue banner or placeholder string)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59263 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-03-02 12:25:01 +00:00
parent 231728361c
commit 63f7d5022e
21 changed files with 311 additions and 18 deletions

View File

@@ -97,6 +97,8 @@ enum
TextEntry_DisableAutoComplete = TextEntry_Begin,
TextEntry_AutoCompleteFixed,
TextEntry_AutoCompleteFilenames,
TextEntry_SetHint,
TextEntry_End
};
@@ -164,10 +166,13 @@ protected:
void OnToggleGlobalBusyCursor(wxCommandEvent& event);
void OnToggleBusyCursor(wxCommandEvent& event);
// wxTextEntry-specific tests
void OnDisableAutoComplete(wxCommandEvent& event);
void OnAutoCompleteFixed(wxCommandEvent& event);
void OnAutoCompleteFilenames(wxCommandEvent& event);
void OnSetHint(wxCommandEvent& event);
void OnUpdateTextUI(wxUpdateUIEvent& event)
{
event.Enable( CurrentPage()->GetTextEntry() != NULL );
@@ -308,6 +313,8 @@ BEGIN_EVENT_TABLE(WidgetsFrame, wxFrame)
EVT_MENU(TextEntry_AutoCompleteFixed, WidgetsFrame::OnAutoCompleteFixed)
EVT_MENU(TextEntry_AutoCompleteFilenames, WidgetsFrame::OnAutoCompleteFilenames)
EVT_MENU(TextEntry_SetHint, WidgetsFrame::OnSetHint)
EVT_UPDATE_UI_RANGE(TextEntry_Begin, TextEntry_End - 1,
WidgetsFrame::OnUpdateTextUI)
@@ -419,6 +426,8 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
_T("Fixed-&list auto-completion"));
menuTextEntry->AppendRadioItem(TextEntry_AutoCompleteFilenames,
_T("&Files names auto-completion"));
menuTextEntry->AppendSeparator();
menuTextEntry->Append(TextEntry_SetHint, "Set help &hint");
mbar->Append(menuTextEntry, _T("&Text"));
@@ -948,6 +957,25 @@ void WidgetsFrame::OnAutoCompleteFilenames(wxCommandEvent& WXUNUSED(event))
wxLogMessage("AutoCompleteFileNames() failed.");
}
void WidgetsFrame::OnSetHint(wxCommandEvent& WXUNUSED(event))
{
wxTextEntryBase *entry = CurrentPage()->GetTextEntry();
wxCHECK_RET( entry, "menu item should be disabled" );
static wxString s_hint("Type here");
wxString
hint = wxGetTextFromUser("Text hint:", "Widgets sample", s_hint, this);
if ( hint.empty() )
return;
s_hint = hint;
if ( entry->SetHint(hint) )
wxLogMessage("Set hint to \"%s\".", hint);
else
wxLogMessage("Text hints not supported.");
}
#endif // wxUSE_MENUS
// ----------------------------------------------------------------------------