00001
00002
00003 #ifndef __EDITOR_H
00004 #define __EDITOR_H
00005
00006 #include <gtk/gtk.h>
00007 #include <vector>
00008 #include "propertyeditor.h"
00009 #include "graphics.h"
00010 #include "component.h"
00011 #include "wire.h"
00012 #include "filterloader.h"
00013 #include "frame.h"
00014
00015
00016 using namespace std;
00017
00018 static int EDITOR_MODE_SELECT = 0;
00019 static int EDITOR_MODE_WIRE_START = 1;
00020 static int EDITOR_MODE_WIRE_ADDPOINT = 2;
00021 static int EDITOR_MODE_COMPONENT_PLACE = 3;
00022 static int EDITOR_MODE_COMPONENT_MOVE = 4;
00023
00024
00025 class Editor{
00026
00027 public:
00028 Editor(FilterLoader *filterloader);
00029 ~Editor();
00030
00031 void set_filter_loader(FilterLoader *filterloader);
00032 void create_filter_icon_toolbar();
00033
00034 void create_gui();
00035 void add_component(Component *component);
00036 void remove_component(Component *component);
00037 void add_wire(Wire *wire);
00038 void remove_wire(Wire *wire);
00039 void paint_background();
00040 void paint_foreground();
00041 void paint_components();
00042 void paint_wires();
00043 Component *get_component_at(int tx, int ty);
00044 Wire *get_wire_at(int tx, int ty);
00045 vector<Wire *> *get_wires_at(int tx, int ty);
00046 bool can_place_component(Component *c);
00047
00048 void start_select_mode();
00049 void start_wire_mode();
00050 void start_component_mode();
00051 void update_status_bar1();
00052 void update_status_bar2(int x, int y);
00053 void update_status_bar3(char *temp);
00054 void update_property_grid();
00055 void update_left_toolbar();
00056
00057 void add_possible_component(Component *c);
00058
00059
00060 public:
00061 Graphics *graphics;
00062 string statusbuffer;
00063
00064
00065
00066 private:
00067
00068 FilterLoader *filterloader;
00069 PropertyEditor *propertyeditor;
00070
00071
00072 GtkWidget *window;
00073 GtkWidget *drawing_area;
00074 GdkPixmap *pixmap;
00075 GtkWidget *label1;
00076 GtkWidget *label2;
00077 GtkWidget *label3;
00078
00079 GtkWidget *basic_toolbar;
00080 GtkWidget *tool_toolbar;
00081 GtkWidget *filter_toolbar;
00082 GtkWidget *vbox4;
00083
00084 GtkWidget *select_button;
00085 GtkWidget *wire_button;
00086 GtkWidget *filter_button;
00087 GtkWidget *open_button;
00088 GtkWidget *save_button;
00089 GtkWidget *cut_button;
00090 GtkWidget *copy_button;
00091 GtkWidget *paste_button;
00092 GtkWidget *delete_button;
00093 GtkWidget *rotate_button;
00094 GtkWidget *execute_button;
00095
00096 bool toggle_update_ok;
00097
00098
00099 vector<Component *> possiblecomponents;
00100 int currentcomponenttool_index;
00101
00102
00103
00104 int scale;
00105 vector<Component *> components;
00106 vector<Wire *> wires;
00107 Component *currentcomponent;
00108 bool currentcomponent_canplace;
00109 int component_move_start_x;
00110 int component_move_start_y;
00111 Wire *currentwire;
00112 int mode;
00113 int state;
00114 int mouse_x;
00115 int mouse_y;
00116 int mouse_tx;
00117 int mouse_ty;
00118
00119
00120 vector<GtkWidget *> filter_buttons;
00121
00122
00123 void create_filter_toolbar(int startindex);
00124
00125
00126 void exposed();
00127 void key_released(GdkEventKey *event);
00128 void mouse_motion(GdkEventMotion *event);
00129 void mouse_left_click(GdkEventButton *event);
00130 void mouse_left_double_click(GdkEventButton *event);
00131 void mouse_right_click(GdkEventButton *event);
00132 void mouse_button_released(GdkEventButton *event);
00133 void toolbar_toggle(GtkWidget *toolbar_button);
00134
00135 void __openfile();
00136 void __savefile();
00137 void __importfilter();
00138 void __exit();
00139 void __cut();
00140 void __copy();
00141 void __paste();
00142 void __delete();
00143 void __rotate();
00144 void __propertyeditor();
00145 void __execute();
00146 void __about();
00147 void __help1();
00148 void __help2();
00149
00150
00151
00152 friend gboolean editor_key_release_event(GtkWidget *widget,
00153 GdkEventKey *event,
00154 Editor *editor);
00155 friend gboolean editor_expose_event(GtkWidget *widget,
00156 GdkEventExpose *event,
00157 Editor *editor);
00158 friend gboolean editor_motion_notify_event(GtkWidget *widget,
00159 GdkEventMotion *event,
00160 Editor *editor);
00161 friend gboolean editor_button_press_event(GtkWidget *widget,
00162 GdkEventButton *event,
00163 Editor *editor);
00164 friend gboolean editor_button_release_event(GtkWidget *widget,
00165 GdkEventButton *event,
00166 Editor *editor);
00167 friend void toolbar_toggle_handler(GtkWidget *widget,
00168 Editor *editor);
00169
00170 friend void h__openfile(GtkMenuItem *, Editor *);
00171 friend void h__savefile(GtkMenuItem *, Editor *);
00172 friend void h__importfilter(GtkMenuItem *, Editor *);
00173 friend void h__exit(GtkMenuItem *, Editor *);
00174 friend void h__cut(GtkMenuItem *, Editor *);
00175 friend void h__copy(GtkMenuItem *, Editor *);
00176 friend void h__paste(GtkMenuItem *, Editor *);
00177 friend void h__delete(GtkMenuItem *, Editor *);
00178 friend void h__rotate(GtkMenuItem *, Editor *);
00179 friend void h__propertyeditor(GtkMenuItem *, Editor *);
00180 friend void h__execute(GtkMenuItem *, Editor *);
00181 friend void h__about(GtkMenuItem *, Editor *);
00182 friend void h__help1(GtkMenuItem *, Editor *);
00183 friend void h__help2(GtkMenuItem *, Editor *);
00184
00185
00186
00187 };
00188
00189 #endif