#!/usr/bin/env python

## Set a path to an Image file here:

ImageFile = "FloorPlan.jpg" 


import wx

## import the installed version
from wx.lib.floatcanvas import NavCanvas, FloatCanvas

## import a local version
#import sys
#sys.path.append("../")
#from floatcanvas import NavCanvas, FloatCanvas

class DrawFrame(wx.Frame):

    """
    A frame used for the FloatCanvas Demo

    """

    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        self.CreateStatusBar()

        # Add the Canvas
        Canvas = NavCanvas.NavCanvas(self,
                                     ProjectionFun = None,
                                     BackgroundColor = "DARK SLATE BLUE",
                                     ).Canvas
        Canvas.MaxScale=4
        self.Canvas = Canvas

        FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove ) 

        
        # create the image:
        image = wx.Image(ImageFile)
         
        img = FloatCanvas.ScaledBitmap2( image,
                                         (0,0),
                                         Height=image.GetHeight(),
                                         Position = 'tl',
                                         )
        Canvas.AddObject(img)
        #img.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Binding)
        self.Show()
        Canvas.ZoomToBB()

    def OnMove(self, event):
        """
        Updates the status bar with the world coordinates

        """
        self.SetStatusText("%i, %i"%tuple(event.Coords))

    def Binding(self, event):
        print "Writing a png file:"
        self.Canvas.SaveAsImage("junk.png")
        print "Writing a jpeg file:"
        self.Canvas.SaveAsImage("junk.jpg",wx.BITMAP_TYPE_JPEG)


app = wx.App(False)
F = DrawFrame(None, title="FloatCanvas Demo App", size=(700,700) )
app.MainLoop()
    
    
    
    









