Add a possibility to beep on no match to wxGenericTreeCtrl.

For consistency with Windows, allow to optionally generate a beep when
incremental search in the tree control doesn't find anything.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72638 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-10-07 22:42:02 +00:00
parent e0dec8753a
commit 27bc919446
7 changed files with 68 additions and 2 deletions

View File

@@ -127,7 +127,7 @@ public:
wxTreeFindTimer( wxGenericTreeCtrl *owner ) { m_owner = owner; }
virtual void Notify() { m_owner->m_findPrefix.clear(); }
virtual void Notify() { m_owner->ResetFindState(); }
private:
wxGenericTreeCtrl *m_owner;
@@ -956,6 +956,7 @@ void wxGenericTreeCtrl::Init()
m_renameTimer = NULL;
m_findTimer = NULL;
m_findBell = 0; // default is to not ring bell at all
m_dropEffectAboveItem = false;
@@ -1045,6 +1046,11 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl()
delete m_imageListButtons;
}
void wxGenericTreeCtrl::EnableBellOnNoMatch( bool on )
{
m_findBell = on;
}
// -----------------------------------------------------------------------------
// accessors
// -----------------------------------------------------------------------------
@@ -1557,6 +1563,13 @@ void wxGenericTreeCtrl::ResetTextControl()
m_textCtrl = NULL;
}
void wxGenericTreeCtrl::ResetFindState()
{
m_findPrefix.clear();
if ( m_findBell )
m_findBell = 1;
}
// find the first item starting with the given prefix after the given item
wxTreeItemId wxGenericTreeCtrl::FindItem(const wxTreeItemId& idParent,
const wxString& prefixOrig) const
@@ -3347,6 +3360,24 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
if ( id.IsOk() )
{
SelectItem(id);
// Reset the bell flag if it had been temporarily disabled
// before.
if ( m_findBell )
m_findBell = 1;
}
else // No such item
{
// Signal it with a bell if enabled.
if ( m_findBell == 1 )
{
::wxBell();
// Disable it for the next unsuccessful match, we only
// beep once, this is usually enough and continuing to
// do it would be annoying.
m_findBell = -1;
}
}
}
else