Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
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;
}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
wxFileName xsDirNamePropIO::FromString(const wxString& value)
{
	if( value.Right(1) != wxFileName::GetPathSeparator() )
	{
		return wxFileName( value + wxFileName::GetPathSeparator() );
	}
	else
		return wxFileName( value );
}
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 );
}
void BM2CMP_FRAME::OnExportEeschema()
{
    wxFileName  fn( m_ConvertedFileName );
    wxString    path = fn.GetPath();

    if( path.IsEmpty() || !wxDirExists(path) )
        path = ::wxGetCwd();

    wxString     msg = _( "Schematic lib file (*.lib)|*.lib" );

    wxFileDialog fileDlg( this, _( "Create a lib file for Eeschema" ), 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( 4 ).compare( _( ".lib") ) )
    {
        if( m_ConvertedFileName.Right( 1 ).compare( _( "." ) ) )
            m_ConvertedFileName += _( ".lib" );
        else
            m_ConvertedFileName += _( "lib" );
    }

    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, EESCHEMA_FMT );
    fclose( outfile );
}
Exemplo n.º 14
0
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);
}
Exemplo n.º 15
0
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;
    }
}
Exemplo n.º 16
0
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;
}
Exemplo n.º 17
0
bool ProgramExists(const wxString& editor)
{
	if (wxFileName::FileExists(editor))
		return true;

#ifdef __WXMAC__
	if (editor.Right(4) == _T(".app") && wxFileName::DirExists(editor))
		return true;
#endif

	return false;
}
Exemplo n.º 18
0
void AssFile::InsertAttachment(wxString filename) {
	AssEntryGroup group = ENTRY_GRAPHIC;

	wxString ext = filename.Right(4).Lower();
	if (ext == ".ttf" || ext == ".ttc" || ext == ".pfb")
		group = ENTRY_FONT;

	std::unique_ptr<AssAttachment> newAttach(new AssAttachment(wxFileName(filename).GetFullName(), group));
	newAttach->Import(filename);

	InsertLine(newAttach.release());
}
Exemplo n.º 19
0
void Function::SetContents(wxString contents)
{
    if(contents.Left(1) == '\n')
    {
        contents.Remove(0, 1);
    }
    if(contents.Right(1) == '\n')
    {
        contents.Remove(contents.Len() -1, 1);
    }
    m_functionContents = contents;
}
Exemplo n.º 20
0
wxString CommandManager::GetKey(wxString label)
{
   int loc = -1;

   loc = label.Find(wxT('\t'));
   if (loc == -1)
      loc = label.Find(wxT("\\t"));

   if (loc == -1)
      return wxT("");

   return label.Right(label.Length() - (loc+1));
}
bool MicroDVDSubtitleFormat::CanReadFile(wxString const& filename) const {
	// Return false immediately if extension is wrong
	if (filename.Right(4).Lower() != ".sub") return false;

	// Since there is an infinity of .sub formats, load first line and check if it's valid
	TextFileReader file(filename);
	if (file.HasMoreLines()) {
		wxRegEx exp("^[\\{\\[]([0-9]+)[\\}\\]][\\{\\[]([0-9]+)[\\}\\]](.*)$", wxRE_ADVANCED);
		return exp.Matches(file.ReadLineFromFile());
	}

	return false;
}
Exemplo n.º 22
0
static bool needsQuoting(wxString &value, bool forTypes)
{
	// Is it a number?
	if (value.IsNumber())
		return true;
	else
	{
		// certain types should not be quoted even though it contains a space. Evilness.
		wxString valNoArray;
		if (forTypes && value.Right(2) == wxT("[]"))
			valNoArray = value.Mid(0, value.Len() - 2);
		else
			valNoArray = value;

		if (forTypes &&
		        (!valNoArray.CmpNoCase(wxT("character varying")) ||
		         !valNoArray.CmpNoCase(wxT("\"char\"")) ||
		         !valNoArray.CmpNoCase(wxT("bit varying")) ||
		         !valNoArray.CmpNoCase(wxT("double precision")) ||
		         !valNoArray.CmpNoCase(wxT("timestamp without time zone")) ||
		         !valNoArray.CmpNoCase(wxT("timestamp with time zone")) ||
		         !valNoArray.CmpNoCase(wxT("time without time zone")) ||
		         !valNoArray.CmpNoCase(wxT("time with time zone")) ||
		         !valNoArray.CmpNoCase(wxT("\"trigger\"")) ||
		         !valNoArray.CmpNoCase(wxT("\"unknown\""))))
			return false;

		int pos = 0;
		while (pos < (int)valNoArray.length())
		{
			wxChar c = valNoArray.GetChar(pos);
			if (!((pos > 0) && (c >= '0' && c <= '9')) &&
			        !(c >= 'a' && c  <= 'z') &&
			        !(c == '_'))
			{
				return true;
			}
			pos++;
		}
	}

	// is it a keyword?
	const ScanKeyword *sk = ScanKeywordLookup(value.ToAscii());
	if (!sk)
		return false;
	if (sk->category == UNRESERVED_KEYWORD)
		return false;
	if (forTypes && sk->category == COL_NAME_KEYWORD)
		return false;
	return true;
}
Exemplo n.º 23
0
bool CHideWin::HaveExt( wxString str, wxString ext )
{
    ext.Trim( false );
    ext.Trim( true );

    if ( ext.IsEmpty() )
        return false;

    if ( str.Length() < ext.Length() )
    {
        return false;
    }

    return str.Right( ext.Length() ) == ext;

}
Exemplo n.º 24
0
int wxListBox::FindString(const wxString& s, bool bCase) const
{
    if ( s.Right(1) == wxT("*") )
    {
        wxString search = s.Left( s.length() - 1 ) ;
        int len = search.length() ;
        Str255 s1 , s2 ;
        wxMacStringToPascal( search , s2 ) ;

        for ( unsigned int i = 0 ; i < m_noItems ; ++ i )
        {
            wxMacStringToPascal( m_stringArray[i].Left( len ) , s1 ) ;

            if ( EqualString( s1 , s2 , bCase , false ) )
                return (int)i ;
        }
        if ( s.Left(1) == wxT("*") && s.length() > 1 )
        {
            wxString st = s ;
            st.MakeLower() ;
            for ( unsigned int i = 0 ; i < m_noItems ; ++i )
            {
                if (GetString(i).Lower().Matches(st))
                    return (int)i ;
            }
        }

    }
    else
    {
        Str255 s1 , s2 ;

        wxMacStringToPascal( s , s2 ) ;

        for ( unsigned int i = 0 ; i < m_noItems ; ++ i )
        {
            wxMacStringToPascal( m_stringArray[i] , s1 ) ;

            if ( EqualString( s1 , s2 , bCase , false ) )
                return (int)i ;
        }
    }

    return wxNOT_FOUND;
}
/////////////
// Read file
void ASSSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
    using namespace std;

    // Reader
    TextFileReader file(filename,encoding);
    bool IsSSA = filename.Right(4).Lower() == _T(".ssa");

    // Parse file
    wxString curgroup;
    int lasttime = -1;
    while (file.HasMoreLines()) {
        // Reads line
        wxString wxbuffer = file.ReadLineFromFile();

        // Convert v4 styles to v4+ styles
        if (wxbuffer.Lower() == _T("[v4 styles]")) {
            wxbuffer = _T("[V4+ Styles]");
        }

        // Set group
        if (wxbuffer[0] == _T('[')) {
            curgroup = wxbuffer;
        }

        // Add line
        try {
            lasttime = AddLine(wxbuffer,curgroup,lasttime,IsSSA);
        }
        catch (const wchar_t *err) {
            Clear();
            throw wxString(_T("Error processing line: ")) + wxbuffer + _T(": ") + wxString(err);
        }
        catch (...) {
            Clear();
            throw wxString(_T("Error processing line: ")) + wxbuffer;
        }
    }

    // Set ASS
    SetIsASS(!IsSSA);
}
//////////////
// Write file
void ASSSubtitleFormat::WriteFile(wxString _filename,wxString encoding) {
    // Open file
    TextFileWriter file(_filename,encoding);
    bool ssa = _filename.Right(4).Lower() == _T(".ssa");

    // Write lines
    using std::list;
    AssEntry *entry;
    for (list<AssEntry*>::iterator cur=Line->begin(); cur!=Line->end();) {
        // Get entry
        entry = *cur;

        // Only add a line break if there is a next line
        cur++;
        bool lineBreak = cur != Line->end();

        // Write line
        if (ssa) file.WriteLineToFile(entry->GetSSAText(),lineBreak);
        else file.WriteLineToFile(entry->GetEntryData(),lineBreak);
    }
}
Exemplo n.º 27
0
// Load the DXF file.  If the zlib support is compiled in wxWidgets,
// supports also the ".dxf.gz" gzip compressed files.
void TestGLCanvas::LoadDXF(const wxString& filename)
{
    wxFileInputStream stream(filename);
    if (stream.IsOk())
#if wxUSE_ZLIB
    {
        if (filename.Right(3).Lower() == wxT(".gz"))
        {
            wxZlibInputStream zstream(stream);
            m_renderer.Load(zstream);
        } else
        {
            m_renderer.Load(stream);
        }
    }
#else
    {
        m_renderer.Load(stream);
    }
#endif
}
Exemplo n.º 28
0
wxString CDTMF::processDCS(const wxString& command) const
{
	unsigned int len = command.Len();

	wxChar c = command.GetChar(len - 1U);
	if (c == wxT('A') || c == wxT('B') || c == wxT('C') || c == wxT('D')) {
		if (len < 2U || len > 4U)
			return wxEmptyString;

		unsigned long n;
		command.Left(len - 1U).ToULong(&n);
		if (n == 0UL)
			return wxEmptyString;

		wxString out;
		out.Printf(wxT("DCS%03lu%cL"), n, c);
	
		return out;
	} else {
		if (len < 3U || len > 5U)
			return wxEmptyString;

		unsigned long n1;
		command.Left(len - 2U).ToULong(&n1);
		if (n1 == 0UL)
			return wxEmptyString;

		unsigned long n2;
		command.Right(2U).ToULong(&n2);
		if (n2 == 0UL || n2 > 26UL)
			return wxEmptyString;

		c = wxT('A') + n2 - 1UL;

		wxString out;
		out.Printf(wxT("DCS%03lu%cL"), n1, c);
	
		return out;
	}
}
Exemplo n.º 29
0
int KeyBinder::StringToKeyCode(const wxString &keyName)
{

    // a function key ?
    if (keyName.StartsWith(wxT("F")) && keyName.Len() > 1) {

        long n;
        keyName.Right(keyName.Len()-1).ToLong(&n);
        return WXK_F1+n-1;
    }

    // a special key ?
    if (keyName == wxT("BACK")) return WXK_BACK;
    if (keyName == wxT("ENTER")) return WXK_RETURN;
    if (keyName == wxT("RETURN")) return WXK_RETURN;
    if (keyName == wxT("TAB")) return WXK_TAB;
    if (keyName == wxT("ESCAPE")) return WXK_ESCAPE;
    if (keyName == wxT("SPACE")) return WXK_SPACE;
    if (keyName == wxT("DEL") || keyName == wxT("DELETE")) return WXK_DELETE;

    // it should be an ASCII key...
    return (int)keyName.GetChar(0);
}
Exemplo n.º 30
0
/* Function to increment bus label members numbers,
 * i.e. when a text is ending with a number, adds
 * aIncrement to this number
 */
void IncrementLabelMember( wxString& name, int aIncrement )
{
    int  ii, nn;
    long number = 0;

    ii = name.Len() - 1; nn = 0;

    if( !isdigit( name.GetChar( ii ) ) )
        return;

    while( (ii >= 0) && isdigit( name.GetChar( ii ) ) )
    {
        ii--; nn++;
    }

    ii++;   /* digits are starting at ii position */
    wxString litt_number = name.Right( nn );

    if( litt_number.ToLong( &number ) )
    {
        number += aIncrement;
        name.Remove( ii ); name << number;
    }
}