From: Mark D. <mar...@zn...> - 2007-03-28 22:18:49
|
Mark Dootson wrote: > > I shall test wrapping DoPrepareDC and post a diff a little later. If you are on MSWin, I will have incorporated changes in PPMs too. > Or maybe not! I have wrapped DoPrepareDC and that works fine. It still doesn't really solve the issue though: Within wxWidgets itself, there is a hack used to make OnDraw work. The base class for ScrolledWindow checks if any handler of a wxPaintEvent in a derived class actually did anything. If it didn't, the base class still calls its own handler for the event. That handler does the following. wxPaintDC dc(m_win); DoPrepareDC(dc); OnDraw(dc); note: the problem here is that the base class DoPrepareDC is called - NOT any DoPrepareDC in any derived class. Gnash. So, for now, to do what I suggested in the earlier post, you would do as follows. (You don't actually need a separate OnDraw sub anymore of course) sub new { ....... ....... EVT_PAINT( $self, \&OnPaint ); $self->set_user_scale(0.5,0.5); ....... ....... } sub OnPaint { my ($self, $event) = @_; $event->Skip(1); my $dc = Wx::PaintDC->new($self); $self->PrepareDC( $dc ); $self->OnDraw($dc); } sub OnDraw { my($self, $dc) = @_; ........... ........... } sub PrepareDC { my ($self, $dc) = @_; $self->SUPER::PrepareDC( $dc ); $dc->SetUserScale( $self->get_user_scale() ); } sub get_user_scale { my ($self) = @_; return @{ $self->{_user_scale} }; } sub set_user_scale { my ($self, $scalex, $scaley) = @_; $self->{_user_scale} = [ $scalex, $scaley ]; } --------------------------------------------------- It would be nice to have wxPerl act like the C wxWidgets docs suggest so I'll not post a diff for DoPrepareDC. To make that work would mean installing a default wxPaintEvent handler for wxScrolledWindow in wxPerl. Regards Mark |