Hello. I'm trying to make a GUI for GPS chart and track display. I worked this 
code up from bits taken from samples, and reference to the wxWidgets 
descriptions of functions and such, and some reductions of my own devising in 
the part that loads and displays the chart image. I can't find any indication 
that this mailing lists accepts attachments so I've risked wordwrap mangling 
with the script at the end of this message.

I don't have the grounding to understand the details behind wxLua, I can only 
learn from example (and lots of trial and error), and although I made this work 
very well for dragging the content like a page in a PDF reader, it's obviously 
not constructed right, and I've driven myself alternately crazy and stupified 
for weeks and failed to improve it no matter what snippets I find and try. 
Playing with scroll events and refreshes and updates all fail, they'd just add 
weight even if they did work, this is too broken for that to help... That it 
works at all gives a good idea what I want, but I'd like to see how it should 
be done.

To make it show a 'chart', edit the IMAGE:LoadFile line to point to some large 
image. The diagonal red line, top left, has to display on the chart at all 
times unless asked not to. I worked out the whole track draw code, but I left 
only the simplest content to save you time looking at the code.

BLANK is an unseen panel of smallest possible size, which is shown and hidden 
each time the window content is dragged around. It was a tortuous discovery, 
but it makes the redraw of the chart and track work as I want them. They also 
redraw as I want if the frame is obscured and uncovered, but not when scrolling 
with any method. The scroll window itself won't work without the status bar! No 
idea why, but it makes the scroll window about 2 pixels wide if absent! If 
anything proves just how broken this is, it's that status bar weirdness.

After several tens of loads during a session, the chart image fails to draw, 
suggesting that some resource is being created and not destroyed when it should 
be, and I can't tell which, if any.

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()
  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
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to