Magritte description morph colour

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Magritte description morph colour

Ben Coman
I am trying to set the background color of the StringMorph that
represents the label & value of the description.

 From looking at MADescription>>morphColor
    ^ self propertyAt: #morphColor ifAbsent: [ self class
defaultMorphColor ]

 I thought I might go like "THIS LINE" below...
-------------------
magritteDescription
    <magritteContainer>
     | container |
    container := MAContainer new.
    container add: (MAStringDescription new
        accessor: #emptyString ;
        label: 'Equipment123456789' ;
        beReadonly ;
        propertyAt: #morphColor put: Color white;  
"<<<<<<<<<<<<<<<<<<THIS LINE"
        yourself).
        "more deleted"
    ^ container
-------------------
but "THIS LINE" has no effect.   Digging in further, it appears that
MADescriptionMorph>>defaultBackgroundColor is the only sender of
#morphColor,
but then there are no senders of #defaultBackgroundColor.

What is the correct way to go about changing the background color of the
description's morph?

cheers -ben

btw, What I am trying to create a separator label between several groups
of descriptions as shown in the attached image.





_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev

Magritte-separator-mockup.png (17K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Magritte description morph colour

Ben Coman
I achieved what I needed by subclassing MASeparatorMorph from MAElementMorph.  Could the attached mcz be merged into the Magritte trunk, or should I remove the MA and package it in my application only?  I do think it could be generally useful. 

I am using it as follows...
-----------------
magritteSeparator
    ^ (MAStringDescription new
        accessor: #emptyString ;
        label: thisContext sender methodClass cimClassName ;
        propertyAt: #morphClass put: MASeparatorMorph ;
        beReadonly ;
        yourself).
----------------
...where #magritteSeparator is defined just once in root-superclass of the model, and is called from each subclass that adds descriptions for its own instance variables.
btw, for the image in my previous post, the model classes were IdentifiedObject, Equipment and ConductingEquipment.

cheers -ben

Ben Coman wrote:
I am trying to set the background color of the StringMorph that represents the label & value of the description.

>From looking at MADescription>>morphColor
   ^ self propertyAt: #morphColor ifAbsent: [ self class defaultMorphColor ]

I thought I might go like "THIS LINE" below...
------------------- magritteDescription
   <magritteContainer>
    | container |
   container := MAContainer new.
   container add: (MAStringDescription new
       accessor: #emptyString ;
       label: 'Equipment123456789' ;
       beReadonly ;
       propertyAt: #morphColor put: Color white;   "<<<<<<<<<<<<<<<<<<THIS LINE"
       yourself).
       "more deleted"
   ^ container
------------------- but "THIS LINE" has no effect.   Digging in further, it appears that MADescriptionMorph>>defaultBackgroundColor is the only sender of #morphColor,
but then there are no senders of #defaultBackgroundColor.
What is the correct way to go about changing the background color of the description's morph?

cheers -ben

btw, What I am trying to create a separator label between several groups of descriptions as shown in the attached image.








_______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev

Magritte-Morph-BenComan.65.mcz (19K) Download Attachment