115 lines
3.3 KiB
Smalltalk
115 lines
3.3 KiB
Smalltalk
Class {
|
|
#name : #GrafoscopioComposer,
|
|
#superclass : #Object,
|
|
#instVars : [
|
|
'text',
|
|
'styler',
|
|
'container',
|
|
'lines'
|
|
],
|
|
#category : #'Grafoscopio-Rub'
|
|
}
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> actualWidth [
|
|
^ 50
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> calculateMaximumAmountOfCharactersToComposeStartingAt: anInteger [
|
|
self shouldBeImplemented.
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> calculateMaximumAmountOfCharactersToComposeStartingAt: startingY contemplating: delta [
|
|
|
|
| deltaX deltaY |
|
|
|
|
" This method is mean to restrict the amount of text to be processed. For knowing how much of the text is going to be processed, we calculate the size of a minimal character with the default font.
|
|
This strategy is not really the best, since we should check with the smallest font used in the text instead of using the default.
|
|
But by the time being this code should beenough, knowning that for a text drawn in a scrolled area we have almost infinite space. We should mind this bug first then come back .
|
|
|
|
"
|
|
|
|
deltaX := delta + (((styler fontAt: styler defaultFontIndex) linearWidthOf: $.) roundDownTo: 1).
|
|
deltaY := (styler fontAt: styler defaultFontIndex) height.
|
|
|
|
|
|
^ (container width / deltaX) * ((container height - startingY ) / deltaY ).
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> composeLinesFrom: start to: stop delta: delta into: lineColl priorLines: priorLines atY: startingY [
|
|
| maxChars |
|
|
stop > 0
|
|
ifTrue: [ self haltOnce ].
|
|
" we set the lines collection "
|
|
lines := lineColl.
|
|
" we do calculate the size of an average "
|
|
maxChars := self
|
|
calculateMaximumAmountOfCharactersToComposeStartingAt: startingY
|
|
contemplating: delta.
|
|
" we should care about really fragmenting the composittion once we have this assert failling
|
|
should be enough to stop the inspection of the tree nodes once the from > maxChars.
|
|
something like:
|
|
|
|
text allSegmentsOfLinesUpTo: [: from : to | from > maxChars] collect: [ :from :to | GrafoscopioLine new from: from to: to].
|
|
for this we should implement #allSegmentsOfLinesUpTo:collect:
|
|
"
|
|
self assert: stop - start < maxChars.
|
|
lines
|
|
addAll:
|
|
(text
|
|
allSegmentsOfLinesCollect: [ :from :to | GrafoscopioLine new from: from to: to ])
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> container: aRectangle [
|
|
container := aRectangle
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> cursorWidth: anInteger [
|
|
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> emphasisHere: anObject [
|
|
self assert: (anObject isNil or: [ anObject isArray ])
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> lineIndexForPoint: aPoint [
|
|
^ 1
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> lineIndexOfCharacterIndex: anInteger [
|
|
^ 1
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> lines [
|
|
^ lines ifNil: [ lines := { GrafoscopioLine new }]
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> replaceFrom: anInteger to: anInteger2 with: aCollection [
|
|
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> text [
|
|
^ text
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> text: aCollection [
|
|
text := aCollection
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioComposer >> textStyle: aTextStyle [
|
|
styler := aTextStyle
|
|
]
|