00001 // 00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 00003 // All rights reserved. 00004 // This component and the accompanying materials are made available 00005 // under the terms of the License "Eclipse Public License v1.0" 00006 // which accompanies this distribution, and is available 00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00008 // 00009 // Initial Contributors: 00010 // Nokia Corporation - initial contribution. 00011 // 00012 // Contributors: 00013 // 00014 // Description: 00015 // 00016 00017 // INCLUDES 00018 #include <eikedwin.h> 00019 #include <eikenv.h> 00020 #include <aknutils.h> 00021 #include <AudioTone.rsg> 00022 00023 #include "AudioToneMainView.h" 00024 00025 // MEMBER FUNCTIONS 00026 00027 // -------------------------------------------------------------------------- 00028 // Two-phase constructor 00029 // -------------------------------------------------------------------------- 00030 CAudioToneMainView* CAudioToneMainView::NewL(const TRect& aRect) 00031 { 00032 CAudioToneMainView* self = CAudioToneMainView::NewLC(aRect); 00033 CleanupStack::Pop(self); 00034 return self; 00035 } 00036 00037 // -------------------------------------------------------------------------- 00038 // Two-phase constructor 00039 // -------------------------------------------------------------------------- 00040 CAudioToneMainView* CAudioToneMainView::NewLC(const TRect& aRect) 00041 { 00042 CAudioToneMainView* self = new (ELeave) CAudioToneMainView; 00043 CleanupStack::PushL(self); 00044 self->ConstructL(aRect); 00045 return self; 00046 } 00047 00048 // -------------------------------------------------------------------------- 00049 // Destructor 00050 // -------------------------------------------------------------------------- 00051 CAudioToneMainView::~CAudioToneMainView() 00052 { 00053 delete iEikEdwin; 00054 } 00055 00056 // -------------------------------------------------------------------------- 00057 // Second phase constructor 00058 // -------------------------------------------------------------------------- 00059 void CAudioToneMainView::ConstructL(const TRect& aRect) 00060 { 00061 CreateWindowL(); 00062 00063 // Create an edwin on this control. 00064 iEikEdwin = new (ELeave) CEikEdwin(); 00065 iEikEdwin->ConstructL(CEikEdwin::EReadOnly | CEikEdwin::ENoAutoSelection); 00066 iEikEdwin->SetContainerWindowL(*this); 00067 HBufC* message = ControlEnv()->AllocReadResourceLC(R_AUDIOTONE_TEXT); 00068 iEikEdwin->SetTextL(message); 00069 CleanupStack::PopAndDestroy(message); 00070 00071 SetRect(aRect); 00072 ActivateL(); 00073 } 00074 00075 // -------------------------------------------------------------------------- 00076 // Sets the text to be displayed on this control. 00077 // -------------------------------------------------------------------------- 00078 void CAudioToneMainView::SetTextL(const TDesC& aText) 00079 { 00080 if (iEikEdwin) 00081 { 00082 iEikEdwin->SetTextL(&aText); 00083 DrawDeferred(); 00084 } 00085 } 00086 00087 // -------------------------------------------------------------------------- 00088 // Returns the number of controls. 00089 // In this example, it returns 1 because there is only one 00090 // control, which is an edwin control. 00091 // -------------------------------------------------------------------------- 00092 TInt CAudioToneMainView::CountComponentControls() const 00093 { 00094 if (iEikEdwin) 00095 { 00096 return 1; 00097 } 00098 return 0; 00099 } 00100 00101 // -------------------------------------------------------------------------- 00102 // Returns the pointer of the controls. 00103 // In this example, it returns the pointer of the edwin control. 00104 // -------------------------------------------------------------------------- 00105 CCoeControl* CAudioToneMainView::ComponentControl(TInt aIndex) const 00106 { 00107 switch (aIndex) 00108 { 00109 case 0: 00110 return iEikEdwin; 00111 default: 00112 break; 00113 } 00114 return 0; 00115 } 00116 00117 // -------------------------------------------------------------------------- 00118 // Called when this control needs to be redrawn. 00119 // -------------------------------------------------------------------------- 00120 void CAudioToneMainView::Draw(const TRect& /*aRect*/) const 00121 { 00122 CWindowGc& gc = SystemGc(); 00123 gc.Clear(); 00124 } 00125 00126 // -------------------------------------------------------------------------- 00127 // Called when the size/resolution of this control has been 00128 // changed. If this happens, the size of the edwin has to be 00129 // adjusted as well. 00130 // -------------------------------------------------------------------------- 00131 void CAudioToneMainView::SizeChanged() 00132 { 00133 if (iEikEdwin) 00134 { 00135 TRect rect(Rect()); 00136 iEikEdwin->SetExtent( 00137 TPoint(0, 0), 00138 TSize(rect.Width(), rect.Height())); 00139 } 00140 } 00141 00142 // End of File