本文整理汇总了C++中wxStrlen函数的典型用法代码示例。如果您正苦于以下问题:C++ wxStrlen函数的具体用法?C++ wxStrlen怎么用?C++ wxStrlen使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxStrlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxFileDialog
void CDistinta::SalvaDistinta(bool saveas)
{
wxFile ff;
wxString nome_file;
int uu;
RigaDist* rd;
ListaRighe::Node* nrd;
if (saveas) {
fd = new wxFileDialog(NULL, "Save As...",dist_path,nome_dist,"*.dat", wxFD_SAVE);
if (fd->ShowModal() == wxID_CANCEL) {
delete fd;
return; // the user changed idea...
}
nome_dist = fd->GetFilename();
nome_file = dist_path+nome_dist;
}
else
nome_file = ".\\DISTINTA.DAT";
ff.Open(nome_file,wxFile::write);
//se salvataggio distinta attuale
//come prima cosa salvo il nome della distinta...
if(saveas==false) {
uu=wxStrlen(nome_dist);
ff.Write(&uu,sizeof(int));
if (uu>0)
ff.Write(nome_dist,wxMBConvUTF8());
}
//... e poi tutte le righe...
nrd=lista->GetFirst();
while (nrd) {
rd = nrd->GetData();
for(int ii=0; ii<num_var; ii++) {
ff.Write(&rd->dati.d[ii],sizeof(double));
ff.Write(&rd->dati.i[ii],sizeof(int));
}
for(int ii=0; ii<num_var; ii++) {
uu=wxStrlen(rd->dati.s[ii]);
ff.Write(&uu,sizeof(int));
if (uu>0)
ff.Write(rd->dati.s[ii],wxMBConvUTF8());
} //TODO vedere se passare all'ascii 8 bit
nrd = nrd->GetNext();
}
ff.Close();
statusbar->SetStatusText(nome_dist,0);
}
示例2: wxPuts
void InteractiveInputTestCase::TestRegExInteractive()
{
#ifdef TEST_REGEX
wxPuts(wxT("*** Testing RE interactively ***"));
for ( ;; )
{
wxChar pattern[128];
wxPrintf(wxT("Enter a pattern (press ENTER or type 'quit' to escape): "));
if ( !wxFgets(pattern, WXSIZEOF(pattern), stdin) )
break;
// kill the last '\n'
pattern[wxStrlen(pattern) - 1] = 0;
if (pattern[0] == '\0' || wxStrcmp(pattern, "quit") == 0)
break;
wxRegEx re;
if ( !re.Compile(pattern) )
{
continue;
}
wxChar text[128];
for ( ;; )
{
wxPrintf(wxT("Enter text to match: "));
if ( !wxFgets(text, WXSIZEOF(text), stdin) )
break;
// kill the last '\n'
text[wxStrlen(text) - 1] = 0;
if ( !re.Matches(text) )
{
wxPrintf(wxT("No match.\n"));
}
else
{
wxPrintf(wxT("Pattern matches at '%s'\n"), re.GetMatch(text).c_str());
size_t start, len;
for ( size_t n = 1; ; n++ )
{
if ( !re.GetMatch(&start, &len, n) )
{
break;
}
wxPrintf(wxT("Subexpr %u matched '%s'\n"),
n, wxString(text + start, len).c_str());
}
}
}
wxPuts("\n");
}
#endif // TEST_REGEX
}
示例3: buffer
void VarArgTestCase::RepeatedPrintf()
{
wxCharBuffer buffer(2);
char *p = buffer.data();
*p = 'h';
p++;
*p = 'i';
wxString s;
s = wxString::Format("buffer %s, len %d", buffer, (int)wxStrlen(buffer));
CPPUNIT_ASSERT_EQUAL("buffer hi, len 2", s);
s = wxString::Format("buffer %s, len %d", buffer, (int)wxStrlen(buffer));
CPPUNIT_ASSERT_EQUAL("buffer hi, len 2", s);
}
示例4: wxStrlen
wxString::size_type wxFilterClassFactoryBase::FindExtension(
const wxChar *location) const
{
size_t len = wxStrlen(location);
for (const wxChar *const *p = GetProtocols(wxSTREAM_FILEEXT); *p; p++)
{
size_t l = wxStrlen(*p);
if (l <= len && wxStrcmp(*p, location + len - l) == 0)
return len - l;
}
return wxString::npos;
}
示例5: GetActiveProject
bool EffectDtmf::Init()
{
// dialog will be passed values from effect
// Effect retrieves values from saved config
// Dialog will take care of using them to initialize controls
// If there is a selection, use that duration, otherwise use
// value from saved config: this is useful is user wants to
// replace selection with dtmf sequence
if (mT1 > mT0) {
// there is a selection: let's fit in there...
// MJS: note that this is just for the TTC and is independent of the track rate
// but we do need to make sure we have the right number of samples at the project rate
AudacityProject *p = GetActiveProject();
double projRate = p->GetRate();
double quantMT0 = QUANTIZED_TIME(mT0, projRate);
double quantMT1 = QUANTIZED_TIME(mT1, projRate);
mDuration = quantMT1 - quantMT0;
mIsSelection = true;
} else {
// retrieve last used values
gPrefs->Read(wxT("/Effects/DtmfGen/SequenceDuration"), &mDuration, 1L);
mIsSelection = false;
}
gPrefs->Read(wxT("/Effects/DtmfGen/String"), &dtmfString, wxT("audacity"));
gPrefs->Read(wxT("/Effects/DtmfGen/DutyCycle"), &dtmfDutyCycle, 550L);
gPrefs->Read(wxT("/Effects/DtmfGen/Amplitude"), &dtmfAmplitude, 0.8f);
dtmfNTones = wxStrlen(dtmfString);
return true;
}
示例6: wxStrlen
int AutoCompData::FindString( const wxChar* word, const wxChar* words, const wxArrayInt& indicies )
{
// Do a simple binary search using the index array
// to find the strings in the word list. It's all
// sorted, so it should be super quick.
size_t i,
lo = 0,
hi = indicies.GetCount();
int res;
const wxChar* other;
size_t wordLen = wxStrlen( word );
while ( lo < hi ) {
i = (lo + hi) / 2;
other = words + indicies[i];
res = wxStrnicmp(word, other, wordLen);
if ( res < 0 )
hi = i;
else if ( res > 0 )
lo = i + 1;
else
return i;
}
return -1;
}
示例7: wxT
bool EffectDtmf::Init()
{
// dialog will be passed values from effect
// Effect retrieves values from saved config
// Dialog will take care of using them to initialize controls
// If there is a selection, use that duration, otherwise use
// value from saved config: this is useful is user wants to
// replace selection with dtmf sequence
if (mT1 > mT0) {
// there is a selection: let's fit in there...
mDuration = mT1 - mT0;
mIsSelection = true;
} else {
// retrieve last used values
gPrefs->Read(wxT("/CsPresets/DtmfGen_SequenceDuration"), &mDuration, 1L);
mIsSelection = false;
}
/// \todo this code shouldn't be using /CsPresets - need to review its use
gPrefs->Read(wxT("/CsPresets/DtmfGen_String"), &dtmfString, wxT("audacity"));
gPrefs->Read(wxT("/CsPresets/DtmfGen_DutyCycle"), &dtmfDutyCycle, 550L);
gPrefs->Read(wxT("/CsPresets/DtmfGen_Amplitude"), &dtmfAmplitude, 0.8f);
dtmfNTones = wxStrlen(dtmfString);
return true;
}
示例8: GTK_ENTRY
wxString wxComboBox::DoGetValue() const
{
GtkEntry *entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
wxString tmp( wxGTK_CONV_BACK( gtk_entry_get_text( entry ) ) );
#if 0
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
# pragma ivdep
# pragma swp
# pragma unroll
# pragma prefetch
# if 0
# pragma simd noassert
# endif
#endif /* VDM auto patch */
for (int i = 0; i < wxStrlen(tmp.c_str()) +1; i++)
{
wxChar c = tmp[i];
printf( "%d ", (int) (c) );
}
printf( "\n" );
#endif
return tmp;
}
示例9: WXUNUSED
void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y,
long *descent, long *externalLeading, wxFont *theFont, bool WXUNUSED(use16bit)) const
{
wxFont *fontToUse = theFont;
if (!fontToUse)
fontToUse = (wxFont*) &m_font;
HDC dc = GetDC(NULL);
SIZE sizeRect;
TEXTMETRIC tm;
::GetTextExtentPoint32(dc, WXSTRINGCAST string, wxStrlen(WXSTRINGCAST string), &sizeRect);
GetTextMetrics(dc, &tm);
ReleaseDC(NULL, dc);
if ( x )
*x = sizeRect.cx;
if ( y )
*y = sizeRect.cy;
if ( descent )
*descent = tm.tmDescent;
if ( externalLeading )
*externalLeading = tm.tmExternalLeading;
}
示例10: IsNumberedAccelKey
// return prefixCode+number if the string is of the form "<prefix><number>" and
// 0 if it isn't
//
// first and last parameter specify the valid domain for "number" part
static int
IsNumberedAccelKey(const wxString& str,
const wxChar *prefix,
wxKeyCode prefixCode,
unsigned first,
unsigned last)
{
const size_t lenPrefix = wxStrlen(prefix);
if ( !CompareAccelString(str.Left(lenPrefix), prefix) )
return 0;
unsigned long num;
if ( !str.Mid(lenPrefix).ToULong(&num) )
return 0;
if ( num < first || num > last )
{
// this must be a mistake, chances that this is a valid name of another
// key are vanishingly small
wxLogDebug(_T("Invalid key string \"%s\""), str.c_str());
return 0;
}
return prefixCode + num - first;
}
示例11: main
int main(int argc, char **argv)
{
wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
wxInitializer initializer;
if ( !initializer )
{
fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
return -1;
}
wxCmdLineParser parser(cmdLineDesc, argc, argv);
switch ( parser.Parse() )
{
case -1:
// help was given, terminating
break;
case 0:
// everything is ok; proceed
if (parser.Found("d"))
{
wxPrintf("Dummy switch was given...\n");
while (1)
{
wxChar input[128];
wxPrintf("Try to guess the magic number (type 'quit' to escape): ");
if ( !wxFgets(input, WXSIZEOF(input), stdin) )
break;
// kill the last '\n'
input[wxStrlen(input) - 1] = 0;
if (wxStrcmp(input, "quit") == 0)
break;
long val;
if (!wxString(input).ToLong(&val))
{
wxPrintf("Invalid number...\n");
continue;
}
if (val == 42)
wxPrintf("You guessed!\n");
else
wxPrintf("Bad luck!\n");
}
}
break;
default:
break;
}
// do something useful here
return 0;
}
示例12: wxT
// assigns C string
wxStringImpl& wxStringImpl::operator=(const wxStringCharType *psz)
{
if ( !AssignCopy(wxStrlen(psz), psz) ) {
wxFAIL_MSG( wxT("out of memory in wxStringImpl::operator=(const wxStringCharType *)") );
}
return *this;
}
示例13: fd
void ChatLog::FillLastLineArray()
{
int fd ( open(GetCurrentLogfilePath().mb_str(), O_RDONLY) );
if ( fd < 0 )
{
wxLogError(_T("%s: failed to open log file."), __PRETTY_FUNCTION__);
return;
}
size_t num_lines ( sett().GetAutoloadedChatlogLinesCount() );
m_last_lines.Clear();
m_last_lines.Alloc(num_lines);
const wxChar* wc_EOL ( wxTextBuffer::GetEOL() );
size_t eol_num_chars ( wxStrlen(wc_EOL) );
#ifndef WIN32
char* eol ( static_cast<char*>( alloca(eol_num_chars) ) );
#else
char* eol ( new char[eol_num_chars] );
#endif
wxConvUTF8.WC2MB(eol, wc_EOL, eol_num_chars);
size_t lines_added ( find_tail_sequences(fd, eol, eol_num_chars, num_lines, m_last_lines) );
wxLogMessage(_T("ChatLog::FillLastLineArray: Loaded %lu lines from %s."), lines_added, GetCurrentLogfilePath().c_str());
close(fd);
#ifdef WIN32
delete[] eol;
#endif
}
示例14: InstallDebugAssertOutputHandler
bool wxApp::Initialize(int& argc, wxChar **argv)
{
// Mac-specific
#if wxDEBUG_LEVEL && wxOSX_USE_COCOA_OR_CARBON
InstallDebugAssertOutputHandler( NewDebugAssertOutputHandlerUPP( wxMacAssertOutputHandler ) );
#endif
/*
Cocoa supports -Key value options which set the user defaults key "Key"
to the value "value" Some of them are very handy for debugging like
-NSShowAllViews YES. Cocoa picks these up from the real argv so
our removal of them from the wx copy of it does not affect Cocoa's
ability to see them.
We basically just assume that any "-NS" option and its following
argument needs to be removed from argv. We hope that user code does
not expect to see -NS options and indeed it's probably a safe bet
since most user code accepting options is probably using the
double-dash GNU-style syntax.
*/
for(int i=1; i < argc; ++i)
{
static const wxChar *ARG_NS = wxT("-NS");
if( wxStrncmp(argv[i], ARG_NS, wxStrlen(ARG_NS)) == 0 )
{
// Only eat this option if it has an argument
if( (i + 1) < argc )
{
memmove(argv + i, argv + i + 2, (argc-i-1)*sizeof(wxChar*));
argc -= 2;
// drop back one position so the next run through the loop
// reprocesses the argument at our current index.
--i;
}
}
}
if ( !wxAppBase::Initialize(argc, argv) )
return false;
#if wxUSE_INTL
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif
// these might be the startup dirs, set them to the 'usual' dir containing the app bundle
wxString startupCwd = wxGetCwd() ;
if ( startupCwd == wxT("/") || startupCwd.Right(15) == wxT("/Contents/MacOS") )
{
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle() ) ;
CFURLRef urlParent = CFURLCreateCopyDeletingLastPathComponent( kCFAllocatorDefault , url ) ;
CFRelease( url ) ;
CFStringRef path = CFURLCopyFileSystemPath ( urlParent , kCFURLPOSIXPathStyle ) ;
CFRelease( urlParent ) ;
wxString cwd = wxCFStringRef(path).AsString(wxLocale::GetSystemEncoding());
wxSetWorkingDirectory( cwd ) ;
}
return true;
}
示例15: selFont
void wxMetafileDCImpl::DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent, wxCoord *externalLeading,
const wxFont *theFont) const
{
const wxFont *fontToUse = theFont;
if (!fontToUse)
fontToUse = &m_font;
ScreenHDC dc;
SelectInHDC selFont(dc, GetHfontOf(*fontToUse));
SIZE sizeRect;
TEXTMETRIC tm;
::GetTextExtentPoint32(dc, WXSTRINGCAST string, wxStrlen(WXSTRINGCAST string), &sizeRect);
::GetTextMetrics(dc, &tm);
if ( x )
*x = sizeRect.cx;
if ( y )
*y = sizeRect.cy;
if ( descent )
*descent = tm.tmDescent;
if ( externalLeading )
*externalLeading = tm.tmExternalLeading;
}