def __init__(self, parent, pos=(0,0), size=wx.DefaultSize): wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, pos=pos, size=size, style = wx.EXPAND) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundColour(BACKGROUND_COLOUR) self.parent = parent dt = MyFileDropTarget(self) self.SetDropTarget(dt) self.useMario = False self.backBitmap = None self.needBitmap = True self.onMotion = False self.marios = [wx.Bitmap(os.path.join(IMAGES_PATH, 'Mario%d.png' % i), wx.BITMAP_TYPE_PNG) for i in [1,2,3,2,4,5,6,5]] if PLATFORM == "darwin": fontsize = 10 else: fontsize = 8 self.font = wx.Font(fontsize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) self.font_pos = wx.Font(fontsize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) self.trajectories = [Trajectory(self, i+1) for i in range(MAX_STREAMS)] self.memorizedTrajectory = Trajectory(self, -1) self.memorizedId = {} self.midiTranspose = True self.midiXposition = 0 self.midiOctaveSpread = 2 self.fxballs = {} if len(self.fxballs) != 0: self.fxball = self.fxballs[0] self.fxballValues = [fx for fx in self.fxballs.values()] self.screenOffset = 2 self.sndBitmap = None self.selected = self.trajectories[0] self.bitmapDict = {} self.closed = 0 self.oscilPeriod = 2 self.oscilScaling = 1 self.mode = TRAJTYPES[0] self.pointerPos = None self.SetColors(outline=(255,255,255), bg=(30,30,30), fill=(184,32,32), rect=(0,255,0), losa=(0,0,255), wave=(70,70,70)) self.currentSize = tuple(self.GetSize()) self.Bind(wx.EVT_KEY_DOWN, self.KeyDown) self.Bind(wx.EVT_KEY_UP, self.KeyUp) self.Bind(wx.EVT_LEFT_DOWN, self.MouseDown) self.Bind(wx.EVT_LEFT_DCLICK, self.MouseDoubleClick) self.Bind(wx.EVT_LEFT_UP, self.MouseUp) self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) self.Bind(wx.EVT_MOTION, self.MouseMotion) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnResize) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) if sys.platform == "win32": self.dcref = wx.BufferedPaintDC else: self.dcref = wx.PaintDC
def loadFile(self, path): if self.midiSettings.IsShown(): self.midiSettings.Hide() self.panel.removeAllFxBalls() f = open(path, 'r') msg = f.read() f.close() result, method = xmlrpclib.loads(msg) dict = result[0] if 'new_soundgrain_file.sg' in path: self.currentFile = None self.currentPath = None title = '%s %s - ' % (NAME, SG_VERSION) self.status.SetStatusText("") else: self.currentFile = path self.currentPath = os.path.split(path)[0] title = '%s %s - %s' % (NAME, SG_VERSION, os.path.split(self.currentFile)[1]) self.panel.trajectories = [ Trajectory(self.panel, i + 1) for i in range(MAX_STREAMS) ] self.panel.memorizedTrajectory = Trajectory(self.panel, -1) self.panel.memorizedId = {} self.controls.setSelected(0) self.setState(dict) self.SetTitle(title) self.panel.needBitmap = True size = self.GetSize() if size[0] > self.screen_size[0]: x = self.screen_size[0] - 50 else: x = size[0] if size[1] > self.screen_size[1]: y = self.screen_size[1] - 50 else: y = size[1] size = (x, y) wx.CallAfter(self.panel.Refresh) wx.CallLater(100, self.SetSize, size)