From 9505d02edd75496301ff2e37d820d35f9871b289 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Tue, 9 Nov 2010 13:51:43 +0200 Subject: [PATCH] Boundry check + mouse capture --- miniframe.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/miniframe.py b/miniframe.py index 46ac51bf5..61579a6ff 100644 --- a/miniframe.py +++ b/miniframe.py @@ -506,6 +506,8 @@ class PFTabsContainer(wx.Window): self.dragTrigger = 5 self.UpdateTabsPosition() self.Refresh() + if self.HasCapture(): + self.ReleaseMouse() return if self.startDrag: @@ -595,19 +597,24 @@ class PFTabsContainer(wx.Window): if self.dragTrigger < 0: self.dragging = True self.dragTrigger = 5 + self.CaptureMouse() else: self.dragTrigger -= 1 if self.dragging: - self.draggedTab.SetPosition( (mposx - self.dragx, self.dragy)) + dtx = mposx - self.dragx w,h = self.draggedTab.GetSize() + if dtx < 0: + dtx = 0 + if dtx + w > self.tabContainerWidth + 9: + dtx = self.tabContainerWidth - w + 9 + self.draggedTab.SetPosition( (dtx, self.dragy)) + index = self.tabs.index(self.draggedTab) leftTab = self.GetTabAtLeft(index) rightTab = self.GetTabAtRight(index) - dtx = mposx - self.dragx - if leftTab: lw,lh = leftTab.GetSize() lx,ly = leftTab.GetPosition() @@ -741,8 +748,8 @@ class PFTabsContainer(wx.Window): tabMinWidth = mw if self.GetTabsCount() >0: - if (self.GetTabsCount()) * (tabMinWidth - 9) > self.tabContainerWidth - self.reserved: - self.tabMinWidth = float(self.tabContainerWidth - self.reserved) / float(self.GetTabsCount()) + 9 + if (self.GetTabsCount()) * (tabMinWidth - 9) > self.tabContainerWidth: + self.tabMinWidth = float(self.tabContainerWidth) / float(self.GetTabsCount()) + 9 else: self.tabMinWidth = tabMinWidth