本文整理汇总了C++中wxString::ToDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ wxString::ToDouble方法的具体用法?C++ wxString::ToDouble怎么用?C++ wxString::ToDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxString
的用法示例。
在下文中一共展示了wxString::ToDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompareFloatString
/* compare Strings that contains floats */
static int CompareFloatString(const wxString& first,const wxString& second) {
double dFirst;
double dSecond;
first.ToDouble(&dFirst);
second.ToDouble(&dSecond);
if(dFirst < dSecond) {
return reverseCompareOrder ? 1 : -1 ;
}
if(dSecond < dFirst) {
return reverseCompareOrder ? -1 : 1 ;
}
return 0;
}
示例2: ResetWith
/////////////////////////////////////////////////////////
// Resets a value with a string, preserving current type
void VariableData::ResetWith(wxString value) {
switch (type) {
case VARDATA_INT: {
long temp = 0;
value.ToLong(&temp);
SetInt(temp);
break;
}
case VARDATA_FLOAT: {
double temp = 0;
value.ToDouble(&temp);
SetFloat(temp);
break;
}
case VARDATA_BOOL:
if (value == _T("1")) SetBool(true);
else SetBool(false);
break;
case VARDATA_COLOUR: {
long r=0,g=0,b=0;
value.Mid(1,2).ToLong(&r,16);
value.Mid(3,2).ToLong(&g,16);
value.Mid(5,2).ToLong(&b,16);
SetColour(wxColour(r,g,b));
break;
}
default:
SetText(value);
break;
}
}
示例3: SetValue
void PluginPreference::SetValue(const wxString& value) {
hasBeenSet_ = true;
if (value_ == value) return;
if (GetType() == PluginPreferenceType::Spinner) {
double dValue;
bool converted = value.ToDouble(&dValue);
if (!converted) {
ELOG(_T("PluginPreference: value is not a number"));
return;
}
double fValue = (double)dValue;
if (minValue_ != maxValue_) {
if (fValue < minValue_ || fValue > maxValue_) {
ELOG(wxString::Format(_T("PluginPreference: value of '%s' is not within correct range (%d, %d)."), GetName(), GetMinValue(), GetMaxValue()));
return;
}
}
}
value_ = value;
Invalidate();
}
示例4: getDoubleValue
////////////////////////////////////////////////////////////
// Class name: MainFrame
// Method name: getDoubleValue
//
// Description: asdfadf
////////////////////////////////////////////////////////////
double MainFrame::getDoubleValue(wxString p_str)
{
double value;
if (!p_str.IsEmpty())
{
// if cannot convert
if (!p_str.ToDouble(&value))
{
// if not a valid number, show error.
wxMessageBox(
wxT("Not a valid double value."),
wxT("Value error."),
wxOK|wxICON_EXCLAMATION,
this
);
}
}
else
{
value = -1;
}
// return double value
return value;
}
示例5: BeginEdit
void wxGridCellFloatEditor::BeginEdit(int row, int col, wxGrid* grid)
{
// first get the value
wxGridTableBase * const table = grid->GetTable();
if ( table->CanGetValueAs(row, col, wxGRID_VALUE_FLOAT) )
{
m_value = table->GetValueAsDouble(row, col);
}
else
{
m_value = 0.0;
const wxString value = table->GetValue(row, col);
if ( !value.empty() )
{
if ( !value.ToDouble(&m_value) )
{
wxFAIL_MSG( wxT("this cell doesn't have float value") );
return;
}
}
}
DoBeginEdit(GetString());
}
示例6: return
static int Time2Frame(const wxString& timestr, int round)
{
double timeval;
int msec;
msec = timestr.ToDouble(&timeval)? (int)(timeval * 1000): 0;
return (round > 0)? (msec + 49)/ 50: (round < 0)? msec / 50: (msec + 25)/ 50; //round up/down/closest
}
示例7: StrToInt1Units
int StrToInt1Units( wxString aStr )
{
double num, precision = 10;
// TODO: Is the following commented string necessary?
// if (pos(',',s)>0) then DecimalSeparator:=',' else DecimalSeparator:='.';
aStr.ToDouble( &num );
return KiROUND( num * precision );
}
示例8: FromString
double xsDoublePropIO::FromString(const wxString& value)
{
double num = 0;
if(!value.IsEmpty())
{
value.ToDouble(&num);
}
return num;
}
示例9: SetCustomAttribute
bool wxSVGFEGaussianBlurElement::SetCustomAttribute(const wxString& name, const wxString& value) {
double dvalue;
if (name == wxT("stdDeviation") && value.ToDouble(&dvalue)) {
m_stdDeviationX.SetBaseVal(dvalue);
m_stdDeviationY.SetBaseVal(dvalue);
return true;
}
return false;
}
示例10: SetValue
void SpinControl::SetValue(const wxString& textValue) {
double doubleValue;
if (textValue.ToDouble(&doubleValue) && InRange(doubleValue)) {
DoSetValue(doubleValue);
} else {
m_text->SetValue(textValue);
m_text->SetSelection(0, -1);
m_text->SetInsertionPointEnd();
}
}
示例11: incrementCtrlBy
void INCREMENTAL_TEXT_CTRL::incrementCtrlBy( double aInc )
{
const wxString txt = getCtrlText();
if( !validateFloatField( txt ) )
return;
txt.ToDouble( &m_currentValue );
m_currentValue += aInc;
updateTextValue();
}
示例12: ParseLatLon
static double ParseLatLon(wxString s)
{
if(s.empty())
return NAN;
wxChar ns = s.Last();
int sign = (ns == 'S' || ns == 'W') ? -1 : 1;
double d;
s.ToDouble(&d);
return sign * d;
}
示例13: IsValidFloatValue
/* checks if the value contains a valid float */
bool CDlgAdvPreferences::IsValidFloatValue(const wxString& value) {
for(unsigned int i=0; i < value.Length();i++) {
if(!IsValidFloatChar(value[i])) {
return false;
}
}
//all chars are valid, now what is with the value as a whole ?
double td;
if(!value.ToDouble(&td)) {
return false;
}
return true;
}
示例14: IsValidFloatValueBetween
bool CDlgAdvPreferences::IsValidFloatValueBetween(const wxString& value, double minVal, double maxVal){
for(unsigned int i=0; i < value.Length();i++) {
if(!IsValidFloatChar(value[i])) {
return false;
}
}
//all chars are valid, now what is with the value as a whole ?
double td;
if(!value.ToDouble(&td)) {
return false;
}
if ((td < minVal) || (td > maxVal)) return false;
return true;
}
示例15: setCellValueWithEvt
void PropGrid::setCellValueWithEvt(int row,int col,const wxString& val)
{
wxDouble dummy;
long dummyL;
wxString cellDataType=this->GetTable()->GetTypeName(row,col);
if(cellDataType==wxGRID_VALUE_STRING
|| (val.ToLong(&dummyL) && cellDataType==wxGRID_VALUE_NUMBER)
|| (val.ToDouble(&dummy) && cellDataType==wxGRID_VALUE_FLOAT)
)
{
this->SetCellValue(row,col,val);
wxGridEvent customGreedEvent(1,wxEVT_GRID_CELL_CHANGE,this,row,col);
GetEventHandler()->ProcessEvent( customGreedEvent );
}
}