Applied patch [ 546335 ] Added Automation types and array access

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15929 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2002-06-23 14:10:32 +00:00
parent c0b8a8b9cc
commit 24f4ad9592
2 changed files with 72 additions and 1 deletions

View File

@@ -55,6 +55,7 @@ public:
// Invoke a member function
wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]);
wxVariant CallMethodArray(const wxString& method, int noArgs, const wxVariant **args);
// Convenience function
wxVariant CallMethod(const wxString& method,
@@ -64,11 +65,13 @@ public:
// Get/Put property
wxVariant GetProperty(const wxString& property, int noArgs = 0, wxVariant args[] = (wxVariant*) NULL) const;
wxVariant GetPropertyArray(const wxString& property, int noArgs, const wxVariant **args) const;
wxVariant GetProperty(const wxString& property,
const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant,
const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
bool wxAutomationObject::PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args);
bool PutProperty(const wxString& property, int noArgs, wxVariant args[]) ;
bool PutProperty(const wxString& property,
const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant,
@@ -80,10 +83,12 @@ public:
// on the pointer, though this could be implicit by constructing an wxAutomationObject
// with it and letting the destructor call Release.
WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, wxVariant args[]) const;
WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const;
// A way of initialising another wxAutomationObject with a dispatch object,
// without having to deal with nasty IDispatch pointers.
bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs = 0, wxVariant args[] = (wxVariant*) NULL) const;
bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const;
public:
WXIDISPATCH* m_dispatchPtr;

View File

@@ -267,6 +267,16 @@ wxVariant wxAutomationObject::CallMethod(const wxString& member, int noArgs, wxV
return retVariant;
}
wxVariant wxAutomationObject::CallMethodArray(const wxString& member, int noArgs, const wxVariant **args)
{
wxVariant retVariant;
if (!Invoke(member, DISPATCH_METHOD, retVariant, noArgs, NULL, args))
{
retVariant.MakeNull();
}
return retVariant;
}
wxVariant wxAutomationObject::CallMethod(const wxString& member,
const wxVariant& arg1, const wxVariant& arg2,
const wxVariant& arg3, const wxVariant& arg4,
@@ -314,6 +324,15 @@ wxVariant wxAutomationObject::CallMethod(const wxString& member,
}
// Get/Set property
wxVariant wxAutomationObject::GetPropertyArray(const wxString& property, int noArgs, const wxVariant **args) const
{
wxVariant retVariant;
if (!Invoke(property, DISPATCH_PROPERTYGET, retVariant, noArgs, NULL, args))
{
retVariant.MakeNull();
}
return retVariant;
}
wxVariant wxAutomationObject::GetProperty(const wxString& property, int noArgs, wxVariant args[]) const
{
wxVariant retVariant;
@@ -380,6 +399,16 @@ bool wxAutomationObject::PutProperty(const wxString& property, int noArgs, wxVar
return TRUE;
}
bool wxAutomationObject::PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args)
{
wxVariant retVariant;
if (!Invoke(property, DISPATCH_PROPERTYPUT, retVariant, noArgs, NULL, args))
{
return FALSE;
}
return TRUE;
}
bool wxAutomationObject::PutProperty(const wxString& property,
const wxVariant& arg1, const wxVariant& arg2,
const wxVariant& arg3, const wxVariant& arg4,
@@ -442,6 +471,25 @@ WXIDISPATCH* wxAutomationObject::GetDispatchProperty(const wxString& property, i
return (WXIDISPATCH*) NULL;
}
// Uses DISPATCH_PROPERTYGET
// and returns a dispatch pointer. The calling code should call Release
// on the pointer, though this could be implicit by constructing an wxAutomationObject
// with it and letting the destructor call Release.
WXIDISPATCH* wxAutomationObject::GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const
{
wxVariant retVariant;
if (Invoke(property, DISPATCH_PROPERTYGET, retVariant, noArgs, NULL, args))
{
if (retVariant.GetType() == wxT("void*"))
{
return (WXIDISPATCH*) retVariant.GetVoidPtr();
}
}
return (WXIDISPATCH*) NULL;
}
// A way of initialising another wxAutomationObject with a dispatch object
bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, wxVariant args[]) const
{
@@ -455,6 +503,19 @@ bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& prop
return FALSE;
}
// A way of initialising another wxAutomationObject with a dispatch object
bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const
{
WXIDISPATCH* dispatch = GetDispatchProperty(property, noArgs, args);
if (dispatch)
{
obj.SetDispatchPtr(dispatch);
return TRUE;
}
else
return FALSE;
}
// Get a dispatch pointer from the current object associated
// with a class id
bool wxAutomationObject::GetInstance(const wxString& classId) const
@@ -527,7 +588,12 @@ bool ConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
wxString type(variant.GetType());
if (type == wxT("long"))
if (type == wxT("char"))
{
oleVariant.vt=VT_I1; // Signed Char
oleVariant.cVal=variant.GetChar();
}
else if (type == wxT("long"))
{
oleVariant.vt = VT_I4;
oleVariant.lVal = variant.GetLong() ;