sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Part of the MVS Application for TechView sl@0: // sl@0: sl@0: #include sl@0: sl@0: #include "MVSApp.h" sl@0: #include "MVSAppUI.h" sl@0: #include "mvsvideocontrol.h" sl@0: sl@0: CMVSAppView* CMVSAppView::NewL(const TRect& aRect, CMVSVideoPlayAgent& aVideoPlayAgent) sl@0: { sl@0: CMVSAppView * self = new(ELeave) CMVSAppView; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aRect, aVideoPlayAgent); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: CMVSAppView::CMVSAppView() sl@0: { sl@0: } sl@0: sl@0: sl@0: CMVSAppView::~CMVSAppView() sl@0: { sl@0: //Remove our controls sl@0: delete iMainWindowControl; sl@0: delete iStatusWindowFNameControl; sl@0: delete iStatusWindowStateControl; sl@0: delete iStatusWindowTimeControl; sl@0: delete iInfoWindowControl; sl@0: delete iProgress; sl@0: sl@0: CloseWindow(); sl@0: } sl@0: sl@0: sl@0: void CMVSAppView::ConstructL(const TRect& aRect, CMVSVideoPlayAgent& aVideoPlayAgent) sl@0: { sl@0: //we need a window in which to place controls, so take ownership of one sl@0: CreateWindowL(); sl@0: sl@0: //Set the extent of the control. sl@0: SetRect(aRect); sl@0: TRect fullRectWindow = Rect(); sl@0: //vertical point co-ordinate sl@0: TInt statusPaneHeight = 4*(fullRectWindow.iTl.iY + fullRectWindow.iBr.iY)/5; sl@0: TInt halfLength = (fullRectWindow.iTl.iX + fullRectWindow.iBr.iX)/2; sl@0: TInt threeQuarterLength= 3*(fullRectWindow.iTl.iX + fullRectWindow.iBr.iX)/4; sl@0: sl@0: //set the dimensions of our main window sl@0: TRect mainWindow(Rect()); sl@0: mainWindow.iTl.iX = halfLength-115; sl@0: mainWindow.iBr.iY = statusPaneHeight; sl@0: sl@0: iMainWindowControl = CMVSVideoControl::NewL(aVideoPlayAgent, 0, Window()); sl@0: iMainWindowControl->SetExtent(mainWindow.iTl, mainWindow.Size()); sl@0: sl@0: //set the dimensions of our status window sl@0: TRect statusWindowFName = fullRectWindow; sl@0: statusWindowFName.iTl.iY = statusPaneHeight; sl@0: statusWindowFName.iBr.iX = halfLength; sl@0: sl@0: //now construct our status window filename control sl@0: iStatusWindowFNameControl = CMVSFileControl::NewL(*this, statusWindowFName, sl@0: KNullDesC); sl@0: //set the dimensions of our state window sl@0: TRect statusWindowState = fullRectWindow; sl@0: statusWindowState.iTl.iX = halfLength; sl@0: statusWindowState.iTl.iY = statusPaneHeight; sl@0: statusWindowState.iBr.iX = threeQuarterLength; sl@0: sl@0: //now construct our status window state control sl@0: iStatusWindowStateControl = CMVSStateControl::NewL(*this, statusWindowState, sl@0: KNullDesC); sl@0: sl@0: //set the dimensions of our timer window sl@0: TRect statusWindowTime = fullRectWindow; sl@0: statusWindowTime.iTl.iX = threeQuarterLength; sl@0: statusWindowTime.iTl.iY = statusPaneHeight; sl@0: sl@0: //now construct our status window timer control sl@0: iStatusWindowTimeControl = CMVSTimeControl::NewL(*this, statusWindowTime, sl@0: KNullDesC); sl@0: TRect infoWindow = fullRectWindow; sl@0: infoWindow.iTl.iX=0; sl@0: infoWindow.iBr.iX= halfLength-115; sl@0: infoWindow.iBr.iY =statusPaneHeight-15; sl@0: iInfoWindowControl = CMVSInfoControl::NewL(*this,infoWindow,KNullDesC); sl@0: iInfoWindowControl->SetParent(this); sl@0: //now activate the control. sl@0: sl@0: // construct and draw the progress bar sl@0: iProgress = new (ELeave) CEikProgressInfo(); sl@0: sl@0: TResourceReader reader; sl@0: iEikonEnv->CreateResourceReaderLC(reader, R_CLIP_PROGRESSINFO); sl@0: iProgress->ConstructFromResourceL(reader); sl@0: iProgress->SetContainerWindowL(*this); sl@0: iProgress->SetExtent(TPoint(fullRectWindow.iTl.iX+ (fullRectWindow.iBr.iX/20),statusPaneHeight-10),TSize((fullRectWindow.iBr.iX - fullRectWindow.iTl.iX - (fullRectWindow.iBr.iX/10) ),10)); sl@0: iProgress->SetAndDraw(0); sl@0: CleanupStack::PopAndDestroy(); sl@0: sl@0: ActivateL(); sl@0: } sl@0: sl@0: void CMVSAppView::SetClipLength(TInt& aClipLen) sl@0: { sl@0: iClipLength = aClipLen; sl@0: } sl@0: sl@0: // sl@0: //CountComponentControls() sl@0: // sl@0: // Implemented by a view with more than one control so that a call to sl@0: // DrawNow successfully draws all four component controls. sl@0: // sl@0: TInt CMVSAppView::CountComponentControls() const sl@0: { sl@0: return 6; //we have six controls sl@0: } sl@0: sl@0: // sl@0: // To handle the Pointer events on the Progress Bar sl@0: // sl@0: void CMVSAppView::HandlePointerEventL(const TPointerEvent &aPointerEvent) sl@0: { sl@0: TInt clipPos; sl@0: TRect rect = iProgress->Rect(); sl@0: if( (aPointerEvent.iPosition.iX>=rect.iTl.iX && aPointerEvent.iPosition.iX<=rect.iBr.iX) && sl@0: (aPointerEvent.iPosition.iY>=rect.iTl.iY && aPointerEvent.iPosition.iY<=rect.iBr.iY) ) sl@0: { sl@0: TInt pos = aPointerEvent.iPosition.iX - rect.iTl.iX; sl@0: switch(aPointerEvent.iType) sl@0: { sl@0: case TPointerEvent::EButton1Down: sl@0: break; sl@0: case TPointerEvent::EDrag: sl@0: { sl@0: iProgress->SetAndDraw(pos); sl@0: break; sl@0: } sl@0: case TPointerEvent::EButton1Up: sl@0: { sl@0: TInt progToDraw = pos* (static_cast(200)/(rect.iBr.iX -rect.iTl.iX)); sl@0: iProgress->SetAndDraw(progToDraw+1); sl@0: clipPos = (progToDraw+1) *(static_cast(iClipLength)/200); sl@0: TTimeIntervalMicroSeconds clipTime(clipPos); sl@0: static_cast(CEikonEnv::Static()->EikAppUi())->SetPosition(clipTime); sl@0: break; sl@0: } sl@0: sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: CCoeControl::HandlePointerEventL(aPointerEvent); sl@0: sl@0: } sl@0: sl@0: sl@0: // sl@0: // Updates the Audion play progress sl@0: // sl@0: void CMVSAppView::UpdatePlayProgress(TTimeIntervalMicroSeconds& aPos) sl@0: { sl@0: TInt curPos = I64INT(aPos.Int64()); sl@0: TInt percent = curPos*(static_cast(100)/iClipLength); sl@0: TInt progressPos = percent*2; sl@0: iProgress->SetAndDraw(progressPos+1); sl@0: } sl@0: sl@0: // sl@0: // Reset the Progress to ) and redraw sl@0: // sl@0: void CMVSAppView::ResetProgressBar() sl@0: { sl@0: iProgress->SetAndDraw(0); sl@0: } sl@0: // sl@0: //ComponentControl(...) sl@0: // sl@0: // Returns the control by index. The counting sequence goes left to right, top sl@0: // to bottom. sl@0: // sl@0: CCoeControl* CMVSAppView::ComponentControl(TInt aIndex) const sl@0: { sl@0: switch (aIndex) sl@0: { sl@0: case 0: return iMainWindowControl; sl@0: case 1: return iStatusWindowFNameControl; sl@0: case 2: return iStatusWindowStateControl; sl@0: case 3: return iStatusWindowTimeControl; sl@0: case 4: return iInfoWindowControl; sl@0: case 5: return iProgress; sl@0: default: return 0; sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // sl@0: // class CMVSFileControl sl@0: // sl@0: // sl@0: sl@0: sl@0: sl@0: // sl@0: //NewL(...) *** This method can LEAVE *** sl@0: // sl@0: // Factory contructor, initialises a control based on the rectangle provided. sl@0: // sl@0: CMVSFileControl* CMVSFileControl::NewL(const CCoeControl& aContainer, sl@0: const TRect& aRect, sl@0: const TDesC& aText) sl@0: { sl@0: CMVSFileControl* self=new(ELeave) CMVSFileControl; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aContainer, aRect, aText); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: // sl@0: //ContructL(...) *** This method can LEAVE *** sl@0: // sl@0: // sl@0: void CMVSFileControl::ConstructL(const CCoeControl& aContainer, sl@0: const TRect& aRect, const TDesC& aText) sl@0: { sl@0: SetContainerWindowL(aContainer); sl@0: SetRect(aRect); sl@0: iWindow = aRect; sl@0: SetTextL(aText); sl@0: //Activate the control sl@0: ActivateL(); sl@0: } sl@0: sl@0: sl@0: // sl@0: //CMVSControl() sl@0: // sl@0: // Constructor, does nothing. Private to prevent it being called. sl@0: // sl@0: CMVSFileControl::CMVSFileControl() sl@0: { sl@0: } sl@0: sl@0: sl@0: // sl@0: //~CMVSControl() sl@0: // sl@0: // Destructor. sl@0: // sl@0: CMVSFileControl::~CMVSFileControl() sl@0: { sl@0: delete iText; sl@0: } sl@0: sl@0: sl@0: //Draw the FileName Display Window sl@0: void CMVSFileControl::Draw(const TRect& /*aRect*/) const sl@0: { sl@0: //Establish a Graphics Context sl@0: CWindowGc& gc=SystemGc(); sl@0: sl@0: //Establish a drawing rectangle sl@0: TRect rect=Rect(); sl@0: sl@0: //Move in 2 pixels each side to give a white border sl@0: rect.Shrink(2,2); sl@0: sl@0: //Set-up a pen sl@0: gc.SetPenStyle(CGraphicsContext::ENullPen); sl@0: gc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: gc.SetBrushColor(KRgbDarkGray); sl@0: sl@0: //Draw a blank rectangle sl@0: gc.DrawRect(rect); sl@0: sl@0: //Fill in the border-regions sl@0: DrawUtils::DrawBetweenRects(gc, Rect(), rect); sl@0: sl@0: //Change the pen colour to black sl@0: gc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: gc.SetPenColor(KRgbWhite); sl@0: sl@0: //Set the fill colour to 'no fill' sl@0: gc.SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: sl@0: //Draw a rectangle (transparent with a black border) sl@0: gc.DrawRect(rect); sl@0: rect.Shrink(1,1); sl@0: sl@0: const CFont* appFont = iEikonEnv->AnnotationFont(); sl@0: DrawOtherWindows(gc,rect,appFont); sl@0: return; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: //DrawOtherWindows(...) sl@0: // sl@0: // Draw the text in a central position in the window. sl@0: // sl@0: void CMVSFileControl::DrawOtherWindows(CGraphicsContext& aGc, sl@0: const TRect& aDeviceRect, sl@0: const CFont* aFont) const sl@0: { sl@0: //Set up the pen and brush colours sl@0: aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc.SetBrushColor(KRgbGray); sl@0: sl@0: aGc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc.SetPenColor(KRgbWhite); sl@0: sl@0: //Set-up a font sl@0: aGc.UseFont(aFont); sl@0: sl@0: //Set the baseline to be half the height of the rectangle + half sl@0: //the height of the font sl@0: TInt baseline=aDeviceRect.Height()/2 + aFont->AscentInPixels()/2; sl@0: sl@0: //Draw the text sl@0: //__ASSERT_ALWAYS(iText != NULL, User::Panic(KNullPtr, KNAPanicNullPointer)); sl@0: aGc.DrawText(*iText, aDeviceRect, baseline, CGraphicsContext::ECenter); sl@0: sl@0: //Done with the font sl@0: aGc.DiscardFont(); sl@0: } sl@0: sl@0: void CMVSFileControl::SetTextL(const TDesC& aText) sl@0: { sl@0: HBufC* text=aText.AllocL(); sl@0: delete iText; sl@0: iText=text; sl@0: } sl@0: sl@0: // sl@0: //Window() sl@0: // sl@0: // Returns the window defined by this object. sl@0: TRect& CMVSFileControl::Window() sl@0: { sl@0: return iWindow; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // sl@0: // class CMVSStateControl sl@0: // sl@0: // sl@0: sl@0: sl@0: sl@0: // sl@0: //NewL(...) *** This method can LEAVE *** sl@0: // sl@0: // Factory contructor, initialises a control based on the rectangle provided. sl@0: // sl@0: CMVSStateControl* CMVSStateControl::NewL(const CCoeControl& aContainer, sl@0: const TRect& aRect, sl@0: const TDesC& aText) sl@0: { sl@0: CMVSStateControl* self=new(ELeave) CMVSStateControl; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aContainer, aRect, aText); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: //ContructL(...) *** This method can LEAVE *** sl@0: // sl@0: // sl@0: void CMVSStateControl::ConstructL(const CCoeControl& aContainer, sl@0: const TRect& aRect, const TDesC& aText) sl@0: { sl@0: SetContainerWindowL(aContainer); sl@0: SetRect(aRect); sl@0: iWindow = aRect; sl@0: SetTextL(aText); sl@0: sl@0: //Activate the control sl@0: ActivateL(); sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: //CMVSControl() sl@0: // sl@0: // Constructor, does nothing. Private to prevent it being called. sl@0: // sl@0: CMVSStateControl::CMVSStateControl() sl@0: { sl@0: } sl@0: sl@0: sl@0: // sl@0: //~CMVSControl() sl@0: // sl@0: // Destructor. sl@0: // sl@0: CMVSStateControl::~CMVSStateControl() sl@0: { sl@0: delete iText; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: //For Displaying the state sl@0: void CMVSStateControl::Draw(const TRect& /*aRect*/) const sl@0: { sl@0: //Establish a Graphics Context sl@0: CWindowGc& gc=SystemGc(); sl@0: sl@0: //Establish a drawing rectangle sl@0: TRect rect=Rect(); sl@0: sl@0: //Move in 2 pixels each side to give a white border sl@0: rect.Shrink(2,2); sl@0: sl@0: //Set-up a pen sl@0: gc.SetPenStyle(CGraphicsContext::ENullPen); sl@0: gc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: gc.SetBrushColor(KRgbDarkGray); sl@0: sl@0: //Draw a blank rectangle sl@0: gc.DrawRect(rect); sl@0: sl@0: //Fill in the border-regions sl@0: DrawUtils::DrawBetweenRects(gc, Rect(), rect); sl@0: sl@0: //Change the pen colour to black sl@0: gc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: gc.SetPenColor(KRgbWhite); sl@0: sl@0: //Set the fill colour to 'no fill' sl@0: gc.SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: sl@0: //Draw a rectangle (transparent with a black border) sl@0: gc.DrawRect(rect); sl@0: rect.Shrink(1,1); sl@0: sl@0: const CFont* appFont = iEikonEnv->AnnotationFont(); sl@0: DrawOtherWindows(gc,rect,appFont); sl@0: return; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // sl@0: //DrawOtherWindows(...) sl@0: // sl@0: // Draw the text in a central position in the window. sl@0: // sl@0: void CMVSStateControl::DrawOtherWindows(CGraphicsContext& aGc, sl@0: const TRect& aDeviceRect, sl@0: const CFont* aFont) const sl@0: { sl@0: //Set up the pen and brush colours sl@0: aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc.SetBrushColor(KRgbGray); sl@0: sl@0: aGc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc.SetPenColor(KRgbWhite); sl@0: sl@0: //Set-up a font sl@0: aGc.UseFont(aFont); sl@0: sl@0: //Set the baseline to be half the height of the rectangle + half sl@0: //the height of the font sl@0: TInt baseline=aDeviceRect.Height()/2 + aFont->AscentInPixels()/2; sl@0: sl@0: //Draw the text sl@0: //__ASSERT_ALWAYS(iText != NULL, User::Panic(KNullPtr, KNAPanicNullPointer)); sl@0: aGc.DrawText(*iText, aDeviceRect, baseline, CGraphicsContext::ECenter); sl@0: sl@0: //Done with the font sl@0: aGc.DiscardFont(); sl@0: } sl@0: sl@0: void CMVSStateControl::SetTextL(const TDesC& aText) sl@0: { sl@0: HBufC* text=aText.AllocL(); sl@0: delete iText; sl@0: iText=NULL; sl@0: iText=text; sl@0: } sl@0: sl@0: // sl@0: //Window() sl@0: // sl@0: // Returns the window defined by this object. sl@0: TRect& CMVSStateControl::Window() sl@0: { sl@0: return iWindow; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // sl@0: // class CMVSTimeControl sl@0: // sl@0: // sl@0: sl@0: sl@0: sl@0: // sl@0: //NewL(...) *** This method can LEAVE *** sl@0: // sl@0: // Factory contructor, initialises a control based on the rectangle provided. sl@0: // sl@0: CMVSTimeControl* CMVSTimeControl::NewL(const CCoeControl& aContainer, sl@0: const TRect& aRect, sl@0: const TDesC& aText) sl@0: { sl@0: CMVSTimeControl* self=new(ELeave) CMVSTimeControl; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aContainer, aRect, aText); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: //ContructL(...) *** This method can LEAVE *** sl@0: // sl@0: // sl@0: void CMVSTimeControl::ConstructL(const CCoeControl& aContainer, sl@0: const TRect& aRect, const TDesC& aText) sl@0: { sl@0: SetContainerWindowL(aContainer); sl@0: SetRect(aRect); sl@0: iWindow = aRect; sl@0: SetTextL(aText); sl@0: iText2 = NULL; sl@0: //Activate the control sl@0: ActivateL(); sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: //CMVSControl() sl@0: // sl@0: // Constructor, does nothing. Private to prevent it being called. sl@0: // sl@0: CMVSTimeControl::CMVSTimeControl() sl@0: { sl@0: } sl@0: sl@0: sl@0: // sl@0: //~CMVSControl() sl@0: // sl@0: // Destructor. sl@0: // sl@0: CMVSTimeControl::~CMVSTimeControl() sl@0: { sl@0: delete iText; sl@0: if(iText2) sl@0: { sl@0: delete iText2; sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: //For TimeDisplay sl@0: void CMVSTimeControl::Draw(const TRect& /*aRect*/) const sl@0: { sl@0: //Establish a Graphics Context sl@0: CWindowGc& gc=SystemGc(); sl@0: sl@0: //Establish a drawing rectangle sl@0: TRect rect=Rect(); sl@0: sl@0: //Move in 2 pixels each side to give a white border sl@0: rect.Shrink(2,2); sl@0: sl@0: //Set-up a pen sl@0: gc.SetPenStyle(CGraphicsContext::ENullPen); sl@0: gc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: gc.SetBrushColor(KRgbDarkGray); sl@0: sl@0: //Draw a blank rectangle sl@0: gc.DrawRect(rect); sl@0: sl@0: //Fill in the border-regions sl@0: DrawUtils::DrawBetweenRects(gc, Rect(), rect); sl@0: sl@0: //Change the pen colour to black sl@0: gc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: gc.SetPenColor(KRgbWhite); sl@0: sl@0: //Set the fill colour to 'no fill' sl@0: gc.SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: sl@0: //Draw a rectangle (transparent with a black border) sl@0: gc.DrawRect(rect); sl@0: rect.Shrink(1,1); sl@0: sl@0: const CFont* appFont = iEikonEnv->AnnotationFont(); sl@0: DrawOtherWindows(gc,rect,appFont); sl@0: return; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // sl@0: //DrawOtherWindows(...) sl@0: // sl@0: // Draw the text in a central position in the window. sl@0: // sl@0: void CMVSTimeControl::DrawOtherWindows(CGraphicsContext& aGc, sl@0: const TRect& aDeviceRect, sl@0: const CFont* aFont) const sl@0: { sl@0: //Set up the pen and brush colours sl@0: aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc.SetBrushColor(KRgbGray); sl@0: sl@0: aGc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc.SetPenColor(KRgbWhite); sl@0: sl@0: //Set-up a font sl@0: aGc.UseFont(aFont); sl@0: sl@0: sl@0: if(iText2) sl@0: { sl@0: TInt rWidth = aDeviceRect.iBr.iX - aDeviceRect.iTl.iX; sl@0: TInt rHeight = aDeviceRect.iBr.iY - aDeviceRect.iTl.iY; sl@0: sl@0: TRect rect1(aDeviceRect.iTl,TSize(rWidth, rHeight/2)); sl@0: TRect rect2(TPoint(aDeviceRect.iTl.iX, aDeviceRect.iTl.iY + rHeight/2),TSize(rWidth, rHeight/2)); sl@0: sl@0: TInt baseline = rect1.Height(); sl@0: //Draw the text 1 sl@0: aGc.DrawText(*iText, rect1, baseline - 2, CGraphicsContext::ECenter); sl@0: //Draw the text 2 sl@0: aGc.DrawText(*iText2, rect2, baseline - 3 , CGraphicsContext::ECenter); sl@0: } sl@0: else sl@0: { sl@0: //Set the baseline to be half the height of the rectangle + half sl@0: //the height of the font sl@0: TInt baseline=aDeviceRect.Height()/2 + aFont->AscentInPixels()/2; sl@0: sl@0: //Draw the text sl@0: aGc.DrawText(*iText, aDeviceRect, baseline, CGraphicsContext::ECenter); sl@0: } sl@0: sl@0: //Done with the font sl@0: aGc.DiscardFont(); sl@0: } sl@0: sl@0: void CMVSTimeControl::SetTextL(const TDesC& aText) sl@0: { sl@0: HBufC* text=aText.AllocL(); sl@0: delete iText; sl@0: iText=NULL; sl@0: iText=text; sl@0: } sl@0: sl@0: void CMVSTimeControl::SetText2L(const TDesC& aText) sl@0: { sl@0: HBufC* text=aText.AllocL(); sl@0: delete iText2; sl@0: iText2=NULL; sl@0: iText2=text; sl@0: } sl@0: sl@0: void CMVSTimeControl::ResetText2L() sl@0: { sl@0: delete iText2; sl@0: iText2=NULL; sl@0: } sl@0: // sl@0: //Window() sl@0: // sl@0: // Returns the window defined by this object. sl@0: TRect& CMVSTimeControl::Window() sl@0: { sl@0: return iWindow; sl@0: } sl@0: sl@0: sl@0: // sl@0: // sl@0: // class CMVSInfoControl sl@0: // sl@0: // sl@0: sl@0: sl@0: sl@0: // sl@0: //NewL(...) *** This method can LEAVE *** sl@0: // sl@0: // Factory contructor, initialises a control based on the rectangle provided. sl@0: // sl@0: CMVSInfoControl* CMVSInfoControl::NewL(const CCoeControl& aContainer, sl@0: const TRect& aRect, sl@0: const TDesC& aText) sl@0: { sl@0: CMVSInfoControl* self=new(ELeave) CMVSInfoControl; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aContainer, aRect, aText); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: //ContructL(...) *** This method can LEAVE *** sl@0: // sl@0: // sl@0: void CMVSInfoControl::ConstructL(const CCoeControl& aContainer, sl@0: const TRect& aRect, const TDesC& aText) sl@0: { sl@0: SetContainerWindowL(aContainer); sl@0: SetRect(aRect); sl@0: iWindow = aRect; sl@0: SetTextL(aText); sl@0: //Activate the control sl@0: ActivateL(); sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: //CMVSControl() sl@0: // sl@0: // Constructor, does nothing. Private to prevent it being called. sl@0: // sl@0: CMVSInfoControl::CMVSInfoControl() sl@0: { sl@0: } sl@0: sl@0: sl@0: // sl@0: //~CMVSControl() sl@0: // sl@0: // Destructor. sl@0: // sl@0: CMVSInfoControl::~CMVSInfoControl() sl@0: { sl@0: delete iText; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: //Draw(...) sl@0: // sl@0: void CMVSInfoControl::Draw(const TRect& /*aRect*/) const sl@0: { sl@0: //Establish a Graphics Context sl@0: CWindowGc& gc=SystemGc(); sl@0: sl@0: //Establish a drawing rectangle sl@0: TRect rect=Rect(); sl@0: sl@0: //Move in 2 pixels each side to give a white border sl@0: rect.Shrink(2,2); sl@0: sl@0: //Set-up a pen sl@0: gc.SetPenStyle(CGraphicsContext::ENullPen); sl@0: gc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: gc.SetBrushColor(KRgbDarkGray); sl@0: sl@0: //Draw a blank rectangle sl@0: //gc.DrawRect(rect); sl@0: sl@0: //To cover Progress Bar area sl@0: TRect ProgRect = rect; sl@0: TInt statusPaneHeight = 4*(Parent()->Rect().iTl.iY + Parent()->Rect().iBr.iY)/5; sl@0: ProgRect.iBr.iY = statusPaneHeight; sl@0: ProgRect.Grow(2,0); sl@0: gc.DrawRect(ProgRect); sl@0: sl@0: //Fill in the border-regions sl@0: DrawUtils::DrawBetweenRects(gc, Rect(), rect); sl@0: sl@0: //Change the pen colour to black sl@0: gc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: gc.SetPenColor(KRgbWhite); sl@0: sl@0: //Set the fill colour to 'no fill' sl@0: gc.SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: sl@0: //Draw a rectangle (transparent with a black border) sl@0: gc.DrawRect(rect); sl@0: rect.Shrink(1,1); sl@0: sl@0: const CFont* appFont = iEikonEnv->AnnotationFont(); sl@0: DrawMainWindow(gc,rect,appFont); sl@0: return; sl@0: } sl@0: sl@0: sl@0: sl@0: void CMVSInfoControl::DrawMainWindow(CGraphicsContext& aGc, sl@0: const TRect& /*aDeviceRect*/, sl@0: const CFont* aFont) const sl@0: { sl@0: //Set up a brush and pen sl@0: aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc.SetBrushColor(KRgbDarkGray); sl@0: sl@0: aGc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc.SetPenColor(KRgbWhite); sl@0: sl@0: //Get a font sl@0: aGc.UseFont(aFont); sl@0: sl@0: //The 'step' by which we move down to get to a fresh line in sl@0: //the window sl@0: TInt distToNextBaseline = (aFont->AscentInPixels()/2)*3; sl@0: sl@0: //The main window text sl@0: TPtrC mainWindowText; sl@0: mainWindowText.Set(iText->Des()); sl@0: sl@0: //The escape sequence sl@0: _LIT(KDollarDollar, "$$"); sl@0: sl@0: TRect rect; sl@0: TInt x = 10; //The left hand side of the rectangle sl@0: TInt y = 10; //The top of the rectangle. sl@0: sl@0: //Whilst we can find a '$$' in the string sl@0: while(mainWindowText.Find(KDollarDollar) != KErrNotFound) sl@0: { sl@0: //do text up to $$ sl@0: TInt pos = mainWindowText.Find(KDollarDollar); sl@0: TPtrC text(mainWindowText.Mid(0,pos)); sl@0: sl@0: //define the rectangle for this text sl@0: TInt height = aFont->HeightInPixels(); sl@0: TInt width = aFont->TextWidthInPixels( text ); sl@0: rect.SetRect( x, y, x + width, y + height ); sl@0: sl@0: //Draw the text sl@0: aGc.DrawText(text, rect, height - aFont->DescentInPixels(), sl@0: CGraphicsContext::ELeft); sl@0: sl@0: //delete text upto and including '$$' sl@0: text.Set(mainWindowText.Right(mainWindowText.Length() - (pos+2))); sl@0: mainWindowText.Set(text); sl@0: sl@0: //adjust the baseline offset sl@0: y+=distToNextBaseline; sl@0: } sl@0: sl@0: //Done with our font sl@0: aGc.DiscardFont(); sl@0: } sl@0: sl@0: sl@0: void CMVSInfoControl::SetTextL(const TDesC& aText) sl@0: { sl@0: HBufC* text=aText.AllocL(); sl@0: delete iText; sl@0: iText=NULL; sl@0: iText=text; sl@0: } sl@0: sl@0: // sl@0: //Window() sl@0: // sl@0: // Returns the window defined by this object. sl@0: TRect& CMVSInfoControl::Window() sl@0: { sl@0: return iWindow; sl@0: }