X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5f3286d17d6f65c3acddabb45545c2ef1b0d9b20..5cf69f76a10799e5e6eb1836cffeee11507e0788:/samples/scrollsub/scrollsub.cpp diff --git a/samples/scrollsub/scrollsub.cpp b/samples/scrollsub/scrollsub.cpp index c7ce613e4e..cc8d3acc7e 100644 --- a/samples/scrollsub/scrollsub.cpp +++ b/samples/scrollsub/scrollsub.cpp @@ -210,7 +210,18 @@ MyTopLabels::MyTopLabels( wxScrolledWindow *parent, wxWindowID id, const wxPoint void MyTopLabels::OnPaint( wxPaintEvent &event ) { wxPaintDC dc(this); - m_owner->PrepareDC( dc ); + + // This is wrong.. it will translate both x and y if the + // window is scrolled, the label windows are active in one + // direction only. Do the action below instead -- RL. + //m_owner->PrepareDC( dc ); + + int xScrollUnits, xOrigin; + + m_owner->GetViewStart( &xOrigin, 0 ); + m_owner->GetScrollPixelsPerUnit( &xScrollUnits, 0 ); + dc.SetDeviceOrigin( -xOrigin * xScrollUnits, 0 ); + dc.DrawText( "Column 1", 5, 5 ); dc.DrawText( "Column 2", 105, 5 ); dc.DrawText( "Column 3", 205, 5 ); @@ -233,7 +244,18 @@ MyRightLabels::MyRightLabels( wxScrolledWindow *parent, wxWindowID id, const wxP void MyRightLabels::OnPaint( wxPaintEvent &event ) { wxPaintDC dc(this); - m_owner->PrepareDC( dc ); + + // This is wrong.. it will translate both x and y if the + // window is scrolled, the label windows are active in one + // direction only. Do the action below instead -- RL. + //m_owner->PrepareDC( dc ); + + int yScrollUnits, yOrigin; + + m_owner->GetViewStart( 0, &yOrigin ); + m_owner->GetScrollPixelsPerUnit( 0, &yScrollUnits ); + dc.SetDeviceOrigin( 0, -yOrigin * yScrollUnits ); + dc.DrawText( "Row 1", 5, 5 ); dc.DrawText( "Row 2", 5, 30 ); dc.DrawText( "Row 3", 5, 55 ); @@ -264,6 +286,9 @@ MyCanvas::MyCanvas( wxScrolledWindow *parent, MyTopLabels *top, MyRightLabels *r (void)new wxTextCtrl( this, -1, "Text I", wxPoint(0,100), wxSize(100,25) ); (void)new wxTextCtrl( this, -1, "Text II", wxPoint(200,100), wxSize(100,25) ); + (void)new wxComboBox( this, -1, "ComboBox I", wxPoint(0,150), wxSize(100,25), 0, NULL ); + (void)new wxComboBox( this, -1, "ComboBox II", wxPoint(200,150), wxSize(100,25), 0, NULL ); + SetBackgroundColour( wxT("WHEAT") ); SetCursor( wxCursor( wxCURSOR_IBEAM ) ); @@ -306,12 +331,12 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) (0-scroll_x < size_x) && (0-scroll_y < size_y)) { // Has the region on screen been exposed? - if (IsExposed(0,0,100,25)) - { - wxLogMessage( wxT("Redraw first cell") ); + if (IsExposed(0,0,100,25)) + { + wxLogMessage( wxT("Redraw first cell") ); dc.DrawRectangle( 0, 0, 100, 25 ); - dc.DrawText( "First Cell", 5, 5 ); - } + dc.DrawText( "First Cell", 5, 5 ); + } } @@ -321,12 +346,12 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) (200-scroll_x < size_x) && (0-scroll_y < size_y)) { // Has the region on screen been exposed? - if (IsExposed(200,0,100,25)) - { - wxLogMessage( wxT("Redraw second cell") ); + if (IsExposed(200,0,100,25)) + { + wxLogMessage( wxT("Redraw second cell") ); dc.DrawRectangle( 200, 0, 100, 25 ); - dc.DrawText( "Second Cell", 205, 5 ); - } + dc.DrawText( "Second Cell", 205, 5 ); + } } }