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.

126 lines
3.2KB

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