Beispiel #1
0
size_t AdbModule::EnumModules(const char *kind,
                              wxArrayString& names, wxArrayString& descs)
{
    names.Empty();
    descs.Empty();

    AdbModule *importer = NULL;
    AdbModule::AdbModuleInfo *info = AdbModule::GetAdbModuleInfo(kind);
    while ( info )
    {
        importer = info->CreateModule();
        if ( importer )
        {
            names.Add(importer->GetName());
            descs.Add(importer->GetFormatDesc());

            importer->DecRef();
            importer = NULL;
        }
        else
        {
            wxLogDebug(_T("Failed to load ADB importer '%s'."), info->name.c_str());
        }

        info = info->next;
    }

    FreeAdbModuleInfo(info);

    return names.GetCount();
}
size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
{
    InitIfNeeded();

    mimetypes.Empty();

    size_t count = m_aTypes.GetCount();
#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 ( size_t n = 0; n < count; n++ )
    {
        // don't return template types from here (i.e. anything containg '*')
        const wxString &type = m_aTypes[n];
        if ( type.Find(wxT('*')) == wxNOT_FOUND )
        {
            mimetypes.Add(type);
        }
    }

    return mimetypes.GetCount();
}
void wxGenericFileDialog::GetPaths( wxArrayString& paths ) const
{
    paths.Empty();
    if (m_list->GetSelectedItemCount() == 0)
    {
        paths.Add( GetPath() );
        return;
    }

    paths.Alloc( m_list->GetSelectedItemCount() );

    wxString dir = m_list->GetDir();
#ifdef __UNIX__
    if (dir != wxT("/"))
#endif
#ifdef __WXWINCE__
        if (dir != wxT("/") && dir != wxT("\\"))
#endif
            dir += wxFILE_SEP_PATH;

    wxListItem item;
    item.m_mask = wxLIST_MASK_TEXT;

    item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
    while ( item.m_itemId != -1 )
    {
        m_list->GetItem( item );
        paths.Add( dir + item.m_text );
        item.m_itemId = m_list->GetNextItem( item.m_itemId,
                                             wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
    }
}
Beispiel #4
0
void wxGenericFileDialog::GetFilenames(wxArrayString& files) const
{
#ifdef __WXGTK__
    m_list->GetFilenames(files);
#else
    files.Empty();
    if (m_list->GetSelectedItemCount() == 0)
    {
        files.Add( GetFilename() );
        return;
    }
    files.Alloc( m_list->GetSelectedItemCount() );

    wxListItem item;
    item.m_mask = wxLIST_MASK_TEXT;

    item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
    while ( item.m_itemId != -1 )
    {
        m_list->GetItem( item );
        files.Add( item.m_text );
        item.m_itemId = m_list->GetNextItem( item.m_itemId,
            wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
    }
#endif
}
Beispiel #5
0
void wxFileDialog::GetPaths(wxArrayString& paths) const
{
#ifdef __WXGTK24__
    if (!gtk_check_version(2,4,0))
    {
        paths.Empty();
        if (gtk_file_chooser_get_select_multiple(GTK_FILE_CHOOSER(m_widget)))
        {
            GSList *gpathsi = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(m_widget));
            GSList *gpaths = gpathsi;
            while (gpathsi)
            {
                wxString file(wxConvFileName->cMB2WX((gchar*) gpathsi->data));
                paths.Add(file);
                g_free(gpathsi->data);
                gpathsi = gpathsi->next;
            }

            g_slist_free(gpaths);
        }
        else
            paths.Add(GetPath());
    }
    else
#endif
        wxGenericFileDialog::GetPaths( paths );
}
void wxFileDialog::GetPaths(wxArrayString& paths) const
{
    paths.Empty();

    wxString dir(m_dir);
    if ( m_dir.Last() != wxT('\\') )
        dir += wxT('\\');

    size_t count = m_fileNames.GetCount();
#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 ( size_t n = 0; n < count; n++ )
    {
        if (wxFileName(m_fileNames[n]).IsAbsolute())
            paths.Add(m_fileNames[n]);
        else
            paths.Add(dir + m_fileNames[n]);
    }
}
Beispiel #7
0
bool TabgroupManager::FindTabgroup(const wxString& tabgroupname, wxArrayString& items)
{
    items.Empty();
    vTabGrps::const_iterator iter = m_tabgroups.begin();
    for(; iter != m_tabgroups.end(); ++iter) {
        if(iter->first == tabgroupname) {
            items = iter->second;
            return true;
        }
    }
    return false;
}
int fn_init(wxLog *ptLogTarget, wxXmlNode *ptCfgNode, wxString &strPluginId)
{
	wxLog *pOldLogTarget;
	int iResult;


	/* set main app's log target */
	pOldLogTarget = wxLog::GetActiveTarget();
	if( pOldLogTarget!=ptLogTarget )
	{
		wxLog::SetActiveTarget(ptLogTarget);
		if( pOldLogTarget!=NULL )
		{
			delete pOldLogTarget;
		}
	}

	/* say hi */
	wxLogMessage(wxT("bootloader openocd plugin init: ") + strPluginId);

	/* remember id */
	plugin_desc.strPluginId = strPluginId;

	/* init the lua state */
	m_ptLuaState = NULL;

	/* clear the command arrays */
	astrInitCfg.Empty();
	astrRunCfg.Empty();

	/* read the config file */
	iResult = readXmlTextArray(ptCfgNode, wxT("Init"), &astrInitCfg);
	if( iResult==0 )
	{
		iResult = readXmlTextArray(ptCfgNode, wxT("Run"), &astrRunCfg);
	}

	return iResult;
}
bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
{
    const wxString strExtensions = m_manager->GetExtension(m_index[0]);
    extensions.Empty();

    // one extension in the space or comma-delimited list
    wxString strExt;
    wxString::const_iterator end = strExtensions.end();
#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 ( wxString::const_iterator p = strExtensions.begin(); /* nothing */; ++p )
    {
        if ( p == end || *p == wxT(' ') || *p == wxT(',') )
        {
            if ( !strExt.empty() )
            {
                extensions.Add(strExt);
                strExt.Empty();
            }
            //else: repeated spaces
            // (shouldn't happen, but it's not that important if it does happen)

            if ( p == end )
                break;
        }
        else if ( *p == wxT('.') )
        {
            // remove the dot from extension (but only if it's the first char)
            if ( !strExt.empty() )
            {
                strExt += wxT('.');
            }
            //else: no, don't append it
        }
        else
        {
            strExt += *p;
        }
    }

    return true;
}
Beispiel #10
0
// TODO this function is half implemented
bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
{
    if ( m_ext.empty() ) {
        // the only way to get the list of extensions from the file type is to
        // scan through all extensions in the registry - too slow...
        return false;
    }
    else {
        extensions.Empty();
        extensions.Add(m_ext);

        // it's a lie too, we don't return _all_ extensions...
        return true;
    }
}
Beispiel #11
0
void wxFileDialog::GetPaths (
  wxArrayString&                    rasPaths
) const
{
    wxString                        sDir(m_dir);
    size_t                          nCount = m_fileNames.GetCount();

    rasPaths.Empty();
    if (m_dir.Last() != _T('\\'))
        sDir += _T('\\');

    for ( size_t n = 0; n < nCount; n++ )
    {
        rasPaths.Add(sDir + m_fileNames[n]);
    }
} // end of wxFileDialog::GetPaths
Beispiel #12
0
void wxFileDialog::GetPaths(wxArrayString& paths) const
{
    paths.Empty();

    wxString dir(m_dir);
    if ( m_dir.Last() != wxT('\\') )
        dir += wxT('\\');

    size_t count = m_fileNames.GetCount();
    for ( size_t n = 0; n < count; n++ )
    {
        if (wxFileName(m_fileNames[n]).IsAbsolute())
            paths.Add(m_fileNames[n]);
        else
            paths.Add(dir + m_fileNames[n]);
    }
}
Beispiel #13
0
size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
{
    InitIfNeeded();

    mimetypes.Empty();

    size_t count = m_aTypes.GetCount();
    for ( size_t n = 0; n < count; n++ )
    {
        // don't return template types from here (i.e. anything containg '*')
        const wxString &type = m_aTypes[n];
        if ( type.Find(wxT('*')) == wxNOT_FOUND )
        {
            mimetypes.Add(type);
        }
    }

    return mimetypes.GetCount();
}
Beispiel #14
0
void wxGtkFileChooser::GetPaths( wxArrayString& paths ) const
{
    paths.Empty();
    if ( gtk_file_chooser_get_select_multiple( m_widget ) )
    {
        GSList *gpathsi = gtk_file_chooser_get_filenames( m_widget );
        GSList *gpaths = gpathsi;
        while ( gpathsi )
        {
            wxString file( wxConvFileName->cMB2WX( ( gchar* ) gpathsi->data ) );
            paths.Add( file );
            g_free( gpathsi->data );
            gpathsi = gpathsi->next;
        }

        g_slist_free( gpaths );
    }
    else
        paths.Add( GetPath() );
}
Beispiel #15
0
void wxGtkFileChooser::GetPaths( wxArrayString& paths ) const
{
    paths.Empty();
    if ( gtk_file_chooser_get_select_multiple( m_widget ) )
    {
        GSList *gpathsi = gtk_file_chooser_get_filenames( m_widget );
        GSList *gpaths = gpathsi;
        while ( gpathsi )
        {
            wxString file(wxString::FromUTF8(static_cast<gchar *>(gpathsi->data)));
            paths.Add( file );
            g_free( gpathsi->data );
            gpathsi = gpathsi->next;
        }

        g_slist_free( gpaths );
    }
    else
        paths.Add( GetPath() );
}
Beispiel #16
0
bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
{
    const wxString strExtensions = m_manager->GetExtension(m_index[0]);
    extensions.Empty();

    // one extension in the space or comma-delimited list
    wxString strExt;
    wxString::const_iterator end = strExtensions.end();
    for ( wxString::const_iterator p = strExtensions.begin(); /* nothing */; ++p )
    {
        if ( p == end || *p == wxT(' ') || *p == wxT(',') )
        {
            if ( !strExt.empty() )
            {
                extensions.Add(strExt);
                strExt.Empty();
            }
            //else: repeated spaces
            // (shouldn't happen, but it's not that important if it does happen)

            if ( p == end )
                break;
        }
        else if ( *p == wxT('.') )
        {
            // remove the dot from extension (but only if it's the first char)
            if ( !strExt.empty() )
            {
                strExt += wxT('.');
            }
            //else: no, don't append it
        }
        else
        {
            strExt += *p;
        }
    }

    return true;
}
void FILEDIALOG::GetFilenames(wxArrayString& files) const
{
   files.Empty();
   if (m_list->GetSelectedItemCount() == 0)
   {
      files.Add( GetFilename() );
      return;
   }
   files.Alloc( m_list->GetSelectedItemCount() );
   
   wxListItem item;
   item.m_mask = wxLIST_MASK_TEXT;
   
   item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
   while ( item.m_itemId != -1 )
   {
      m_list->GetItem( item );
      files.Add( item.m_text );
      item.m_itemId = m_list->GetNextItem( item.m_itemId,
                                          wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
   }
}
Beispiel #18
0
 virtual size_t GetGroupNames(wxArrayString& names) const
    { names.Empty(); return 0; }
/**
 * Calculates the checksums from the given stream.
 *
 * @param  in         Input stream from which the data will be extracted to
 *                    compute the checksum. The data are extracted until the end
 *                    of the stream is reached.
 * @param  checksums  Array of checksums to calculate.
 * @param  sumValues  The calculated values of the checksums from the input
 *                    stream. The array is erased first before adding results.
 *                    On success <CODE>ArrayChecksum.GetCount() == sumValues.GetCount()</CODE>,
 *                    on failure, <CODE>sumValues</CODE> should be empty.
 * @return <UL>
 *           <LI><CODE>Ok</CODE> if the checksum has been successfully calculated.</Li>
 *           <LI><CODE>ReadError</CODE> if a read error has occured.</LI>
 *           <LI><CODE>Canceled</CODE> if the user has canceled the calculation.</LI>
 *         </UL>
 */
ChecksumCalculator::State ChecksumCalculator::calculate(wxInputStream& in,
                                                 const ArrayChecksum& checksums,
                                                       wxArrayString& sumValues)
{
  // Check if the input stream is valid.
  if (!in.IsOk())
    return ReadError;
  
  // Check if at least a checksum instance is OK.
  bool aInstanceOK = false;
  size_t i = 0;
  size_t s = checksums.GetCount();
  while (!aInstanceOK && i < s)
    if (checksums[i] != NULL)
      aInstanceOK = true;
    else
      i++;
  if (!aInstanceOK)
    return ReadError;
  
  // Initializes the buffer.
  const size_t bufSize = getBufferSize();
  wxByte* buff = new wxByte[bufSize];

  // Calculating the checksum.
  ChecksumProgress* p = getChecksumProgress();
  bool canceled = false;
  size_t read;
  wxStreamError lastError = wxSTREAM_NO_ERROR;
  s = checksums.GetCount();
  for (i = 0; i < s; i++)
    if (checksums[i] != NULL)
      checksums[i]->reset();
  while (!canceled && !in.Eof() && lastError == wxSTREAM_NO_ERROR)
  {
    in.Read(buff, bufSize);
    read = in.LastRead();
    if (read > 0 && read <= bufSize)
    {
      for (i = 0; i < s; i++)
        if (checksums[i] != NULL)
          checksums[i]->update(buff, read);
      if (p != NULL)
        p->update(read, canceled);
    }
    lastError = in.GetLastError();
  }

  // Cleans-up the memory
  delete[] buff;
  
  if (canceled)
    return CanceledByUser;
  
  if (lastError != wxSTREAM_NO_ERROR && lastError != wxSTREAM_EOF)
    return ReadError;
    
  sumValues.Empty();
  for (i = 0; i < s; i++)
    if (checksums[i] != NULL)
      sumValues.Add(checksums[i]->getValue());
    else
      sumValues.Add(wxEmptyString);

  return Ok;
}