I use linux-2.6.31, X11R7.4, fltk-2.0.x-r692 and a 22 inch WideScreen
TFT-display with 5 ms reaction time.
Problem 1:
The following small program shows a vibrating text (text behind a schliere)when
the text is marching. Is this a display problem?
Problem 2:
When I drag the window vertically the marching time seems to increase during
the drag. After the drag the marching time seems to be normal again. Am I the
problem :-) ?
winfried
#include <stdlib.h>
#include <string.h>
#include <fltk/run.h>
#include <fltk/draw.h>
#include <fltk/Color.h>
#include <fltk/Widget.h>
#include <fltk/Window.h>
#include <fltk/Button.h>
#include <fltk/damage.h>
static const char *text="Simple example of a marquee text";
//#define TIMESTEP 0.035
#define TIMESTEP 0.037
//#define TIMESTEP 0.04
#define STARTDELAY 0.5
#define XSTEP 1
#define FONTH 30
#define FONTNAME TIMES
#define PADW 2
using namespace fltk;
static Window *win = NULL;
class ShiftText : public Widget
{
int pos, step, rest, textW, textH, textlen;
public:
int start, stopped;
ShiftText(int x, int y, int w, int h) :
Widget(x, y, w, h)
{
step = XSTEP; start = 1; stopped = 0;
};
void draw()
{
scroll_left();
fltk::redraw();
}
void scroll_left()
{
setfont(FONTNAME, FONTH);
if(start)
{
textlen = strlen(label());
measure(label(), textW, textH);
rest = textW+PADW; pos = w();
start = 0;
}
if(stopped)
{
if(!(damage() & DAMAGE_ALL)) return;
}
setcolor(color());
push_clip(0,0,w(),h());
fillrect(0,0,w(),h());
setcolor(RED);
drawtext(label(), textlen, pos, h() - getdescent());
pop_clip();
if(stopped) return;
pos -= step;
if((rest -= step) <= 0) stopped = 1;
}
};
static void repeat_cb(void *v)
{
ShiftText *st = (ShiftText*)v;
remove_timeout(repeat_cb, v);
if(st->stopped) return;
st->draw();
repeat_timeout(TIMESTEP, repeat_cb, v);
}
static void restart_cb(Widget *wid, void *v)
{
ShiftText *st = (ShiftText*)v;
if(!st->stopped)
{
st->stopped = 1;
remove_timeout(repeat_cb, v);
}
add_timeout(STARTDELAY, repeat_cb, st);
st->start = 1; st->stopped = 0;
}
static void cancel_cb(Widget *wid, void *v)
{
exit(0);
}
int main()
{
int x, y, w, boxh;
boxh = FONTH + PADW + PADW;
win = new Window(300, 12*boxh+10);
win->begin();
x = 5; y = win->h() - 35 - boxh; w = win->w()-10;
ShiftText *lhs = new ShiftText(x, y, w, boxh);
lhs->label(text);
Button *r = new Button(5,win->h()-30,60,25,"Restart");
r->callback(restart_cb, lhs);
Button *c = new Button(win->w()-65,win->h()-30,60,25,"Cancel");
c->callback(cancel_cb);
win->end();
win->show();
add_timeout(STARTDELAY, repeat_cb, lhs);
return run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk