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.

94 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_ask.H>
  20. #include <FL/fl_draw.H>
  21. #include "../../SpiralSynthModularInfo.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. const char *t=fl_input("and your comment is:", m_Comment.c_str());
  37. if (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. //int x,y;
  46. //fl_measure(m_Comment.c_str(),x,y);
  47. //m_DragBar->size(x,y);
  48. }
  49. }
  50. }
  51. return Fl_DeviceGUI::handle(event);
  52. }
  53. void Fl_CommentGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime)
  54. {
  55. Fl_DeviceGUI::Setup(Info,FirstTime);
  56. }
  57. void Fl_CommentGUI::Clear()
  58. {
  59. Fl_DeviceGUI::Clear();
  60. }
  61. void Fl_CommentGUI::StreamOut(ostream &s)
  62. {
  63. s<<1<<" ";
  64. s<<m_Comment.size()<<" ";
  65. s<<m_Comment<<endl;
  66. }
  67. void Fl_CommentGUI::StreamIn(istream &s)
  68. {
  69. unsigned int size,version;
  70. string temp;
  71. s>>version;
  72. s>>size;
  73. size++; // see below
  74. char *str = new char[size+1];
  75. s.read(str,size);
  76. str[size]='\0';
  77. // have to move the pointer on by one, as the string
  78. // starts with " ", as the file pointer starts on
  79. // a blank space (after streaming the size)
  80. m_Comment=str+1;
  81. delete[] str;
  82. m_DragBar->label(m_Comment.c_str());
  83. }