00001
00002
00003
00004
00005
00006 #include <aknutils.h>
00007 #include <w32std.h>
00008 #include "AudioStreamView.h"
00009
00010 #include <TXTRICH.H>
00011
00012
00013 const TUint KNumberOfLines = 0;
00014 const TUint KTextLimit = 0;
00015
00016
00017 CAudioStreamView* CAudioStreamView::NewL(const TRect & aRect,
00018 CAudioStreamEngine* aEngine)
00019 {
00020 CAudioStreamView* self = NewLC(aRect, aEngine);
00021 CleanupStack::Pop(self);
00022 return self;
00023 }
00024
00025 CAudioStreamView* CAudioStreamView::NewLC(const TRect & aRect,
00026 CAudioStreamEngine* aEngine)
00027 {
00028 CAudioStreamView* self = new (ELeave) CAudioStreamView();
00029 CleanupStack::PushL(self);
00030 self->ConstructL(aRect, aEngine);
00031 return self;
00032 }
00033
00034
00035
00036
00037
00038
00039
00040 void CAudioStreamView::ConstructL(const TRect& aRect,
00041 CAudioStreamEngine* aEngine)
00042 {
00043 iEngine = aEngine;
00044
00045 CreateWindowL();
00046
00047
00048 iLogComponent = new(ELeave) CEikRichTextEditor;
00049 iLogComponent->ConstructL(this, KNumberOfLines, KTextLimit,
00050 CEikEdwin::EReadOnly | CEikEdwin::EAvkonDisableCursor);
00051 iLogComponent->CreateScrollBarFrameL()->SetScrollBarVisibilityL(
00052 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn);
00053
00054
00055 #ifdef __WINS__
00056 _LIT(KFontArial,"Arial");
00057 TFontSpec MyeFontSpec (KFontArial, 8*10);
00058 MyeFontSpec.iTypeface.SetIsProportional(ETrue);
00059
00060 TCharFormatMask charFormatMask;
00061 charFormatMask.SetAttrib(EAttFontHeight);
00062 TCharFormat charFormat(MyeFontSpec.iTypeface.iName, MyeFontSpec.iHeight);
00063 charFormat.iFontPresentation.iTextColor=KRgbBlack;
00064 charFormat.iFontSpec.iHeight=100;
00065
00066 CRichText* text = iLogComponent->RichText();
00067 text->ApplyCharFormatL(charFormat,charFormatMask,0,1);
00068 #endif
00069
00070 SetRect(aRect);
00071 _LIT(KInfo, "Audio streaming example");
00072 ShowMessageL(KInfo);
00073
00074
00075 ActivateL();
00076
00077
00078
00079 SetRect(aRect);
00080 }
00081
00082
00083
00084
00085
00086
00087 CAudioStreamView::CAudioStreamView()
00088 {
00089 }
00090
00091
00092
00093
00094
00095
00096 CAudioStreamView::~CAudioStreamView()
00097 {
00098 delete iLogComponent;
00099 }
00100
00101
00102
00103
00104
00105
00106 void CAudioStreamView::SizeChanged()
00107 {
00108 TRect rect = Rect();
00109
00110 TInt scrollbarWidth = iLogComponent->ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical);
00111
00112
00113 if (scrollbarWidth == 0)
00114 {
00115 scrollbarWidth = 8;
00116 }
00117 iLogComponent->SetExtent(TPoint(0, 0),
00118 TSize(rect.Width() - scrollbarWidth, rect.Height()));
00119 DrawNow();
00120 }
00121
00122
00123
00124
00125
00126
00127 void CAudioStreamView::HandleResourceChange(TInt aType)
00128 {
00129 CCoeControl::HandleResourceChange(aType);
00130 if ( aType==KEikDynamicLayoutVariantSwitch )
00131 {
00132 TRect rect;
00133 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00134 SetRect(rect);
00135 }
00136 }
00137
00138
00139
00140
00141
00142 TInt CAudioStreamView::CountComponentControls() const
00143 {
00144 return 1;
00145 }
00146
00147
00148
00149
00150 CCoeControl* CAudioStreamView::ComponentControl(TInt aIndex) const
00151 {
00152 switch ( aIndex )
00153 {
00154 case 0:
00155 return iLogComponent;
00156 default:
00157 return NULL;
00158 }
00159 }
00160
00161
00162
00163
00164
00165 void CAudioStreamView::Draw( const TRect& aRect ) const
00166 {
00167 CWindowGc& gc = SystemGc();
00168 gc.SetPenStyle( CGraphicsContext::ENullPen );
00169 gc.SetBrushColor( KRgbWhite );
00170 gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
00171 gc.DrawRect( aRect );
00172 }
00173
00174
00175
00176
00177
00178
00179 void CAudioStreamView::ShowMessageL(const TDesC& aMsg)
00180 {
00181 CPlainText* text = iLogComponent->Text();
00182 text->InsertL(text->DocumentLength(), aMsg);
00183 text->InsertL(text->DocumentLength(), CEditableText::ELineBreak);
00184 iLogComponent->HandleTextChangedL();
00185
00186 iLogComponent->MoveCursorL(TCursorPosition::EFPageDown, EFalse);
00187 DrawNow();
00188 }
00189
00190
00191
00192
00193