本文整理汇总了C++中wxVariant::GetBool方法的典型用法代码示例。如果您正苦于以下问题:C++ wxVariant::GetBool方法的具体用法?C++ wxVariant::GetBool怎么用?C++ wxVariant::GetBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxVariant
的用法示例。
在下文中一共展示了wxVariant::GetBool方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxPGVariantToInt
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;
}
示例2: if
//------------------------------------------------------------------------
// variant <= wxVariant
//------------------------------------------------------------------------
_variant_t memmonitor::wxVariant2Variant(const wxVariant &wxVar)
{
_variant_t var;
const wxString type = wxVar.GetType();
if (type == "bool")
{
var = _variant_t(wxVar.GetBool());
}
else if (type == "char")
{
var = _variant_t((char)wxVar);
}
else if (type == "datetime")
{
}
else if (type == "double")
{
var = _variant_t(wxVar.GetDouble());
}
else if (type == "list")
{
}
else if (type == "long")
{
var = _variant_t(wxVar.GetLong());
}
else if (type == "longlong")
{
}
else if (type == "string")
{
}
else if (type == "ulonglong")
{
}
else if (type == "arrstring")
{
}
else if (type == "void*")
{
}
return var;
}
示例3: SetValue
bool vvStampsModel::SetValue(
const wxVariant& cValue,
const wxDataViewItem& cItem,
unsigned int uColumn
)
{
wxASSERT(cItem.IsOk());
DataItem* pItem = this->ConvertDataItem(cItem);
bool bChanged = false;
switch (static_cast<Column>(uColumn))
{
case COLUMN_B_CHECKED:
pItem->bChecked = cValue.GetBool();
bChanged = true;
break;
case COLUMN_BS_NAME:
case COLUMN_S_NAME:
case COLUMN_U_COUNT:
wxLogError("Cannot set values in StampsModel column: %u", uColumn);
bChanged = false;
break;
default:
wxLogError("Unknown StampsModel column: %u", uColumn);
bChanged = false;
break;
}
if (bChanged)
{
this->ItemChanged(cItem);
}
return bChanged;
}
示例4: wxConvertVariantToOle
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))
//.........这里部分代码省略.........
示例5: wxConvertVariantToOle
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;
//.........这里部分代码省略.........
示例6: wxConvertVariantToOle
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;
//.........这里部分代码省略.........
示例7: wxConvertVariantToOle
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();
//.........这里部分代码省略.........
示例8: SetValueByRow
//#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;
//.........这里部分代码省略.........