#pragma hdrstop
#endif
+#if wxUSE_RICHTEXT
+
+#include "wx/richtext/richtextctrl.h"
+
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
-#include "wx/image.h"
-
-#if wxUSE_RICHTEXT
-
#include "wx/textfile.h"
#include "wx/ffile.h"
#include "wx/settings.h"
#include "wx/filename.h"
#include "wx/dcbuffer.h"
-
-#include "wx/richtext/richtextctrl.h"
#include "wx/arrimpl.cpp"
DEFINE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED)
}
/// Call Thaw to refresh
-void wxRichTextCtrl::Thaw(bool refresh)
+void wxRichTextCtrl::Thaw()
{
m_freezeCount --;
- if (m_freezeCount == 0 && refresh)
+ if (m_freezeCount == 0)
{
SetupScrollbars();
- Refresh();
+ Refresh(false);
}
}
if (m_freezeCount == 0)
{
SetupScrollbars();
- Refresh();
+ Refresh(false);
}
SendUpdateEvent();
}
{
wxBufferedPaintDC dc(this, m_bufferBitmap);
//wxLogDebug(wxT("OnPaint"));
-
+
PrepareDC(dc);
-
+
if (m_freezeCount > 0)
return;
-
+
dc.SetFont(GetFont());
-
+
// Paint the background
PaintBackground(dc);
-
+
wxRegion dirtyRegion = GetUpdateRegion();
-
+
wxRect drawingArea(GetLogicalPoint(wxPoint(0, 0)), GetClientSize());
wxRect availableSpace(GetClientSize());
if (GetBuffer().GetDirty())
GetBuffer().SetDirty(false);
SetupScrollbars();
}
-
+
GetBuffer().Draw(dc, GetBuffer().GetRange(), GetSelectionRange(), drawingArea, 0 /* descent */, 0 /* flags */);
}
PositionCaret();
if (!IsFrozen())
- Refresh();
+ Refresh(false);
}
void wxRichTextCtrl::OnKillFocus(wxFocusEvent& WXUNUSED(event))
SetCaret(NULL);
if (!IsFrozen())
- Refresh();
+ Refresh(false);
}
/// Left-click
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
}
}
}
event.GetKeyCode() == WXK_NEXT ||
event.GetKeyCode() == WXK_END)
{
- Navigate(event.GetKeyCode(), flags);
+ KeyboardNavigate(event.GetKeyCode(), flags);
}
else if (event.GetKeyCode() == WXK_RETURN)
{
*/
-bool wxRichTextCtrl::Navigate(int keyCode, int flags)
+bool wxRichTextCtrl::KeyboardNavigate(int keyCode, int flags)
{
bool success = false;
- Freeze();
if (keyCode == WXK_RIGHT)
{
SetDefaultStyleToCursorStyle();
}
- Thaw(false);
-
return success;
}
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
else
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
else
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
- else
- return false;
+
+ return false;
}
/// Move to the end of the paragraph
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
else
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
else
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
}
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
SetDefaultStyleToCursorStyle();
if (extendSel)
- Refresh();
+ Refresh(false);
return true;
}
m_fullLayoutTime = 0;
GetBuffer().Invalidate(wxRICHTEXT_ALL);
ShowPosition(m_fullLayoutSavedPosition);
- Refresh();
+ Refresh(false);
}
event.Skip();
}
LayoutContent();
PositionCaret();
SetupScrollbars(true);
- Refresh();
+ Refresh(false);
SendUpdateEvent();
if (success)
((wxRichTextCtrl*)this)->PrepareDC(dc);
int hit = ((wxRichTextCtrl*)this)->GetBuffer().HitTest(dc, pt, *pos);
- if (hit == wxRICHTEXT_HITTEST_BEFORE)
- return wxTE_HT_BEFORE;
- else if (hit == wxRICHTEXT_HITTEST_AFTER)
- return wxTE_HT_BEYOND;
- else if (hit == wxRICHTEXT_HITTEST_ON)
- return wxTE_HT_ON_TEXT;
- else
- return wxTE_HT_UNKNOWN;
+
+ switch ( hit )
+ {
+ case wxRICHTEXT_HITTEST_BEFORE:
+ return wxTE_HT_BEFORE;
+
+ case wxRICHTEXT_HITTEST_AFTER:
+ return wxTE_HT_BEYOND;
+
+ case wxRICHTEXT_HITTEST_ON:
+ return wxTE_HT_ON_TEXT;
+ }
+
+ return wxTE_HT_UNKNOWN;
}
// ----------------------------------------------------------------------------
wxImage image2 = image;
if (imageBlock.MakeImageBlock(image2, bitmapType))
return WriteImage(imageBlock);
- else
- return false;
+
+ return false;
}
bool wxRichTextCtrl::WriteImage(const wxString& filename, int bitmapType)
wxImage image;
if (imageBlock.MakeImageBlock(filename, bitmapType, image, false))
return WriteImage(imageBlock);
- else
- return false;
+
+ return false;
}
bool wxRichTextCtrl::WriteImage(const wxRichTextImageBlock& imageBlock)
wxImage image = bitmap.ConvertToImage();
if (image.Ok() && imageBlock.MakeImageBlock(image, bitmapType))
return WriteImage(imageBlock);
- else
- return false;
}
+
return false;
}
DeleteSelectedContent();
LayoutContent();
- Refresh();
+ Refresh(false);
}
}
{
m_selectionAnchor = from;
m_selectionRange.SetRange(from, to);
- Refresh();
+ Refresh(false);
PositionCaret();
}
LayoutContent();
if (!IsFrozen())
- Refresh();
+ Refresh(false);
}
bool wxRichTextCtrl::IsModified() const
rect = wxRect(pt, wxSize(wxRICHTEXT_DEFAULT_CARET_WIDTH, height));
return true;
}
- else
- return false;
+
+ return false;
}
/// Gets the line for the visible caret position. If the caret is
flags |= wxRICHTEXT_LAYOUT_SPECIFIED_RECT;
availableSpace.SetPosition(GetLogicalPoint(wxPoint(0, 0)));
}
-
+
wxClientDC dc(this);
dc.SetFont(GetFont());
-
+
PrepareDC(dc);
-
+
GetBuffer().Defragment();
GetBuffer().UpdateRanges(); // If items were deleted, ranges need recalculation
GetBuffer().Layout(dc, availableSpace, flags);
GetBuffer().SetDirty(false);
-
+
if (!IsFrozen())
SetupScrollbars();
}
SetDefaultStyle(attr);
return true;
}
- else
- return false;
+
+ return false;
}
/// Returns the first visible position in the current view