00001
00002
00003 #ifndef __GRAPHICS_H
00004 #define __GRAPHICS_H
00005
00006 #include <gtk/gtk.h>
00007 #include <vector>
00008 #include <string>
00009 #include <iostream.h>
00010
00011
00012 using namespace std;
00013
00014 #define colmult 256
00015
00016 static const int GRAPHICS_SURFACE_0 = 0;
00017 static const int GRAPHICS_SURFACE_1 = 1;
00018
00019 static const int TEXT_ALIGN_LEFT = 0;
00020 static const int TEXT_ALIGN_RIGHT = 1;
00021 static const int TEXT_ALIGN_CENTER = 2;
00022
00023 static const int cGRIDPOINTS = 0;
00024 static const int cBACKGROUND = 1;
00025 static const int cWIREPOINTCONNECTED1 = 2;
00026 static const int cWIREPOINTCONNECTED2 = 3;
00027 static const int cWIREPOINTDISCONNECTED1 = 4;
00028 static const int cWIREPOINTDISCONNECTED2 = 5;
00029 static const int cWIRESELECTED = 6;
00030 static const int cWIREUNSELECTED = 7;
00031 static const int cCOMPONENTSELECTED = 8;
00032 static const int cCOMPONENTINVALID = 9;
00033 static const int cCOMPONENT = 10;
00034 static const int cCOMPONENTSHADOW = 11;
00035 static const int cCOMPONENTEXECUTING = 12;
00036 static const int cCOMPONENTLABEL = 13;
00037 static const int cCOMPONENTLABELSELECTED = 14;
00038 static const int cPIN = 15;
00039 static const int cWIREPOINTINVALID = 16;
00040 static const int cCROSSHAIR = 17;
00041
00042
00043
00044 static GdkGC *GCS[18];
00045
00046 class Point{
00047 public:
00048 Point(int x, int y);
00049 Point(int x, int y, void *tag);
00050 Point(Point *p);
00051 int x;
00052 int y;
00053 void *tag;
00054 };
00055
00056
00057 void show_msg(const char *title, const char *c);
00058
00059 class Graphics{
00060
00061 public:
00062 Graphics(GtkWidget *drawingarea, int width, int height, int nbsurfaces);
00063 Graphics(GtkWidget *drawingarea, int nbsurfaces);
00064 ~Graphics();
00065
00066 void create_colors();
00067
00068 int width();
00069 int height();
00070
00071 void draw_line(int x1, int y1, int x2, int y2, int colorindex);
00072 void draw_rectangle(int x, int y, int width, int height, bool fill, int colorindex);
00073 void draw_pixmap(GdkPixmap *pixmap, int x, int y, int width, int height);
00074 void draw_pixmap(gchar **pixmap, int x, int y, int width, int height);
00075 void render(GdkPixbuf *pixbuf, int x, int y, int width, int height);
00076
00077
00078 void clear(int color_index);
00079 void put_pixel(int x, int y, int colorindex);
00080
00081 void draw_text(int x, int y, const char *text, int colorindex);
00082 void draw_text(int x, int y, const char *text, int colorindex, int alignment);
00083 void apply();
00084 void repaint();
00085
00086 void copy_surface(int surface);
00087 void set_draw_surface(int surface);
00088
00089 GdkPixmap *currentpixmap;
00090 vector<GdkPixmap*> pixmaps;
00091
00092 private:
00093
00094 GdkGC *make_gc(int red, int green, int blue);
00095
00096 GtkWidget *drawingarea;
00097 GdkColormap *colormap;
00098
00099 public:
00100 int _width;
00101 int _height;
00102
00103 };
00104
00105
00106 #endif