You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.6KB

  1. /* Canvas Widget
  2. * Copyleft (C) 2002 David Griffiths <dave@pawfal.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <FL/Fl_Group.h>
  19. #include <FL/Fl_Output.h>
  20. #include <FL/Fl_Image.h>
  21. #include <vector>
  22. #include <string>
  23. #include "../../GraphSort.h"
  24. #ifndef CANVAS_WIDGET
  25. #define CANVAS_WIDGET
  26. using namespace std;
  27. class Fl_DeviceGUI;
  28. class CanvasWire
  29. {
  30. public:
  31. CanvasWire() { Clear(); }
  32. void Clear()
  33. {
  34. OutputChild=-1;
  35. OutputPort=-1;
  36. OutputID=-1;
  37. InputChild=-1;
  38. InputPort=-1;
  39. InputID=-1;
  40. }
  41. int OutputID;
  42. int OutputChild;
  43. int OutputPort;
  44. int InputID;
  45. int InputChild;
  46. int InputPort;
  47. };
  48. class Fl_Canvas : public Fl_Group
  49. {
  50. public:
  51. Fl_Canvas(int x, int y, int w, int h, char *name);
  52. ~Fl_Canvas();
  53. virtual void draw();
  54. virtual int handle(int event);
  55. void PortClicked(Fl_DeviceGUI* Device, int Type, int Port, bool Value);
  56. void SetConnectionCallback(Fl_Callback* s) { cb_Connection=s; }
  57. void SetUnconnectCallback(Fl_Callback* s) { cb_Unconnect=s; }
  58. void SetAddDeviceCallback(Fl_Callback* s) { cb_AddDevice=s; }
  59. void ClearConnections(Fl_DeviceGUI* Device);
  60. void RemoveDevice(Fl_DeviceGUI* Device);
  61. void Clear();
  62. void AddPluginName(const string &s, int ID)
  63. { m_PluginNameList.push_back(pair<string,int>(s,ID)); }
  64. GraphSort* GetGraph() { return &m_Graph; }
  65. private:
  66. void DrawWires();
  67. Fl_Image *m_BG;
  68. char *m_BGData;
  69. void (*cb_Connection)(Fl_Widget*, void*);
  70. void (*cb_Unconnect)(Fl_Widget*, void*);
  71. void (*cb_AddDevice)(Fl_Widget*, void*);
  72. vector<CanvasWire> m_WireVec;
  73. CanvasWire m_IncompleteWire;
  74. bool m_ToolMenu, m_ButtonDown;
  75. int m_x,m_y,m_Selected;
  76. vector< pair<string,int> > m_PluginNameList;
  77. GraphSort m_Graph;
  78. friend istream &operator>>(istream &s, Fl_Canvas &o);
  79. friend ostream &operator<<(ostream &s, Fl_Canvas &o);
  80. };
  81. istream &operator>>(istream &s, Fl_Canvas &o);
  82. ostream &operator<<(ostream &s, Fl_Canvas &o);
  83. #endif