#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(false);
{
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 */);
}
event.GetKeyCode() == WXK_NEXT ||
event.GetKeyCode() == WXK_END)
{
- Navigate(event.GetKeyCode(), flags);
+ KeyboardNavigate(event.GetKeyCode(), flags);
}
else if (event.GetKeyCode() == WXK_RETURN)
{
EndBatchUndo();
SetDefaultStyleToCursorStyle();
+
+ ScrollIntoView(m_caretPosition, WXK_RIGHT);
}
else if (event.GetKeyCode() == WXK_BACK)
{
SetDefaultStyleToCursorStyle();
}
+ ScrollIntoView(m_caretPosition, WXK_LEFT);
}
else if (event.GetKeyCode() == WXK_DELETE)
{
EndBatchUndo();
SetDefaultStyleToCursorStyle();
+ ScrollIntoView(m_caretPosition, WXK_RIGHT);
}
#if 0
else
*/
-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;
}
Refresh(false);
return true;
}
- else
- return false;
+
+ return false;
}
/// Move to the end of the paragraph
((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;
}
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