2022-03-16 18:37:51 +01:00
|
|
|
Class {
|
|
|
|
#name : #DiyaLabel,
|
|
|
|
#superclass : #DiyaWidget,
|
2022-03-21 22:39:52 +01:00
|
|
|
#instVars : [
|
|
|
|
'txt',
|
|
|
|
'icon'
|
|
|
|
],
|
2022-03-16 18:37:51 +01:00
|
|
|
#category : #'Diya-Widgets'
|
|
|
|
}
|
2022-03-21 22:39:52 +01:00
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaLabel >> icon [
|
|
|
|
^ icon
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaLabel >> icon: anObject [
|
|
|
|
icon := nil.
|
2022-03-23 00:52:15 +01:00
|
|
|
anObject isNumber ifTrue: [ icon := self addNode: (DiyaFontIcon data: anObject) ].
|
|
|
|
anObject isString ifTrue: [ icon := self addNode: (DiyaImageView from: anObject)].
|
2022-03-21 22:39:52 +01:00
|
|
|
icon ifNil: [ ^ DiyaCoreAPIError signal: 'Invalid icon identification'].
|
|
|
|
dirty := true.
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #initialization }
|
|
|
|
DiyaLabel >> initialize [
|
|
|
|
super initialize.
|
2022-03-23 00:52:15 +01:00
|
|
|
txt := self addNode:(DiyaText data: '').
|
2022-03-21 22:39:52 +01:00
|
|
|
icon := nil.
|
|
|
|
self extent: 0@0.
|
2022-03-23 00:52:15 +01:00
|
|
|
"style := DiyaDefaultStyle uniqueInstance."
|
2022-03-21 22:39:52 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaLabel >> txt [
|
|
|
|
^ txt
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaLabel >> txt: anObject [
|
|
|
|
txt data: anObject.
|
|
|
|
dirty := true
|
|
|
|
]
|
2022-03-23 00:52:15 +01:00
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaLabel >> updateLayout [
|
|
|
|
|offset isize|
|
|
|
|
offset := 0.
|
|
|
|
isize := style get: #fontSize.
|
|
|
|
icon ifNotNil: [
|
|
|
|
offset := isize + (isize >> 1).
|
|
|
|
icon position: 0 @ (extent y - isize)
|
|
|
|
].
|
|
|
|
txt extent: (extent x - offset) @ (extent y).
|
|
|
|
txt position: offset @ (extent y)
|
|
|
|
|
|
|
|
]
|