Change foreground color a piece of fieldText

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

Change foreground color a piece of fieldText

Mario Carrera
Hi, I need to change the foreground color to a piece of AbtTextView.
I try to explain me  better: I have in a widget some fields (AbtTextView). In one of them, when the length of string is grater than 10 then changeForegroundColor.Es.  So from 1 to 10 text is black, from 11 to end of entrie text, it will be red.
How to do?
Im using vast 6.01
Thanks  

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/f5SR1CA6I7QJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Change foreground color a piece of fieldText

SebastianHC
Hi Mario,

I don't have access to a 6.01 installation, but I don't expect changes
since then.
If you have trouble I'll check this on an old version, too.

I attached one very simple, no thought on performance, sense, GCs and so
on...
I assume your problem is the non responding change on setting the
foreground: , anyway... it's the widget you have to access.

Have fun,
Sebastian


Am 18.11.2011 16:42, schrieb Mario Carrera:

> Hi, I need to change the foreground color to a piece of AbtTextView.
> I try to explain me  better: I have in a widget some fields
> (AbtTextView). In one of them, when the length of string is grater
> than 10 then changeForegroundColor.Es.  So from 1 to 10 text is black,
> from 11 to end of entrie text, it will be red.
> How to do?
> Im using vast 6.01
> Thanks
> --
> You received this message because you are subscribed to the Google
> Groups "VA Smalltalk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/va-smalltalk/-/f5SR1CA6I7QJ.
> To post to this group, send email to [hidden email].
> To unsubscribe from this group, send email to
> [hidden email].
> For more options, visit this group at
> http://groups.google.com/group/va-smalltalk?hl=en.
--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.


MyApplication1.app (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Change foreground color a piece of fieldText

SebastianHC
In reply to this post by Mario Carrera
Ups ;-)

You mean two colors within one TextView?

Okay,... that's not it,...

I'll have alook, but, never tried it.
 From a first thought, you might need a new Part.

Sebastian

Am 18.11.2011 16:42, schrieb Mario Carrera:

> Hi, I need to change the foreground color to a piece of AbtTextView.
> I try to explain me  better: I have in a widget some fields
> (AbtTextView). In one of them, when the length of string is grater
> than 10 then changeForegroundColor.Es.  So from 1 to 10 text is black,
> from 11 to end of entrie text, it will be red.
> How to do?
> Im using vast 6.01
> Thanks
> --
> You received this message because you are subscribed to the Google
> Groups "VA Smalltalk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/va-smalltalk/-/f5SR1CA6I7QJ.
> To post to this group, send email to [hidden email].
> To unsubscribe from this group, send email to
> [hidden email].
> For more options, visit this group at
> http://groups.google.com/group/va-smalltalk?hl=en.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Change foreground color a piece of fieldText

SebastianHC
In reply to this post by Mario Carrera
Hi Mario,

With AbtTextView you won't be able to have two Colors within your widget.
AbtTextView uses OSEditWidget and this widget sets the whole text at a time.

What you might have to consider. is searching an other widgetclass under
VAST 6.0.1 which uses the method

OSWidget>>#drawText: aString x: anX y: aY width: aWidth height: aHeight
flags: flags

You may then try to override this method like this.

drawText: aString x: anX y: aY width: aWidth height: aHeight flags: flags
         "Private - Draw aString using the platform dependant flags within
         the rectangle described by the anX, aY, aWidth and aHeight
parameters. "
     | text rect border nLeft nTop nRight nBottom |

     aString isNil ifTrue:[^self].

     self dcDo: [:hDC |
         "Create the drawing rectangle for the text."
         border := self borderWidth.
         nLeft := anX - border.
         nTop := aY - border.
         nRight := (nLeft + aWidth min: width - (border * 2)).
         nBottom :=  (nTop + aHeight min: height - (border * 2)).
         (rect := OSRect new)
             setRect: nLeft
             nTop: nTop
             nRight: nRight
             nBottom: nBottom.

         "Convert to a platform string before drawing."
         text := PlatformString fromString: aString.

         hDC
             drawText: (text copyFrom: 1 to: (text size min: 10))
             cb: (text size min: 10)
             lprc: rect
             fuFormat: flags.

         text size > 10
             ifTrue:[ hDC setTextColor: 16r000000 .

                         hDC
                             drawText: (text copyFrom: 10 to: text size)
                             cb: text size
                             lprc: rect
                             fuFormat: flags].

          hDC setTextColor: 16rFFFFFF.

     ].

Im not 100% sure if this will work properly, but it should.
This means in the end that you will end up with a new
Abt/Cw/OSTextWidget-kombination.

Or you search for senders of setTextColor: ,.. maybe you find another
solution or existing class.

Cheers!
Sebastian



Am 18.11.2011 16:42, schrieb Mario Carrera:

> Hi, I need to change the foreground color to a piece of AbtTextView.
> I try to explain me  better: I have in a widget some fields
> (AbtTextView). In one of them, when the length of string is grater
> than 10 then changeForegroundColor.Es.  So from 1 to 10 text is black,
> from 11 to end of entrie text, it will be red.
> How to do?
> Im using vast 6.01
> Thanks
> --
> You received this message because you are subscribed to the Google
> Groups "VA Smalltalk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/va-smalltalk/-/f5SR1CA6I7QJ.
> To post to this group, send email to [hidden email].
> To unsubscribe from this group, send email to
> [hidden email].
> For more options, visit this group at
> http://groups.google.com/group/va-smalltalk?hl=en.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Change foreground color a piece of fieldText

Mario Carrera
Thank you Sebastian I will try...but let me understand, you mind to try create a new kind of CwText?

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/va-smalltalk/-/5XkWMnsgajsJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Change foreground color a piece of fieldText

SebastianHC
yes,... new Classes for all three layers OS/Cw/Abt...

You may want to add new attributes to all layers,... position of color change and colors,...

If this is too much work for you, you could also use a MulitlineEditWidget.
There's codecoloring in VAST,.... StsPowertools include the coding. I'm not to sure if you have those implementatiosn inyou VAST 6.0.1

Or, it is simply time to upgrade ;-)
John will love to assist you!

Sebastian