Sorry, Robin, either I didn't make my question clear or I am misunderstanding even more than normal. You seem to be answering a question about a screen DC. My screen DC is fine; I am asking about printing that. In other words, going from a PaintDC in a ScrolledWindow, to a PrintDC that corresponds to a piece of paper.
On the screen, I don't care if part of the drawing has scrolled off the window. That part all works fine. But when I print the drawing, I want to print all of it, including the part that's scrolled off the window.
So my question is, how to scale the drawing in the ScrolledWindow, onto a single printed page.
I can do that easily if the drawing doesn't scroll; I just use the window size. I can do it for a single drawing that has scrolled; I use the VirtualSize of the ScrolledWindow and scale that down to a single page. The problem arises because in the wx.FlatNotebook, once one page has scrolled the rest are all scrolled even though the drawing on the next page doesn't need a scroll.
How can I tell the actual dimensions of each drawing in the wx.Notebook -- distinguishing whether they actually needed to scroll, or if they fit on the window and it was some other drawing that needed to be scrolled?
I hope this is a little clearer. Sorry for the incoherence.
Ian
···
---------- Forwarded message ----------
From: "Ian York" <iayork@iayork.com>
To: wxPython-users@lists.wxwidgets.org
Date: Tue, 19 Feb 2008 08:03:14 -0500
Subject: Size of a DC in a ScrolledWindow?
MacOS 10.5, Python2.5.1, wxPython 2.8.4.0
I have a wx.FlatNotebook containing several pages of
wx.ScrolledWindows. Each ScrolledWindow contains an independent wx.DC
drawing, some of which may require scrolling to see completely, others
of which may not.
When I print one of the pages, I can use either GetClientSize(), which
returns the unscrolled size, or GetVirtualSize(), which returns the
size of the full drawing if it's spilled over off the visible page
(i.e. requires scrolling). I use GetVirtualSize so I can print the
whole drawing. This is all fine.
The problem arises if I have two drawings, one of which spills over
and one of which does not. Both drawings register as having the same
GetVirtualSize(), even though only one actually needs it, so the
drawing prints too small.
I've tried dc.GetClippingBox(), dc.GetSize(). and dc.MaxX(),
dc.MinX(), dc.MaxY(), dc.MinY(), but all the dc info seems to be
visible size, ignoring the part that's off the screen (i.e. these
commands all return the same info as GetClientSize(), which is too
small if it's scrolled off the window).
Is there a way of getting accurate dc sizes in a ScrolledWindow, or
otherwise determining if a drawing actually requires scrolling or
not?
Thanks,
Ian
--
Ian York (iayork@iayork.com) <http://www.iayork.com/>
"-but as he was a York, I am rather inclined to suppose him a
very respectable Man." -Jane Austen, The History of England
---------- Forwarded message ----------
From: Robin Dunn <robin@alldunn.com>
To: wxPython-users@lists.wxwidgets.org
Date: Tue, 19 Feb 2008 16:44:11 -0800
Subject: Re: [wxPython-users] Size of a DC in a ScrolledWindow?
Ian York wrote:
> MacOS 10.5, Python2.5.1, wxPython 2.8.4.0
>
> I have a wx.FlatNotebook containing several pages of
> wx.ScrolledWindows. Each ScrolledWindow contains an independent wx.DC
> drawing, some of which may require scrolling to see completely, others
> of which may not.
>
> When I print one of the pages, I can use either GetClientSize(), which
> returns the unscrolled size, or GetVirtualSize(), which returns the
> size of the full drawing if it's spilled over off the visible page
> (i.e. requires scrolling). I use GetVirtualSize so I can print the
> whole drawing. This is all fine.
>
> The problem arises if I have two drawings, one of which spills over
> and one of which does not. Both drawings register as having the same
> GetVirtualSize(), even though only one actually needs it, so the
> drawing prints too small.
>
> I've tried dc.GetClippingBox(), dc.GetSize(). and dc.MaxX(),
> dc.MinX(), dc.MaxY(), dc.MinY(), but all the dc info seems to be
> visible size, ignoring the part that's off the screen (i.e. these
> commands all return the same info as GetClientSize(), which is too
> small if it's scrolled off the window).
>
> Is there a way of getting accurate dc sizes in a ScrolledWindow, or
> otherwise determining if a drawing actually requires scrolling or
> not?
I think you have a couple of the basic concepts turned around. First,
the DC will only ever be the size of the physical device (the window),
the virtual size is just a helper provided by wx to help you deal with
scrolling. Second, you should have a way to know how much space your
drawing will need, and then set the virtual size of the scrolled window
to be that size. Then if the virtual size ends up being bigger than the
client size then you will get scrollbars, otherwise there will be no
scrollbars. Your drawing code really shouldn't care if there are
scrollbars or not, it just needs to draw as if there is no scrolling and
wx.ScrolledWindow will take care of the rest. You just need to call
self.PrepareDC(dc) at the beginning of the draw and it will reset the
DC's origin to take the current scroll position into account automatically.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
--
Ian York (iayork@iayork.com) <http://www.iayork.com/>
"-but as he was a York, I am rather inclined to suppose him a
very respectable Man." -Jane Austen, The History of England