Glaz wrote:
> Hello.
>
> If I start the sample_editor_tuto, right click with the mouse and select
> 'Zoom to fit' everything shall be fitted to the application window. But
> there are scroll bars drawn. By right clicking with the mouse and
> selecting 'Zoom to fit' a second time the scroll bars disappear. By
> doing this a third time the scroll bars appear again. Why is this?
Scrollbar behaviour is a bit of a nightmare in wxWidgets.
Adding/removing scrollbars leads to a change in the size of the client area.
And that changes the mapping from world to device coordinates, and that again
might change the scrollbars etc.
So before you know it, it becomes an endless loop.
Therefore i try to clauclate the fitting on the current client size, and if it
turn out that with after the fit the
scrollbars should be invisible/visible it will happen.
>
> In my imagination a zoom to fit should never lead to scroll bars
> displayed - am I right?
No that is not right.
//defines the whole area in world coordinates that can be seen by scrolling
m_canvas->SetScrollMaximum(0,0,1600,1600);
If the drawing size stored in the document, if say (200,200) to (400,500), a
Zoom to fit will fit the drawing into the
current window, and set the scrollbars to the part that is visible int the
ranges 0,0,1600,1600.
At least that is the idea behind SetScrollMaximum(), even if it does not look
very consistent.
E.g what happens if you zoom out beyond the SetScrollMaximum(0,0,1600,1600), if
FixScrollMaximum is not set,
it will change the maximum scrollable area to that zoom value.
So to keep that area constant do this:
// no change in scrollmaximum when zooming out further
void FixScrollMaximum(bool fixed) { m_scrollmaxfixed=fixed; }
Also it is possible to disable scrolbars completely:
void SetScrollBarsVisible(bool onoff);
In any case you have to realize that a2dCanvas tries to cope with an infinit
drawing area, of which only a part is
visible in the window. So scrollbars need to be set to some part of this
infinite drawing area, or else they are simply
undefined.
>
> Background:
> I want to zoom to fit in my own application. I discovered that the
> following lines of code do the trick:
>
> a2dCanvas *canvas = getTheCanvasFromSomewhere();
> canvas->SetMappingShowAll( false ); // Zoom to fit (100%).
> //canvas->SetMappingShowAll( true ); // Also leads to scroll bars.
>
> But I mostly get scroll bars (sometimes I am lucky and don't get them).
> But as I said I don't want them at all. What can I do about this?
Never right!
SetScrollBarsVisible(bool onoff);
Regards,
Klaas
--
Unclassified
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Wxart2d-users_dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev