From: Mark D. <mar...@zn...> - 2007-03-28 18:33:31
|
Hi, Having to set the user scale all over the place is poor, so you could do the following in your drawing canvas class. 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 ]; } By overriding PrepareDC, you can just put setting the user scale in the one place. EXCEPT: You do still have to put it in one extra place - your OnDraw routine. OnDraw prepares the DC for you - which should still work - but doesn't because PrepareDC is apparantly just a wrapper for DoPrepareDC. Internally, OnDraw calls DoPrepareDC directly. DoPrepareDC is not wrapped by wxPerl so we can't override that. Gnash. So for now, you'll need ... sub OnDraw { my ($self, $dc) = @_; $dc->SetUserScale($self->get_user_scale() ); ..... ..... But at least it is only in one place. 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. B.T.W. I do have to create something that uses all these functions myself in the near future so having you 'debug' the process in your work is very useful to me too. Regards Mark Mark Dootson wrote: > Vaughn Staples wrote: >> Mark, >> >> I've used the standard "ColourDialog" in wxPerl; does there also exist >> ones for selecting line styles & fill patterns that are commonly used >> when drawing on a canvas? I'm suspecting that what I'm seeking doesn't >> exist ... I just want to rule it out. >> > > Hi, > > You'll need your own custom dialogs for these things. > > On zooming, use $dc->SetUserScale. > > For example > > $dc->SetUserScale(0.5,0.5) > > zooms to 50%. > > You have to call SetUserScale everytime you use the dc, so in addition to in your drawing routines it also needs to go into your mouse events routines BEFORE you call $event->GetLogicalPosition( $dc ); > > Regards > > Mark > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users |