Search code examples
wxwidgetswxpython

What does wxScrolled.SetScale() do?


I am reading the documentation for wxScrolled, and came across wxScrolled.SetScale(). There is no documentation for it, and calling it seems to have no effect. What does it do?

If it matters, I am using wxPython 4.1.0.


In context:

I am writing my own widget subclassing wxScrolled. It displays a graph, and I want my user to be able to zoom in and out of the graph. Can I use safely use wxScrolled.SetScale() and GetScaleX()/GetScaleY() to store zoom ratio information?


Solution

  • The scale values will be forwarded to wxDC::SetUserScale(), when DoPrepareDC() was called (i.e. you should see their effect if you do your own drawing by overriding wxScrolled< T >::OnDraw()).

    Probable causes for not having any effect:

    • you don't do any drawing;
    • custom drawing is done by directly handling wxEVT_PAINT and not calling DoPrepareDC() explicitly.