IDEFrame.py
changeset 1855 f33942053466
parent 1850 614396cbffbf
child 1878 fb73a6b6622d
equal deleted inserted replaced
1854:cff5179cc601 1855:f33942053466
   295     if len(tabs) == 0:
   295     if len(tabs) == 0:
   296         return tabs
   296         return tabs
   297     if len(tabs) == 1:
   297     if len(tabs) == 1:
   298         return tabs[0]
   298         return tabs[0]
   299     split = None
   299     split = None
       
   300     split_id = None
   300     for idx, tab in enumerate(tabs):
   301     for idx, tab in enumerate(tabs):
   301         if len(tab["pages"]) == 0:
   302         if len(tab["pages"]) == 0:
   302             raise ValueError("Not possible")
   303             raise ValueError("Not possible")
   303         if tab["size"][0] == rect.width:
   304         if tab["size"][0] == rect.width:
   304             if tab["pos"][1] == rect.y:
   305             if tab["pos"][1] == rect.y:
   307                                      rect.width, rect.height - tab["size"][1] - TAB_BORDER)
   308                                      rect.width, rect.height - tab["size"][1] - TAB_BORDER)
   308             elif tab["pos"][1] == rect.height + 1 - tab["size"][1]:
   309             elif tab["pos"][1] == rect.height + 1 - tab["size"][1]:
   309                 split = (wx.BOTTOM, 1.0 - float(tab["size"][1]) / float(rect.height))
   310                 split = (wx.BOTTOM, 1.0 - float(tab["size"][1]) / float(rect.height))
   310                 split_rect = wx.Rect(rect.x, rect.y,
   311                 split_rect = wx.Rect(rect.x, rect.y,
   311                                      rect.width, rect.height - tab["size"][1] - TAB_BORDER)
   312                                      rect.width, rect.height - tab["size"][1] - TAB_BORDER)
       
   313             split_id = idx
   312             break
   314             break
   313         elif tab["size"][1] == rect.height:
   315         elif tab["size"][1] == rect.height:
   314             if tab["pos"][0] == rect.x:
   316             if tab["pos"][0] == rect.x:
   315                 split = (wx.LEFT, float(tab["size"][0]) / float(rect.width))
   317                 split = (wx.LEFT, float(tab["size"][0]) / float(rect.width))
   316                 split_rect = wx.Rect(rect.x + tab["size"][0] + TAB_BORDER, rect.y,
   318                 split_rect = wx.Rect(rect.x + tab["size"][0] + TAB_BORDER, rect.y,
   317                                      rect.width - tab["size"][0] - TAB_BORDER, rect.height)
   319                                      rect.width - tab["size"][0] - TAB_BORDER, rect.height)
   318             elif tab["pos"][0] == rect.width + 1 - tab["size"][0]:
   320             elif tab["pos"][0] == rect.width + 1 - tab["size"][0]:
   319                 split = (wx.RIGHT, 1.0 - float(tab["size"][0]) / float(rect.width))
   321                 split = (wx.RIGHT, 1.0 - float(tab["size"][0]) / float(rect.width))
   320                 split_rect = wx.Rect(rect.x, rect.y,
   322                 split_rect = wx.Rect(rect.x, rect.y,
   321                                      rect.width - tab["size"][0] - TAB_BORDER, rect.height)
   323                                      rect.width - tab["size"][0] - TAB_BORDER, rect.height)
       
   324             split_id = id
   322             break
   325             break
   323     if split is not None:
   326     if split is not None:
   324         split_tab = tabs.pop(idx)
   327         split_tab = tabs.pop(split_id)
   325         return {"split": split,
   328         return {"split": split,
   326                 "tab": split_tab,
   329                 "tab": split_tab,
   327                 "others": ComputeTabsLayout(tabs, split_rect)}
   330                 "others": ComputeTabsLayout(tabs, split_rect)}
   328     else:
   331     else:
   329         if SimplifyTabLayout(tabs, rect):
   332         if SimplifyTabLayout(tabs, rect):
   330             return ComputeTabsLayout(tabs, rect)
   333             return ComputeTabsLayout(tabs, rect)
   331     return tabs
   334     return tabs
   332 
   335 
   333 
   336 
   334 UNEDITABLE_NAMES_DICT = dict([(_(name), name) for name in UNEDITABLE_NAMES])
   337 UNEDITABLE_NAMES_DICT = dict([(_(n), n) for n in UNEDITABLE_NAMES])
   335 
   338 
   336 
   339 
   337 class IDEFrame(wx.Frame):
   340 class IDEFrame(wx.Frame):
   338     """IDEFrame Base Class"""
   341     """IDEFrame Base Class"""
   339     # Compatibility function for wx versions < 2.6
   342     # Compatibility function for wx versions < 2.6