Page 1 of 1

AppendRVFFromStream - No Bullets ?

Posted: Wed Jul 02, 2008 10:33 am
by wray
Hi,

i use

RichViewEdit1->AddBulletEx("", 0, Form1->ImageList3, -1);
RichViewEdit1->Reformat();

to add a bullet..

But when i try:

TMemoryStream *stream = new TMemoryStream();
RichViewEdit1->SaveRVFToStream(stream,false);
stream->Seek(0,0);
tabel->Cells[0][1]->VAlign = rvvaAbsMiddle;
tabel->Cells[0][1]->AppendRVFFromStream(stream,-1,Dummy1,Dummy2);
delete stream;

I get only the text, no bullets. Is in same application.

Please advise

Also would be great for me if i could trigger the SaveRVFToStream (event), because then i itinerate the bullets when they are about to be saved in a stream and replace them back with the text corespondents ( for smileys - when i find 0 index in ImageList3, means is :) )

Regards

P.S. Please also tell me how do i get the caret position in curent line, i am using RichViewEdit1->GetCurrentItemText(); to get the text i am typing.

(i need it to replace :) with a bullet smiley)

Posted: Thu Jul 03, 2008 7:02 am
by Sergey Tkachenko
When loading "bullets" or "hotspot" item from RVF, OnRVFImageListNeeded event occurs, where you need to specify the image list for this item.
For example,

Code: Select all

void __fastcall TForm1::RichViewEdit1RVFImageListNeeded(TCustomRichView *Sender,
    int ImageListTag, TCustomImageList *&il)
{
  il = ImageList3;
}
As for executing some custom code before saving. Since you save to the file yourself, you can add this code yourself before SaveRVF(). If you need to do it before copying to the clipboard, use OnCopy event.

Posted: Thu Jul 03, 2008 7:06 am
by Sergey Tkachenko
As for the second question, it is OffsetInCurItem property (or better, to support tables, RichViewEdit1->TopLevelEditor->OffsetInCurItem)
The example of replacing text to emoticons on typing can be found in Demos\CBuilder\Assorted\Graphics\Emoticons

Posted: Thu Jul 03, 2008 11:55 am
by wray
Most helpfull like always.

Thank you very much

Posted: Thu Jul 03, 2008 1:16 pm
by wray
Can you hint me what i am doing wrong with the VAlign here ?

OnKeyPress i did the emoticon replacement with align like this:

if (s[Offs-1]==':')
{
rve->SetSelectionBounds(ItemNo, Offs-1, ItemNo, Offs);
rve->InsertBullet(GetImageIndex(Key), Form1->ImageList3);
Key = 0;
((TRVBulletItemInfo*)(RichViewEdit1->GetCurrentItem()))->VAlign = rvvaAbsMiddle;
RichViewEdit1->Reformat();
}

and i get good align in RichViewEdit1 lik ein picture:

Image

but when i append it from stream in table, i get bad align...

Code is:

TMemoryStream *stream = new TMemoryStream();
RichViewEdit1->SaveRVFToStream(stream,false);
stream->Seek(0,0);
tabel->Cells[0][1]->VAlign = rvvaAbsMiddle;
tabel->Cells[0][1]->AppendRVFFromStream(stream,-1,Dummy1,Dummy2);
tabel->Cells[0][1]->VAlign = rvvaAbsMiddle;
RichView1->AddItem("Spreadsheet", tabel);
RichView1->FormatTail();

And it looks like in this picture:

Image

Thank you

Posted: Thu Jul 03, 2008 2:07 pm
by Sergey Tkachenko
Unfortunately, VAlign of "bullets" and "hotspots" is not saved in RVF.
It will be fixed in the next update (but not sooner than after 2 weeks).

Posted: Thu Jul 03, 2008 5:11 pm
by wray
Is ok.

But can you think of a method to align them manually after they have been appended in table ?

Like for loop to scan all the items in cell and align them manually each of them ?

Regards

Posted: Thu Jul 03, 2008 5:25 pm
by Sergey Tkachenko

Code: Select all

TMemoryStream *stream = new TMemoryStream(); 
RichViewEdit1->SaveRVFToStream(stream,false); 
stream->Seek(0,0); 
int ItemCount = tabel->Cells[0][1]->ItemCount;
tabel->Cells[0][1]->AppendRVFFromStream(stream,-1,Dummy1,Dummy2); 
for (int i =ItemCount; i<tabel->Cells[0][1]->ItemCount; i++)
  if (tabel->Cells[0][1]->GetItemStyle(i)==rvsBullet)
    ((TRVBulletItemInfo*)(tabel->Cells[0][1]->GetItem(i)))->VAlign = rvvaAbsMiddle;
RichView1->AddItem("Spreadsheet", tabel); 
RichView1->FormatTail(); 

Posted: Thu Jul 03, 2008 5:30 pm
by Sergey Tkachenko
And rvvaAbsMiddle is not a valid value for Cell->VAlign.
Available values for Cell->VAlign: rvcTop, rvcMiddle, rvcBottom, rvcVDefault (TRVCellVAlign type).

rvvaAbsMiddle can be used only for VAlign of items, not cells. It is of TRVVAlign type.

Posted: Fri Jul 04, 2008 10:11 am
by wray
Thank you

Working perfectly