Symbian S60 - scrolling text in CEikLabel

I have one CEikLabel line in my application that needs to scroll the text.

A simple solution that comes to mind (but possibly naive) would be something like.

[begin pseduo code]

 on timer.fire {
  set slightly shifted text in label
  redraw label
 }
 start timer

[end pseudo code]

      

Using CPeriodic class as timer and label.DrawDeferred () for each update.

Do you think this is the best way, it can be a rather inefficient redrawing of the label two or three times per second .. but is there any other way?

Thank:)

+1


source to share


3 answers


I've seen a timer based solution used to scroll through item names in lists.

A few things to watch out for are that it may flicker slightly while scrolling and that you need to make sure that the text you are pasting on the label is not too long, otherwise it will automatically close the line and add elipsis (.. .)



Use TextUtils::ClipToFit

to get the string that fits on the label and remove the elipsis they added before putting the text on the label (search KTextUtilClipEndChar

your trimmed string). You will need to figure out how many characters to skip at the beginning of the line before passing it to the clip function.

+1


source


I don't know if there is any other way to do this, and I cannot tell if the approach you have in mind will be ineffective. However, you can take a look at this thread , which discusses almost the same question as yours and also briefly mentions the same solution as the one you have in mind.



+1


source


I did it like this

TTimeIntervalMicroSeconds32 scrolltime(70000);
iPeriodicScroll = CPeriodic::NewL(CActive::EPriorityIdle);
iPeriodicScroll->Start(scrolltime, scrolltime, TCallBack(CVisTagContainerView::ScrollTextL, this));

      

and then in a repeating function

CEikLabel *label = iContainer->Label();
const TDesC16 *temp = label->Text();
if (temp->Length() <= 0) { 
    if (iTextState != ETextIdle) { return; }
    DownloadMoreTextL();
    return;
}
TPtrC16 right = temp->Right(temp->Length()-1);
label->SetTextL(right);
label->DrawDeferred();

      

This way the text moves right and left, and when all is gone, the label is re-copied DownloadMoreTextL

+1


source







All Articles