/// /// Real number form validator /// bool wxRealFormValidator::OnCheckValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view), wxWindow *parentWindow) { if (m_realMin == 0.0 && m_realMax == 0.0) return true; // The item used for viewing the real number: should be a text item. wxWindow *m_propertyWindow = property->GetWindow(); if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) return false; wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue()); float val = 0.0; if (!StringToFloat(WXSTRINGCAST value, &val)) { wxChar buf[200]; wxSprintf(buf, wxT("Value %s is not a valid real number!"), (const wxChar *)value); wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return false; } if (val < m_realMin || val > m_realMax) { wxChar buf[200]; wxSprintf(buf, wxT("Value must be a real number between %.2f and %.2f!"), m_realMin, m_realMax); wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return false; } return true; }
// Build up and save an index into the poetry data file, for // rapid random access bool Compile(void) { FILE *file; int j; int ch; wxChar buf[100]; if (data_filename) wxSprintf(buf, wxT("%s.dat"), data_filename); file = wxFopen(buf, wxT("rb")); if (! (data_filename && file)) { wxSprintf(error_buf, wxT("Poetry data file %s not found\n"), buf); PoetryError(error_buf); return false; } nitems = 0; // Do first one (?) poem_index[nitems] = 0; nitems ++; // Do rest do { ch = getc(file); if (ch == '#') { ch = getc(file); long data; data = ftell(file); poem_index[nitems] = data; nitems ++; } } while (ch != EOF); fclose(file); if (index_filename) wxSprintf(buf, wxT("%s.idx"), index_filename); file = wxFopen(buf, wxT("w")); if (! (data_filename && file)) { wxSprintf(error_buf, wxT("Poetry index file %s cannot be created\n"), buf); PoetryError(error_buf); return false; } wxFprintf(file, wxT("%ld\n\n"), nitems); for (j = 0; j < nitems; j++) wxFprintf(file, wxT("%ld\n"), poem_index[j]); fclose(file); PoetryNotify(wxT("Poetry index compiled.")); return true; }
void wxTreeLayout::DrawNode(long id, wxDC& dc) { wxChar buf[80]; wxString name(GetNodeName(id)); if (name != wxT("")) wxSprintf(buf, wxT("%s"), (const wxChar*) name); else wxSprintf(buf, wxT("<unnamed>")); long x = 80; long y = 20; dc.GetTextExtent(buf, &x, &y); dc.DrawText(buf, GetNodeX(id), (long)(GetNodeY(id) - (y/2.0))); }
// Load index file int LoadIndex(const wxChar *file_name) { long data; FILE *index_file; wxChar buf[100]; if (file_name == NULL) return 0; wxSprintf(buf, wxT("%s.idx"), file_name); index_file = wxFopen(buf, wxT("r")); if (index_file == NULL) return 0; wxFscanf(index_file, wxT("%ld"), &nitems); for (int i = 0; i < nitems; i++) { wxFscanf(index_file, wxT("%ld"), &data); poem_index[i] = data; } fclose(index_file); return 1; }
String strutil_ultoa(unsigned long i) { wxChar buffer[256]; // much longer than any integer wxSprintf(buffer, _T("%lu"), i); return String(buffer); }
ScriptSection::ScriptSection( const wxString& name, const wxString& body, ScriptTemplate* pSectionTemplate, ScriptTemplate* pReferenceTemplate, bool autoHide, bool sorted ) : m_pParent ( NULL ), m_Name ( name ), m_Body ( body ), m_AutoHide ( autoHide ), m_SortOn ( sorted ), m_pSectTempl( pSectionTemplate ), m_pRefTempl ( pReferenceTemplate ), m_RefCount( 0 ), m_ArrSize( 0 ) { // generate GUID wxChar buf[32]; wxSprintf( buf, _T("%d"), ++m_IdCounter ); m_Id = buf; }
bool wxIniConfig::Write(const wxString& szKey, long lValue) { // ltoa() is not ANSI :-( wxChar szBuf[40]; // should be good for sizeof(long) <= 16 (128 bits) wxSprintf(szBuf, wxT("%ld"), lValue); return Write(szKey, szBuf); }
wxChar * DoubleToString (double number, const wxChar *fmt) { static wxChar buf[256]; wxSprintf (buf, fmt, number); return buf; }
wxChar * IntToString (int number) { static wxChar buf[20]; wxSprintf (buf, wxT("%d"), number); return buf; }
wxChar * LongToString (long number) { static wxChar buf[20]; wxSprintf (buf, wxT("%ld"), number); return buf; }
wxChar * FloatToString (float number, const wxChar *fmt) { static wxChar buf[256]; wxSprintf (buf, fmt, number); return buf; }
const wxChar *wxDataObject::GetFormatName(wxDataFormat format) { // case 'xxx' is not a valid value for switch of enum 'wxDataFormat' #ifdef __VISUALC__ #pragma warning(disable:4063) #endif // VC++ static wxChar s_szBuf[256]; switch ( format ) { case CF_TEXT: return wxT("CF_TEXT"); case CF_BITMAP: return wxT("CF_BITMAP"); case CF_SYLK: return wxT("CF_SYLK"); case CF_DIF: return wxT("CF_DIF"); case CF_TIFF: return wxT("CF_TIFF"); case CF_OEMTEXT: return wxT("CF_OEMTEXT"); case CF_DIB: return wxT("CF_DIB"); case CF_PALETTE: return wxT("CF_PALETTE"); case CF_PENDATA: return wxT("CF_PENDATA"); case CF_RIFF: return wxT("CF_RIFF"); case CF_WAVE: return wxT("CF_WAVE"); case CF_UNICODETEXT: return wxT("CF_UNICODETEXT"); case CF_METAFILEPICT: return wxT("CF_METAFILEPICT"); case CF_ENHMETAFILE: return wxT("CF_ENHMETAFILE"); case CF_LOCALE: return wxT("CF_LOCALE"); case CF_HDROP: return wxT("CF_HDROP"); default: if ( !::GetClipboardFormatName(format, s_szBuf, WXSIZEOF(s_szBuf)) ) { // it must be a new predefined format we don't know the name of wxSprintf(s_szBuf, wxT("unknown CF (0x%04x)"), format.GetFormatId()); } return s_szBuf; } #ifdef __VISUALC__ #pragma warning(default:4063) #endif // VC++ }
bool wxIntegerFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view), wxWindow *parentWindow) { if (m_integerMin == 0.0 && m_integerMax == 0.0) return true; // The item used for viewing the real number: should be a text item or a slider wxWindow *m_propertyWindow = property->GetWindow(); if (!m_propertyWindow) return false; long val = 0; if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) { wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue()); if (!StringToLong(WXSTRINGCAST value, &val)) { wxChar buf[200]; wxSprintf(buf, wxT("Value %s is not a valid integer!"), (const wxChar *)value); wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return false; } } else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider))) { val = (long)((wxSlider *)m_propertyWindow)->GetValue(); } else return false; if (val < m_integerMin || val > m_integerMax) { wxChar buf[200]; wxSprintf(buf, wxT("Value must be an integer between %ld and %ld!"), m_integerMin, m_integerMax); wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return false; } return true; }
void SaveConfig() { wxChar szValue[256]; const wxString iniFile(Path::Combine(s_strIniPath, L"zzogl-pg-cg.ini")); wxSprintf(szValue, L"%u", conf.interlace); WritePrivateProfileString(L"Settings", L"Interlace", szValue, iniFile); wxSprintf(szValue, L"%u", conf.aa); WritePrivateProfileString(L"Settings", L"Antialiasing", szValue, iniFile); wxSprintf(szValue, L"%u", conf.bilinear); WritePrivateProfileString(L"Settings", L"Bilinear", szValue, iniFile); wxSprintf(szValue, L"%u", conf.zz_options); WritePrivateProfileString(L"Settings", L"ZZOptions", szValue, iniFile); wxSprintf(szValue, L"%u", conf.hacks); WritePrivateProfileString(L"Settings", L"AdvancedOptions", szValue, iniFile); wxSprintf(szValue, L"%u", conf.width); WritePrivateProfileString(L"Settings", L"Width", szValue, iniFile); wxSprintf(szValue, L"%u", conf.height); WritePrivateProfileString(L"Settings", L"Height", szValue, iniFile); wxSprintf(szValue, L"%u", conf.SkipDraw); WritePrivateProfileString(L"Settings", L"SkipDraw", szValue, iniFile); }
void Constraint::glCommands(HeeksColor color, gp_Ax1 axis) { double mag = sqrt(axis.Direction().X() * axis.Direction().X() + axis.Direction().Y() * axis.Direction().Y()); float rot = (float)atan2(axis.Direction().Y()/mag,axis.Direction().X()/mag); glPushMatrix(); glTranslatef((float)axis.Location().X(),(float)axis.Location().Y(),(float)axis.Location().Z()); glRotatef(rot*180/(float)Pi,0,0,1); glTranslatef(0,ANGLE_OFFSET_FROM_LINE,0); switch(m_type) { case AbsoluteAngleConstraint: switch(m_angle) { case AbsoluteAngleHorizontal: render_text(_("H")); break; case AbsoluteAngleVertical: glRotatef(90,0,0,1); render_text(_("V")); break; } break; case LineLengthConstraint: wxChar str[100]; wxSprintf(str,_T("%f"),m_length/(double)wxGetApp().m_view_units); render_text(str); break; case ParallelLineConstraint: render_text(_("L")); break; case PerpendicularLineConstraint: render_text(_("P")); break; default: break; } glPopMatrix(); }
bool MyPrintout::OnPrintPage(int page) { wxDC *dc = GetDC(); if (dc) { if (page == 1) DrawPageOne(); else if (page == 2) DrawPageTwo(); // Draw page numbers at top left corner of printable area, sized so that // screen size of text matches paper size. MapScreenSizeToPage(); wxChar buf[200]; wxSprintf(buf, wxT("PAGE %d"), page); dc->DrawText(buf, 0, 0); return true; } else return false; }
void wxCompositeShape::ReadConstraints(wxExpr *clause, wxExprDatabase *database) { // Constraints are output as constraint1 = (...), constraint2 = (...), etc. int constraintNo = 1; wxChar m_constraintNameBuf[20]; bool haveConstraints = TRUE; while (haveConstraints) { wxSprintf(m_constraintNameBuf, wxT("constraint%d"), constraintNo); wxExpr *constraintExpr = NULL; clause->GetAttributeValue(m_constraintNameBuf, &constraintExpr); if (!constraintExpr) { haveConstraints = FALSE; break; } wxString cName = wxEmptyString; wxShape *m_constrainingObject = NULL; wxList m_constrainedObjects; // Each constraint is stored in the form // (type name id xspacing yspacing m_constrainingObjectId constrainedObjectIdList) wxExpr *typeExpr = constraintExpr->Nth(0); wxExpr *nameExpr = constraintExpr->Nth(1); wxExpr *idExpr = constraintExpr->Nth(2); wxExpr *xExpr = constraintExpr->Nth(3); wxExpr *yExpr = constraintExpr->Nth(4); wxExpr *constrainingExpr = constraintExpr->Nth(5); wxExpr *constrainedExpr = constraintExpr->Nth(6); int cType = (int)typeExpr->IntegerValue(); double cXSpacing = xExpr->RealValue(); double cYSpacing = yExpr->RealValue(); cName = nameExpr->StringValue(); long cId = idExpr->IntegerValue(); wxExpr *objExpr1 = database->HashFind(wxT("node_image"), constrainingExpr->IntegerValue()); if (objExpr1 && objExpr1->GetClientData()) m_constrainingObject = (wxShape *)objExpr1->GetClientData(); else wxLogFatalError(wxT("Object graphics error: Couldn't find constraining image of composite.")); int i = 0; wxExpr *currentIdExpr = constrainedExpr->Nth(i); while (currentIdExpr) { long currentId = currentIdExpr->IntegerValue(); wxExpr *objExpr2 = database->HashFind(wxT("node_image"), currentId); if (objExpr2 && objExpr2->GetClientData()) { m_constrainedObjects.Append((wxShape *)objExpr2->GetClientData()); } else { wxLogFatalError(wxT("Object graphics error: Couldn't find constrained image of composite.")); } i ++; currentIdExpr = constrainedExpr->Nth(i); } wxOGLConstraint *newConstraint = AddConstraint(cType, m_constrainingObject, m_constrainedObjects); newConstraint->SetSpacing(cXSpacing, cYSpacing); newConstraint->m_constraintId = cId; newConstraint->m_constraintName = cName; constraintNo ++; } }
// Do the search long MainWindow::DoSearch(void) { if (m_searchString.empty()) return false; FILE *file; size_t i = 0; int ch = 0; wxChar buf[100]; long find_start; long previous_poem_start; bool found = false; size_t search_length = m_searchString.length(); if (same_search) { find_start = last_find + 1; previous_poem_start = last_poem_start; } else { find_start = 0; last_poem_start = 0; previous_poem_start = -1; } if (data_filename) wxSprintf(buf, wxT("%s.dat"), data_filename); file = wxFopen(buf, wxT("rb")); if (! (data_filename && file)) { wxSprintf(error_buf, wxT("Poetry data file %s not found\n"), buf); PoetryError(error_buf); return false; } fseek(file, find_start, SEEK_SET); while ((ch != EOF) && !found) { ch = getc(file); ch = wxTolower(ch); // Make lower case // Only match if we're looking at a different poem // (no point in displaying the same poem again) if ((m_searchString[i] == ch) && (last_poem_start != previous_poem_start)) { if (i == 0) last_find = ftell(file); if (i == search_length-1) found = true; i ++; } else { i = 0; } if (ch == '#') { ch = getc(file); last_poem_start = ftell(file); } } fclose(file); if (ch == EOF) { last_find = -1; } if (found) { return last_poem_start; } return -1; }
// Load a poem from given file, at given point in file. // If position is > -1, use this for the position in the // file, otherwise use index[index_ptr] to find the correct position. bool LoadPoem(const wxChar *file_name, long position) { // int j = 0; // int indexn = 0; wxChar buf[100]; long data; FILE *data_file; paging = false; current_page = 0; if (file_name == NULL) { wxSprintf(error_buf, wxT("Error in Poem loading.")); PoetryError(error_buf); return false; } wxSprintf(buf, wxT("%s.dat"), file_name); data_file = wxFopen(buf, wxT("rb")); if (data_file == NULL) { wxSprintf(error_buf, wxT("Data file %s not found."), buf); PoetryError(error_buf); return false; } if (position > -1) data = position; else data = poem_index[index_ptr]; fseek(data_file, data, SEEK_SET); int ch = 0; int i = 0; while ((ch != EOF) && (ch != '#')) { ch = getc(data_file); // Add a linefeed so it will copy to the clipboard ok if (ch == 10) { poem_buffer[i] = 13; i++; } poem_buffer[i] = (wxChar)ch; i ++; if (i == BUFFER_SIZE) { wxSprintf(error_buf, wxT("%s"), wxT("Poetry buffer exceeded.")); PoetryError(error_buf); return false; } } fclose(data_file); poem_buffer[i-1] = 0; return true; }
void CircuitPrint::DrawPageOne(wxDC *dc) { // Scale the image to fit within a // "margined" area on the printer DC, and // keep its same aspect ratio: // Get the size of the print DC in pixels int w, h; dc->GetSize(&w, &h); // draw the filename wxChar buf[200]; wxSprintf(buf, filename); int textWidth, textHeight; dc->GetTextExtent(buf, &textWidth, &textHeight); dc->DrawText(buf, w/2-textWidth/2, 10); float marginX = 150; float marginY = 150; int maxW = (int)(w - 2 * marginX); int maxH = (int)(h - 2 * marginY); int cw, ch; sourceCanvas->GetClientSize( &cw, &ch ); float aspect = (float) ch / (float) cw; float imageWidth = 0; float imageHeight = 0; if( aspect * maxW <= maxH ) { // If we can fit the maximum width image in the given height, // then do it, otherwise take the maximum height. imageWidth = maxW; imageHeight = aspect * maxW; } else { imageWidth = (float) maxH / aspect; imageHeight = maxH; } /* // Calculate a suitable scaling factor float scaleX=(float)(w/maxX); float scaleY=(float)(h/maxY); // Use x or y scaling factor, whichever fits on the DC float actualScale = wxMin(scaleX,scaleY); // Calculate the position on the DC for centring the graphic float posX = (float)((w - (200*actualScale))/2.0); float posY = (float)((h - (200*actualScale))/2.0); // Set the scale and origin dc->SetUserScale(actualScale, actualScale); dc->SetDeviceOrigin( (long)posX, (long)posY ); */ wxImage viewShot = sourceCanvas->renderToImage((int)imageWidth, (int)imageHeight); wxBitmap printBmp(viewShot); float posX = ((float) w / 2.0) - imageWidth / 2.0; float posY = ((float) h / 2.0) - imageHeight / 2.0; dc->DrawBitmap( printBmp, (int)posX, (int)posY ); }
bool FFTviewerFrame::SaveConfiguration() { char outbuf[80]; char newline[3]; memset(outbuf,0,sizeof(outbuf)); #define _N (sizeof(outbuf)-1) wxSprintf(newline,"\r\n"); if(g_CfgChanged) { g_CfgChanged = false; //Avoid repeated writes if(m_CFG_FileClassPtr == NULL) m_CFG_FileClassPtr = new wxFile(); m_CFG_FileClassPtr->Create(g_CfgFileName,TRUE,wxS_DEFAULT); if(!m_CFG_FileClassPtr->IsOpened()) { cout << "CFG File Open Fail" << endl; if(m_CFG_FileClassPtr != NULL) { m_CFG_FileClassPtr->Close(); delete m_CFG_FileClassPtr; m_CFG_FileClassPtr = NULL; } return(false); } wxSnprintf(outbuf,_N,"RASDRproc Version %s - NOTE: Limit to 80 column to avoid problems %s", AutoVersion::FULLVERSION_STRING,"..............................................................."); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%.12f // Center Frequency (GHz)",mSpectrum->m_RxFreq); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14g // Frequency Step",mSpectrum->m_frequencyStep); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // LPF Bandwidth (index)",LMLL_RxLPFGetLpfBw()); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // VGA1 Gain (index)",LMLL_RxFEGetRFB_TIA_RXFE()); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // VGA2 Gain (index)",LMLL_RxVGA2GetVga2G_u()); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // LNA Gain (index)",LMLL_RxFEGetG_LNA_RXFE()); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // Enable Averaging (0=no, 1=yes)",mSpectrum->chkAverage->GetValue()); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // Number of frames to average",mSpectrum->spinAvgCount->GetValue()); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // FFT log2(Samples/Frame) (N=2^integer; 10=1024, 11=2048, etc)",mSpectrum->spinFFTsamples->GetValue()); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // Sampling Frequency (MHz, integer, min=2, max=32)",mSpectrum->spinSamplingFreq->GetValue()); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // FFTOutput - Multiple Control (1=single 2=multiple suffixed)",g_NumbFFTFiles); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // FFTOutput - File Type Control (0=.csv for excel 1=General)",g_FFTFileType); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // FFTOutput - Time Standard Control (0=Local Time 1=UTC)",g_FFT_TimeStandard); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // FFTOutput - Number of Frames To Skip (integer)",g_FFTframeSkip); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // FFTOutput - Number of Frames to Write (integer)",g_FFTframesOut); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // PWROutput - Multiple Control (1=single 2=multiple suffixed)",g_NumbPWRFiles); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // PWROutput - File Type Control",g_PWRFileType); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // PWROutput - Time Standard Control (0=Local Time 1=UTC)",g_PWRTimeStandard); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // PWROutput - Recording Rate (seconds/sample)",g_PwrRecordRate); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // PWROutput - Plot Span (seconds)",g_PwrSpanSec); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // FFTOutput - Record Span (0=full range, 1=zoom/span)",g_FFTDataSource); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); /* m_CFG_FileClassPtr->Write(g_FFTfileName); m_CFG_FileClassPtr->Write(newline); */ wxSnprintf(outbuf,_N,"%-14d // Background Subtraction Code (bit encoded, try 71, bit0=en)",g_backgroundDebugCfg); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%.12f // Integration Gain",g_integrationGain); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%14.10f // DC Offset for I samples",(g_DcOffsetI == 0.0?g_avgI:g_DcOffsetI)); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%14.10f // DC Offset for Q samples",(g_DcOffsetQ == 0.0?g_avgQ:g_DcOffsetQ)); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // Unlimited Averaging (0=no, 1=yes)", g_UnlimitedAveraging); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); // RSS Integration wxSnprintf(outbuf,_N,"%-14s // RSS Server IP",g_RSS_IP); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14hu // RSS Server Port (default=8888)", g_RSS_Port); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // RSS Channels (range is 100 to 512 unless extensions enabled)", g_RSS_Channels); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // RSS Server Enabled (0=disabled, 1=enabled)", g_RSS_Enable?1:0); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); // RSS RASDR Extension wxSnprintf(outbuf,_N,"%14.10f // RSS Frequency Offset (GHz)",g_RSS_FrequencyOffset); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%-14d // RSS Extensions Enabled (0=disabled, 1=enabled)", g_RSS_Extension?1:0); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%14.10f // RSS Channel Offset Adjustment",g_RSS_Offset); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%14.10f // RSS Channel Gain Adjustment",g_RSS_Gain); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%14.10f // RSS Channel Bias Adjustment",g_RSS_Bias); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%14.9f // RSS Channel Minimum Output Value",g_RSS_MinValue); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); wxSnprintf(outbuf,_N,"%14.9f // RSS Channel Maximum Output Value",g_RSS_MaxValue); m_CFG_FileClassPtr->Write(outbuf); m_CFG_FileClassPtr->Write(newline); // m_CFG_FileClassPtr->Flush(); m_CFG_FileClassPtr->Close(); delete m_CFG_FileClassPtr; m_CFG_FileClassPtr = NULL; cout << "Configuration Saved" << endl; } return(true); }
// get error message from system const wxChar *wxSysErrorMsg(unsigned long nErrCode) { if ( nErrCode == 0 ) nErrCode = wxSysErrorCode(); #if defined(__WXMSW__) && !defined(__WXMICROWIN__) static wxChar s_szBuf[1024]; // get error message from system LPVOID lpMsgBuf; if ( ::FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, nErrCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL ) == 0 ) { // if this happens, something is seriously wrong, so don't use _() here // for safety wxSprintf(s_szBuf, _T("unknown error %lx"), nErrCode); return s_szBuf; } // copy it to our buffer and free memory // Crashes on SmartPhone (FIXME) #if !defined(__SMARTPHONE__) /* of WinCE */ if( lpMsgBuf != 0 ) { wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1); s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxT('\0'); LocalFree(lpMsgBuf); // returned string is capitalized and ended with '\r\n' - bad s_szBuf[0] = (wxChar)wxTolower(s_szBuf[0]); size_t len = wxStrlen(s_szBuf); if ( len > 0 ) { // truncate string if ( s_szBuf[len - 2] == wxT('\r') ) s_szBuf[len - 2] = wxT('\0'); } } else #endif // !__SMARTPHONE__ { s_szBuf[0] = wxT('\0'); } return s_szBuf; #else // !__WXMSW__ #if wxUSE_UNICODE static wchar_t s_wzBuf[1024]; wxConvCurrent->MB2WC(s_wzBuf, strerror((int)nErrCode), WXSIZEOF(s_wzBuf) - 1); return s_wzBuf; #else return strerror((int)nErrCode); #endif #endif // __WXMSW__/!__WXMSW__ }
wxChar *wxPropertyValidator::LongToString (long number) { static wxChar buf[20]; wxSprintf (buf, wxT("%ld"), number); return buf; }
void wxCompositeShape::WriteAttributes(wxExpr *clause) { wxRectangleShape::WriteAttributes(clause); // clause->AddAttributeValue("selectable", (long)selectable); // Output constraints as constraint1 = (...), constraint2 = (...), etc. int constraintNo = 1; wxChar m_constraintNameBuf[20]; wxNode *node = m_constraints.GetFirst(); while (node) { wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData(); wxSprintf(m_constraintNameBuf, wxT("constraint%d"), constraintNo); // Each constraint is stored in the form // (type name id xspacing yspacing m_constrainingObjectId constrainedObjectIdList) wxExpr *constraintExpr = new wxExpr(wxExprList); constraintExpr->Append(new wxExpr((long)constraint->m_constraintType)); constraintExpr->Append(new wxExpr(wxExprString, constraint->m_constraintName)); constraintExpr->Append(new wxExpr(constraint->m_constraintId)); constraintExpr->Append(new wxExpr(constraint->m_xSpacing)); constraintExpr->Append(new wxExpr(constraint->m_ySpacing)); constraintExpr->Append(new wxExpr(constraint->m_constrainingObject->GetId())); wxExpr *objectList = new wxExpr(wxExprList); wxNode *node1 = constraint->m_constrainedObjects.GetFirst(); while (node1) { wxShape *obj = (wxShape *)node1->GetData(); objectList->Append(new wxExpr(obj->GetId())); node1 = node1->GetNext(); } constraintExpr->Append(objectList); clause->AddAttributeValue(m_constraintNameBuf, constraintExpr); node = node->GetNext(); constraintNo ++; } // Write the ids of all the child images wxExpr *childrenExpr = new wxExpr(wxExprList); node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); childrenExpr->Append(new wxExpr(child->GetId())); node = node->GetNext(); } clause->AddAttributeValue(wxT("children"), childrenExpr); // Write the ids of all the division images if (m_divisions.GetCount() > 0) { wxExpr *divisionsExpr = new wxExpr(wxExprList); node = m_divisions.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); divisionsExpr->Append(new wxExpr(child->GetId())); node = node->GetNext(); } clause->AddAttributeValue(wxT("divisions"), divisionsExpr); } }
wxChar *wxPropertyValidator::IntToString (int number) { static wxChar buf[20]; wxSprintf (buf, wxT("%d"), number); return buf; }
void CMemoryWindow::onSearch(wxCommandEvent& event) { u8* TheRAM = nullptr; u32 szRAM = 0; switch (memview->GetMemoryType()) { case 0: default: if (Memory::m_pRAM) { TheRAM = Memory::m_pRAM; szRAM = Memory::REALRAM_SIZE; } break; case 1: { u8* aram = DSP::GetARAMPtr(); if (aram) { TheRAM = aram; szRAM = DSP::ARAM_SIZE; } } break; } //Now we have memory to look in //Are we looking for ASCII string, or hex? //memview->cu wxString rawData = valbox->GetValue(); std::vector<u8> Dest; //May need a better name u32 size = 0; int pad = rawData.size()%2; //If it's uneven unsigned int i = 0; long count = 0; char copy[3] = {0}; long newsize = 0; unsigned char *tmp2 = nullptr; char* tmpstr = nullptr; if (chkHex->GetValue()) { //We are looking for hex //If it's uneven size = (rawData.size()/2) + pad; Dest.resize(size+32); newsize = rawData.size(); if (pad) { tmpstr = new char[newsize + 2]; memset(tmpstr, 0, newsize + 2); tmpstr[0] = '0'; } else { tmpstr = new char[newsize + 1]; memset(tmpstr, 0, newsize + 1); } strcat(tmpstr, WxStrToStr(rawData).c_str()); tmp2 = &Dest.front(); count = 0; for (i = 0; i < strlen(tmpstr); i++) { copy[0] = tmpstr[i]; copy[1] = tmpstr[i+1]; copy[2] = 0; int tmpint; sscanf(copy, "%02x", &tmpint); tmp2[count++] = tmpint; // Dest[count] should now be the hex of what the two chars were! // Also should add a check to make sure it's A-F only //sscanf(copy, "%02x", &tmp2[count++]); i += 1; } delete[] tmpstr; } else { //Looking for an ascii string size = rawData.size(); Dest.resize(size+1); tmpstr = new char[size+1]; tmp2 = &Dest.front(); sprintf(tmpstr, "%s", WxStrToStr(rawData).c_str()); for (i = 0; i < size; i++) tmp2[i] = tmpstr[i]; delete[] tmpstr; } if (size) { unsigned char* pnt = &Dest.front(); unsigned int k = 0; //grab wxString txt = addrbox->GetValue(); u32 addr = 0; if (txt.size()) { sscanf(WxStrToStr(txt).c_str(), "%08x", &addr); } i = addr+4; for ( ; i < szRAM; ++i) { for (k = 0; k < size; ++k) { if (i + k > szRAM) break; if (k > size) break; if (pnt[k] != TheRAM[i+k]) { k = 0; break; } } if (k == size) { //Match was found wxMessageBox(_("A match was found. Placing viewer at the offset.")); wxChar tmpwxstr[128] = {0}; wxSprintf(tmpwxstr, "%08x", i); wxString tmpwx(tmpwxstr); addrbox->SetValue(tmpwx); //memview->curAddress = i; //memview->Refresh(); OnAddrBoxChange(event); return; } } wxMessageBox(_("No match was found.")); } }