1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSAppView.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,907 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Part of the MVS Application for TechView
1.18 +//
1.19 +
1.20 +#include <w32std.h>
1.21 +
1.22 +#include "MVSApp.h"
1.23 +#include "MVSAppUI.h"
1.24 +#include "mvsvideocontrol.h"
1.25 +
1.26 +CMVSAppView* CMVSAppView::NewL(const TRect& aRect, CMVSVideoPlayAgent& aVideoPlayAgent)
1.27 + {
1.28 + CMVSAppView * self = new(ELeave) CMVSAppView;
1.29 + CleanupStack::PushL(self);
1.30 + self->ConstructL(aRect, aVideoPlayAgent);
1.31 + CleanupStack::Pop();
1.32 + return self;
1.33 + }
1.34 +
1.35 +
1.36 +CMVSAppView::CMVSAppView()
1.37 + {
1.38 + }
1.39 +
1.40 +
1.41 +CMVSAppView::~CMVSAppView()
1.42 + {
1.43 + //Remove our controls
1.44 + delete iMainWindowControl;
1.45 + delete iStatusWindowFNameControl;
1.46 + delete iStatusWindowStateControl;
1.47 + delete iStatusWindowTimeControl;
1.48 + delete iInfoWindowControl;
1.49 + delete iProgress;
1.50 +
1.51 + CloseWindow();
1.52 + }
1.53 +
1.54 +
1.55 +void CMVSAppView::ConstructL(const TRect& aRect, CMVSVideoPlayAgent& aVideoPlayAgent)
1.56 + {
1.57 + //we need a window in which to place controls, so take ownership of one
1.58 + CreateWindowL();
1.59 +
1.60 + //Set the extent of the control.
1.61 + SetRect(aRect);
1.62 + TRect fullRectWindow = Rect();
1.63 + //vertical point co-ordinate
1.64 + TInt statusPaneHeight = 4*(fullRectWindow.iTl.iY + fullRectWindow.iBr.iY)/5;
1.65 + TInt halfLength = (fullRectWindow.iTl.iX + fullRectWindow.iBr.iX)/2;
1.66 + TInt threeQuarterLength= 3*(fullRectWindow.iTl.iX + fullRectWindow.iBr.iX)/4;
1.67 +
1.68 + //set the dimensions of our main window
1.69 + TRect mainWindow(Rect());
1.70 + mainWindow.iTl.iX = halfLength-115;
1.71 + mainWindow.iBr.iY = statusPaneHeight;
1.72 +
1.73 + iMainWindowControl = CMVSVideoControl::NewL(aVideoPlayAgent, 0, Window());
1.74 + iMainWindowControl->SetExtent(mainWindow.iTl, mainWindow.Size());
1.75 +
1.76 + //set the dimensions of our status window
1.77 + TRect statusWindowFName = fullRectWindow;
1.78 + statusWindowFName.iTl.iY = statusPaneHeight;
1.79 + statusWindowFName.iBr.iX = halfLength;
1.80 +
1.81 + //now construct our status window filename control
1.82 + iStatusWindowFNameControl = CMVSFileControl::NewL(*this, statusWindowFName,
1.83 + KNullDesC);
1.84 + //set the dimensions of our state window
1.85 + TRect statusWindowState = fullRectWindow;
1.86 + statusWindowState.iTl.iX = halfLength;
1.87 + statusWindowState.iTl.iY = statusPaneHeight;
1.88 + statusWindowState.iBr.iX = threeQuarterLength;
1.89 +
1.90 + //now construct our status window state control
1.91 + iStatusWindowStateControl = CMVSStateControl::NewL(*this, statusWindowState,
1.92 + KNullDesC);
1.93 +
1.94 + //set the dimensions of our timer window
1.95 + TRect statusWindowTime = fullRectWindow;
1.96 + statusWindowTime.iTl.iX = threeQuarterLength;
1.97 + statusWindowTime.iTl.iY = statusPaneHeight;
1.98 +
1.99 + //now construct our status window timer control
1.100 + iStatusWindowTimeControl = CMVSTimeControl::NewL(*this, statusWindowTime,
1.101 + KNullDesC);
1.102 + TRect infoWindow = fullRectWindow;
1.103 + infoWindow.iTl.iX=0;
1.104 + infoWindow.iBr.iX= halfLength-115;
1.105 + infoWindow.iBr.iY =statusPaneHeight-15;
1.106 + iInfoWindowControl = CMVSInfoControl::NewL(*this,infoWindow,KNullDesC);
1.107 + iInfoWindowControl->SetParent(this);
1.108 + //now activate the control.
1.109 +
1.110 + // construct and draw the progress bar
1.111 + iProgress = new (ELeave) CEikProgressInfo();
1.112 +
1.113 + TResourceReader reader;
1.114 + iEikonEnv->CreateResourceReaderLC(reader, R_CLIP_PROGRESSINFO);
1.115 + iProgress->ConstructFromResourceL(reader);
1.116 + iProgress->SetContainerWindowL(*this);
1.117 + iProgress->SetExtent(TPoint(fullRectWindow.iTl.iX+ (fullRectWindow.iBr.iX/20),statusPaneHeight-10),TSize((fullRectWindow.iBr.iX - fullRectWindow.iTl.iX - (fullRectWindow.iBr.iX/10) ),10));
1.118 + iProgress->SetAndDraw(0);
1.119 + CleanupStack::PopAndDestroy();
1.120 +
1.121 + ActivateL();
1.122 + }
1.123 +
1.124 +void CMVSAppView::SetClipLength(TInt& aClipLen)
1.125 + {
1.126 + iClipLength = aClipLen;
1.127 + }
1.128 +
1.129 +//
1.130 +//CountComponentControls()
1.131 +//
1.132 +// Implemented by a view with more than one control so that a call to
1.133 +// DrawNow successfully draws all four component controls.
1.134 +//
1.135 +TInt CMVSAppView::CountComponentControls() const
1.136 + {
1.137 + return 6; //we have six controls
1.138 + }
1.139 +
1.140 +//
1.141 +// To handle the Pointer events on the Progress Bar
1.142 +//
1.143 +void CMVSAppView::HandlePointerEventL(const TPointerEvent &aPointerEvent)
1.144 + {
1.145 + TInt clipPos;
1.146 + TRect rect = iProgress->Rect();
1.147 + if( (aPointerEvent.iPosition.iX>=rect.iTl.iX && aPointerEvent.iPosition.iX<=rect.iBr.iX) &&
1.148 + (aPointerEvent.iPosition.iY>=rect.iTl.iY && aPointerEvent.iPosition.iY<=rect.iBr.iY) )
1.149 + {
1.150 + TInt pos = aPointerEvent.iPosition.iX - rect.iTl.iX;
1.151 + switch(aPointerEvent.iType)
1.152 + {
1.153 + case TPointerEvent::EButton1Down:
1.154 + break;
1.155 + case TPointerEvent::EDrag:
1.156 + {
1.157 + iProgress->SetAndDraw(pos);
1.158 + break;
1.159 + }
1.160 + case TPointerEvent::EButton1Up:
1.161 + {
1.162 + TInt progToDraw = pos* (static_cast<double>(200)/(rect.iBr.iX -rect.iTl.iX));
1.163 + iProgress->SetAndDraw(progToDraw+1);
1.164 + clipPos = (progToDraw+1) *(static_cast<double>(iClipLength)/200);
1.165 + TTimeIntervalMicroSeconds clipTime(clipPos);
1.166 + static_cast<CMVSAppUi*>(CEikonEnv::Static()->EikAppUi())->SetPosition(clipTime);
1.167 + break;
1.168 + }
1.169 +
1.170 + default:
1.171 + break;
1.172 + }
1.173 + }
1.174 + CCoeControl::HandlePointerEventL(aPointerEvent);
1.175 +
1.176 + }
1.177 +
1.178 +
1.179 +//
1.180 +// Updates the Audion play progress
1.181 +//
1.182 +void CMVSAppView::UpdatePlayProgress(TTimeIntervalMicroSeconds& aPos)
1.183 + {
1.184 + TInt curPos = I64INT(aPos.Int64());
1.185 + TInt percent = curPos*(static_cast<double>(100)/iClipLength);
1.186 + TInt progressPos = percent*2;
1.187 + iProgress->SetAndDraw(progressPos+1);
1.188 + }
1.189 +
1.190 +//
1.191 +// Reset the Progress to ) and redraw
1.192 +//
1.193 +void CMVSAppView::ResetProgressBar()
1.194 + {
1.195 + iProgress->SetAndDraw(0);
1.196 + }
1.197 +//
1.198 +//ComponentControl(...)
1.199 +//
1.200 +// Returns the control by index. The counting sequence goes left to right, top
1.201 +// to bottom.
1.202 +//
1.203 +CCoeControl* CMVSAppView::ComponentControl(TInt aIndex) const
1.204 + {
1.205 + switch (aIndex)
1.206 + {
1.207 + case 0: return iMainWindowControl;
1.208 + case 1: return iStatusWindowFNameControl;
1.209 + case 2: return iStatusWindowStateControl;
1.210 + case 3: return iStatusWindowTimeControl;
1.211 + case 4: return iInfoWindowControl;
1.212 + case 5: return iProgress;
1.213 + default: return 0;
1.214 + }
1.215 + }
1.216 +
1.217 +
1.218 +
1.219 +//
1.220 +//
1.221 +// class CMVSFileControl
1.222 +//
1.223 +//
1.224 +
1.225 +
1.226 +
1.227 +//
1.228 +//NewL(...) *** This method can LEAVE ***
1.229 +//
1.230 +// Factory contructor, initialises a control based on the rectangle provided.
1.231 +//
1.232 +CMVSFileControl* CMVSFileControl::NewL(const CCoeControl& aContainer,
1.233 + const TRect& aRect,
1.234 + const TDesC& aText)
1.235 + {
1.236 + CMVSFileControl* self=new(ELeave) CMVSFileControl;
1.237 + CleanupStack::PushL(self);
1.238 + self->ConstructL(aContainer, aRect, aText);
1.239 + CleanupStack::Pop();
1.240 + return self;
1.241 + }
1.242 +
1.243 +
1.244 +//
1.245 +//ContructL(...) *** This method can LEAVE ***
1.246 +//
1.247 +//
1.248 +void CMVSFileControl::ConstructL(const CCoeControl& aContainer,
1.249 + const TRect& aRect, const TDesC& aText)
1.250 + {
1.251 + SetContainerWindowL(aContainer);
1.252 + SetRect(aRect);
1.253 + iWindow = aRect;
1.254 + SetTextL(aText);
1.255 + //Activate the control
1.256 + ActivateL();
1.257 + }
1.258 +
1.259 +
1.260 +//
1.261 +//CMVSControl()
1.262 +//
1.263 +// Constructor, does nothing. Private to prevent it being called.
1.264 +//
1.265 +CMVSFileControl::CMVSFileControl()
1.266 + {
1.267 + }
1.268 +
1.269 +
1.270 +//
1.271 +//~CMVSControl()
1.272 +//
1.273 +// Destructor.
1.274 +//
1.275 +CMVSFileControl::~CMVSFileControl()
1.276 + {
1.277 + delete iText;
1.278 + }
1.279 +
1.280 +
1.281 +//Draw the FileName Display Window
1.282 +void CMVSFileControl::Draw(const TRect& /*aRect*/) const
1.283 + {
1.284 + //Establish a Graphics Context
1.285 + CWindowGc& gc=SystemGc();
1.286 +
1.287 + //Establish a drawing rectangle
1.288 + TRect rect=Rect();
1.289 +
1.290 + //Move in 2 pixels each side to give a white border
1.291 + rect.Shrink(2,2);
1.292 +
1.293 + //Set-up a pen
1.294 + gc.SetPenStyle(CGraphicsContext::ENullPen);
1.295 + gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
1.296 + gc.SetBrushColor(KRgbDarkGray);
1.297 +
1.298 + //Draw a blank rectangle
1.299 + gc.DrawRect(rect);
1.300 +
1.301 + //Fill in the border-regions
1.302 + DrawUtils::DrawBetweenRects(gc, Rect(), rect);
1.303 +
1.304 + //Change the pen colour to black
1.305 + gc.SetPenStyle(CGraphicsContext::ESolidPen);
1.306 + gc.SetPenColor(KRgbWhite);
1.307 +
1.308 + //Set the fill colour to 'no fill'
1.309 + gc.SetBrushStyle(CGraphicsContext::ENullBrush);
1.310 +
1.311 + //Draw a rectangle (transparent with a black border)
1.312 + gc.DrawRect(rect);
1.313 + rect.Shrink(1,1);
1.314 +
1.315 + const CFont* appFont = iEikonEnv->AnnotationFont();
1.316 + DrawOtherWindows(gc,rect,appFont);
1.317 + return;
1.318 + }
1.319 +
1.320 +
1.321 +
1.322 +//
1.323 +//DrawOtherWindows(...)
1.324 +//
1.325 +// Draw the text in a central position in the window.
1.326 +//
1.327 +void CMVSFileControl::DrawOtherWindows(CGraphicsContext& aGc,
1.328 + const TRect& aDeviceRect,
1.329 + const CFont* aFont) const
1.330 + {
1.331 + //Set up the pen and brush colours
1.332 + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
1.333 + aGc.SetBrushColor(KRgbGray);
1.334 +
1.335 + aGc.SetPenStyle(CGraphicsContext::ESolidPen);
1.336 + aGc.SetPenColor(KRgbWhite);
1.337 +
1.338 + //Set-up a font
1.339 + aGc.UseFont(aFont);
1.340 +
1.341 + //Set the baseline to be half the height of the rectangle + half
1.342 + //the height of the font
1.343 + TInt baseline=aDeviceRect.Height()/2 + aFont->AscentInPixels()/2;
1.344 +
1.345 + //Draw the text
1.346 + //__ASSERT_ALWAYS(iText != NULL, User::Panic(KNullPtr, KNAPanicNullPointer));
1.347 + aGc.DrawText(*iText, aDeviceRect, baseline, CGraphicsContext::ECenter);
1.348 +
1.349 + //Done with the font
1.350 + aGc.DiscardFont();
1.351 + }
1.352 +
1.353 +void CMVSFileControl::SetTextL(const TDesC& aText)
1.354 + {
1.355 + HBufC* text=aText.AllocL();
1.356 + delete iText;
1.357 + iText=text;
1.358 + }
1.359 +
1.360 +//
1.361 +//Window()
1.362 +//
1.363 +// Returns the window defined by this object.
1.364 +TRect& CMVSFileControl::Window()
1.365 + {
1.366 + return iWindow;
1.367 + }
1.368 +
1.369 +
1.370 +
1.371 +//
1.372 +//
1.373 +// class CMVSStateControl
1.374 +//
1.375 +//
1.376 +
1.377 +
1.378 +
1.379 +//
1.380 +//NewL(...) *** This method can LEAVE ***
1.381 +//
1.382 +// Factory contructor, initialises a control based on the rectangle provided.
1.383 +//
1.384 +CMVSStateControl* CMVSStateControl::NewL(const CCoeControl& aContainer,
1.385 + const TRect& aRect,
1.386 + const TDesC& aText)
1.387 + {
1.388 + CMVSStateControl* self=new(ELeave) CMVSStateControl;
1.389 + CleanupStack::PushL(self);
1.390 + self->ConstructL(aContainer, aRect, aText);
1.391 + CleanupStack::Pop();
1.392 + return self;
1.393 + }
1.394 +
1.395 +
1.396 +
1.397 +//
1.398 +//ContructL(...) *** This method can LEAVE ***
1.399 +//
1.400 +//
1.401 +void CMVSStateControl::ConstructL(const CCoeControl& aContainer,
1.402 + const TRect& aRect, const TDesC& aText)
1.403 + {
1.404 + SetContainerWindowL(aContainer);
1.405 + SetRect(aRect);
1.406 + iWindow = aRect;
1.407 + SetTextL(aText);
1.408 +
1.409 + //Activate the control
1.410 + ActivateL();
1.411 + }
1.412 +
1.413 +
1.414 +
1.415 +//
1.416 +//CMVSControl()
1.417 +//
1.418 +// Constructor, does nothing. Private to prevent it being called.
1.419 +//
1.420 +CMVSStateControl::CMVSStateControl()
1.421 + {
1.422 + }
1.423 +
1.424 +
1.425 +//
1.426 +//~CMVSControl()
1.427 +//
1.428 +// Destructor.
1.429 +//
1.430 +CMVSStateControl::~CMVSStateControl()
1.431 + {
1.432 + delete iText;
1.433 + }
1.434 +
1.435 +
1.436 +
1.437 +
1.438 +//For Displaying the state
1.439 +void CMVSStateControl::Draw(const TRect& /*aRect*/) const
1.440 + {
1.441 + //Establish a Graphics Context
1.442 + CWindowGc& gc=SystemGc();
1.443 +
1.444 + //Establish a drawing rectangle
1.445 + TRect rect=Rect();
1.446 +
1.447 + //Move in 2 pixels each side to give a white border
1.448 + rect.Shrink(2,2);
1.449 +
1.450 + //Set-up a pen
1.451 + gc.SetPenStyle(CGraphicsContext::ENullPen);
1.452 + gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
1.453 + gc.SetBrushColor(KRgbDarkGray);
1.454 +
1.455 + //Draw a blank rectangle
1.456 + gc.DrawRect(rect);
1.457 +
1.458 + //Fill in the border-regions
1.459 + DrawUtils::DrawBetweenRects(gc, Rect(), rect);
1.460 +
1.461 + //Change the pen colour to black
1.462 + gc.SetPenStyle(CGraphicsContext::ESolidPen);
1.463 + gc.SetPenColor(KRgbWhite);
1.464 +
1.465 + //Set the fill colour to 'no fill'
1.466 + gc.SetBrushStyle(CGraphicsContext::ENullBrush);
1.467 +
1.468 + //Draw a rectangle (transparent with a black border)
1.469 + gc.DrawRect(rect);
1.470 + rect.Shrink(1,1);
1.471 +
1.472 + const CFont* appFont = iEikonEnv->AnnotationFont();
1.473 + DrawOtherWindows(gc,rect,appFont);
1.474 + return;
1.475 + }
1.476 +
1.477 +
1.478 +
1.479 +
1.480 +//
1.481 +//DrawOtherWindows(...)
1.482 +//
1.483 +// Draw the text in a central position in the window.
1.484 +//
1.485 +void CMVSStateControl::DrawOtherWindows(CGraphicsContext& aGc,
1.486 + const TRect& aDeviceRect,
1.487 + const CFont* aFont) const
1.488 + {
1.489 + //Set up the pen and brush colours
1.490 + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
1.491 + aGc.SetBrushColor(KRgbGray);
1.492 +
1.493 + aGc.SetPenStyle(CGraphicsContext::ESolidPen);
1.494 + aGc.SetPenColor(KRgbWhite);
1.495 +
1.496 + //Set-up a font
1.497 + aGc.UseFont(aFont);
1.498 +
1.499 + //Set the baseline to be half the height of the rectangle + half
1.500 + //the height of the font
1.501 + TInt baseline=aDeviceRect.Height()/2 + aFont->AscentInPixels()/2;
1.502 +
1.503 + //Draw the text
1.504 + //__ASSERT_ALWAYS(iText != NULL, User::Panic(KNullPtr, KNAPanicNullPointer));
1.505 + aGc.DrawText(*iText, aDeviceRect, baseline, CGraphicsContext::ECenter);
1.506 +
1.507 + //Done with the font
1.508 + aGc.DiscardFont();
1.509 + }
1.510 +
1.511 +void CMVSStateControl::SetTextL(const TDesC& aText)
1.512 + {
1.513 + HBufC* text=aText.AllocL();
1.514 + delete iText;
1.515 + iText=NULL;
1.516 + iText=text;
1.517 + }
1.518 +
1.519 +//
1.520 +//Window()
1.521 +//
1.522 +// Returns the window defined by this object.
1.523 +TRect& CMVSStateControl::Window()
1.524 + {
1.525 + return iWindow;
1.526 + }
1.527 +
1.528 +
1.529 +
1.530 +//
1.531 +//
1.532 +// class CMVSTimeControl
1.533 +//
1.534 +//
1.535 +
1.536 +
1.537 +
1.538 +//
1.539 +//NewL(...) *** This method can LEAVE ***
1.540 +//
1.541 +// Factory contructor, initialises a control based on the rectangle provided.
1.542 +//
1.543 +CMVSTimeControl* CMVSTimeControl::NewL(const CCoeControl& aContainer,
1.544 + const TRect& aRect,
1.545 + const TDesC& aText)
1.546 + {
1.547 + CMVSTimeControl* self=new(ELeave) CMVSTimeControl;
1.548 + CleanupStack::PushL(self);
1.549 + self->ConstructL(aContainer, aRect, aText);
1.550 + CleanupStack::Pop();
1.551 + return self;
1.552 + }
1.553 +
1.554 +
1.555 +
1.556 +//
1.557 +//ContructL(...) *** This method can LEAVE ***
1.558 +//
1.559 +//
1.560 +void CMVSTimeControl::ConstructL(const CCoeControl& aContainer,
1.561 + const TRect& aRect, const TDesC& aText)
1.562 + {
1.563 + SetContainerWindowL(aContainer);
1.564 + SetRect(aRect);
1.565 + iWindow = aRect;
1.566 + SetTextL(aText);
1.567 + iText2 = NULL;
1.568 + //Activate the control
1.569 + ActivateL();
1.570 + }
1.571 +
1.572 +
1.573 +
1.574 +//
1.575 +//CMVSControl()
1.576 +//
1.577 +// Constructor, does nothing. Private to prevent it being called.
1.578 +//
1.579 +CMVSTimeControl::CMVSTimeControl()
1.580 + {
1.581 + }
1.582 +
1.583 +
1.584 +//
1.585 +//~CMVSControl()
1.586 +//
1.587 +// Destructor.
1.588 +//
1.589 +CMVSTimeControl::~CMVSTimeControl()
1.590 + {
1.591 + delete iText;
1.592 + if(iText2)
1.593 + {
1.594 + delete iText2;
1.595 + }
1.596 + }
1.597 +
1.598 +
1.599 +
1.600 +
1.601 +//For TimeDisplay
1.602 +void CMVSTimeControl::Draw(const TRect& /*aRect*/) const
1.603 + {
1.604 + //Establish a Graphics Context
1.605 + CWindowGc& gc=SystemGc();
1.606 +
1.607 + //Establish a drawing rectangle
1.608 + TRect rect=Rect();
1.609 +
1.610 + //Move in 2 pixels each side to give a white border
1.611 + rect.Shrink(2,2);
1.612 +
1.613 + //Set-up a pen
1.614 + gc.SetPenStyle(CGraphicsContext::ENullPen);
1.615 + gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
1.616 + gc.SetBrushColor(KRgbDarkGray);
1.617 +
1.618 + //Draw a blank rectangle
1.619 + gc.DrawRect(rect);
1.620 +
1.621 + //Fill in the border-regions
1.622 + DrawUtils::DrawBetweenRects(gc, Rect(), rect);
1.623 +
1.624 + //Change the pen colour to black
1.625 + gc.SetPenStyle(CGraphicsContext::ESolidPen);
1.626 + gc.SetPenColor(KRgbWhite);
1.627 +
1.628 + //Set the fill colour to 'no fill'
1.629 + gc.SetBrushStyle(CGraphicsContext::ENullBrush);
1.630 +
1.631 + //Draw a rectangle (transparent with a black border)
1.632 + gc.DrawRect(rect);
1.633 + rect.Shrink(1,1);
1.634 +
1.635 + const CFont* appFont = iEikonEnv->AnnotationFont();
1.636 + DrawOtherWindows(gc,rect,appFont);
1.637 + return;
1.638 + }
1.639 +
1.640 +
1.641 +
1.642 +
1.643 +//
1.644 +//DrawOtherWindows(...)
1.645 +//
1.646 +// Draw the text in a central position in the window.
1.647 +//
1.648 +void CMVSTimeControl::DrawOtherWindows(CGraphicsContext& aGc,
1.649 + const TRect& aDeviceRect,
1.650 + const CFont* aFont) const
1.651 + {
1.652 + //Set up the pen and brush colours
1.653 + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
1.654 + aGc.SetBrushColor(KRgbGray);
1.655 +
1.656 + aGc.SetPenStyle(CGraphicsContext::ESolidPen);
1.657 + aGc.SetPenColor(KRgbWhite);
1.658 +
1.659 + //Set-up a font
1.660 + aGc.UseFont(aFont);
1.661 +
1.662 +
1.663 + if(iText2)
1.664 + {
1.665 + TInt rWidth = aDeviceRect.iBr.iX - aDeviceRect.iTl.iX;
1.666 + TInt rHeight = aDeviceRect.iBr.iY - aDeviceRect.iTl.iY;
1.667 +
1.668 + TRect rect1(aDeviceRect.iTl,TSize(rWidth, rHeight/2));
1.669 + TRect rect2(TPoint(aDeviceRect.iTl.iX, aDeviceRect.iTl.iY + rHeight/2),TSize(rWidth, rHeight/2));
1.670 +
1.671 + TInt baseline = rect1.Height();
1.672 + //Draw the text 1
1.673 + aGc.DrawText(*iText, rect1, baseline - 2, CGraphicsContext::ECenter);
1.674 + //Draw the text 2
1.675 + aGc.DrawText(*iText2, rect2, baseline - 3 , CGraphicsContext::ECenter);
1.676 + }
1.677 + else
1.678 + {
1.679 + //Set the baseline to be half the height of the rectangle + half
1.680 + //the height of the font
1.681 + TInt baseline=aDeviceRect.Height()/2 + aFont->AscentInPixels()/2;
1.682 +
1.683 + //Draw the text
1.684 + aGc.DrawText(*iText, aDeviceRect, baseline, CGraphicsContext::ECenter);
1.685 + }
1.686 +
1.687 + //Done with the font
1.688 + aGc.DiscardFont();
1.689 + }
1.690 +
1.691 +void CMVSTimeControl::SetTextL(const TDesC& aText)
1.692 + {
1.693 + HBufC* text=aText.AllocL();
1.694 + delete iText;
1.695 + iText=NULL;
1.696 + iText=text;
1.697 + }
1.698 +
1.699 +void CMVSTimeControl::SetText2L(const TDesC& aText)
1.700 + {
1.701 + HBufC* text=aText.AllocL();
1.702 + delete iText2;
1.703 + iText2=NULL;
1.704 + iText2=text;
1.705 + }
1.706 +
1.707 +void CMVSTimeControl::ResetText2L()
1.708 + {
1.709 + delete iText2;
1.710 + iText2=NULL;
1.711 + }
1.712 +//
1.713 +//Window()
1.714 +//
1.715 +// Returns the window defined by this object.
1.716 +TRect& CMVSTimeControl::Window()
1.717 + {
1.718 + return iWindow;
1.719 + }
1.720 +
1.721 +
1.722 +//
1.723 +//
1.724 +// class CMVSInfoControl
1.725 +//
1.726 +//
1.727 +
1.728 +
1.729 +
1.730 +//
1.731 +//NewL(...) *** This method can LEAVE ***
1.732 +//
1.733 +// Factory contructor, initialises a control based on the rectangle provided.
1.734 +//
1.735 +CMVSInfoControl* CMVSInfoControl::NewL(const CCoeControl& aContainer,
1.736 + const TRect& aRect,
1.737 + const TDesC& aText)
1.738 + {
1.739 + CMVSInfoControl* self=new(ELeave) CMVSInfoControl;
1.740 + CleanupStack::PushL(self);
1.741 + self->ConstructL(aContainer, aRect, aText);
1.742 + CleanupStack::Pop();
1.743 + return self;
1.744 + }
1.745 +
1.746 +
1.747 +
1.748 +//
1.749 +//ContructL(...) *** This method can LEAVE ***
1.750 +//
1.751 +//
1.752 +void CMVSInfoControl::ConstructL(const CCoeControl& aContainer,
1.753 + const TRect& aRect, const TDesC& aText)
1.754 + {
1.755 + SetContainerWindowL(aContainer);
1.756 + SetRect(aRect);
1.757 + iWindow = aRect;
1.758 + SetTextL(aText);
1.759 + //Activate the control
1.760 + ActivateL();
1.761 + }
1.762 +
1.763 +
1.764 +
1.765 +//
1.766 +//CMVSControl()
1.767 +//
1.768 +// Constructor, does nothing. Private to prevent it being called.
1.769 +//
1.770 +CMVSInfoControl::CMVSInfoControl()
1.771 + {
1.772 + }
1.773 +
1.774 +
1.775 +//
1.776 +//~CMVSControl()
1.777 +//
1.778 +// Destructor.
1.779 +//
1.780 +CMVSInfoControl::~CMVSInfoControl()
1.781 + {
1.782 + delete iText;
1.783 + }
1.784 +
1.785 +
1.786 +
1.787 +//
1.788 +//Draw(...)
1.789 +//
1.790 +void CMVSInfoControl::Draw(const TRect& /*aRect*/) const
1.791 + {
1.792 + //Establish a Graphics Context
1.793 + CWindowGc& gc=SystemGc();
1.794 +
1.795 + //Establish a drawing rectangle
1.796 + TRect rect=Rect();
1.797 +
1.798 + //Move in 2 pixels each side to give a white border
1.799 + rect.Shrink(2,2);
1.800 +
1.801 + //Set-up a pen
1.802 + gc.SetPenStyle(CGraphicsContext::ENullPen);
1.803 + gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
1.804 + gc.SetBrushColor(KRgbDarkGray);
1.805 +
1.806 + //Draw a blank rectangle
1.807 + //gc.DrawRect(rect);
1.808 +
1.809 + //To cover Progress Bar area
1.810 + TRect ProgRect = rect;
1.811 + TInt statusPaneHeight = 4*(Parent()->Rect().iTl.iY + Parent()->Rect().iBr.iY)/5;
1.812 + ProgRect.iBr.iY = statusPaneHeight;
1.813 + ProgRect.Grow(2,0);
1.814 + gc.DrawRect(ProgRect);
1.815 +
1.816 + //Fill in the border-regions
1.817 + DrawUtils::DrawBetweenRects(gc, Rect(), rect);
1.818 +
1.819 + //Change the pen colour to black
1.820 + gc.SetPenStyle(CGraphicsContext::ESolidPen);
1.821 + gc.SetPenColor(KRgbWhite);
1.822 +
1.823 + //Set the fill colour to 'no fill'
1.824 + gc.SetBrushStyle(CGraphicsContext::ENullBrush);
1.825 +
1.826 + //Draw a rectangle (transparent with a black border)
1.827 + gc.DrawRect(rect);
1.828 + rect.Shrink(1,1);
1.829 +
1.830 + const CFont* appFont = iEikonEnv->AnnotationFont();
1.831 + DrawMainWindow(gc,rect,appFont);
1.832 + return;
1.833 + }
1.834 +
1.835 +
1.836 +
1.837 +void CMVSInfoControl::DrawMainWindow(CGraphicsContext& aGc,
1.838 + const TRect& /*aDeviceRect*/,
1.839 + const CFont* aFont) const
1.840 + {
1.841 + //Set up a brush and pen
1.842 + aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
1.843 + aGc.SetBrushColor(KRgbDarkGray);
1.844 +
1.845 + aGc.SetPenStyle(CGraphicsContext::ESolidPen);
1.846 + aGc.SetPenColor(KRgbWhite);
1.847 +
1.848 + //Get a font
1.849 + aGc.UseFont(aFont);
1.850 +
1.851 + //The 'step' by which we move down to get to a fresh line in
1.852 + //the window
1.853 + TInt distToNextBaseline = (aFont->AscentInPixels()/2)*3;
1.854 +
1.855 + //The main window text
1.856 + TPtrC mainWindowText;
1.857 + mainWindowText.Set(iText->Des());
1.858 +
1.859 + //The escape sequence
1.860 + _LIT(KDollarDollar, "$$");
1.861 +
1.862 + TRect rect;
1.863 + TInt x = 10; //The left hand side of the rectangle
1.864 + TInt y = 10; //The top of the rectangle.
1.865 +
1.866 + //Whilst we can find a '$$' in the string
1.867 + while(mainWindowText.Find(KDollarDollar) != KErrNotFound)
1.868 + {
1.869 + //do text up to $$
1.870 + TInt pos = mainWindowText.Find(KDollarDollar);
1.871 + TPtrC text(mainWindowText.Mid(0,pos));
1.872 +
1.873 + //define the rectangle for this text
1.874 + TInt height = aFont->HeightInPixels();
1.875 + TInt width = aFont->TextWidthInPixels( text );
1.876 + rect.SetRect( x, y, x + width, y + height );
1.877 +
1.878 + //Draw the text
1.879 + aGc.DrawText(text, rect, height - aFont->DescentInPixels(),
1.880 + CGraphicsContext::ELeft);
1.881 +
1.882 + //delete text upto and including '$$'
1.883 + text.Set(mainWindowText.Right(mainWindowText.Length() - (pos+2)));
1.884 + mainWindowText.Set(text);
1.885 +
1.886 + //adjust the baseline offset
1.887 + y+=distToNextBaseline;
1.888 + }
1.889 +
1.890 + //Done with our font
1.891 + aGc.DiscardFont();
1.892 + }
1.893 +
1.894 +
1.895 +void CMVSInfoControl::SetTextL(const TDesC& aText)
1.896 + {
1.897 + HBufC* text=aText.AllocL();
1.898 + delete iText;
1.899 + iText=NULL;
1.900 + iText=text;
1.901 + }
1.902 +
1.903 +//
1.904 +//Window()
1.905 +//
1.906 +// Returns the window defined by this object.
1.907 +TRect& CMVSInfoControl::Window()
1.908 + {
1.909 + return iWindow;
1.910 + }