00001
00002
00003 #ifndef GUITERMINAL_H
00004 #define GUITERMINAL_H
00005
00006 #include <gnome.h>
00007 #include <vector>
00008 #include <string>
00009 #include <fstream>
00010 #include "UITerminal.h"
00011 #include "GUILink.h"
00012 #include <math.h>
00013
00014 namespace FD {
00015
00016 class UINode;
00017 class UILink;
00018 class UINetTerminal;
00019 class ItemInfo;
00020
00021 class GUITerminal : public UITerminal {
00022 protected:
00023
00025 GnomeCanvasItem *item;
00026
00027 GnomeCanvasItem *item_text;
00028
00029 GtkTooltips *tooltip;
00030
00031 bool hidden;
00032
00033
00034 public:
00035
00036 void showName() {
00037 gnome_canvas_item_show(item_text);
00038 hidden = false;
00039 }
00040
00041 void hideName() {
00042 gnome_canvas_item_hide(item_text);
00043 hidden = true;
00044 }
00045
00046 GnomeCanvasItem * getItem() {return item;}
00047
00048 GUITerminal (ItemInfo *terminalInfo, UINode *_node, bool _isInput, double _x, double _y);
00049
00050 ~GUITerminal();
00051
00052 gint event(GdkEvent *event);
00053
00055 void move (double dx,double dy);
00056
00058 double dist(double &wx, double &wy)
00059 {
00060 double ix=x;
00061 double iy=y;
00062 gnome_canvas_item_i2w(item->parent, &ix, &iy);
00063 return sqrt((ix-wx)*(ix-wx) + (iy-wy)*(iy-wy));
00064 }
00065
00067 void getPos(double &wx, double &wy) const
00068 {
00069 wx=x;
00070 wy=y;
00071 gnome_canvas_item_i2w(item->parent, &wx, &wy);
00072 }
00073
00074 void updatePos() {
00075
00076 double x1,y1,x2,y2;
00077
00078 gnome_canvas_item_get_bounds(item,&x1,&y1,&x2,&y2);
00079
00080 x = (x1+x2) /2.0;
00081 y = (y1+y2) /2.0;
00082 }
00083
00084 void setAbsPos(double x1, double y1) {
00085
00086 double dx = x1 - x;
00087 double dy = y1 - y;
00088
00089 x = x1;
00090 y = y1;
00091
00092
00093 gnome_canvas_item_set(item,
00094 "x1",x1 - 2,
00095 "y1",y1 - 2,
00096 "x2",x1 + 2,
00097 "y2",y1 + 2,NULL);
00098
00099
00100 if (isInput) {
00101 gnome_canvas_item_set(item_text,
00102 "x",x + 5,
00103 "y",y - 0.5,NULL);
00104 }
00105 else {
00106 gnome_canvas_item_set(item_text,
00107 "x",x - 5,
00108 "y",y - 0.5,NULL);
00109 }
00110
00111
00112 move(dx,dy);
00113
00114
00115 }
00116
00117
00118 double getWidth() {
00119
00120 double x1,y1,x2,y2;
00121
00122 if (!hidden) {
00123 gnome_canvas_item_get_bounds(item_text,&x1,&y1,&x2,&y2);
00124
00125
00126
00127 return x2 - x1 + 5;
00128 }
00129 else {
00130 return 5.0;
00131 }
00132 }
00133
00134
00135
00136 };
00137
00138 }
00139 #endif