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.

122 lines
3.1KB

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