Esempio n. 1
0
bool MyMusicTreeModel::SetValue( const wxVariant &variant,
                                 const wxDataViewItem &item, unsigned int col )
{
    wxASSERT(item.IsOk());

    MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) item.GetID();
    switch (col)
    {
        case 0:
            node->m_title = variant.GetString();
            return true;
        case 1:
            node->m_artist = variant.GetString();
            return true;
        case 2:
            node->m_year = variant.GetLong();
            return true;
        case 3:
            node->m_quality = variant.GetString();
            return true;

        default:
            wxLogError( "MyMusicTreeModel::SetValue: wrong column" );
    }
    return false;
}
Esempio n. 2
0
bool wxPGVariantToDouble( const wxVariant& variant, double* pResult )
{
    if ( variant.IsNull() )
        return false;

    wxString variantType = variant.GetType();

    if ( variantType == wxPG_VARIANT_TYPE_DOUBLE )
    {
        *pResult = variant.GetDouble();
        return true;
    }

    if ( variantType == wxPG_VARIANT_TYPE_LONG )
    {
        *pResult = (double)variant.GetLong();
        return true;
    }

    if ( variantType == wxLongLong_VariantType )
    {
        wxLongLong ll;
        ll << variant;
        *pResult = ll.ToDouble();
        return true;
    }

    if ( variantType == wxPG_VARIANT_TYPE_STRING )
        if ( variant.GetString().ToDouble(pResult) )
            return true;

    return false;
}
Esempio n. 3
0
long wxPGVariantToInt( const wxVariant& variant, long defVal )
{
    if ( variant.IsNull() )
        return defVal;

    if ( variant.GetType() == wxS("long") )
        return variant.GetLong();

    if ( variant.GetType() == wxS("bool") )
        return variant.GetBool() ? 1 : 0;

    if ( variant.GetType() == wxS("wxLongLong") )
    {
        wxLongLong ll;
        ll << variant;
        if ( ll >= LONG_MAX )
            return LONG_MAX;
        else if ( ll <= LONG_MIN )
            return LONG_MIN;
        return ll.ToLong();
    }

    long l = defVal;

    if ( variant.GetType() == wxPG_VARIANT_TYPE_STRING )
        variant.GetString().ToLong(&l, 0);

    return l;
}
Esempio n. 4
0
bool CTimeBarListModel::SetValueByRow( const wxVariant &variant, unsigned int row, unsigned int col )
{
    if (row < m_textColValues.GetCount())
    {
        switch ( col )
        {
        case Col_EditableText:
            m_textColValues[row] = variant.GetString();
            break;

        case Col_Visible:
            m_view[row] = variant.GetChar();
            break;

        case Col_Lock:
            m_lock[row] = variant.GetChar();
            break;

        case Col_Max:
        default:
            wxFAIL_MSG( _T("invalid column") );
            break;
        }
    }
    return false;
}
Esempio n. 5
0
bool MyListModel::SetValueByRow( const wxVariant &variant,
                                 unsigned int row, unsigned int col )
{
    switch ( col )
    {
        case Col_EditableText:
        case Col_IconText:
            if (row >= m_textColValues.GetCount())
            {
                // the item is not in the range of the items
                // which we store... for simplicity, don't allow editing it
                wxLogError( "Cannot edit rows with an index greater than %d",
                            m_textColValues.GetCount() );
                return false;
            }

            if ( col == Col_EditableText )
            {
                m_textColValues[row] = variant.GetString();
            }
            else // col == Col_IconText
            {
                wxDataViewIconText iconText;
                iconText << variant;
                m_iconColValues[row] = iconText.GetText();
            }
            return true;

        case Col_Date:
        case Col_TextWithAttr:
            wxLogError("Cannot edit the column %d", col);
            break;

        case Col_Custom:
            m_customColValues[row] = variant.GetString();
            break;

        case Col_Max:
            wxFAIL_MSG( "invalid column" );
    }

    return false;
}
Esempio n. 6
0
    virtual wxSize GetSize() const
    {
        int xx, yy;
        wxBitmap bmp(1, 1);
        wxMemoryDC dc;
        dc.SelectObject(bmp);

        wxString s = m_value.GetString();
        wxFont f = m_font;
        dc.GetTextExtent(s, &xx, &yy, NULL, NULL, &f);
        return wxSize(xx, yy);
    }
Esempio n. 7
0
    virtual wxSize GetSize() const {
        int xx, yy;
        wxBitmap bmp(1, 1);
        wxMemoryDC dc;
        dc.SelectObject(bmp);

        wxString s = m_value.GetString();
        wxFont f = m_font;
        dc.GetTextExtent(s, &xx, &yy, NULL, NULL, &f);

        // Adjust the height to fit the bitmap height at least
        yy < m_errorBmp.GetHeight() ? yy = m_errorBmp.GetHeight() : yy = yy;
        return wxSize(xx, yy);
    }
Esempio n. 8
0
bool FileProperty::DoSetAttribute( const wxString& name, wxVariant& value )
{
    // Return false on some occasions to make sure those attribs will get
    // stored in m_attributes.
    if ( name == wxPG_FILE_WILDCARD )
    {
        wildcard = value.GetString();
    }
    else if ( name == wxPG_FILE_SHOW_RELATIVE_PATH )
    {
        basePath = value.GetString();
    }
    else if ( name == wxPG_FILE_INITIAL_PATH )
    {
        initialPath = value.GetString();
        return true;
    }
    else if ( name == wxPG_FILE_DIALOG_TITLE )
    {
        dialogTitle = value.GetString();
        return true;
    }
    return false;
}
Esempio n. 9
0
wxVariant luProjectProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
{
	luProjectProps obj;
	obj << thisValue;
	switch ( childIndex )
	{
	case PROP_PROJECT_NAME:
		{ 
			obj.projName = childValue.GetString(); 
			luMainFrame* frame = getLuMainFrame(); GK_ASSERT(frame);			
			frame->setProjectName(obj.projName);
			break; 
		}
	}
	return thisValue << obj;
}
Esempio n. 10
0
wxVariant  luObjectProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
{
	luGameObjProps obj;
	obj << thisValue;
	switch ( childIndex )
	{
	case PROP_NAME:	{ obj.name = childValue.GetString(); break; }
	//case PROP_TYPE:	{ obj.type = childValue.GetString(); break; }
	case PROP_POS:	{ obj.pos = gkVector3RefFromVariant(childValue); break; }
	case PROP_SCALE:	{ obj.scale = gkVector3RefFromVariant(childValue); break; }
	case PROP_FRONT:	{ obj.front = gkVector3RefFromVariant(childValue); break; }
	case PROP_UP:	{ obj.up = gkVector3RefFromVariant(childValue); break; }
	case PROP_DIM:	{ obj.dim = gkVector3RefFromVariant(childValue); break; }
	case PROP_FLAGS:	{ obj.flags = childValue.GetInteger(); break; }
	case PROP_STATE:	{ obj.state = childValue.GetInteger(); break; }
	}
	return thisValue << obj;
}
Esempio n. 11
0
int wxGISGPGxObjectDomain::GetPosByValue(const wxVariant &oVal) const
{
    if(!oVal.IsNull())
    {
		wxFileName oName(oVal.GetString());
        for(size_t i = 0; i < m_asoData.size(); ++i)
        {
            wxGxObjectFilter* poFilter = GetFilter(i);
            if(poFilter)
            {
                if( oName.GetExt().IsSameAs(poFilter->GetExt(), false) || poFilter->GetExt().IsEmpty() )
                {
                    return i;
                }
            }
        }
    }
	return wxNOT_FOUND;
}
	bool SetValue(wxVariant const& variant, unsigned int col) override {
		if (col == 0) {
			wxArrayString toks = wxSplit(variant.GetString(), '-');
			std::vector<std::string> keys;
			keys.reserve(toks.size());
			transform(toks.begin(), toks.end(), back_inserter(keys), (std::string(*)(wxString const&))&from_wx);
			combo = Combo(combo.Context(), combo.CmdName(), keys);
			cmd_str = to_wx(combo.Str());
			return true;
		}
		else if (col == 1) {
			wxDataViewIconText text;
			text << variant;
			combo = Combo(combo.Context(), from_wx(text.GetText()), combo.Get());
			cmd_name = text.GetText();
			return true;
		}
		return false;
	}
	bool SetValue(wxVariant const& variant, unsigned int col) {
		if (col == 0) {
			wxArrayString toks = wxSplit(variant.GetString(), '-');
			std::vector<std::string> keys;
			keys.resize(toks.size());
			for (size_t i = 0; i < toks.size(); ++i)
				keys[i] = STD_STR(toks[i]);
			combo = Combo(combo.Context(), combo.CmdName(), keys);
			cmd_str = combo.Str();
			return true;
		}
		else if (col == 1) {
			wxDataViewIconText text;
			text << variant;
			combo = Combo(combo.Context(), STD_STR(text.GetText()), combo.Get());
			cmd_name = text.GetText();
			return true;
		}
		return false;
	}
Esempio n. 14
0
/**
 * Set the value of a particular item in the model
 */
bool BOM_TABLE_MODEL::SetValue( const wxVariant& aVariant, const wxDataViewItem& aItem,
                                unsigned int aFieldId )
{
    if( !aItem.IsOk() || !m_widget )
    {
        return false;
    }

    // Extract the value to be set
    if( aVariant.GetType().Cmp( "string" ) == 0 )
    {
        wxString value = aVariant.GetString();

        bool result = false;

        wxDataViewItemArray selectedItems;
        m_widget->GetSelections( selectedItems );

        // Set the row value for all selected rows

        for( auto item : selectedItems )
        {
            auto selectedRow = static_cast<BOM_TABLE_ROW*>( item.GetID() );

            if( selectedRow )
            {
                result |= selectedRow->SetFieldValue( aFieldId, value, true );
            }
        }

        if( m_widget )
        {
            m_widget->Update();
        }

        return result;
    }

    // Default
    return false;
}
Esempio n. 15
0
WXDLLEXPORT bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
{
    VariantInit(&oleVariant);
    if (variant.IsNull())
    {
        oleVariant.vt = VT_NULL;
        return true;
    }

    wxString type(variant.GetType());

    if (type == wxT("errorcode"))
    {
        wxVariantDataErrorCode* const
            ec = wxStaticCastVariantData(variant.GetData(),
                                         wxVariantDataErrorCode);
        oleVariant.vt = VT_ERROR;
        oleVariant.scode = ec->GetValue();
    }
    else if (type == wxT("currency"))
    {
        wxVariantDataCurrency* const
            c = wxStaticCastVariantData(variant.GetData(),
                                        wxVariantDataCurrency);
        oleVariant.vt = VT_CY;
        oleVariant.cyVal = c->GetValue();
    }
    else if (type == wxT("safearray"))
    {
        wxVariantDataSafeArray* const
            vsa = wxStaticCastVariantData(variant.GetData(),
                                          wxVariantDataSafeArray);
        SAFEARRAY* psa = vsa->GetValue();
        VARTYPE vt;

        wxCHECK(psa, false);
        HRESULT hr = SafeArrayGetVartype(psa, &vt);
        if ( FAILED(hr) )
        {
            wxLogApiError(wxS("SafeArrayGetVartype()"), hr);
            SafeArrayDestroy(psa);
            return false;
        }
        oleVariant.vt = vt | VT_ARRAY;
        oleVariant.parray = psa;
    }
    else if (type == wxT("long"))
    {
        oleVariant.vt = VT_I4;
        oleVariant.lVal = variant.GetLong() ;
    }
#if wxUSE_LONGLONG
    else if (type == wxT("longlong"))
    {
        oleVariant.vt = VT_I8;
        oleVariant.llVal = variant.GetLongLong().GetValue();
    }
#endif
    else if (type == wxT("char"))
    {
        oleVariant.vt=VT_I1;            // Signed Char
        oleVariant.cVal=variant.GetChar();
    }
    else if (type == wxT("double"))
    {
        oleVariant.vt = VT_R8;
        oleVariant.dblVal = variant.GetDouble();
    }
    else if (type == wxT("bool"))
    {
        oleVariant.vt = VT_BOOL;
        oleVariant.boolVal = variant.GetBool() ? VARIANT_TRUE : VARIANT_FALSE;
    }
    else if (type == wxT("string"))
    {
        wxString str( variant.GetString() );
        oleVariant.vt = VT_BSTR;
        oleVariant.bstrVal = wxConvertStringToOle(str);
    }
#if wxUSE_DATETIME
    else if (type == wxT("datetime"))
    {
        wxDateTime date( variant.GetDateTime() );
        oleVariant.vt = VT_DATE;

        SYSTEMTIME st;
        date.GetAsMSWSysTime(&st);

        SystemTimeToVariantTime(&st, &oleVariant.date);
    }
#endif
    else if (type == wxT("void*"))
    {
        oleVariant.vt = VT_DISPATCH;
        oleVariant.pdispVal = (IDispatch*) variant.GetVoidPtr();
    }
    else if (type == wxT("list"))
    {
        wxSafeArray<VT_VARIANT> safeArray;
        if (!safeArray.CreateFromListVariant(variant))
            return false;

        oleVariant.vt = VT_VARIANT | VT_ARRAY;
        oleVariant.parray = safeArray.Detach();
    }
    else if (type == wxT("arrstring"))
    {
        wxSafeArray<VT_BSTR> safeArray;

        if (!safeArray.CreateFromArrayString(variant.GetArrayString()))
            return false;

        oleVariant.vt = VT_BSTR | VT_ARRAY;
        oleVariant.parray = safeArray.Detach();
    }
    else
    {
        oleVariant.vt = VT_NULL;
        return false;
    }
    return true;
}
Esempio n. 16
0
WXDLLEXPORT bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
{
    VariantInit(&oleVariant);
    if (variant.IsNull())
    {
        oleVariant.vt = VT_NULL;
        return true;
    }

    wxString type(variant.GetType());

    if (type == wxT("errorcode"))
    {
        wxVariantDataErrorCode* const
            ec = wxStaticCastVariantData(variant.GetData(),
                                         wxVariantDataErrorCode);
        oleVariant.vt = VT_ERROR;
        oleVariant.scode = ec->GetValue();
    }
    else if (type == wxT("currency"))
    {
        wxVariantDataCurrency* const
            c = wxStaticCastVariantData(variant.GetData(),
                                        wxVariantDataCurrency);
        oleVariant.vt = VT_CY;
        oleVariant.cyVal = c->GetValue();
    }
    else if (type == wxT("safearray"))
    {
        wxVariantDataSafeArray* const
            vsa = wxStaticCastVariantData(variant.GetData(),
                                          wxVariantDataSafeArray);
        SAFEARRAY* psa = vsa->GetValue();
        VARTYPE vt;

        wxCHECK(psa, false);
        HRESULT hr = SafeArrayGetVartype(psa, &vt);
        if ( FAILED(hr) )
        {
            wxLogApiError(wxS("SafeArrayGetVartype()"), hr);
            SafeArrayDestroy(psa);
            return false;
        }
        oleVariant.vt = vt | VT_ARRAY;
        oleVariant.parray = psa;
    }
    else if (type == wxT("long"))
    {
        oleVariant.vt = VT_I4;
        oleVariant.lVal = variant.GetLong() ;
    }
    // Original VC6 came with SDK too old to contain VARIANT::llVal declaration
    // and there doesn't seem to be any way to test for it as Microsoft simply
    // added it to the later version of oaidl.h without changing anything else.
    // So assume it's not present for VC6, even though it might be if an
    // updated SDK is used. In this case the user would need to disable this
    // check himself.
#if wxUSE_LONGLONG && !defined(__VISUALC6__)
    else if (type == wxT("longlong"))
    {
        oleVariant.vt = VT_I8;
        oleVariant.llVal = variant.GetLongLong().GetValue();
    }
#endif
    else if (type == wxT("char"))
    {
        oleVariant.vt=VT_I1;            // Signed Char
        oleVariant.cVal=variant.GetChar();
    }
    else if (type == wxT("double"))
    {
        oleVariant.vt = VT_R8;
        oleVariant.dblVal = variant.GetDouble();
    }
    else if (type == wxT("bool"))
    {
        oleVariant.vt = VT_BOOL;
        oleVariant.boolVal = variant.GetBool() ? VARIANT_TRUE : VARIANT_FALSE;
    }
    else if (type == wxT("string"))
    {
        wxString str( variant.GetString() );
        oleVariant.vt = VT_BSTR;
        oleVariant.bstrVal = wxConvertStringToOle(str);
    }
#if wxUSE_DATETIME
    else if (type == wxT("datetime"))
    {
        wxDateTime date( variant.GetDateTime() );
        oleVariant.vt = VT_DATE;

        SYSTEMTIME st;
        date.GetAsMSWSysTime(&st);

        SystemTimeToVariantTime(&st, &oleVariant.date);
    }
#endif
    else if (type == wxT("void*"))
    {
        oleVariant.vt = VT_DISPATCH;
        oleVariant.pdispVal = (IDispatch*) variant.GetVoidPtr();
    }
    else if (type == wxT("list"))
    {
        wxSafeArray<VT_VARIANT> safeArray;
        if (!safeArray.CreateFromListVariant(variant))
            return false;

        oleVariant.vt = VT_VARIANT | VT_ARRAY;
        oleVariant.parray = safeArray.Detach();
    }
    else if (type == wxT("arrstring"))
    {
        wxSafeArray<VT_BSTR> safeArray;

        if (!safeArray.CreateFromArrayString(variant.GetArrayString()))
            return false;

        oleVariant.vt = VT_BSTR | VT_ARRAY;
        oleVariant.parray = safeArray.Detach();
    }
    else
    {
        oleVariant.vt = VT_NULL;
        return false;
    }
    return true;
}
Esempio n. 17
0
// -----------------------------------------------------------------------
wxString WxGUIFontProperty::ValueToString( wxVariant& value, int argFlags ) const
{
	wxString s = value.GetString();
	return s;
}
Esempio n. 18
0
 virtual bool SetValue( const wxVariant &value )
 {
     m_value = value.GetString();
     return true;
 }
Esempio n. 19
0
WXDLLEXPORT bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
{
    VariantInit(&oleVariant);
    if (variant.IsNull())
    {
        oleVariant.vt = VT_NULL;
        return true;
    }

    wxString type(variant.GetType());


    if (type == wxT("long"))
    {
        oleVariant.vt = VT_I4;
        oleVariant.lVal = variant.GetLong() ;
    }
    else if (type == wxT("char"))
    {
        oleVariant.vt=VT_I1;            // Signed Char
        oleVariant.cVal=variant.GetChar();
    }
    else if (type == wxT("double"))
    {
        oleVariant.vt = VT_R8;
        oleVariant.dblVal = variant.GetDouble();
    }
    else if (type == wxT("bool"))
    {
        oleVariant.vt = VT_BOOL;
        oleVariant.boolVal = variant.GetBool();
    }
    else if (type == wxT("string"))
    {
        wxString str( variant.GetString() );
        oleVariant.vt = VT_BSTR;
        oleVariant.bstrVal = wxConvertStringToOle(str);
    }
#if wxUSE_DATETIME
    else if (type == wxT("datetime"))
    {
        wxDateTime date( variant.GetDateTime() );
        oleVariant.vt = VT_DATE;

        SYSTEMTIME st;
        date.GetAsMSWSysTime(&st);

        SystemTimeToVariantTime(&st, &oleVariant.date);
    }
#endif
    else if (type == wxT("void*"))
    {
        oleVariant.vt = VT_DISPATCH;
        oleVariant.pdispVal = (IDispatch*) variant.GetVoidPtr();
    }
    else if (type == wxT("list") || type == wxT("stringlist"))
    {
        oleVariant.vt = VT_VARIANT | VT_ARRAY;

        SAFEARRAY *psa;
        SAFEARRAYBOUND saBound;
        VARIANTARG *pvargBase;
        VARIANTARG *pvarg;
        int i, j;

        int iCount = variant.GetCount();

        saBound.lLbound = 0;
        saBound.cElements = iCount;

        psa = SafeArrayCreate(VT_VARIANT, 1, &saBound);
        if (psa == NULL)
            return false;

        SafeArrayAccessData(psa, (void**)&pvargBase);

        pvarg = pvargBase;
        for (i = 0; i < iCount; i++)
        {
            // copy each string in the list of strings
            wxVariant eachVariant(variant[i]);
            if (!wxConvertVariantToOle(eachVariant, * pvarg))
            {
                // memory failure:  back out and free strings alloc'ed up to
                // now, and then the array itself.
                pvarg = pvargBase;
                for (j = 0; j < i; j++)
                {
                    SysFreeString(pvarg->bstrVal);
                    pvarg++;
                }
                SafeArrayDestroy(psa);
                return false;
            }
            pvarg++;
        }

        SafeArrayUnaccessData(psa);

        oleVariant.parray = psa;
    }
    else
    {
        oleVariant.vt = VT_NULL;
        return false;
    }
    return true;
}
Esempio n. 20
0
//#define PRINT_RAW_IN_FEILD
bool PMBUSCMDListModel::SetValueByRow(const wxVariant &variant, unsigned int row, unsigned int col)
{

	wxDataViewIconText iconText;

	switch (col)
	{
	case Col_Toggle:
		PSU_DEBUG_PRINT(MSG_DETAIL, "%d", variant.GetBool());
		this->m_available[row] = variant.GetBool();
		this->m_pmBusCommand[row].m_toggle = this->m_available[row];
		return true;

	case Col_RegisterIconText:
		if (row >= m_registerColValues.GetCount())
		{
			// the item is not in the range of the items
			// which we store... for simplicity, don't allow editing it
			wxLogError("Cannot edit rows with an index greater than %d",
				m_registerColValues.GetCount());
			return false;
		}

		iconText << variant;
		m_registerColValues[row] = iconText.GetText();

		return true;

		break;

	case Col_NameText:
		if (row >= m_nameColValues.GetCount())
		{
			// the item is not in the range of the items
			// which we store... for simplicity, don't allow editing it
			wxLogError("Cannot edit rows with an index greater than %d",
				m_nameColValues.GetCount());
			return false;
		}

		m_nameColValues[row] = variant.GetString();
		
		return true;

		break;

	case Col_AccessText:

		break;

	case Col_QueryText:

		m_queryColValues[row] = variant.GetString();

		break;

	case Col_CoefficientsText:

		m_coefficientsColValues[row] = variant.GetString();

		break;

	case Col_CookText:

		m_cookColValues[row] = variant.GetString();

		break;

	case Col_RawText:
#ifdef PRINT_RAW_IN_FEILD
		PSU_DEBUG_PRINT(MSG_DETAIL, "");
		PSU_DEBUG_PRINT(MSG_DETAIL, "row = %d, length = %d ", row, this->m_pmBusCommand[row].m_recvBuff.m_length);
		m_rawColValues[row].clear();
		for (unsigned int idx = 0; idx < this->m_pmBusCommand[row].m_recvBuff.m_length; idx++){
			m_rawColValues[row] += wxString::Format(" %02x ", this->m_pmBusCommand[row].m_recvBuff.m_recvBuff[idx]);
		}
		PSU_DEBUG_PRINT(MSG_DETAIL, "call %s , %s", m_rawColValues[row].c_str());
#else
		m_rawColValues[row] = variant.GetString();
#endif

		return true;

		break;

	case Col_Date:
	case Col_TextWithAttr:
		wxLogError("Cannot edit the column %d", col);
		break;

	case Col_Custom:
		m_customColValues[row] = variant.GetString();
		break;

	case Col_Max:
		wxFAIL_MSG("invalid column");
	}

	return false;
}
Esempio n. 21
0
WXDLLEXPORT bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
{
    VariantInit(&oleVariant);
    if (variant.IsNull())
    {
        oleVariant.vt = VT_NULL;
        return true;
    }

    wxString type(variant.GetType());


    if (type == wxT("long"))
    {
        oleVariant.vt = VT_I4;
        oleVariant.lVal = variant.GetLong() ;
    }
    // Original VC6 came with SDK too old to contain VARIANT::llVal declaration
    // and there doesn't seem to be any way to test for it as Microsoft simply
    // added it to the later version of oaidl.h without changing anything else.
    // So assume it's not present for VC6, even though it might be if an
    // updated SDK is used. In this case the user would need to disable this
    // check himself.
#if wxUSE_LONGLONG && !defined(__VISUALC6__)
    else if (type == wxT("longlong"))
    {
        oleVariant.vt = VT_I8;
        oleVariant.llVal = variant.GetLongLong().GetValue();
    }
#endif
    else if (type == wxT("char"))
    {
        oleVariant.vt=VT_I1;            // Signed Char
        oleVariant.cVal=variant.GetChar();
    }
    else if (type == wxT("double"))
    {
        oleVariant.vt = VT_R8;
        oleVariant.dblVal = variant.GetDouble();
    }
    else if (type == wxT("bool"))
    {
        oleVariant.vt = VT_BOOL;
        oleVariant.boolVal = variant.GetBool() ? VARIANT_TRUE : VARIANT_FALSE;
    }
    else if (type == wxT("string"))
    {
        wxString str( variant.GetString() );
        oleVariant.vt = VT_BSTR;
        oleVariant.bstrVal = wxConvertStringToOle(str);
    }
#if wxUSE_DATETIME
    else if (type == wxT("datetime"))
    {
        wxDateTime date( variant.GetDateTime() );
        oleVariant.vt = VT_DATE;

        SYSTEMTIME st;
        date.GetAsMSWSysTime(&st);

        SystemTimeToVariantTime(&st, &oleVariant.date);
    }
#endif
    else if (type == wxT("void*"))
    {
        oleVariant.vt = VT_DISPATCH;
        oleVariant.pdispVal = (IDispatch*) variant.GetVoidPtr();
    }
    else if (type == wxT("list"))
    {
        wxSafeArrayHelper sah;

        if (!sah.Create(VT_VARIANT, variant.GetCount()))
            return false;

        for (size_t i = 0; i < variant.GetCount(); i++)
        {
            if (!sah.SetElement(i, variant[i]))
                return false;
        }

        oleVariant.vt = VT_VARIANT | VT_ARRAY;
        oleVariant.parray = sah.Detach();
    }
    else if (type == wxT("arrstring"))
    {
        wxArrayString strings(variant.GetArrayString());
        wxSafeArrayHelper sah;

        if (!sah.Create(VT_BSTR, strings.GetCount()))
            return false;

        for (size_t i = 0; i < strings.GetCount(); i++)
        {
            if (!sah.SetElement(i, strings[i]))
                return false;
        }

        oleVariant.vt = VT_BSTR | VT_ARRAY;
        oleVariant.parray = sah.Detach();
    }
    else
    {
        oleVariant.vt = VT_NULL;
        return false;
    }
    return true;
}
Esempio n. 22
0
bool DirProperty::ValidateValue(wxVariant& value,
		wxPGValidationInfo& validationinfo) const {
	const wxString dir = value.GetString();
	namespace fs = boost::filesystem;
	return fs::exists(fs::path(dir.ToStdString()));
}