Re: is there an item.onTextStyleChanged ?

Return to index



Sergey Tkachenko

Posted: 04/29/2004 21:12:52

Applying text style to text items and non-text items is performed in

different ways.

While RichViewEdit changes a style of text items directly, for non-text

items it calls a special item method allowing them to respond on style


There is one more important difference between text and non-text items. For

text item, style applying changes their style (StyleNo item property). For

non-text item, item style must *not* be changed. StyleNo of non-text item is

not an index in the collection of text styles, it's a constant identifying

item type.

May be it would be better to take the example from Demos\Addins\LabelItem\

as a base for your item. It may be not necessary to create a control - item

can draw itself onto canvas and respond on mouse events.

Even if you still need a control, you can look how LabelItem works with the

associated text style.

Note: there were some changes in the latest version of TRichView (available

for registered users), so LabelItem was updated. Specifically, changes are

related to style applying.

> Hi Sergey,


> What we are trying to do is this:


> We are trying to embed a delphi control in trichview. This is obviously

> easy. In our case, the control actually represents a different,

> non-visual, aspect of our program to the user.  Therefore the control

> has text (representing the name and/or value of the non-visual part).

> We are trying to keep the font of the text in the control the same as

> what it should be. i.e. if the user selects several items that includes

> the control, and changes the font on the selection, the font on the

> control should change appropriately.


> We have followed the example in the \demos\addins\chartItem to create a

> new item. We have modified the print routine so our controlItem prints

> properly. That works wonderfully.


> When streaming out, we don't want to save the control (as happens in

> default saveToRVF), because we want to keep the possibility of changing

> the type of this control in future versions of our product. We want to

> stream out the controlItem, without the control, and when we stream the

> item back in, dynamically create the appropriate control.


> So, we now want to store the style number, so that when we stream in

> our new item, we can reapply that style to the control. Now, I am still

> relatively new to trichview, but it seems that the styleNum property of

> an item is overloaded for different purposes.  One is the item type

> (i.e. text, component, bullet, table), and the other is a font style

> number. It would be easier if these were two different properties, so

> that a controlItem could have a font style, for instance.


> What is the easiest way to do what we need with trichview. We want to

> be able to create a descendant of the control item and remember what

> font style it had. I ordered your software but have not received the

> source yet. Is there a setStyle for the controlItem I can override to

> store the style number, even though it seems I have to make my style

> return -12345 or something. How do I let richview know that this style

> is being used by my item.


> I know this is complex so I really thank you for your help in this

> matter.


> -Dave



> Sergey Tkachenko wrote:


> > Currently no function/event is called on changing text style of item.

> > Can you explain why it's needed?

> > May be I'll add this functionality.

> >

> > > I would like to execute some code when an item changes text style.

> > > Is there a way to trap this?  Preferably through an event, but if

> > > need be we could override a setStyle-type method in our own

> > > *ItemInfo descendent.


Powered by ABC Amber Outlook Express Converter