Changeset 270

Show
Ignore:
Timestamp:
10/03/08 06:44:16 (3 months ago)
Author:
tal
Message:
Added some documentation. Fixed a few small bugs.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • packages/defconAppKit/trunk/Lib/defconAppKit/views/glyphCollectionView.py

    r265 r270  
    154154        ## tweak the scroll view 
    155155        self._nsObject.setBackgroundColor_(gridColor) 
     156        ## table view tweak 
     157        self._haveTweakedColumnWidths = initialMode == "list" 
    156158        ## set the mode 
    157159        self._mode = None 
    158160        self.setMode(initialMode) 
    159         ## table view tweak 
    160         self._haveTweakedColumnWidths = initialMode == "list" 
    161161 
    162162    def _breakCycles(self): 
     
    200200            self._haveTweakedColumnWidths = True 
    201201 
     202    def getMode(self): 
     203        """ 
     204        Get the current mode. 
     205        """ 
     206        return self._mode 
     207 
    202208    # -------------------- 
    203209    # selection management 
     
    205211 
    206212    def getSelection(self): 
     213        """ 
     214        Get the selection in the view as a list of indexes. 
     215        """ 
    207216        if self._mode == "list": 
    208217            return super(GlyphCollectionView, self).getSelection() 
     
    210219 
    211220    def setSelection(self, selection): 
     221        """ 
     222        Sets the selection in the view. The passed value 
     223        should be a list of indexes. 
     224        """ 
    212225        if self._mode == "list": 
    213226            super(GlyphCollectionView, self).setSelection(selection) 
     
    216229 
    217230    def scrollToSelection(self): 
     231        """ 
     232        Scroll the view so that the current selection is visible. 
     233        """ 
    218234        super(GlyphCollectionView, self).scrollToSelection() 
    219235        selection = self.getSelection() 
     
    268284    def _glyphChanged(self, notification): 
    269285        glyph = notification.object 
     286        if glyph not in self._wrappedListItems: 
     287            return 
    270288        d = self._wrappedListItems[glyph] 
    271289        for key, attr in self._keyToAttribute.items(): 
     
    426444 
    427445    def index(self, glyph): 
    428         item = self._wrappedListItems(glyph) 
     446        item = self._wrappedListItems[glyph] 
    429447        return super(GlyphCollectionView, self).index(item) 
    430448 
     
    444462 
    445463    def set(self, glyphs): 
     464        """ 
     465        Set the glyphs in the view. 
     466        """ 
    446467        # remove removed wrapped items 
    447468        removedGlyphs = set(self._wrappedListItems) - set(glyphs) 
     
    451472        # wrap the glyphs for the list 
    452473        wrappedGlyphs = [self._wrapGlyphForList(glyph) for glyph in glyphs] 
     474        # set the list 
     475        super(GlyphCollectionView, self).set(wrappedGlyphs) 
    453476        # set the cell view 
    454477        self._glyphCellView.setGlyphs_(glyphs) 
    455         # set the list 
    456         super(GlyphCollectionView, self).set(wrappedGlyphs) 
    457478 
    458479    def get(self): 
     480        """ 
     481        Get the glyphs in the view. 
     482        """ 
    459483        return self._unwrapListItems() 
    460484 
     
    464488 
    465489    def getGlyphCellView(self): 
     490        """ 
     491        Get the cell NSView. 
     492        """ 
    466493        return self._glyphCellView 
    467494 
    468495    def setCellSize(self, (width, height)): 
     496        """ 
     497        Set the size of the cells. 
     498        """ 
    469499        self._glyphCellView.setCellSize_((width, height)) 
    470500 
    471501    def setCellRepresentationArguments(self, **kwargs): 
     502        """ 
     503        Set the arguments that should be passed to the cell representation factory. 
     504        """ 
    472505        self._glyphCellView.setCellRepresentationArguments_(**kwargs) 
    473506 
    474507    def getCellRepresentationArguments(self): 
     508        """ 
     509        Get the arguments passed to the cell representation factory. 
     510        """ 
    475511        return self._glyphCellView.getCellRepresentationArguments() 
    476512 
     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() 
    477519 
    478520# -------------