/// Do selection void wxRichTextStyleListBox::ApplyStyle(int item) { if ( item != wxNOT_FOUND ) { wxRichTextStyleDefinition* def = GetStyle(item); if (def && GetRichTextCtrl()) { GetRichTextCtrl()->ApplyStyle(def); GetRichTextCtrl()->SetFocus(); } } }
void wxRichTextStyleComboCtrl::OnIdle(wxIdleEvent& event) { event.Skip(); if ( !m_stylePopup ) return; wxRichTextCtrl * const richtext = GetRichTextCtrl(); if ( !richtext ) return; if ( !IsPopupShown() && IsShownOnScreen() && wxWindow::FindFocus() != this ) { wxString styleName = wxRichTextStyleListBox::GetStyleToShowInIdleTime(richtext, m_stylePopup->GetStyleType()); wxString currentValue = GetValue(); if (!styleName.IsEmpty()) { // Don't do the selection if it's already set if (currentValue == styleName) return; SetValue(styleName); } else if (!currentValue.IsEmpty()) SetValue(wxEmptyString); } }
/// Auto-select from style under caret in idle time void wxRichTextStyleListBox::OnIdle(wxIdleEvent& event) { if (CanAutoSetSelection() && GetRichTextCtrl() && wxWindow::FindFocus() != this) { wxString styleName = GetStyleToShowInIdleTime(GetRichTextCtrl(), GetStyleType()); int sel = GetSelection(); if (!styleName.IsEmpty()) { // Don't do the selection if it's already set if (sel == GetIndexForStyle(styleName)) return; SetStyleSelection(styleName); } else if (sel != -1) SetSelection(-1); } event.Skip(); }