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.

127 lines
3.4KB

  1. /* SpiralPlugin
  2. * Copyleft (C) 2000 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 "TrigPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_draw.H>
  21. #include <stdio.h>
  22. ////////////////////////////////////////////
  23. TrigPluginGUI::TrigPluginGUI(int w, int h,TrigPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
  24. SpiralPluginGUI(w,h,o,ch)
  25. {
  26. m_Sin = new Fl_Button (10, 15, 60, 20, "Sin");
  27. m_Sin->labelsize (8);
  28. m_Sin->type (FL_TOGGLE_BUTTON);
  29. m_Sin->box (FL_PLASTIC_UP_BOX);
  30. m_Sin->value (1);
  31. m_Sin->color (Info->GUI_COLOUR);
  32. m_Sin->selection_color (Info->GUI_COLOUR);
  33. m_Sin->callback ((Fl_Callback*)cb_Sin);
  34. m_Cos = new Fl_Button (10, 35, 60, 20, "Cos");
  35. m_Cos->labelsize (8);
  36. m_Cos->type (FL_TOGGLE_BUTTON);
  37. m_Cos->box (FL_PLASTIC_UP_BOX);
  38. m_Cos->color (Info->GUI_COLOUR);
  39. m_Cos->selection_color (Info->GUI_COLOUR);
  40. m_Cos->callback ((Fl_Callback*)cb_Cos);
  41. m_Tan = new Fl_Button (10, 55, 60, 20, "Tan");
  42. m_Tan->labelsize (8);
  43. m_Tan->type (FL_TOGGLE_BUTTON);
  44. m_Tan->box (FL_PLASTIC_UP_BOX);
  45. m_Tan->color (Info->GUI_COLOUR);
  46. m_Tan->selection_color (Info->GUI_COLOUR);
  47. m_Tan->callback ((Fl_Callback*)cb_Tan);
  48. end();
  49. }
  50. void TrigPluginGUI::UpdateValues(SpiralPlugin *o)
  51. {
  52. TrigPlugin* Plugin = (TrigPlugin*)o;
  53. m_Sin->value(false);
  54. m_Cos->value(false);
  55. m_Tan->value(false);
  56. switch (Plugin->GetOperator())
  57. {
  58. case TrigPlugin::SIN : m_Sin->value(true); break;
  59. case TrigPlugin::COS : m_Cos->value(true); break;
  60. case TrigPlugin::TAN : m_Tan->value(true); break;
  61. default: break;
  62. }
  63. }
  64. //// Callbacks ////
  65. inline void TrigPluginGUI::cb_Sin_i(Fl_Button* o, void* v)
  66. {
  67. if (o->value())
  68. {
  69. m_Cos->value(false);
  70. m_Tan->value(false);
  71. m_GUICH->Set("Operator",(int)TrigPlugin::SIN);
  72. }
  73. else
  74. {
  75. o->value(true);
  76. }
  77. }
  78. void TrigPluginGUI::cb_Sin(Fl_Button* o, void* v)
  79. { ((TrigPluginGUI*)(o->parent()))->cb_Sin_i(o,v);}
  80. inline void TrigPluginGUI::cb_Cos_i(Fl_Button* o, void* v)
  81. {
  82. if (o->value())
  83. {
  84. m_Sin->value(false);
  85. m_Tan->value(false);
  86. m_GUICH->Set("Operator",(int)TrigPlugin::COS);
  87. }
  88. else
  89. {
  90. o->value(true);
  91. }
  92. }
  93. void TrigPluginGUI::cb_Cos(Fl_Button* o, void* v)
  94. { ((TrigPluginGUI*)(o->parent()))->cb_Cos_i(o,v);}
  95. inline void TrigPluginGUI::cb_Tan_i(Fl_Button* o, void* v)
  96. {
  97. if (o->value())
  98. {
  99. m_Sin->value(false);
  100. m_Cos->value(false);
  101. m_GUICH->Set("Operator",(int)TrigPlugin::TAN);
  102. }
  103. else
  104. {
  105. o->value(true);
  106. }
  107. }
  108. void TrigPluginGUI::cb_Tan(Fl_Button* o, void* v)
  109. { ((TrigPluginGUI*)(o->parent()))->cb_Tan_i(o,v);}
  110. const string TrigPluginGUI::GetHelpText(const string &loc){
  111. return string("")
  112. + "Calculates the sin/cos/tan of the input value, 1.0=360 degrees.";
  113. }