X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/38f833b10c071603eb8d7739ab31b1c07c4576f1..8acd14d1779dd5610b0fa16b0863adc7df5d9a82:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 3ff5366e30..58057e12a1 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -31,6 +31,7 @@ #include "wx/filename.h" #include "wx/dcbuffer.h" #include "wx/arrimpl.cpp" +#include "wx/fontenum.h" // DLL options compatibility check: #include "wx/app.h" @@ -91,6 +92,8 @@ END_EVENT_TABLE() * wxRichTextCtrl */ +wxArrayString wxRichTextCtrl::sm_availableFontNames; + wxRichTextCtrl::wxRichTextCtrl() : wxScrollHelper(this) { @@ -123,6 +126,9 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va GetBuffer().SetRichTextCtrl(this); + if (style & wxTE_READONLY) + SetEditable(false); + wxTextAttrEx attributes; attributes.SetFont(GetFont()); attributes.SetTextColour(*wxBLACK); @@ -639,6 +645,27 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) return; } + if (keycode == wxT('\t')) + { + // See if we need to promote or demote the selection or paragraph at the cursor + // position, instead of inserting a tab. + long pos = GetAdjustedCaretPosition(GetCaretPosition()); + wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(pos); + if (para && para->GetRange().GetStart() == pos && para->GetAttributes().HasListStyleName()) + { + wxRichTextRange range; + if (HasSelection()) + range = GetSelectionRange(); + else + range = para->GetRange().FromInternal(); + + int promoteBy = event.ShiftDown() ? 1 : -1; + + PromoteList(promoteBy, range, NULL); + return; + } + } + BeginBatchUndo(_("Insert Text")); long newPos = m_caretPosition; @@ -2749,20 +2776,20 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def) if (def->IsKindOf(CLASSINFO(wxRichTextListStyleDefinition))) { flags |= wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY; - + wxRichTextRange range; - + if (HasSelection()) range = GetSelectionRange(); else { - long pos = GetAdjustedCaretPosition(GetCaretPosition()); + long pos = GetAdjustedCaretPosition(GetCaretPosition()); range = wxRichTextRange(pos, pos+1); } - - return SetListStyle(range, (wxRichTextListStyleDefinition*) def, flags); - } - + + return SetListStyle(range, (wxRichTextListStyleDefinition*) def, flags); + } + // Make sure the attr has the style name if (def->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition))) { @@ -2889,12 +2916,12 @@ bool wxRichTextCtrl::ClearListStyle(const wxRichTextRange& range, int flags) /// Number/renumber any list elements in the given range bool wxRichTextCtrl::NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags, int startFrom, int specifiedLevel) { - return GetBuffer().NumberList(range.ToInternal(), def, flags, startFrom, specifiedLevel); + return GetBuffer().NumberList(range.ToInternal(), def, flags, startFrom, specifiedLevel); } bool wxRichTextCtrl::NumberList(const wxRichTextRange& range, const wxString& defName, int flags, int startFrom, int specifiedLevel) { - return GetBuffer().NumberList(range.ToInternal(), defName, flags, startFrom, specifiedLevel); + return GetBuffer().NumberList(range.ToInternal(), defName, flags, startFrom, specifiedLevel); } /// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1 @@ -2908,6 +2935,20 @@ bool wxRichTextCtrl::PromoteList(int promoteBy, const wxRichTextRange& range, co return GetBuffer().PromoteList(promoteBy, range.ToInternal(), defName, flags, specifiedLevel); } +const wxArrayString& wxRichTextCtrl::GetAvailableFontNames() +{ + if (sm_availableFontNames.GetCount() == 0) + { + sm_availableFontNames = wxFontEnumerator::GetFacenames(); + sm_availableFontNames.Sort(); + } + return sm_availableFontNames; +} + +void wxRichTextCtrl::ClearAvailableFontNames() +{ + sm_availableFontNames.Clear(); +} + #endif // wxUSE_RICHTEXT -