pan and scale a wxScrollWindow

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

pan and scale a wxScrollWindow

Post by gpu » Thu Aug 28, 2014 8:03 am

i want to pan a very big wxScrollWindow, i realized with dc.SetDeviceOrigin, but i still want to know what is the best way to do this?
(2)and then as for the scale problem, what is the difference beteen SetSize and SetVirtualSize ? actually i need a very big window.
(3)hwo to show the Scrollbats, i set ShowScrollbars, but it doesn't show now....

gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: pan and scale a wxScrollWindow

Post by gpu » Thu Aug 28, 2014 8:07 am

and if i want a "infinit" wxScrollWindow, is it possible?
I mean wherever i drag, there is always the window

User avatar
doublemax
Moderator
Moderator
Posts: 15860
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: pan and scale a wxScrollWindow

Post by doublemax » Thu Aug 28, 2014 8:39 am

i want to pan a very big wxScrollWindow, i realized with dc.SetDeviceOrigin, but i still want to know what is the best way to do this?
SetDeviceOrigin() only matters while drawing into the window. You just need to set a big virtual size.
(2)and then as for the scale problem, what is the difference beteen SetSize and SetVirtualSize ? actually i need a very big window.
This is not directly related to scaling. The virtual size is the whole are that can be reached by scrolling. SetSize set the outer dimensions of the visible portion. E.g. you could have a 20000x20000 area with only a 500x500 window visible.
3)hwo to show the Scrollbats, i set ShowScrollbars, but it doesn't show now....
I think you also need to call SetScrollRate().
Use the source, Luke!

User avatar
doublemax
Moderator
Moderator
Posts: 15860
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: pan and scale a wxScrollWindow

Post by doublemax » Thu Aug 28, 2014 8:49 am

and if i want a "infinit" wxScrollWindow, is it possible?
I mean wherever i drag, there is always the window
Thoeretically possible, just not with wxScrolledWindow which is based on the concept of a defined virtual size. Also when putting native controls onto the panel, you need to consider that Windows still uses 16bit values for coordinates in some places. I'm not sure it would be possible to place a wxButton at (100000, 100000). You should try that before continuing in that direction.

Possible workaround for the "infinite area" problem: Make sure there is a 15% (or any other useful value) border around all controls. Recalculate that bounding box whenever controls are added, deleted or moved. That way there is always some free space where the user can place new items.
Use the source, Luke!

gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: pan and scale a wxScrollWindow

Post by gpu » Thu Aug 28, 2014 9:32 am

thanks :)
so ur opinion is that don't use SetDeviceOrigin,
i now have problem:
(1)i use mouseWheel event to scale the window, and i set the virtual size, it works fine. But when i drag the scrollbar, the background drawed lines are now fresh, i mean ,how can i get the scrollbar event when i draging and dragdone it
(2)SetDeviceOrigin is not used, so how can i pan the window, use startview or sth? and i think the Pan event i deal with can do the same thing when i drag the scrollbar, so how i unify them?

gpu
Experienced Solver
Experienced Solver
Posts: 92
Joined: Tue Aug 12, 2014 3:46 am

Re: pan and scale a wxScrollWindow

Post by gpu » Thu Aug 28, 2014 9:40 am

plus, when i wheel the mouse, not only the Scale things i do works, but also the srcollbar(verticle one) is moving...i think it's the defalut event which i have to deal

User avatar
doublemax
Moderator
Moderator
Posts: 15860
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: pan and scale a wxScrollWindow

Post by doublemax » Thu Aug 28, 2014 10:15 am

But when i drag the scrollbar, the background drawed lines are now fresh, i mean ,how can i get the scrollbar event when i draging and dragdone it
I'm not quite sure what you mean. During the scrolling the window should receive paint events and redraw itself. If there are redraw errors, check your drawing code. Besides that you can still catch the scroll events given in the documentation:
http://docs.wxwidgets.org/trunk/classwx_scrolled.html
SetDeviceOrigin is not used, so how can i pan the window, use startview or sth?
The Scroll() method is really not that hard to find.
http://docs.wxwidgets.org/trunk/classwx ... d065907f69
plus, when i wheel the mouse, not only the Scale things i do works, but also the srcollbar(verticle one) is moving...
I would recommend to use CTRL+Mouse wheel for the zooming which is the quasi standard.
Use the source, Luke!

Post Reply