Пример #1
0
bool SjInterfaceBase::ReadFromCache(const wxString& file, wxArrayString& retInfo, unsigned long fileTimestamp)
{
	retInfo.Clear();

	// get key
	wxString key(SjModule::GetUniqueStrId(m_name+file, 0));

	// create file timestamp if not given
	if( fileTimestamp == 0 )
	{
		if( ::wxFileExists(file) )
		{
			size_t fileModTime = ::wxFileModificationTime(file);
			fileTimestamp = (unsigned long)fileModTime;
		}
	}

	// get info from cache as "<timestamp>:<len1>:<val1>:<len2>:<val2>:<len3> ..."
	wxString info(g_tools->m_config->Read("modulecache/" + key, ""));
	if( info.IsEmpty() )
	{
		return FALSE; // not in cache
	}

	// get cache timestamp
	long l;
	if( !info.BeforeFirst(':').ToLong(&l, 10) ) { l = 0; }
	if( (unsigned long)l != fileTimestamp )
	{
		return FALSE; // cache out of date
	}
	info = info.AfterFirst(':');

	// get cache data
	long currLen;
	while( info.BeforeFirst(':').ToLong(&currLen, 10) )
	{
		info = info.AfterFirst(':');

		if( currLen >= (long)info.Len() ) { return FALSE; }
		retInfo.Add(info.Left(currLen));

		info = info.Mid(currLen+1);
	}

	return TRUE;
}
Пример #2
0
//Split (Tokenize) string at specified intervals
	//s == string to split
	//retArray == split up string (out)
	//cpszExp == expression to split at
	//crnStart == start postion to split
	//crnCount == max number of split of strings
	//crbCIComp == true if case insensitive
	void Split( const wxString& s, wxArrayString& retArray,  const wxChar* cpszExp, 
				const size_t& crnStart = 0, const size_t& crnCount = (size_t)-1,
				const bool& crbCIComp = false)
	{
		//sanity checks
		wxASSERT_MSG(cpszExp != NULL, wxT("Invalid value for First Param of wxString::Split (cpszExp)"));
		//wxASSERT_MSG(crnCount >= (size_t)-1, wxT("Invalid value for Third Param of wxString::Split (crnCount)"));

		retArray.Clear();

		size_t  nOldPos = crnStart,	  //Current start position in this string
				nPos = crnStart;	  //Current end position in this string

		wxString szComp,			//this string as-is (if bCIComp is false) or converted to lowercase
				 szExp = cpszExp;   //Expression string, normal or lowercase

		if (crbCIComp)
		{
			szComp = s.Lower();
			szExp.MakeLower();
		}
		else
			szComp = s;

		if(crnCount == (size_t)-1)
		{
		for (; (nPos = szComp.find(szExp, nPos)) != wxString::npos;)//Is there another token in the string
			{
			retArray.Add(Slice(s, nOldPos, nPos)); //Insert the token in the array
			nOldPos = nPos += szExp.Length();//Move up the start slice position
			}
	   
		}
		else
		{
		for (int i = crnCount;
				(nPos = szComp.find(szExp, nPos)) != wxString::npos &&
				i != 0;
					--i)//Is there another token in the string && have we met nCount?
		{
			retArray.Add(Slice(s, nOldPos, nPos)); //Insert the token in the array
			nOldPos = nPos += szExp.Length();//Move up the start slice position
		}
		}
		if (nOldPos != s.Length())
			retArray.Add( Slice(s, nOldPos, s.Length()) ); //Add remaining characters in string
	}
Пример #3
0
/*---------------------------------------------------------------------------*/
void wxSQLBook::GetScripSQL(wxArrayString& array)
{
    long start, end, count;
    wxString str;
    array.Clear();
    start = end = 0;

    count = m_SQLEdit->GetLineCount();

    while (start < count && end != -1)
    {
        str = GetSQLStatementAt(start, end);
        if (!str.IsEmpty())
            array.Add(str);
        start = end + 1;
    }
}
Пример #4
0
bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
{
    mimeTypes.Clear();
    size_t nCount = m_index.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 i = 0; i < nCount; i++)
        mimeTypes.Add(m_manager->m_aTypes[m_index[i]]);

    return true;
}
Пример #5
0
int ecUtils::Chop(const wxString& str, wxArrayString &ar, const wxString& sep,
                  bool bObserveStrings/*=false*/,bool bBackslashQuotes/*=false*/)
{
    ar.Clear();
    
    const wxChar* pszSep = (const wxChar*) sep;
    const wxChar* psz = (const wxChar*) str;
    
    int i=0;
    for(;;){
        // Skip multiple separators
        while(*psz && wxStrchr(pszSep,*psz)){
            psz++;
        }
        if(!*psz){
            return i;
        }
        wxString strTok;
        if(bObserveStrings){
            bool bInString=FALSE;
            do{
                if(*psz == wxT('\\') && bBackslashQuotes && psz[1]){
                    strTok += psz[1];
                    psz++;
                } else if(*psz == wxT('"')){
                    bInString ^= 1;
                } else if (!bInString && *psz && NULL != wxStrchr(pszSep,*psz)) {
                    break;
                } else {
                    strTok+=*psz;
                }
            } while (*++psz);
        } else {
            const wxChar* pszStart=psz;
            do {
                psz++;
            } while (*psz && ! wxStrchr(pszSep,*psz));
            strTok=wxString(pszStart,psz-pszStart);
        }
        ar.Add(strTok);
        i++;
    }
    return ar.GetCount();
}
Пример #6
0
/*static*/
bool TranslationMemoryUpdater::FindFilesInPaths(const wxArrayString& paths,
                                                wxArrayString& files,
                                                const wxString& lang)
{
    bool rv = true;
    
    files.Clear();
    TMUDirTraverser trav(&files, lang);

    for (size_t i = 0; i < paths.GetCount(); i++)
    {
        wxDir dir(paths[i]);
        if (!dir.IsOpened() || dir.Traverse(trav) == (size_t)-1) 
            // return false, but don't terminate, try other directories
            // first:
            rv = false;
    }
    return rv;
}
Пример #7
0
bool wxMySQL::EnumDatabases(wxArrayString & array)
{
	MYSQL_RES * res;
	MYSQL_ROW row;
	array.Clear();
	do
	{
		res = mysql_list_dbs(m_pDB,NULL);
		if(!res) break;
		while(row = mysql_fetch_row(res))
		{
			array.Add(wxString(row[0]));			
		}
		mysql_free_result(res);
	}
	while(false);
	m_LastErrorMessage = mysql_error(m_pDB);
	return true;
}
//---------------------------------------------------------
bool CWKSP_Data_Menu_File::Get(wxArrayString &FileNames, bool bAppend)
{
	if( !bAppend )
	{
		FileNames.Clear();
	}

	if( m_Recent && m_Recent_Count > 0 )
	{
		for(int i=0; i<m_Recent_Count; i++)
		{
			FileNames.Add(m_Recent[i]);
		}

		return( true );
	}

	return( false );
}
Пример #9
0
	void OnChar(wxKeyEvent &evt) {
		if (evt.GetKeyCode()==WXK_TAB) {
			if (debug->CanTalkToGDB()) {
				comp_options.Clear();
				wxString ans = debug->SendCommand("complete ",GetValue());
				while (ans.Contains("\n")) {
					wxString line=ans.BeforeFirst('\n');
					ans=ans.AfterFirst('\n');
					if (line.StartsWith("~\"")) {
						wxString ue=mxUT::UnEscapeString(line.Mid(1));
						while (ue.Len() && (ue.Last()=='\n'||ue.Last()=='\r')) ue.RemoveLast();
						comp_options.Add(ue);
					}
				}
				if (!comp_options.GetCount()) return;
				if (comp_options.GetCount()==1) { SetText(comp_options[0]); return; }
				else {
					wxString common_part=comp_options[0];
					for(unsigned int i=1;i<comp_options.GetCount();i++) { 
						int j=0, l1=comp_options[i].Len(), l2=common_part.Len();
						while (j<l1 && j<l2 && comp_options[i][j]==common_part[j]) j++;
						if (j<l2) common_part=common_part.Mid(0,j);
					}
					if (common_part!=GetValue()) SetValue(common_part);
				}
				wxMenu menu("");
				for(unsigned int i=0;i<comp_options.GetCount();i++)
					menu.Append(wxID_HIGHEST+1000+i, comp_options[i]);
				wxRect r = GetScreenRect();
				PopupMenu(&menu,0,r.height);
			}
		} else if (evt.GetKeyCode()==WXK_UP) {
			if (input_history_pos>0) 
				SetText(input_history[--input_history_pos]);
		} else if (evt.GetKeyCode()==WXK_DOWN) {
			if (input_history_pos+1==input_history.GetCount())
				SetText("");
			else if (input_history_pos+1<input_history.GetCount()) 
				SetText(input_history[++input_history_pos]);
		} else {
			evt.Skip();
		}
	}
Пример #10
0
void MusikScanNewThread::GetMusicDirs( const wxArrayString & aDirs, wxArrayString & aFiles )
{
	aFiles.Clear();
	if ( aDirs.GetCount() > 0 )
	{

		wxString sCurrPath;
		wxCommandEvent evtSetTotalFiles	( wxEVT_COMMAND_MENU_SELECTED, MUSIK_LIBRARY_THREAD_PROG );
		evtSetTotalFiles.SetInt(SET_TOTAL);
		wxCommandEvent ScanNewProgEvt	( wxEVT_COMMAND_MENU_SELECTED, MUSIK_LIBRARY_THREAD_PROG );	
		ScanNewProgEvt.SetInt(SET_CURRENT);
		wxCommandEvent evtSetNewFiles	( wxEVT_COMMAND_MENU_SELECTED, MUSIK_LIBRARY_THREAD_PROG );
		evtSetNewFiles.SetInt(SET_NEW);


		for ( size_t i = 0; i < aDirs.GetCount(); i++ )
		{
			if ( TestDestroy() )
				break;
			else 
			{
					//--- get directory ---//
				int nLastCount = aFiles.GetCount();
				GetMusicDir(  aDirs[i], aFiles );

				//--- do math ---//
				int nTotal		= aFiles.GetCount() - nLastCount;
				evtSetTotalFiles.SetExtraLong( nTotal );
				wxPostEvent( Parent(), evtSetTotalFiles );

				int nCompare	= wxGetApp().Library.GetSongDirCount( sCurrPath );
				int nResult		= nTotal - nCompare;

				//--- post update progress event ---//
				evtSetNewFiles.SetExtraLong( nResult );
				wxPostEvent( Parent(), evtSetNewFiles );
				ScanNewProgEvt.SetExtraLong(i);
				wxPostEvent( Parent(), ScanNewProgEvt );
			}
		}
	}
}
Пример #11
0
bool wxMySQL::EnumTables(wxArrayString & array, wxString wildchar)
{
	MYSQL_RES * res = mysql_list_tables(m_pDB, wildchar);
	MYSQL_ROW row;
	bool success(true);
	array.Clear();	
	do
	{
		if(!res) 
		{
			success = false;
			break;
		}
		while(row = mysql_fetch_row(res)) array.Add(row[0]);
		mysql_free_result(res);
	}
	while(false);
	m_LastErrorMessage = mysql_error(m_pDB);
	return success;
}
Пример #12
0
void CMusikLibrary::GetInfo( const wxArrayString & aList, const PlaylistColumn & ColumnIn, const PlaylistColumn & ColumnOut ,wxArrayString & aReturn, bool bSorted )
{
	aReturn.Clear();
	wxString sInfo;
	wxString query;
	query.Alloc(50 * aList.GetCount()+ 40);
    wxString sColumnOut(wxString::Format(ColumnOut.ColQueryMask,ColumnOut.DBName.c_str()));
    sColumnOut += wxT(" as OutColumn ");
	if(bSorted)
	{
		if( wxGetApp().Prefs.bSortArtistWithoutPrefix && ColumnOut.SortOrder == PlaylistColumn::SortNoCaseNoPrefix)
			query << wxT("select distinct ") << sColumnOut << wxT(",REMPREFIX(") << sColumnOut << wxT(") as RPF from songs where ");
        else
            query = wxT("select distinct ") + sColumnOut + wxT(" from songs where ");
	}
	else
		query = wxT("select distinct ") + sColumnOut + wxT(" from songs where ");
    _Add_IN_ClauseForColumn(query,ColumnIn,aList);
	if(bSorted)
	{
		switch ( ColumnOut.SortOrder )
		{
        case PlaylistColumn::SortNoCase:
		case PlaylistColumn::SortNoCaseNoPrefix:
			query += (wxGetApp().Prefs.bSortArtistWithoutPrefix) ? wxT(" order by RPF collate nocase") 
																 : wxT(" order by OutColumn collate nocase");
			break;

        case PlaylistColumn::SortCase:
			query += wxT(" order by OutColumn");
			break;

        case PlaylistColumn::SortNone:
			break;
		}
	}
	query << wxT(';');
    
    Query(query,aReturn,false);
}
Пример #13
0
void AssStyle::GetEncodings(wxArrayString &encodingStrings) {
	encodingStrings.Clear();
	encodingStrings.Add(wxString("0 - ") + _("ANSI"));
	encodingStrings.Add(wxString("1 - ") + _("Default"));
	encodingStrings.Add(wxString("2 - ") + _("Symbol"));
	encodingStrings.Add(wxString("77 - ") + _("Mac"));
	encodingStrings.Add(wxString("128 - ") + _("Shift_JIS"));
	encodingStrings.Add(wxString("129 - ") + _("Hangeul"));
	encodingStrings.Add(wxString("130 - ") + _("Johab"));
	encodingStrings.Add(wxString("134 - ") + _("GB2312"));
	encodingStrings.Add(wxString("136 - ") + _("Chinese BIG5"));
	encodingStrings.Add(wxString("161 - ") + _("Greek"));
	encodingStrings.Add(wxString("162 - ") + _("Turkish"));
	encodingStrings.Add(wxString("163 - ") + _("Vietnamese"));
	encodingStrings.Add(wxString("177 - ") + _("Hebrew"));
	encodingStrings.Add(wxString("178 - ") + _("Arabic"));
	encodingStrings.Add(wxString("186 - ") + _("Baltic"));
	encodingStrings.Add(wxString("204 - ") + _("Russian"));
	encodingStrings.Add(wxString("222 - ") + _("Thai"));
	encodingStrings.Add(wxString("238 - ") + _("East European"));
	encodingStrings.Add(wxString("255 - ") + _("OEM"));
}
Пример #14
0
// Do serv sends the command back to the script server function,
// and creates a list of response lines to be sent.
int DoSrv( char * pIn )
{
   wxString Str1(pIn);
   Str1.Replace("\r","");
   Str1.Replace("\n","");
   (*pScriptServerFn)( &Str2, &Str1 );
   int l = Str2.Length();
   Str2+= '\n';
   aStr.Clear();
   iSent = -1;
   int iStart = 0;
   int i;
   for(i=0;i<=l;i++)
   {
      if( Str2[i] == '\n' )
      {
         aStr.Add( Str2.Mid( iStart, i-iStart) );
         iStart = i+1;
      }
   }
//   wxLogDebug("Added %i Strings", aStr.GetCount());
   return 1;
}
Пример #15
0
bool myStyleElement::GetCSS(wxArrayString& cssElement, bool bAppend) {
    wxString sText;

    if (!bAppend)
        cssElement.Clear();

    if (m_attrArray.Count() > 0) {
        if (!m_sCSSComment.IsEmpty()) {
            sText = wxT("/** ") + m_sCSSComment + wxT(" **/");
            cssElement.Add(sText);
        }

        sText = m_sCSSTag;

        if (!m_sCSSClass.IsEmpty()) {
            sText += wxT(".") + m_sCSSClass;
        }

        if (!m_sCSSId.IsEmpty()) {
            sText += wxT("#") + m_sCSSId;
        }

        sText += wxT(" {");

        cssElement.Add( sText );

        for (size_t index = 0 ; index < m_attrArray.Count() ; index++) {
            wxString sAttrPair = wxT("\t") + *(m_attrArray[index]);

            cssElement.Add( sAttrPair );
        }

        cssElement.Add(wxT("}"));
    }

    return (cssElement.Count() > 0)?true:false;
}
    /*! \brief Run the dialogue.
     *
     * \param aItems wxArrayString&
     * \return bool
     *
     */
bool wxsImageTreeEditorDlg::Execute(wxArrayString &aItems)
{
    int             i, n;
    int             jv, j1, j2, j3, j4;
    wxColor         jc;
    bool            jb;
    wxString        jt;
    wxTreeItemId    jp[32];

    wxString        ss, tt;
    wxTreeItemId    root;
    wxTreeItemId    item;
    wxBitmap        bmp;
    wxsImageList    *ilist;


    // get name of combo-box and image-list
    n = aItems.GetCount();
    m_sTreeName  = _("<unknown>");
    m_sImageName = _("<none>");
    if(n >= 1){
        m_sTreeName  = aItems.Item(0);
    }
    if(n >= 2){
        m_sImageName = aItems.Item(1);
    }

    // show the names
    ss = _("Tree Control: ") + m_sTreeName;
    StaticBoxSizer1->GetStaticBox()->SetLabel(ss);

    ss = m_sImageName;
    StaticText13->SetLabel(ss);

    // clear old junk
    Tree1->DeleteAllItems();

    // a valid image-list given?
    m_imageList.RemoveAll();
    ilist = (wxsImageList *) wxsImageListEditorDlg::FindTool(NULL, m_sImageName);
    if(ilist != NULL){
        ilist->GetImageList(m_imageList);
    }
    SetImageList(m_imageList);

    // add all the new items
    n = aItems.GetCount();
    for(i = 2; i < n; i++){
        ss = aItems.Item(i);
        ParseTreeItem(ss, jv, jc, jb, j1, j2, j3, j4, jt);

        if(jv == 0){
            item = Tree1->AddRoot(jt);
        }
        else{
            item = Tree1->AppendItem(jp[jv-1], jt);
        }
        jp[jv] = item;

        if(jc.IsOk()){
            Tree1->SetItemTextColour(item, jc);
        }
        Tree1->SetItemBold(item, jb);
        Tree1->SetItemImage(item, j1, wxTreeItemIcon_Normal);
        Tree1->SetItemImage(item, j2, wxTreeItemIcon_Selected);
        Tree1->SetItemImage(item, j3, wxTreeItemIcon_Expanded);
        Tree1->SetItemImage(item, j4, wxTreeItemIcon_SelectedExpanded);
    }

    Tree1->ExpandAll();

    // show the dialog and wait for a response
    n = ShowModal();

    // save all new stuff?
    if(n == wxOK){
        // must save combo-box name and image-list name
        aItems.Clear();
        aItems.Add(m_sTreeName);
        aItems.Add(m_sImageName);

        // save the root item and all it's children
        // this effectively saves every item in the tree
        // I wanted to use a simple loop here, but it works MUCH easier with a recursive function
        root = Tree1->GetRootItem();
        if(root.IsOk()){
            EncodeTreeItems(root, 0, aItems);
        }
    }

    // done
    return (n == wxOK);
}
    /*! \brief Run the dialogue.
     *
     * \param aItems wxArrayString&
     * \return bool
     *
     */
    bool wxsImageComboEditorDlg::Execute(wxArrayString &aItems)
    {
        int             i,n;
        int             j,k;
        long            ll;
        wxString        ss, tt;
        wxTreeItemId    root;
        wxTreeItemId    item;
        wxTreeItemIdValue   cookie;
        wxBitmap        bmp;
        wxsImageList    *ilist;


        // get name of combo-box and image-list
        n = aItems.GetCount();
        if(n == 0){
            m_ComboName = _("<unknown>");
            m_ImageName = _("<none>");
        }
        else if(n == 1){
            m_ComboName = aItems.Item(0);
            m_ImageName = _("<none>");
        }
        else{
            m_ComboName = aItems.Item(0);
            m_ImageName = aItems.Item(1);
        }

        // show the names
        ss = _("Combo Box: ") + m_ComboName;
        StaticText1->SetLabel(ss);

        ss = _("Image List: ") + m_ImageName;
        StaticText9->SetLabel(ss);

        // a valid image-list given?
        m_ImageList.RemoveAll();
        ilist = (wxsImageList *) wxsImageListEditorDlg::FindTool(NULL, m_ImageName);
        if(ilist == NULL){
            m_pCmbImage->Enable(false);
        }
        else{
            m_pCmbImage->Enable(true);
            ilist->GetImageList(m_ImageList);
        }

        // setup the combo-box image selector
        m_pCmbImage->Clear();
        m_pCmbImage->Append(_("<none>"));

        n = m_ImageList.GetImageCount();
        for(i=0; i<n; i++){
            ss.Printf(_T("%3d"), i);
            bmp = m_ImageList.GetBitmap(i);

            m_pCmbImage->Append(ss, bmp);
        }

        m_pCmbImage->SetSelection(0);

        // clear old junk
        m_pTree->DeleteAllItems();

        // make a root item
        root = m_pTree->AddRoot(_("root"));

        // make sure we are using the image list -- even if it is empty
        m_pTree->SetImageList(&m_ImageList);

        // add all the new items
        n = aItems.GetCount();
        for(i = 2;i < n;i++){
            ss = aItems.Item(i);
            j  = ss.Find(_T(","));
            k = -1;
            if(j != wxNOT_FOUND){
                tt = ss.Left(j);
                ss.erase(0, j + 1);
                if(tt.ToLong(&ll)) k = ll;
            }
            item = m_pTree->AppendItem(root, ss, k);
        }

        // show the dialog and wait for a response
        n = ShowModal();

        // save all new stuff?
        if(n == wxOK){
            // must save combo-box name and image-list name
            aItems.Clear();
            aItems.Add(m_ComboName);
            aItems.Add(m_ImageName);

            // fetch the actual root item, it might have been recreated or
            // even deleted while executing the dialog
            root = m_pTree->GetRootItem();
            if (root.IsOk())
            {
                // save text of all children of the root item
                // these are actually the only things seen by the user
                item = m_pTree->GetFirstChild(root, cookie);
                while(item.IsOk()){
                    ss = m_pTree->GetItemText(item);
                    k  = m_pTree->GetItemImage(item, wxTreeItemIcon_Normal);

                    tt.Printf(_T("%d,"), k);
                    ss = tt + ss;

                    aItems.Add(ss);

                    item = m_pTree->GetNextChild(root, cookie);
                }
            }
        }

        // done
        return (n == wxOK);
    }
Пример #18
0
GameDatabaseListView& GameDatabaseListView::ClearAllGames()
{
	m_GamesInView.Clear();
	return *this;
}
Пример #19
0
int WXDLLIMPEXP_BASE wxParseCommonDialogsFilter(const wxString& filterStr,
                                           wxArrayString& descriptions,
                                           wxArrayString& filters)
{
    descriptions.Clear();
    filters.Clear();

    wxString str(filterStr);

    wxString description, filter;
    int pos = 0;
    while( pos != wxNOT_FOUND )
    {
        pos = str.Find(wxT('|'));
        if ( pos == wxNOT_FOUND )
        {
            // if there are no '|'s at all in the string just take the entire
            // string as filter and make description empty for later autocompletion
            if ( filters.IsEmpty() )
            {
                descriptions.Add(wxEmptyString);
                filters.Add(filterStr);
            }
            else
            {
                wxFAIL_MSG( wxT("missing '|' in the wildcard string!") );
            }

            break;
        }

        description = str.Left(pos);
        str = str.Mid(pos + 1);
        pos = str.Find(wxT('|'));
        if ( pos == wxNOT_FOUND )
        {
            filter = str;
        }
        else
        {
            filter = str.Left(pos);
            str = str.Mid(pos + 1);
        }

        descriptions.Add(description);
        filters.Add(filter);
    }

#if defined(__WXMOTIF__)
    // split it so there is one wildcard per entry
    for( size_t i = 0 ; i < descriptions.GetCount() ; i++ )
    {
        pos = filters[i].Find(wxT(';'));
        if (pos != wxNOT_FOUND)
        {
            // first split only filters
            descriptions.Insert(descriptions[i],i+1);
            filters.Insert(filters[i].Mid(pos+1),i+1);
            filters[i]=filters[i].Left(pos);

            // autoreplace new filter in description with pattern:
            //     C/C++ Files(*.cpp;*.c;*.h)|*.cpp;*.c;*.h
            // cause split into:
            //     C/C++ Files(*.cpp)|*.cpp
            //     C/C++ Files(*.c;*.h)|*.c;*.h
            // and next iteration cause another split into:
            //     C/C++ Files(*.cpp)|*.cpp
            //     C/C++ Files(*.c)|*.c
            //     C/C++ Files(*.h)|*.h
            for ( size_t k=i;k<i+2;k++ )
            {
                pos = descriptions[k].Find(filters[k]);
                if (pos != wxNOT_FOUND)
                {
                    wxString before = descriptions[k].Left(pos);
                    wxString after = descriptions[k].Mid(pos+filters[k].Len());
                    pos = before.Find(wxT('('),true);
                    if (pos>before.Find(wxT(')'),true))
                    {
                        before = before.Left(pos+1);
                        before << filters[k];
                        pos = after.Find(wxT(')'));
                        int pos1 = after.Find(wxT('('));
                        if (pos != wxNOT_FOUND && (pos<pos1 || pos1==wxNOT_FOUND))
                        {
                            before << after.Mid(pos);
                            descriptions[k] = before;
                        }
                    }
                }
            }
        }
    }
#endif

    // autocompletion
    for( size_t j = 0 ; j < descriptions.GetCount() ; j++ )
    {
        if ( descriptions[j].empty() && !filters[j].empty() )
        {
            descriptions[j].Printf(_("Files (%s)"), filters[j].c_str());
        }
    }

    return filters.GetCount();
}
Пример #20
0
void PluginManager::ReadExtraFilesFromManifestFile(const wxString& pluginFilename,
                                                    wxArrayString& extraFiles)
{
    extraFiles.Clear();

    // find and load plugin's resource file
    // (pluginFilename contains no path info)
    wxFileName fname(pluginFilename);
    fname.SetExt(_T("zip"));
    wxString actual = fname.GetFullName();

    // remove 'lib' prefix from plugin name (if any)
    if (!platform::windows && actual.StartsWith(_T("lib")))
        actual.Remove(0, 3);

    actual = ConfigManager::LocateDataFile(actual, sdPluginsUser | sdDataUser | sdPluginsGlobal | sdDataGlobal);
    if (actual.IsEmpty())
    {
        Manager::Get()->GetLogManager()->LogError(_T("Plugin resource not found: ") + fname.GetFullName());
        return; // not found
    }

    // load XML from ZIP
    wxString contents;
    wxFileSystem* fs = new wxFileSystem;
    wxFSFile* f = fs->OpenFile(actual + _T("#zip:manifest.xml"));
    if (f)
    {
        wxInputStream* is = f->GetStream();
        char tmp[1024] = {};
        while (!is->Eof() && is->CanRead())
        {
            memset(tmp, 0, sizeof(tmp));
            is->Read(tmp, sizeof(tmp) - 1);
            contents << cbC2U((const char*)tmp);
        }
        delete f;
    }
    else
    {
        Manager::Get()->GetLogManager()->LogError(_T("No plugin manifest file in resource: ") + actual);
        delete fs;
        return;
    }
    delete fs;

    // actually load XML document
    TiXmlDocument doc;
    if (!doc.Parse(cbU2C(contents)))
        return;

    TiXmlElement* root = doc.FirstChildElement("CodeBlocks_plugin_manifest_file");
    if (!root)
        return;

    TiXmlElement* extra = root->FirstChildElement("Extra");
    while (extra)
    {
        const char* file = extra->Attribute("file");
        if (file && *file)
        {
            extraFiles.Add(cbC2U(file));
        }

        extra = extra->NextSiblingElement("Extra");
    }
}
Пример #21
0
void XFunctionsShowDialog::GetChoiceItems(wxArrayString& awxszList)
{
   awxszList.Clear();
   wxString wxszFnName = wxT("Autocorrelation");
   awxszList.Add(wxszFnName + wxT(" Left"));
   awxszList.Add(wxszFnName + wxT(" Right"));

   int nXFnType = m_pXf->GetXFunctionType();
   switch(nXFnType)
   {
      case XFunctions::XFT_AUTO_CORRELATION:
         break;

      case XFunctions::XFT_CROSS_CORRELATION:
         wxszFnName = wxT("Crosscorrelation");
         break;

      case XFunctions::XFT_WHITE_CORRELATION:
         wxszFnName = wxT("White Crosscorr.");
         break;

      case XFunctions::XFT_CROSS_POWER:
         wxszFnName = wxT("Cross-Power Spect.");
         break;

      case XFunctions::XFT_TF_H1:
         wxszFnName = wxT("H1");
         break;

      case XFunctions::XFT_TF_H2:
         wxszFnName = wxT("H2");
         break;

      case XFunctions::XFT_TF_H3:
         wxszFnName = wxT("H3");
         break;

      case XFunctions::XFT_ALPHA:

         if(m_pXf->IsProbeFreeField())
         {
            awxszList.Add(wxT("PU FF Calibration"));
            wxszFnName = wxT("Dirac delta");
//          awxszList.Add(wxT("Alpha"));
         }
         else if(m_pXf->IsProbeRigidTerminated())
         {
            awxszList.Add(wxT("PU SW Calibration"));
            wxszFnName = wxT("Dirac delta");
//          awxszList.Add(wxT("Alpha"));
         }
         else // alpha
         {
            wxszFnName = wxT("Alpha");
            awxszList.Add(wxT("Coherence"));
//          awxszList.Add(wxT("Alpha"));
         }
         break;
   }

   if(nXFnType != XFunctions::XFT_AUTO_CORRELATION)
   {
	   awxszList.Add(wxszFnName + wxT(" Magn."));
	   awxszList.Add(wxszFnName + wxT(" Phase"));
	   awxszList.Add(wxszFnName + wxT(" Real"));
	   awxszList.Add(wxszFnName + wxT(" Imag."));
   }

   if(nXFnType != XFunctions::XFT_ALPHA)
   {
	   awxszList.Add(wxT("Coherence"));
	   awxszList.Add(wxT("Alpha"));
   }
   else if(!m_pXf->IsProbeFreeField() && !m_pXf->IsProbeRigidTerminated())
   {
	   awxszList.Add(wxT("Coherence"));
   }
}