Omnibrowser, italic Traits' method names

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

Omnibrowser, italic Traits' method names

Juraj Kubelka-4
Hi All,

May I ask you, how is it done that Traits' method names are displayed  
in italic?  I cannot find a code which do this.

Thank you in advance,
Juraj

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Robert Krahn
Hello Juraj,

the code you are looking for is in OBMethodNode>>displayString. There  
the text attribute TextEmphasis italic is added when the selector  
belongs to a trait (= is not local)

Regards
Robert

Am 23.06.2007 um 17:29 schrieb Juraj Kubelka:

> Hi All,
>
> May I ask you, how is it done that Traits' method names are  
> displayed in italic?  I cannot find a code which do this.
>
> Thank you in advance,
> Juraj
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Juraj Kubelka-4
Hello Robert,

Thank you!

I am playing with OB and I tried to make a filter which should  
display Traits' names with bold text.  But it doesn't work.  It  
displays prefix '(t) ' but nothing more. I have no idea where is the  
mistake.  Do you have any idea?  I can file out the filter class, if  
you wish.

displayString: aString forNode: aNode
        (aNode isKindOf: OBClassNode) ifFalse: [^ aString].
        ^ ((aNode theClass respondsTo: #isTrait) and: [ aNode theClass  
isTrait ])
                ifTrue: [('(t) ', aString) asText addAttribute: TextEmphasis bold ]
                ifFalse: ['(c) ', aString].


Thank you in advance,
Juraj

On 23.6.2007, at 18:32, Robert Krahn wrote:

> Hello Juraj,
>
> the code you are looking for is in OBMethodNode>>displayString.  
> There the text attribute TextEmphasis italic is added when the  
> selector belongs to a trait (= is not local)
>
> Regards
> Robert
>
> Am 23.06.2007 um 17:29 schrieb Juraj Kubelka:
>
>> Hi All,
>>
>> May I ask you, how is it done that Traits' method names are  
>> displayed in italic?  I cannot find a code which do this.
>>
>> Thank you in advance,
>> Juraj
>>
>> _______________________________________________
>> Beginners mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Robert Krahn
Hello Juraj,

 From where do you call #displayString:forNode: ?


Am 23.06.2007 um 19:11 schrieb Juraj Kubelka:

> Hello Robert,
>
> Thank you!
>
> I am playing with OB and I tried to make a filter which should  
> display Traits' names with bold text.  But it doesn't work.  It  
> displays prefix '(t) ' but nothing more. I have no idea where is  
> the mistake.  Do you have any idea?  I can file out the filter  
> class, if you wish.
>
> displayString: aString forNode: aNode
> (aNode isKindOf: OBClassNode) ifFalse: [^ aString].
> ^ ((aNode theClass respondsTo: #isTrait) and: [ aNode theClass  
> isTrait ])
> ifTrue: [('(t) ', aString) asText addAttribute: TextEmphasis bold ]
> ifFalse: ['(c) ', aString].
>
>
> Thank you in advance,
> Juraj
>
> On 23.6.2007, at 18:32, Robert Krahn wrote:
>
>> Hello Juraj,
>>
>> the code you are looking for is in OBMethodNode>>displayString.  
>> There the text attribute TextEmphasis italic is added when the  
>> selector belongs to a trait (= is not local)
>>
>> Regards
>> Robert
>>
>> Am 23.06.2007 um 17:29 schrieb Juraj Kubelka:
>>
>>> Hi All,
>>>
>>> May I ask you, how is it done that Traits' method names are  
>>> displayed in italic?  I cannot find a code which do this.
>>>
>>> Thank you in advance,
>>> Juraj
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>
>> _______________________________________________
>> Beginners mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Juraj Kubelka-5
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Lukas Renggli
> It is a standard OB filter subclassed from OBFilter.  It is added to
> OBCodeBrowser metagraph. There are source codes in attachment.

Have a look at OB-Refactory, it uses filters to show elements within
an environment in bold:

displayString: aString forParent: aParentNode child: aNode
        "Display elements that are part of the environment in bold."
       
        ^ (mode = #highlight and: [ aNode withinBrowserEnvironment: environment ])
                ifTrue: [ Text string: aString attribute: TextEmphasis bold ]
                ifFalse: [ aString ]

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Robert Krahn
Hello Juraj,

the reason why your code doesn't work is located in  
OBClassSortFilter>>displayString:forParent:child: . This filter is  
evaluated after the OBTraitColorFilter. The string which is passed to  
this method is your created Text. But in this method a new String  
(which is a ByteString) is constructed. There your text attribute is  
lost.

If I have some time later on I will look for a workaround.

Regards
Robert
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Robert Krahn
Hello Juraj

If you replace String with Text in  
OBClassSortFilter>>displayString:forParent:child: everything works  
fine. But thats quite dirty. I think something general should be  
changed with the handling of those displayString methods. On the one  
hand sometimes Text-objects are used (and needed for the attributes).  
On the other hand the variables which refer to those objects are  
named aString and sometimes they are Strings.

Best, Robert
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Juraj Kubelka-5
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Robert Krahn

Am 24.06.2007 um 00:44 schrieb Juraj Kubelka:

It is possible to use TextEmphasis>>bold now but TextColor>>green attribute doesn't work.


Yes, thats why the standard colors in LazyListMorph overwrite your chosen color. LazyListMorph >>display: atRow:on: looks like that:

display: item  atRow: row on: canvas
"display the given item at row row"
| drawBounds |
drawBounds := self drawBoundsForRow: row.
drawBounds := drawBounds intersect: self bounds.
item isText
ifTrue: [ canvas drawString: item in: drawBounds font: (font emphasized: (item emphasisAt: 1)) color: (self colorForRow: row) ]
ifFalse: [ canvas drawString: item in: drawBounds font: font color: (self colorForRow: row) ].

The item is your displayString but the color is changed to LazyListMorph >>colorForRow: which turns out to be the follow:

colorForRow: row
^(selectedRow notNil and: [ row = selectedRow])
ifTrue: [ Color red ]
ifFalse: [ self color ].

It seems that those things are really in the guts of the system and because of that they cannot be parameterized easily (yet).

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Omnibrowser, italic Traits' method names

Robert Krahn
Sorry, I don't want to spam you but I thought about a possible solution for that issue.

The first thing one could do is to subclass LazyListMorph to have a Morph which permits the displayStrings to keep their color. Then there is the need for a new PluggableListMorph which overrides PluggableListMorph >>listMorphClass to get this subclass of LazyListMorph. The next thing is to construct another OBMorphBuilder which changes #listMorphForColumn:.

Then a new builder exists which delivers browsers with the wanted property. I don't know if there are other classes which have to be changed (OBPane?) or if there is an easier solution. Please give me your opinion.

Robert 

Am 24.06.2007 um 02:18 schrieb Robert Krahn:


Am 24.06.2007 um 00:44 schrieb Juraj Kubelka:

It is possible to use TextEmphasis>>bold now but TextColor>>green attribute doesn't work.

Yes, thats why the standard colors in LazyListMorph overwrite your chosen color. LazyListMorph >>display: atRow:on: looks like that:

display: item  atRow: row on: canvas
"display the given item at row row"
| drawBounds |
drawBounds := self drawBoundsForRow: row.
drawBounds := drawBounds intersect: self bounds.
item isText
ifTrue: [ canvas drawString: item in: drawBounds font: (font emphasized: (item emphasisAt: 1)) color: (self colorForRow: row) ]
ifFalse: [ canvas drawString: item in: drawBounds font: font color: (self colorForRow: row) ].

The item is your displayString but the color is changed to LazyListMorph >>colorForRow: which turns out to be the follow:

colorForRow: row
^(selectedRow notNil and: [ row = selectedRow])
ifTrue: [ Color red ]
ifFalse: [ self color ].

It seems that those things are really in the guts of the system and because of that they cannot be parameterized easily (yet).
_______________________________________________
Beginners mailing list


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners