X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1ddb6d28576c3ab21f80d8a3815fcccb1545961c..d5cc191c9cd48a915ce0dfc6e49511b2fddb6746:/samples/scroll/scroll.cpp diff --git a/samples/scroll/scroll.cpp b/samples/scroll/scroll.cpp index 98a9d01dad..d8bc171f06 100644 --- a/samples/scroll/scroll.cpp +++ b/samples/scroll/scroll.cpp @@ -1,11 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// // Name: scroll.cpp -// Purpose: wxScrolledWindow sample +// Purpose: wxScrolled sample // Author: Robert Roebling // RCS-ID: $Id$ // Copyright: (C) 1998 Robert Roebling, 2002 Ron Lee, 2003 Matt Gregory // (C) 2008 Vadim Zeitlin -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -22,12 +22,16 @@ #include "wx/log.h" #include "wx/tglbtn.h" +#ifndef wxHAS_IMAGES_IN_RESOURCES + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // a trivial example // ---------------------------------------------------------------------------- // MySimpleCanvas: a scrolled window which draws a simple rectangle -class MySimpleCanvas : public wxScrolledWindow +class MySimpleCanvas : public wxScrolled { public: enum @@ -40,7 +44,7 @@ public: }; MySimpleCanvas(wxWindow *parent) - : wxScrolledWindow(parent, wxID_ANY) + : wxScrolled(parent, wxID_ANY) { SetScrollRate( 10, 10 ); SetVirtualSize( WIDTH, HEIGHT ); @@ -86,7 +90,7 @@ public: // ---------------------------------------------------------------------- // MyCanvas -class MyCanvas : public wxScrolledWindow +class MyCanvas : public wxScrolled { public: MyCanvas(wxWindow *parent); @@ -145,13 +149,13 @@ private: }; // ---------------------------------------------------------------------------- -// example using sizers with wxScrolledWindow +// example using sizers with wxScrolled // ---------------------------------------------------------------------------- const wxSize SMALL_BUTTON( 100, 50 ); const wxSize LARGE_BUTTON( 300, 200 ); -class MySizerScrolledWindow : public wxScrolledWindow +class MySizerScrolledWindow : public wxScrolled { public: MySizerScrolledWindow(wxWindow *parent); @@ -189,7 +193,7 @@ public: class MySubColLabels : public wxWindow { public: - MySubColLabels(wxScrolledWindow *parent) + MySubColLabels(wxScrolled *parent) : wxWindow(parent, wxID_ANY) { m_owner = parent; @@ -218,13 +222,13 @@ private: dc.DrawText("Column 3", 205, 5); } - wxScrolledWindow *m_owner; + wxScrolled *m_owner; }; class MySubRowLabels : public wxWindow { public: - MySubRowLabels(wxScrolledWindow *parent) + MySubRowLabels(wxScrolled *parent) : wxWindow(parent, wxID_ANY) { m_owner = parent; @@ -256,13 +260,13 @@ private: dc.DrawText("Row 6", 5, 130); } - wxScrolledWindow *m_owner; + wxScrolled *m_owner; }; class MySubCanvas : public wxPanel { public: - MySubCanvas(wxScrolledWindow *parent, wxWindow *cols, wxWindow *rows) + MySubCanvas(wxScrolled *parent, wxWindow *cols, wxWindow *rows) : wxPanel(parent, wxID_ANY) { m_owner = parent; @@ -354,12 +358,12 @@ private: } } - wxScrolledWindow *m_owner; + wxScrolled *m_owner; wxWindow *m_colLabels, *m_rowLabels; }; -class MySubScrolledWindow : public wxScrolledWindow +class MySubScrolledWindow : public wxScrolled { public: enum @@ -369,7 +373,7 @@ public: }; MySubScrolledWindow(wxWindow *parent) - : wxScrolledWindow(parent, wxID_ANY) + : wxScrolled(parent, wxID_ANY) { // create the children MySubColLabels *cols = new MySubColLabels(this); @@ -440,17 +444,17 @@ public: }; // ---------------------------------------------------------------------------- -// more simple examples of wxScrolledWindow usage +// more simple examples of wxScrolled usage // ---------------------------------------------------------------------------- // base class for both of them -class MyScrolledWindowBase : public wxScrolledWindow +class MyScrolledWindowBase : public wxScrolled { public: MyScrolledWindowBase(wxWindow *parent) - : wxScrolledWindow(parent, wxID_ANY, - wxDefaultPosition, wxDefaultSize, - wxBORDER_SUNKEN) + : wxScrolled(parent, wxID_ANY, + wxDefaultPosition, wxDefaultSize, + wxBORDER_SUNKEN) { m_nLines = 50; m_winSync = NULL; @@ -472,7 +476,7 @@ public: virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL) { - wxScrolledWindow::ScrollWindow(dx, dy, rect); + wxScrolled::ScrollWindow(dx, dy, rect); DoSyncIfNecessary(); } @@ -547,7 +551,7 @@ public: // functionality // ---------------------------------------------------------------------------- -class MyAutoScrollingWindow : public wxScrolledWindow +class MyAutoScrollingWindow : public wxScrolled { public: MyAutoScrollingWindow( wxWindow* parent ); @@ -648,15 +652,15 @@ public: // MyCanvas // ---------------------------------------------------------------------------- -const wxWindowID ID_ADDBUTTON = wxWindow::NewControlId(); -const wxWindowID ID_DELBUTTON = wxWindow::NewControlId(); -const wxWindowID ID_MOVEBUTTON = wxWindow::NewControlId(); -const wxWindowID ID_SCROLLWIN = wxWindow::NewControlId(); -const wxWindowID ID_QUERYPOS = wxWindow::NewControlId(); +const wxWindowIDRef ID_ADDBUTTON = wxWindow::NewControlId(); +const wxWindowIDRef ID_DELBUTTON = wxWindow::NewControlId(); +const wxWindowIDRef ID_MOVEBUTTON = wxWindow::NewControlId(); +const wxWindowIDRef ID_SCROLLWIN = wxWindow::NewControlId(); +const wxWindowIDRef ID_QUERYPOS = wxWindow::NewControlId(); -const wxWindowID ID_NEWBUTTON = wxWindow::NewControlId(); +const wxWindowIDRef ID_NEWBUTTON = wxWindow::NewControlId(); -BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) +BEGIN_EVENT_TABLE(MyCanvas, wxScrolled) EVT_PAINT( MyCanvas::OnPaint) EVT_RIGHT_DOWN( MyCanvas::OnMouseRightDown) EVT_MOUSEWHEEL( MyCanvas::OnMouseWheel) @@ -668,9 +672,9 @@ BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) END_EVENT_TABLE() MyCanvas::MyCanvas(wxWindow *parent) - : wxScrolledWindow(parent, wxID_ANY, - wxDefaultPosition, wxDefaultSize, - wxSUNKEN_BORDER | wxTAB_TRAVERSAL) + : wxScrolled(parent, wxID_ANY, + wxDefaultPosition, wxDefaultSize, + wxSUNKEN_BORDER | wxTAB_TRAVERSAL) { // you can use either a single SetScrollbars() call or these 2 functions, // usually using them is better because you normally won't need to change @@ -777,7 +781,7 @@ void MyCanvas::OnScrollWin( wxCommandEvent &WXUNUSED(event) ) // ---------------------------------------------------------------------------- MySizerScrolledWindow::MySizerScrolledWindow(wxWindow *parent) - : wxScrolledWindow(parent) + : wxScrolled(parent) { SetBackgroundColour( "GREEN" ); @@ -854,6 +858,8 @@ END_EVENT_TABLE() MyFrame::MyFrame() : wxFrame(NULL, wxID_ANY, "wxWidgets scroll sample") { + SetIcon(wxICON(sample)); + wxMenu *menuFile = new wxMenu; menuFile->Append(wxID_ABOUT, "&About.."); menuFile->AppendSeparator(); @@ -957,7 +963,7 @@ void MyFrame::OnQuit(wxCommandEvent &WXUNUSED(event)) void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) ) { - (void)wxMessageBox( "wxScrolledWindow sample\n" + (void)wxMessageBox( "Scrolled window sample\n" "\n" "Robert Roebling (c) 1998\n" "Vadim Zeitlin (c) 2008\n" @@ -1040,7 +1046,7 @@ void MyScrolledWindowSmart::OnDraw(wxDC& dc) // MyAutoScrollingWindow // ---------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(MyAutoScrollingWindow, wxScrolledWindow) +BEGIN_EVENT_TABLE(MyAutoScrollingWindow, wxScrolled) EVT_LEFT_DOWN(MyAutoScrollingWindow::OnMouseLeftDown) EVT_LEFT_UP(MyAutoScrollingWindow::OnMouseLeftUp) EVT_MOTION(MyAutoScrollingWindow::OnMouseMove) @@ -1049,8 +1055,8 @@ BEGIN_EVENT_TABLE(MyAutoScrollingWindow, wxScrolledWindow) END_EVENT_TABLE() MyAutoScrollingWindow::MyAutoScrollingWindow(wxWindow* parent) - : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxVSCROLL | wxHSCROLL | wxSUNKEN_BORDER), + : wxScrolled(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxVSCROLL | wxHSCROLL | wxSUNKEN_BORDER), m_selStart(-1, -1), m_cursor(-1, -1), m_font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL) @@ -1234,7 +1240,7 @@ void MyAutoScrollingWindow::OnDraw(wxDC& dc) dc.SetPen(*wxTRANSPARENT_PEN); const wxString str = sm_testData; size_t strLength = str.length(); - wxString::const_iterator str_i; + wxString::const_iterator str_i = str.begin(); // draw the characters // 1. for each update region