controls/VariablePanel.py
changeset 1675 5f4e53508e4e
parent 1668 cd9db17c7ab5
child 1676 eed01e0ab32a
equal deleted inserted replaced
1674:85e22d514c05 1675:5f4e53508e4e
   455                   size=wx.Size(28, 28), style=wx.NO_BORDER)
   455                   size=wx.Size(28, 28), style=wx.NO_BORDER)
   456             button.SetToolTipString(help)
   456             button.SetToolTipString(help)
   457             setattr(self, name, button)
   457             setattr(self, name, button)
   458             controls_sizer.AddWindow(button)
   458             controls_sizer.AddWindow(button)
   459 
   459 
   460         self.VariablesGrid = CustomGrid(self, style=wx.VSCROLL)
   460         self.VariablesGrid = CustomGrid(self, style=wx.VSCROLL | wx.HSCROLL)
   461         self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
   461         self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
   462         self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
   462         self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
   463               self.OnVariablesGridCellChange)
   463               self.OnVariablesGridCellChange)
   464         self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK,
   464         self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK,
   465               self.OnVariablesGridCellLeftClick)
   465               self.OnVariablesGridCellLeftClick)
   530             #                      Num  Name    Class   Type    Init    Option   Doc
   530             #                      Num  Name    Class   Type    Init    Option   Doc
   531             self.ColSizes       = [40,  80,     100,    80,     120,    100,     160]
   531             self.ColSizes       = [40,  80,     100,    80,     120,    100,     160]
   532             self.ColAlignements = [c,   l,      l,      l,      l,      l,       l]
   532             self.ColAlignements = [c,   l,      l,      l,      l,      l,       l]
   533             self.ColFixedSizeFlag=[True,False,  True,   False,  True,   True,    False]
   533             self.ColFixedSizeFlag=[True,False,  True,   False,  True,   True,    False]
   534 
   534 
       
   535         self.PanelWidthMin = sum(self.ColSizes)
       
   536         
   535         self.ElementType = element_type
   537         self.ElementType = element_type
   536         self.BodyType = None
   538         self.BodyType = None
   537 
   539 
   538         for choice in self.FilterChoices:
   540         for choice in self.FilterChoices:
   539             self.ClassFilter.Append(_(choice))
   541             self.ClassFilter.Append(_(choice))
   636                 self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit))
   638                 self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit))
   637                 self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All"))
   639                 self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All"))
   638                 self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All"))
   640                 self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All"))
   639         setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons)
   641         setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons)
   640 
   642 
   641         stretch_cols_width = window.Parent.ScreenRect.Width - 35
   643         panel_width = window.Parent.ScreenRect.Width - 35
   642         stretch_cols_sum = 0
   644         if panel_width > self.PanelWidthMin:
   643         for col  in range(len(self.ColFixedSizeFlag)):
   645             stretch_cols_width = panel_width
   644             if self.ColFixedSizeFlag[col]:
   646             stretch_cols_sum = 0            
   645                 stretch_cols_width -= self.ColSizes[col]
   647             for col in range(len(self.ColFixedSizeFlag)):
   646             else:
   648                 if self.ColFixedSizeFlag[col]:
   647                 stretch_cols_sum += self.ColSizes[col]
   649                     stretch_cols_width -= self.ColSizes[col]
       
   650                 else:
       
   651                     stretch_cols_sum += self.ColSizes[col]
       
   652 
   648         self.VariablesGrid.SetRowLabelSize(0)
   653         self.VariablesGrid.SetRowLabelSize(0)
   649         for col in range(self.Table.GetNumberCols()):
   654         for col in range(self.Table.GetNumberCols()):
   650             attr = wx.grid.GridCellAttr()
   655             attr = wx.grid.GridCellAttr()
   651             attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE)
   656             attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE)
   652             self.VariablesGrid.SetColAttr(col, attr)
   657             self.VariablesGrid.SetColAttr(col, attr)
   653             self.VariablesGrid.SetColMinimalWidth(col, self.ColSizes[col])
   658             self.VariablesGrid.SetColMinimalWidth(col, self.ColSizes[col])
   654             if not self.ColFixedSizeFlag[col]:
   659             if (panel_width > self.PanelWidthMin) and not self.ColFixedSizeFlag[col]:
   655                 self.VariablesGrid.SetColSize(col, int((float(self.ColSizes[col])/stretch_cols_sum)*stretch_cols_width))
   660                 self.VariablesGrid.SetColSize(col, int((float(self.ColSizes[col])/stretch_cols_sum)*stretch_cols_width))
   656             else:
   661             else:
   657                 self.VariablesGrid.SetColSize(col, self.ColSizes[col])
   662                 self.VariablesGrid.SetColSize(col, self.ColSizes[col])
   658 
   663 
   659     def __del__(self):
   664     def __del__(self):