[vox-tech] Text Scroller in Xlib---
Bill Kendrick
vox-tech@lists.lugod.org
Wed, 26 Nov 2003 01:41:01 -0800
On Wed, Nov 26, 2003 at 01:00:43AM -0800, Sharad Bajaj wrote:
> Hello Mr Julie Russell ,
(Julie would be a "Ms", "Mrs" or the like, FYI ;^) )
> I have seen one or two message from ur side regrading one
> application .I am also developing same application I am looking for
> help how can we scroll text in child window,please help me i will be
> very great full to u. Regards
I vaguely remember the thread about that. I don't recall if there
was any consensus or solution, though.
Out of curiosity, are you planning to use plain Xlib, or are you going to
(or willing to) use a toolkit on top of it, like GTK+ or Qt?
I've done Xlib, long ago, but didn't do anything very fancy with text.
I usually stuck with fixed-width (non-proportional) fonts, and used them
for status displays in games. :^)
Either way, though, the way _I_ would do it would be to, in my main loop,
have something that acts as a timer. Every 30th of a second (or 20th, 50th,
60th, whatever...), increment a "position" variable, and use that to
determine what part of my text string to display, and where.
For something like a stock market ticker, or news crawl, it shouldn't be
to hard to get something that, over time, looks like this:
HELLO THIS IS MY
HELLO THIS IS MY S
HELLO THIS IS MY SC
HELLO THIS IS MY SCR
HELLO THIS IS MY SCRO
ELLO THIS IS MY SCROL
LLO THIS IS MY SCROLL
LO THIS IS MY SCROLLE
O THIS IS MY SCROLLER
THIS IS MY SCROLLER
...
I've seen this done in web pages (especially popular a few years ago, was
to make things like these appear in web browser status bars) using JavaScript
to update the text.
One problem with this is that most of the time they used proportional fonts,
so the text would move jerkily. Consider if you had the string:
IIWWIWIWIWWIWIWIIWWIWWIIW
with an 'Arial'-style font. When a "W" disappeared off the left edge, the
string would move many more pixels to the left than if an "I" had disappeared
(since the "W" is, say, 12 pixels wide, while the "I" is only 2 pixels!)
So I would do a combination of moving within the string, to determine what
portion to display in the window, along with fine-scrolling by changing
the pixel position of the string.
I hope that makes some sense. ;)
Good luck!
-bill!
(who has mostly moved on from straight X-lib)
bill@newbreedsoftware.com Got kids? Get Tux Paint!
http://newbreedsoftware.com/bill/ http://newbreedsoftware.com/tuxpaint/