Symbian S60 - 在 CEikLabel 中滚动文本
我的应用程序中有一行 CEikLabel 需要滚动文本。
我想到的简单解决方案(但可能很幼稚)类似于......
[begin pseduo code]
on timer.fire {
set slightly shifted text in label
redraw label
}
start timer
[end pseudo code]
在每次更新时使用 CPeridic 类作为计时器和 label.DrawDeferred() 。
您认为这是最好的方法吗?每秒重绘标签两到三次可能效率相当低。但是还有其他方法吗?
谢谢 :)
I have a single line CEikLabel in my application that needs to scroll text.
The 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 a CPeriodic class as the timer and label.DrawDeferred() on each update.
Do you think this is the best way, it may be rather inefficient redrawing the label two or three times a second.. but is there any other way?
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经看到基于计时器的解决方案用于滚动列表框中的项目名称。
需要注意的一些事情是,它在滚动时可能会闪烁一点,并且您需要确保放在标签上的文本不要太长,否则它会自动剪切字符串并添加省略号(.. .)
使用
TextUtils::ClipToFit
获取适合标签的字符串,并在将文本放在标签上之前删除它添加的省略号(在剪切的文本中搜索KTextUtilClipEndChar
细绳)。 在将字符串传递给剪辑函数之前,您需要计算出在字符串开头要跳过多少个字符。I've seen the timer based solution used for scrolling item names in listboxes.
A couple of things to watch out for are that it could flicker a bit while scrolling and that you need to make sure the text you put on the label is not too long, otherwise it will automatically clip the string and add an elipsis (...)
Use
TextUtils::ClipToFit
to get a string that fits on the label and remove the elipsis it adds before putting the text on the label (search forKTextUtilClipEndChar
in your clipped string). You will need to work out how many characters to skip at the beginning of the string before passing it to the clip function.我不知道是否还有其他方法可以做到这一点,也不能说你心中的方法是否会效率低下。 不过,您可能想看看此帖子其中讨论了与您的问题几乎相同的问题,并且还简要提到了与您构想的解决方案有些相同的解决方案。
I don't know whether there is another way to do it and can't say whether the approach you have in your mind will be inefficient. However, you may want to take a look at this thread which discusses pretty much the same question as yours and also briefly mentions somewhat the same solution as the one you have conceived of.
我已经这样做了
,然后在重复功能中
,因此文本从右向左移动,当全部消失时,标签将由 DownloadMoreTextL 重新填充
I have done it like this
and then in the repeated function
So text moves right to left, and when all gone, the label is repopulated by DownloadMoreTextL