From 4ee14879f2a8114b714a8d6a52b731157a4a13c7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 1 Aug 1999 22:17:11 +0000 Subject: [PATCH] fix for wxMSW git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3231 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/caret/caret.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/samples/caret/caret.cpp b/samples/caret/caret.cpp index 9142ef3094..2ecaf096a1 100644 --- a/samples/caret/caret.cpp +++ b/samples/caret/caret.cpp @@ -105,7 +105,6 @@ public: void OnChar( wxKeyEvent &event ); private: - wxCaret m_caret; wxFont m_font; // the margin around the text (looks nicer) @@ -276,14 +275,15 @@ MyCanvas::MyCanvas( wxWindow *parent ) m_heightChar = dc.GetCharHeight(); m_widthChar = dc.GetCharWidth(); - m_caret.Create( this, m_widthChar, m_heightChar ); + wxCaret *caret = new wxCaret(this, m_widthChar, m_heightChar); + SetCaret(caret); m_xCaret = m_yCaret = m_xChars = m_yChars = 0; m_xMargin = m_yMargin = 5; - m_caret.Move(m_xMargin, m_yMargin); - m_caret.Show(); + caret->Move(m_xMargin, m_yMargin); + caret->Show(); } MyCanvas::~MyCanvas() @@ -303,10 +303,15 @@ void MyCanvas::OnSize( wxSizeEvent &event ) free(m_text); m_text = (wxChar *)calloc(m_xChars * m_yChars, sizeof(wxChar)); - wxString msg; - msg.Printf(_T("Panel size is (%d, %d)"), m_xChars, m_yChars); + wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); + + if ( frame && frame->GetStatusBar() ) + { + wxString msg; + msg.Printf(_T("Panel size is (%d, %d)"), m_xChars, m_yChars); - ((wxFrame *)GetParent())->SetStatusText(msg, 1); + frame->SetStatusText(msg, 1); + } event.Skip(); } @@ -382,8 +387,8 @@ void MyCanvas::OnChar( wxKeyEvent &event ) wxLogStatus(_T("Caret is at (%d, %d)"), m_xCaret, m_yCaret); - m_caret.Move(m_xMargin + m_xCaret * m_widthChar, - m_yMargin + m_yCaret * m_heightChar); + GetCaret()->Move(m_xMargin + m_xCaret * m_widthChar, + m_yMargin + m_yCaret * m_heightChar); Refresh(); } -- 2.45.2