00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __plot_gtk__
00010 #define __plot_gtk__
00011
00012 #include <gtk/gtk.h>
00013
00014 #define SCENE_REFRESH 500
00015 #define BORDER 15
00016
00017 struct prog_opt option;
00018 FILE *file_out, *file_err;
00019 int argc;
00020 char **argv;
00021
00022
00023
00024
00025 struct prog_opt {
00026 unsigned int opt_flag;
00027
00028 #define OPT_GTK_TEST 0x1000
00029 #define OPT_TEXT_MODE 0x2000
00030 };
00031
00032
00033 pthread_mutex_t plot_mutex;
00034
00035
00036 GtkWidget *window;
00037 GtkWidget *drawing_area;
00038
00039
00040 static GdkPixmap *xpm_scene = NULL;
00041
00042
00043 struct pixmap_obj {
00044 char *xpm_filename;
00045 GdkPixmap *pixmap;
00046 GdkBitmap *mask;
00047 unsigned int seq_count;
00048 unsigned int width;
00049 unsigned int height;
00050 };
00051
00052
00053 struct moveable_obj {
00054 int type;
00055 int x;
00056 int y;
00057 unsigned int width;
00058 unsigned int height;
00059 unsigned int seq;
00060 unsigned int seq_count;
00061 };
00062
00063
00064 struct pixmap_obj xpm_background[] = {
00065 { "images/background.xpm", NULL, NULL, 0, 632, 452},
00066 { NULL, NULL, NULL, 0, 0, 0 }
00067 };
00068
00069
00070 struct pixmap_obj xpm_robot[] = {
00071 { "images/robot.xpm", NULL, NULL, 0, 19, 19 },
00072 { NULL, NULL, NULL, 0, 0, 0 }
00073 };
00074
00075
00076 struct pixmap_obj xpm_sample[] = {
00077 { "images/point3x3r.xpm", NULL, NULL, 0, 3, 3 },
00078 { "images/point3x3b.xpm", NULL, NULL, 0, 3, 3 },
00079 { "images/point3x3c.xpm", NULL, NULL, 0, 3, 3 },
00080 { "images/point3x3y.xpm", NULL, NULL, 0, 3, 3 },
00081 { "images/point3x3g.xpm", NULL, NULL, 0, 1, 1 },
00082 { NULL, NULL, NULL, 0, 0, 0 }
00083 };
00084
00085 struct moveable_obj *moveable;
00086
00090
00091 void quit ();
00092 void get_size (GdkPixmap *xpm, unsigned int *width, unsigned int *height);
00093 void load_pixmaps (GtkWidget *widget, struct moveable_obj *moveable,
00094 struct pixmap_obj *pixmaps);
00095 void load_scene_pixmap(GtkWidget *widget);
00096 static gint configure_event (GtkWidget *widget, GdkEventConfigure *event);
00097 gint expose_event (GtkWidget *widget, GdkEventExpose *event);
00098 gint repaint (gpointer data);
00099 void test_repaint();
00100 void test_animation(int argc, char *argv[]);
00101 void init_animation(int argc, char *argv[], void (*repaint_func)());
00102 void scene_repaint();
00103
00107 void print_usage();
00108
00115 int parseopt(int argc, char **argv);
00116
00120 #ifndef DEBUG
00121 #define DEBUG
00122 #endif
00123 #ifdef DEBUG
00124 #define PROG_NAME "plot_gtk"
00125 #define DBG(f, a...) printf(f, ## a)
00126 #define DBGPROG(f, a...) printf(PROG_NAME ": " f, ## a)
00127 #else
00128 #define DBG(f, a...) do { } while(0);
00129 #define DBGPROG(f, a...) do { } while(0);
00130 #endif
00131
00132 #endif