- Add limited support for CSS styles for <a> tags too in wxHTML (gevorg).
- Add "inherit" to <font> XRC tag (Steffen Olszewski, Gero Meßsysteme GmbH).
- Add support for wxALWAYS_SHOW_SB style to wxScrolled<> (Catalin Raceanu).
+- Add wxTreeCtrl::EnableBellOnNoMatch() (Jonathan Dagresta).
wxGTK:
const wxValidator &validator = wxDefaultValidator,
const wxString& name = wxTreeCtrlNameStr);
-
// implement base class pure virtuals
// ----------------------------------
virtual void EndEditLabel(const wxTreeItemId& item,
bool discardChanges = false);
+ virtual void EnableBellOnNoMatch(bool on = true);
+
virtual void SortChildren(const wxTreeItemId& item);
// items geometry
// incremental search data
wxString m_findPrefix;
wxTimer *m_findTimer;
+ // This flag is set to 0 if the bell is disabled, 1 if it is enabled and -1
+ // if it is globally enabled but has been temporarily disabled because we
+ // had already beeped for this particular search.
+ int m_findBell;
bool m_dropEffectAboveItem;
virtual wxSize DoGetBestSize() const;
private:
+ // Reset the state of the last find (i.e. keyboard incremental search)
+ // operation.
+ void ResetFindState();
+
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxGenericTreeCtrl)
wxDECLARE_NO_COPY_CLASS(wxGenericTreeCtrl);
virtual void EndEditLabel(const wxTreeItemId& item,
bool discardChanges = false) = 0;
+ // Enable or disable beep when incremental match doesn't find any item.
+ // Only implemented in the generic version currently.
+ virtual void EnableBellOnNoMatch(bool WXUNUSED(on) = true) { }
+
// sorting
// -------
virtual wxTextCtrl *EditLabel(const wxTreeItemId& item,
wxClassInfo* textCtrlClass = wxCLASSINFO(wxTextCtrl));
+ /**
+ Enable or disable a beep if there is no match for the currently
+ entered text when searching for the item from keyboard.
+
+ The default is to not beep in this case except in wxMSW where the
+ beep is always generated by the native control and cannot be disabled,
+ i.e. calls to this function do nothing there.
+
+ @since 2.9.5
+ */
+ void EnableBellOnNoMatch(bool on = true);
+
/**
Ends label editing. If @a cancelEdit is @true, the edit will be
cancelled.
MENU_LINK(Recreate)
MENU_LINK(ToggleImages)
MENU_LINK(ToggleStates)
+ MENU_LINK(ToggleBell)
MENU_LINK(ToggleAlternateImages)
MENU_LINK(ToggleAlternateStates)
MENU_LINK(ToggleButtons)
#endif // NO_MULTIPLE_SELECTION
style_menu->AppendCheckItem(TreeTest_ToggleImages, wxT("Toggle show ima&ges"));
style_menu->AppendCheckItem(TreeTest_ToggleStates, wxT("Toggle show st&ates"));
+ style_menu->AppendCheckItem(TreeTest_ToggleBell, wxT("Toggle &bell on no match"));
style_menu->AppendCheckItem(TreeTest_ToggleAlternateImages, wxT("Toggle alternate images"));
style_menu->AppendCheckItem(TreeTest_ToggleAlternateStates, wxT("Toggle alternate state images"));
style_menu->Append(TreeTest_SetImageSize, wxT("Set image si&ze..."));
}
}
+void MyFrame::OnToggleBell(wxCommandEvent& event)
+{
+ m_treeCtrl->EnableBellOnNoMatch(event.IsChecked());
+}
+
void MyFrame::OnToggleAlternateImages(wxCommandEvent& WXUNUSED(event))
{
bool alternateImages = m_treeCtrl->AlternateImages();
void OnToggleButtons(wxCommandEvent& event);
void OnToggleImages(wxCommandEvent& event);
void OnToggleStates(wxCommandEvent& event);
+ void OnToggleBell(wxCommandEvent& event);
void OnToggleAlternateImages(wxCommandEvent& event);
void OnToggleAlternateStates(wxCommandEvent& event);
void OnSetImageSize(wxCommandEvent& event);
TreeTest_Recreate,
TreeTest_ToggleImages,
TreeTest_ToggleStates,
+ TreeTest_ToggleBell,
TreeTest_ToggleAlternateImages,
TreeTest_ToggleAlternateStates,
TreeTest_ToggleButtons,
wxTreeFindTimer( wxGenericTreeCtrl *owner ) { m_owner = owner; }
- virtual void Notify() { m_owner->m_findPrefix.clear(); }
+ virtual void Notify() { m_owner->ResetFindState(); }
private:
wxGenericTreeCtrl *m_owner;
m_renameTimer = NULL;
m_findTimer = NULL;
+ m_findBell = 0; // default is to not ring bell at all
m_dropEffectAboveItem = false;
delete m_imageListButtons;
}
+void wxGenericTreeCtrl::EnableBellOnNoMatch( bool on )
+{
+ m_findBell = on;
+}
+
// -----------------------------------------------------------------------------
// accessors
// -----------------------------------------------------------------------------
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
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