Changeset 270
- Timestamp:
- 10/03/08 06:44:16 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
packages/defconAppKit/trunk/Lib/defconAppKit/views/glyphCollectionView.py
r265 r270 154 154 ## tweak the scroll view 155 155 self._nsObject.setBackgroundColor_(gridColor) 156 ## table view tweak 157 self._haveTweakedColumnWidths = initialMode == "list" 156 158 ## set the mode 157 159 self._mode = None 158 160 self.setMode(initialMode) 159 ## table view tweak160 self._haveTweakedColumnWidths = initialMode == "list"161 161 162 162 def _breakCycles(self): … … 200 200 self._haveTweakedColumnWidths = True 201 201 202 def getMode(self): 203 """ 204 Get the current mode. 205 """ 206 return self._mode 207 202 208 # -------------------- 203 209 # selection management … … 205 211 206 212 def getSelection(self): 213 """ 214 Get the selection in the view as a list of indexes. 215 """ 207 216 if self._mode == "list": 208 217 return super(GlyphCollectionView, self).getSelection() … … 210 219 211 220 def setSelection(self, selection): 221 """ 222 Sets the selection in the view. The passed value 223 should be a list of indexes. 224 """ 212 225 if self._mode == "list": 213 226 super(GlyphCollectionView, self).setSelection(selection) … … 216 229 217 230 def scrollToSelection(self): 231 """ 232 Scroll the view so that the current selection is visible. 233 """ 218 234 super(GlyphCollectionView, self).scrollToSelection() 219 235 selection = self.getSelection() … … 268 284 def _glyphChanged(self, notification): 269 285 glyph = notification.object 286 if glyph not in self._wrappedListItems: 287 return 270 288 d = self._wrappedListItems[glyph] 271 289 for key, attr in self._keyToAttribute.items(): … … 426 444 427 445 def index(self, glyph): 428 item = self._wrappedListItems (glyph)446 item = self._wrappedListItems[glyph] 429 447 return super(GlyphCollectionView, self).index(item) 430 448 … … 444 462 445 463 def set(self, glyphs): 464 """ 465 Set the glyphs in the view. 466 """ 446 467 # remove removed wrapped items 447 468 removedGlyphs = set(self._wrappedListItems) - set(glyphs) … … 451 472 # wrap the glyphs for the list 452 473 wrappedGlyphs = [self._wrapGlyphForList(glyph) for glyph in glyphs] 474 # set the list 475 super(GlyphCollectionView, self).set(wrappedGlyphs) 453 476 # set the cell view 454 477 self._glyphCellView.setGlyphs_(glyphs) 455 # set the list456 super(GlyphCollectionView, self).set(wrappedGlyphs)457 478 458 479 def get(self): 480 """ 481 Get the glyphs in the view. 482 """ 459 483 return self._unwrapListItems() 460 484 … … 464 488 465 489 def getGlyphCellView(self): 490 """ 491 Get the cell NSView. 492 """ 466 493 return self._glyphCellView 467 494 468 495 def setCellSize(self, (width, height)): 496 """ 497 Set the size of the cells. 498 """ 469 499 self._glyphCellView.setCellSize_((width, height)) 470 500 471 501 def setCellRepresentationArguments(self, **kwargs): 502 """ 503 Set the arguments that should be passed to the cell representation factory. 504 """ 472 505 self._glyphCellView.setCellRepresentationArguments_(**kwargs) 473 506 474 507 def getCellRepresentationArguments(self): 508 """ 509 Get the arguments passed to the cell representation factory. 510 """ 475 511 return self._glyphCellView.getCellRepresentationArguments() 476 512 513 def preloadGlyphCellImages(self): 514 """ 515 Preload the images to be used in the cells. This is useful 516 when lots of cellsneed to be displayed. 517 """ 518 self._glyphCellView.preloadGlyphCellImages() 477 519 478 520 # -------------
