X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5cab4a770cee73214cdbea645712652b29db6802..f06832c1b6caae13c0bddf8f3a8aeb1114f4392b:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 17a0f07790..485aa1e2b1 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -32,6 +32,7 @@ #include "wx/dcbuffer.h" #include "wx/arrimpl.cpp" #include "wx/fontenum.h" +#include "wx/accel.h" // DLL options compatibility check: #include "wx/app.h" @@ -215,8 +216,6 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va attributes.SetLineSpacing(10); attributes.SetParagraphSpacingAfter(10); attributes.SetParagraphSpacingBefore(0); - attributes.SetTextEffects(0); - attributes.SetTextEffectFlags(wxTEXT_ATTR_EFFECT_STRIKETHROUGH|wxTEXT_ATTR_EFFECT_CAPITALS); SetBasicStyle(attributes); @@ -255,6 +254,17 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va GetBuffer().AddEventHandler(this); + // Accelerators + wxAcceleratorEntry entries[4]; + + entries[0].Set(wxACCEL_CMD, (int) 'C', wxID_COPY); + entries[1].Set(wxACCEL_CMD, (int) 'X', wxID_CUT); + entries[2].Set(wxACCEL_CMD, (int) 'V', wxID_PASTE); + entries[3].Set(wxACCEL_CMD, (int) 'A', wxID_SELECTALL); + + wxAcceleratorTable accel(4, entries); + SetAcceleratorTable(accel); + return true; } @@ -446,6 +456,7 @@ void wxRichTextCtrl::OnLeftClick(wxMouseEvent& event) long oldCaretPos = m_caretPosition; MoveCaret(position, caretAtLineStart); + SetDefaultStyleToCursorStyle(); if (event.ShiftDown()) { @@ -584,6 +595,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) ExtendSelection(m_caretPosition, position, wxRICHTEXT_SHIFT_DOWN); MoveCaret(position, caretAtLineStart); + SetDefaultStyleToCursorStyle(); } } } @@ -674,7 +686,6 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) if (event.GetKeyCode() == WXK_RETURN) { - SetDefaultStyleToCursorStyle(); BeginBatchUndo(_("Insert Text")); long newPos = m_caretPosition; @@ -686,11 +697,14 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) wxString text; text = wxRichTextLineBreakChar; GetBuffer().InsertTextWithUndo(newPos+1, text, this); + m_caretAtLineStart = true; + PositionCaret(); } else GetBuffer().InsertNewlineWithUndo(newPos+1, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE|wxRICHTEXT_INSERT_INTERACTIVE); EndBatchUndo(); + SetDefaultStyleToCursorStyle(); ScrollIntoView(m_caretPosition, WXK_RIGHT); @@ -744,6 +758,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) m_caretPosition = -1; PositionCaret(); + SetDefaultStyleToCursorStyle(); } ScrollIntoView(m_caretPosition, WXK_LEFT); @@ -778,6 +793,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) m_caretPosition = -1; PositionCaret(); + SetDefaultStyleToCursorStyle(); } wxRichTextEvent cmdEvent( @@ -939,7 +955,6 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) } } - SetDefaultStyleToCursorStyle(); BeginBatchUndo(_("Insert Text")); long newPos = m_caretPosition; @@ -954,6 +969,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event) EndBatchUndo(); + SetDefaultStyleToCursorStyle(); ScrollIntoView(m_caretPosition, WXK_RIGHT); GetEventHandler()->ProcessEvent(cmdEvent); @@ -1070,6 +1086,7 @@ bool wxRichTextCtrl::KeyboardNavigate(int keyCode, int flags) if (success) { ScrollIntoView(m_caretPosition, keyCode); + SetDefaultStyleToCursorStyle(); } return success; @@ -1291,11 +1308,13 @@ void wxRichTextCtrl::MoveCaretForward(long oldPosition) m_caretPosition = oldPosition; m_caretAtLineStart = true; } + SetDefaultStyleToCursorStyle(); return; } } } m_caretPosition ++; + SetDefaultStyleToCursorStyle(); } /// Move caret one visual step backward: this may mean setting a flag @@ -1339,11 +1358,13 @@ void wxRichTextCtrl::MoveCaretBack(long oldPosition) // to the previous character position. m_caretPosition = oldPosition - 1; } + SetDefaultStyleToCursorStyle(); return; } } } m_caretPosition --; + SetDefaultStyleToCursorStyle(); } /// Move right @@ -1371,6 +1392,7 @@ bool wxRichTextCtrl::MoveRight(int noPositions, int flags) SetCaretPosition(newPos); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1397,6 +1419,7 @@ bool wxRichTextCtrl::MoveLeft(int noPositions, int flags) SetCaretPosition(newPos); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1485,6 +1508,7 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags) SetCaretPosition(newPos, caretLineStart); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1505,6 +1529,7 @@ bool wxRichTextCtrl::MoveToParagraphEnd(int flags) SetCaretPosition(newPos); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1525,6 +1550,7 @@ bool wxRichTextCtrl::MoveToParagraphStart(int flags) SetCaretPosition(newPos); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1547,6 +1573,7 @@ bool wxRichTextCtrl::MoveToLineEnd(int flags) SetCaretPosition(newPos); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1571,6 +1598,7 @@ bool wxRichTextCtrl::MoveToLineStart(int flags) SetCaretPosition(newPos, para->GetRange().GetStart() != lineRange.GetStart()); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1589,6 +1617,7 @@ bool wxRichTextCtrl::MoveHome(int flags) SetCaretPosition(-1); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1609,6 +1638,7 @@ bool wxRichTextCtrl::MoveEnd(int flags) SetCaretPosition(endPos); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1647,6 +1677,7 @@ bool wxRichTextCtrl::PageDown(int noPages, int flags) SetCaretPosition(pos, para->GetRange().GetStart() != lineRange.GetStart()); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1763,6 +1794,7 @@ bool wxRichTextCtrl::WordLeft(int WXUNUSED(n), int flags) SetCaretPosition(pos, para->GetRange().GetStart() != pos); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1784,6 +1816,7 @@ bool wxRichTextCtrl::WordRight(int WXUNUSED(n), int flags) SetCaretPosition(pos, para->GetRange().GetStart() != pos); PositionCaret(); + SetDefaultStyleToCursorStyle(); return true; } @@ -1957,7 +1990,7 @@ bool wxRichTextCtrl::RecreateBuffer(const wxSize& size) bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType) { - bool success = GetBuffer().LoadFile(filename, fileType); + bool success = GetBuffer().LoadFile(filename, (wxRichTextFileType)fileType); if (success) m_filename = filename; @@ -1981,7 +2014,7 @@ bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType) bool wxRichTextCtrl::DoSaveFile(const wxString& filename, int fileType) { - if (GetBuffer().SaveFile(filename, fileType)) + if (GetBuffer().SaveFile(filename, (wxRichTextFileType)fileType)) { m_filename = filename; @@ -2092,6 +2125,7 @@ bool wxRichTextCtrl::SelectWord(long position) if (positionStart >= 0) { MoveCaret(positionStart-1, true); + SetDefaultStyleToCursorStyle(); } return true; @@ -2209,7 +2243,6 @@ void wxRichTextCtrl::DoWriteText(const wxString& value, int flags) { wxString valueUnix = wxTextFile::Translate(value, wxTextFileType_Unix); - SetDefaultStyleToCursorStyle(); GetBuffer().InsertTextWithUndo(m_caretPosition+1, valueUnix, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE); if ( flags & SetValue_SendEvent ) @@ -2224,7 +2257,7 @@ void wxRichTextCtrl::AppendText(const wxString& text) } /// Write an image at the current insertion point -bool wxRichTextCtrl::WriteImage(const wxImage& image, int bitmapType) +bool wxRichTextCtrl::WriteImage(const wxImage& image, wxBitmapType bitmapType) { wxRichTextImageBlock imageBlock; @@ -2235,7 +2268,7 @@ bool wxRichTextCtrl::WriteImage(const wxImage& image, int bitmapType) return false; } -bool wxRichTextCtrl::WriteImage(const wxString& filename, int bitmapType) +bool wxRichTextCtrl::WriteImage(const wxString& filename, wxBitmapType bitmapType) { wxRichTextImageBlock imageBlock; @@ -2251,7 +2284,7 @@ bool wxRichTextCtrl::WriteImage(const wxRichTextImageBlock& imageBlock) return GetBuffer().InsertImageWithUndo(m_caretPosition+1, imageBlock, this); } -bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, int bitmapType) +bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType) { if (bitmap.Ok()) { @@ -2268,7 +2301,7 @@ bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, int bitmapType) /// Insert a newline (actually paragraph) at the current insertion point. bool wxRichTextCtrl::Newline() { - return GetBuffer().InsertNewlineWithUndo(m_caretPosition+1, this); + return GetBuffer().InsertNewlineWithUndo(m_caretPosition+1, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE); } /// Insert a line break at the current insertion point. @@ -2309,7 +2342,6 @@ void wxRichTextCtrl::Paste() { if (CanPaste()) { - SetDefaultStyleToCursorStyle(); BeginBatchUndo(_("Paste")); long newPos = m_caretPosition;