Changeset 238
- Timestamp:
- 06/07/08 21:26:58 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
packages/defconAppKit/trunk/TestApp/DefconAppKitTest.py
r148 r238 7 7 from defconAppKit.windows.progressWindow import ProgressWindow 8 8 from 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 9 from defconAppKit.representationFactories.glyphCellFactory import GlyphCellHeaderHeight, GlyphCellMinHeightForHeader 10 from defconAppKit.views.glyphCollectionView import GlyphCollectionView 12 11 from defconAppKit.views.glyphLineView import GlyphLineView 13 12 from defconAppKit.views.glyphNameComboBox import GlyphNameComboBox … … 53 52 self.w = vanilla.Window((700, 500), minSize=(400, 400)) 54 53 55 self.w.tabs = vanilla.Tabs((10, 10, -10, -10), ["Window", "GlyphC ellView", "GlyphList", "GlyphLineView", "Misc. Controls"])54 self.w.tabs = vanilla.Tabs((10, 10, -10, -10), ["Window", "GlyphCollectionView", "GlyphLineView", "Misc. Controls"]) 56 55 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] 61 59 62 60 # test various window methods … … 69 67 70 68 # 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) 90 78 91 79 # test line view … … 141 129 # cell view 142 130 143 def c ellViewDoubleClickCallback(self, sender):131 def collectionViewDoubleClickCallback(self, sender): 144 132 print "double click" 145 133 146 def c ellViewDeleteCallback(self, sender):134 def collectionViewDeleteCallback(self, sender): 147 135 print "delete", sender.getSelection() 148 136 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: 151 141 for glyph in glyphs: 152 142 self.font.insertGlyph(glyph, name=".glyph%d" % len(self.font)) 153 143 self.glyphs = [self.font[k] for k in sorted(self.font.keys())] 154 self.c ellViewTab.cellView.set(self.glyphs)144 self.collectionViewTab.collectionView.set(self.glyphs) 155 145 return True 156 146 157 def c ellViewSelectionCallback(self, sender):158 self.c ellViewTab.cellView.setSelection(sender.getSelection())147 def collectionViewSelectionCallback(self, sender): 148 self.collectionViewTab.collectionView.setSelection(sender.getSelection()) 159 149 160 def c ellViewModify(self, sender):161 selection = [self.glyphs[index] for index in self.c ellViewTab.cellView.getSelection()]150 def collectionViewModify(self, sender): 151 selection = [self.glyphs[index] for index in self.collectionViewTab.collectionView.getSelection()] 162 152 for glyph in selection: 163 153 glyph.move((100, 100)) 164 154 165 def c ellViewResize(self, sender):155 def collectionViewResize(self, sender): 166 156 width = height = int(sender.get()) 167 157 drawHeader = height > GlyphCellMinHeightForHeader 168 158 if drawHeader: 169 159 height += GlyphCellHeaderHeight 170 self.c ellViewTab.cellView.setCellSize((width, height))171 self.c ellViewTab.cellView.setCellRepresentationArguments(drawHeader=drawHeader, drawMetrics=drawHeader)160 self.collectionViewTab.collectionView.setCellSize((width, height)) 161 self.collectionViewTab.collectionView.setCellRepresentationArguments(drawHeader=drawHeader, drawMetrics=drawHeader) 172 162 173 163 # list view
