diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_fonts_shell_8cpp-source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_fonts_shell_8cpp-source.html Tue Mar 30 11:56:28 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,229 +0,0 @@ - -
-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 #include <e32keys.h> -00017 -00018 #include <coemain.h> -00019 -00020 #include <eikenv.h> -00021 #include <eikdef.h> -00022 #include <eikon.hrh> -00023 #include <eiklabel.h> -00024 #include <eikstart.h> -00025 -00026 #include <fontsshell.rsg> -00027 #include "FontsShell.hrh" -00028 #include "FontsShell.h" -00029 #include "FontsGraphicsControl.h" -00030 -00031 // -00032 // TExampleShellModel -00033 // -00034 -00035 TExampleShellModel::TExampleShellModel() -00036 { -00037 iLibrary=KNullDesC; -00038 } -00039 -00040 TBool TExampleShellModel::Differs(const TExampleShellModel* aCompare) const -00041 { -00042 return((*(TInt32*)this)!=(*(TInt32*)aCompare)); -00043 } -00044 -00045 // -00046 // class CExampleShellContainer -00047 // -00048 -00049 void CExampleShellContainer::ConstructL(const TRect& aRect, TExampleShellModel* aModel) -00050 { -00051 iModel=aModel; -00052 CreateWindowL(); -00053 Window().SetShadowDisabled(ETrue); -00054 iContext=this; -00055 iBrushStyle=CGraphicsContext::ESolidBrush; -00056 iBrushColor=KRgbWhite; -00057 SetRect(aRect); -00058 CreateLabelL(); -00059 ActivateL(); -00060 } -00061 -00062 CExampleShellContainer::~CExampleShellContainer() -00063 { -00064 delete iExampleControl; -00065 delete iLabel; -00066 } -00067 -00068 TInt CExampleShellContainer::CountComponentControls() const -00069 { -00070 return 1 + (iExampleControl ? 1 : 0); -00071 } -00072 -00073 CCoeControl* CExampleShellContainer::ComponentControl(TInt aIndex) const -00074 { -00075 switch (aIndex) -00076 { -00077 case 0: return iLabel; -00078 case 1: return iExampleControl; -00079 default: return 0; -00080 }; -00081 } -00082 -00083 const TInt KLabelHeight=20; -00084 -00085 void CExampleShellContainer::CreateLabelL() -00086 { -00087 iLabel=new (ELeave) CEikLabel; -00088 TRect rect=Rect(); -00089 rect.iTl.iY=rect.iBr.iY-KLabelHeight; // make it bottom 20 pixels -00090 iLabel->SetContainerWindowL(*this); -00091 iLabel->SetRect(rect); -00092 iLabel->SetAlignment(EHCenterVCenter); // center text -00093 iLabel->SetBufferReserveLengthL(200); // nice long buffer -00094 iLabel->SetFont(iEikonEnv->AnnotationFont()); -00095 iLabel->ActivateL(); // now ready -00096 } -00097 -00098 void CExampleShellContainer::ResetExampleL(CGraphicExampleControl* aExample) -00099 { -00100 // get rid of old control -00101 delete iExampleControl; -00102 // set up new one -00103 iExampleControl=aExample; -00104 // if non-zero, then carry on -00105 if (!iExampleControl) return; -00106 TRect rect=Rect(); // get our rect -00107 rect.iBr.iY-=KLabelHeight; // make way for label -00108 rect.Shrink(2,2); // shrink it a bit -00109 iExampleControl->ConstructL(rect,this,*this); // construct, giving rect and observer -00110 } -00111 -00112 _LIT(KTxtFinished,"example finished"); -00113 void CExampleShellContainer::NotifyGraphicExampleFinished() -00114 { -00115 NotifyStatus(KTxtFinished); -00116 } -00117 -00118 void CExampleShellContainer::NotifyStatus(const TDesC& aMessage) -00119 { -00120 TRAPD(err,iLabel->SetTextL(aMessage)); -00121 if(err) -00122 { -00123 return; -00124 } -00125 if (IsActivated()) iLabel->DrawNow(); -00126 } -00127 -00128 TKeyResponse CExampleShellContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) -00129 { -00130 if (iExampleControl) -00131 return iExampleControl->OfferKeyEventL(aKeyEvent,aType); -00132 else -00133 return EKeyWasNotConsumed; -00134 } -00135 -00136 void CExampleShellContainer::Draw(const TRect& /*aRect*/) const -00137 { -00138 CWindowGc& gc = SystemGc(); -00139 gc.SetPenStyle(CGraphicsContext::ENullPen); -00140 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); -00141 gc.DrawRect(Rect()); -00142 } -00143 -00144 // -00145 // CExampleShellAppUi -00146 // -00147 -00148 _LIT(KTxtInitialized,"initialized"); -00149 void CExampleShellAppUi::ConstructL() -00150 { -00151 BaseConstructL(); -00152 iModel=((CExampleShellDocument*)iDocument)->Model(); -00153 iContainer=new(ELeave) CExampleShellContainer; -00154 iContainer->ConstructL(ClientRect(),iModel); -00155 iContainer->NotifyStatus(KTxtInitialized); -00156 // add container to stack; enables key event handling. -00157 AddToStackL(iContainer); -00158 } -00159 -00160 void CExampleShellAppUi::HandleCommandL(TInt aCommand) -00161 { -00162 switch (aCommand) -00163 { -00164 case EExampleShellSelectHello: -00165 iContainer->ResetExampleL(new (ELeave) CHelloControl); -00166 return; -00167 case EExampleShellSelectFont: -00168 iContainer->ResetExampleL(new (ELeave) CFontControl); -00169 return; -00170 case EEikCmdExit: -00171 Exit(); -00172 return; -00173 } -00174 } -00175 -00176 CExampleShellAppUi::~CExampleShellAppUi() -00177 { -00178 RemoveFromStack(iContainer); -00179 delete iContainer; -00180 } -00181 -00182 // -00183 // CExampleShellDocument -00184 // -00185 -00186 CEikAppUi* CExampleShellDocument::CreateAppUiL() -00187 { -00188 return(new(ELeave) CExampleShellAppUi); -00189 } -00190 -00191 // -00192 // CExampleShellApplication -00193 // -00194 -00195 TUid CExampleShellApplication::AppDllUid() const -00196 { -00197 return KUidExampleShellApp; -00198 } -00199 -00200 CApaDocument* CExampleShellApplication::CreateDocumentL() -00201 { -00202 return new(ELeave) CExampleShellDocument(*this); -00203 } -00204 -00205 // -00206 // EXPORTed functions -00207 // -00208 -00209 EXPORT_C CApaApplication* NewApplication() -00210 { -00211 return new CExampleShellApplication; -00212 } -00213 -00214 GLDEF_C TInt E32Main() -00215 { -00216 return EikStart::RunApplication(NewApplication); -00217 } -