Beispiel #1
0
void wxTranslationHelper::GetInstalledLanguages(wxArrayString& names, wxArrayLong& identifiers)
{
	names.Clear();
	identifiers.Clear();
	wxString filename;
	const wxLanguageInfo* langinfo;

	names.Add(_("English"));
	identifiers.Add(wxLANGUAGE_ENGLISH);

	if (!wxDir::Exists(m_SearchPath)) {
		wxLogError(_T("Directory %s DOES NOT EXIST"), m_SearchPath.GetData());
		return;
	}
	wxDir dir(m_SearchPath);

	int localeid = wxLocale::GetSystemLanguage();

	for (bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS); cont; cont = dir.GetNext(&filename)) {
		langinfo = wxLocale::FindLanguageInfo(filename);
		if (langinfo != NULL) {
			wxString mo_file = dir.GetName() + wxFileName::GetPathSeparator() + filename + wxFileName::GetPathSeparator() + _T("LC_MESSAGES") + wxFileName::GetPathSeparator() + catalogname + wxT(".mo");
			wxLogInfo(_("SEARCHING FOR %s"), mo_file.GetData());
			if (wxFileExists(mo_file)) {
				if (langinfo->Language == localeid)
					names.Add(langinfo->Description + _(" (Default)"));
				else
					names.Add(langinfo->Description);
				identifiers.Add(langinfo->Language);
			}
		}
	}
}
Beispiel #2
0
wxMutexError wxMutexInternal::Unlock()
{
    if ( UMASystemIsInitialized() )
    {
        OSErr err;
        err = ::ThreadBeginCritical();
        wxASSERT( err == noErr ) ;

        if (m_locked > 0)
            m_locked--;

        // this mutex is not owned by anybody anmore
        m_owner = kNoThreadID;

        // now pass on to the first waiting thread
        ThreadID firstWaiting = kNoThreadID;
        bool found = false;
        while (!m_waiters.IsEmpty() && !found)
        {
            firstWaiting = m_waiters[0];
            err = ::SetThreadState(firstWaiting, kReadyThreadState, kNoThreadID);
            // in case this was not successful (dead thread), we just loop on and reset the id
            found = (err != threadNotFoundErr);
            if ( !found )
                firstWaiting = kNoThreadID ;
            m_waiters.RemoveAt(0) ;
        }
        // now we have a valid firstWaiting thread, which has been scheduled to run next, just end the
        // critical section and invoke the scheduler
        err = ::SetThreadStateEndCritical(kCurrentThreadID, kReadyThreadState, firstWaiting);
    }
    else
    {
        if (m_locked > 0)
            m_locked--;
    }
    return wxMUTEX_NO_ERROR;
}
Beispiel #3
0
bool wxGxWebConnectionFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
    wxGxCatalogBase* pCatalog = GetGxCatalog();
    for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
    {
        CPLString szExt = CPLGetExtension(pFileNames[i]);
		if(wxGISEQUAL(szExt, "wconn"))
		{
            if( m_bHasDriver )
            {
    			wxGxObject* pObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i]); 
                if(pObj)
                    pChildrenIds.Add(pObj->GetId());
            }
            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
		}
    }
	return true;
}
bool wxGxLocalDBFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
    wxGxCatalogBase* pCatalog = GetGxCatalog();
    bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT;
    for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
    {
        VSIStatBufL BufL;
        int ret = VSIStatL(pFileNames[i], &BufL);
        if(ret == 0)
        {
            if (VSI_ISDIR(BufL.st_mode) && wxGISEQUAL(CPLGetExtension(pFileNames[i]), "gdb"))
            {
                wxGxObject* pObj = GetGxObject(pParent, wxString(CPLGetFilename(pFileNames[i]), wxConvUTF8), pFileNames[i], enumContGDBFolder, bCheckNames);
                if(pObj)
                    pChildrenIds.Add(pObj->GetId());
                pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
            }
            //TODO: mdb, sqlite, db extensions
        }
    }
    return true;
}
Beispiel #5
0
wxMutexError wxMutexInternal::Lock()
{
    wxMacStCritical critical ;
    if ( UMASystemIsInitialized() )
    {
        OSErr err ;
        ThreadID current = kNoThreadID;
        err = ::MacGetCurrentThread(&current);
        // if we are not the owner, add this thread to the list of waiting threads, stop this thread
        // and invoke the scheduler to continue executing the owner's thread
        while ( m_owner != kNoThreadID && m_owner != current)
        {
            m_waiters.Add(current);
            err = ::SetThreadStateEndCritical(kCurrentThreadID, kStoppedThreadState, m_owner);
            err = ::ThreadBeginCritical();
            wxASSERT( err == noErr ) ;
        }
        m_owner = current;
    }
    m_locked++;

    return wxMUTEX_NO_ERROR;
}
bool wxGxPrjFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
    bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT;
    for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
    {
        CPLString szExt = CPLGetExtension(pFileNames[i]);

        wxGxObject* pGxObj = NULL;
 
        if(wxGISEQUAL(szExt, "prj"))
        {
            bool bAdd = true;
            for(int j = 0; prj_notadd_exts[j] != NULL; ++j )
            {
                if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL))
                {
                    bAdd = false;
                    break;
                }
            }

            if(bAdd)
            {
                pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumESRIPrjFile, bCheckNames);
            }

            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
        }
        else if(wxGISEQUAL(szExt, "qpj"))
        {
            bool bAdd = true;
            for(int j = 0; prj_notadd_exts[j] != NULL; ++j )
            {
                if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL))
                {
                    bAdd = false;
                    break;
                }
            }

            if(bAdd)
            {
                pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumQPJfile, bCheckNames);
            }

            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
        }
        else if(wxGISEQUAL(szExt, "spr"))
        {
            pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumSPRfile, bCheckNames);

            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
        }

        if(pGxObj)
        {
            pChildrenIds.Add(pGxObj->GetId());
            pGxObj = NULL;
        }
    }
	return true;
}
Beispiel #7
0
void OpenUserDataRec::MakeUserDataRec( const wxString& filter )
{
    if ( !filter.empty() )
    {
        wxString filter2(filter) ;
        int filterIndex = 0;
        bool isName = true ;
        wxString current ;

        for ( unsigned int i = 0; i < filter2.length() ; i++ )
        {
            if ( filter2.GetChar(i) == wxT('|') )
            {
                if ( isName )
                {
                    m_name.Add( current ) ;
                }
                else
                {
                    m_extensions.Add( current ) ;
                    ++filterIndex ;
                }

                isName = !isName ;
                current = wxEmptyString ;
            }
            else
            {
                current += filter2.GetChar(i) ;
            }
        }
        // we allow for compatibility reason to have a single filter expression (like *.*) without
        // an explanatory text, in that case the first part is name and extension at the same time

        wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ;
        if ( current.empty() )
            m_extensions.Add( m_name[filterIndex] ) ;
        else
            m_extensions.Add( current ) ;
        if ( filterIndex == 0 || isName )
            m_name.Add( current ) ;

        ++filterIndex ;

        const size_t extCount = m_extensions.GetCount();
        for ( size_t i = 0 ; i < extCount; i++ )
        {
            wxUint32 fileType, creator;
            wxString extension = m_extensions[i];

            // Remove leading '*'
            if ( !extension.empty() && (extension.GetChar(0) == '*') )
                extension = extension.Mid( 1 );

            // Remove leading '.'
            if ( !extension.empty() && (extension.GetChar(0) == '.') )
                extension = extension.Mid( 1 );

            if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator ))
                m_filtermactypes.Add( (OSType)fileType );
            else
                m_filtermactypes.Add( '****' ); // We'll fail safe if it's not recognized
        }
    }
}
bool wxGISToolExecuteView::OnDropObjects(wxCoord x, wxCoord y, long nParentPointer, const wxArrayLong& TaskIds)
{
    wxBusyCursor wait;
    SetItemState(m_HighLightItem, 0, wxLIST_STATE_DROPHILITED);
    //SetItemState(m_HighLightItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);

    if(nParentPointer != wxThread::GetMainId())
        return false;

    wxPoint pt(x, y);
    unsigned long nFlags(0);
    long nItemId = HitTest(pt, (int &)nFlags);
    long nObjectID(m_nParentGxObjectId);

    if(nItemId == wxNOT_FOUND)
        return false;

    IGxTask* pBeforeTask(NULL);
    int nInsertPoint = GetItemCount() - TaskIds.GetCount(); //the end
    if(nFlags & wxLIST_HITTEST_ONITEM)
    {
        nInsertPoint = nItemId;// - 1;
        pBeforeTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(GetItemData(nInsertPoint)));
    }

    //1. Read all items to map sortig using priority, but not adding moving items
    m_bDropping = true;
    std::map<long, IGxTask*> ItemsMap;
    for(int i = 0; i < GetItemCount(); ++i)
    {
        long nTaskId = GetItemData(i);
        if(TaskIds.Index(nTaskId) == wxNOT_FOUND)
        {
            IGxTask* pTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(nTaskId));
            if(pTask && pTask->GetState() != enumGISTaskDone)
            {
                ItemsMap[pTask->GetPriority()] = pTask;
            }
        }
    }

    //wxWindowUpdateLocker noUpdates(this);

    //get min priority
    if(nInsertPoint < 0)
    {
        long nMinPrio = ItemsMap.begin()->first;
        for(size_t i = 0; i < TaskIds.GetCount(); ++i)
        {
            IGxTask* pTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(TaskIds[i]));
            if(pTask)
            {
                pTask->SetPriority(++nMinPrio);
            }
        }
        for(std::map<long, IGxTask*>::iterator it = ItemsMap.begin(); it != ItemsMap.end(); ++it)
        {
            it->second->SetPriority(++nMinPrio);
        }
    }
    else if(nInsertPoint >= TaskIds.GetCount())
    {
        long nMinPrio = ItemsMap.begin()->first;
        for(std::map<long, IGxTask*>::iterator it = ItemsMap.begin(); it != ItemsMap.end(); ++it)
        {
            it->second->SetPriority(++nMinPrio);
        }

        for(size_t i = 0; i < TaskIds.GetCount(); ++i)
        {
            IGxTask* pTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(TaskIds[i]));
            if(pTask)
            {
                pTask->SetPriority(++nMinPrio);
            }
        }
    }
    else
    {
        //2. Read from map until end for insert to array
        bool bSetPrio(false);
        long nMinPrio = wxNOT_FOUND;
        for(std::map<long, IGxTask*>::iterator it = ItemsMap.begin(); it != ItemsMap.end(); ++it)
        {
            if(pBeforeTask == it->second)
            {
                nMinPrio = pBeforeTask->GetPriority();
                for(size_t i = 0; i < TaskIds.GetCount(); ++i)
                {
                    IGxTask* pTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(TaskIds[i]));
                    if(pTask)
                    {
                        pTask->SetPriority(++nMinPrio);
                    }
                }
                bSetPrio = true;
            }
            if(bSetPrio)
                it->second->SetPriority(++nMinPrio);
        }
    }

    SortItems(GxTaskCompareFunction, 0);

    m_bDropping = false;

    return true;
}
bool wxGxRasterFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
    bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT;
    for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
    {
        wxGxObject* pGxObj = NULL;
        CPLString szExt = CPLGetExtension(pFileNames[i]);
        CPLString szPath;
        bool bContinue(false);

        unsigned int j;
        for(j = 0; j < sizeof(raster_exts) / sizeof(raster_exts[0]); ++j)
        {
            if(wxGISEQUAL(szExt, raster_exts[j].sExt) )
		    {
                if(raster_exts[j].bAvailable)
                {
                    CPLString szPath(pFileNames[i]);
                    pGxObj = GetGxObject(pParent, GetConvName(szPath), szPath, raster_exts[j].eType, bCheckNames);
                    if(pGxObj != NULL)
                        pChildrenIds.Add(pGxObj->GetId());
                }
                pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
                bContinue = true;
                break;
		    }
        }

        if(bContinue)
            continue;


        if(wxGISEQUAL(szExt, "prj"))
        {
			if(pFileNames)
			{
                unsigned int j;
                for(j = 0; j < sizeof(raster_exts) / sizeof(raster_exts[0]); ++j)
                {
    				szPath = (char*)CPLResetExtension(pFileNames[i], raster_exts[j].sExt);
	    			if(CPLCheckForFile((char*)szPath.c_str(), NULL))
                    {
		    			pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
                        bContinue = true;
                        break;
                    }
                }
            }
        }

        if(bContinue)
            continue;
        
        for( j = 0; raster_add_exts[j] != NULL; ++j )
        {
            if(wxGISEQUAL(szExt, raster_add_exts[j]))
            {
                pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
                break;
            }
        }
    }
	return true;
}