00001
00002
00003
00004
00005
00006
00007
00008 OC = __import__('objectclasses')
00009
00010
00011
00012
00013
00014
00015
00016
00017 def flatten(my_list):
00018
00019 if type(my_list) != type([]):
00020 return [my_list]
00021 if my_list == []:
00022 return my_list
00023
00024 return flatten(my_list[0]) + flatten(my_list[1:])
00025
00026
00027
00028
00029
00030
00031
00032
00033 def prepostquotes(thestring):
00034
00035 return '"' + thestring + '"'
00036 '''
00037 ##
00038 # Drag and drop text functionality class.
00039 #
00040 # Here we define what that should be done on drop
00041 #
00042 class TextDropTarget(wxTextDropTarget):
00043
00044 ##
00045 # Constructor.
00046 #
00047 # Parameters:
00048 # @obj - The object associated with the drop
00049 # @mainwin - The MainWindow instance (for communication)
00050 #
00051 def __init__(self,obj,mainwin):
00052
00053 wxTextDropTarget.__init__(self)
00054
00055 self.obj = obj
00056 self.appwin = mainwin
00057
00058 ##
00059 # Method that is invoked on the drop of an object.
00060 #
00061 # Parameters:
00062 # @x - x position (coord) of the dropped object
00063 # @y - y position (coord) of the dropped object
00064 # @data - data (string) set to the dropped object
00065 #
00066 def OnDropText(self,x,y,data):
00067
00068 tmp_info = data.split("|") # We have defined a string to be associated with every drag and drop object
00069 # First part is the systemname, second part the name of the object type dropped
00070 # They are separated by a '|'.
00071
00072 if tmp_info[2] == "Device":
00073 tmp_devices = self.appwin.CreateDeviceClick(None) # Open Create Device Window
00074
00075 if tmp_devices != False and len(tmp_devices) > 0: # If we created one or more devices...
00076 i = 0
00077 for tmp_device in tmp_devices: # Lay them out nicely in the visual window
00078 x_offset,y_offset = self.appwin.GetVisWindow().CalcUnscrolledPosition(x,y+i)
00079 self.appwin.GetVisWindow().CreateNode(x_offset,y_offset,tmp_device)
00080 i += 5
00081
00082 else: #So far, only support for Devices...
00083 print "Dropped an unknown object type"
00084
00085 '''
00086