void NetBuilderProperties_frame::OnCellClick( wxGridEvent& event ) { MainFrame *myparent=(MainFrame *) GetParent(); int error=0; wxChar *endptr; char rest[100]; if (event.GetRow()==3){ pop_selected=event.GetCol(); int total_fdomains_value= (int) wxStrtol(Properties_grid->GetCellValue(2,pop_selected),&endptr,10); strcpy(rest,wxString(endptr).mb_str()); rest[100-1]='\0'; if (total_fdomains_value > 0 && strcmp(rest,"")==0){ if (total_fdomains_value!=population[pop_selected].total_fdomains) Initialize_Fdomains(pop_selected,total_fdomains_value); } else{ myparent->text_status->SetForegroundColour( wxColour( 247, 22, 10 ) ); wxLogMessage(wxT(">> WARNING: fdomains of population ") + int2wxStr(pop_selected) + wxT(" must be an integer greater than 0.")); myparent->text_status->SetForegroundColour( wxColour( 0, 0, 0 ) ); error=-1; } if (error==0) { population[pop_selected].total_fdomains=wxAtoi(Properties_grid->GetCellValue(2,pop_selected)); this->Enable(false); NetBuilderDynamics_frame *Dynamics_frame=new NetBuilderDynamics_frame(this); Dynamics_frame->Show(); } } event.Skip(); }
long wxStrtol_l(const char* str, char **endptr, int base, const wxXLocale& loc) { wxCHECK( loc.IsOk(), 0 ); CNumericLocaleSetter locSetter; return wxStrtol(str, endptr, base); }
bool CSG_String::asInt(int &Value) const { const wxChar *start = m_pString->c_str(); wxChar *end; Value = wxStrtol(start, &end, 10); return( end > start ); }
wxInt32 wxTextInputStream::Read32S(int base) { wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") ); if(!m_input) return 0; wxString word = ReadWord(); if(word.empty()) return 0; return wxStrtol(word.c_str(), 0, base); }
bool ecUtils::StrToItemIntegerType(const wxString & str, long &d) { wxChar* pEnd; bool rc; errno=0; bool bHex=(str.Len() > 2 && str[0]==wxT('0') && (str[1]==wxT('x')||str[1]==wxT('X'))); //d=_tcstol(str,&pEnd,bHex?16:10); d=wxStrtol(str,&pEnd,bHex?16:10); rc=(0==errno && (*pEnd==wxT('\0'))); return rc; }
bool CUtils::StrToItemIntegerType(const wxString & str, long &d) { wxChar *pEnd; errno = 0; bool bHex = (str.Len() > 2 && str[0] == wxT('0') && (str[1] == wxT('x') || str[1] == wxT('X'))); d = wxStrtol(str, &pEnd, bHex ? 16 : 10); return (errno == 0 && (*pEnd == wxT('\0'))); }
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file ) { wxChar *s = NULL; bool succ = wxGetResource(section, entry, (wxChar **)&s, file); if (succ) { *value = (int)wxStrtol(s, NULL, 10); delete[] s; return true; } else return false; }
bool wxPropertyValidator::StringToLong (wxChar *s, long *number) { bool ok = true; wxChar *value_ptr; *number = wxStrtol (s, &value_ptr, 10); if (value_ptr) { int len = wxStrlen (value_ptr); for (int i = 0; i < len; i++) { ok = (wxIsspace (value_ptr[i]) != 0); if (!ok) return false; } } return ok; }
void MyFrame::OnSetMinSize(wxCommandEvent& WXUNUSED(event) ) { wxString str; str.Printf( wxT("%d"), m_splitter->GetMinimumPaneSize()); #if wxUSE_TEXTDLG str = wxGetTextFromUser(wxT("Enter minimal size for panes:"), wxT(""), str, this); #endif if ( str.empty() ) return; int minsize = wxStrtol( str, (wxChar**)NULL, 10 ); m_splitter->SetMinimumPaneSize(minsize); #if wxUSE_STATUSBAR str.Printf( wxT("Min pane size = %d"), minsize); SetStatusText(str, 1); #endif // wxUSE_STATUSBAR }
bool wxFont::Create(const wxString& fontname, wxFontEncoding enc) { if( !fontname ) { *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT); return true; } m_refData = new wxFontRefData(); M_FONTDATA->m_nativeFontInfo.SetXFontName(fontname); // X font name wxString tmp; wxStringTokenizer tn( fontname, wxT("-") ); tn.GetNextToken(); // skip initial empty token tn.GetNextToken(); // foundry M_FONTDATA->m_faceName = tn.GetNextToken(); // family tmp = tn.GetNextToken().MakeUpper(); // weight if (tmp == wxT("BOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("BLACK")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("EXTRABOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("DEMIBOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("ULTRABOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("LIGHT")) M_FONTDATA->m_weight = wxFONTWEIGHT_LIGHT; if (tmp == wxT("THIN")) M_FONTDATA->m_weight = wxFONTWEIGHT_LIGHT; tmp = tn.GetNextToken().MakeUpper(); // slant if (tmp == wxT("I")) M_FONTDATA->m_style = wxFONTSTYLE_ITALIC; if (tmp == wxT("O")) M_FONTDATA->m_style = wxFONTSTYLE_ITALIC; tn.GetNextToken(); // set width tn.GetNextToken(); // add. style tn.GetNextToken(); // pixel size tmp = tn.GetNextToken(); // pointsize if (tmp != wxT("*")) { long num = wxStrtol (tmp.c_str(), (wxChar **) NULL, 10); M_FONTDATA->m_pointSize = (int)(num / 10); } tn.GetNextToken(); // x-res tn.GetNextToken(); // y-res tmp = tn.GetNextToken().MakeUpper(); // spacing if (tmp == wxT("M")) M_FONTDATA->m_family = wxFONTFAMILY_MODERN; else if (M_FONTDATA->m_faceName == wxT("TIMES")) M_FONTDATA->m_family = wxFONTFAMILY_ROMAN; else if (M_FONTDATA->m_faceName == wxT("HELVETICA")) M_FONTDATA->m_family = wxFONTFAMILY_SWISS; else if (M_FONTDATA->m_faceName == wxT("LUCIDATYPEWRITER")) M_FONTDATA->m_family = wxFONTFAMILY_TELETYPE; else if (M_FONTDATA->m_faceName == wxT("LUCIDA")) M_FONTDATA->m_family = wxFONTFAMILY_DECORATIVE; else if (M_FONTDATA->m_faceName == wxT("UTOPIA")) M_FONTDATA->m_family = wxFONTFAMILY_SCRIPT; tn.GetNextToken(); // avg width // deal with font encoding M_FONTDATA->m_encoding = enc; if ( M_FONTDATA->m_encoding == wxFONTENCODING_SYSTEM ) { wxString registry = tn.GetNextToken().MakeUpper(), encoding = tn.GetNextToken().MakeUpper(); if ( registry == wxT("ISO8859") ) { int cp; if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) { M_FONTDATA->m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); } } else if ( registry == wxT("MICROSOFT") ) { int cp; if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) { M_FONTDATA->m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); } } else if ( registry == wxT("KOI8") ) { M_FONTDATA->m_encoding = wxFONTENCODING_KOI8; } //else: unknown encoding - may be give a warning here? else return false; } return true; }
void NetBuilderProperties_frame::Onbtn_pop_OKClick( wxCommandEvent& event ) { MainFrame *myparent=(MainFrame *) GetParent(); int error = 0; wxChar *endptr; char rest[100]; for (unsigned int i=0; i<total_populations; i++){ int return_value; char size_label[MAXLABELSIZE]; char old_label[MAXLABELSIZE]; str_equal(population[i].label,old_label); strncpy(population[i].label,Properties_grid->GetCellValue(0,i).mb_str(),MAXLABELSIZE); population[i].label[MAXLABELSIZE-1]='\0'; if (strcmp("",population[i].label)==0){ myparent->text_status->SetForegroundColour( wxColour( 247, 22, 10 ) ); wxLogMessage(wxT(">> WARNING: label of population ") + wxString::Format(wxT("%i"),i) + wxT(" is empty")); myparent->text_status->SetForegroundColour( wxColour( 0, 0, 0 ) ); str_equal(old_label,population[i].label); error=-1; } wxStr2str(Properties_grid->GetCellValue(1,i),size_label); return_value=sscanf(size_label,"%ld*%ld*%ld)",&population[i].topology.dim_x,&population[i].topology.dim_y,&population[i].topology.dim_z); if (return_value!=3 || population[i].topology.dim_x < 1 || population[i].topology.dim_y < 1 || population[i].topology.dim_z < 1) { myparent->text_status->SetForegroundColour( wxColour( 247, 22, 10 ) ); wxLogMessage(wxT(">> WARNING: size of population ") + wxString::Format(wxT("%i"),i) + wxT(" is invalid")); myparent->text_status->SetForegroundColour( wxColour( 0, 0, 0 ) ); population[i].topology.dim_x = 1; population[i].topology.dim_y = 1; population[i].topology.dim_z = 1; error=-1; } for (unsigned int j=0; j<total_populations; j++){ if (dist_values[j][i][0]>population[i].topology.dim_x*population[i].topology.d_mean) RANDOM_DIST[j][i][0]=1; //uniform else RANDOM_DIST[j][i][0]=0; //gaussian if (dist_values[j][i][1]>population[i].topology.dim_y*population[i].topology.d_mean) RANDOM_DIST[j][i][1]=1; //uniform else RANDOM_DIST[j][i][1]=0; //gaussian if (dist_values[j][i][2]>population[i].topology.dim_z*population[i].topology.d_mean) RANDOM_DIST[j][i][2]=1; //uniform else RANDOM_DIST[j][i][2]=0; //gaussian } int total_fdomains_value= (int) wxStrtol(Properties_grid->GetCellValue(2,i),&endptr,10); strcpy(rest,wxString(endptr).mb_str()); rest[100-1]='\0'; if (total_fdomains_value <= 0 || strcmp(rest, "")!=0){ myparent->text_status->SetForegroundColour( wxColour( 247, 22, 10 ) ); wxLogMessage(wxT(">> WARNING: fdomains of population ") + int2wxStr(i) + wxT(" must be an integer greater than 0.")); myparent->text_status->SetForegroundColour( wxColour( 0, 0, 0 ) ); error=-1; } else{ if (total_fdomains_value!=population[i].total_fdomains){ Initialize_Fdomains(i,total_fdomains_value); for (unsigned int j=0; j<total_populations; j++){ fdms_values[i][j]=0; } } population[i].total_fdomains=total_fdomains_value; } } if (error == 0){ this->Close(); myparent->Enable(true); wxLogMessage(wxT(">> Population properties (re)defined.")); if (summary_show==true) { Summary->Destroy(); Summary = new NetBuilderSummary_frame(this); Summary->Show(true); summary_show=true; } } }
void StringToLong (const wxChar *s, long *number) { if (s && *s && number) *number = wxStrtol (s, (wxChar **) NULL, 10); }
void StringToInt (const wxChar *s, int *number) { if (s && *s && number) *number = (int) wxStrtol (s, (wxChar **) NULL, 10); }
long wxStrtol_l(const char* str, char **endptr, int base, const wxXLocale& loc) { IMPLEMENT_STRTOX_L_START long ret = wxStrtol(str, endptr, base); IMPLEMENT_STRTOX_L_END }