00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "FontsGraphicsControl.h"
00032 #include <coemain.h>
00033
00034 CFontControl::CFontControl() {
00035
00036 iNumTypefaces = iCoeEnv->ScreenDevice()->NumTypefaces();
00037
00038 SetMaxPhases(iNumTypefaces);
00039 }
00040
00041 void CFontControl::UpdateModelL()
00042 {
00043
00044 iZoomFactor.SetGraphicsDeviceMap(iCoeEnv->ScreenDevice());
00045 iZoomFactor.SetZoomFactor(TZoomFactor::EZoomOneToOne);
00046 iDeviceMap = &iZoomFactor;
00047
00048
00049 TTypefaceSupport* myTypefaceSupport = new TTypefaceSupport;
00050 iCoeEnv->ScreenDevice()->TypefaceSupport(*myTypefaceSupport,Phase());
00051 iCurrentFont = myTypefaceSupport->iTypeface.iName.Des();
00052
00053
00054 _LIT(KFormat,"Typeface index=%d. Name=%S. Num heights=%d. (Num typefaces=%d)");
00055 TBuf<128> commentaryText;
00056 commentaryText.Format(KFormat,Phase(),&iCurrentFont,myTypefaceSupport->iNumHeights,iNumTypefaces);
00057 iGraphObserver->NotifyStatus(commentaryText);
00058 delete myTypefaceSupport;
00059 };
00060
00061 void CFontControl::Draw(const TRect& ) const
00062 {
00063
00064 CWindowGc& gc=SystemGc();
00065 gc.Clear();
00066
00067
00068 TRect screenRect=Rect();
00069
00070
00071 TFontSpec fontSpec(iCurrentFont,300);
00072
00073 CFont* screenFont;
00074 iDeviceMap->GetNearestFontInTwips(screenFont,fontSpec);
00075
00076 gc.UseFont(screenFont);
00077
00078
00079 TInt screenHeight=screenRect.Height();
00080
00081 TInt textHeight = screenFont->HeightInPixels();
00082
00083
00084 TInt exampleMargin = 0;
00085 TInt currentOffset = ((screenHeight+textHeight)/2) - (TInt)(textHeight*2.4);
00086
00087
00088 TBuf<50> buffer;
00089 TInt endPoint[6] = {64,96,138,182,216,255};
00090 TInt count = 32;
00091 for(TInt pass=0;pass<=5;pass++) {
00092 while (count<=endPoint[pass]) {
00093 buffer.Append((TUint)count);
00094 count++;
00095 }
00096
00097 gc.DrawText(buffer,screenRect,currentOffset,CGraphicsContext::ECenter,exampleMargin);
00098 currentOffset = currentOffset + (TInt)(textHeight*1.2);
00099 buffer.Zero();
00100 }
00101
00102
00103 gc.DiscardFont();
00104 iDeviceMap->ReleaseFont(screenFont);
00105 }