]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/scroll/scroll.cpp
added wxNativeFontInfo() ctor from LOGFONT, this is convenient for MSW code
[wxWidgets.git] / samples / scroll / scroll.cpp
index 345e64cd045883f56a7835dfc54d879c47a03fde..1275d544f5586cce5060f776a1456669e6c8507f 100644 (file)
@@ -67,11 +67,11 @@ MySimpleCanvas::MySimpleCanvas( wxWindow *parent, wxWindowID id,
     SetBackgroundColour( *wxWHITE );
 }
 
     SetBackgroundColour( *wxWHITE );
 }
 
-void MySimpleCanvas::OnPaint( wxPaintEvent &event )
+void MySimpleCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
 {
     wxPaintDC dc(this);
     PrepareDC( dc );
 {
     wxPaintDC dc(this);
     PrepareDC( dc );
-    
+
     dc.SetPen( *wxRED_PEN );
     dc.SetBrush( *wxTRANSPARENT_BRUSH );
     dc.DrawRectangle( 0,0,92,97 );
     dc.SetPen( *wxRED_PEN );
     dc.SetBrush( *wxTRANSPARENT_BRUSH );
     dc.DrawRectangle( 0,0,92,97 );
@@ -273,6 +273,7 @@ protected: // event stuff
     void OnMouseLeftDown(wxMouseEvent& event);
     void OnMouseLeftUp(wxMouseEvent& event);
     void OnMouseMove(wxMouseEvent& event);
     void OnMouseLeftDown(wxMouseEvent& event);
     void OnMouseLeftUp(wxMouseEvent& event);
     void OnMouseMove(wxMouseEvent& event);
+    void OnMouseCaptureLost(wxMouseCaptureLostEvent& event);
     void OnScroll(wxScrollWinEvent& event);
 
     DECLARE_EVENT_TABLE()
     void OnScroll(wxScrollWinEvent& event);
 
     DECLARE_EVENT_TABLE()
@@ -514,7 +515,7 @@ BEGIN_EVENT_TABLE( MyAutoScrollWindow, wxScrolledWindow)
 END_EVENT_TABLE()
 
 MyAutoScrollWindow::MyAutoScrollWindow( wxWindow *parent )
 END_EVENT_TABLE()
 
 MyAutoScrollWindow::MyAutoScrollWindow( wxWindow *parent )
-    : wxScrolledWindow( parent, -1, wxDefaultPosition, wxDefaultSize, 
+    : wxScrolledWindow( parent, -1, wxDefaultPosition, wxDefaultSize,
                         wxSUNKEN_BORDER|wxScrolledWindowStyle )
 {
     SetBackgroundColour( wxT("GREEN") );
                         wxSUNKEN_BORDER|wxScrolledWindowStyle )
 {
     SetBackgroundColour( wxT("GREEN") );
@@ -534,16 +535,11 @@ MyAutoScrollWindow::MyAutoScrollWindow( wxWindow *parent )
                              wxDefaultPosition,
                              SMALL_BUTTON );
 
                              wxDefaultPosition,
                              SMALL_BUTTON );
 
-    // We need to do this here, because wxADJUST_MINSIZE below
-    // will cause the initial size to be ignored for Best/Min size.
-    // It would be nice to fix the sizers to handle this a little
-    // more cleanly.
-
     m_button->SetSizeHints( SMALL_BUTTON.GetWidth(), SMALL_BUTTON.GetHeight() );
 
     innersizer->Add( m_button,
                      0,
     m_button->SetSizeHints( SMALL_BUTTON.GetWidth(), SMALL_BUTTON.GetHeight() );
 
     innersizer->Add( m_button,
                      0,
-                     wxALIGN_CENTER | wxALL | wxADJUST_MINSIZE,
+                     wxALIGN_CENTER | wxALL,
                      20 );
 
     innersizer->Add( new wxStaticText( this, wxID_ANY, _T("This is just") ),
                      20 );
 
     innersizer->Add( new wxStaticText( this, wxID_ANY, _T("This is just") ),
@@ -672,6 +668,9 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
 
 bool MyApp::OnInit()
 {
 
 bool MyApp::OnInit()
 {
+    if ( !wxApp::OnInit() )
+        return false;
+
     wxFrame *frame = new MyFrame();
     frame->Show( true );
 
     wxFrame *frame = new MyFrame();
     frame->Show( true );
 
@@ -698,7 +697,7 @@ void MyScrolledWindowDumb::OnDraw(wxDC& dc)
         CalcScrolledPosition(0, y, NULL, &yPhys);
 
         dc.DrawText(wxString::Format(_T("Line %u (logical %d, physical %d)"),
         CalcScrolledPosition(0, y, NULL, &yPhys);
 
         dc.DrawText(wxString::Format(_T("Line %u (logical %d, physical %d)"),
-                                     line, y, yPhys), 0, y);
+                                     unsigned(line), y, yPhys), 0, y);
         y += m_hLine;
     }
 }
         y += m_hLine;
     }
 }
@@ -727,7 +726,7 @@ void MyScrolledWindowSmart::OnDraw(wxDC& dc)
         CalcScrolledPosition(0, y, NULL, &yPhys);
 
         dc.DrawText(wxString::Format(_T("Line %u (logical %d, physical %d)"),
         CalcScrolledPosition(0, y, NULL, &yPhys);
 
         dc.DrawText(wxString::Format(_T("Line %u (logical %d, physical %d)"),
-                                     line, y, yPhys), 0, y);
+                                     unsigned(line), y, yPhys), 0, y);
         y += m_hLine;
     }
 }
         y += m_hLine;
     }
 }
@@ -740,6 +739,7 @@ BEGIN_EVENT_TABLE(MyAutoTimedScrollingWindow, wxScrolledWindow)
     EVT_LEFT_DOWN(MyAutoTimedScrollingWindow::OnMouseLeftDown)
     EVT_LEFT_UP(MyAutoTimedScrollingWindow::OnMouseLeftUp)
     EVT_MOTION(MyAutoTimedScrollingWindow::OnMouseMove)
     EVT_LEFT_DOWN(MyAutoTimedScrollingWindow::OnMouseLeftDown)
     EVT_LEFT_UP(MyAutoTimedScrollingWindow::OnMouseLeftUp)
     EVT_MOTION(MyAutoTimedScrollingWindow::OnMouseMove)
+    EVT_MOUSE_CAPTURE_LOST(MyAutoTimedScrollingWindow::OnMouseCaptureLost)
     EVT_SCROLLWIN(MyAutoTimedScrollingWindow::OnScroll)
 END_EVENT_TABLE()
 
     EVT_SCROLLWIN(MyAutoTimedScrollingWindow::OnScroll)
 END_EVENT_TABLE()
 
@@ -1010,6 +1010,12 @@ void MyAutoTimedScrollingWindow::OnMouseMove(wxMouseEvent& event)
     }
 }
 
     }
 }
 
+void MyAutoTimedScrollingWindow::OnMouseCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event))
+{
+    // we only capture mouse for timed scrolling, so nothing is needed here
+    // other than making sure to not call event.Skip()
+}
+
 void MyAutoTimedScrollingWindow::OnScroll(wxScrollWinEvent& event)
 {
     // need to move the cursor when autoscrolling
 void MyAutoTimedScrollingWindow::OnScroll(wxScrollWinEvent& event)
 {
     // need to move the cursor when autoscrolling