]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/scroll/scroll.cpp
Support using GetTextExtent() with empty string to get descent in wxOSX.
[wxWidgets.git] / samples / scroll / scroll.cpp
index 2186f19bbcbd0b96bf6c1e6cb054e44509b57c6c..c31e0f45a7617d97d2415cfd720994d6e59adddb 100644 (file)
@@ -1,11 +1,11 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        scroll.cpp
 /////////////////////////////////////////////////////////////////////////////
 // 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
 // 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"
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/wxprec.h"
 #include "wx/log.h"
 #include "wx/tglbtn.h"
 
 #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
 // ----------------------------------------------------------------------------
 // a trivial example
 // ----------------------------------------------------------------------------
 
 // MySimpleCanvas: a scrolled window which draws a simple rectangle
-class MySimpleCanvas : public wxScrolledWindow
+class MySimpleCanvas : public wxScrolled<wxWindow>
 {
 public:
     enum
 {
 public:
     enum
@@ -40,7 +44,7 @@ public:
     };
 
     MySimpleCanvas(wxWindow *parent)
     };
 
     MySimpleCanvas(wxWindow *parent)
-        : wxScrolledWindow(parent, wxID_ANY)
+        : wxScrolled<wxWindow>(parent, wxID_ANY)
     {
         SetScrollRate( 10, 10 );
         SetVirtualSize( WIDTH, HEIGHT );
     {
         SetScrollRate( 10, 10 );
         SetVirtualSize( WIDTH, HEIGHT );
@@ -86,7 +90,7 @@ public:
 // ----------------------------------------------------------------------
 
 // MyCanvas
 // ----------------------------------------------------------------------
 
 // MyCanvas
-class MyCanvas : public wxScrolledWindow
+class MyCanvas : public wxScrolled<wxPanel>
 {
 public:
     MyCanvas(wxWindow *parent);
 {
 public:
     MyCanvas(wxWindow *parent);
@@ -122,9 +126,9 @@ public:
         mbar->Append(menuFile, "&File");
         SetMenuBar( mbar );
 
         mbar->Append(menuFile, "&File");
         SetMenuBar( mbar );
 
-        Connect(wxID_DELETE, wxEVT_COMMAND_MENU_SELECTED,
+        Connect(wxID_DELETE, wxEVT_MENU,
                 wxCommandEventHandler(MyCanvasFrame::OnDeleteAll));
                 wxCommandEventHandler(MyCanvasFrame::OnDeleteAll));
-        Connect(wxID_NEW, wxEVT_COMMAND_MENU_SELECTED,
+        Connect(wxID_NEW, wxEVT_MENU,
                 wxCommandEventHandler(MyCanvasFrame::OnInsertNew));
 
         Show();
                 wxCommandEventHandler(MyCanvasFrame::OnInsertNew));
 
         Show();
@@ -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 );
 
 // ----------------------------------------------------------------------------
 
 const wxSize SMALL_BUTTON( 100, 50 );
 const wxSize LARGE_BUTTON( 300, 200 );
 
-class MySizerScrolledWindow : public wxScrolledWindow
+class MySizerScrolledWindow : public wxScrolled<wxWindow>
 {
 public:
     MySizerScrolledWindow(wxWindow *parent);
 {
 public:
     MySizerScrolledWindow(wxWindow *parent);
@@ -189,7 +193,7 @@ public:
 class MySubColLabels : public wxWindow
 {
 public:
 class MySubColLabels : public wxWindow
 {
 public:
-    MySubColLabels(wxScrolledWindow *parent)
+    MySubColLabels(wxScrolled<wxWindow> *parent)
         : wxWindow(parent, wxID_ANY)
     {
         m_owner = parent;
         : wxWindow(parent, wxID_ANY)
     {
         m_owner = parent;
@@ -218,13 +222,13 @@ private:
         dc.DrawText("Column 3", 205, 5);
     }
 
         dc.DrawText("Column 3", 205, 5);
     }
 
-    wxScrolledWindow *m_owner;
+    wxScrolled<wxWindow> *m_owner;
 };
 
 class MySubRowLabels : public wxWindow
 {
 public:
 };
 
 class MySubRowLabels : public wxWindow
 {
 public:
-    MySubRowLabels(wxScrolledWindow *parent)
+    MySubRowLabels(wxScrolled<wxWindow> *parent)
         : wxWindow(parent, wxID_ANY)
     {
         m_owner = parent;
         : wxWindow(parent, wxID_ANY)
     {
         m_owner = parent;
@@ -256,13 +260,13 @@ private:
         dc.DrawText("Row 6", 5, 130);
     }
 
         dc.DrawText("Row 6", 5, 130);
     }
 
-    wxScrolledWindow *m_owner;
+    wxScrolled<wxWindow> *m_owner;
 };
 
 class MySubCanvas : public wxPanel
 {
 public:
 };
 
 class MySubCanvas : public wxPanel
 {
 public:
-    MySubCanvas(wxScrolledWindow *parent, wxWindow *cols, wxWindow *rows)
+    MySubCanvas(wxScrolled<wxWindow> *parent, wxWindow *cols, wxWindow *rows)
         : wxPanel(parent, wxID_ANY)
     {
         m_owner = parent;
         : wxPanel(parent, wxID_ANY)
     {
         m_owner = parent;
@@ -354,12 +358,12 @@ private:
         }
     }
 
         }
     }
 
-    wxScrolledWindow *m_owner;
+    wxScrolled<wxWindow> *m_owner;
     wxWindow *m_colLabels,
              *m_rowLabels;
 };
 
     wxWindow *m_colLabels,
              *m_rowLabels;
 };
 
-class MySubScrolledWindow : public wxScrolledWindow
+class MySubScrolledWindow : public wxScrolled<wxWindow>
 {
 public:
     enum
 {
 public:
     enum
@@ -369,7 +373,7 @@ public:
     };
 
     MySubScrolledWindow(wxWindow *parent)
     };
 
     MySubScrolledWindow(wxWindow *parent)
-        : wxScrolledWindow(parent, wxID_ANY)
+        : wxScrolled<wxWindow>(parent, wxID_ANY)
     {
         // create the children
         MySubColLabels *cols = new MySubColLabels(this);
     {
         // create the children
         MySubColLabels *cols = new MySubColLabels(this);
@@ -440,19 +444,19 @@ public:
 };
 
 // ----------------------------------------------------------------------------
 };
 
 // ----------------------------------------------------------------------------
-// more simple examples of wxScrolledWindow usage
+// more simple examples of wxScrolled usage
 // ----------------------------------------------------------------------------
 
 // base class for both of them
 // ----------------------------------------------------------------------------
 
 // base class for both of them
-class MyScrolledWindowBase : public wxScrolledWindow
+class MyScrolledWindowBase : public wxScrolled<wxWindow>
 {
 public:
     MyScrolledWindowBase(wxWindow *parent)
 {
 public:
     MyScrolledWindowBase(wxWindow *parent)
-        : wxScrolledWindow(parent, wxID_ANY,
-                           wxDefaultPosition, wxDefaultSize,
-                           wxBORDER_SUNKEN)
+        : wxScrolled<wxWindow>(parent, wxID_ANY,
+                               wxDefaultPosition, wxDefaultSize,
+                               wxBORDER_SUNKEN)
     {
     {
-        m_nLines = 100;
+        m_nLines = 50;
         m_winSync = NULL;
         m_inDoSync = false;
 
         m_winSync = NULL;
         m_inDoSync = false;
 
@@ -472,7 +476,7 @@ public:
 
     virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL)
     {
 
     virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL)
     {
-        wxScrolledWindow::ScrollWindow(dx, dy, rect);
+        wxScrolled<wxWindow>::ScrollWindow(dx, dy, rect);
 
         DoSyncIfNecessary();
     }
 
         DoSyncIfNecessary();
     }
@@ -547,7 +551,7 @@ public:
 // functionality
 // ----------------------------------------------------------------------------
 
 // functionality
 // ----------------------------------------------------------------------------
 
-class MyAutoScrollingWindow : public wxScrolledWindow
+class MyAutoScrollingWindow : public wxScrolled<wxWindow>
 {
 public:
     MyAutoScrollingWindow( wxWindow* parent );
 {
 public:
     MyAutoScrollingWindow( wxWindow* parent );
@@ -621,6 +625,7 @@ private:
     void OnTestAuto(wxCommandEvent& WXUNUSED(event)) { new MyAutoFrame(this); }
 
     void OnToggleSync(wxCommandEvent& event);
     void OnTestAuto(wxCommandEvent& WXUNUSED(event)) { new MyAutoFrame(this); }
 
     void OnToggleSync(wxCommandEvent& event);
+    void OnScrollbarVisibility(wxCommandEvent& event);
 
     MyScrolledWindowBase *m_win1,
                          *m_win2;
 
     MyScrolledWindowBase *m_win1,
                          *m_win2;
@@ -647,15 +652,15 @@ public:
 // MyCanvas
 // ----------------------------------------------------------------------------
 
 // 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<wxPanel>)
     EVT_PAINT(                  MyCanvas::OnPaint)
     EVT_RIGHT_DOWN(             MyCanvas::OnMouseRightDown)
     EVT_MOUSEWHEEL(             MyCanvas::OnMouseWheel)
     EVT_PAINT(                  MyCanvas::OnPaint)
     EVT_RIGHT_DOWN(             MyCanvas::OnMouseRightDown)
     EVT_MOUSEWHEEL(             MyCanvas::OnMouseWheel)
@@ -667,9 +672,9 @@ BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
 END_EVENT_TABLE()
 
 MyCanvas::MyCanvas(wxWindow *parent)
 END_EVENT_TABLE()
 
 MyCanvas::MyCanvas(wxWindow *parent)
-    : wxScrolledWindow(parent, wxID_ANY,
-                       wxDefaultPosition, wxDefaultSize,
-                       wxSUNKEN_BORDER | wxTAB_TRAVERSAL)
+    : wxScrolled<wxPanel>(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
 {
     // 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
@@ -776,7 +781,7 @@ void MyCanvas::OnScrollWin( wxCommandEvent &WXUNUSED(event) )
 // ----------------------------------------------------------------------------
 
 MySizerScrolledWindow::MySizerScrolledWindow(wxWindow *parent)
 // ----------------------------------------------------------------------------
 
 MySizerScrolledWindow::MySizerScrolledWindow(wxWindow *parent)
-    : wxScrolledWindow(parent)
+    : wxScrolled<wxWindow>(parent)
 {
     SetBackgroundColour( "GREEN" );
 
 {
     SetBackgroundColour( "GREEN" );
 
@@ -792,7 +797,7 @@ MySizerScrolledWindow::MySizerScrolledWindow(wxWindow *parent)
     m_button = new wxButton( this, wxID_RESIZE_FRAME, "Press me",
                              wxDefaultPosition, SMALL_BUTTON );
 
     m_button = new wxButton( this, wxID_RESIZE_FRAME, "Press me",
                              wxDefaultPosition, SMALL_BUTTON );
 
-    sizer->Add(m_button, wxSizerFlags().Centre().Border(20));
+    sizer->Add(m_button, wxSizerFlags().Centre().Border(wxALL, 20));
     sizer->Add(new wxStaticText(this, wxID_ANY, "This is just"),
                wxSizerFlags().Centre());
     sizer->Add(new wxStaticText(this, wxID_ANY, "some decoration"),
     sizer->Add(new wxStaticText(this, wxID_ANY, "This is just"),
                wxSizerFlags().Centre());
     sizer->Add(new wxStaticText(this, wxID_ANY, "some decoration"),
@@ -804,7 +809,7 @@ MySizerScrolledWindow::MySizerScrolledWindow(wxWindow *parent)
 
     SetSizer( sizer );
 
 
     SetSizer( sizer );
 
-    Connect(wxID_RESIZE_FRAME, wxEVT_COMMAND_BUTTON_CLICKED,
+    Connect(wxID_RESIZE_FRAME, wxEVT_BUTTON,
             wxCommandEventHandler(MySizerScrolledWindow::OnResizeClick));
 }
 
             wxCommandEventHandler(MySizerScrolledWindow::OnResizeClick));
 }
 
@@ -834,6 +839,7 @@ const wxWindowID Scroll_Test_Sub    = wxWindow::NewControlId();
 const wxWindowID Scroll_Test_Auto   = wxWindow::NewControlId();
 
 const wxWindowID Scroll_TglBtn_Sync = wxWindow::NewControlId();
 const wxWindowID Scroll_Test_Auto   = wxWindow::NewControlId();
 
 const wxWindowID Scroll_TglBtn_Sync = wxWindow::NewControlId();
+const wxWindowID Scroll_Radio_ShowScrollbar = wxWindow::NewControlId();
 
 BEGIN_EVENT_TABLE(MyFrame,wxFrame)
     EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
 
 BEGIN_EVENT_TABLE(MyFrame,wxFrame)
     EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
@@ -846,11 +852,14 @@ BEGIN_EVENT_TABLE(MyFrame,wxFrame)
     EVT_MENU(Scroll_Test_Auto, MyFrame::OnTestAuto)
 
     EVT_TOGGLEBUTTON(Scroll_TglBtn_Sync, MyFrame::OnToggleSync)
     EVT_MENU(Scroll_Test_Auto, MyFrame::OnTestAuto)
 
     EVT_TOGGLEBUTTON(Scroll_TglBtn_Sync, MyFrame::OnToggleSync)
+    EVT_RADIOBOX(Scroll_Radio_ShowScrollbar, MyFrame::OnScrollbarVisibility)
 END_EVENT_TABLE()
 
 MyFrame::MyFrame()
        : wxFrame(NULL, wxID_ANY, "wxWidgets scroll sample")
 {
 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();
     wxMenu *menuFile = new wxMenu;
     menuFile->Append(wxID_ABOUT, "&About..");
     menuFile->AppendSeparator();
@@ -876,10 +885,12 @@ MyFrame::MyFrame()
     SetMenuBar( mbar );
 
 
     SetMenuBar( mbar );
 
 
+    wxPanel *panel = new wxPanel(this);
+
     const wxSizerFlags flagsExpand(wxSizerFlags(1).Expand());
 
     wxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
     const wxSizerFlags flagsExpand(wxSizerFlags(1).Expand());
 
     wxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
-    topsizer->Add(new wxStaticText(this, wxID_ANY,
+    topsizer->Add(new wxStaticText(panel, wxID_ANY,
         "The windows below should behave in the same way, even though\n"
         "they're implemented quite differently, see the code for details.\n"
         "\n"
         "The windows below should behave in the same way, even though\n"
         "they're implemented quite differently, see the code for details.\n"
         "\n"
@@ -888,20 +899,39 @@ MyFrame::MyFrame()
         "don't be surprised by this."),
         wxSizerFlags().Centre().Border());
 
         "don't be surprised by this."),
         wxSizerFlags().Centre().Border());
 
-    m_win1 = new MyScrolledWindowDumb(this);
-    m_win2 = new MyScrolledWindowSmart(this);
+    m_win1 = new MyScrolledWindowDumb(panel);
+    m_win2 = new MyScrolledWindowSmart(panel);
 
     wxSizer *sizerScrollWin = new wxBoxSizer(wxHORIZONTAL);
     sizerScrollWin->Add(m_win1, flagsExpand);
     sizerScrollWin->Add(m_win2, flagsExpand);
     topsizer->Add(sizerScrollWin, flagsExpand);
 
 
     wxSizer *sizerScrollWin = new wxBoxSizer(wxHORIZONTAL);
     sizerScrollWin->Add(m_win1, flagsExpand);
     sizerScrollWin->Add(m_win2, flagsExpand);
     topsizer->Add(sizerScrollWin, flagsExpand);
 
+    const wxSizerFlags
+        flagsHBorder(wxSizerFlags().Centre().Border(wxLEFT | wxRIGHT));
+
     wxSizer *sizerBtns = new wxBoxSizer(wxHORIZONTAL);
     wxSizer *sizerBtns = new wxBoxSizer(wxHORIZONTAL);
-    sizerBtns->Add(new wxToggleButton(this, Scroll_TglBtn_Sync, "&Synchronize"));
+
+    // the radio buttons are in the same order as wxSHOW_SB_XXX values but
+    // offset by 1
+    const wxString visibilities[] = { "&never", "&default", "&always" };
+    wxRadioBox *radio = new wxRadioBox(panel, Scroll_Radio_ShowScrollbar,
+                                       "Left &scrollbar visibility: ",
+                                       wxDefaultPosition, wxDefaultSize,
+                                       WXSIZEOF(visibilities), visibilities);
+    radio->SetSelection(wxSHOW_SB_DEFAULT + 1);
+    sizerBtns->Add(radio, flagsHBorder);
+
+    sizerBtns->Add(new wxToggleButton(panel, Scroll_TglBtn_Sync, "S&ynchronize"),
+                   flagsHBorder);
+
     topsizer->Add(sizerBtns, wxSizerFlags().Centre().Border());
 
     topsizer->Add(sizerBtns, wxSizerFlags().Centre().Border());
 
-    SetSizer(topsizer);
+    panel->SetSizer(topsizer);
 
 
+    wxSize size = panel->GetBestSize();
+    SetSizeHints(size);
+    SetClientSize(2*size);
 
     Show();
 }
 
     Show();
 }
@@ -920,6 +950,12 @@ void MyFrame::OnToggleSync(wxCommandEvent& event)
     }
 }
 
     }
 }
 
+void MyFrame::OnScrollbarVisibility(wxCommandEvent& event)
+{
+    m_win1->ShowScrollbars(wxSHOW_SB_NEVER,
+                           wxScrollbarVisibility(event.GetSelection() - 1));
+}
+
 void MyFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
 {
     Close(true);
 void MyFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
 {
     Close(true);
@@ -927,7 +963,7 @@ void MyFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
 
 void MyFrame::OnAbout( 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"
                         "\n"
                         "Robert Roebling (c) 1998\n"
                         "Vadim Zeitlin (c) 2008\n"
@@ -1010,7 +1046,7 @@ void MyScrolledWindowSmart::OnDraw(wxDC& dc)
 // MyAutoScrollingWindow
 // ----------------------------------------------------------------------------
 
 // MyAutoScrollingWindow
 // ----------------------------------------------------------------------------
 
-BEGIN_EVENT_TABLE(MyAutoScrollingWindow, wxScrolledWindow)
+BEGIN_EVENT_TABLE(MyAutoScrollingWindow, wxScrolled<wxWindow>)
     EVT_LEFT_DOWN(MyAutoScrollingWindow::OnMouseLeftDown)
     EVT_LEFT_UP(MyAutoScrollingWindow::OnMouseLeftUp)
     EVT_MOTION(MyAutoScrollingWindow::OnMouseMove)
     EVT_LEFT_DOWN(MyAutoScrollingWindow::OnMouseLeftDown)
     EVT_LEFT_UP(MyAutoScrollingWindow::OnMouseLeftUp)
     EVT_MOTION(MyAutoScrollingWindow::OnMouseMove)
@@ -1019,8 +1055,8 @@ BEGIN_EVENT_TABLE(MyAutoScrollingWindow, wxScrolledWindow)
 END_EVENT_TABLE()
 
 MyAutoScrollingWindow::MyAutoScrollingWindow(wxWindow* parent)
 END_EVENT_TABLE()
 
 MyAutoScrollingWindow::MyAutoScrollingWindow(wxWindow* parent)
-    : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
-                       wxVSCROLL | wxHSCROLL | wxSUNKEN_BORDER),
+    : wxScrolled<wxWindow>(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)
       m_selStart(-1, -1),
       m_cursor(-1, -1),
       m_font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)
@@ -1197,14 +1233,12 @@ MyAutoScrollingWindow::DCNormalize(int x, int y, int w, int h)
 void MyAutoScrollingWindow::OnDraw(wxDC& dc)
 {
     dc.SetFont(m_font);
 void MyAutoScrollingWindow::OnDraw(wxDC& dc)
 {
     dc.SetFont(m_font);
-    wxBrush normBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)
-            , wxSOLID);
-    wxBrush selBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)
-            , wxSOLID);
+    wxBrush normBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
+    wxBrush selBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
     dc.SetPen(*wxTRANSPARENT_PEN);
     const wxString str = sm_testData;
     size_t strLength = str.length();
     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
 
     // draw the characters
     // 1. for each update region