本文整理汇总了C++中wxVariant类的典型用法代码示例。如果您正苦于以下问题:C++ wxVariant类的具体用法?C++ wxVariant怎么用?C++ wxVariant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了wxVariant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxPGVariantToDouble
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;
}
示例2: return
bool wxVariant::operator== (const wxVariant& variant) const
{
if (IsNull() || variant.IsNull())
return (IsNull() == variant.IsNull());
return (GetData()->Eq(* variant.GetData()));
}
示例3: SetValueByRow
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;
}
示例4: SetValue
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;
}
示例5: GetValueString
std::string ScalarSelectionDialog::GetValueString(const wxVariant& variant, std::type_index type, int precision)
{
std::string result;
if (!variant.IsNull()) {
if (IsFloat(type)) {
std::stringstream strstream;
if (precision > 0) {
strstream << std::setprecision(precision) << std::fixed << variant.GetDouble();
}
else {
strstream << std::fixed << variant.GetDouble();
}
auto tmpStr = strstream.str();
size_t last_not_zero = tmpStr.find_last_not_of('0');
result = tmpStr.substr(0, last_not_zero == std::string::npos ? last_not_zero : last_not_zero+1);
}
else if (IsIntegral(type)) {
result = std::to_string(variant.GetInteger());
}
}
return result;
}
示例6: LogVariant
void LogVariant(const wxString& prefix, const wxVariant& v)
{
const wxString type = v.GetType();
wxString info;
const wxString& name = v.GetName();
if (type == wxS("arrstring")) {
wxArrayString as = v.GetArrayString();
info.Printf(wxS("%svariant type: \"%s\", element count: %zu, name: \"%s\"."),
prefix, type, as.size(), name);
wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
for (size_t i = 0; i < as.size(); i++)
{
info.Printf(wxS(" string #%zu value: \"%s\""), i, as[i]);
if ( i == LogVariantMaxItemsInList )
{
wxLogTrace(wxTRACE_AutoExcel, wxS("And %zu more strings"), as.size() - i);
break;
}
else
wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
}
return;
}
if (type == wxS("list")) {
info.Printf(wxS("%sVariant type: \"%s\", element count: %zu, name: \"%s\"."),
prefix, type, v.GetCount(), name);
wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
for (size_t i = 0; i < v.GetCount(); i++)
{
if ( i == LogVariantMaxItemsInList )
{
wxLogTrace(wxTRACE_AutoExcel, wxS("And %zu more variants"), v.GetCount() - i);
break;
} else
{
const wxVariant& vTmp = v[i];
info.Printf(wxS(" variant #%zu type: \"%s\", value: \"%s\", name: \"%s\"."),
i, vTmp.GetType(), vTmp.MakeString(), vTmp.GetName());
wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
}
}
return;
}
if (type == wxS("void*") && v.GetVoidPtr() != NULL) {
wxString automationName;
wxExcelObject object;
IDispatch* dispatch = (IDispatch*)v.GetVoidPtr();
dispatch->AddRef();
object.GetAutomationObject_()->SetDispatchPtr(dispatch);
info.Printf(wxS("%svariant type: \"IDispatch - %s\", value: \"%s\", name: \"%s\"."),
prefix, object.GetAutomationObjectName_(false), v.MakeString(), name);
} else {
info.Printf(wxS("%svariant type: \"%s\", value: \"%s\", name: \"%s\"."),
prefix, type, v.MakeString(), name);
}
wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
}
示例7: PointRefFromVariant
wxVariant wxPointProperty::ChildChanged(wxVariant& thisValue, int childIndex, wxVariant& childValue) const
{
Point& point = PointRefFromVariant(thisValue);
switch ( childIndex )
{
case 0: point.X = childValue.GetInteger(); break;
case 1: point.Y = childValue.GetInteger(); break;
}
wxVariant newVariant;
newVariant << point;
return newVariant;
}
示例8: SizeRefFromVariant
wxVariant wxSizeProperty::ChildChanged(wxVariant& thisValue, int childIndex, wxVariant& childValue) const
{
Size& size = SizeRefFromVariant(thisValue);
switch ( childIndex )
{
case 0: size.Width = childValue.GetInteger(); break;
case 1: size.Height = childValue.GetInteger(); break;
}
wxVariant newVariant;
newVariant << size;
return newVariant;
}
示例9:
wxVariant luVector3Property::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
{
gkVector3 v;
v << thisValue;
switch ( childIndex )
{
case 0: v.x = childValue.GetDouble(); break;
case 1: v.y = childValue.GetDouble(); break;
case 2: v.z = childValue.GetDouble(); break;
}
return thisValue << v;
}
示例10: RangeRefFromVariant
wxVariant wxRangeProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
{
Range& range = RangeRefFromVariant(thisValue);
switch ( childIndex )
{
case 0: range.Min = childValue.GetDouble(); break;
case 1: range.Max = childValue.GetDouble(); break;
}
wxVariant newVariant;
newVariant << range;
return newVariant;
}
示例11: Vector2RefFromVariant
wxVariant wxVector2Property::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
{
Vector2& vec = Vector2RefFromVariant(thisValue);
switch ( childIndex )
{
case 0: vec.X = childValue.GetDouble(); break;
case 1: vec.Y = childValue.GetDouble(); break;
}
wxVariant newVariant;
newVariant << vec;
return newVariant;
}
示例12: 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;
}
示例13: CGUISizeRefFromVariant
// -----------------------------------------------------------------------
wxVariant WxGUISizeProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
{
CGUISize& size = CGUISizeRefFromVariant(thisValue);
switch ( childIndex )
{
case 0: size.m_fWidth = childValue.GetDouble(); break;
case 1: size.m_fHeight = childValue.GetDouble(); break;
}
wxVariant newVariant;
newVariant << size;
return newVariant;
}
示例14: switch
wxVariant nsVector3Property::ChildChanged(wxVariant& thisValue, int childIndex, wxVariant& childValue) const
{
Vector3 vector;
vector << thisValue;
switch (childIndex)
{
case 0: vector._x = childValue.GetDouble(); break;
case 1: vector._y = childValue.GetDouble(); break;
case 2: vector._z = childValue.GetDouble(); break;
}
wxVariant newVariant;
newVariant << vector;
return newVariant;
}
示例15: CGUIRotatorRefFromVariant
// -----------------------------------------------------------------------
wxVariant WxGUIRotatorProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
{
CGUIRotator& rotator = CGUIRotatorRefFromVariant(thisValue);
switch ( childIndex )
{
case 0: rotator.Pitch = childValue.GetDouble(); break;
case 1: rotator.Yaw = childValue.GetDouble(); break;
case 2: rotator.Roll = childValue.GetDouble(); break;
}
wxVariant newVariant;
newVariant << rotator;
return newVariant;
}