|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : AudioStreamView.cpp 00004 * Part of : AudioStream 00005 * Created : April 28, 2006 by Forum Nokia 00006 * Description : 00007 * Version : 2.0 00008 * 00009 * Copyright (c) 2006 - 2007 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. 00013 * ============================================================================== 00014 */ 00015 00016 // INCLUDE FILES 00017 #include <aknutils.h> // Fonts 00018 #include <w32std.h> // key codes and events 00019 00020 #include "AudioStreamView.h" 00021 00022 00023 CAudioStreamView* CAudioStreamView::NewL(const TRect & aRect, 00024 CAudioStreamEngine* aEngine) 00025 { 00026 CAudioStreamView* self = NewLC(aRect, aEngine); 00027 CleanupStack::Pop(self); 00028 return self; 00029 } 00030 00031 CAudioStreamView* CAudioStreamView::NewLC(const TRect & aRect, 00032 CAudioStreamEngine* aEngine) 00033 { 00034 CAudioStreamView* self = new (ELeave) CAudioStreamView(); 00035 CleanupStack::PushL(self); 00036 self->ConstructL(aRect, aEngine); 00037 return self; 00038 } 00039 00040 // ---------------------------------------------------------------------------- 00041 // CAudioStreamView::ConstructL(const TRect& aRect, 00042 // CAudioStreamEngine* aEngine) 00043 // 00044 // Standard EPOC 2nd phase constructor 00045 // ---------------------------------------------------------------------------- 00046 void CAudioStreamView::ConstructL(const TRect& aRect, 00047 CAudioStreamEngine* aEngine) 00048 { 00049 iEngine = aEngine; 00050 // create new window, 00051 CreateWindowL(); 00052 // create label to display status to user 00053 iLabel = new (ELeave) CEikLabel; 00054 iLabel->SetContainerWindowL( *this ); 00055 #ifndef __SERIES60_3X__ 00056 // The default font is too big in 2nd Edition devices 00057 iLabel->SetFont( LatinBold12() ); 00058 #endif 00059 // set window size 00060 SetRect(aRect); 00061 00062 _LIT(KInfo, "Audio streaming example\n"); 00063 iLabel->SetTextL( KInfo ); 00064 00065 // activate window 00066 ActivateL(); 00067 } 00068 00069 // ---------------------------------------------------------------------------- 00070 // CAudioStreamView::CAudioStreamView() 00071 // 00072 // constructor 00073 // ---------------------------------------------------------------------------- 00074 CAudioStreamView::CAudioStreamView(): 00075 iLabel(NULL) 00076 { 00077 } 00078 00079 // ---------------------------------------------------------------------------- 00080 // CAudioStreamView::~CAudioStreamView() 00081 // 00082 // destructor 00083 // ---------------------------------------------------------------------------- 00084 CAudioStreamView::~CAudioStreamView() 00085 { 00086 delete iLabel; 00087 iLabel=NULL; 00088 } 00089 00090 // ---------------------------------------------------------------------------- 00091 // CAudioStreamView::SizeChanged() 00092 // 00093 // called by framework when the view size is changed 00094 // ---------------------------------------------------------------------------- 00095 void CAudioStreamView::SizeChanged() 00096 { 00097 iLabel->SetRect( Rect() ); 00098 } 00099 00100 // --------------------------------------------------------- 00101 // CAudioStreamView::HandleResourceChange() 00102 // Called by framework when resource is changed. 00103 // --------------------------------------------------------- 00104 // 00105 void CAudioStreamView::HandleResourceChange(TInt aType) 00106 { 00107 CCoeControl::HandleResourceChange(aType); 00108 00109 // ADDED FOR SCALABLE UI SUPPORT 00110 // ***************************** 00111 if ( aType==KEikDynamicLayoutVariantSwitch ) 00112 { 00113 TRect rect; 00114 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); 00115 SetRect(rect); 00116 } 00117 } 00118 00119 00120 // ---------------------------------------------------------------------------- 00121 // CAudioStreamView::CountComponentControls() const 00122 // ---------------------------------------------------------------------------- 00123 TInt CAudioStreamView::CountComponentControls() const 00124 { 00125 return 1; // return number of controls inside this container 00126 } 00127 00128 // ---------------------------------------------------------------------------- 00129 // CAudioStreamView::ComponentControl(TInt aIndex) const 00130 // ---------------------------------------------------------------------------- 00131 CCoeControl* CAudioStreamView::ComponentControl(TInt aIndex) const 00132 { 00133 switch ( aIndex ) 00134 { 00135 case 0: 00136 return iLabel; 00137 default: 00138 return NULL; 00139 } 00140 } 00141 00142 00143 // ---------------------------------------------------------------------------- 00144 // CAudioStreamView::Draw(const TRect& aRect) const 00145 // ---------------------------------------------------------------------------- 00146 void CAudioStreamView::Draw( const TRect& aRect ) const 00147 { 00148 CWindowGc& gc = SystemGc(); 00149 gc.SetPenStyle( CGraphicsContext::ENullPen ); 00150 gc.SetBrushColor( KRgbWhite ); 00151 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); 00152 gc.DrawRect( aRect ); 00153 } 00154 00155 00156 // ---------------------------------------------------------------------------- 00157 // CAudioStreamView::HandleControlEventL( 00158 // CCoeControl* aControl,TCoeEvent aEventType) 00159 // ---------------------------------------------------------------------------- 00160 void CAudioStreamView::HandleControlEventL( 00161 CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) 00162 { 00163 } 00164 00165 00166 // ---------------------------------------------------------------------------- 00167 // CAudioStreamView::ShowMessageL(const TDesC& aMsg) 00168 // 00169 // displays status messages to user 00170 // ---------------------------------------------------------------------------- 00171 void CAudioStreamView::ShowMessageL(const TDesC& aMsg) 00172 { 00173 iLabel->SetTextL(aMsg); 00174 DrawNow(); 00175 } 00176 00177 00178 // End of File 00179 00180
|
© Nokia 2009 |