I've made some progress on this. It's not done by far, but I thought I would share for those who might be interested.
While chatting with Scott (poppabear) he mentioned the "Lua panels". This got me thinking and I now have an embedded Lua panel loading my image and returning the mouse X and Y coordinates when the left mouse button is clicked. This gets me closer to a component that can load an image and provide feed back when clicked on - think image maps like in HTML. I'll probably use a second bitmap that mirrors the image shown and provides quick lookup if the user clicked in a roped off area or not.
To use this, add a Lua Panel to your screen set. Cut-n-paste the code below into the script property of the panel. Be sure to choose a different image. My images are broken out into directory image of the screen set (ie. the .set file has been unzipped). I will eventually need to know how to read a file from the zip if I want to keep my images in the screen set. Brian, Steve, et al - if you have any guidance on how to read images from the screen set file, I would be very interested in hearing how.
I still need to wire in the proper events to catch resizing of the panel to resize the image on the fly.
function onPaint (event)
local dc = wx.wxPaintDC(panel);
local image = wx.wxImage();
if (not image:LoadFile('./screens/MyStdMill/images/MSM_Probe_1.png', wx.wxBITMAP_TYPE_PNG)) then
wx.wxLogError("Could not load image from '%s'!", imagePath);
dc:delete();
return;
end
--image:Resize(panel.getSize());
local bitmap = wx.wxBitmap(image);
dc:DrawBitmap (bitmap, 0,0, true);
dc:delete ();
end
function onLeftUp (event)
local mouseX = event:GetX();
local mouseY = event:GetY();
wx.wxMessageBox("LEFT CLICK - X: "..tostring(mouseX)..", Y: "..tostring(mouseY));
end
function onSize (event)
local size = panel.getSize();
wx.wxMessageBox('Width: %d, Height: %d', size.getWidth(), size.getHeight());
end
panel = mcLuaPanelParent
-- connect the paint event handler function with the paint event
panel:Connect(wx.wxEVT_PAINT, onPaint)
panel:Connect(wx.wxEVT_LEFT_UP, onLeftUp);
panel:Connect(wx.wxEVT_SIZE, onSize);
-Freeman