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:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 24: LUGOD election season has begun!
Page last updated:
2003 Nov 26 20:06

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:Re: [vox-tech] Text Scroller in Xlib---
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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/

--__--__--
Hello Sir,
                           I was looking for help regrading Xlib for some graphics as I have two window i want to play movie in one window and in another window i want to scroll some image and text,For that purpose i gone thru so many documents so find problems

(1) How Blitting is possible in Xlib as when we make windows we specify same GC and whenever we will update gc it will update all display.

(2) How can we scroll text or Image flicker free in Xlib.

I am Looking for positive help from you side I hope u will help me I am giving you the code by which i am making windows.
Thanks and Regards
Linux---Worker
=========================================
void Init_X11()
{
XPixmapFormatValues *pf;
 int argc=1;
 int n;
 char * argv[2]={"swfplay",NULL};
 XSetWindowAttributes attr;
 unsigned long mask;
 XInitThreads();
 XtToolkitThreadInitialize();
 XtToolkitInitialize ();
 context = XtCreateApplicationContext();
 dpy = XtOpenDisplay (context,
  getenv("PLAYDPY")?getenv("PLAYDPY"):getenv("DISPLAY"),
   "ScrollPlay", "ScrollPlay", 0,0,
   &argc, argv);
 if (dpy == 0) {
  fprintf(stderr,"Can't open X display\n");
  system("reboot");
  exit(1);
 }
 if(!XShmQueryExtension(dpy)){
  fprintf(stderr,"No SHM extension found");
 }
  scr = DefaultScreenOfDisplay(dpy);
 screen = XScreenNumberOfScreen(scr);
 gc = DefaultGC(dpy, DefaultScreen(dpy));
 attr.bit_gravity = NorthWestGravity;
 attr.event_mask =
//  ButtonMotionMask |
//  ButtonPressMask |
//  ButtonReleaseMask |
  EnterWindowMask |
  ExposureMask |
//  KeyPressMask |
//  KeyReleaseMask |
//  LeaveWindowMask |
//  PointerMotionMask |
  StructureNotifyMask |
  VisibilityChangeMask |
  FocusChangeMask;
 mask = CWBitGravity | CWEventMask | CWBorderPixel | CWBackPixel;
 if (on_root) {
  //frame = VirtualRootWindowOfScreen(screen);
  Window root = RootWindow(dpy, DefaultScreen(dpy));
      XGetWindowAttributes(dpy, root, &wattr);
  width = 1020; /* wattr.width */
  height = 1000;/* wattr.height; */
  dprintf("use root window\n");
 }
 frame = XCreateSimpleWindow
  (dpy, RootWindow(dpy, screen),
   0, 0, 1020, 680, 0,
   BlackPixel(dpy,  screen),
   BlackPixel(dpy,  screen));
 
 scrollwin= XCreateSimpleWindow
  (dpy, RootWindow(dpy, screen),
   0,669, 1020,120, 0,
   BlackPixel(dpy,  screen),
   BlackPixel(dpy,  screen));
 dprintf("without root\n");
 XChangeWindowAttributes(dpy,scrollwin,mask,&attr);
 XChangeWindowAttributes(dpy,frame,mask,&attr);
 XMapWindow(dpy,frame);
 XMapWindow(dpy, scrollwin);
 XSetWindowBackground(dpy,scrollwin,GetColor("yellow"));
 XSetWindowBackgroundPixmap(dpy,scrollwin,None);
 XSelectInput(dpy, scrollwin, ExposureMask);
 XSetForeground(dpy, gc,GetColor("red"));
 
 XSetWindowBackground(dpy,frame,BlackPixel(dpy,  screen));
 XSetWindowBackgroundPixmap(dpy,frame,None);
 XSelectInput(dpy, frame, ExposureMask);
 XGetWindowAttributes(dpy, frame, &wattr);
 visual = wattr.visual;
 width = 1020;/*wattr.width;*/
 height = 690;/*wattr.height;*/
 XFlush(dpy);
 Widget topLevel  =
  XtAppCreateShell("drawingArea", "SwfPlay",
    topLevelShellWidgetClass, dpy, NULL, 0);
 widget = XtVaCreateWidget("form", compositeWidgetClass, topLevel, NULL);
 n = 0;
 XtSetArg(args[n], XtNheight, height); n++;
 XtSetArg(args[n], XtNwidth,  width);  n++;
 XtSetValues(topLevel, args, n);
 n = 0;
 XtSetArg(args[n], XtNheight, height); n++;
 XtSetArg(args[n], XtNwidth,  width);  n++;
 XtSetValues(widget, args, n); 
 topLevel->core.window = frame;
 XtRegisterDrawable(dpy,frame,topLevel);
 XtRealizeWidget(widget);
 XtRealizeWidget(topLevel);
 window = XtWindow(widget);
 XSetWindowBackground(dpy,window,BlackPixel(dpy,  screen));
 XSetWindowBackgroundPixmap(dpy,window,None);
 XtManageChild(widget);
 XFlush(dpy);
 //Pixmap pixmap=XCreatePixmap(dpy,frame,1,1,1);
 //static XColor black;
 //Cursor cursor=XCreatePixmapCursor(dpy,pixmap,pixmap,&black,&black,0,0);
 //Cursor dot=XCreateFontCursor(dpy,XC_man);
 XDefineCursor(dpy,window,None);
 XDefineCursor(dpy,frame,None);
 XWarpPointer(dpy,window,window,0,0,0,0,width,height);
 //XUnmapSubwindows(dpy,frame);
 playerWindow.window = (void*) window;
 playerWindow.x=0;
 playerWindow.y=0;
 playerWindow.width=width;          /* Maximum window size */
 playerWindow.height=690;
 playerWindow.clipRect.top =10;
 playerWindow.clipRect.left=10;
 playerWindow.clipRect.right=width;
 playerWindow.clipRect.bottom= 690;
 playerWindow.ws_info=&ws_info;
 ws_info.type=0;
 ws_info.display=dpy;
 ws_info.visual=visual;
 ws_info.colormap=DefaultColormap(dpy,screen);
 ws_info.depth=DefaultDepth(dpy,screen);
 font=XLoadFont(dpy,USE_FONT);
 XSetFont(dpy,gc,font);
 XUnmapSubwindows(dpy,frame);
}


Do you Yahoo!?
Free Pop-Up Blocker - Get it now

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:
EDGE Tech Corp.
For donating some give-aways for our meetings.