From: John L. <jla...@gm...> - 2009-03-01 09:02:04
|
On Sat, Feb 28, 2009 at 9:34 AM, lostgallifreyan <los...@gm...> wrote: > > Ultimately I want to zoom the view in and out as well as pan it, so if you have clues on how to do that, please let me know. > > > SCRIPT: > > function main() > FRAME=wx.wxFrame(wx.NULL,-1,"GPS Plot",wx.wxDefaultPosition,wx.wxSize(1024,768),wx.wxDEFAULT_FRAME_STYLE) > FRAME:Centre() FRAME:Show(true) > FRAME:CreateStatusBar() > > IMAGE=wx.wxBitmap():ConvertToImage() > IMAGE:LoadFile("Chart.jpg") > local X,Y=IMAGE:GetWidth(),IMAGE:GetHeight() > SCROLL=wx.wxScrolledWindow(FRAME,-1) SCROLL:SetScrollbars(1,1,X,Y) > CHART=wx.wxStaticBitmap(SCROLL,-1,wx.wxBitmap(IMAGE),wx.wxPoint(0,0),wx.wxSize(X,Y)) IMAGE:Destroy() This next wxPanel is on top of the CHART window. I would suggest drawing the image on a wxPanel yourself since the wxStaticBitmap is really meant for small images. You can either let the scrolled window take care of moving the image or get the coords from the scrolled window and crop the image before drawing. Hope this helps, John > LAYER=wx.wxPanel(SCROLL,-1,wx.wxPoint(0,0),wx.wxSize(X,Y)) > BLANK=wx.wxPanel(SCROLL,-1,wx.wxPoint(0,0),wx.wxSize(0,0)) > > CHART:Connect(wx.wxEVT_LEFT_DOWN,OnLeftDown) > CHART:Connect(wx.wxEVT_MOTION,OnMotion) > LAYER:Connect(wx.wxEVT_PAINT,OnPaint) > end > > --==================== Mouse Handling ====================-- > > MX,MY,VX,VY=0,0,0,0 > > function OnLeftDown(event) > MX,MY,VX,VY=wx.wxGetMousePosition():GetX(),wx.wxGetMousePosition():GetY(),SCROLL:GetViewStart() > end > > function OnMotion(event) > if event:LeftIsDown() then > SCROLL:Scroll(VX+MX-wx.wxGetMousePosition():GetX(),VY+MY-wx.wxGetMousePosition():GetY()) > BLANK:Show(nil) BLANK:Show(1) > end > end > > --==================== Track Drawing =====================-- > > function OnPaint(event) > local DC=wx.wxPaintDC(LAYER) > DC:SetPen(wx.wxPen(wx.wxColour(255,0,0),1,wx.wxSOLID)) > DC:DrawLine(0,0,600,600) > DC:delete() > end > > --====================================================================================================================-- > > main() > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > wxlua-users mailing list > wxl...@li... > https://lists.sourceforge.net/lists/listinfo/wxlua-users > |