00001 //------------------------------------------------------------------------ 00002 // Project : VST SDK 00003 // Version : 3.0 00004 // 00005 // Category : Helpers 00006 // Filename : vstguieditor.h 00007 // Created by : Steinberg, 04/2005 00008 // Modified : $Date: 2008/01/09 12:51:07 $ 00009 // Description : VSTGUI Editor 00010 // 00011 //----------------------------------------------------------------------------- 00012 // LICENSE 00013 // © 2008, Steinberg Media Technologies GmbH, All Rights Reserved 00014 //----------------------------------------------------------------------------- 00015 // This Software Development Kit may not be distributed in parts or its entirety 00016 // without prior written agreement by Steinberg Media Technologies GmbH. 00017 // This SDK must not be used to re-engineer or manipulate any technology used 00018 // in any Steinberg or Third-party application or software module, 00019 // unless permitted by law. 00020 // Neither the name of the Steinberg Media Technologies nor the names of its 00021 // contributors may be used to endorse or promote products derived from this 00022 // software without specific prior written permission. 00023 // 00024 // THIS SDK IS PROVIDED BY STEINBERG MEDIA TECHNOLOGIES GMBH "AS IS" AND 00025 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00026 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00027 // IN NO EVENT SHALL STEINBERG MEDIA TECHNOLOGIES GMBH BE LIABLE FOR ANY DIRECT, 00028 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00031 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00032 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 00033 // OF THE POSSIBILITY OF SUCH DAMAGE. 00034 //----------------------------------------------------------------------------- 00035 00036 #include "vstguieditor.h" 00037 00038 #if MAC 00039 void* VSTGUI::gBundleRef = 0; 00040 extern CFBundleRef ghInst; 00041 #endif 00042 00043 namespace Steinberg { 00044 namespace Vst { 00045 00046 //------------------------------------------------------------------------ 00047 VSTGUIEditor::VSTGUIEditor (void* controller, ViewRect* size) 00048 : EditorView ((EditController*)controller, size) 00049 , plugFrame (0) 00050 { 00051 // create a timer used for idle update: will call notify method 00052 timer = new CVSTGUITimer ((CBaseObject*)this); 00053 } 00054 00055 //------------------------------------------------------------------------ 00056 VSTGUIEditor::~VSTGUIEditor () 00057 { 00058 if (timer) 00059 timer->forget (); 00060 } 00061 00062 //------------------------------------------------------------------------ 00063 void VSTGUIEditor::setIdleRate (int millisec) 00064 { 00065 if (timer) 00066 timer->setFireTime (millisec); 00067 } 00068 00069 //------------------------------------------------------------------------ 00070 tresult PLUGIN_API VSTGUIEditor::isPlatformTypeSupported (FIDString type) 00071 { 00072 #if WINDOWS 00073 if (!strcmp (type, kPlatformTypeHWND)) 00074 return kResultTrue; 00075 00076 #elif MAC 00077 if (!strcmp (type, kPlatformTypeHIView)) 00078 return kResultTrue; 00079 00080 // TODO ? kPlatformTypeNSView 00081 #endif 00082 00083 return kNotImplemented; 00084 } 00085 00086 //------------------------------------------------------------------------ 00087 tresult PLUGIN_API VSTGUIEditor::attached (void* parent, FIDString type) 00088 { 00089 if (timer) 00090 timer->start (); 00091 00092 #if MAC 00093 VSTGUI::gBundleRef = ghInst; 00094 #endif 00095 if (open (parent) == true && plugFrame) 00096 { 00097 ViewRect vr (0, 0, frame->getWidth (), frame->getHeight ()); 00098 setRect (vr); 00099 plugFrame->resizeView (this, &vr); 00100 return kResultTrue; 00101 } 00102 return EditorView::attached (parent, type); 00103 } 00104 00105 //------------------------------------------------------------------------ 00106 tresult PLUGIN_API VSTGUIEditor::removed () 00107 { 00108 if (timer) 00109 timer->stop (); 00110 00111 close (); 00112 return EditorView::removed (); 00113 } 00114 00115 //------------------------------------------------------------------------ 00116 tresult PLUGIN_API VSTGUIEditor::setFrame (IPlugFrame* frame) 00117 { 00118 plugFrame = frame; 00119 return kResultTrue; 00120 } 00121 00122 //------------------------------------------------------------------------ 00123 CMessageResult VSTGUIEditor::notify (CBaseObject* sender, const char* message) 00124 { 00125 if (message == CVSTGUITimer::kMsgTimer) 00126 { 00127 if (frame) 00128 frame->idle (); 00129 00130 return kMessageNotified; 00131 } 00132 00133 return kMessageUnknown; 00134 } 00135 00136 } // namespace Vst 00137 } // namespace Steinberg