⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oplutil.cpp

📁 在手机操作系统symbina上使用的一个脚本扩展语言的代码实现,可以参考用于自己的开发
💻 CPP
📖 第 1 页 / 共 2 页
字号:
const TInt KOS61DenseFontId		= KOS61BaseFontId2 + 0x05 ;

const TInt KOS61BaseFontId	=0x10000000;
const TInt KOplLatinPlain12	=KOS61BaseFontId+ELatinPlain12;
const TInt KOplLatinBold12	=KOS61BaseFontId+ELatinBold12;
const TInt KOplKOplLatinBold13	=KOS61BaseFontId+ELatinBold13;
const TInt KOplLatinBold17	=KOS61BaseFontId+ELatinBold17;
const TInt KOplLatinBold19	=KOS61BaseFontId+ELatinBold19;
const TInt KOplNumberPlain5	=KOS61BaseFontId+ENumberPlain5;
const TInt KOplClockBold30	=KOS61BaseFontId+EClockBold30;
const TInt KOplLatinClock14	=KOS61BaseFontId+ELatinClock14;
const TInt KOplFontCustom	=KOS61BaseFontId+EFontCustom; //0x10000009
const TInt KOplPlain12		=KOS61BaseFontId+EPlain12;
const TInt KOplPlain16		=KOS61BaseFontId+EPlain16; 
const TInt KOplApacPlain12	=KOS61BaseFontId+EApacPlain12;
const TInt KOplApacPlain16	=KOS61BaseFontId+EApacPlain16;
const TInt KOplBold18		=KOS61BaseFontId+EBold18;
const TInt KOplBold24		=KOS61BaseFontId+EBold24; //0x1000000d
const TInt KOS61MaxFontId	=KOplBold24; // Always set to the last font id.

/*
 * TitleFont -- the heavyweight app title font
 * AnnotationFont -- used by the softkeys Option, Exit etc.
 * LegendFont -- ditto
 * SymbolFont -- ditto
 * DenseFont -- the app names in main "menu"
 */

TBool OplUtil::IsStandardFontUid(const TUid aFontUid)
	{
	if ((aFontUid.iUid==0x1000000a) || (aFontUid.iUid==0x1000000b)) // Don't use: gives LAFENV 8 panic
		return EFalse; 
	if ((aFontUid.iUid >= KOS61BaseFontId) && (aFontUid.iUid<=KOS61MaxFontId))
		return ETrue;
	return EFalse;
	}

/*
KOplKOplLatinBold13
KOplLatinBold17
KOplLatinBold19
KOplNumberPlain5
KOplClockBold30
KOplLatinClock14 
KOplFontCustom 
KOplPlain12
KOplPlain16
KOplApacPlain12
KOplApacPlain16
KOplBold18
KOplBold24
*/

//  ELatinPlain12, ELatinBold12, ELatinBold13, ELatinBold17, ELatinBold19, ENumberPlain5,
// ClockBold30, LatinClock14, ECustomFont


const CFont* OplUtil::MapFontUidToStandardFontL(const TUid aFontUid)
	{
	if (OplUtil::IsStandardFontUid(aFontUid))
		return (AknLayoutUtils::FontFromId(aFontUid.iUid-KOS61BaseFontId));
	User::Leave(KOplErrFontNotLoaded);
	return NULL; //Keep compiler happy.
	}

/*


	switch(aFontUid.iUid)
		{
		case KOplLatinPlain2:
			return LatinPlain12();
			break;
		case KOplLatinBold12:
			return LatinBold12();
			break;
		case KOplKOplLatinBold13:
			return LatinBold13();
			break;
		case KOplLatinBold17:
			return LatinBold17();
			break;
		case KOplLatinBold19:
			return LatinBold19();
			break;
		case KOplNumberPlain5:
			return NumberPlain5();
			break;
		case KOplClockBold30:
			return ClockBold30();
			break;
		case KOplLatinClock14:
			return LatinClock14();
			break;
		case KOplFontCustom:
			return FontCustom();
			break;
		case KOplPlain12:
			return Plain12();
			break;
		case KOplPlain16:
			return Plain16();
			break;
		case KOplApacPlain12:
			return ApacPlain12();
			break;
		case KOplApacPlain16:
			return ApacPlain16();
			break;
		case KOplBold18:
			return Bold18();
			break;
		case KOplBold24:
			return Bold24();
			break;
*/

/*
		case KOS61NormalFontId:
			return CEikonEnv::Static()->NormalFont();
			break;
		case KOS61TitleFontId:
			return CEikonEnv::Static()->TitleFont();
			break;
		case KOS61AnnotationFontId:
			return CEikonEnv::Static()->AnnotationFont();
			break;
		case KOS61LegendFontId:
			return CEikonEnv::Static()->LegendFont();
			break;
		case KOS61SymbolFontId:
			return CEikonEnv::Static()->SymbolFont();
			break;
		case KOS61DenseFontId:
			return CEikonEnv::Static()->DenseFont();
			break;
			
*/

/*		
		default:
			break;
		}
	User::Leave(KOplErrFontNotLoaded);
	return NULL; //Keep compiler happy.
*/

//AknLayoutUtils::FontFromId



/*

// If the gFONT id is low, it's one of the OS6.1 built-in ones,
// so don't try and find a UID. (or use some 'match' uid)
//

// Keeping with the spirit of early font usage,
// on-board fonts are mapped to low numbers,
// external fonts can be loaded and their ids are used as before.

 * TitleFont -- the heavyweight app title font
 * AnnotationFont -- used by the softkeys Option, Exit etc.
 * LegendFont -- ditto
 * SymbolFont -- ditto
 * DenseFont -- the app names in main "menu"

Fonts:

MapFontId

Do all uses then call SetFontByUid somewhere???
FONT does
CLOCK n/a
gstyle calls getfontbyuid and then setfont()
gfont calls getfontbyname!!!!This will have to change...

mono 8x8 = dense mono ?????
roman 8/swiss 8 = normal ???
11 normal ????
13 annot ???
16 = title ??? 

*/
#endif

#if !defined(__UIQ__)
TUid OplUtil::MapFontId(TInt aFontId,TAlgStyle& aStyle)
	{
	switch(aFontId)
		{
	case 4 :
		aFontId = KScreenFontUidCourierNormal8;
//		aStyle.SetIsMono(ETrue); // courier should already be mono !!!
		break;
	case 5 :
		aFontId = KScreenFontUidTimesNormal8;
		break;
	case 6 :
		aFontId = KScreenFontUidTimesNormal11;
		break;
	case 7 :
		aFontId = KScreenFontUidTimesNormal13;
		break;
	case 8 :
		aFontId = KScreenFontUidTimesNormal15;
		break;
	case 9 :
		aFontId = KScreenFontUidArialNormal8;
		break;
	case 10 :
		aFontId = KScreenFontUidArialNormal11;
		break;
	case 11 :
		aFontId = KScreenFontUidArialNormal13;
		break;
	case 13 :
		aFontId = KScreenFontUidTiny4;
		aStyle.SetIsMono(ETrue);
		break;
	case 12 :
		aFontId = KScreenFontUidArialNormal15;
		break;
	case 0x9A :
#if defined(__SERIES60__)
		aFontId = KOplLatinPlain12;
#else
		aFontId = KScreenFontUidArialNormal15;
#endif
	default :
		// treat aFontId as the fonts UID
		// e.g. LatinBold12 on Series 60
		break;
		}
	return TUid::Uid(aFontId);
	}
#else
TUid OplUtil::MapFontId(TInt aFontId,TAlgStyle& /*aStyle*/)
	{
	return TUid::Uid(aFontId);
	}
#endif

//
// Character conversion stuff
//
EXPORT_C HBufC16* COplRuntimeCharConv::ConvertFromNarrowToUnicodeL(const TDesC8& aNarrowString,const TUint aCharacterSet)
	{
	HBufC* wide=ConvertFromNarrowToUnicodeLC(aNarrowString,aCharacterSet);
	CleanupStack::Pop();
	return wide;
	}

EXPORT_C HBufC16* COplRuntimeCharConv::ConvertFromNarrowToUnicodeLC(const TDesC8& aNarrowString,const TUint aCharacterSet)
	{
	HBufC* wide = HBufC::NewLC(aNarrowString.Length());
	CCnvCharacterSetConverter* charconv = CCnvCharacterSetConverter::NewLC();
	TPtr widePtr = wide->Des();
	// Convert the buffer to unicode and decode it with the current charset
	if (charconv->PrepareToConvertToOrFromL(aCharacterSet, CEikonEnv::Static()->FsSession())!=CCnvCharacterSetConverter::EAvailable)
		User::Leave(KErrNotSupported);
	TInt state = CCnvCharacterSetConverter::KStateDefault;
#ifdef _DEBUG
	const TInt conversionResult=User::LeaveIfError(charconv->ConvertToUnicode(widePtr,aNarrowString,state));
	__ASSERT_DEBUG(conversionResult==0, User::Invariant());
#else
	User::LeaveIfError(charconv->ConvertToUnicode(widePtr,aNarrowString,state));
#endif
	CleanupStack::PopAndDestroy(); // charconv
	return wide;
	}

EXPORT_C HBufC8* COplRuntimeCharConv::ConvertFromUnicodeToNarrowL(const TDesC16& aUnicodeString,const TUint aCharacterSet)
	{
	HBufC8* narrow = ConvertFromUnicodeToNarrowLC(aUnicodeString,aCharacterSet);
	CleanupStack::Pop();
	return narrow;
	}

EXPORT_C HBufC8* COplRuntimeCharConv::ConvertFromUnicodeToNarrowLC(const TDesC16& aUnicodeString,const TUint aCharacterSet)
	{
	HBufC8* narrow = HBufC8::NewLC(aUnicodeString.Length());
	CCnvCharacterSetConverter* charconv = CCnvCharacterSetConverter::NewLC();
	TPtr8 narrowPtr = narrow->Des();
	// Convert the buffer and decode it with the current charset
	if (charconv->PrepareToConvertToOrFromL(aCharacterSet, CEikonEnv::Static()->FsSession())!=CCnvCharacterSetConverter::EAvailable)
		User::Leave(KErrNotSupported);
	charconv->SetDowngradeForExoticLineTerminatingCharacters(CCnvCharacterSetConverter::EDowngradeExoticLineTerminatingCharactersToJustLineFeed);
#ifdef _DEBUG
	const TInt conversionResult=User::LeaveIfError(charconv->ConvertFromUnicode(narrowPtr, aUnicodeString));
	__ASSERT_DEBUG(conversionResult==0, User::Invariant());
#else
	User::LeaveIfError(charconv->ConvertFromUnicode(narrowPtr, aUnicodeString));
#endif
	CleanupStack::PopAndDestroy(); // charconv
	return narrow;
	}

#if defined(__UIQ__)
const CFont* OplUtil::MapFontUidToStandardFontL(const TUid /*aFontUid*/)
	{
	return CEikonEnv::Static()->NormalFont();
	}

TBool OplUtil::IsStandardFontUid(const TUid /*aFontUid*/)
	{
	return ETrue;
	}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -