本文整理汇总了C++中wxString::Right方法的典型用法代码示例。如果您正苦于以下问题:C++ wxString::Right方法的具体用法?C++ wxString::Right怎么用?C++ wxString::Right使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxString
的用法示例。
在下文中一共展示了wxString::Right方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportMIDI
bool ImportMIDI(wxString fName, NoteTrack * dest)
{
if (fName.Length() <= 4){
wxMessageBox( _("Could not open file ") + fName + _(": Filename too short."));
return false;
}
bool is_midi = false;
if (fName.Right(4).CmpNoCase(wxT(".mid")) == 0)
is_midi = true;
else if(fName.Right(4).CmpNoCase(wxT(".gro")) != 0) {
wxMessageBox( _("Could not open file ") + fName + _(": Incorrect filetype."));
return false;
}
wxFFile mf(fName, wxT("rb"));
if (!mf.IsOpened()) {
wxMessageBox( _("Could not open file ") + fName + wxT("."));
return false;
}
Alg_seq_ptr new_seq = new Alg_seq(fName.mb_str(), is_midi);
//Should we also check if(seq->tracks() == 0) ?
if(new_seq->get_read_error() == alg_error_open){
wxMessageBox( _("Could not open file ") + fName + wxT("."));
mf.Close();
return false;
}
dest->SetSequence(new_seq);
mf.Close();
return true;
}
示例2: ImportMIDI
bool ImportMIDI(wxString fName, NoteTrack * dest)
{
if (fName.Length() <= 4){
wxMessageBox( _("Could not open file ") + fName + _(": Filename too short."));
return false;
}
bool is_midi = false;
if (fName.Right(4).CmpNoCase(wxT(".mid")) == 0 || fName.Right(5).CmpNoCase(wxT(".midi")) == 0)
is_midi = true;
else if(fName.Right(4).CmpNoCase(wxT(".gro")) != 0) {
wxMessageBox( _("Could not open file ") + fName + _(": Incorrect filetype."));
return false;
}
wxFFile mf(fName, wxT("rb"));
if (!mf.IsOpened()) {
wxMessageBox( _("Could not open file ") + fName + wxT("."));
return false;
}
double offset = 0.0;
Alg_seq_ptr new_seq = new Alg_seq(fName.mb_str(), is_midi, &offset);
//Should we also check if(seq->tracks() == 0) ?
if(new_seq->get_read_error() == alg_error_open){
wxMessageBox( _("Could not open file ") + fName + wxT("."));
mf.Close();
delete new_seq;
return false;
}
dest->SetSequence(new_seq);
dest->SetOffset(offset);
wxString trackNameBase = fName.AfterLast(wxFILE_SEP_PATH).BeforeLast('.');
dest->SetName(trackNameBase);
mf.Close();
// the mean pitch should be somewhere in the middle of the display
Alg_iterator iterator(new_seq, false);
iterator.begin();
// for every event
Alg_event_ptr evt;
int note_count = 0;
int pitch_sum = 0;
while ((evt = iterator.next())) {
// if the event is a note
if (evt->get_type() == 'n') {
Alg_note_ptr note = (Alg_note_ptr) evt;
pitch_sum += (int) note->pitch;
note_count++;
}
}
int mean_pitch = (note_count > 0 ? pitch_sum / note_count : 60);
// initial track is about 27 half-steps high; if bottom note is C,
// then middle pitch class is D. Round mean_pitch to the nearest D:
int mid_pitch = ((mean_pitch - 2 + 6) / 12) * 12 + 2;
dest->SetBottomNote(mid_pitch - 14);
return true;
}
示例3: RenameFile
bool RenameFile(wxWindow* parent, wxString dir, wxString from, wxString to)
{
if (dir.Right(1) != _T("\\") && dir.Right(1) != _T("/"))
dir += wxFileName::GetPathSeparator();
#ifdef __WXMSW__
to = to.Left(255);
if ((to.Find('/') != -1) ||
(to.Find('\\') != -1) ||
(to.Find(':') != -1) ||
(to.Find('*') != -1) ||
(to.Find('?') != -1) ||
(to.Find('"') != -1) ||
(to.Find('<') != -1) ||
(to.Find('>') != -1) ||
(to.Find('|') != -1))
{
wxMessageBox(_("Filenames may not contain any of the following characters: / \\ : * ? \" < > |"), _("Invalid filename"), wxICON_EXCLAMATION);
return false;
}
SHFILEOPSTRUCT op;
memset(&op, 0, sizeof(op));
from = dir + from + _T(" ");
from.SetChar(from.Length() - 1, '\0');
op.pFrom = from;
to = dir + to + _T(" ");
to.SetChar(to.Length()-1, '\0');
op.pTo = to;
op.hwnd = (HWND)parent->GetHandle();
op.wFunc = FO_RENAME;
op.fFlags = FOF_ALLOWUNDO;
return SHFileOperation(&op) == 0;
#else
if ((to.Find('/') != -1) ||
(to.Find('*') != -1) ||
(to.Find('?') != -1) ||
(to.Find('<') != -1) ||
(to.Find('>') != -1) ||
(to.Find('|') != -1))
{
wxMessageBox(_("Filenames may not contain any of the following characters: / * ? < > |"), _("Invalid filename"), wxICON_EXCLAMATION);
return false;
}
return wxRename(dir + from, dir + to) == 0;
#endif
}
示例4: Replace
bool EDA_ITEM::Replace( wxFindReplaceData& aSearchData, wxString& aText )
{
wxCHECK_MSG( IsReplaceable(), false,
wxT( "Attempt to replace text in <" ) + GetClass() + wxT( "> item." ) );
wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
aSearchData.GetFindString() :
aSearchData.GetFindString().Upper() );
if( result == wxNOT_FOUND )
return false;
wxString prefix = aText.Left( result );
wxString suffix;
if( aSearchData.GetFindString().length() + result < aText.length() )
suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ),
GetChars( suffix ) );
aText = prefix + aSearchData.GetReplaceString() + suffix;
return true;
}
示例5:
void
SimpleFrameClass::Print (int x, int y, wxString &Value)
{
int From, To, Length, xend;
// Sanity checking. Abort if the string will be completely
// off the screen. The usual case is that everthing will be
// fine and on-screen, so we do a quick check for that case.
if (y < 0 || y >= RowsToUse)
return;
Length = Value.Length ();
xend = x + Length;
if (x < 0 || xend > TELEMETRY_COLUMNS)
{
// Perhaps it's completely off-screen!
if (xend <= 0 || x >= TELEMETRY_COLUMNS)
return;
// No, at least partially on-screen.
if (xend > TELEMETRY_COLUMNS)
{
Length -= (xend - TELEMETRY_COLUMNS);
Value = Value.Left (Length);
}
if (x < 0)
{
Length += x;
Value = Value.Right (Length);
}
}
// All checked and/or clipped. Output it.
From = TextCtrl->XYToPosition (x, y);
To = From + Length;
TextCtrl->Replace (From, To, Value);
}
示例6: PathExpand
bool PathExpand(wxString& cmd)
{
#ifndef __WXMSW__
if (cmd[0] == '/')
return true;
#else
if (cmd[0] == '\\')
// UNC or root of current working dir, whatever that is
return true;
if (cmd.Len() > 2 && cmd[1] == ':')
// Absolute path
return true;
#endif
// Need to search for program in $PATH
wxString path;
if (!wxGetEnv(_T("PATH"), &path))
return false;
wxString full_cmd;
bool found = wxFindFileInPath(&full_cmd, path, cmd);
#ifdef __WXMSW__
if (!found && cmd.Right(4).Lower() != _T(".exe"))
{
cmd += _T(".exe");
found = wxFindFileInPath(&full_cmd, path, cmd);
}
#endif
if (!found)
return false;
cmd = full_cmd;
return true;
}
示例7: GetLocalFile
wxString CUpdater::GetLocalFile( build const& b, bool allow_existing )
{
wxString const fn = GetFilename( b.url_ );
wxString const dl = GetDownloadDir().GetPath();
int i = 1;
wxString f = dl + fn;
while( CLocalFileSystem::GetFileType(f) != CLocalFileSystem::unknown && (!allow_existing || !VerifyChecksum(f, b.size_, b.hash_))) {
if( ++i > 99 ) {
return _T("");
}
wxString ext;
int pos;
if( !fn.Right(8).CmpNoCase(_T(".tar.bz2")) ) {
pos = fn.size() - 8;
}
else {
pos = fn.Find('.', true);
}
if( pos == -1 ) {
f = dl + fn + wxString::Format(_T(" (%d)"), i);
}
else {
f = dl + fn.Left(pos) + wxString::Format(_T(" (%d)"), i) + fn.Mid(pos);
}
}
return f;
}
示例8: IsCmd
bool ArcApp::IsCmd(const wxString& cmd,
const wxString& params,
const wxChar *description)
{
// count the expected parameters (actually count the spaces and brackets)
size_t expected = params.empty() ? 1 : 2;
size_t brackets = 0;
for (wxString::size_type i = 0; params[i]; ++i)
if (params[i] == _T(' '))
++expected;
else if (params[i] == _T('['))
++brackets;
// add the description of the cmd to m_availCmds to be used in the usage
m_availCmds << wxString::Format(_T(" %-8s ARCHIVE %-12s %s\n"),
cmd.c_str(), params.c_str(), description);
// if this is the command to execute...
if (m_help || !m_errMsg.empty() || m_cmd != cmd)
return false;
m_validCmd = true;
size_t num = m_args.size() + (m_archive.empty() ? 0 : 1);
if (num < expected - brackets ||
(params.Right(3) != _T("...") && num > expected)) {
m_errMsg = _T("wrong number of arguments for '") + cmd + _T("'");
return false;
}
return true;
}
示例9: ToFile
bool Bitmap::ToFile(wxString file)
{
bool res = false;
if (file.Right(4) == wxT(".bmp"))
res = m_bmp.SaveFile(file, wxBITMAP_TYPE_BMP);
else if (file.Right(4) == wxT(".xpm"))
res = m_bmp.SaveFile(file, wxBITMAP_TYPE_XPM);
else if (file.Right(4) == wxT(".jpg"))
res = m_bmp.SaveFile(file, wxBITMAP_TYPE_JPEG);
else
{
if (file.Right(4) != wxT(".png"))
file = file + wxT(".png");
res = m_bmp.SaveFile(file, wxBITMAP_TYPE_PNG);
}
return res;
}
示例10: IsTimeStamp
bool CDirList::IsTimeStamp(const wxString &s)
{
bool bRtn = true;
if(s.Len() != 15)
{
bRtn = false;
}
else if(s.GetChar(8) != '_')
{
bRtn = false;
}
else if(!nwxString::IsInteger(s.Left(8),false))
{
bRtn = false;
}
else if(!nwxString::IsInteger(s.Right(6),false))
{
bRtn = false;
}
else
{
#define BETWEEN(n,min,max) ((n >= min) && (n <= max))
int nY = atoi(s.Left(4).utf8_str());
int nM = atoi(s.Mid(4,2).utf8_str());
int nD = atoi(s.Mid(6,2).utf8_str());
int nHH = atoi(s.Mid(9,2).utf8_str());
int nMM = atoi(s.Mid(11,2).utf8_str());
int nSS = atoi(s.Mid(13,2).utf8_str());
// check year to see if newer than this software
if( !BETWEEN(nY,2011,2099) )
{
bRtn = false;
}
else if( !BETWEEN(nM,1,12) )
{
bRtn = false;
}
else if( !BETWEEN(nD,1,MaxDayOfMonth(nY,nM)) )
{
bRtn = false;
}
else if( !BETWEEN(nHH,0,23) )
{
bRtn = false;
}
else if(! BETWEEN(nMM,0,59) )
{
bRtn = false;
}
else if(! BETWEEN(nSS,0,59) )
{
bRtn = false;
}
}
#undef BETWEEN
return bRtn;
}
示例11: FromString
wxFileName xsDirNamePropIO::FromString(const wxString& value)
{
if( value.Right(1) != wxFileName::GetPathSeparator() )
{
return wxFileName( value + wxFileName::GetPathSeparator() );
}
else
return wxFileName( value );
}
示例12: fn
void BM2CMP_FRAME::OnExportPcbnew()
{
wxFileName fn( m_ConvertedFileName );
wxString path = fn.GetPath();
if( path.IsEmpty() || !wxDirExists( path ) )
path = ::wxGetCwd();
wxString msg = _( "Footprint file (*.kicad_mod)|*.kicad_mod" );
wxFileDialog fileDlg( this, _( "Create a footprint file for PcbNew" ),
path, wxEmptyString,
msg,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = fileDlg.ShowModal();
if( diag != wxID_OK )
return;
m_ConvertedFileName = fileDlg.GetPath();
if( m_ConvertedFileName.size() > 1
&& m_ConvertedFileName.Right( 10 ).compare( _( ".kicad_mod") ) )
{
if( m_ConvertedFileName.Right( 1 ).compare( _( "." ) ) )
m_ConvertedFileName += _( ".kicad_mod" );
else
m_ConvertedFileName += _( "kicad_mod" );
}
FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
if( outfile == NULL )
{
wxString msg;
msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() );
wxMessageBox( msg );
return;
}
ExportFile( outfile, PCBNEW_KICAD_MOD );
fclose( outfile );
}
示例13: OnDrop
void EnviroFrame::OnDrop(const wxString &str)
{
vtString utf8 = (const char *) str.ToUTF8();
if (!str.Right(4).CmpNoCase(_T(".kml")))
{
g_App.ImportModelFromKML(utf8);
}
else
LoadLayer(utf8);
}
示例14: AdjustLine
bool SearchThread::AdjustLine(wxString& line, int& pos, const wxString& findString)
{
// adjust the current line
if(line.Length() - (pos + findString.Length()) >= findString.Length()) {
line = line.Right(line.Length() - (pos + findString.Length()));
pos += (int)findString.Length();
return true;
} else {
return false;
}
}
示例15: GetAnchor
wxString wxFileSystemHandler::GetAnchor(const wxString& location) const
{
wxChar c;
int l = location.length();
for (int i = l-1; i >= 0; i--) {
c = location[i];
if (c == wxT('#')) return location.Right(l-i-1);
else if ((c == wxT('.')) || (c == wxT('/')) || (c == wxT('\\')) || (c == wxT(':'))) return wxEmptyString;
}
return wxEmptyString;
}