/* SpiralPlugin * Copyleft (C) 2000 David Griffiths * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "OperatorPluginGUI.h" #include #include #include //////////////////////////////////////////// OperatorPluginGUI::OperatorPluginGUI(int w, int h,OperatorPlugin *o,ChannelHandler *ch,const HostInfo *Info) : SpiralPluginGUI(w,h,o,ch) { int KeyWidth=10,Note,Pos=0,Count=0; m_Add = new Fl_Button(5, 15, 15, 15,"+"); m_Add->type(1); m_Add->value(1); m_Add->selection_color(Info->GUI_COLOUR); m_Add->callback((Fl_Callback*)cb_Add); m_Sub = new Fl_Button(5, 30, 15, 15,"-"); m_Sub->type(1); m_Sub->selection_color(Info->GUI_COLOUR); m_Sub->callback((Fl_Callback*)cb_Sub); m_Mul = new Fl_Button(5, 45, 15, 15,"*"); m_Mul->type(1); m_Mul->selection_color(Info->GUI_COLOUR); m_Mul->callback((Fl_Callback*)cb_Mul); m_Div = new Fl_Button(5, 60, 15, 15,"/"); m_Div->type(1); m_Div->selection_color(Info->GUI_COLOUR); m_Div->callback((Fl_Callback*)cb_Div); m_Constant = new Fl_Input(25, 15, 50, 20, "Constant"); m_Constant->color(Info->GUI_COLOUR); m_Constant->labelsize(8); m_Constant->align(FL_ALIGN_BOTTOM|FL_ALIGN_CENTER); m_Constant->textsize(10); m_Constant->value("0"); m_Constant->when(FL_WHEN_ENTER_KEY); m_Constant->callback((Fl_Callback*)cb_Constant); end(); } void OperatorPluginGUI::UpdateValues(SpiralPlugin *o) { OperatorPlugin* Plugin = (OperatorPlugin*)o; m_Add->value(false); m_Sub->value(false); m_Mul->value(false); m_Div->value(false); switch (Plugin->GetOperator()) { case OperatorPlugin::ADD : m_Add->value(true); break; case OperatorPlugin::SUB : m_Sub->value(true); break; case OperatorPlugin::MUL : m_Mul->value(true); break; case OperatorPlugin::DIV : m_Div->value(true); break; } char t[256]; sprintf(t,"%f",Plugin->GetConstant()); m_Constant->value(t); } //// Callbacks //// inline void OperatorPluginGUI::cb_Add_i(Fl_Button* o, void* v) { if (o->value()) { m_Sub->value(false); m_Mul->value(false); m_Div->value(false); m_GUICH->Set("Operator",(int)OperatorPlugin::ADD); } else { o->value(true); } } void OperatorPluginGUI::cb_Add(Fl_Button* o, void* v) { ((OperatorPluginGUI*)(o->parent()))->cb_Add_i(o,v);} inline void OperatorPluginGUI::cb_Sub_i(Fl_Button* o, void* v) { if (o->value()) { m_Add->value(false); m_Mul->value(false); m_Div->value(false); m_GUICH->Set("Operator",(int)OperatorPlugin::SUB); } else { o->value(true); } } void OperatorPluginGUI::cb_Sub(Fl_Button* o, void* v) { ((OperatorPluginGUI*)(o->parent()))->cb_Sub_i(o,v);} inline void OperatorPluginGUI::cb_Mul_i(Fl_Button* o, void* v) { if (o->value()) { m_Add->value(false); m_Sub->value(false); m_Div->value(false); m_GUICH->Set("Operator",(int)OperatorPlugin::MUL); } else { o->value(true); } } void OperatorPluginGUI::cb_Mul(Fl_Button* o, void* v) { ((OperatorPluginGUI*)(o->parent()))->cb_Mul_i(o,v);} inline void OperatorPluginGUI::cb_Div_i(Fl_Button* o, void* v) { if (o->value()) { m_Add->value(false); m_Sub->value(false); m_Mul->value(false); m_GUICH->Set("Operator",(int)OperatorPlugin::DIV); } else { o->value(true); } } void OperatorPluginGUI::cb_Div(Fl_Button* o, void* v) { ((OperatorPluginGUI*)(o->parent()))->cb_Div_i(o,v);} inline void OperatorPluginGUI::cb_Constant_i(Fl_Input* o, void* v) { m_GUICH->Set("Constant",(float)strtod(o->value(),NULL)); } void OperatorPluginGUI::cb_Constant(Fl_Input* o, void* v) { ((OperatorPluginGUI*)(o->parent()))->cb_Constant_i(o,v);} const string OperatorPluginGUI::GetHelpText(const string &loc){ return string("") + "Simply performs the operation on the input data,\n" + "if there is only one input, it uses the constant."; }