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.

95 lines
2.4KB

  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_CommentGUI.h"
  19. #include <FL/fl_draw.H>
  20. #include "../../SpiralSynthModularInfo.h"
  21. #include "../../GUI/Widgets/PawfalInput.h"
  22. Fl_CommentGUI::Fl_CommentGUI(const DeviceGUIInfo& Info, Fl_Window *PW, Fl_Pixmap *Icon) :
  23. Fl_DeviceGUI(Info,PW,Icon),
  24. m_Comment("double click to edit.")
  25. {
  26. box(FL_NO_BOX);
  27. m_DragBar->box(FL_NO_BOX);
  28. m_DragBar->label(m_Comment.c_str());
  29. m_DragBar->color(SpiralSynthModularInfo::GUICOL_Device);
  30. // m_DragBar->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
  31. }
  32. int Fl_CommentGUI::handle(int event)
  33. {
  34. if (Fl::event_button()==1 && event==FL_PUSH && Fl::event_clicks()==1)
  35. {
  36. char t[1024];
  37. if (Pawfal_Input("and your comment is:", m_Comment.c_str(), t))
  38. {
  39. string temp(t);
  40. if (temp!="")
  41. {
  42. m_Comment=temp;
  43. m_DragBar->label(m_Comment.c_str());
  44. redraw();
  45. parent()->redraw();
  46. //int x,y;
  47. //fl_measure(m_Comment.c_str(),x,y);
  48. //m_DragBar->size(x,y);
  49. }
  50. }
  51. }
  52. return Fl_DeviceGUI::handle(event);
  53. }
  54. void Fl_CommentGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime)
  55. {
  56. Fl_DeviceGUI::Setup(Info,FirstTime);
  57. }
  58. void Fl_CommentGUI::Clear()
  59. {
  60. Fl_DeviceGUI::Clear();
  61. }
  62. void Fl_CommentGUI::StreamOut(ostream &s)
  63. {
  64. s<<1<<" ";
  65. s<<m_Comment.size()<<" ";
  66. s<<m_Comment<<endl;
  67. }
  68. void Fl_CommentGUI::StreamIn(istream &s)
  69. {
  70. unsigned int size,version;
  71. string temp;
  72. s>>version;
  73. s>>size;
  74. size++; // see below
  75. char *str = new char[size+1];
  76. s.read(str,size);
  77. str[size]='\0';
  78. // have to move the pointer on by one, as the string
  79. // starts with " ", as the file pointer starts on
  80. // a blank space (after streaming the size)
  81. m_Comment=str+1;
  82. delete[] str;
  83. m_DragBar->label(m_Comment.c_str());
  84. }