1 // 2 // canvas.h 3 // 4 5 #ifndef __CANVAS_H__ 6 #define __CANVAS_H__ 7 8 #include "wx/brush.h" 9 #include "wx/colour.h" 10 #include "wx/dc.h" 11 #include "wx/scrolwin.h" 12 13 #include <vector> 14 15 16 class Edge; 17 class GTFrame; // see gui.h 18 class Graph; 19 class Vertex; 20 21 class wxFont; 22 23 class Canvas : public wxScrolledWindow 24 { 25 private: 26 static const int vertex_radius = 8; 27 static const int edge_width = 2; 28 static const int font_height = 8; 29 30 GTFrame *gui; 31 Graph **gg; 32 bool vertex_mode; 33 bool do_labels, do_weights, do_flows; 34 35 std::vector<wxColour> selection_colours; 36 wxColour white, black, red; 37 wxFont *bold_font, *normal_font; 38 39 int motion_last_x, motion_last_y; 40 41 DECLARE_EVENT_TABLE() 42 43 void draw (wxDC &dc, Vertex *v); 44 void draw (wxDC &dc, Edge *e, bool curved = false); 45 46 Vertex *findVertex (int x, int y) const; 47 Edge *findEdge (int x, int y) const; 48 void cb_Properties (); 49 50 public: 51 52 Canvas (GTFrame *gui, Graph **g); 53 void OnPaint (wxPaintEvent &event); 54 void OnEraseBackground (wxEraseEvent &event); 55 void OnClick (wxMouseEvent &event); 56 void OnMouseMove (wxMouseEvent &event); 57 void OnKeyPress (wxKeyEvent &event); 58 59 void redraw (); 60 void setVertexMode (bool v_mode = true); 61 void setEdgeMode (); 62 void setParam (bool labels, bool weights, bool flows); 63 }; 64 65 #endif // __CANVAS_H__ 66