Browse Source

Changed the var class to be able to hold any ReferenceCountedObject rather than just a DynamicObject. Altered the drag-and-drop classes to use a var instead of a String as the drag description. This affects the getDragSourceDescription() methods in the TreeViewItem, ListBoxModel and TableListBoxModel classes, which now return a var instead of a String.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
e9bdd1d637
23 changed files with 458 additions and 481 deletions
  1. +1
    -1
      extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp
  2. +1
    -1
      extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h
  3. +2
    -2
      extras/JuceDemo/Source/demos/DragAndDropDemo.cpp
  4. +1
    -1
      extras/JuceDemo/Source/demos/TreeViewDemo.cpp
  5. +66
    -65
      extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp
  6. +106
    -107
      extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp
  7. +100
    -101
      juce_amalgamated.cpp
  8. +40
    -51
      juce_amalgamated.h
  9. +71
    -67
      src/containers/juce_Variant.cpp
  10. +17
    -13
      src/containers/juce_Variant.h
  11. +1
    -1
      src/core/juce_StandardHeader.h
  12. +5
    -5
      src/gui/components/controls/juce_ListBox.cpp
  13. +3
    -3
      src/gui/components/controls/juce_ListBox.h
  14. +3
    -3
      src/gui/components/controls/juce_TableListBox.cpp
  15. +3
    -3
      src/gui/components/controls/juce_TableListBox.h
  16. +4
    -4
      src/gui/components/controls/juce_TreeView.cpp
  17. +2
    -2
      src/gui/components/controls/juce_TreeView.h
  18. +1
    -1
      src/gui/components/filebrowser/juce_FileTreeComponent.cpp
  19. +2
    -3
      src/gui/components/menus/juce_MenuBarModel.h
  20. +9
    -8
      src/gui/components/menus/juce_PopupMenu.cpp
  21. +8
    -13
      src/gui/components/mouse/juce_DragAndDropContainer.cpp
  22. +9
    -16
      src/gui/components/mouse/juce_DragAndDropContainer.h
  23. +3
    -10
      src/gui/components/mouse/juce_DragAndDropTarget.h

+ 1
- 1
extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp View File

@@ -492,7 +492,7 @@ const String ProjectTreeViewBase::getTooltip()
return String::empty;
}
const String ProjectTreeViewBase::getDragSourceDescription()
const var ProjectTreeViewBase::getDragSourceDescription()
{
delayedSelectionTimer = nullptr;
return projectItemDragType;


+ 1
- 1
extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h View File

@@ -86,7 +86,7 @@ public:
void itemDoubleClicked (const MouseEvent& e);
void itemSelectionChanged (bool isNowSelected);
const String getTooltip();
const String getDragSourceDescription();
const var getDragSourceDescription();
//==============================================================================
// Drag-and-drop stuff..


+ 2
- 2
extras/JuceDemo/Source/demos/DragAndDropDemo.cpp View File

@@ -70,7 +70,7 @@ public:
Justification::centredLeft, true);
}
const String getDragSourceDescription (const SparseSet<int>& selectedRows)
const var getDragSourceDescription (const SparseSet<int>& selectedRows)
{
// for our drag desctription, we'll just make a list of the selected
// row numbers - this will be picked up by the drag target and displayed in
@@ -159,7 +159,7 @@ public:
void itemDropped (const SourceDetails& dragSourceDetails)
{
message = "last rows dropped: " + dragSourceDetails.description;
message = "last rows dropped: " + dragSourceDetails.description.toString();
somethingIsBeingDraggedOver = false;
repaint();


+ 1
- 1
extras/JuceDemo/Source/demos/TreeViewDemo.cpp View File

@@ -98,7 +98,7 @@ public:
}
}
const String getDragSourceDescription()
const var getDragSourceDescription()
{
return "TreeView Items";
}


+ 66
- 65
extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp View File

@@ -93,15 +93,17 @@ public:
{
const Identifier memberId (getStringFromDISPID (dispIdMember));
if (memberId.toString().isEmpty() || v.getObject() == 0)
DynamicObject* const object = v.getDynamicObject();
if (memberId.toString().isEmpty() || object == nullptr)
return DISP_E_MEMBERNOTFOUND;
if ((wFlags & DISPATCH_METHOD) != 0)
{
if (! v.getObject()->hasMethod (memberId))
if (! object->hasMethod (memberId))
return DISP_E_MEMBERNOTFOUND;
const int numArgs = pDispParams == 0 ? 0 : pDispParams->cArgs;
const int numArgs = pDispParams == nullptr ? 0 : pDispParams->cArgs;
var result;
if (numArgs == 0)
@@ -117,27 +119,27 @@ public:
result = v.invoke (memberId, numArgs == 0 ? 0 : args.getRawDataPointer(), numArgs);
}
if (pVarResult != 0)
if (pVarResult != nullptr)
juceVarToVariant (result, *pVarResult);
return S_OK;
}
else if ((wFlags & DISPATCH_PROPERTYGET) != 0)
{
if (! v.getObject()->hasProperty (memberId))
if (! object->hasProperty (memberId))
return DISP_E_MEMBERNOTFOUND;
if (pVarResult != 0)
if (pVarResult != nullptr)
{
juceVarToVariant (v.getObject()->getProperty (memberId), *pVarResult);
juceVarToVariant (object->getProperty (memberId), *pVarResult);
return S_OK;
}
}
else if ((wFlags & DISPATCH_PROPERTYPUT) != 0)
{
if (pDispParams != 0 && pDispParams->cArgs > 0)
if (pDispParams != nullptr && pDispParams->cArgs > 0)
{
v.getObject()->setProperty (memberId, variantTojuceVar (pDispParams->rgvarg[0]));
object->setProperty (memberId, variantTojuceVar (pDispParams->rgvarg[0]));
return S_OK;
}
}
@@ -376,7 +378,7 @@ void juceVarToVariant (const var& v, VARIANT& dest)
dest.vt = VT_BSTR;
dest.bstrVal = SysAllocString (v.toString().toUTF16());
}
else if (v.isObject())
else if (v.getDynamicObject() != nullptr)
{
dest.vt = VT_DISPATCH;
dest.pdispVal = new IDispatchWrappingDynamicObject (v);
@@ -397,25 +399,25 @@ const var variantTojuceVar (const VARIANT& v)
{
switch (v.vt & ~VT_BYREF)
{
case VT_VOID:
case VT_EMPTY: return var::null;
case VT_I1: return var ((int) v.cVal);
case VT_I2: return var ((int) v.iVal);
case VT_I4: return var ((int) v.lVal);
case VT_I8: return var (String (v.llVal));
case VT_UI1: return var ((int) v.bVal);
case VT_UI2: return var ((int) v.uiVal);
case VT_UI4: return var ((int) v.ulVal);
case VT_UI8: return var (String (v.ullVal));
case VT_INT: return var ((int) v.intVal);
case VT_UINT: return var ((int) v.uintVal);
case VT_R4: return var ((double) v.fltVal);
case VT_R8: return var ((double) v.dblVal);
case VT_BSTR: return var (String (v.bstrVal));
case VT_BOOL: return var (v.boolVal ? true : false);
case VT_DISPATCH: return var (new DynamicObjectWrappingIDispatch (v.pdispVal));
default:
break;
case VT_VOID:
case VT_EMPTY: return var::null;
case VT_I1: return var ((int) v.cVal);
case VT_I2: return var ((int) v.iVal);
case VT_I4: return var ((int) v.lVal);
case VT_I8: return var (String (v.llVal));
case VT_UI1: return var ((int) v.bVal);
case VT_UI2: return var ((int) v.uiVal);
case VT_UI4: return var ((int) v.ulVal);
case VT_UI8: return var (String (v.ullVal));
case VT_INT: return var ((int) v.intVal);
case VT_UINT: return var ((int) v.uintVal);
case VT_R4: return var ((double) v.fltVal);
case VT_R8: return var ((double) v.dblVal);
case VT_BSTR: return var (String (v.bstrVal));
case VT_BOOL: return var (v.boolVal ? true : false);
case VT_DISPATCH: return var (new DynamicObjectWrappingIDispatch (v.pdispVal));
default:
break;
}
}
@@ -430,31 +432,31 @@ public:
//==============================================================================
AXBrowserPluginHolderComponent()
: parentHWND (0),
browser (0)
browser (nullptr)
{
setOpaque (true);
setWantsKeyboardFocus (false);
addAndMakeVisible (child = createBrowserPlugin());
jassert (child != 0); // You have to create one of these!
jassert (child != nullptr); // You have to create one of these!
}
~AXBrowserPluginHolderComponent()
{
setWindow (0);
child = 0;
setWindow (nullptr);
child = nullptr;
}
//==============================================================================
void paint (Graphics& g)
{
if (child == 0 || ! child->isOpaque())
if (child == nullptr || ! child->isOpaque())
g.fillAll (Colours::white);
}
void resized()
{
if (child != 0)
if (child != nullptr)
child->setBounds (0, 0, getWidth(), getHeight());
}
@@ -462,22 +464,22 @@ public:
void setWindow (IOleInPlaceSite* site)
{
if (browser != 0)
if (browser != nullptr)
{
browser->Release();
browser = 0;
browser = nullptr;
}
HWND newHWND = 0;
if (site != 0)
if (site != nullptr)
{
site->GetWindow (&newHWND);
IServiceProvider* sp = 0;
IServiceProvider* sp = nullptr;
site->QueryInterface (IID_IServiceProvider, (void**) &sp);
if (sp != 0)
if (sp != nullptr)
{
sp->QueryService (IID_IWebBrowserApp, IID_IWebBrowser2, (void**) &browser);
sp->Release();
@@ -505,16 +507,16 @@ public:
}
}
if (site != 0)
if (site != nullptr)
site->OnInPlaceActivate();
}
const String getBrowserURL() const
{
if (browser == 0)
if (browser == nullptr)
return String::empty;
BSTR url = 0;
BSTR url = nullptr;
browser->get_LocationURL (&url);
return URL::removeEscapeChars (url);
}
@@ -531,8 +533,7 @@ extern String browserVersionDesc;
static const String getExePath()
{
TCHAR moduleFile [2048];
moduleFile[0] = 0;
TCHAR moduleFile [2048] = { 0 };
GetModuleFileName (0, moduleFile, 2048);
return moduleFile;
}
@@ -550,7 +551,7 @@ static const String getExeVersion (const String& exeFileName, const String& fiel
if (GetFileVersionInfo (exeFileName.toUTF16(), 0, size, exeInfo))
{
TCHAR* result = 0;
TCHAR* result = nullptr;
unsigned int resultLen = 0;
// try the 1200 codepage (Unicode)
@@ -580,7 +581,7 @@ class JuceActiveXObject : public IUnknown,
{
public:
JuceActiveXObject()
: site (0), refCount (0)
: site (nullptr), refCount (0)
{
log ("JuceActiveXObject");
}
@@ -588,7 +589,7 @@ public:
~JuceActiveXObject()
{
log ("~JuceActiveXObject");
holderComp = 0;
holderComp = nullptr;
}
HRESULT __stdcall QueryInterface (REFIID id, void __RPC_FAR* __RPC_FAR* result)
@@ -620,7 +621,7 @@ public:
DISPPARAMS* pDispParams, VARIANT* pVarResult,
EXCEPINFO* pExcepInfo, UINT* puArgErr)
{
if (holderComp == 0)
if (holderComp == nullptr)
return DISP_E_MEMBERNOTFOUND;
return iDispatchHelper.doInvoke (holderComp->getObject(),
@@ -632,19 +633,19 @@ public:
{
if (newSite != site)
{
if (site != 0)
if (site != nullptr)
site->Release();
site = newSite;
if (site != 0)
if (site != nullptr)
{
site->AddRef();
IOleInPlaceSite* inPlaceSite = 0;
IOleInPlaceSite* inPlaceSite = nullptr;
site->QueryInterface (IID_IOleInPlaceSite, (void**) &inPlaceSite);
if (inPlaceSite != 0)
if (inPlaceSite != nullptr)
{
createHolderComp();
@@ -667,7 +668,7 @@ public:
void createHolderComp()
{
if (holderComp == 0)
if (holderComp == nullptr)
{
if (numActivePlugins++ == 0)
{
@@ -683,9 +684,9 @@ public:
void deleteHolderComp()
{
if (holderComp != 0)
if (holderComp != nullptr)
{
holderComp = 0;
holderComp = nullptr;
if (--numActivePlugins == 0)
{
@@ -704,7 +705,7 @@ public:
//==============================================================================
HRESULT __stdcall SetObjectRects (LPCRECT r, LPCRECT c)
{
if (holderComp != 0)
if (holderComp != nullptr)
holderComp->setBounds (r->left, r->top, r->right - r->left, r->bottom - r->top);
return S_OK;
@@ -712,7 +713,7 @@ public:
HRESULT __stdcall GetWindow (HWND* phwnd)
{
if (holderComp == 0)
if (holderComp == nullptr)
return E_NOTIMPL;
*phwnd = (HWND) holderComp->getWindowHandle();
@@ -766,9 +767,9 @@ public:
HRESULT __stdcall CreateInstance (IUnknown* pUnkOuter, REFIID riid, void** ppvObject)
{
*ppvObject = 0;
*ppvObject = nullptr;
if (pUnkOuter != 0 && riid != IID_IUnknown)
if (pUnkOuter != nullptr && riid != IID_IUnknown)
return CLASS_E_NOAGGREGATION;
JuceActiveXObject* ax = new JuceActiveXObject();
@@ -788,7 +789,7 @@ private:
const String getActiveXBrowserURL (const BrowserPluginComponent* comp)
{
AXBrowserPluginHolderComponent* const ax = dynamic_cast <AXBrowserPluginHolderComponent*> (comp->getParentComponent());
return ax != 0 ? ax->getBrowserURL() : String::empty;
return ax != nullptr ? ax->getBrowserURL() : String::empty;
}
//==============================================================================
@@ -822,16 +823,16 @@ extern "C" BOOL WINAPI DllMain (HANDLE instance, DWORD reason, LPVOID)
static const String CLSIDToJuceString (REFCLSID clsid)
{
LPWSTR s = 0;
LPWSTR s = nullptr;
StringFromIID (clsid, &s);
if (s == 0)
if (s == nullptr)
return String::empty;
const String result (s);
LPMALLOC malloc;
CoGetMalloc (1, &malloc);
if (malloc != 0)
if (malloc != nullptr)
{
malloc->Free (s);
malloc->Release();
@@ -844,7 +845,7 @@ STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
#pragma EXPORTED_FUNCTION
*ppv = 0;
*ppv = nullptr;
if (CLSIDToJuceString (rclsid).equalsIgnoreCase (String (JuceBrowserPlugin_ActiveXCLSID)))
{


+ 106
- 107
extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp View File

@@ -121,9 +121,9 @@ NPError NP_GetValue (void* future, NPPVariable variable, void* value)
#if JUCE_WINDOWS || JUCE_MAC
NPError OSCALL NP_GetEntryPoints (NPPluginFuncs* funcs)
{
#if JUCE_WINDOWS
#if JUCE_WINDOWS
#pragma EXPORTED_FUNCTION
#endif
#endif
log ("NP_GetEntryPoints");
if (funcs == 0 || (funcs->size > 0 && funcs->size < sizeof (NPPluginFuncs)))
@@ -138,17 +138,17 @@ NPError OSCALL NP_GetEntryPoints (NPPluginFuncs* funcs)
funcs->destroystream = NPP_DestroyStream;
funcs->asfile = NPP_StreamAsFile;
funcs->writeready = NPP_WriteReady;
#if JUCE_MAC
#if JUCE_MAC
funcs->write = (NPP_WriteProcPtr) NPP_Write;
#else
#else
funcs->write = NPP_Write;
#endif
#endif
funcs->print = NPP_Print;
funcs->event = NPP_HandleEvent;
funcs->urlnotify = NPP_URLNotify;
funcs->getvalue = NPP_GetValue;
funcs->setvalue = NPP_SetValue;
funcs->javaClass = 0;
funcs->javaClass = nullptr;
return NPERR_NO_ERROR;
}
@@ -160,9 +160,9 @@ NPError OSCALL NP_Initialize (NPNetscapeFuncs* funcs
#endif
)
{
#if JUCE_WINDOWS
#if JUCE_WINDOWS
#pragma EXPORTED_FUNCTION
#endif
#endif
log ("NP_Initialize");
if (funcs == 0)
@@ -174,7 +174,7 @@ NPError OSCALL NP_Initialize (NPNetscapeFuncs* funcs
zerostruct (browser);
memcpy (&browser, funcs, jmin ((size_t) funcs->size, sizeof (browser)));
#ifdef XP_UNIX
#ifdef XP_UNIX
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
pluginFuncs->size = sizeof (NPPluginFuncs);
pluginFuncs->newp = NewNPP_NewProc (NPP_New);
@@ -192,16 +192,16 @@ NPError OSCALL NP_Initialize (NPNetscapeFuncs* funcs
#ifdef OJI
pluginFuncs->javaClass = NPP_GetJavaClass();
#endif
#endif
#endif
return NPERR_NO_ERROR;
}
NPError OSCALL NP_Shutdown()
{
#if JUCE_WINDOWS
#if JUCE_WINDOWS
#pragma EXPORTED_FUNCTION
#endif
#endif
log ("NP_Shutdown");
return NPERR_NO_ERROR;
@@ -266,36 +266,37 @@ public:
: npp (npp_)
{
log ("BrowserPluginHolderComponent created");
#if JUCE_WINDOWS
#if JUCE_WINDOWS
parentHWND = 0;
oldWinProc = 0;
#else
#else
currentParentView = 0;
#endif
#endif
setOpaque (true);
setWantsKeyboardFocus (false);
addAndMakeVisible (child = createBrowserPlugin());
jassert (child != 0); // You have to create one of these!
jassert (child != nullptr); // You have to create one of these!
}
~BrowserPluginHolderComponent()
{
log ("BrowserPluginHolderComponent deleted");
setWindow (0);
child = 0;
setWindow (nullptr);
child = nullptr;
}
//==============================================================================
void paint (Graphics& g)
{
if (child == 0 || ! child->isOpaque())
if (child == nullptr || ! child->isOpaque())
g.fillAll (Colours::white);
}
void resized()
{
if (child != 0)
if (child != nullptr)
child->setBounds (getLocalBounds());
}
@@ -370,7 +371,7 @@ private:
public:
void setWindow (NPWindow* window)
{
HWND newHWND = (window != 0 ? ((HWND) window->window) : 0);
HWND newHWND = (window != nullptr ? ((HWND) window->window) : 0);
if (parentHWND != newHWND)
{
@@ -428,7 +429,7 @@ public:
{
NSView* found = findViewAt (v, x, y);
if (found != 0)
if (found != nil)
return found;
}
}
@@ -437,7 +438,7 @@ public:
return parent;
}
return 0;
return nil;
}
public:
@@ -454,22 +455,22 @@ public:
log ("setWindow");
NSView* parentView = 0;
NP_CGContext* const cgContext = (window != 0) ? (NP_CGContext*) window->window : 0;
NSView* parentView = nil;
NP_CGContext* const cgContext = (window != nullptr) ? (NP_CGContext*) window->window : nullptr;
log ("NP_CGContext: " + String::toHexString ((pointer_sized_int) cgContext));
#ifndef __LP64__
WindowRef windowRef = cgContext != 0 ? (WindowRef) cgContext->window : 0;
#ifndef __LP64__
WindowRef windowRef = cgContext != nullptr ? (WindowRef) cgContext->window : 0;
if (windowRef != 0)
{
NSWindow* win = [[[NSWindow alloc] initWithWindowRef: windowRef] autorelease];
#else
NSWindow* win = cgContext != 0 ? (NSWindow*) cgContext->window : 0;
#else
NSWindow* win = cgContext != nullptr ? (NSWindow*) cgContext->window : nil;
if (win != 0)
if (win != nil)
{
#endif
#endif
log ("window: " + nsStringToJuce ([win description]));
const Rectangle<int> clip (window->clipRect.left, window->clipRect.top,
@@ -505,7 +506,7 @@ public:
if (! isBrowserContentView (parentView))
parentView = currentParentView;
}
else if (currentParentView != 0 && ! target.isEmpty())
else if (currentParentView != nil && ! target.isEmpty())
{
// Firefox can send lots of spurious resize messages when updating its pages, so this is a
// bodge to avoid flickering caused by repeatedly removing and re-adding the view..
@@ -524,7 +525,7 @@ public:
currentParentView = parentView;
if (parentView != 0)
if (parentView != nil)
{
setSize (window->width, window->height);
addToDesktop (0, parentView);
@@ -532,7 +533,7 @@ public:
}
}
if (window != 0)
if (window != nullptr)
setSize (window->width, window->height);
}
#endif
@@ -673,16 +674,16 @@ private:
bool hasMethod (NPIdentifier name)
{
DynamicObject* const o = object.getObject();
return o != 0 && o->hasMethod (identifierToString (name));
DynamicObject* const o = object.getDynamicObject();
return o != nullptr && o->hasMethod (identifierToString (name));
}
bool invoke (NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* out)
{
DynamicObject* const o = object.getObject();
DynamicObject* const o = object.getDynamicObject();
const var::identifier methodName (identifierToString (name));
if (o == 0 || ! o->hasMethod (methodName))
if (o == nullptr || ! o->hasMethod (methodName))
return false;
struct ParamHolder
@@ -700,7 +701,7 @@ private:
const var result (o->invokeMethod (methodName, params.params, argCount));
if (out != 0)
if (out != nullptr)
createNPVariantFromValue (npp, *out, result);
return true;
@@ -713,21 +714,21 @@ private:
bool hasProperty (NPIdentifier name)
{
DynamicObject* const o = object.getObject();
return o != 0 && o->hasProperty (identifierToString (name));
DynamicObject* const o = object.getDynamicObject();
return o != nullptr && o->hasProperty (identifierToString (name));
}
bool getProperty (NPIdentifier name, NPVariant* out)
{
DynamicObject* const o = object.getObject();
DynamicObject* const o = object.getDynamicObject();
const var::identifier propName (identifierToString (name));
if (o == 0 || ! o->hasProperty (propName))
if (o == nullptr || ! o->hasProperty (propName))
return false;
const var result (o->getProperty (propName));
if (out != 0)
if (out != nullptr)
createNPVariantFromValue (npp, *out, result);
return true;
@@ -735,9 +736,9 @@ private:
bool setProperty (NPIdentifier name, const NPVariant* value)
{
DynamicObject* const o = object.getObject();
DynamicObject* const o = object.getDynamicObject();
if (value == 0 || o == 0)
if (value == nullptr || o == nullptr)
return false;
o->setProperty (identifierToString (name), createValueFromNPVariant (npp, *value));
@@ -746,10 +747,10 @@ private:
bool removeProperty (NPIdentifier name)
{
DynamicObject* const o = object.getObject();
DynamicObject* const o = object.getDynamicObject();
const var::identifier propName (identifierToString (name));
if (o == 0 || ! o->hasProperty (propName))
if (o == nullptr || ! o->hasProperty (propName))
return false;
o->removeProperty (propName);
@@ -789,33 +790,30 @@ public:
static bool class_construct (NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result) { return ((NPObjectWrappingDynamicObject*) npobj)->construct (args, argCount, result); }
};
#ifndef NP_CLASS_STRUCT_VERSION_ENUM
static NPClass sNPObjectWrappingDynamicObject_NPClass =
{
#ifndef NP_CLASS_STRUCT_VERSION_ENUM
NP_CLASS_STRUCT_VERSION, NPObjectWrappingDynamicObject::createInstance,
NPObjectWrappingDynamicObject::class_deallocate, NPObjectWrappingDynamicObject::class_invalidate,
NPObjectWrappingDynamicObject::class_hasMethod, NPObjectWrappingDynamicObject::class_invoke,
NPObjectWrappingDynamicObject::class_invokeDefault, NPObjectWrappingDynamicObject::class_hasProperty,
NPObjectWrappingDynamicObject::class_getProperty, NPObjectWrappingDynamicObject::class_setProperty,
NPObjectWrappingDynamicObject::class_removeProperty
};
#else
static NPClass sNPObjectWrappingDynamicObject_NPClass =
{
#else
NP_CLASS_STRUCT_VERSION_ENUM, NPObjectWrappingDynamicObject::createInstance,
NPObjectWrappingDynamicObject::class_deallocate, NPObjectWrappingDynamicObject::class_invalidate,
NPObjectWrappingDynamicObject::class_hasMethod, NPObjectWrappingDynamicObject::class_invoke,
NPObjectWrappingDynamicObject::class_invokeDefault, NPObjectWrappingDynamicObject::class_hasProperty,
NPObjectWrappingDynamicObject::class_getProperty, NPObjectWrappingDynamicObject::class_setProperty,
NPObjectWrappingDynamicObject::class_removeProperty, NPObjectWrappingDynamicObject::class_enumerate
#endif
};
#endif
bool NPObjectWrappingDynamicObject::construct (const NPVariant* args, uint32_t argCount, NPVariant* result)
{
NPObject* const newObj = browser.createobject (npp, &sNPObjectWrappingDynamicObject_NPClass);
if (newObj == 0)
if (newObj == nullptr)
return false;
OBJECT_TO_NPVARIANT (newObj, *result);
@@ -824,11 +822,11 @@ bool NPObjectWrappingDynamicObject::construct (const NPVariant* args, uint32_t a
NPObject* NPObjectWrappingDynamicObject::create (NPP npp, const var& objectToWrap)
{
jassert (objectToWrap.getObject() != 0);
jassert (objectToWrap.getDynamicObject() != nullptr);
NPObject* const nppObject = browser.createobject (npp, &sNPObjectWrappingDynamicObject_NPClass);
if (nppObject != 0)
if (nppObject != nullptr)
((NPObjectWrappingDynamicObject*) nppObject)->object = objectToWrap;
return nppObject;
@@ -845,17 +843,18 @@ static const var createValueFromNPVariant (NPP npp, const NPVariant& v)
else if (NPVARIANT_IS_DOUBLE (v))
return var (NPVARIANT_TO_DOUBLE (v));
else if (NPVARIANT_IS_STRING (v))
#if JUCE_MAC
return var (String::fromUTF8 ((const char*) (NPVARIANT_TO_STRING (v).UTF8Characters),
(int) NPVARIANT_TO_STRING (v).UTF8Length));
#else
return var (String::fromUTF8 ((const char*) (NPVARIANT_TO_STRING (v).utf8characters),
(int) NPVARIANT_TO_STRING (v).utf8length));
#endif
else if (NPVARIANT_IS_OBJECT (v) && npp != 0)
{
return var (String::fromUTF8 ((const char*)
#if JUCE_MAC
(NPVARIANT_TO_STRING (v).UTF8Characters), (int) NPVARIANT_TO_STRING (v).UTF8Length));
#else
(NPVARIANT_TO_STRING (v).utf8characters), (int) NPVARIANT_TO_STRING (v).utf8length));
#endif
}
else if (NPVARIANT_IS_OBJECT (v) && npp != nullptr)
return var (new DynamicObjectWrappingNPObject (npp, NPVARIANT_TO_OBJECT (v)));
return var();
return var::null;
}
static void createNPVariantFromValue (NPP npp, NPVariant& out, const var& v)
@@ -875,7 +874,7 @@ static void createNPVariantFromValue (NPP npp, NPVariant& out, const var& v)
memcpy (stringCopy, utf8, utf8Len);
STRINGZ_TO_NPVARIANT (stringCopy, out);
}
else if (v.isObject() && npp != 0)
else if (v.getDynamicObject() != nullptr && npp != nullptr)
OBJECT_TO_NPVARIANT (NPObjectWrappingDynamicObject::create (npp, v), out);
else
VOID_TO_NPVARIANT (out);
@@ -888,21 +887,21 @@ public:
//==============================================================================
JucePluginInstance (NPP npp_)
: npp (npp_),
holderComp (0),
scriptObject (0)
holderComp (nullptr),
scriptObject (nullptr)
{
}
~JucePluginInstance()
{
setWindow (0);
setWindow (nullptr);
}
bool setWindow (NPWindow* window)
{
if (window != 0)
if (window != nullptr)
{
if (holderComp == 0)
if (holderComp == nullptr)
holderComp = new BrowserPluginHolderComponent (npp);
holderComp->setWindow (window);
@@ -910,7 +909,7 @@ public:
else
{
deleteAndZero (holderComp);
scriptObject = 0;
scriptObject = nullptr;
}
return true;
@@ -918,10 +917,10 @@ public:
NPObject* getScriptableObject()
{
if (scriptObject == 0)
if (scriptObject == nullptr)
scriptObject = NPObjectWrappingDynamicObject::create (npp, holderComp->getObject());
if (scriptObject != 0 && shouldRetainBrowserObject())
if (scriptObject != nullptr && shouldRetainBrowserObject())
browser.retainobject (scriptObject);
return scriptObject;
@@ -947,24 +946,24 @@ private:
};
//==============================================================================
static NPP currentlyInitialisingNPP = 0;
static NPP currentlyInitialisingNPP = nullptr;
static int numPluginInstances = 0;
NPError NPP_New (NPMIMEType pluginType, NPP npp, ::uint16 mode, ::int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
log ("NPP_New");
if (npp == 0)
if (npp == nullptr)
return NPERR_INVALID_INSTANCE_ERROR;
#if JUCE_MAC
#if JUCE_MAC
browser.setvalue (npp, (NPPVariable) NPNVpluginDrawingModel, (void*) NPDrawingModelCoreGraphics);
#ifdef __LP64__
#ifdef __LP64__
browser.setvalue (npp, (NPPVariable) 1001 /*NPPVpluginEventModel*/, (void*) 1 /*NPEventModelCocoa*/);
#else
#else
browser.setvalue (npp, (NPPVariable) 1001 /*NPPVpluginEventModel*/, 0 /*NPEventModelCarbon*/);
#endif
#endif
#endif
#endif
if (numPluginInstances++ == 0)
{
@@ -974,7 +973,7 @@ NPError NPP_New (NPMIMEType pluginType, NPP npp, ::uint16 mode, ::int16 argc, ch
currentlyInitialisingNPP = npp;
JucePluginInstance* p = new JucePluginInstance (npp);
currentlyInitialisingNPP = 0;
currentlyInitialisingNPP = nullptr;
npp->pdata = (void*) p;
return NPERR_NO_ERROR;
@@ -983,12 +982,12 @@ NPError NPP_New (NPMIMEType pluginType, NPP npp, ::uint16 mode, ::int16 argc, ch
NPError NPP_Destroy (NPP npp, NPSavedData** save)
{
log ("NPP_Destroy");
if (npp == 0)
if (npp == nullptr)
return NPERR_INVALID_INSTANCE_ERROR;
JucePluginInstance* const p = (JucePluginInstance*) npp->pdata;
if (p != 0)
if (p != nullptr)
{
delete p;
@@ -1005,33 +1004,33 @@ NPError NPP_Destroy (NPP npp, NPSavedData** save)
NPError NPP_SetWindow (NPP npp, NPWindow* pNPWindow)
{
if (npp == 0)
if (npp == nullptr)
return NPERR_INVALID_INSTANCE_ERROR;
if (pNPWindow == 0)
if (pNPWindow == nullptr)
return NPERR_GENERIC_ERROR;
JucePluginInstance* const p = (JucePluginInstance*) npp->pdata;
if (p == 0)
if (p == nullptr)
return NPERR_GENERIC_ERROR;
currentlyInitialisingNPP = npp;
NPError result = p->setWindow (pNPWindow) ? NPERR_NO_ERROR
: NPERR_MODULE_LOAD_FAILED_ERROR;
currentlyInitialisingNPP = 0;
currentlyInitialisingNPP = nullptr;
return result;
}
//==============================================================================
NPError NPP_GetValue (NPP npp, NPPVariable variable, void* value)
{
if (npp == 0)
if (npp == nullptr)
return NPERR_INVALID_INSTANCE_ERROR;
JucePluginInstance* const p = (JucePluginInstance*) npp->pdata;
if (p == 0)
if (p == nullptr)
return NPERR_GENERIC_ERROR;
switch (variable)
@@ -1047,7 +1046,7 @@ NPError NPP_GetValue (NPP npp, NPPVariable variable, void* value)
NPError NPP_NewStream (NPP npp, NPMIMEType type, NPStream* stream, NPBool seekable, ::uint16* stype)
{
if (npp == 0)
if (npp == nullptr)
return NPERR_INVALID_INSTANCE_ERROR;
return NPERR_NO_ERROR;
@@ -1055,7 +1054,7 @@ NPError NPP_NewStream (NPP npp, NPMIMEType type, NPStream* stream, NPBool seekab
::int32 NPP_WriteReady (NPP npp, NPStream *stream)
{
if (npp == 0)
if (npp == nullptr)
return NPERR_INVALID_INSTANCE_ERROR;
return 0x0fffffff;
@@ -1063,7 +1062,7 @@ NPError NPP_NewStream (NPP npp, NPMIMEType type, NPStream* stream, NPBool seekab
::int32 NPP_Write (NPP npp, NPStream *stream, ::int32 offset, ::int32 len, void *buffer)
{
if (npp == 0)
if (npp == nullptr)
return NPERR_INVALID_INSTANCE_ERROR;
return len;
@@ -1071,7 +1070,7 @@ NPError NPP_NewStream (NPP npp, NPMIMEType type, NPStream* stream, NPBool seekab
NPError NPP_DestroyStream (NPP npp, NPStream *stream, NPError reason)
{
if (npp == 0)
if (npp == nullptr)
return NPERR_INVALID_INSTANCE_ERROR;
return NPERR_NO_ERROR;
@@ -1079,25 +1078,25 @@ NPError NPP_DestroyStream (NPP npp, NPStream *stream, NPError reason)
void NPP_StreamAsFile (NPP npp, NPStream* stream, const char* fname)
{
if (npp == 0)
if (npp == nullptr)
return;
}
void NPP_Print (NPP npp, NPPrint* printInfo)
{
if (npp == 0)
if (npp == nullptr)
return;
}
void NPP_URLNotify (NPP npp, const char* url, NPReason reason, void* notifyData)
{
if (npp == 0)
if (npp == nullptr)
return;
}
NPError NPP_SetValue (NPP npp, NPNVariable variable, void* value)
{
if (npp == 0)
if (npp == nullptr)
return NPERR_INVALID_INSTANCE_ERROR;
return NPERR_NO_ERROR;
@@ -1105,7 +1104,7 @@ NPError NPP_SetValue (NPP npp, NPNVariable variable, void* value)
::int16 NPP_HandleEvent (NPP npp, void* ev)
{
if (npp != 0)
if (npp != nullptr)
{
//JucePluginInstance* const p = (JucePluginInstance*) npp->pdata;
}
@@ -1119,7 +1118,7 @@ static NPP getInstance (const BrowserPluginComponent* bpc)
{
BrowserPluginHolderComponent* holder = dynamic_cast <BrowserPluginHolderComponent*> (bpc->getParentComponent());
if (holder != 0)
if (holder != nullptr)
return holder->npp;
return currentlyInitialisingNPP;
@@ -1138,7 +1137,7 @@ const String BrowserPluginComponent::getBrowserVersion() const
{
if (browserVersionDesc.isEmpty())
{
if (getInstance (this) != 0)
if (getInstance (this) != nullptr)
browserVersionDesc << browser.uagent (getInstance (this));
else
browserVersionDesc << "Netscape Plugin V" << (int) ((browser.version >> 8) & 0xff)
@@ -1157,23 +1156,23 @@ const String BrowserPluginComponent::getBrowserURL() const
{
String result;
#if JUCE_WINDOWS
#if JUCE_WINDOWS
result = getActiveXBrowserURL (this);
if (result.isNotEmpty())
return result;
#endif
#endif
// (FireFox doesn't seem happy if you call this from a background thread..)
jassert (MessageManager::getInstance()->isThisTheMessageThread());
NPP npp = getInstance (this);
if (npp != 0)
if (npp != nullptr)
{
NPObject* windowObj = 0;
NPObject* windowObj = nullptr;
browser.getvalue (npp, NPNVWindowNPObject, &windowObj);
if (windowObj != 0)
if (windowObj != nullptr)
{
NPVariant location;
bool ok = browser.getproperty (npp, windowObj,


+ 100
- 101
juce_amalgamated.cpp View File

@@ -4173,15 +4173,15 @@ enum VariantStreamMarkers
class var::VariantType
{
public:
VariantType() {}
virtual ~VariantType() {}
VariantType() noexcept {}
virtual ~VariantType() noexcept {}

virtual int toInt (const ValueUnion&) const { return 0; }
virtual int64 toInt64 (const ValueUnion&) const { return 0; }
virtual double toDouble (const ValueUnion&) const { return 0; }
virtual const String toString (const ValueUnion&) const { return String::empty; }
virtual bool toBool (const ValueUnion&) const { return false; }
virtual DynamicObject* toObject (const ValueUnion&) const { return nullptr; }
virtual int toInt (const ValueUnion&) const noexcept { return 0; }
virtual int64 toInt64 (const ValueUnion&) const noexcept { return 0; }
virtual double toDouble (const ValueUnion&) const noexcept { return 0; }
virtual const String toString (const ValueUnion&) const { return String::empty; }
virtual bool toBool (const ValueUnion&) const noexcept { return false; }
virtual ReferenceCountedObject* toObject (const ValueUnion&) const noexcept { return nullptr; }

virtual bool isVoid() const noexcept { return false; }
virtual bool isInt() const noexcept { return false; }
@@ -4201,7 +4201,7 @@ public:
class var::VariantType_Void : public var::VariantType
{
public:
VariantType_Void() {}
VariantType_Void() noexcept {}
static const VariantType_Void instance;

bool isVoid() const noexcept { return true; }
@@ -4212,14 +4212,14 @@ public:
class var::VariantType_Int : public var::VariantType
{
public:
VariantType_Int() {}
VariantType_Int() noexcept {}
static const VariantType_Int instance;

int toInt (const ValueUnion& data) const { return data.intValue; };
int64 toInt64 (const ValueUnion& data) const { return (int64) data.intValue; };
double toDouble (const ValueUnion& data) const { return (double) data.intValue; }
int toInt (const ValueUnion& data) const noexcept { return data.intValue; };
int64 toInt64 (const ValueUnion& data) const noexcept { return (int64) data.intValue; };
double toDouble (const ValueUnion& data) const noexcept { return (double) data.intValue; }
const String toString (const ValueUnion& data) const { return String (data.intValue); }
bool toBool (const ValueUnion& data) const { return data.intValue != 0; }
bool toBool (const ValueUnion& data) const noexcept { return data.intValue != 0; }
bool isInt() const noexcept { return true; }

bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -4238,14 +4238,14 @@ public:
class var::VariantType_Int64 : public var::VariantType
{
public:
VariantType_Int64() {}
VariantType_Int64() noexcept {}
static const VariantType_Int64 instance;

int toInt (const ValueUnion& data) const { return (int) data.int64Value; };
int64 toInt64 (const ValueUnion& data) const { return data.int64Value; };
double toDouble (const ValueUnion& data) const { return (double) data.int64Value; }
int toInt (const ValueUnion& data) const noexcept { return (int) data.int64Value; };
int64 toInt64 (const ValueUnion& data) const noexcept { return data.int64Value; };
double toDouble (const ValueUnion& data) const noexcept { return (double) data.int64Value; }
const String toString (const ValueUnion& data) const { return String (data.int64Value); }
bool toBool (const ValueUnion& data) const { return data.int64Value != 0; }
bool toBool (const ValueUnion& data) const noexcept { return data.int64Value != 0; }
bool isInt64() const noexcept { return true; }

bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -4264,14 +4264,14 @@ public:
class var::VariantType_Double : public var::VariantType
{
public:
VariantType_Double() {}
VariantType_Double() noexcept {}
static const VariantType_Double instance;

int toInt (const ValueUnion& data) const { return (int) data.doubleValue; };
int64 toInt64 (const ValueUnion& data) const { return (int64) data.doubleValue; };
double toDouble (const ValueUnion& data) const { return data.doubleValue; }
int toInt (const ValueUnion& data) const noexcept { return (int) data.doubleValue; };
int64 toInt64 (const ValueUnion& data) const noexcept { return (int64) data.doubleValue; };
double toDouble (const ValueUnion& data) const noexcept { return data.doubleValue; }
const String toString (const ValueUnion& data) const { return String (data.doubleValue); }
bool toBool (const ValueUnion& data) const { return data.doubleValue != 0; }
bool toBool (const ValueUnion& data) const noexcept { return data.doubleValue != 0; }
bool isDouble() const noexcept { return true; }

bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -4290,14 +4290,14 @@ public:
class var::VariantType_Bool : public var::VariantType
{
public:
VariantType_Bool() {}
VariantType_Bool() noexcept {}
static const VariantType_Bool instance;

int toInt (const ValueUnion& data) const { return data.boolValue ? 1 : 0; };
int64 toInt64 (const ValueUnion& data) const { return data.boolValue ? 1 : 0; };
double toDouble (const ValueUnion& data) const { return data.boolValue ? 1.0 : 0.0; }
int toInt (const ValueUnion& data) const noexcept { return data.boolValue ? 1 : 0; };
int64 toInt64 (const ValueUnion& data) const noexcept { return data.boolValue ? 1 : 0; };
double toDouble (const ValueUnion& data) const noexcept { return data.boolValue ? 1.0 : 0.0; }
const String toString (const ValueUnion& data) const { return String::charToString (data.boolValue ? '1' : '0'); }
bool toBool (const ValueUnion& data) const { return data.boolValue; }
bool toBool (const ValueUnion& data) const noexcept { return data.boolValue; }
bool isBool() const noexcept { return true; }

bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -4315,17 +4315,17 @@ public:
class var::VariantType_String : public var::VariantType
{
public:
VariantType_String() {}
VariantType_String() noexcept {}
static const VariantType_String instance;

void cleanUp (ValueUnion& data) const noexcept { delete data.stringValue; }
void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest.stringValue = new String (*source.stringValue); }

int toInt (const ValueUnion& data) const { return data.stringValue->getIntValue(); };
int64 toInt64 (const ValueUnion& data) const { return data.stringValue->getLargeIntValue(); };
double toDouble (const ValueUnion& data) const { return data.stringValue->getDoubleValue(); }
int toInt (const ValueUnion& data) const noexcept { return data.stringValue->getIntValue(); };
int64 toInt64 (const ValueUnion& data) const noexcept { return data.stringValue->getLargeIntValue(); };
double toDouble (const ValueUnion& data) const noexcept { return data.stringValue->getDoubleValue(); }
const String toString (const ValueUnion& data) const { return *data.stringValue; }
bool toBool (const ValueUnion& data) const { return data.stringValue->getIntValue() != 0
bool toBool (const ValueUnion& data) const noexcept { return data.stringValue->getIntValue() != 0
|| data.stringValue->trim().equalsIgnoreCase ("true")
|| data.stringValue->trim().equalsIgnoreCase ("yes"); }
bool isString() const noexcept { return true; }
@@ -4349,16 +4349,16 @@ public:
class var::VariantType_Object : public var::VariantType
{
public:
VariantType_Object() {}
VariantType_Object() noexcept {}
static const VariantType_Object instance;

void cleanUp (ValueUnion& data) const noexcept { if (data.objectValue != nullptr) data.objectValue->decReferenceCount(); }
void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest.objectValue = source.objectValue; if (dest.objectValue != nullptr) dest.objectValue->incReferenceCount(); }
void cleanUp (ValueUnion& data) const noexcept { if (data.objectValue != nullptr) data.objectValue->decReferenceCount(); }
void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest.objectValue = source.objectValue; if (dest.objectValue != nullptr) dest.objectValue->incReferenceCount(); }

const String toString (const ValueUnion& data) const { return "Object 0x" + String::toHexString ((int) (pointer_sized_int) data.objectValue); }
bool toBool (const ValueUnion& data) const { return data.objectValue != 0; }
DynamicObject* toObject (const ValueUnion& data) const { return data.objectValue; }
bool isObject() const noexcept { return true; }
const String toString (const ValueUnion& data) const { return "Object 0x" + String::toHexString ((int) (pointer_sized_int) data.objectValue); }
bool toBool (const ValueUnion& data) const noexcept { return data.objectValue != 0; }
ReferenceCountedObject* toObject (const ValueUnion& data) const noexcept { return data.objectValue; }
bool isObject() const noexcept { return true; }

bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
@@ -4375,11 +4375,11 @@ public:
class var::VariantType_Method : public var::VariantType
{
public:
VariantType_Method() {}
VariantType_Method() noexcept {}
static const VariantType_Method instance;

const String toString (const ValueUnion&) const { return "Method"; }
bool toBool (const ValueUnion& data) const { return data.methodValue != 0; }
bool toBool (const ValueUnion& data) const noexcept { return data.methodValue != 0; }
bool isMethod() const noexcept { return true; }

bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -4454,7 +4454,7 @@ var::var (const wchar_t* const value_) : type (&VariantType_String::instance)
value.stringValue = new String (value_);
}

var::var (DynamicObject* const object) : type (&VariantType_Object::instance)
var::var (ReferenceCountedObject* const object) : type (&VariantType_Object::instance)
{
value.objectValue = object;

@@ -4476,14 +4476,15 @@ bool var::isString() const noexcept { return type->isString(); }
bool var::isObject() const noexcept { return type->isObject(); }
bool var::isMethod() const noexcept { return type->isMethod(); }

var::operator int() const { return type->toInt (value); }
var::operator int64() const { return type->toInt64 (value); }
var::operator bool() const { return type->toBool (value); }
var::operator float() const { return (float) type->toDouble (value); }
var::operator double() const { return type->toDouble (value); }
const String var::toString() const { return type->toString (value); }
var::operator const String() const { return type->toString (value); }
DynamicObject* var::getObject() const { return type->toObject (value); }
var::operator int() const noexcept { return type->toInt (value); }
var::operator int64() const noexcept { return type->toInt64 (value); }
var::operator bool() const noexcept { return type->toBool (value); }
var::operator float() const noexcept { return (float) type->toDouble (value); }
var::operator double() const noexcept { return type->toDouble (value); }
const String var::toString() const { return type->toString (value); }
var::operator const String() const { return type->toString (value); }
ReferenceCountedObject* var::getObject() const noexcept { return type->toObject (value); }
DynamicObject* var::getDynamicObject() const noexcept { return dynamic_cast <DynamicObject*> (getObject()); }

void var::swapWith (var& other) noexcept
{
@@ -4491,16 +4492,16 @@ void var::swapWith (var& other) noexcept
std::swap (value, other.value);
}

var& var::operator= (const var& newValue) { type->cleanUp (value); type = newValue.type; type->createCopy (value, newValue.value); return *this; }
var& var::operator= (int newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (int64 newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (bool newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (double newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const char* newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const wchar_t* newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const String& newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (DynamicObject* newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (MethodFunction newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const var& newValue) { type->cleanUp (value); type = newValue.type; type->createCopy (value, newValue.value); return *this; }
var& var::operator= (const int newValue) { type->cleanUp (value); type = &VariantType_Int::instance; value.intValue = newValue; return *this; }
var& var::operator= (const int64 newValue) { type->cleanUp (value); type = &VariantType_Int64::instance; value.int64Value = newValue; return *this; }
var& var::operator= (const bool newValue) { type->cleanUp (value); type = &VariantType_Bool::instance; value.boolValue = newValue; return *this; }
var& var::operator= (const double newValue) { type->cleanUp (value); type = &VariantType_Double::instance; value.doubleValue = newValue; return *this; }
var& var::operator= (const char* const newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const wchar_t* const newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const String& newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (ReferenceCountedObject* newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (MethodFunction newValue) { var v (newValue); swapWith (v); return *this; }

bool var::equals (const var& other) const noexcept
{
@@ -4514,8 +4515,10 @@ bool var::equalsWithSameType (const var& other) const noexcept

bool operator== (const var& v1, const var& v2) noexcept { return v1.equals (v2); }
bool operator!= (const var& v1, const var& v2) noexcept { return ! v1.equals (v2); }
bool operator== (const var& v1, const String& v2) noexcept { return v1.toString() == v2; }
bool operator!= (const var& v1, const String& v2) noexcept { return v1.toString() != v2; }
bool operator== (const var& v1, const String& v2) { return v1.toString() == v2; }
bool operator!= (const var& v1, const String& v2) { return v1.toString() != v2; }
bool operator== (const var& v1, const char* const v2) { return v1.toString() == v2; }
bool operator!= (const var& v1, const char* const v2) { return v1.toString() != v2; }

void var::writeToStream (OutputStream& output) const
{
@@ -4551,13 +4554,13 @@ const var var::readFromStream (InputStream& input)

const var var::operator[] (const Identifier& propertyName) const
{
DynamicObject* const o = getObject();
DynamicObject* const o = getDynamicObject();
return o != nullptr ? o->getProperty (propertyName) : var::null;
}

const var var::invoke (const Identifier& method, const var* arguments, int numArguments) const
{
DynamicObject* const o = getObject();
DynamicObject* const o = getDynamicObject();
return o != nullptr ? o->invokeMethod (method, arguments, numArguments) : var::null;
}

@@ -4565,7 +4568,7 @@ const var var::invoke (const var& targetObject, const var* arguments, int numArg
{
if (isMethod())
{
DynamicObject* const target = targetObject.getObject();
DynamicObject* const target = targetObject.getDynamicObject();

if (target != nullptr)
return (target->*(value.methodValue)) (arguments, numArguments);
@@ -49066,9 +49069,9 @@ public:

if (selectedRows.size() > 0)
{
const String dragDescription (owner.getModel()->getDragSourceDescription (selectedRows));
const var dragDescription (owner.getModel()->getDragSourceDescription (selectedRows));

if (dragDescription.isNotEmpty())
if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty())))
{
isDragging = true;
owner.startDragAndDrop (e, dragDescription);
@@ -49854,7 +49857,7 @@ const Image ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
return snapshot;
}

void ListBox::startDragAndDrop (const MouseEvent& e, const String& dragDescription)
void ListBox::startDragAndDrop (const MouseEvent& e, const var& dragDescription)
{
DragAndDropContainer* const dragContainer
= DragAndDropContainer::findParentDragContainerFor (this);
@@ -49890,8 +49893,8 @@ void ListBoxModel::selectedRowsChanged (int) {}
void ListBoxModel::deleteKeyPressed (int) {}
void ListBoxModel::returnKeyPressed (int) {}
void ListBoxModel::listWasScrolled() {}
const String ListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return String::empty; }
const String ListBoxModel::getTooltipForRow (int) { return String::empty; }
const var ListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var::null; }
const String ListBoxModel::getTooltipForRow (int) { return String::empty; }

END_JUCE_NAMESPACE
/*** End of inlined file: juce_ListBox.cpp ***/
@@ -52432,9 +52435,9 @@ public:

if (selectedRows.size() > 0)
{
const String dragDescription (owner.getModel()->getDragSourceDescription (selectedRows));
const var dragDescription (owner.getModel()->getDragSourceDescription (selectedRows));

if (dragDescription.isNotEmpty())
if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty())))
{
isDragging = true;
owner.startDragAndDrop (e, dragDescription);
@@ -52749,7 +52752,7 @@ void TableListBoxModel::returnKeyPressed (int) {}
void TableListBoxModel::listWasScrolled() {}

const String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; }
const String TableListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return String::empty; }
const var TableListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var::null; }

Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component* existingComponentToUpdate)
{
@@ -56523,9 +56526,9 @@ public:

if (item != nullptr && e.getMouseDownX() >= pos.getX())
{
const String dragDescription (item->getDragSourceDescription());
const var dragDescription (item->getDragSourceDescription());

if (dragDescription.isNotEmpty())
if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty())))
{
DragAndDropContainer* const dragContainer
= DragAndDropContainer::findParentDragContainerFor (this);
@@ -57679,9 +57682,9 @@ const String TreeViewItem::getTooltip()
return String::empty;
}

const String TreeViewItem::getDragSourceDescription()
const var TreeViewItem::getDragSourceDescription()
{
return String::empty;
return var::null;
}

bool TreeViewItem::isInterestedInFileDrag (const StringArray&)
@@ -60179,7 +60182,7 @@ public:
const String getUniqueName() const { return file.getFullPathName(); }
int getItemHeight() const { return 22; }

const String getDragSourceDescription() { return owner.getDragAndDropDescription(); }
const var getDragSourceDescription() { return owner.getDragAndDropDescription(); }

void itemOpennessChanged (bool isNowOpen)
{
@@ -70483,14 +70486,16 @@ private:
{
const Rectangle<int> mon (Desktop::getInstance()
.getMonitorAreaContaining (target.getCentre(),
#if JUCE_MAC
#if JUCE_MAC
true));
#else
#else
false)); // on windows, don't stop the menu overlapping the taskbar
#endif
#endif

const int maxMenuHeight = mon.getHeight() - 24;

int x, y, widthToUse, heightToUse;
layoutMenuItems (mon.getWidth() - 24, widthToUse, heightToUse);
layoutMenuItems (mon.getWidth() - 24, maxMenuHeight, widthToUse, heightToUse);

if (alignToRectangle)
{
@@ -70531,10 +70536,10 @@ private:

if (biggestSpace < widthToUse)
{
layoutMenuItems (biggestSpace + target.getWidth() / 3, widthToUse, heightToUse);
layoutMenuItems (biggestSpace + target.getWidth() / 3, maxMenuHeight, widthToUse, heightToUse);

if (numColumns > 1)
layoutMenuItems (biggestSpace - 4, widthToUse, heightToUse);
layoutMenuItems (biggestSpace - 4, maxMenuHeight, widthToUse, heightToUse);

tendTowardsRight = (mon.getRight() - target.getRight()) >= (target.getX() - mon.getX());
}
@@ -70559,11 +70564,10 @@ private:
&& owner->windowPos.intersects (windowPos.expanded (-4, -4));
}

void layoutMenuItems (const int maxMenuW, int& width, int& height)
void layoutMenuItems (const int maxMenuW, const int maxMenuH, int& width, int& height)
{
numColumns = 0;
contentHeight = 0;
const int maxMenuH = getParentHeight() - 24;
int totalW;

do
@@ -71539,13 +71543,12 @@ class DragImageComponent : public Component,
{
public:
DragImageComponent (const Image& im,
const String& desc,
const var& desc,
Component* const sourceComponent,
Component* const mouseDragSource_,
DragAndDropContainer* const o,
const Point<int>& imageOffset_,
ReferenceCountedObject* const customDataObject)
: sourceDetails (desc, sourceComponent, Point<int>(), customDataObject),
const Point<int>& imageOffset_)
: sourceDetails (desc, sourceComponent, Point<int>()),
image (im),
mouseDragSource (mouseDragSource_),
owner (o),
@@ -71809,12 +71812,11 @@ DragAndDropContainer::~DragAndDropContainer()
dragImageComponent = nullptr;
}

void DragAndDropContainer::startDragging (const String& sourceDescription,
void DragAndDropContainer::startDragging (const var& sourceDescription,
Component* sourceComponent,
const Image& dragImage_,
const bool allowDraggingToExternalWindows,
const Point<int>* imageOffsetFromMouse,
ReferenceCountedObject* customDataObject)
const Point<int>* imageOffsetFromMouse)
{
Image dragImage (dragImage_);

@@ -71883,8 +71885,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
}

dragImageComponent = new DragImageComponent (dragImage, sourceDescription, sourceComponent,
draggingSource->getComponentUnderMouse(), this,
imageOffset, customDataObject);
draggingSource->getComponentUnderMouse(), this, imageOffset);

currentDragDesc = sourceDescription;

@@ -71934,12 +71935,10 @@ bool DragAndDropContainer::shouldDropFilesWhenDraggedExternally (const DragAndDr
return false;
}

DragAndDropTarget::SourceDetails::SourceDetails (const String& description_, Component* sourceComponent_,
const Point<int>& localPosition_, ReferenceCountedObject* const customDataObject_) noexcept
DragAndDropTarget::SourceDetails::SourceDetails (const var& description_, Component* sourceComponent_, const Point<int>& localPosition_) noexcept
: description (description_),
sourceComponent (sourceComponent_),
localPosition (localPosition_),
customDataObject (customDataObject_)
localPosition (localPosition_)
{
}



+ 40
- 51
juce_amalgamated.h View File

@@ -73,7 +73,7 @@ namespace JuceDummyNamespace {}
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 74
#define JUCE_BUILDNUMBER 75

/** Current Juce version number.

@@ -8724,6 +8724,7 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const NewLine&);
/*** End of inlined file: juce_OutputStream.h ***/

#ifndef DOXYGEN
class ReferenceCountedObject;
class DynamicObject;
#endif

@@ -8731,8 +8732,8 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const NewLine&);
A variant class, that can be used to hold a range of primitive values.

A var object can hold a range of simple primitive values, strings, or
a reference-counted pointer to a DynamicObject. The var class is intended
to act like the values used in dynamic scripting languages.
any kind of ReferenceCountedObject. The var class is intended to act like
the kind of values used in dynamic scripting languages.

@see DynamicObject
*/
@@ -8760,7 +8761,7 @@ public:
var (const char* value);
var (const wchar_t* value);
var (const String& value);
var (DynamicObject* object);
var (ReferenceCountedObject* object);
var (MethodFunction method) noexcept;

var& operator= (const var& valueToCopy);
@@ -8771,19 +8772,20 @@ public:
var& operator= (const char* value);
var& operator= (const wchar_t* value);
var& operator= (const String& value);
var& operator= (DynamicObject* object);
var& operator= (ReferenceCountedObject* object);
var& operator= (MethodFunction method);

void swapWith (var& other) noexcept;

operator int() const;
operator int64() const;
operator bool() const;
operator float() const;
operator double() const;
operator int() const noexcept;
operator int64() const noexcept;
operator bool() const noexcept;
operator float() const noexcept;
operator double() const noexcept;
operator const String() const;
const String toString() const;
DynamicObject* getObject() const;
ReferenceCountedObject* getObject() const noexcept;
DynamicObject* getDynamicObject() const noexcept;

bool isVoid() const noexcept;
bool isInt() const noexcept;
@@ -8864,7 +8866,7 @@ private:
bool boolValue;
double doubleValue;
String* stringValue;
DynamicObject* objectValue;
ReferenceCountedObject* objectValue;
MethodFunction methodValue;
};

@@ -8874,8 +8876,10 @@ private:

bool operator== (const var& v1, const var& v2) noexcept;
bool operator!= (const var& v1, const var& v2) noexcept;
bool operator== (const var& v1, const String& v2) noexcept;
bool operator!= (const var& v1, const String& v2) noexcept;
bool operator== (const var& v1, const String& v2);
bool operator!= (const var& v1, const String& v2);
bool operator== (const var& v1, const char* v2);
bool operator!= (const var& v1, const char* v2);

#endif // __JUCE_VARIANT_JUCEHEADER__
/*** End of inlined file: juce_Variant.h ***/
@@ -46472,14 +46476,14 @@ public:

/** To allow rows from your list to be dragged-and-dropped, implement this method.

If this returns a non-empty name then when the user drags a row, the listbox will
If this returns a non-null variant then when the user drags a row, the listbox will
try to find a DragAndDropContainer in its parent hierarchy, and will use it to trigger
a drag-and-drop operation, using this string as the source description, with the listbox
itself as the source component.

@see DragAndDropContainer::startDragging
*/
virtual const String getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
virtual const var getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);

/** You can override this to provide tool tips for specific rows.
@see TooltipClient
@@ -46880,7 +46884,7 @@ public:
/** @internal */
void colourChanged();
/** @internal */
void startDragAndDrop (const MouseEvent& e, const String& dragDescription);
void startDragAndDrop (const MouseEvent& e, const var& dragDescription);

private:

@@ -50626,11 +50630,10 @@ public:
{
public:
/** Creates a SourceDetails object from its various settings. */
SourceDetails (const String& description, Component* sourceComponent,
const Point<int>& localPosition, ReferenceCountedObject* customDataObject = nullptr) noexcept;
SourceDetails (const var& description, Component* sourceComponent, const Point<int>& localPosition) noexcept;

/** A descriptor string - this is set DragAndDropContainer::startDragging(). */
String description;
/** A descriptor for the drag - this is set DragAndDropContainer::startDragging(). */
var description;

/** The component from the drag operation was started. */
WeakReference<Component> sourceComponent;
@@ -50639,12 +50642,6 @@ public:
Note that for calls such as isInterestedInDragSource(), this may be a null position.
*/
Point<int> localPosition;

/** A pointer to a user-supplied object which contains some kind of data which is relevant to
the specific classes which are being used. Make sure that you check the type of this object,
and safely dynamic_cast it to your required type.
*/
ReferenceCountedObjectPtr<ReferenceCountedObject> customDataObject;
};

/** Callback to check whether this target is interested in the type of object being
@@ -50768,8 +50765,8 @@ public:
findParentDragContainerFor() is a handy method to call to find the
drag container to use for a component.

@param sourceDescription a string to use as the description of the thing being dragged - this
will be passed to the objects that might be dropped-onto so they can
@param sourceDescription a string or value to use as the description of the thing being dragged -
this will be passed to the objects that might be dropped-onto so they can
decide whether they want to handle it
@param sourceComponent the component that is being dragged
@param dragImage the image to drag around underneath the mouse. If this is a null image,
@@ -50781,16 +50778,12 @@ public:
at which the image should be drawn from the mouse. If it isn't
specified, then the image will be centred around the mouse. If
an image hasn't been passed-in, this will be ignored.
@param customDataObject Any kind of reference-counted object which you want to have passed to
the target component. A pointer to this object will be made available
to the targets in the DragAndDropTarget::SourceDetails class.
*/
void startDragging (const String& sourceDescription,
void startDragging (const var& sourceDescription,
Component* sourceComponent,
const Image& dragImage = Image::null,
bool allowDraggingToOtherJuceWindows = false,
const Point<int>* imageOffsetFromMouse = nullptr,
ReferenceCountedObject* customDataObject = nullptr);
const Point<int>* imageOffsetFromMouse = nullptr);

/** Returns true if something is currently being dragged. */
bool isDragAndDropActive() const;
@@ -50856,17 +50849,14 @@ protected:
and if you want it to then perform a file drag-and-drop, add the filenames you want
to the array passed in, and return true.

@param dragSourceDescription the description passed into the startDrag() call when the drag began
@param dragSourceComponent the component passed into the startDrag() call when the drag began
@param files on return, the filenames you want to drag
@param canMoveFiles on return, true if it's ok for the receiver to move the files; false if
it must make a copy of them (see the performExternalDragDropOfFiles()
method)
@param sourceDetails information about the source of the drag operation
@param files on return, the filenames you want to drag
@param canMoveFiles on return, true if it's ok for the receiver to move the files; false if
it must make a copy of them (see the performExternalDragDropOfFiles() method)
@see performExternalDragDropOfFiles
*/
virtual bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
StringArray& files,
bool& canMoveFiles);
StringArray& files, bool& canMoveFiles);

private:

@@ -53674,14 +53664,14 @@ public:

/** To allow rows from your table to be dragged-and-dropped, implement this method.

If this returns a non-empty name then when the user drags a row, the table will try to
If this returns a non-null variant then when the user drags a row, the table will try to
find a DragAndDropContainer in its parent hierarchy, and will use it to trigger a
drag-and-drop operation, using this string as the source description, and the listbox
itself as the source component.

@see DragAndDropContainer::startDragging
@see getDragSourceCustomData, DragAndDropContainer::startDragging
*/
virtual const String getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
virtual const var getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
};

/**
@@ -54367,7 +54357,7 @@ public:

/** To allow items from your treeview to be dragged-and-dropped, implement this method.

If this returns a non-empty name then when the user drags an item, the treeview will
If this returns a non-null variant then when the user drags an item, the treeview will
try to find a DragAndDropContainer in its parent hierarchy, and will use it to trigger
a drag-and-drop operation, using this string as the source description, with the treeview
itself as the source component.
@@ -54380,7 +54370,7 @@ public:

@see DragAndDropContainer::startDragging
*/
virtual const String getDragSourceDescription();
virtual const var getDragSourceDescription();

/** If you want your item to be able to have files drag-and-dropped onto it, implement this
method and return true.
@@ -59232,7 +59222,7 @@ public:
virtual void menuItemSelected (int menuItemID,
int topLevelMenuIndex) = 0;

#if JUCE_MAC || DOXYGEN
#if JUCE_MAC || DOXYGEN
/** MAC ONLY - Sets the model that is currently being shown as the main
menu bar at the top of the screen on the Mac.

@@ -59254,8 +59244,7 @@ public:
the main menu bar.
*/
static MenuBarModel* getMacMainMenu();

#endif
#endif

/** @internal */
void applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo& info);


+ 71
- 67
src/containers/juce_Variant.cpp View File

@@ -45,15 +45,15 @@ enum VariantStreamMarkers
class var::VariantType
{
public:
VariantType() {}
virtual ~VariantType() {}
VariantType() noexcept {}
virtual ~VariantType() noexcept {}
virtual int toInt (const ValueUnion&) const { return 0; }
virtual int64 toInt64 (const ValueUnion&) const { return 0; }
virtual double toDouble (const ValueUnion&) const { return 0; }
virtual const String toString (const ValueUnion&) const { return String::empty; }
virtual bool toBool (const ValueUnion&) const { return false; }
virtual DynamicObject* toObject (const ValueUnion&) const { return nullptr; }
virtual int toInt (const ValueUnion&) const noexcept { return 0; }
virtual int64 toInt64 (const ValueUnion&) const noexcept { return 0; }
virtual double toDouble (const ValueUnion&) const noexcept { return 0; }
virtual const String toString (const ValueUnion&) const { return String::empty; }
virtual bool toBool (const ValueUnion&) const noexcept { return false; }
virtual ReferenceCountedObject* toObject (const ValueUnion&) const noexcept { return nullptr; }
virtual bool isVoid() const noexcept { return false; }
virtual bool isInt() const noexcept { return false; }
@@ -74,7 +74,7 @@ public:
class var::VariantType_Void : public var::VariantType
{
public:
VariantType_Void() {}
VariantType_Void() noexcept {}
static const VariantType_Void instance;
bool isVoid() const noexcept { return true; }
@@ -86,14 +86,14 @@ public:
class var::VariantType_Int : public var::VariantType
{
public:
VariantType_Int() {}
VariantType_Int() noexcept {}
static const VariantType_Int instance;
int toInt (const ValueUnion& data) const { return data.intValue; };
int64 toInt64 (const ValueUnion& data) const { return (int64) data.intValue; };
double toDouble (const ValueUnion& data) const { return (double) data.intValue; }
int toInt (const ValueUnion& data) const noexcept { return data.intValue; };
int64 toInt64 (const ValueUnion& data) const noexcept { return (int64) data.intValue; };
double toDouble (const ValueUnion& data) const noexcept { return (double) data.intValue; }
const String toString (const ValueUnion& data) const { return String (data.intValue); }
bool toBool (const ValueUnion& data) const { return data.intValue != 0; }
bool toBool (const ValueUnion& data) const noexcept { return data.intValue != 0; }
bool isInt() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -113,14 +113,14 @@ public:
class var::VariantType_Int64 : public var::VariantType
{
public:
VariantType_Int64() {}
VariantType_Int64() noexcept {}
static const VariantType_Int64 instance;
int toInt (const ValueUnion& data) const { return (int) data.int64Value; };
int64 toInt64 (const ValueUnion& data) const { return data.int64Value; };
double toDouble (const ValueUnion& data) const { return (double) data.int64Value; }
int toInt (const ValueUnion& data) const noexcept { return (int) data.int64Value; };
int64 toInt64 (const ValueUnion& data) const noexcept { return data.int64Value; };
double toDouble (const ValueUnion& data) const noexcept { return (double) data.int64Value; }
const String toString (const ValueUnion& data) const { return String (data.int64Value); }
bool toBool (const ValueUnion& data) const { return data.int64Value != 0; }
bool toBool (const ValueUnion& data) const noexcept { return data.int64Value != 0; }
bool isInt64() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -140,14 +140,14 @@ public:
class var::VariantType_Double : public var::VariantType
{
public:
VariantType_Double() {}
VariantType_Double() noexcept {}
static const VariantType_Double instance;
int toInt (const ValueUnion& data) const { return (int) data.doubleValue; };
int64 toInt64 (const ValueUnion& data) const { return (int64) data.doubleValue; };
double toDouble (const ValueUnion& data) const { return data.doubleValue; }
int toInt (const ValueUnion& data) const noexcept { return (int) data.doubleValue; };
int64 toInt64 (const ValueUnion& data) const noexcept { return (int64) data.doubleValue; };
double toDouble (const ValueUnion& data) const noexcept { return data.doubleValue; }
const String toString (const ValueUnion& data) const { return String (data.doubleValue); }
bool toBool (const ValueUnion& data) const { return data.doubleValue != 0; }
bool toBool (const ValueUnion& data) const noexcept { return data.doubleValue != 0; }
bool isDouble() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -167,14 +167,14 @@ public:
class var::VariantType_Bool : public var::VariantType
{
public:
VariantType_Bool() {}
VariantType_Bool() noexcept {}
static const VariantType_Bool instance;
int toInt (const ValueUnion& data) const { return data.boolValue ? 1 : 0; };
int64 toInt64 (const ValueUnion& data) const { return data.boolValue ? 1 : 0; };
double toDouble (const ValueUnion& data) const { return data.boolValue ? 1.0 : 0.0; }
int toInt (const ValueUnion& data) const noexcept { return data.boolValue ? 1 : 0; };
int64 toInt64 (const ValueUnion& data) const noexcept { return data.boolValue ? 1 : 0; };
double toDouble (const ValueUnion& data) const noexcept { return data.boolValue ? 1.0 : 0.0; }
const String toString (const ValueUnion& data) const { return String::charToString (data.boolValue ? '1' : '0'); }
bool toBool (const ValueUnion& data) const { return data.boolValue; }
bool toBool (const ValueUnion& data) const noexcept { return data.boolValue; }
bool isBool() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -193,17 +193,17 @@ public:
class var::VariantType_String : public var::VariantType
{
public:
VariantType_String() {}
VariantType_String() noexcept {}
static const VariantType_String instance;
void cleanUp (ValueUnion& data) const noexcept { delete data.stringValue; }
void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest.stringValue = new String (*source.stringValue); }
int toInt (const ValueUnion& data) const { return data.stringValue->getIntValue(); };
int64 toInt64 (const ValueUnion& data) const { return data.stringValue->getLargeIntValue(); };
double toDouble (const ValueUnion& data) const { return data.stringValue->getDoubleValue(); }
int toInt (const ValueUnion& data) const noexcept { return data.stringValue->getIntValue(); };
int64 toInt64 (const ValueUnion& data) const noexcept { return data.stringValue->getLargeIntValue(); };
double toDouble (const ValueUnion& data) const noexcept { return data.stringValue->getDoubleValue(); }
const String toString (const ValueUnion& data) const { return *data.stringValue; }
bool toBool (const ValueUnion& data) const { return data.stringValue->getIntValue() != 0
bool toBool (const ValueUnion& data) const noexcept { return data.stringValue->getIntValue() != 0
|| data.stringValue->trim().equalsIgnoreCase ("true")
|| data.stringValue->trim().equalsIgnoreCase ("yes"); }
bool isString() const noexcept { return true; }
@@ -228,16 +228,16 @@ public:
class var::VariantType_Object : public var::VariantType
{
public:
VariantType_Object() {}
VariantType_Object() noexcept {}
static const VariantType_Object instance;
void cleanUp (ValueUnion& data) const noexcept { if (data.objectValue != nullptr) data.objectValue->decReferenceCount(); }
void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest.objectValue = source.objectValue; if (dest.objectValue != nullptr) dest.objectValue->incReferenceCount(); }
void cleanUp (ValueUnion& data) const noexcept { if (data.objectValue != nullptr) data.objectValue->decReferenceCount(); }
void createCopy (ValueUnion& dest, const ValueUnion& source) const { dest.objectValue = source.objectValue; if (dest.objectValue != nullptr) dest.objectValue->incReferenceCount(); }
const String toString (const ValueUnion& data) const { return "Object 0x" + String::toHexString ((int) (pointer_sized_int) data.objectValue); }
bool toBool (const ValueUnion& data) const { return data.objectValue != 0; }
DynamicObject* toObject (const ValueUnion& data) const { return data.objectValue; }
bool isObject() const noexcept { return true; }
const String toString (const ValueUnion& data) const { return "Object 0x" + String::toHexString ((int) (pointer_sized_int) data.objectValue); }
bool toBool (const ValueUnion& data) const noexcept { return data.objectValue != 0; }
ReferenceCountedObject* toObject (const ValueUnion& data) const noexcept { return data.objectValue; }
bool isObject() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
{
@@ -255,11 +255,11 @@ public:
class var::VariantType_Method : public var::VariantType
{
public:
VariantType_Method() {}
VariantType_Method() noexcept {}
static const VariantType_Method instance;
const String toString (const ValueUnion&) const { return "Method"; }
bool toBool (const ValueUnion& data) const { return data.methodValue != 0; }
bool toBool (const ValueUnion& data) const noexcept { return data.methodValue != 0; }
bool isMethod() const noexcept { return true; }
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
@@ -338,7 +338,7 @@ var::var (const wchar_t* const value_) : type (&VariantType_String::instance)
value.stringValue = new String (value_);
}
var::var (DynamicObject* const object) : type (&VariantType_Object::instance)
var::var (ReferenceCountedObject* const object) : type (&VariantType_Object::instance)
{
value.objectValue = object;
@@ -361,14 +361,15 @@ bool var::isString() const noexcept { return type->isString(); }
bool var::isObject() const noexcept { return type->isObject(); }
bool var::isMethod() const noexcept { return type->isMethod(); }
var::operator int() const { return type->toInt (value); }
var::operator int64() const { return type->toInt64 (value); }
var::operator bool() const { return type->toBool (value); }
var::operator float() const { return (float) type->toDouble (value); }
var::operator double() const { return type->toDouble (value); }
const String var::toString() const { return type->toString (value); }
var::operator const String() const { return type->toString (value); }
DynamicObject* var::getObject() const { return type->toObject (value); }
var::operator int() const noexcept { return type->toInt (value); }
var::operator int64() const noexcept { return type->toInt64 (value); }
var::operator bool() const noexcept { return type->toBool (value); }
var::operator float() const noexcept { return (float) type->toDouble (value); }
var::operator double() const noexcept { return type->toDouble (value); }
const String var::toString() const { return type->toString (value); }
var::operator const String() const { return type->toString (value); }
ReferenceCountedObject* var::getObject() const noexcept { return type->toObject (value); }
DynamicObject* var::getDynamicObject() const noexcept { return dynamic_cast <DynamicObject*> (getObject()); }
//==============================================================================
void var::swapWith (var& other) noexcept
@@ -377,16 +378,16 @@ void var::swapWith (var& other) noexcept
std::swap (value, other.value);
}
var& var::operator= (const var& newValue) { type->cleanUp (value); type = newValue.type; type->createCopy (value, newValue.value); return *this; }
var& var::operator= (int newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (int64 newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (bool newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (double newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const char* newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const wchar_t* newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const String& newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (DynamicObject* newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (MethodFunction newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const var& newValue) { type->cleanUp (value); type = newValue.type; type->createCopy (value, newValue.value); return *this; }
var& var::operator= (const int newValue) { type->cleanUp (value); type = &VariantType_Int::instance; value.intValue = newValue; return *this; }
var& var::operator= (const int64 newValue) { type->cleanUp (value); type = &VariantType_Int64::instance; value.int64Value = newValue; return *this; }
var& var::operator= (const bool newValue) { type->cleanUp (value); type = &VariantType_Bool::instance; value.boolValue = newValue; return *this; }
var& var::operator= (const double newValue) { type->cleanUp (value); type = &VariantType_Double::instance; value.doubleValue = newValue; return *this; }
var& var::operator= (const char* const newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const wchar_t* const newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (const String& newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (ReferenceCountedObject* newValue) { var v (newValue); swapWith (v); return *this; }
var& var::operator= (MethodFunction newValue) { var v (newValue); swapWith (v); return *this; }
//==============================================================================
bool var::equals (const var& other) const noexcept
@@ -401,8 +402,11 @@ bool var::equalsWithSameType (const var& other) const noexcept
bool operator== (const var& v1, const var& v2) noexcept { return v1.equals (v2); }
bool operator!= (const var& v1, const var& v2) noexcept { return ! v1.equals (v2); }
bool operator== (const var& v1, const String& v2) noexcept { return v1.toString() == v2; }
bool operator!= (const var& v1, const String& v2) noexcept { return v1.toString() != v2; }
bool operator== (const var& v1, const String& v2) { return v1.toString() == v2; }
bool operator!= (const var& v1, const String& v2) { return v1.toString() != v2; }
bool operator== (const var& v1, const char* const v2) { return v1.toString() == v2; }
bool operator!= (const var& v1, const char* const v2) { return v1.toString() != v2; }
//==============================================================================
void var::writeToStream (OutputStream& output) const
@@ -439,13 +443,13 @@ const var var::readFromStream (InputStream& input)
const var var::operator[] (const Identifier& propertyName) const
{
DynamicObject* const o = getObject();
DynamicObject* const o = getDynamicObject();
return o != nullptr ? o->getProperty (propertyName) : var::null;
}
const var var::invoke (const Identifier& method, const var* arguments, int numArguments) const
{
DynamicObject* const o = getObject();
DynamicObject* const o = getDynamicObject();
return o != nullptr ? o->invokeMethod (method, arguments, numArguments) : var::null;
}
@@ -453,7 +457,7 @@ const var var::invoke (const var& targetObject, const var* arguments, int numArg
{
if (isMethod())
{
DynamicObject* const target = targetObject.getObject();
DynamicObject* const target = targetObject.getDynamicObject();
if (target != nullptr)
return (target->*(value.methodValue)) (arguments, numArguments);


+ 17
- 13
src/containers/juce_Variant.h View File

@@ -31,6 +31,7 @@
#include "../io/streams/juce_InputStream.h"
#ifndef DOXYGEN
class ReferenceCountedObject;
class DynamicObject;
#endif
@@ -39,8 +40,8 @@
A variant class, that can be used to hold a range of primitive values.
A var object can hold a range of simple primitive values, strings, or
a reference-counted pointer to a DynamicObject. The var class is intended
to act like the values used in dynamic scripting languages.
any kind of ReferenceCountedObject. The var class is intended to act like
the kind of values used in dynamic scripting languages.
@see DynamicObject
*/
@@ -69,7 +70,7 @@ public:
var (const char* value);
var (const wchar_t* value);
var (const String& value);
var (DynamicObject* object);
var (ReferenceCountedObject* object);
var (MethodFunction method) noexcept;
var& operator= (const var& valueToCopy);
@@ -80,19 +81,20 @@ public:
var& operator= (const char* value);
var& operator= (const wchar_t* value);
var& operator= (const String& value);
var& operator= (DynamicObject* object);
var& operator= (ReferenceCountedObject* object);
var& operator= (MethodFunction method);
void swapWith (var& other) noexcept;
operator int() const;
operator int64() const;
operator bool() const;
operator float() const;
operator double() const;
operator int() const noexcept;
operator int64() const noexcept;
operator bool() const noexcept;
operator float() const noexcept;
operator double() const noexcept;
operator const String() const;
const String toString() const;
DynamicObject* getObject() const;
ReferenceCountedObject* getObject() const noexcept;
DynamicObject* getDynamicObject() const noexcept;
bool isVoid() const noexcept;
bool isInt() const noexcept;
@@ -178,7 +180,7 @@ private:
bool boolValue;
double doubleValue;
String* stringValue;
DynamicObject* objectValue;
ReferenceCountedObject* objectValue;
MethodFunction methodValue;
};
@@ -188,8 +190,10 @@ private:
bool operator== (const var& v1, const var& v2) noexcept;
bool operator!= (const var& v1, const var& v2) noexcept;
bool operator== (const var& v1, const String& v2) noexcept;
bool operator!= (const var& v1, const String& v2) noexcept;
bool operator== (const var& v1, const String& v2);
bool operator!= (const var& v1, const String& v2);
bool operator== (const var& v1, const char* v2);
bool operator!= (const var& v1, const char* v2);
#endif // __JUCE_VARIANT_JUCEHEADER__

+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 74
#define JUCE_BUILDNUMBER 75
/** Current Juce version number.


+ 5
- 5
src/gui/components/controls/juce_ListBox.cpp View File

@@ -117,9 +117,9 @@ public:
if (selectedRows.size() > 0)
{
const String dragDescription (owner.getModel()->getDragSourceDescription (selectedRows));
const var dragDescription (owner.getModel()->getDragSourceDescription (selectedRows));
if (dragDescription.isNotEmpty())
if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty())))
{
isDragging = true;
owner.startDragAndDrop (e, dragDescription);
@@ -915,7 +915,7 @@ const Image ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
return snapshot;
}
void ListBox::startDragAndDrop (const MouseEvent& e, const String& dragDescription)
void ListBox::startDragAndDrop (const MouseEvent& e, const var& dragDescription)
{
DragAndDropContainer* const dragContainer
= DragAndDropContainer::findParentDragContainerFor (this);
@@ -952,8 +952,8 @@ void ListBoxModel::selectedRowsChanged (int) {}
void ListBoxModel::deleteKeyPressed (int) {}
void ListBoxModel::returnKeyPressed (int) {}
void ListBoxModel::listWasScrolled() {}
const String ListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return String::empty; }
const String ListBoxModel::getTooltipForRow (int) { return String::empty; }
const var ListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var::null; }
const String ListBoxModel::getTooltipForRow (int) { return String::empty; }
END_JUCE_NAMESPACE

+ 3
- 3
src/gui/components/controls/juce_ListBox.h View File

@@ -139,14 +139,14 @@ public:
/** To allow rows from your list to be dragged-and-dropped, implement this method.
If this returns a non-empty name then when the user drags a row, the listbox will
If this returns a non-null variant then when the user drags a row, the listbox will
try to find a DragAndDropContainer in its parent hierarchy, and will use it to trigger
a drag-and-drop operation, using this string as the source description, with the listbox
itself as the source component.
@see DragAndDropContainer::startDragging
*/
virtual const String getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
virtual const var getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
/** You can override this to provide tool tips for specific rows.
@see TooltipClient
@@ -560,7 +560,7 @@ public:
/** @internal */
void colourChanged();
/** @internal */
void startDragAndDrop (const MouseEvent& e, const String& dragDescription);
void startDragAndDrop (const MouseEvent& e, const var& dragDescription);
private:
//==============================================================================


+ 3
- 3
src/gui/components/controls/juce_TableListBox.cpp View File

@@ -168,9 +168,9 @@ public:
if (selectedRows.size() > 0)
{
const String dragDescription (owner.getModel()->getDragSourceDescription (selectedRows));
const var dragDescription (owner.getModel()->getDragSourceDescription (selectedRows));
if (dragDescription.isNotEmpty())
if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty())))
{
isDragging = true;
owner.startDragAndDrop (e, dragDescription);
@@ -490,7 +490,7 @@ void TableListBoxModel::returnKeyPressed (int) {}
void TableListBoxModel::listWasScrolled() {}
const String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; }
const String TableListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return String::empty; }
const var TableListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var::null; }
Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component* existingComponentToUpdate)
{


+ 3
- 3
src/gui/components/controls/juce_TableListBox.h View File

@@ -176,14 +176,14 @@ public:
/** To allow rows from your table to be dragged-and-dropped, implement this method.
If this returns a non-empty name then when the user drags a row, the table will try to
If this returns a non-null variant then when the user drags a row, the table will try to
find a DragAndDropContainer in its parent hierarchy, and will use it to trigger a
drag-and-drop operation, using this string as the source description, and the listbox
itself as the source component.
@see DragAndDropContainer::startDragging
@see getDragSourceCustomData, DragAndDropContainer::startDragging
*/
virtual const String getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
virtual const var getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
};


+ 4
- 4
src/gui/components/controls/juce_TreeView.cpp View File

@@ -124,9 +124,9 @@ public:
if (item != nullptr && e.getMouseDownX() >= pos.getX())
{
const String dragDescription (item->getDragSourceDescription());
const var dragDescription (item->getDragSourceDescription());
if (dragDescription.isNotEmpty())
if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty())))
{
DragAndDropContainer* const dragContainer
= DragAndDropContainer::findParentDragContainerFor (this);
@@ -1291,9 +1291,9 @@ const String TreeViewItem::getTooltip()
return String::empty;
}
const String TreeViewItem::getDragSourceDescription()
const var TreeViewItem::getDragSourceDescription()
{
return String::empty;
return var::null;
}
bool TreeViewItem::isInterestedInFileDrag (const StringArray&)


+ 2
- 2
src/gui/components/controls/juce_TreeView.h View File

@@ -340,7 +340,7 @@ public:
//==============================================================================
/** To allow items from your treeview to be dragged-and-dropped, implement this method.
If this returns a non-empty name then when the user drags an item, the treeview will
If this returns a non-null variant then when the user drags an item, the treeview will
try to find a DragAndDropContainer in its parent hierarchy, and will use it to trigger
a drag-and-drop operation, using this string as the source description, with the treeview
itself as the source component.
@@ -353,7 +353,7 @@ public:
@see DragAndDropContainer::startDragging
*/
virtual const String getDragSourceDescription();
virtual const var getDragSourceDescription();
/** If you want your item to be able to have files drag-and-dropped onto it, implement this
method and return true.


+ 1
- 1
src/gui/components/filebrowser/juce_FileTreeComponent.cpp View File

@@ -86,7 +86,7 @@ public:
const String getUniqueName() const { return file.getFullPathName(); }
int getItemHeight() const { return 22; }
const String getDragSourceDescription() { return owner.getDragAndDropDescription(); }
const var getDragSourceDescription() { return owner.getDragAndDropDescription(); }
void itemOpennessChanged (bool isNowOpen)
{


+ 2
- 3
src/gui/components/menus/juce_MenuBarModel.h View File

@@ -132,7 +132,7 @@ public:
int topLevelMenuIndex) = 0;
//==============================================================================
#if JUCE_MAC || DOXYGEN
#if JUCE_MAC || DOXYGEN
/** MAC ONLY - Sets the model that is currently being shown as the main
menu bar at the top of the screen on the Mac.
@@ -154,8 +154,7 @@ public:
the main menu bar.
*/
static MenuBarModel* getMacMainMenu();
#endif
#endif
//==============================================================================
/** @internal */


+ 9
- 8
src/gui/components/menus/juce_PopupMenu.cpp View File

@@ -731,14 +731,16 @@ private:
{
const Rectangle<int> mon (Desktop::getInstance()
.getMonitorAreaContaining (target.getCentre(),
#if JUCE_MAC
#if JUCE_MAC
true));
#else
#else
false)); // on windows, don't stop the menu overlapping the taskbar
#endif
#endif
const int maxMenuHeight = mon.getHeight() - 24;
int x, y, widthToUse, heightToUse;
layoutMenuItems (mon.getWidth() - 24, widthToUse, heightToUse);
layoutMenuItems (mon.getWidth() - 24, maxMenuHeight, widthToUse, heightToUse);
if (alignToRectangle)
{
@@ -779,10 +781,10 @@ private:
if (biggestSpace < widthToUse)
{
layoutMenuItems (biggestSpace + target.getWidth() / 3, widthToUse, heightToUse);
layoutMenuItems (biggestSpace + target.getWidth() / 3, maxMenuHeight, widthToUse, heightToUse);
if (numColumns > 1)
layoutMenuItems (biggestSpace - 4, widthToUse, heightToUse);
layoutMenuItems (biggestSpace - 4, maxMenuHeight, widthToUse, heightToUse);
tendTowardsRight = (mon.getRight() - target.getRight()) >= (target.getX() - mon.getX());
}
@@ -807,11 +809,10 @@ private:
&& owner->windowPos.intersects (windowPos.expanded (-4, -4));
}
void layoutMenuItems (const int maxMenuW, int& width, int& height)
void layoutMenuItems (const int maxMenuW, const int maxMenuH, int& width, int& height)
{
numColumns = 0;
contentHeight = 0;
const int maxMenuH = getParentHeight() - 24;
int totalW;
do


+ 8
- 13
src/gui/components/mouse/juce_DragAndDropContainer.cpp View File

@@ -47,13 +47,12 @@ class DragImageComponent : public Component,
{
public:
DragImageComponent (const Image& im,
const String& desc,
const var& desc,
Component* const sourceComponent,
Component* const mouseDragSource_,
DragAndDropContainer* const o,
const Point<int>& imageOffset_,
ReferenceCountedObject* const customDataObject)
: sourceDetails (desc, sourceComponent, Point<int>(), customDataObject),
const Point<int>& imageOffset_)
: sourceDetails (desc, sourceComponent, Point<int>()),
image (im),
mouseDragSource (mouseDragSource_),
owner (o),
@@ -319,12 +318,11 @@ DragAndDropContainer::~DragAndDropContainer()
dragImageComponent = nullptr;
}
void DragAndDropContainer::startDragging (const String& sourceDescription,
void DragAndDropContainer::startDragging (const var& sourceDescription,
Component* sourceComponent,
const Image& dragImage_,
const bool allowDraggingToExternalWindows,
const Point<int>* imageOffsetFromMouse,
ReferenceCountedObject* customDataObject)
const Point<int>* imageOffsetFromMouse)
{
Image dragImage (dragImage_);
@@ -393,8 +391,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
}
dragImageComponent = new DragImageComponent (dragImage, sourceDescription, sourceComponent,
draggingSource->getComponentUnderMouse(), this,
imageOffset, customDataObject);
draggingSource->getComponentUnderMouse(), this, imageOffset);
currentDragDesc = sourceDescription;
@@ -445,12 +442,10 @@ bool DragAndDropContainer::shouldDropFilesWhenDraggedExternally (const DragAndDr
}
//==============================================================================
DragAndDropTarget::SourceDetails::SourceDetails (const String& description_, Component* sourceComponent_,
const Point<int>& localPosition_, ReferenceCountedObject* const customDataObject_) noexcept
DragAndDropTarget::SourceDetails::SourceDetails (const var& description_, Component* sourceComponent_, const Point<int>& localPosition_) noexcept
: description (description_),
sourceComponent (sourceComponent_),
localPosition (localPosition_),
customDataObject (customDataObject_)
localPosition (localPosition_)
{
}


+ 9
- 16
src/gui/components/mouse/juce_DragAndDropContainer.h View File

@@ -73,8 +73,8 @@ public:
findParentDragContainerFor() is a handy method to call to find the
drag container to use for a component.
@param sourceDescription a string to use as the description of the thing being dragged - this
will be passed to the objects that might be dropped-onto so they can
@param sourceDescription a string or value to use as the description of the thing being dragged -
this will be passed to the objects that might be dropped-onto so they can
decide whether they want to handle it
@param sourceComponent the component that is being dragged
@param dragImage the image to drag around underneath the mouse. If this is a null image,
@@ -86,16 +86,12 @@ public:
at which the image should be drawn from the mouse. If it isn't
specified, then the image will be centred around the mouse. If
an image hasn't been passed-in, this will be ignored.
@param customDataObject Any kind of reference-counted object which you want to have passed to
the target component. A pointer to this object will be made available
to the targets in the DragAndDropTarget::SourceDetails class.
*/
void startDragging (const String& sourceDescription,
void startDragging (const var& sourceDescription,
Component* sourceComponent,
const Image& dragImage = Image::null,
bool allowDraggingToOtherJuceWindows = false,
const Point<int>* imageOffsetFromMouse = nullptr,
ReferenceCountedObject* customDataObject = nullptr);
const Point<int>* imageOffsetFromMouse = nullptr);
/** Returns true if something is currently being dragged. */
bool isDragAndDropActive() const;
@@ -163,17 +159,14 @@ protected:
and if you want it to then perform a file drag-and-drop, add the filenames you want
to the array passed in, and return true.
@param dragSourceDescription the description passed into the startDrag() call when the drag began
@param dragSourceComponent the component passed into the startDrag() call when the drag began
@param files on return, the filenames you want to drag
@param canMoveFiles on return, true if it's ok for the receiver to move the files; false if
it must make a copy of them (see the performExternalDragDropOfFiles()
method)
@param sourceDetails information about the source of the drag operation
@param files on return, the filenames you want to drag
@param canMoveFiles on return, true if it's ok for the receiver to move the files; false if
it must make a copy of them (see the performExternalDragDropOfFiles() method)
@see performExternalDragDropOfFiles
*/
virtual bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
StringArray& files,
bool& canMoveFiles);
StringArray& files, bool& canMoveFiles);
private:
//==============================================================================


+ 3
- 10
src/gui/components/mouse/juce_DragAndDropTarget.h View File

@@ -57,11 +57,10 @@ public:
{
public:
/** Creates a SourceDetails object from its various settings. */
SourceDetails (const String& description, Component* sourceComponent,
const Point<int>& localPosition, ReferenceCountedObject* customDataObject = nullptr) noexcept;
SourceDetails (const var& description, Component* sourceComponent, const Point<int>& localPosition) noexcept;
/** A descriptor string - this is set DragAndDropContainer::startDragging(). */
String description;
/** A descriptor for the drag - this is set DragAndDropContainer::startDragging(). */
var description;
/** The component from the drag operation was started. */
WeakReference<Component> sourceComponent;
@@ -70,12 +69,6 @@ public:
Note that for calls such as isInterestedInDragSource(), this may be a null position.
*/
Point<int> localPosition;
/** A pointer to a user-supplied object which contains some kind of data which is relevant to
the specific classes which are being used. Make sure that you check the type of this object,
and safely dynamic_cast it to your required type.
*/
ReferenceCountedObjectPtr<ReferenceCountedObject> customDataObject;
};
//==============================================================================


Loading…
Cancel
Save