l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
January 6: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2003 Nov 26 16:59

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Text Scroller in Xlib---
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Text Scroller in Xlib---



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/

_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.