Main Page | Namespaces | Classes | Compounds | Files | Compound Members | Related MainDialog.h00001 // 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 #ifndef __mainDialog 00008 #define __mainDialog 00009 00010 #include "Synth.h" 00011 #include <iostream> 00012 #include "math.h" 00013 00014 #include "WinForm.h" 00015 #include "menu.h" 00016 #include "AInput.h" 00017 #include <string> 00018 #include <vector> 00019 00020 00021 #include "envDialog.h" 00022 #include "OscDialog.h" 00023 00024 using namespace SynthCore; 00025 using namespace GUIToolkit; 00026 00027 namespace SynthGUI { 00028 00029 00030 00032 class modInOuts { 00033 public: 00034 bool Input; // define whether input or output 00035 std::string label; // label the IN/OUT-put. 00036 Module * connectTo; 00037 00038 modInOuts() {label = "Noname"; connectTo = 0;}; 00039 ~modInOuts() {}; 00040 }; 00041 00042 00046 typedef std::vector<Module *> ModVector; 00047 00049 class mod { 00050 public: 00054 ModVector mv; 00055 00057 int x; 00058 00060 int y; 00061 00063 int x2; 00064 00066 int y2; 00067 00069 std::vector<modInOuts *> InOuts; 00070 00072 mod(Module * mm) {x=0; y=0; mv.push_back(mm);}; 00073 00075 ~mod() {}; 00076 00079 void addModule(Module * mm) { 00080 mv.push_back(mm); 00081 } 00082 00084 void displayDialog() ; 00085 }; 00086 00087 00089 class modList { 00090 private: 00091 int displayWidth; 00092 int Width ; 00093 int Height; 00094 public: 00096 int chosen; 00097 00099 std::vector<mod *> mods; 00100 00102 void addMod(mod * m) {mods.push_back(m);} 00103 00107 void addModule(Module * m) { 00108 mod * md = new mod(m); 00109 if (mods.size() == 0) { 00110 // this is the first mod. 00111 md->x = 10; md->y = 10; 00112 md->x2 = md -> x + Width; md->y2 = md->y +Height; 00113 } else { 00114 int x2 = mods[mods.size()-1]->x2; 00115 int y = mods[mods.size()-1]->y; 00116 int y2 = mods[mods.size()-1]->y2; 00117 00118 00119 if (x2 + 10 + Width > displayWidth) { 00120 // Move to next line 00121 md->x = 10; md->y = y2+10; 00122 md->x2 = md -> x + Width; md->y2 = md->y +Height; 00123 } else 00124 { 00125 // Place next to previous 00126 md->x = x2+10; md->y = y; 00127 md->x2 = md -> x + Width; md->y2 = md->y +Height; 00128 } 00129 } 00130 00131 addMod(md); 00132 } 00133 00135 modList() {chosen = -1; displayWidth = 420; Width = 100; Height = 80;}; 00136 00138 ~modList() {}; 00139 00141 void print() { 00142 // For debugging 00143 for (int i=0; i<mods.size(); i++) { 00144 std::cout << "NAME: " << mods[i]->mv[0]->getName() << std::endl; 00145 } 00146 } 00147 00149 void setChosen(int i) { 00150 // 'chosen' is the graphically selected mod. 00151 chosen = i; 00152 } 00153 00156 int getMod(Module * m) { 00157 00158 for (int i=0; i<mods.size(); i++) { 00159 if (m == mods[i]->mv[0]) {return i;} 00160 } 00161 00162 // not found 00163 return -1; 00164 } 00165 00167 int getFirstModule(int ID) { 00168 00169 for (int i=0; i<mods.size(); i++) { 00170 if (mods[i]->mv[0]->ModID == ID) {return i;} 00171 } 00172 return -1; 00173 } 00174 }; 00175 00177 class mainDialog : public EventHandler { 00178 public: 00180 mainDialog(Synth * syn); 00181 00183 void drawmain(); 00184 00186 ~mainDialog(); 00187 00189 void MessageLoop(); 00190 00192 void HandleEvents(event ev); 00193 00195 void drawMod(int x, int y, int x2, int y2, std::string s, mod * md, bool drawLines ); 00196 00198 int mouseOverMod(int x,int y) ; 00199 //void mainToScreen(float xx, float yy, int &x,int &y); 00200 //void ScreenTomain(int x,int y,float &xx, float &yy ); 00201 private: 00202 COLORREF C1; 00203 int ii; 00204 int deltaX, deltaY; 00205 modList * myModList; 00206 WinForm * myWindow; 00207 TextBox * myText2 ; 00208 int lastChoosen; 00209 //HMENU hSubMenu; 00210 //HMENU hSubMenu2; 00211 // Canvases 00212 POINT pt; 00213 MCanvas * modCanvas; 00214 00215 00216 00217 // Context popup menu 00218 00219 popupMenu * myPopup; 00220 popupMenu * myPopup2; 00221 menuItem * mItem11; 00222 menuItem * mItem12; 00223 menuItem * mItem13; 00224 menuItem * mItem21; 00225 00226 // Extra Inputs 00227 00228 // AInput * freqInput; 00229 00230 00231 // IN/OUT 00232 00233 //IOSelector * outputSel; 00234 00235 // rest 00236 00237 }; 00238 00239 }; // end of namespace: SynthGUI 00240 00241 #endif Docs made by Doxygen. Email: Mikael Christensen |