[squeak-dev] The Trunk: Morphic-cwp.591.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Apr 2 23:58:59 UTC 2012


Colin Putney uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cwp.591.mcz

==================== Summary ====================

Name: Morphic-cwp.591
Author: cwp
Time: 8 December 2011, 12:36:03.945 pm
UUID: d629ac13-c193-4f7e-810c-685205b2def0
Ancestors: Morphic-cwp.590

Added icon support to PluggableListMorph and LazyListMorph.

=============== Diff against Morphic-cwp.590 ===============

Item was changed:
  Morph subclass: #LazyListMorph
+ 	instanceVariableNames: 'listItems listIcons font selectedRow selectedRows listSource maxWidth'
- 	instanceVariableNames: 'listItems font selectedRow selectedRows listSource maxWidth'
  	classVariableNames: 'ListSelectionColor ListSelectionTextColor'
  	poolDictionaries: ''
  	category: 'Morphic-Widgets'!
  
  !LazyListMorph commentStamp: 'efc 8/6/2005 11:34' prior: 0!
  The morph that displays the list in a PluggableListMorph.  It is "lazy" because it will only request the list items that it actually needs to display.
  
  I will cache the maximum width of my items in maxWidth to avoid this potentially expensive and frequent computation.!

Item was changed:
  ----- Method: LazyListMorph>>display:atRow:on: (in category 'drawing') -----
+ display: item atRow: row on: canvas
- display: item  atRow: row on: canvas
  	"display the given item at row row"
+ 
+ 	| drawBounds emphasized rowColor |
+ 	emphasized := item isText 
+ 		ifTrue: [font emphasized: (item emphasisAt: 1)] 
+ 		ifFalse: [font].
+ 	rowColor := self colorForRow: row.
- 	| drawBounds |
  	drawBounds := self drawBoundsForRow: row.
  	drawBounds := drawBounds intersect: self bounds.
+ 	(self icon: row) ifNotNil: 
+ 		[ :icon || top |
+ 		top := drawBounds top + ((drawBounds height - icon height) // 2).
+ 		canvas translucentImage: icon at: drawBounds left @ top.
+ 		drawBounds := drawBounds left: drawBounds left + icon width + 2 ].
+ 	canvas drawString: item in: drawBounds font: emphasized color: rowColor!
- 	item isText
- 		ifTrue: [ canvas drawString: item in: drawBounds font: (font emphasized: (item emphasisAt: 1)) color: (self colorForRow: row) ]
- 		ifFalse: [ canvas drawString: item in: drawBounds font: font color: (self colorForRow: row) ].!

Item was added:
+ ----- Method: LazyListMorph>>icon: (in category 'accessing') -----
+ icon: row
+ 	| icon |
+ 	listIcons ifNil: [listIcons := Array new: listItems size].
+ 	row <= listIcons size ifFalse: [^ listSource iconAt: row].
+ 	icon := listIcons at: row.
+ 	icon ifNil:
+ 		[icon := listSource iconAt: row.
+ 		listIcons at: row put: icon].
+ 	^ icon!

Item was changed:
  ----- Method: LazyListMorph>>initialize (in category 'initialization') -----
  initialize
  	super initialize.
  	self color: Color black.
  	font := Preferences standardListFont.
  	listItems := #().
+ 	listIcons := #().
  	selectedRow := nil.
  	selectedRows := PluggableSet integerSet.
  	self adjustHeight.!

Item was changed:
  ----- Method: LazyListMorph>>listChanged (in category 'list management') -----
  listChanged
  	"set newList to be the list of strings to display"
+ 	| size |
+ 	size := self getListSize.
+ 	listItems := Array new: size withAll: nil.
+ 	listIcons := Array new: size withAll: nil.
- 	listItems := Array new: self getListSize withAll: nil.
  	maxWidth := nil.
  	selectedRow := nil.
  	selectedRows := PluggableSet integerSet.
  	self adjustHeight.
  	self adjustWidth.
  	self changed.
  !

Item was changed:
  ScrollPane subclass: #PluggableListMorph
+ 	instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector priorSelection getIconSelector'
- 	instanceVariableNames: 'list getListSelector getListSizeSelector getListElementSelector getIndexSelector setIndexSelector keystrokeActionSelector autoDeselect lastKeystrokeTime lastKeystrokes lastClickTime doubleClickSelector handlesBasicKeys potentialDropRow listMorph hScrollRangeCache keystrokePreviewSelector priorSelection'
  	classVariableNames: 'ClearFilterAutomatically FilterableLists'
  	poolDictionaries: ''
  	category: 'Morphic-Pluggable Widgets'!
  
  !PluggableListMorph commentStamp: 'cmm 8/21/2011 23:37' prior: 0!
  When a PluggableListMorph is in focus, type in a letter (or several letters quickly) to go to the next item that begins with that letter (if FilterableLists is false).
  
  Special keys (up, down, home, etc.) are also supported.!

Item was added:
+ ----- Method: PluggableListMorph>>getIconSelector: (in category 'initialization') -----
+ getIconSelector: aSymbol
+ 	getIconSelector := aSymbol!

Item was added:
+ ----- Method: PluggableListMorph>>iconAt: (in category 'model access') -----
+ iconAt: anInteger
+ 	^ getIconSelector ifNotNil: [model perform: getIconSelector with: anInteger]!



More information about the Squeak-dev mailing list