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.

98 lines
3.0KB

  1. /* MousePlugin
  2. * Copyleft (C) 2002 Dan Bethell <dan@pawfal.org>
  3. * Dave Griffiths <dave@pawfal.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #include "MousePluginGUI.h"
  20. #include <FL/fl_draw.H>
  21. #include <FL/fl_draw.H>
  22. ScratchWidget::ScratchWidget (int x, int y, int w, int h, const char *l) :
  23. Fl_Widget (x, y, w, h, l),
  24. m_Data (0.0)
  25. {
  26. }
  27. void ScratchWidget::draw() {
  28. fl_color (color ());
  29. fl_rectf (x(), y(), w(), h());
  30. fl_push_clip (x(), y(), w(), h());
  31. int val = (int)(((m_Data * -1) + 1) * (h() / 2.0));
  32. fl_color (selection_color ());
  33. fl_rectf (x(), y() + val, w(), h());
  34. fl_pop_clip();
  35. }
  36. ////////////////////////////////////////////
  37. MousePluginGUI::MousePluginGUI (int w, int h, MousePlugin *o, ChannelHandler *ch, const HostInfo *Info) :
  38. SpiralPluginGUI (w, h, o, ch)
  39. {
  40. m_Port0 = new Fl_LED_Button (0, 10, 23, 23);
  41. m_Port0->type (FL_RADIO_BUTTON);
  42. m_Port0->labelsize (10);
  43. m_Port0->label ("ttyS0");
  44. m_Port0->set();
  45. m_Port0->callback ((Fl_Callback*)cb_Port0);
  46. m_Port1 = new Fl_LED_Button (50, 10, 23, 23);
  47. m_Port1->type (FL_RADIO_BUTTON);
  48. m_Port1->labelsize (10);
  49. m_Port1->label ("ttyS1");
  50. m_Port1->callback ((Fl_Callback*)cb_Port1);
  51. m_Scope = new ScratchWidget (10, 32, 80, 100, "Scratch");
  52. m_Scope->color(Info->SCOPE_BG_COLOUR);
  53. m_Scope->selection_color(Info->SCOPE_FG_COLOUR);
  54. end();
  55. }
  56. void MousePluginGUI::Update () {
  57. m_Scope->m_Data = m_GUICH->GetFloat ("Data");
  58. m_Scope->redraw();
  59. }
  60. void MousePluginGUI::UpdateValues (SpiralPlugin* o) {
  61. MousePlugin *Plugin = (MousePlugin*)o;
  62. if (Plugin->GetPort() == '1') m_Port1->setonly();
  63. }
  64. inline void MousePluginGUI::cb_Port0_i (Fl_LED_Button* o, void* v) {
  65. m_GUICH->Set("Port", '0');
  66. m_GUICH->SetCommand (MousePlugin::SETPORT);
  67. }
  68. void MousePluginGUI::cb_Port0 (Fl_LED_Button* o, void* v) {
  69. ((MousePluginGUI*)(o->parent ()))->cb_Port0_i (o, v);
  70. }
  71. inline void MousePluginGUI::cb_Port1_i (Fl_LED_Button* o, void* v) {
  72. m_GUICH->Set("Port", '1');
  73. m_GUICH->SetCommand (MousePlugin::SETPORT);
  74. }
  75. void MousePluginGUI::cb_Port1 (Fl_LED_Button* o, void* v) {
  76. ((MousePluginGUI*)(o->parent ()))->cb_Port1_i (o, v);
  77. }
  78. const string MousePluginGUI::GetHelpText (const string &loc) {
  79. return string("")
  80. + "\n"
  81. + "\n";
  82. }