Patches to include in wxWidgets to build LenMus
================================================

Last updated: May/2008


Building LenMus requires to install and build wxWidgets. There is a couple of fixes to add to wxWidgets source code. One of them is critical; without it LenMus will not build.


1. Critical patches
-----------------------

==================================================================================
Problem: Add scaling factor to HTML window
See: http://sourceforge.net/tracker/index.php?func=detail&aid=1790374&group_id=9863&atid=359863
==================================================================================

    
1. Define a new public method and a private variable in wxHtmlWindow:


include/wx/html/htmlwin.h
@@ 460
    virtual wxCursor GetHTMLCursor(HTMLCursor type) const;
 +   virtual void SetPixelScalingFactor(double pixel_scale) { m_PixelScale = pixel_scale; }
 
 // implementation of SetPage()
    bool DoSetPage(const wxString& source);


@@ 513
    // window content for double buffered rendering:
    wxBitmap *m_backBuffer;
    
+   // pixel scale
+	double m_PixelScale;

    // background image, may be invalid
    wxBitmap m_bmpBg;



2. Modify wxHtmlWindow::Init() method to initialise this new variable to 1.0

src/html/htmlwin.cpp
@@ 
void wxHtmlWindow::Init()
{
+	m_PixelScale = 1.0;
    m_tmpCanDrawLocks = 0;


3. Modify method wxHtmlWindow::DoSetPage to use this value replacing:
src/html/htmlwin.cpp
@@ 447
    SetBackgroundImage(wxNullBitmap);

-   m_Parser->SetDC(dc);
+	m_Parser->SetDC(dc, m_PixelScale);
    if (m_Cell)


---------------------------------------------------------------------------------


2. Not-important patches
---------------------------

==================================================================================
Problem in VScrolledWindow, file generic/vscroll.cpp
	patch #1667599	http://sourceforge.net/tracker/index.php?func=detail&aid=1667599&group_id=9863&atid=309863
==================================================================================
	
Two patches to apply:


---------------------------------------------------------------------------------
Index: vscroll.cpp
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/src/generic/vscroll.cpp,v
retrieving revision 1.30
diff -u -r1.30 vscroll.cpp
--- vscroll.cpp	2006/08/16 12:17:05	1.30
+++ vscroll.cpp	2007/02/24 01:23:26
@@ -230,14 +230,9 @@
 
     // recalculate the scrollbars parameters
     if ( count )
-    {
-        m_lineFirst = 1;    // make sure it is != 0
         ScrollToLine(0);
-    }
     else // no items
-    {
         RemoveScrollbar();
-    }
 }
 
 void wxVScrolledWindow::RefreshLine(size_t line)

 
 
 
---------------------------------------------------------------------------------
Index: src/generic/vscroll.cpp
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/src/generic/vscroll.cpp,v
retrieving revision 1.30
diff -u -r1.30 vscroll.cpp
--- src/generic/vscroll.cpp	2006/08/16 12:17:05	1.30
+++ src/generic/vscroll.cpp	2007/03/12 19:52:38
@@ -169,6 +169,13 @@
 
 void wxVScrolledWindow::UpdateScrollbar()
 {
+    // if there is nothing to scroll, remove the scrollbar
+    if ( !m_lineMax )
+    {
+        RemoveScrollbar();
+        return;
+    }
+
     // see how many lines can we fit on screen
     const wxCoord hWindow = GetClientSize().y;
 
@@ -228,16 +235,13 @@
     // and our estimate for their total height
     m_heightTotal = EstimateTotalHeight();
 
-    // recalculate the scrollbars parameters
-    if ( count )
-    {
-        m_lineFirst = 1;    // make sure it is != 0
-        ScrollToLine(0);
-    }
-    else // no items
-    {
-        RemoveScrollbar();
-    }
+    // ScrollToLine() will check if we are scrolled past the new max scroll
+    // position.  If the scroll position isn't changed in ScrollToLine(), the
+    // scrollbars will still need to be updated for total line count changes.
+    size_t oldScrollPos = m_lineFirst;
+    ScrollToLine(m_lineFirst);
+    if ( oldScrollPos == m_lineFirst )
+        UpdateScrollbar();
 }
 
 void wxVScrolledWindow::RefreshLine(size_t line)
 
 
 
---------------------------------------------------------------------------------
