"klaas.holwerda" <n...@klaasholwerda.nl> wrote: (06/05/2009 23:00)
> >Hi, > >To add something more, it looks like you need some canvas like sample. >wxLua contains wxluacan sample/app. >And based on that i made this: >http://www.pontademangue.com/canvas/ > >wxArt2D contains much more then the above. But i think it would be an >overkill. >Although it is more are less completely wrapped to wxLua now. > >I think you need to optimize drawing the background image as explained, >and use it as background for the canvas. > >Still the above samples are not wrapped into Lua, maybe we actually >should make some simple canvas for wxLua. > >Anyway, hope this helps a bit too. > >Klaas > That's very cool, (even the basic Luacan is neat given the free moving and placing and transparency, etc), but on my system it called for a few DLL's not native to it, and it does more than I need, I am fairly certain that the main binary distribution of wxLua contains all I need, somewhere, somehow. I've noticed that the W98 SE rendering failure takes two forms, one with, and one without, scrollbars. That means the bitmap sometimes fails to form before it can be shown, because the code is failing to get its size prior to setting the scrollbars. Not sure what all that means yet, though I think making the bitmap into smaller sections only delays the onset of the problem, so either I go with a single one for ease and convenience and I accept the occasional need to wait or reboot, or I go all out to emulate the Google Maps tiling system, which I want to avoid doing because it's complex. For now I've reverted to one of my older ideas, having learned stuff since that made it appear to work right. Initially I'd used a wxStaticBitmap() to hold the huge chart image. This actually works well despite not being intended for that use, and it simplifies the OnPaint handling because I only need to redraw the overlaid stuff, not the chart itself, if I do it that way. I've translated the direct layer draw idea to a more standard form that draws the image as I've been told I ought, though, and this also works: --Complete script, as simplified as I know how, written for wxLua v2.8.7.0. function main() FRAME=wx.wxFrame(wx.NULL,-1,"GPS Plot",wx.wxDefaultPosition,wx.wxSize(1024,768),wx.wxDEFAULT_FRAME_STYLE) FRAME:CreateStatusBar() FRAME:SetStatusText(" ") --NOTE! Omitting this status bar causes display bother, try it... FRAME:Centre() FRAME:Show(true) BITMAP=wx.wxBitmap("Very Big Image.jpg") --Ideally try something like 9000,6000 px, on W98 SE, to emulate context. :) local X,Y=BITMAP:GetWidth(),BITMAP:GetHeight() SCROLL=wx.wxScrolledWindow(FRAME,-1) SCROLL:SetScrollbars(1,1,X,Y) LAYER=wx.wxPanel(SCROLL,-1,wx.wxPoint(0,0),wx.wxSize(X,Y)) --Layer must be created before chart panel. PANEL=wx.wxPanel(SCROLL,-1,wx.wxPoint(0,0),wx.wxSize(X,Y)) FRAME:Connect(wx.wxID_EXIT,wx.wxEVT_COMMAND_MENU_SELECTED,function(E) FRAME:Close(true) end ) LAYER:Connect(wx.wxEVT_LEFT_DOWN,OnLeftDown) LAYER:Connect(wx.wxEVT_MOTION,OnMotion) LAYER:Connect(wx.wxEVT_ERASE_BACKGROUND,function() end) PANEL:Connect(wx.wxEVT_ERASE_BACKGROUND,function() end) LAYER:Connect(wx.wxEVT_PAINT,OnPaint) end --==================== Mouse Handling ====================-- MX,MY,VX,VY=0,0,0,0 function OnLeftDown(E) MX,MY,VX,VY=wx.wxGetMousePosition():GetX(),wx.wxGetMousePosition():GetY(),SCROLL:GetViewStart() end function OnMotion(E) if E:LeftIsDown() then SCROLL:Scroll(VX+MX-wx.wxGetMousePosition():GetX(),VY+MY-wx.wxGetMousePosition():GetY()) end end --==================== Track Drawing =====================-- function OnPaint(E) local DC=wx.wxPaintDC(PANEL) -chart panel must be drawn before layer data. if BITMAP then DC:DrawBitmap(BITMAP,0,0,false) end DC:delete() local DC,P=wx.wxPaintDC(LAYER),wx.wxPen() P:SetColour(255,0,0) P:SetWidth(2) DC:SetPen(P) DC:DrawLine(0,0,600,600) DC:DrawLine(600,600,1200,0) P:delete() DC:delete() end --=======================================================-- main() One thing I failed to manage was drawing on demand to the layer in OnLeftDown, unless I build the draws into a table to be read from and drawn in OnPaint. I also tried drawing into a MemoryDC to see if I could use a new bitmap overlaid over the chart. I noticed that the MemoryDC would contain various random stuff as background, which relates to the absence of defined background that allows the current layer-draw trick to work, because the layer 'appears' over the existing chart background. I don't know if this comes under the general heading of 'undefined behaviour' or not, but the consistency seems to suggest I can trust it, or perhaps learn more about it so I can exploit it more correctly. ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users