当前位置: 首页>>代码示例>>C++>>正文


C++ VString::MAC_FromCFString方法代码示例

本文整理汇总了C++中VString::MAC_FromCFString方法的典型用法代码示例。如果您正苦于以下问题:C++ VString::MAC_FromCFString方法的具体用法?C++ VString::MAC_FromCFString怎么用?C++ VString::MAC_FromCFString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VString的用法示例。


在下文中一共展示了VString::MAC_FromCFString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _ReadProductName

void VProcess::_ReadProductName( VString& outName) const
{
#if VERSIONWIN
#ifndef XTOOLBOX_AS_STANDALONE
	DWORD size = ::GetFileVersionInfoSizeW( GetExecutableFilePath().GetPath().GetCPointer(), NULL);
	void *buffer = malloc( size);
	if ( (buffer != NULL) && GetFileVersionInfoW( GetExecutableFilePath().GetPath().GetCPointer(), NULL, size, buffer))
	{
		void *valueAdress;
		UINT valueSize;
		if (::VerQueryValueW( buffer, L"\\StringFileInfo\\040904B0\\ProductName", &valueAdress, &valueSize))
		{
			outName.FromBlock( valueAdress, (valueSize - 1) * sizeof( UniChar), VTC_UTF_16);
		}
	}
	if (buffer != NULL)
		free( buffer);
#endif
#elif VERSIONMAC
	CFStringRef cfProductName = (CFStringRef) CFBundleGetValueForInfoDictionaryKey( CFBundleGetMainBundle(), kCFBundleNameKey);
	if (cfProductName != NULL)
		outName.MAC_FromCFString( cfProductName);

#elif VERSION_LINUX
    outName="Wakanda Server";	//Postponed Linux Implementation
#endif
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:27,代码来源:VProcess.cpp

示例2: _ReadProductVersion

void VProcess::_ReadProductVersion( VString& outVersion) const
{
#if VERSIONWIN
#ifndef XTOOLBOX_AS_STANDALONE
	DWORD size = ::GetFileVersionInfoSizeW( GetExecutableFilePath().GetPath().GetCPointer(), NULL);
	void *buffer = malloc( size);
	if ( (buffer != NULL) && GetFileVersionInfoW( GetExecutableFilePath().GetPath().GetCPointer(), NULL, size, buffer))
	{
		void *valueAdress;
		UINT valueSize;
		if (::VerQueryValueW( buffer, L"\\StringFileInfo\\040904B0\\ProductVersion", &valueAdress, &valueSize))
		{
			outVersion.FromBlock( valueAdress, (valueSize - 1) * sizeof( UniChar), VTC_UTF_16);
		}
	}
	if (buffer != NULL)
		free( buffer);
#endif
#elif VERSIONMAC
	// The constant for the "short version" property does not exist.
	CFStringRef cfProductVersion = (CFStringRef) CFBundleGetValueForInfoDictionaryKey( CFBundleGetMainBundle(), CFSTR ( "CFBundleShortVersionString" ) /*kCFBundleVersionKey*/);
	if (cfProductVersion != NULL)
	{
		outVersion.MAC_FromCFString( cfProductVersion);
	}

#elif VERSION_LINUX
    //jmo - We get the Linux product version with SetProductVersion() on VRIAServerApplication init
#endif
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:30,代码来源:VProcess.cpp

示例3: GetExecutableFilePath

VFilePath VProcess::GetExecutableFilePath() const
{
	VFilePath filePath;

#if VERSIONMAC

	CFURLRef exeURL = ::CFBundleCopyExecutableURL( ::CFBundleGetMainBundle());
	
	if (testAssert( exeURL != NULL ))
	{
		CFStringRef cfPath = ::CFURLCopyFileSystemPath( exeURL, kCFURLHFSPathStyle);
		if (testAssert( cfPath != NULL ))
		{
			VString thepath;
			thepath.MAC_FromCFString( cfPath);
			thepath.Compose();
			filePath.FromFullPath( thepath, FPS_SYSTEM);
			::CFRelease( cfPath);
		}
		
		::CFRelease(exeURL );
	}

#elif VERSIONWIN

	// Get a path to the exe.
	UniChar path[4096];
	DWORD pathLength=0;

	path[sizeof(path)/sizeof(UniChar)-2]=0;
	pathLength = ::GetModuleFileNameW(NULL, path, sizeof(path));
	
	if (testAssert(pathLength != 0 && !path[sizeof(path)/sizeof(UniChar)-2]))
	{
		VString thepath( path);
		filePath.FromFullPath( thepath, FPS_SYSTEM);
	}

#elif VERSION_LINUX

	PathBuffer path;

	VError verr=path.InitWithExe();
	xbox_assert(verr==VE_OK);

	path.ToPath(&filePath);
	xbox_assert(verr==VE_OK);
		
#endif
	
	return filePath;
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:52,代码来源:VProcess.cpp

示例4: SearchExecutablePath

bool XMacSystem::SearchExecutablePath( const VString& inExecutableName, VFilePath& outPath)
{
	// first lookup in environment variables
	bool found = XBSDSystem::SearchExecutablePath( inExecutableName, outPath);
	
	// then ask launch services
	if (!found)
	{
		VString name( inExecutableName);
		
		if (!name.EndsWith( CVSTR( ".app")))
			name += CVSTR( ".app");
		
		CFURLRef cfAppUrl = NULL;
		CFStringRef cfName = name.MAC_RetainCFStringCopy();
		OSStatus status = LSFindApplicationForInfo( kLSUnknownCreator, NULL /* inBundleID */, cfName, NULL /* outFSRef */, &cfAppUrl);
		if (cfName != NULL)
			CFRelease( cfName);
			
		if (status == noErr)
		{
			if (testAssert( cfAppUrl != NULL))
			{
				CFStringRef cfPosixPath = ::CFURLCopyFileSystemPath( cfAppUrl, kCFURLPOSIXPathStyle);
				if (testAssert( cfPosixPath != NULL))
				{
					VString posixPath;
					posixPath.MAC_FromCFString( cfPosixPath);
					
					posixPath.Compose();
					
					// add an ending / because it's a bundle folder
					posixPath += "/";
					outPath.FromFullPath( posixPath, FPS_POSIX);
					
					found = true;
					::CFRelease( cfPosixPath);
				}
			}
		}

		if (cfAppUrl != NULL)
			CFRelease( cfAppUrl);
	}
	
	return found;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:47,代码来源:XMacSystem.cpp

示例5: GetStdFont

void XMacFontMgr::GetStdFont( StdFont inFont, VString& outName, VFontFace& outFace, GReal& outSize)
{
	// on risque de perdre des infos, il faudrait retourner une VFont
	
	CTFontUIFontType fontType = StdFontToThemeFontID( inFont);
	CTFontRef fontRef = ::CTFontCreateUIFontForLanguage( fontType, 0 /*size*/, NULL /*language*/ );

	if (testAssert( fontRef != NULL))
	{
		outSize = ::CTFontGetSize( fontRef);

		CFStringRef cfName = ::CTFontCopyFamilyName( fontRef);
		if (cfName != NULL)
		{
			outName.MAC_FromCFString( cfName);
			::CFRelease( cfName);
		}
		else
		{
			outName.Clear();
		}
		
		CTFontSymbolicTraits traits = ::CTFontGetSymbolicTraits( fontRef);
		outFace = 0;
		
		if (traits & kCTFontItalicTrait)
			outFace |= KFS_ITALIC;
		
		if (traits & kCTFontBoldTrait)
			outFace |= KFS_BOLD;
		
		if (traits & kCTFontExpandedTrait)
			outFace |= KFS_EXTENDED;
		
		if (traits & kCTFontCondensedTrait)
			outFace |= KFS_CONDENSED;

		CFRelease( fontRef); 
	}
	else
	{
		outName.Clear();
		outSize = 0;
		outFace = 0;
	}
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:46,代码来源:XMacFontMgr.cpp

示例6: BuildFontList

void XMacFontMgr::BuildFontList()
{
	fFontFamilies.SetCount(0);
	//fFontNames.SetCount(0);
	fFontNames.clear();
	/*
	FMFontFamilyIterator	iterator;
	OSErr	error = ::FMCreateFontFamilyIterator(NULL, NULL, kFMDefaultOptions, &iterator);
	if (error == noErr)
	{
		FMFontFamily	family;
		
		assert(sizeof(FMFontFamily) == sizeof(sWORD));
		while (::FMGetNextFontFamily(&iterator, &family) == noErr)
		{
			Str255 spFontName;
			if (testAssert(::FMGetFontFamilyName(family, spFontName) == noErr))
			{
				VStr255	name;
				CFStringRef cfname;
				ATSFontFamilyRef ffref = ::ATSFontFamilyFindFromQuickDrawName(spFontName);
				::ATSFontFamilyGetName(ffref, kATSOptionFlagsDefault, &cfname);
				//name.MAC_FromMacPString(spFontName);
				name.MAC_FromCFString(cfname);
				if(name[0] != '.' && name[0] != '%')
				{	
					fFontNames.AppendString(name);
					fFontFamilies.AppendWord((sWORD) family);
				}
				//CFRelease(cfname);
			}
		}
		
		::FMDisposeFontFamilyIterator(&iterator);
	}*/
	
	CTFontCollectionRef FontCollection = ::CTFontCollectionCreateFromAvailableFonts(0);//kCTFontCollectionRemoveDuplicatesOption
	if(FontCollection)
    {
		CFArrayRef fonts = CTFontCollectionCreateMatchingFontDescriptors(FontCollection);
		if(fonts)
		{
			const int numFonts = CFArrayGetCount(fonts);
			for(int i = 0; i < numFonts; ++i) 
			{
				VString	vname;
				CTFontDescriptorRef vfont = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fonts, i);
				CFStringRef family_name = (CFStringRef)CTFontDescriptorCopyAttribute(vfont, kCTFontFamilyNameAttribute);
				if(family_name!=NULL)
				{
					vname.MAC_FromCFString(family_name);
				
					if( std::find(fFontNames.begin(), fFontNames.end(), vname) == fFontNames.end())
						fFontNames.push_back(vname);
				}
				//CFRelease(family_name);
			}
		}
	}	
	
	//fFontNames.SynchronizedSort(false, &fFontFamilies);
	//fFontNames.Sort(0, fFontNames.GetCount()-1);
	std::sort(fFontNames.begin(),fFontNames.end());
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:64,代码来源:XMacFontMgr.cpp

示例7: FontExists

/** return true if font with the specified font family name, style and size exists on the current system */
bool VFont::FontExists(const VString& inFontFamilyName, const VFontFace& inFace, GReal inSize, const GReal inDPI, const VGraphicContext *inGC)
{
#if VERSIONWIN
	bool exists = false;
	//JQ 21/06/2010: fixed and optimized FontExists (was not coherent with font creation)
	VFont *font = RetainFont( inFontFamilyName, inFace, inSize, inDPI, true);
	if (font)
	{
		if (!font->IsTrueTypeFont())
		{
			//not TrueType fonts are drawed with GDI
			//so return true if a valid HFONT is set

			HFONT hFont = font->GetFontRef();
			exists = hFont != NULL;
			font->Release();
			return exists;
		}
#if ENABLE_D2D
		if (inGC && inGC->IsD2DImpl())
		{
			//if DWrite font family name is not equal to inFontFamilyName
			//DWrite has returned a compatible font 
			//so return true only if DWrite font family name matches inFontFamilyName

			VTaskLock lock(&VWinD2DGraphicContext::GetMutexDWriteFactory());
			exists = false;
			if (font->GetImpl().GetDWriteTextFormat() != NULL)
			{
				UINT32 nameLength = font->GetImpl().GetDWriteTextFormat()->GetFontFamilyNameLength();
				if (nameLength+1 <= 80)
				{
					WCHAR familyName[80];
					HRESULT hr = font->GetImpl().GetDWriteTextFormat()->GetFontFamilyName( familyName, nameLength+1);
					exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
				}
				else
				{
					WCHAR *familyName = new WCHAR[nameLength+1];
					font->GetImpl().GetDWriteTextFormat()->GetFontFamilyName( familyName, nameLength+1);
					exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
					delete [] familyName;
				}
			}
			font->Release();
			return exists;
		}
#endif
		//if gdiplus font family name is not equal to inFontFamilyName
		//gdiplus has returned a compatible font 
		//so return true only if gdiplus font family name matches inFontFamilyName
		Gdiplus::FontFamily *family = new Gdiplus::FontFamily();
		Gdiplus::Status status = font->GetImpl().GetGDIPlusFont()->GetFamily(family);
		WCHAR familyName[LF_FACESIZE];
		family->GetFamilyName( familyName);
		exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
		delete family;

		font->Release();
	}
	return exists;
#else
	bool exists = false;
	VFont *font = RetainFont( inFontFamilyName, inFace, inSize, inDPI, true);
	if (font)
	{
		//ensure returned font has the requested family name (here we check only the family name but not the full name)
		//otherwise it is a font substitute
		CTFontRef ctfont = font->GetFontRef();
		CFStringRef name = CTFontCopyFamilyName(ctfont);
		VString xname;
		xname.MAC_FromCFString( name);
		CFRelease(name);
		VString inname( inFontFamilyName);
		inname.Truncate( xname.GetLength());
		return inname.EqualToString( xname);
	}
	return exists;
#endif
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:81,代码来源:VFont.cpp


注:本文中的VString::MAC_FromCFString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。