|
#include <stdio.h>
#include <string.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <sys/time.h>
#include <gdk/gdkkeysyms.h>
#include <utime.h>
#include <time.h>
#include <glib.h>
#include <unistd.h>
#define FONT -*-helvetica-medium-*-*--36-*-*-*-*-*-iso8859-1"
int main(int argc,char *argv[])
{
GdkWindowAttr attr;
GdkGCValues value;
GdkWindow *win;
GdkGC *gc;
GdkFont *font;
Display *dpy;
int position_x =300;
int x = 300;
int total_width = 0;
gdk_init(&argc,&argv);
attr.wclass=GDK_INPUT_OUTPUT;
attr.width = 400;
attr.height = 300;
win = gdk_window_new(NULL, &attr, GDK_WA_X|GDK_WA_Y);
value.line_width = 0;
gc = gdk_gc_new_with_values(win,&value,GDK_GC_FOREGROUND );
gdk_window_show(win);
font=gdk_font_ref(gdk_fontset_load(FONT));
total_width = gdk_string_width( font,"tttttttttttttttttttt");
while(1){
gdk_window_clear(win);
gdk_draw_string(win, font, gc, position_x, 150, "tttttttttttttttttttt");
position_x = position_x -1;
usleep(15000);
if((position_x < -total_width) ){
total_width=gdk_string_width( font,"tttttttttttttttttttt");
position_x = x;
}
gdk_flush();
}
return 1;
}
不知道哪有問題 文字會閃動 >"<
試了好久 我想做跑馬燈~
請各位大大幫忙看看 Thanks |
|