I wish we could remove this
self widget ifNotNil:
but this is more complex than I would like.
stef
Le 14/4/16 21:10, Stephan Eggermont a écrit :
On 14-04-16 16:53, peaslee wrote:
I do not understand your answer. I am too new at this.
ListModel is a subclass of AbstractWidgetModel.
AbstractWidgetModel defines borderWidth: and borderColor:,
so one would expect all its subclasses to implement it.
The mapping in Spec from the model to the actual widget
is in MorphicListAdapter, that is a subclass of AbstractMorphicAdapter.
The implementation is
AbstractMorphicAdapter>borderColor: color
self widget ifNotNil: [ :w | w borderColor: color ]
and
AbstractMorphicAdapter>borderWidth: width
self widget ifNotNil: [ :w | w borderWidth: width ]
To find out how the widget is created, we need to take a look
at its superclass AbstractAdapter, which has
AbstractAdapter class >adapt: aComposableModel
^ self new
adapt: aComposableModel;
yourself
and on the instance side
AbstractAdapter>adapt: aComposableModel
model := aComposableModel.
aComposableModel addDependent: self.
widget := self buildWidget.
buildWidget is then overridden for each concrete subclass
MorphicListAdapter>buildWidget
^ PluggableListMorph new
model: self;
getListSizeSelector: #listSize;
autoDeselect: self autoDeselect;
getIndexSelector: #getIndex;
setIndexSelector: #setIndex:;
getSelectionListSelector: #getSelectionStateFor:;
setSelectionListSelector: #setSelectionStateFor:at:;
backgroundColoringBlockOrSelector: #backgroundColorFor:at: ;
getListElementSelector: #listElementAt: ;
resetListSelector: #resetListSelection;
getMenuSelector: #menu:shifted: ;
setMultipleSelection: self multiSelection;
wrapSelector: #wrapItem:index: ;
setBalloonText: self help;
dragEnabled: self dragEnabled;
dropEnabled: self dropEnabled;
hResizing: #spaceFill;
vResizing: #spaceFill
So we see that the concrete widget is a PluggableListMorph.
That has a method borderStyleToUse which ignores values set to the
individual component:
PluggableListMorph>borderStyleToUse
"Answer the borderStyle that should be used for the receiver."
^self enabled
ifTrue: [self theme listNormalBorderStyleFor: self]
ifFalse: [self theme listDisabledBorderStyleFor: self]
If you then look at the different implementors of borderStyleToUse,
you'll notice that there are a lot of them that only ask the theme for
a style.
Stephan