Main Page | Namespaces | Classes | Compounds | Files | Compound Members | Related vstgui.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 00008 00009 #include "vstgui.h" 00010 #include <windows.h> 00011 #include <commctrl.h> 00012 #include "AudioEffectx.h" 00013 //#include "..\ADelay\ADelay.hpp" 00014 #include "WinForm.h" 00015 #include "softSynth.h" 00016 00017 extern void* hInstance; 00018 int useCount = 0; 00019 HWND CreateFader (HWND parent, char* title, int x, int y, int w, int h, int min, int max); 00020 LONG WINAPI WindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 00021 //----------------------------------------------------------------------------- 00022 00023 00024 00025 ADEditor::ADEditor (AudioEffect *effect) 00026 : AEffEditor (effect) 00027 { 00028 effect->setEditor (this); 00029 } 00030 //----------------------------------------------------------------------------- 00031 ADEditor::~ADEditor () 00032 { 00033 } 00034 //----------------------------------------------------------------------------- 00035 long ADEditor::getRect (ERect **erect) 00036 { 00037 static ERect r = {0, 0, 100, 200}; 00038 *erect = &r; 00039 return true; 00040 } 00041 //----------------------------------------------------------------------------- 00042 long ADEditor::open (void *ptr) 00043 { 00044 // Remember the parent window 00045 systemWindow = ptr; 00046 // Create window class, if we are called the first time 00047 useCount++; 00048 if (useCount == 1) 00049 { 00050 WNDCLASS windowClass; 00051 windowClass.style = 0; 00052 windowClass.lpfnWndProc = WindowProc; 00053 windowClass.cbClsExtra = 0; 00054 windowClass.cbWndExtra = 0; 00055 windowClass.hInstance = (HINSTANCE) hInstance; 00056 windowClass.hIcon = 0; 00057 windowClass.hCursor = 0; 00058 windowClass.hbrBackground = GetSysColorBrush (COLOR_BTNFACE); 00059 windowClass.lpszMenuName = 0; 00060 windowClass.lpszClassName = "DelayWindowClass"; 00061 RegisterClass (&windowClass); 00062 00063 00064 00065 GUIControl * myGUIControl = new GUIControl((HINSTANCE)hInstance, SW_SHOWDEFAULT ); 00066 mitVindue = new mainDialog( ((softSynth *)effect) ->mySynth); 00067 00068 //myGUIControl->MessageLoop(); 00069 //delete(mitVindue); 00070 } 00071 // Create our base window 00072 HWND hwnd = CreateWindowEx (0, "DelayWindowClass", "Window", 00073 WS_CHILD | WS_VISIBLE, 00074 0, 0, 600, 400, 00075 (HWND)systemWindow, NULL,(HINSTANCE) hInstance, NULL); 00076 SetWindowLong (hwnd, GWL_USERDATA, (long)this); 00077 // Create three fader controls 00078 int x= 10; int y=10; int w= 40; int h= 45; 00079 delayFader = CreateFader (hwnd, "Delay", x, y, w, h, 0, 100); 00080 feedbackFader = CreateFader (hwnd, "Feedback", x+50, y, w, h, 0, 100); 00081 volumeFader = CreateFader (hwnd, "Volume", x+100, y, w, h, 0, 100); 00082 return true; 00083 } 00084 void ADEditor::close () 00085 { 00086 useCount--; 00087 if (useCount == 0) 00088 { 00089 UnregisterClass ("DelayWindowClass",(HINSTANCE) hInstance); 00090 delete(mitVindue); 00091 } 00092 } 00093 void ADEditor::idle () 00094 { 00095 AEffEditor::idle (); 00096 } 00097 void ADEditor::update() 00098 { 00099 // SendMessage (delayFader, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) effect->getParameter (kDelay)); 00100 // SendMessage (feedbackFader, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) effect->getParameter(kFeedBack)); 00101 // SendMessage (volumeFader, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) effect->getParameter (kOut)); 00102 } 00103 /* 00104 void ADEditor::setValue(void* fader, int value) 00105 { 00106 if (fader == delayFader) 00107 effect->setParameterAutomated (kDelay, (float)value / 100.f); 00108 else if (fader == feedbackFader) 00109 effect->setParameterAutomated (kFeedBack, (float)value / 100.f); 00110 else if (fader == volumeFader) 00111 effect->setParameterAutomated (kOut, (float)value / 100.f); 00112 }*/ 00113 HWND CreateFader (HWND parent, char* title, int x, int y, int w, int h, int min, int max) 00114 { 00115 HWND hwndTrack = CreateWindowEx (0, TRACKBAR_CLASS, title, 00116 WS_CHILD | WS_VISIBLE | 00117 TBS_NOTICKS | TBS_ENABLESELRANGE | TBS_VERT, 00118 x, y, w, h, parent, NULL, (HINSTANCE)hInstance, NULL); 00119 SendMessage (hwndTrack, TBM_SETRANGE, (WPARAM ) TRUE, (LPARAM) MAKELONG (min, max)); 00120 SendMessage (hwndTrack, TBM_SETPAGESIZE, 0, (LPARAM) 4); 00121 SendMessage (hwndTrack, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) min); 00122 return hwndTrack; 00123 } 00124 LONG WINAPI WindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 00125 { 00126 switch (message) 00127 { 00128 case WM_VSCROLL: 00129 { 00130 int newValue = SendMessage ((HWND)lParam, TBM_GETPOS, 0, 0); 00131 ADEditor* editor = (ADEditor*)GetWindowLong (hwnd, GWL_USERDATA); 00132 //if (editor) 00133 // editor->setValue ((void*)lParam, newValue); 00134 } 00135 break; 00136 } 00137 return DefWindowProc (hwnd, message, wParam, lParam); 00138 } Docs made by Doxygen. Email: Mikael Christensen |