Changeset 1326
- Timestamp:
- 09/15/05 22:55:29 (3 years ago)
- Files:
-
- trunk/dabo/biz/dBizobj.py (modified) (2 diffs)
- trunk/dabo/dEvents.py (modified) (1 diff)
- trunk/dabo/db/dCursorMixin.py (modified) (2 diffs)
- trunk/dabo/icons/boolRendererChecked.png (added)
- trunk/dabo/icons/boolRendererUnchecked.png (added)
- trunk/dabo/lib/datanav/Grid.py (modified) (5 diffs)
- trunk/dabo/lib/datanav/Page.py (modified) (3 diffs)
- trunk/dabo/ui/uiwx/__init__.py (modified) (1 diff)
- trunk/dabo/ui/uiwx/dGrid.py (modified) (89 diffs)
- trunk/dabo/ui/uiwx/gridRenderers.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/biz/dBizobj.py
r1288 r1326 1031 1031 1032 1032 1033 def getFieldVal(self, fld ):1034 """ Return the value of the specified field in the current row.1033 def getFieldVal(self, fld, row=None): 1034 """ Return the value of the specified field in the current or specified row. 1035 1035 """ 1036 1036 cursor = self._CurrentCursor 1037 1037 if cursor is not None: 1038 return cursor.getFieldVal(fld )1038 return cursor.getFieldVal(fld, row) 1039 1039 else: 1040 1040 return None … … 1055 1055 1056 1056 1057 def getDataSet(self, flds= None):1057 def getDataSet(self, flds=(), rowStart=0, rows=None): 1058 1058 """ Return the full data set from the cursor. 1059 1059 trunk/dabo/dEvents.py
r1304 r1326 381 381 pass 382 382 383 class GridHeaderIdle(GridEvent): 384 """Occurs when an idle cycle happens in the grid header.""" 385 pass 386 383 387 class GridHeaderMouseEnter(GridEvent, MouseEvent): 384 388 """Occurs when the mouse pointer enters the grid's header region.""" trunk/dabo/db/dCursorMixin.py
r1267 r1326 520 520 521 521 522 def getFieldVal(self, fld ):523 """ Return the value of the specified field ."""522 def getFieldVal(self, fld, row=None): 523 """ Return the value of the specified field in the current or specified row.""" 524 524 ret = None 525 525 if self.RowCount <= 0: 526 526 raise dException.NoRecordsException, _("No records in the data set.") 527 527 528 rec = self._records[self.RowNumber] 528 if row is None: 529 row = self.RowNumber 530 531 rec = self._records[row] 529 532 if rec.has_key(fld): 530 533 ret = rec[fld] … … 628 631 629 632 630 def getDataSet(self, flds= None):631 """ Get the entire data set encapsulated in a tuple. If the optional633 def getDataSet(self, flds=(), rowStart=0, rows=None): 634 """ Get the entire data set encapsulated in a list. If the optional 632 635 'flds' parameter is given, the result set will be filtered to only 633 636 include the specified fields. 634 637 """ 635 638 try: 636 ret = self._records 639 if rows is not None: 640 ret = self._records[rowStart:rows] 641 else: 642 ret = self._records[rowStart:] 637 643 if flds: 638 644 retlist = [] trunk/dabo/lib/datanav/Grid.py
r1307 r1326 18 18 self.bindEvent(dEvents.GridMouseLeftDoubleClick, self.onGridLeftDClick) 19 19 20 20 21 def _afterInit(self): 21 22 super(Grid, self)._afterInit() 22 self.bizobj = None23 ##pkm self.bizobj = None 23 24 self._fldSpecs = None 24 25 self.skipFields = [] … … 28 29 self.customSort = True 29 30 30 31 def getDataSet(self): 31 32 def getDataSet_old_pkm(self, requery=False): 33 # Normally, getDataSet() just returns the object reference to the list 34 # previously generated, but if we just requeried, we need to ask the 35 # bizobj for the new dataSet. 36 if requery: 37 ret = self.dataSet = None 32 38 ret = self.dataSet 33 if not self.inAutoSizeCalc: 34 if self.bizobj: 35 ret = self.dataSet = self.bizobj.getDataSet() 39 if not ret: 40 if not self.inAutoSizeCalc: 41 if self.bizobj: 42 ret = self.dataSet = self.bizobj.getDataSet() 36 43 return ret 37 44 38 45 39 46 def populate(self): 40 ds = self.getDataSet() 47 ##pkm ds = self.getDataSet(requery=True) 48 ds = self.DataSource 41 49 if not self.built and ds: 42 50 self.buildFromDataSet(ds, … … 50 58 ## pkm: this call appears to be redundant, as the grid as already been 51 59 ## filled in dGrid: 52 #self.fillGrid(True)60 self.fillGrid(True) 53 61 pass 54 62 self.Form.refresh() … … 58 66 # The superclass will have already set the sort properties. 59 67 # We want to send those to the bizobj for sorting. 60 ds1 = self.dataSet61 self.bizobj.sort(self.sortedColumn, self.sortOrder)68 bizobj = self.Form.getBizobj(self.DataSource) 69 bizobj.sort(self.sortedColumn, self.sortOrder, self.caseSensitiveSorting) 62 70 63 71 64 72 def setBizobj(self, biz): 65 self.bizobj = biz 73 self.DataSource = biz.DataSource 74 66 75 67 76 def onGridLeftDClick(self, evt): … … 106 115 def newRecord(self, evt=None): 107 116 """ Request that a new row be added.""" 108 self.Parent.newRecord(self. bizobj.DataSource)117 self.Parent.newRecord(self.DataSource) 109 118 110 119 111 120 def editRecord(self, evt=None): 112 121 """ Request that the current row be edited.""" 113 self.Parent.editRecord(self. bizobj.DataSource)122 self.Parent.editRecord(self.DataSource) 114 123 115 124 116 125 def deleteRecord(self, evt=None): 117 126 """ Request that the current row be deleted.""" 118 self.Parent.deleteRecord(self. bizobj.DataSource)127 self.Parent.deleteRecord(self.DataSource) 119 128 self.setFocus() ## required or assertion happens on Gtk 120 129 trunk/dabo/lib/datanav/Page.py
r1237 r1326 588 588 # If we aren't the active page, strange things can happen if we 589 589 # don't explicitly setFocus back to the active page. 590 self.updateGrid() 590 #self.updateGrid() 591 pass 591 592 # if self.Parent.SelectedPage != self: 592 593 # self.Parent.SelectedPage.setFocus() … … 604 605 if self.itemsCreated: 605 606 self.fillGrid(False) 606 self.BrowseGrid.CurrentRow = bizobj.RowNumber 607 ## dGrid handles this now: 608 #self.BrowseGrid.CurrentRow = bizobj.RowNumber 607 609 608 610 … … 618 620 def createItems(self): 619 621 bizobj = self.Form.getBizobj() 620 grid = Grid.Grid(self, Name ="BrowseGrid")622 grid = Grid.Grid(self, NameBase="BrowseGrid") 621 623 grid.FieldSpecs = self.Form.FieldSpecs 622 624 if not self.Form.preview: trunk/dabo/ui/uiwx/__init__.py
r1254 r1326 533 533 534 534 535 def fontMetricFromFont(txt, font): 536 wind = wx.Frame(None) 537 dc = wx.ClientDC(wind) 538 dc.SetFont(font) 539 ret = dc.GetTextExtent(txt) 540 wind.Destroy() 541 return ret 542 543 535 544 def fontMetric(txt=None, wind=None, face=None, size=None, bold=None, 536 545 italic=None): trunk/dabo/ui/uiwx/dGrid.py
r1307 r1326 17 17 import dKeys 18 18 import dUICursors 19 import dabo.biz 20 import dabo.common.dColors as dColors 19 21 20 22 # See if the new decimal module is present. This is necessary … … 40 42 41 43 self.grid = parent 42 self.bizobj = None #self.grid.Form.getBizobj(parent.DataSource)43 # Holds a copy of the current data to prevent unnecessary re-drawing44 self.__currData = []45 44 self._initTable() 46 45 … … 48 47 def _initTable(self): 49 48 self.relativeColumns = [] 50 self.colLabels = []51 self.colNames = []52 49 self.colDefs = [] 53 self.dataTypes = []54 50 self.imageBaseThumbnails = [] 55 51 self.imageLists = {} 56 self.data = []57 52 self.rowLabels = [] 53 self._oldRowCount = None 58 54 # Call the hook 59 55 self.initTable() … … 67 63 self.rowLabels = rowLbls 68 64 65 69 66 def GetAttr(self, row, col, kind=0): 70 67 ## dColumn maintains one attribute object that applies to every row … … 85 82 ## The column attr object is maintained in dColumn: 86 83 try: 87 return self.grid.Columns[col]._gridColAttr.Clone() 84 dcol = self.grid.Columns[col] 85 attr = dcol._gridColAttr.Clone() 88 86 except IndexError: 89 87 # Something is out of order in the setting up of the grid: the grid table … … 94 92 # just empty - no columns or rows added yet) 95 93 94 ## Now, override with a custom renderer/editor for this row/col if applicable. 95 customEditor = dcol.CustomEditors.get(row) 96 customRenderer = dcol.CustomRenderers.get(row) 97 if customEditor is not None: 98 attr.SetEditor(customEditor()) 99 if customRenderer is not None: 100 attr.SetRenderer(customRenderer()) 101 102 return attr 103 104 96 105 def GetRowLabelValue(self, row): 97 106 try: … … 100 109 return "" 101 110 111 102 112 def GetColLabelValue(self, col): 103 try: 104 return self.colDefs[col].Caption 105 except: 106 return "" 113 # The column headers are painted when the wxGrid queries this method, as 114 # this is the most appropriate time to do so. We return "" so that wx 115 # doesn't draw the string itself. 116 self.grid._paintHeader(col) 117 return "" 107 118 108 119 … … 119 130 self.setColumnInfo() 120 131 return 121 else: 122 self.__currData = [] 132 123 133 for col in colDefs: 124 nm = col. Field134 nm = col.DataField 125 135 while not nm: 126 136 nm = str(idx) … … 175 185 def setColumnInfo(self): 176 186 self.colDefs.sort(self.orderSort) 177 self.colLabels = [col.Caption for col in self.colDefs]178 self.dataTypes = [self.convertType(col.DataType)179 for col in self.colDefs]180 self.colNames = [col.Field for col in self.colDefs]181 187 182 188 … … 212 218 return self.grid.customCanGetValueAs(row, col, typ) 213 219 else: 214 return typ == self.dataTypes[col] 220 dcol = self.grid.Columns[col] 221 return typ == self.convertType(dcol.DataType) 215 222 216 223 def CanSetValueAs(self, row, col, typ): … … 218 225 return self.grid.customCanSetValueAs(row, col, typ) 219 226 else: 220 return typ == self.dataTypes[col] 227 dcol = self.grid.Columns[col] 228 return typ == self.convertType(dcol.DataType) 221 229 222 230 223 231 def fillTable(self, force=False): 224 232 """ Fill the grid's data table to match the data set.""" 225 rows = self.GetNumberRows() 233 234 _oldRowCount = self._oldRowCount 235 236 # Get the data from the grid. 237 dataSet = self.grid.DataSource 238 if dataSet is None: 239 return 240 bizobj = self.grid.getBizobj() 241 242 if bizobj: 243 dataSet = bizobj 244 _newRowCount = dataSet.RowCount 245 else: 246 _newRowCount = len(dataSet) 247 if _oldRowCount is None: 248 ## still haven't tracked down why, but bizobj grids needed _oldRowCount 249 ## to be initialized to None, or extra rows would be added. Since we 250 ## aren't a bizobj grid, we need to change that None to 0 here so that 251 ## the rows can get appended below. 252 _oldRowCount = 0 253 254 if _oldRowCount == _newRowCount and not force: 255 return 256 226 257 oldRow = self.grid.CurrentColumn # current row per the grid 227 258 oldCol = self.grid.CurrentColumn # current column per the grid 228 259 if not oldCol: 229 260 oldCol = 0 230 # Get the data from the grid. 231 dataSet = self.grid.getDataSet() 232 if not force: 233 if self.__currData == dataSet: 234 # Nothing's changed; no need to re-fill the table 235 return 236 else: 237 self.__currData = dataSet 238 239 ## pkm: Discovered this call isn't needed. Not sure if it improves anything 240 ## without it, however: 241 #self.Clear() 242 243 self.data = [] 261 244 262 encod = self.grid.Encoding 245 for record in dataSet:246 recordFmt = self.formatRowForData(record)247 self.data.append(recordFmt)248 263 self.grid.BeginBatch() 249 264 # The data table is now current, but the grid needs to be 250 265 # notified. 251 if len(self.data) > rows: 266 267 if _oldRowCount is not None and _newRowCount > _oldRowCount: 252 268 # tell the grid we've added row(s) 253 num = len(self.data) - rows269 num = _newRowCount - _oldRowCount 254 270 msg = wx.grid.GridTableMessage(self, # The table 255 271 wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, # what we did to it 256 272 num) # how many 257 273 258 elif rows > len(self.data):274 elif _oldRowCount is not None and _oldRowCount > _newRowCount: 259 275 # tell the grid we've deleted row(s) 260 num = rows - len(self.data)276 num = _oldRowCount - _newRowCount 261 277 msg = wx.grid.GridTableMessage(self, # The table 262 278 wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, # what we did to it … … 265 281 else: 266 282 msg = None 283 267 284 if msg: 268 285 self.grid.ProcessTableMessage(msg) … … 271 288 # 2) the fieldSpecs 272 289 # 3) have the grid autosize 290 273 291 for idx, col in enumerate(self.colDefs): 274 fld = col. Field292 fld = col.DataField 275 293 colName = "Column_%s" % fld 276 294 gridCol = idx … … 301 319 self.grid.EndBatch() 302 320 303 321 self._oldRowCount = _newRowCount 322 323 324 ##pkm: The following function doesn't seem to be necessary, at least when 325 ## connected directly to a bizobj. The appRecipes demo properly displays 326 ## the unicode chars, etc. But if this is necessary, because of the 327 ## reworking of things, we should probably make it formatFieldForData(fld,row) 328 ## and call it from self.GetValue(). Ed, thoughts? 304 329 def formatRowForData(self, rec): 305 330 """Takes a row from a record set, and contructs a list … … 309 334 returnFmt = [] 310 335 for col in self.colDefs: 311 fld = col. Field336 fld = col.DataField 312 337 if rec.has_key(fld): 313 338 recVal = rec[fld] … … 351 376 352 377 353 def addTempRow(self, row):354 """Used by the autosize routine to add an individual row355 containing the captions for the columns so that the autosize356 function takes them into account. It is then followed by a357 call to self.removeTempRow() to restore the data back to its358 original state.359 """360 rowFmt = self.formatRowForData(row)361 self.data.append(rowFmt)362 self.grid.BeginBatch()363 msg = wx.grid.GridTableMessage(self,364 wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, 1)365 self.grid.ProcessTableMessage(msg)366 self.grid.EndBatch()367 368 369 def removeTempRow(self):370 """Removes the temp row that was added in a prior call to371 addTempRow(). This method assumes that the last row372 in the data set is the row to remove.373 """374 tmp = self.data.pop()375 self.grid.BeginBatch()376 msg = wx.grid.GridTableMessage(self,377 wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED,378 len(self.data), 1)379 self.grid.ProcessTableMessage(msg)380 self.grid.EndBatch()381 382 383 378 # The following methods are required by the grid, to find out certain 384 379 # important details about the underlying table. 385 380 def GetNumberRows(self): 386 try: 387 num = len(self.data) 381 bizobj = self.grid.getBizobj() 382 if bizobj: 383 return bizobj.RowCount 384 try: 385 num = len(self.grid.DataSource) 388 386 except: 389 387 num = 0 390 388 return num 391 389 390 392 391 def GetNumberCols(self): 393 try: 394 num = len(self.colLabels) 395 except: 396 num = 0 397 return num 392 return self.grid.ColumnCount 398 393 399 394 400 395 def IsEmptyCell(self, row, col): 401 try: 402 return not self.data[row][col] 403 except IndexError: 404 return True 396 bizobj = self.grid.getBizobj() 397 field = self.grid.Columns[col].DataField 398 if bizobj: 399 if field: 400 return not bizobj.getFieldVal(field, row) 401 else: 402 return True 403 if field: 404 try: 405 return not self.grid.DataSource[row][field] 406 except IndexError, KeyError: 407 return True 408 return True 409 405 410 406 411 def GetValue(self, row, col): 407 try: 408 ret = self.data[row][col] 412 bizobj = self.grid.getBizobj() 413 field = self.grid.Columns[col].DataField 414 if bizobj: 415 if field: 416 return bizobj.getFieldVal(field, row) 417 else: 418 return "" 419 try: 420 ret = self.grid.DataSource[row][field] 409 421 except: 410 422 ret = "" 411 423 return ret 412 424 425 413 426 def SetValue(self, row, col, value): 414 self.data[row][col] = value 427 #self.data[row][col] = value 428 field = self.grid.Columns[col].DataField 429 bizobj = self.grid.getBizobj() 430 if bizobj: 431 # make sure we are on the correct row already (we should be already): 432 bizobj.RowNumber = row 433 bizobj.setFieldVal(field, value) 434 else: 435 self.grid.DataSource[row][field] = value 415 436 416 437 … … 436 457 super(dColumn, self)._beforeInit() 437 458 # Define the cell renderer and editor classes 459 import gridRenderers 438 460 self.stringRendererClass = wx.grid.GridCellStringRenderer 439 self.boolRendererClass = wx.grid.GridCellBoolRenderer461 self.boolRendererClass = gridRenderers.BoolRenderer 440 462 self.intRendererClass = wx.grid.GridCellNumberRenderer 441 463 self.longRendererClass = wx.grid.GridCellNumberRenderer … … 471 493 472 494 495 def getRendererForRow(self, row): 496 """Return the cell renderer for the passed row.""" 497 d = self.CustomRenderers 498 r = d.get(row) 499 if r is None: 500 r = self.Renderer 501 return r 502 503 473 504 def _afterInit(self): 474 505 self._isConstructed = True … … 480 511 481 512 513 def _getHeaderRect(self): 514 """Return the rect of this header in the header window.""" 515 grid = self.Parent 516 height = self.Parent.HeaderHeight 517 width = self.Width 518 top = 0 519 520 # Thanks Roger Binns: 521 left = -grid.GetViewStart()[0] * grid.GetScrollPixelsPerUnit()[0] 522 523 for col in range(self.Parent.ColumnCount): 524 colObj = self.Parent.Columns[col] 525 if colObj == self: 526 break 527 left += colObj.Width 528 529 return (left, top, width, height) 530 531 532 def _refreshHeader(self): 533 """Refresh just this column's header.""" 534 if self.Parent: 535 # This will trigger wx to query GetColLabelValue(), which will in turn 536 # call paintHeader() on just this column. It's roundabout, but gives the 537 # best overall results, but risks relying on wx implementation details. 538 # Other options, in case this starts to fail, are: 539 # self.Parent.Header.Refresh() 540 # self.Parent._paintHeader(self._GridColumnIndex) 541 self.Parent.SetColLabelValue(self._GridColumnIndex, "") 542 543 544 def _refreshGrid(self): 545 """Refresh the grid region, not the header region.""" 546 if self.Parent: 547 gw = self.Parent.GetGridWindow() 548 gw.Refresh() 549 550 482 551 def _persist(self, prop): 483 552 """Persist the current prop setting to the user settings table.""" … … 485 554 app = self.Application 486 555 grid = self.Parent 487 colName = "column_%s" % self. Field556 colName = "column_%s" % self.DataField 488 557 val = getattr(self, prop) 489 558 settingName = "%s.%s.%s.%s" % (grid.Form.Name, grid.Name, colName, prop) … … 492 561 493 562 494 def changeMsg(self, prop):495 if self.Parent:496 self.Parent.onColumnChange(self, prop)497 498 499 563 def _getGridColumnIndex(self): 500 564 """Return our column index in the grid, or -1.""" … … 534 598 v = self._caption = "Column" 535 599 return v 600 536 601 def _setCaption(self, val): 537 602 if self._constructed(): 538 603 self._caption = val 539 if self.Parent: 540 ## note: may want to use RefreshRect just on the column header region 541 self.Parent.refresh() 604 self._refreshHeader() 542 605 else: 543 606 self._properties["Caption"] = val 607 544 608 545 609 def _getCustomEditor(self): … … 549 613 v = self._customEditor = None 550 614 return v 615 551 616 def _setCustomEditor(self, val): 552 617 if self._constructed(): … … 555 620 else: 556 621 self._properties["CustomEditor"] = val 622 623 624 def _getCustomEditors(self): 625 try: 626 v = self._customEditors 627 except AttributeError: 628 v = self._customEditors = {} 629 return v 630 631 def _setCustomEditors(self, val): 632 self._customEditors = val 633 557 634 558 635 def _getCustomRenderer(self): … … 562 639 v = self._customRenderer = None 563 640 return v 641 564 642 def _setCustomRenderer(self, val): 565 643 if self._constructed(): … … 568 646 else: 569 647 self._properties["CustomRenderer"] = val 648 649 650 def _getCustomRenderers(self): 651 try: 652 v = self._customRenderers 653 except AttributeError: 654 v = self._customRenderers = {} 655 return v 656 657 def _setCustomRenderers(self, val): 658 self._customRenderers = val 659 570 660 571 661 def _getDataType(self): … … 575 665 v = self._dataType = "" 576 666 return v 667 577 668 def _setDataType(self, val): 578 669 if self._constructed(): 579 670 self._dataType = val 580 if "Automatic" in self.Horizontal CellAlignment:581 self._setAutoHorizontal CellAlignment()671 if "Automatic" in self.HorizontalAlignment: 672 self._setAutoHorizontalAlignment() 582 673 self._updateRenderer() 583 674 self._updateEditor() 584 #self.changeMsg("DataType") ## don't think this is necessary, now that the attr handles.585 675 else: 586 676 self._properties["DataType"] = val 677 587 678 588 679 def _getEditable(self): 589 680 return not self._gridColAttr.IsReadOnly() 681 590 682 def _setEditable(self, val): 591 683 if self._constructed(): … … 595 687 else: 596 688 self._properties["Editable"] = val 689 597 690 598 691 def _getEditor(self): … … 602 695 return v 603 696 604 def _getField(self): 605 try: 606 v = self._field 697 698 def _getDataField(self): 699 try: 700 v = self._dataField 607 701 except AttributeError: 608 v = self._ field = ""702 v = self._dataField = "" 609 703 return v 610 def _setField(self, val): 611 if self._constructed(): 612 self._field = val 704 705 def _setDataField(self, val): 706 if self._constructed(): 707 self._dataField = val 613 708 self._updateRenderer() 614 709 self._updateEditor() 615 self.changeMsg("Field") 616 else: 617 self._properties["Field"] = val 710 else: 711 self._properties["DataField"] = val 712 713 714 def _getHeaderFont(self): 715 try: 716 v = self._headerFont 717 except AttributeError: 718 if self.Parent: 719 v = self.Parent.GetLabelFont() 720 else: 721 v = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.LIGHT) 722 return v 723 724 def _setHeaderFont(self, val): 725 if self._constructed(): 726 self._headerFont = val 727 self._refreshHeader() 728 else: 729 self._properties["HeaderFont"] = val 730 731 732 def _getHeaderFontBold(self): 733 return self.HeaderFont.GetWeight() == wx.BOLD 734 735 def _setHeaderFontBold(self, val): 736 if self._constructed(): 737 font = self.HeaderFont 738 if val: 739 font.SetWeight(wx.BOLD) 740 else: 741 font.SetWeight(wx.LIGHT) # wx.NORMAL doesn't seem to work... 742 self.HeaderFont = font 743 else: 744 self._properties["HeaderFontBold"] = val 745 746 def _getHeaderFontDescription(self): 747 f = self.HeaderFont 748 ret = f.GetFaceName() + " " + str(f.GetPointSize()) 749 if f.GetWeight() == wx.BOLD: 750 ret += " B" 751 if f.GetStyle() == wx.ITALIC: 752 ret += " I" 753 return ret 754 755 def _getHeaderFontInfo(self): 756 return self.HeaderFont.GetNativeFontInfoDesc() 757 758 759 def _getHeaderFontItalic(self): 760 return self.HeaderFont.GetStyle() == wx.ITALIC 761 762 def _setHeaderFontItalic(self, val): 763 if self._constructed(): 764 font = self.HeaderFont 765 if val: 766 font.SetStyle(wx.ITALIC) 767 else: 768 font.SetStyle(wx.NORMAL) 769 self.HeaderFont = font 770 else: 771 self._properties["HeaderFontItalic"] = val 772 773 774 def _getHeaderFontFace(self): 775 return self.HeaderFont.GetFaceName() 776 777 def _setHeaderFontFace(self, val): 778 if self._constructed(): 779 f = self.HeaderFont 780 f.SetFaceName(val) 781 self.HeaderFont = f 782 else: 783 self._properties["HeaderFontFace"] = val 784 785 786 def _getHeaderFontSize(self): 787 return self.HeaderFont.GetPointSize() 788 789 def _setHeaderFontSize(self, val): 790 if self._constructed(): 791 font = self.HeaderFont 792 font.SetPointSize(int(val)) 793 self.HeaderFont = font 794 else: 795 self._properties["HeaderFontSize"] = val 796 797 def _getHeaderFontUnderline(self): 798 return self.HeaderFont.GetUnderlined() 799 800 def _setHeaderFontUnderline(self, val): 801 if self._constructed(): 802 # underlining doesn't seem to be working... 803 font = self.HeaderFont 804 font.SetUnderlined(bool(val)) 805 self.HeaderFont = font 806 else: 807 self._properties["HeaderFontUnderline"] = val 808 618 809 619 810 def _getHeaderBackgroundColor(self): … … 623 814 v = self._headerBackgroundColor = None 624 815 return v 816 625 817 def _setHeaderBackgroundColor(self, val): 626 818 if self._constructed(): … … 631 823 pass 632 824 self._headerBackgroundColor = val 633 if self.Parent: 634 self.Parent.refresh() 825 self._refreshHeader() 635 826 else: 636 827 self._properties["HeaderBackgroundColor"] = val 637 638 def _getHorizontalCellAlignment(self): 639 try: 640 auto = self._autoHorizontalCellAlignment 828 829 830 def _getHeaderForegroundColor(self): 831 try: 832 v = self._headerForegroundColor 641 833 except AttributeError: 642 auto = self._autoHorizontalCellAlignment = True 834 v = self._headerForegroundColor = dColors.colorTupleFromName("Black") 835 return v 836 837 def _setHeaderForegroundColor(self, val): 838 if self._constructed(): 839 if isinstance(val, basestring): 840 try: 841 val = dColors.colorTupleFromName(val) 842 except: 843 pass 844 self._headerForegroundColor = val 845 self._refreshHeader() 846 else: 847 self._properties["HeaderForegroundColor"] = val 848 849 850 def _getHeaderHorizontalAlignment(self): 851 try: 852 val = self._headerHorizontalAlignment 853 except AttributeError: 854 val = self._headerHorizontalAlignment = "Center" 855 return val 856 857 def _setHeaderHorizontalAlignment(self, val): 858 if self._constructed(): 859 v = self._expandPropStringValue(val, ("Left", "Right", "Center")) 860 self._headerHorizontalAlignment = v 861 self._refreshHeader() 862 else: 863 self._properties["HeaderHorizontalAlignment"] = val 864 865 866 def _getHeaderVerticalAlignment(self): 867 try: 868 val = self._headerVerticalAlignment 869 except AttributeError: 870 val = self._headerVerticalAlignment = "Center" 871 return val 872 873 def _setHeaderVerticalAlignment(self, val): 874 if self._constructed(): 875 v = self._expandPropStringValue(val, ("Top", "Bottom", "Center")) 876 self._headerVerticalAlignment = v 877 self._refreshHeader() 878 else: 879 self._properties["HeaderVerticalAlignment"] = val 880 881 882 def _getHorizontalAlignment(self): 883 try: 884 auto = self._autoHorizontalAlignment 885 except AttributeError: 886 auto = self._autoHorizontalAlignment = True 643 887 mapping = {wx.ALIGN_LEFT: "Left", wx.ALIGN_RIGHT: "Right", 644 888 wx.ALIGN_CENTRE: "Center"} … … 651 895 val = "%s (Automatic)" % val 652 896 return val 653 def _setAutoHorizontalCellAlignment(self): 897 898 def _setAutoHorizontalAlignment(self): 654 899 dt = self.DataType 655 900 if isinstance(dt, basestring): 656 901 if dt in ("decimal", "float", "long", "integer"): 657 self._setHorizontal CellAlignment("Right", _autoAlign=True)658 659 def _setHorizontal CellAlignment(self, val, _autoAlign=False):902 self._setHorizontalAlignment("Right", _autoAlign=True) 903 904 def _setHorizontalAlignment(self, val, _autoAlign=False): 660 905 if self._constructed(): 661 906 val = self._expandPropStringValue(val, ("Automatic", "Left", "Right", "Center")) 662 907 if val == "Automatic" and not _autoAlign: 663 self._autoHorizontal CellAlignment = True664 self._setAutoHorizontal CellAlignment()908 self._autoHorizontalAlignment = True 909 self._setAutoHorizontalAlignment() 665 910 return 666 911 if val != "Automatic" and not _autoAlign: 667 self._autoHorizontal CellAlignment = False912 self._autoHorizontalAlignment = False 668 913 mapping = {"Left": wx.ALIGN_LEFT, "Right": wx.ALIGN_RIGHT, 669 914 "Center": wx.ALIGN_CENTRE} … … 675 920 wxVertAlign = self._gridColAttr.GetAlignment()[1] 676 921 self._gridColAttr.SetAlignment(wxHorAlign, wxVertAlign) 677 if self.Parent: 678 self.Parent.refresh() 679 else: 680 self._properties["HorizontalCellAlignment"] = val 922 self._refreshGrid() 923 else: 924 self._properties["HorizontalAlignment"] = val 681 925 682 926 … … 687 931 v = [] 688 932 return v 933 689 934 def _setListEditorChoices(self, val): 690 935 if self._constructed(): … … 700 945 return v 701 946 947 702 948 def _getOrder(self): 703 949 try: … … 706 952 v = self._order = -1 707 953 return v
