Main Page | Namespaces | Classes | Compounds | Files | Compound Members | Related AInput.cpp00001 // 00002 // SYNTOPIA. See http://Syntopia.sourceforge.net for details and documentation. 00003 // 00004 // Author of this file: Mikael Hvidtfeldt Christensen (mikaelc@users.sourceforge.net) 00005 // 00006 00007 #include "AInput.h" 00008 00009 00010 namespace SynthGUI { 00011 00012 AInput::AInput(std::string s, float min, float max, int steps, bool integral) { 00013 myLabel = s; 00014 myMax = max; 00015 myMin = min; 00016 mySteps = steps; 00017 myIntegral = integral; 00018 } 00019 00020 AInput::~AInput() { 00021 } 00022 00023 float AInput::getValue() { 00024 return mScrollBar->get(); 00025 } 00026 00027 00028 void AInput::setValue(float f) { 00029 mScrollBar->set(f); 00030 char ch[20]; 00031 sprintf(ch, "%5.4f", mScrollBar->get()); 00032 mTextBox->setText(std::string(ch)); 00033 } 00034 00035 void AInput::PutInWinForm(WinForm * WF, int x0, int y0, int x1, int y1) { 00036 ID = (HMENU)GUIControl::GUIInstance->Register(this); 00037 topWF = WF; 00038 00039 mLabel = new Label(myLabel); 00040 00041 mLabel->PutInWinForm(WF,x0,y0,100,30); 00042 00043 mDropDown = new ComboBox(); 00044 00045 mDropDown->PutInWinForm(WF,x0+40,y0,90,130); 00046 00047 mDropDown->add(mItem1 = new ComboBoxItem("Manual")); 00048 mDropDown->add(mItem2 = new ComboBoxItem("<-Input")); 00049 mDropDown->add(mItem3 = new ComboBoxItem("<-Panel")); 00050 mDropDown->add(mItem4 = new ComboBoxItem("<-MidiCC")); 00051 mDropDown->setSelected(mItem1); 00052 00053 mInputMenu = new ComboBox(); 00054 00055 mInputMenu->PutInWinForm(WF,x0+145,y0,295,130); 00056 00057 mInputMenu->add(mInput1 = new ComboBoxItem("LFO::Output")); 00058 mInputMenu->add(mInput2 = new ComboBoxItem("Sampler(1)::Output")); 00059 mInputMenu->add(mInput3 = new ComboBoxItem("Sampler(2)::Output")); 00060 mInputMenu->add(mInput4 = new ComboBoxItem("Random::Output")); 00061 mInputMenu->setSelected(mInput1); 00062 mInputMenu->hide(); 00063 00064 mLabel2 = new Label(":"); 00065 00066 mLabel2->PutInWinForm(WF,x0+135,y0,10,30); 00067 00068 mScrollBar = new ScrollBar(myMin,myMax,1000); 00069 00070 mScrollBar->PutInWinForm(WF,x0+145,y0,185,20); 00071 00072 mTextBox = new TextBox(TextBox::singleLine); 00073 mTextBox->setFloatLimit(myMin,myMax); 00074 00075 mTextBox->PutInWinForm(WF,x0+335,y0,95,25); 00076 00077 mTextBox->setEventHandler(this); 00078 mScrollBar->setEventHandler(this); 00079 mDropDown->setEventHandler(this); 00080 00081 00082 00083 } 00084 00085 void AInput::HandleEvents(event ev) 00086 { 00087 00088 if ((ev.EventSource==mDropDown) && (HIWORD(ev.wParam)==CBN_SELCHANGE)) 00089 { 00090 if (mDropDown->getSelected() == mItem1) { 00091 mTextBox->show(); 00092 mScrollBar->show(); 00093 mInputMenu->hide(); 00094 //std::cout << "Manual Input" << std::endl; 00095 } 00096 if (mDropDown->getSelected() == mItem2) { 00097 mTextBox->hide(); 00098 mScrollBar->hide(); 00099 mInputMenu->show(); 00100 00101 //std::cout << "Reconnect" << std::endl; 00102 } 00103 } 00104 00105 if (ev.EventSource==mScrollBar) 00106 { 00107 char Answer[20]; 00108 sprintf(Answer, "%5.4f", mScrollBar->get()); 00109 mTextBox->setText(std::string(Answer)); 00110 //std::cout << mScrollBar->get() << std::endl; 00111 00112 // modify later 00113 if (myEventHandler !=0) { 00114 ev.EventSource = this; 00115 myEventHandler->HandleEvents(ev); 00116 } 00117 } 00118 00119 if (ev.EventSource==mTextBox) 00120 { 00121 mScrollBar->set(mTextBox->getFloatVal()); 00122 if (myEventHandler !=0) { 00123 ev.EventSource = this; 00124 myEventHandler->HandleEvents(ev); 00125 } 00126 } 00127 00128 } 00129 00130 00131 // ------------------------------------------------------------------------- 00132 00133 SlideInput::SlideInput(std::string s, float min, float max, int steps, bool integral) { 00134 myLabel = s; 00135 myMax = max; 00136 myMin = min; 00137 mySteps = steps; 00138 myIntegral = integral; 00139 } 00140 00141 SlideInput::~SlideInput() { 00142 } 00143 00144 float SlideInput::getValue() { 00145 return mScrollBar->get(); 00146 } 00147 00148 void SlideInput::PutInWinForm(WinForm * WF, int x0, int y0, int x1, int y1) { 00149 ID = (HMENU)GUIControl::GUIInstance->Register(this); 00150 topWF = WF; 00151 00152 mLabel = new Label(myLabel); 00153 00154 mLabel->PutInWinForm(WF,x0,y0,100,30); 00155 00156 00157 mLabel2 = new Label(":"); 00158 00159 mLabel2->PutInWinForm(WF,x0+135,y0,10,30); 00160 00161 mScrollBar = new ScrollBar(myMin,myMax,1000); 00162 00163 mScrollBar->PutInWinForm(WF,x0+145,y0,185,20); 00164 00165 mTextBox = new TextBox(TextBox::singleLine); 00166 mTextBox->setFloatLimit(myMin,myMax); 00167 00168 mTextBox->PutInWinForm(WF,x0+335,y0,95,25); 00169 00170 mTextBox->setEventHandler(this); 00171 mScrollBar->setEventHandler(this); 00172 00173 00174 } 00175 00176 void SlideInput::HandleEvents(event ev) 00177 { 00178 00179 00180 if (ev.EventSource==mScrollBar) 00181 { 00182 char Answer[20]; 00183 if (!myIntegral) { 00184 sprintf(Answer, "%5.4f", mScrollBar->get()); 00185 } else { 00186 sprintf(Answer, "%5.0f", mScrollBar->get()); 00187 } 00188 00189 mTextBox->setText(std::string(Answer)); 00190 //std::cout << mScrollBar->get() << std::endl; 00191 00192 // modify later 00193 if (myEventHandler !=0) { 00194 ev.EventSource = this; 00195 myEventHandler->HandleEvents(ev); 00196 } 00197 } 00198 00199 if (ev.EventSource==mTextBox) 00200 { 00201 mScrollBar->set(mTextBox->getFloatVal()); 00202 if (myEventHandler !=0) { 00203 ev.EventSource = this; 00204 myEventHandler->HandleEvents(ev); 00205 } 00206 } 00207 00208 } 00209 00210 }; // end of namespace: SynthGUI 00211 Docs made by Doxygen. Email: Mikael Christensen |