examples/Graphics/Fonts/Hello.cpp

00001 /*
00002 Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description:  
00028 */
00029 
00030 
00031 
00032 #include "FontsGraphicsControl.h"
00033 
00034 _LIT(KTxtUpdateModelEnglish,"English");
00035 _LIT(KTxtUpdateModelFrench,"French");
00036 _LIT(KTxtUpdateModelGerman,"German");
00037 _LIT(KTxtUpdateModelItalian,"Italian");
00038 _LIT(KTxtUpdateModelTurkish,"Turkish");
00039 _LIT(KTxtUpdateModelJapanese,"Japanese");
00040 _LIT(KTxtUpdateModelShakespearian,"Shakespearian");
00041 _LIT(KTxtUpdateModelOverrun,"overrun!");
00042 
00043 void CHelloControl::UpdateModelL()
00044         {
00045         switch(Phase())
00046                 {
00047         case 0:
00048                 iGraphObserver->NotifyStatus(KTxtUpdateModelEnglish);
00049                 break;
00050         case 1:
00051                 iGraphObserver->NotifyStatus(KTxtUpdateModelFrench);
00052                 break;
00053         case 2:
00054                 iGraphObserver->NotifyStatus(KTxtUpdateModelGerman);
00055                 break;
00056         case 3:
00057                 iGraphObserver->NotifyStatus(KTxtUpdateModelItalian);
00058                 break;
00059         case 4:
00060                 iGraphObserver->NotifyStatus(KTxtUpdateModelTurkish);
00061                 break;
00062         case 5:
00063                 iGraphObserver->NotifyStatus(KTxtUpdateModelJapanese);
00064                 break;
00065         case 6:
00066                 iGraphObserver->NotifyStatus(KTxtUpdateModelShakespearian);
00067                 break;
00068         default:
00069                 iGraphObserver->NotifyStatus(KTxtUpdateModelOverrun);
00070                 break;
00071                 };
00072         }
00073 
00074 //Text literals
00075 _LIT(KTxtDrawCase0,"Hello world!");
00076 _LIT(KTxtDrawCase1,"Bonjour tout le monde!");
00077 _LIT(KTxtDrawCase2,"Hallo aller Welt!");
00078 _LIT(KTxtDrawCase3,"Buongiorno tutto il mondo!");
00079 _LIT(KTxtDrawCase4,"Merhaba Dunyaya!");
00080 _LIT(KTxtDrawCase5,"Ohayo gozaimasu!");
00081 _LIT(KTxtDrawCase6,"Friends, Romans, Countrymen!");
00082 
00083 void CHelloControl::Draw(const TRect& /* aRect */) const
00084         {
00085         // draw surrounding rectangle
00086         SystemGc().DrawRect(Rect());
00087         // calculate rectangle to draw into
00088         TRect rect=Rect();
00089         rect.Shrink(1,1);
00090         // calculate vertical centering
00091         CFont *font=iMessageFont;
00092         TInt ascent=
00093                         (rect.Height() - font->HeightInPixels())/2 +
00094                                 font->AscentInPixels();
00095         // draw text in rectangle
00096         CWindowGc& gc=SystemGc();
00097         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00098     gc.UseFont(iMessageFont);
00099         switch(Phase())
00100                 {
00101         case 0:
00102                 gc.DrawText(KTxtDrawCase0,rect,ascent, CGraphicsContext::ECenter, 0);
00103                 break;
00104         case 1:
00105                 gc.DrawText(KTxtDrawCase1,rect,ascent, CGraphicsContext::ECenter, 0);
00106                 break;
00107         case 2:
00108                 gc.DrawText(KTxtDrawCase2,rect,ascent, CGraphicsContext::ECenter, 0);
00109                 break;
00110         case 3:
00111                 gc.DrawText(KTxtDrawCase3,rect,ascent, CGraphicsContext::ECenter, 0);
00112                 break;
00113         case 4:
00114                 gc.DrawText(KTxtDrawCase4,rect,ascent, CGraphicsContext::ECenter, 0);
00115                 break;
00116         case 5:
00117                 gc.DrawText(KTxtDrawCase5,rect,ascent, CGraphicsContext::ECenter, 0);
00118                 break;
00119         case 6:
00120                 gc.DrawText(KTxtDrawCase6,rect,ascent, CGraphicsContext::ECenter, 0);
00121                 break;
00122         default:
00123                 break;
00124                 };
00125         }

Generated by  doxygen 1.6.2