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.

108 lines
2.9KB

  1. /* DeviceGUI composite 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.H>
  19. #include <FL/Fl_Group.H>
  20. #include <FL/Fl_Button.H>
  21. #include <FL/Fl_Pixmap.h>
  22. #include <iostream>
  23. #include <vector>
  24. #include <string>
  25. #include "Fl_DragBar.H"
  26. #include <stdio.h>
  27. #ifndef DEVICEGUI
  28. #define DEVICEGUI
  29. #define WIRE_COL0 91
  30. #define WIRE_COL1 FL_GREEN
  31. #define WIRE_COL2 FL_YELLOW
  32. #define WIRE_COL3 FL_BLUE
  33. #define WIRE_COL4 FL_CYAN
  34. using namespace std;
  35. static const int TitleBarHeight = 12;
  36. static const int PortGroupWidth = 12;
  37. static const int PortSize=6;
  38. struct DeviceGUIInfo
  39. {
  40. int XPos;
  41. int YPos;
  42. int Width;
  43. int Height;
  44. int NumInputs;
  45. int NumOutputs;
  46. vector<string> PortTips;
  47. string Name;
  48. vector<int> PortTypes;
  49. };
  50. class Fl_DeviceGUI : public Fl_Group
  51. {
  52. public:
  53. Fl_DeviceGUI(const DeviceGUIInfo& Info, Fl_Group *PW, Fl_Pixmap *Icon);
  54. virtual int handle(int event);
  55. virtual void draw();
  56. enum PortType {INPUT,OUTPUT};
  57. int GetID() { return m_ID; }
  58. void SetID(int s) { m_ID=s; /*DisplayID(s);*/ }
  59. /*char did[8];
  60. void DisplayID(int s) { sprintf(did,"%d",s); label(did); }*/
  61. bool Killed() { return m_DelMe; }
  62. int GetPortX(int n) { return m_PortVec[n]->x()+PortSize/2; }
  63. int GetPortY(int n) { return m_PortVec[n]->y()+PortSize/2; }
  64. void ForcePortValue(int n, bool v) { m_PortVec[n]->value(v); }
  65. const DeviceGUIInfo* GetInfo() { return &m_Info; }
  66. Fl_Group* GetPluginWindow() { return m_PluginWindow; }
  67. // automatically called from the constructor, but may be redone at any time.
  68. virtual void Setup(const DeviceGUIInfo& Info, bool FirstTime = false);
  69. virtual void Clear();
  70. int GetPortType(int n) { return m_Info.PortTypes[n]; }
  71. protected:
  72. DeviceGUIInfo m_Info;
  73. Fl_DragBar* m_DragBar;
  74. Fl_Group* m_PluginWindow;
  75. Fl_Pixmap* m_Icon;
  76. private:
  77. inline void cb_Port_i(Fl_Button* o, void* v);
  78. static void cb_Port(Fl_Button* o, void* v);
  79. vector<Fl_Button*> m_PortVec;
  80. static int Numbers[512];
  81. string m_Name;
  82. int m_ID;
  83. bool m_DelMe;
  84. };
  85. #endif