X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7b1279006496ba3251a755bcef91301ad107bb78..a85585d595c8409fa5e51a28e60fa49428440d5e:/samples/widgets/textctrl.cpp?ds=sidebyside diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp index 29dcea6c95..e744691027 100644 --- a/samples/widgets/textctrl.cpp +++ b/samples/widgets/textctrl.cpp @@ -29,6 +29,7 @@ #include "wx/log.h" #include "wx/timer.h" + #include "wx/bitmap.h" #include "wx/button.h" #include "wx/checkbox.h" #include "wx/radiobox.h" @@ -41,7 +42,6 @@ #include "widgets.h" -#if 1 #include "icons/text.xpm" // ---------------------------------------------------------------------------- @@ -200,6 +200,8 @@ protected: m_selFrom, m_selTo; + wxString m_range10_20; + private: // any class wishing to process wxWindows events must use this macro DECLARE_EVENT_TABLE() @@ -543,7 +545,7 @@ void TextWidgetsPage::CreateText() { valueOld = m_text->GetValue(); - m_sizerText->Remove(m_text); + m_sizerText->Detach( m_text ); delete m_text; } else @@ -555,8 +557,10 @@ void TextWidgetsPage::CreateText() valueOld, wxDefaultPosition, wxDefaultSize, flags); + + // cast to int needed to silence gcc warning about different enums m_sizerText->Add(m_text, 1, wxALL | - (flags & wxTE_MULTILINE ? wxGROW + (flags & wxTE_MULTILINE ? (int)wxGROW : wxALIGN_TOP), 5); m_sizerText->Layout(); } @@ -604,7 +608,7 @@ void TextWidgetsPage::OnIdle(wxIdleEvent& WXUNUSED(event)) if ( m_textLineLast ) { m_textLineLast->SetValue( - wxString::Format(_T("%ld"), m_text->GetNumberOfLines())); + wxString::Format(_T("%d"), m_text->GetNumberOfLines()) ); } if ( m_textSelFrom && m_textSelTo ) @@ -630,7 +634,12 @@ void TextWidgetsPage::OnIdle(wxIdleEvent& WXUNUSED(event)) if ( m_textRange ) { - m_textRange->SetValue(m_text->GetRange(10, 20)); + wxString range = m_text->GetRange(10, 20); + if ( range != m_range10_20 ) + { + m_range10_20 = range; + m_textRange->SetValue(range); + } } } @@ -699,8 +708,9 @@ void TextWidgetsPage::OnButtonLoad(wxCommandEvent& WXUNUSED(event)) else { long elapsed = sw.Time(); - wxLogMessage(_T("Loaded file '%s' in %u.%us"), - filename.c_str(), elapsed / 1000, elapsed % 1000); + wxLogMessage(_T("Loaded file '%s' in %lu.%us"), + filename.c_str(), elapsed / 1000, + (unsigned int) elapsed % 1000); } } } @@ -732,7 +742,7 @@ void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) (m_chkWrapLines->GetValue() != DEFAULTS.wraplines) ); } -void TextWidgetsPage::OnText(wxCommandEvent& event) +void TextWidgetsPage::OnText(wxCommandEvent& WXUNUSED(event)) { // small hack to suppress the very first message: by then the logging is // not yet redirected and so initial setting of the text value results in @@ -752,8 +762,8 @@ void TextWidgetsPage::OnTextEnter(wxCommandEvent& event) wxLogMessage(_T("Text entered: '%s'"), event.GetString().c_str()); } -void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateText(); } -#endif +