Changeset 238

Show
Ignore:
Timestamp:
06/07/08 21:26:58 (7 months ago)
Author:
tal
Message:
Brought up to date.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • packages/defconAppKit/trunk/TestApp/DefconAppKitTest.py

    r148 r238  
    77from defconAppKit.windows.progressWindow import ProgressWindow 
    88from defconAppKit.representationFactories import registerAllFactories 
    9 from defconAppKit.representationFactories import GlyphCellHeaderHeight, GlyphCellMinHeightForHeader 
    10 from defconAppKit.views.glyphCellView import GlyphCellView 
    11 from defconAppKit.views.glyphList import GlyphList 
     9from defconAppKit.representationFactories.glyphCellFactory import GlyphCellHeaderHeight, GlyphCellMinHeightForHeader 
     10from defconAppKit.views.glyphCollectionView import GlyphCollectionView 
    1211from defconAppKit.views.glyphLineView import GlyphLineView 
    1312from defconAppKit.views.glyphNameComboBox import GlyphNameComboBox 
     
    5352        self.w = vanilla.Window((700, 500), minSize=(400, 400)) 
    5453 
    55         self.w.tabs = vanilla.Tabs((10, 10, -10, -10), ["Window", "GlyphCellView", "GlyphList", "GlyphLineView", "Misc. Controls"]) 
     54        self.w.tabs = vanilla.Tabs((10, 10, -10, -10), ["Window", "GlyphCollectionView", "GlyphLineView", "Misc. Controls"]) 
    5655        self.windowTab = self.w.tabs[0] 
    57         self.cellViewTab = self.w.tabs[1] 
    58         self.listTab = self.w.tabs[2] 
    59         self.lineViewTab = self.w.tabs[3] 
    60         self.controlsTab = self.w.tabs[4] 
     56        self.collectionViewTab = self.w.tabs[1] 
     57        self.lineViewTab = self.w.tabs[2] 
     58        self.controlsTab = self.w.tabs[3] 
    6159 
    6260        # test various window methods 
     
    6967 
    7068        # test cell view 
    71         self.cellViewTab.cellViewModifyButton = vanilla.Button((10, 10, 150, 20), "Modify Glyphs", callback=self.cellViewModify) 
    72         self.cellViewTab.cellViewSizeSlider = vanilla.Slider((170, 10, 150, 20), minValue=10, maxValue=100, value=50, 
    73             continuous=False, callback=self.cellViewResize) 
    74         self.cellViewTab.cellView = GlyphCellView((10, 40, -10, -10), allowDrag=True, 
    75             selectionCallback=self.cellViewSelectionCallback, doubleClickCallback=self.cellViewDoubleClickCallback, 
    76             deleteCallback=self.cellViewDeleteCallback, dropCallback=self.cellViewDropCallback) 
    77         self.cellViewTab.cellView.set(self.glyphs) 
    78         self.cellViewResize(self.cellViewTab.cellViewSizeSlider) 
    79  
    80         ## test list 
    81         #formatter = NSNumberFormatter.alloc().init() 
    82         #formatter.setAllowsFloats_(False) 
    83         #columnDescriptions = [ 
    84         #    dict(title="name", editable=False), 
    85         #    dict(title="width", editable=True, formatter=formatter), 
    86         #    dict(title="leftMargin", editable=True, formatter=formatter), 
    87         #    dict(title="rightMargin", editable=True, formatter=formatter), 
    88         #] 
    89         #self.listTab.glyphList = GlyphList((10, 10, -10, -10), self.glyphs, columnDescriptions=columnDescriptions, editCallback=self.listViewEdit) 
     69        dropSettings = dict(callback=self.collectionViewDropCallback) 
     70        self.collectionViewTab.collectionViewModifyButton = vanilla.Button((10, 10, 150, 20), "Modify Glyphs", callback=self.collectionViewModify) 
     71        self.collectionViewTab.collectionViewSizeSlider = vanilla.Slider((170, 10, 150, 20), minValue=10, maxValue=100, value=50, 
     72            continuous=False, callback=self.collectionViewResize) 
     73        self.collectionViewTab.collectionView = GlyphCollectionView((10, 40, -10, -10), allowDrag=True, 
     74            selectionCallback=self.collectionViewSelectionCallback, doubleClickCallback=self.collectionViewDoubleClickCallback, 
     75            deleteCallback=self.collectionViewDeleteCallback, selfApplicationDropSettings=dropSettings) 
     76        self.collectionViewTab.collectionView.set(self.glyphs) 
     77        self.collectionViewResize(self.collectionViewTab.collectionViewSizeSlider) 
    9078 
    9179        # test line view 
     
    141129    # cell view 
    142130 
    143     def cellViewDoubleClickCallback(self, sender): 
     131    def collectionViewDoubleClickCallback(self, sender): 
    144132        print "double click" 
    145133 
    146     def cellViewDeleteCallback(self, sender): 
     134    def collectionViewDeleteCallback(self, sender): 
    147135        print "delete", sender.getSelection() 
    148136 
    149     def cellViewDropCallback(self, sender, glyphs, testing): 
    150         if not testing: 
     137    def collectionViewDropCallback(self, sender, dropInfo): 
     138        glyphs = dropInfo["data"] 
     139        isProposal = dropInfo["isProposal"] 
     140        if not isProposal: 
    151141            for glyph in glyphs: 
    152142                self.font.insertGlyph(glyph, name=".glyph%d" % len(self.font)) 
    153143            self.glyphs = [self.font[k] for k in sorted(self.font.keys())] 
    154             self.cellViewTab.cellView.set(self.glyphs) 
     144            self.collectionViewTab.collectionView.set(self.glyphs) 
    155145        return True 
    156146 
    157     def cellViewSelectionCallback(self, sender): 
    158         self.cellViewTab.cellView.setSelection(sender.getSelection()) 
     147    def collectionViewSelectionCallback(self, sender): 
     148        self.collectionViewTab.collectionView.setSelection(sender.getSelection()) 
    159149 
    160     def cellViewModify(self, sender): 
    161         selection = [self.glyphs[index] for index in self.cellViewTab.cellView.getSelection()] 
     150    def collectionViewModify(self, sender): 
     151        selection = [self.glyphs[index] for index in self.collectionViewTab.collectionView.getSelection()] 
    162152        for glyph in selection: 
    163153            glyph.move((100, 100)) 
    164154 
    165     def cellViewResize(self, sender): 
     155    def collectionViewResize(self, sender): 
    166156        width = height = int(sender.get()) 
    167157        drawHeader = height > GlyphCellMinHeightForHeader 
    168158        if drawHeader: 
    169159            height += GlyphCellHeaderHeight 
    170         self.cellViewTab.cellView.setCellSize((width, height)) 
    171         self.cellViewTab.cellView.setCellRepresentationArguments(drawHeader=drawHeader, drawMetrics=drawHeader) 
     160        self.collectionViewTab.collectionView.setCellSize((width, height)) 
     161        self.collectionViewTab.collectionView.setCellRepresentationArguments(drawHeader=drawHeader, drawMetrics=drawHeader) 
    172162 
    173163    # list view