344 if len(tabs) == 1: |
344 if len(tabs) == 1: |
345 return tabs[0] |
345 return tabs[0] |
346 split = None |
346 split = None |
347 for idx, tab in enumerate(tabs): |
347 for idx, tab in enumerate(tabs): |
348 if len(tab["pages"]) == 0: |
348 if len(tab["pages"]) == 0: |
349 raise ValueError, "Not possible" |
349 raise ValueError, "Not possible" |
350 if tab["size"][0] == rect.width: |
350 if tab["size"][0] == rect.width: |
351 if tab["pos"][1] == rect.y: |
351 if tab["pos"][1] == rect.y: |
352 split = (wx.TOP, float(tab["size"][1]) / float(rect.height)) |
352 split = (wx.TOP, float(tab["size"][1]) / float(rect.height)) |
353 split_rect = wx.Rect(rect.x, rect.y + tab["size"][1] + TAB_BORDER, |
353 split_rect = wx.Rect(rect.x, rect.y + tab["size"][1] + TAB_BORDER, |
354 rect.width, rect.height - tab["size"][1] - TAB_BORDER) |
354 rect.width, rect.height - tab["size"][1] - TAB_BORDER) |
822 |
822 |
823 def SaveTabLayout(self, notebook): |
823 def SaveTabLayout(self, notebook): |
824 tabs = [] |
824 tabs = [] |
825 for child in notebook.GetChildren(): |
825 for child in notebook.GetChildren(): |
826 if isinstance(child, wx.aui.AuiTabCtrl): |
826 if isinstance(child, wx.aui.AuiTabCtrl): |
827 pos = child.GetPosition() |
827 if child.GetPageCount() > 0: |
828 tab = {"pos": (pos.x, pos.y), "pages": []} |
828 pos = child.GetPosition() |
829 tab_size = child.GetSize() |
829 tab = {"pos": (pos.x, pos.y), "pages": []} |
830 for page_idx in xrange(child.GetPageCount()): |
830 tab_size = child.GetSize() |
831 page = child.GetWindowFromIdx(page_idx) |
831 for page_idx in xrange(child.GetPageCount()): |
832 if not tab.has_key("size"): |
832 page = child.GetWindowFromIdx(page_idx) |
833 tab["size"] = (tab_size[0], tab_size[1] + page.GetSize()[1]) |
833 if not tab.has_key("size"): |
834 tab_infos = self.GetTabInfos(page) |
834 tab["size"] = (tab_size[0], tab_size[1] + page.GetSize()[1]) |
835 if tab_infos is not None: |
835 tab_infos = self.GetTabInfos(page) |
836 tab["pages"].append((tab_infos, page_idx == child.GetActivePage())) |
836 if tab_infos is not None: |
837 tabs.append(tab) |
837 tab["pages"].append((tab_infos, page_idx == child.GetActivePage())) |
|
838 tabs.append(tab) |
838 tabs.sort(lambda x, y: cmp(x["pos"], y["pos"])) |
839 tabs.sort(lambda x, y: cmp(x["pos"], y["pos"])) |
839 size = notebook.GetSize() |
840 size = notebook.GetSize() |
840 return ComputeTabsLayout(tabs, wx.Rect(1, 1, size[0] - NOTEBOOK_BORDER, size[1] - NOTEBOOK_BORDER)) |
841 return ComputeTabsLayout(tabs, wx.Rect(1, 1, size[0] - NOTEBOOK_BORDER, size[1] - NOTEBOOK_BORDER)) |
841 |
842 |
842 def LoadTab(self, notebook, page_infos): |
843 def LoadTab(self, notebook, page_infos): |