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.

139 lines
4.7KB

  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 "OperatorPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_draw.H>
  21. //#include <stdio.h>
  22. ////////////////////////////////////////////
  23. OperatorPluginGUI::OperatorPluginGUI(int w, int h,OperatorPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
  24. SpiralPluginGUI(w,h,o,ch)
  25. {
  26. m_Constant = new Fl_Counter (5, 15, 110, 20, "Constant");
  27. m_Constant->color (Info->GUI_COLOUR);
  28. m_Constant->box (FL_PLASTIC_UP_BOX);
  29. m_Constant->labelsize (10);
  30. m_Constant->align (FL_ALIGN_BOTTOM | FL_ALIGN_CENTER);
  31. m_Constant->textsize (10);
  32. m_Constant->value (0);
  33. m_Constant->step (0.01);
  34. m_Constant->lstep (1);
  35. //m_Constant->when (FL_WHEN_ENTER_KEY);
  36. m_Constant->callback ((Fl_Callback*)cb_Constant);
  37. m_Add = new Fl_Button (5, 50, 20, 20, "+");
  38. m_Add->type (FL_RADIO_BUTTON);
  39. m_Add->box (FL_PLASTIC_UP_BOX);
  40. m_Add->color (Info->GUI_COLOUR);
  41. m_Add->selection_color (Info->GUI_COLOUR);
  42. m_Add->value (true);
  43. m_Add->callback ((Fl_Callback*)cb_Add);
  44. m_Sub = new Fl_Button (35, 50, 20, 20, "-");
  45. m_Sub->type (FL_RADIO_BUTTON);
  46. m_Sub->box (FL_PLASTIC_UP_BOX);
  47. m_Sub->color (Info->GUI_COLOUR);
  48. m_Sub->selection_color (Info->GUI_COLOUR);
  49. m_Sub->callback ((Fl_Callback*)cb_Sub);
  50. m_Mul = new Fl_Button (65, 50, 20, 20, "x");
  51. m_Mul->type (FL_RADIO_BUTTON);
  52. m_Mul->box (FL_PLASTIC_UP_BOX);
  53. m_Mul->color (Info->GUI_COLOUR);
  54. m_Mul->selection_color (Info->GUI_COLOUR);
  55. m_Mul->callback ((Fl_Callback*)cb_Mul);
  56. m_Div = new Fl_Button (95, 50, 20, 20, "รท");
  57. m_Div->type (FL_RADIO_BUTTON);
  58. m_Div->box (FL_PLASTIC_UP_BOX);
  59. m_Div->color (Info->GUI_COLOUR);
  60. m_Div->selection_color (Info->GUI_COLOUR);
  61. m_Div->callback ((Fl_Callback*)cb_Div);
  62. end();
  63. }
  64. void OperatorPluginGUI::UpdateValues(SpiralPlugin *o)
  65. {
  66. OperatorPlugin* Plugin = (OperatorPlugin*)o;
  67. m_Add->value(false);
  68. m_Sub->value(false);
  69. m_Mul->value(false);
  70. m_Div->value(false);
  71. switch (Plugin->GetOperator())
  72. {
  73. case OperatorPlugin::ADD : m_Add->value(true); break;
  74. case OperatorPlugin::SUB : m_Sub->value(true); break;
  75. case OperatorPlugin::MUL : m_Mul->value(true); break;
  76. case OperatorPlugin::DIV : m_Div->value(true); break;
  77. default: break;
  78. }
  79. //char t[256];
  80. //sprintf(t,"%f",Plugin->GetConstant());
  81. m_Constant->value (Plugin->GetConstant());
  82. }
  83. //// Callbacks ////
  84. inline void OperatorPluginGUI::cb_Add_i (Fl_Button* o, void* v) {
  85. if (o->value()) m_GUICH->Set ("Operator", (int)OperatorPlugin::ADD);
  86. }
  87. void OperatorPluginGUI::cb_Add (Fl_Button* o, void* v) {
  88. ((OperatorPluginGUI*)(o->parent()))->cb_Add_i (o, v);
  89. }
  90. inline void OperatorPluginGUI::cb_Sub_i (Fl_Button* o, void* v) {
  91. if (o->value()) m_GUICH->Set ("Operator",(int)OperatorPlugin::SUB);
  92. }
  93. void OperatorPluginGUI::cb_Sub (Fl_Button* o, void* v) {
  94. ((OperatorPluginGUI*)(o->parent()))->cb_Sub_i (o, v);
  95. }
  96. inline void OperatorPluginGUI::cb_Mul_i (Fl_Button* o, void* v) {
  97. if (o->value()) m_GUICH->Set ("Operator",(int)OperatorPlugin::MUL);
  98. }
  99. void OperatorPluginGUI::cb_Mul (Fl_Button* o, void* v) {
  100. ((OperatorPluginGUI*)(o->parent()))->cb_Mul_i (o, v);
  101. }
  102. inline void OperatorPluginGUI::cb_Div_i (Fl_Button* o, void* v) {
  103. if (o->value()) m_GUICH->Set("Operator",(int)OperatorPlugin::DIV);
  104. }
  105. void OperatorPluginGUI::cb_Div (Fl_Button* o, void* v) {
  106. ((OperatorPluginGUI*)(o->parent()))->cb_Div_i (o, v);
  107. }
  108. inline void OperatorPluginGUI::cb_Constant_i (Fl_Counter* o, void* v) {
  109. m_GUICH->Set ("Constant", (float) /*strtod(*/ o->value() /*,NULL)*/);
  110. }
  111. void OperatorPluginGUI::cb_Constant (Fl_Counter* o, void* v) {
  112. ((OperatorPluginGUI*)(o->parent()))->cb_Constant_i (o, v);
  113. }
  114. const string OperatorPluginGUI::GetHelpText(const string &loc){
  115. return string("")
  116. + "Simply performs the operation on the input data,\n"
  117. + "if there is only one input, it uses the constant.";
  118. }