+void MyCanvas::CreateCaret()
+{
+ wxCaret *caret = new wxCaret(this, m_widthChar, m_heightChar);
+ SetCaret(caret);
+
+ caret->Move(m_xMargin, m_yMargin);
+ caret->Show();
+}
+
+void MyCanvas::SetFontSize(int fontSize)
+{
+ m_font = wxFont(fontSize, wxFONTFAMILY_TELETYPE,
+ wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+
+ wxClientDC dc(this);
+ dc.SetFont(m_font);
+ m_heightChar = dc.GetCharHeight();
+ m_widthChar = dc.GetCharWidth();
+
+ wxCaret *caret = GetCaret();
+ if ( caret )
+ {
+ caret->SetSize(m_widthChar, m_heightChar);
+
+ ChangeSize();
+ }
+}
+
+void MyCanvas::MoveCaret(int x, int y)
+{
+ m_xCaret = x;
+ m_yCaret = y;
+
+ DoMoveCaret();
+}
+
+void MyCanvas::DoMoveCaret()
+{
+ wxLogStatus(wxT("Caret is at (%d, %d)"), m_xCaret, m_yCaret);
+
+ GetCaret()->Move(m_xMargin + m_xCaret * m_widthChar,
+ m_yMargin + m_yCaret * m_heightChar);
+}
+
+void MyCanvas::OnSize(wxSizeEvent& event)
+{
+ ChangeSize();
+
+ event.Skip();
+}
+
+void MyCanvas::ChangeSize()