examples/Graphics/Fonts/Hello.cpp

00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 //
00015 
00016 
00017 #include "FontsGraphicsControl.h"
00018 
00019 _LIT(KTxtUpdateModelEnglish,"English");
00020 _LIT(KTxtUpdateModelFrench,"French");
00021 _LIT(KTxtUpdateModelGerman,"German");
00022 _LIT(KTxtUpdateModelItalian,"Italian");
00023 _LIT(KTxtUpdateModelTurkish,"Turkish");
00024 _LIT(KTxtUpdateModelJapanese,"Japanese");
00025 _LIT(KTxtUpdateModelShakespearian,"Shakespearian");
00026 _LIT(KTxtUpdateModelOverrun,"overrun!");
00027 
00028 void CHelloControl::UpdateModelL()
00029         {
00030         switch(Phase())
00031                 {
00032         case 0:
00033                 iGraphObserver->NotifyStatus(KTxtUpdateModelEnglish);
00034                 break;
00035         case 1:
00036                 iGraphObserver->NotifyStatus(KTxtUpdateModelFrench);
00037                 break;
00038         case 2:
00039                 iGraphObserver->NotifyStatus(KTxtUpdateModelGerman);
00040                 break;
00041         case 3:
00042                 iGraphObserver->NotifyStatus(KTxtUpdateModelItalian);
00043                 break;
00044         case 4:
00045                 iGraphObserver->NotifyStatus(KTxtUpdateModelTurkish);
00046                 break;
00047         case 5:
00048                 iGraphObserver->NotifyStatus(KTxtUpdateModelJapanese);
00049                 break;
00050         case 6:
00051                 iGraphObserver->NotifyStatus(KTxtUpdateModelShakespearian);
00052                 break;
00053         default:
00054                 iGraphObserver->NotifyStatus(KTxtUpdateModelOverrun);
00055                 break;
00056                 };
00057         }
00058 
00059 //Text literals
00060 _LIT(KTxtDrawCase0,"Hello world!");
00061 _LIT(KTxtDrawCase1,"Bonjour tout le monde!");
00062 _LIT(KTxtDrawCase2,"Hallo aller Welt!");
00063 _LIT(KTxtDrawCase3,"Buongiorno tutto il mondo!");
00064 _LIT(KTxtDrawCase4,"Merhaba Dunyaya!");
00065 _LIT(KTxtDrawCase5,"Ohayo gozaimasu!");
00066 _LIT(KTxtDrawCase6,"Friends, Romans, Countrymen!");
00067 
00068 void CHelloControl::Draw(const TRect& /* aRect */) const
00069         {
00070         // draw surrounding rectangle
00071         SystemGc().DrawRect(Rect());
00072         // calculate rectangle to draw into
00073         TRect rect=Rect();
00074         rect.Shrink(1,1);
00075         // calculate vertical centering
00076         CFont *font=iMessageFont;
00077         TInt ascent=
00078                         (rect.Height() - font->HeightInPixels())/2 +
00079                                 font->AscentInPixels();
00080         // draw text in rectangle
00081         CWindowGc& gc=SystemGc();
00082         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00083     gc.UseFont(iMessageFont);
00084         switch(Phase())
00085                 {
00086         case 0:
00087                 gc.DrawText(KTxtDrawCase0,rect,ascent, CGraphicsContext::ECenter, 0);
00088                 break;
00089         case 1:
00090                 gc.DrawText(KTxtDrawCase1,rect,ascent, CGraphicsContext::ECenter, 0);
00091                 break;
00092         case 2:
00093                 gc.DrawText(KTxtDrawCase2,rect,ascent, CGraphicsContext::ECenter, 0);
00094                 break;
00095         case 3:
00096                 gc.DrawText(KTxtDrawCase3,rect,ascent, CGraphicsContext::ECenter, 0);
00097                 break;
00098         case 4:
00099                 gc.DrawText(KTxtDrawCase4,rect,ascent, CGraphicsContext::ECenter, 0);
00100                 break;
00101         case 5:
00102                 gc.DrawText(KTxtDrawCase5,rect,ascent, CGraphicsContext::ECenter, 0);
00103                 break;
00104         case 6:
00105                 gc.DrawText(KTxtDrawCase6,rect,ascent, CGraphicsContext::ECenter, 0);
00106                 break;
00107         default:
00108                 break;
00109                 };
00110         }

Generated by  doxygen 1.6.2