AutoScrollingView is much like a ScrollingView.
Subclasses of AutoScrollingView redefine some inst var and behaviours of superclass of ScrollingView. Obviously, code could be better factored. I provide here after a script that made the hierarchy transition for VW 2.5.2. I think i used it in VW5i4 and VW7.2 as is, but not sure any more. Just updated it for VWNC7.3.1 because of some new inst vars, seems to work OK. Due to use of Transcript during changes, code is tricky. Would a modern refactoring engine deal with this? Good exercize. Nicolas "----------------------------------------------------------------------" "1st : file out AutoScrollingView :"! | sfm | sfm := SourceCodeStream write: 'AutoScrollingView.st' encoding: #Source. [sfm timeStamp. AutoScrollingView fileOutSourceOn: sfm.] ensure: [sfm close]! "2nd : rename AutoScrollingView as AutoScrollingView2"! | txt positions start index | txt := ('AutoScrollingView.st' asFilename withEncoding: #Source) contentsOfEntireFile. positions := OrderedCollection new. start := 1. key := 'AutoScrollingView'. [(index := txt findString: key startingAt: start) = 0] whileFalse: [positions add: index. start := index + 1]. positions reverseDo: [:pos | txt := txt copyReplaceFrom: pos to: pos + key size - 1 with: 'AutoScrollingView2']. (('AutoScrollingView2.st' asFilename withEncoding: #Source) writeStream) nextPutAll: txt; close! "3rd : file In from AutoScrollingView2.st"! ('AutoScrollingView2.st' asFilename withEncoding: #Source) fileIn! "4th : move AutoScrollingView2 under ScrollingView"! ScrollingView subclass: #AutoScrollingView2 instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Interface-Support'! "5th same with ComposedTextView"! | sfm txt positions start index | sfm := SourceCodeStream write: 'ComposedTextView.st' encoding: #Source. [sfm timeStamp. ComposedTextView fileOutSourceOn: sfm.] ensure: [sfm close]. txt := ('ComposedTextView.st' asFilename withEncoding: #Source) contentsOfEntireFile. positions := OrderedCollection new. start := 1. key := 'ComposedTextView'. [(index := txt findString: key startingAt: start) = 0] whileFalse: [positions add: index. start := index + 1]. positions reverseDo: [:pos | txt := txt copyReplaceFrom: pos to: pos + key size - 1 with: 'ComposedTextView2']. (('ComposedTextView2.st' asFilename withEncoding: #Source) writeStream) nextPutAll: txt; close. ('ComposedTextView2.st' asFilename withEncoding: #Source) fileIn! AutoScrollingView2 subclass: #ComposedTextView2 instanceVariableNames: 'displayContents startBlock stopBlock selectionShowing displaySelection ' classVariableNames: 'InsertionPoint InstallationWorkspace SystemWorkspace ' poolDictionaries: '' category: 'UIBasics-Components'! "6th : prepare to handle TextCollectorView rehook with initialized state inst var..."! TextCollectorView addInstVarName: 'state'. TextCollectorView allInstancesDo: [:e | e instVarAt: (TextCollectorView allInstVarNames indexOf: 'state') put: WidgetState new.]! "7th : move some subclasses under AutoScrollingView2 without the state inst var"! AutoScrollingView2 subclass: #TableView instanceVariableNames: 'table columnInfo rowInfo selectionChannel selectionIndex targetIndex grid columnWidths rowHeights visualBlock textStyle displayStringSelector showCGrid showRGrid strokedSelection isSlave lpDictionary ' classVariableNames: '' poolDictionaries: '' category: 'UIBasics-Components'! ComposedTextView2 subclass: #TextEditorView instanceVariableNames: 'helpText ' classVariableNames: '' poolDictionaries: '' category: 'UIBasics-Components'! ComposedTextView2 subclass: #TextCollectorView instanceVariableNames: 'appendEntryMutex' classVariableNames: '' poolDictionaries: '' category: 'UIBasics-Components'! "7th now move AutoScrollingView under ScrollingView"! ScrollingView subclass: #AutoScrollingView instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Interface-Support'! AutoScrollingView subclass: #TableView instanceVariableNames: 'table columnInfo rowInfo selectionChannel selectionIndex targetIndex grid columnWidths rowHeights visualBlock textStyle displayStringSelector showCGrid showRGrid strokedSelection isSlave lpDictionary ' classVariableNames: '' poolDictionaries: '' category: 'UIBasics-Components'! ComposedTextView subclass: #TextEditorView instanceVariableNames: 'helpText ' classVariableNames: '' poolDictionaries: '' category: 'UIBasics-Components'! ComposedTextView subclass: #TextCollectorView instanceVariableNames: 'appendEntryMutex' classVariableNames: '' poolDictionaries: '' category: 'UIBasics-Components'! "8th : remove intermediate classes"! ComposedTextView2 removeFromSystem! AutoScrollingView2 removeFromSystem! "9th BIG GARBAGE COLLECTION"! AutoScrollingView removeSelector: #initialize! AutoScrollingView removeSelector: #scrollOffsetHolder:! AutoScrollingView organization removeCategory: #'initialize-release'! AutoScrollingView removeSelector: #changePositionBy:! AutoScrollingView removeSelector: #positionTo:! AutoScrollingView removeSelector: #scrollBy:! AutoScrollingView removeSelector: #setScrollOffsetHolder:! AutoScrollingView removeSelector: #scrollableExtent! AutoScrollingView removeSelector: #validateScrollPosition:! AutoScrollingView removeSelector: #visibleExtent! AutoScrollingView organization removeCategory: #private! TextEditorView removeSelector: #initializeState! !SequenceView methodsFor: 'initialize-release'! initialize "Initialize the receiver." super initialize. measureWidth := false. self initializeGrid. self initializeVisuals. self initializeSelectionChannel. targetIndex := 0.! ! TextEditorView removeSelector: #initialize! TableView removeSelector: #isEnabled! TextEditorView removeSelector: #isEnabled! TextEditorView removeSelector: #isEnabled:! TableView removeSelector: #isEnabled:! TextEditorView removeSelector: #isVisible! TableView removeSelector: #isVisible! TableView removeSelector: #isVisible:! TextEditorView removeSelector: #isVisible:! TableView removeSelector: #widgetState! TextEditorView removeSelector: #widgetState! TableView removeSelector: #widgetState:! TextEditorView removeSelector: #widgetState:! !TableView methodsFor: 'initialize-release'! initialize "Initialize the receiver." super initialize. isSlave := false. self initializeGrid. self initializeVisuals. self initializeLPDictionary. self initializeSelectionChannel. targetIndex := self zeroIndex. showCGrid := false. showRGrid := false. strokedSelection := false.! ! TextEditorView removeSelector: #displayBackgroundIfNeededOn:in:! AutoScrollingView removeSelector: #scrollOffsetValue! AutoScrollingView organization removeCategory: #SEARIA! TextEditorView organization removeCategory: #'initialize-release'! TableView removeSelector: #displayBackgroundIfNeededOn:! TextEditorView removeSelector: #displayBackgroundIfNeededOn:! |
Free forum by Nabble | Edit this page |