diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_zoom_8cpp-source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_zoom_8cpp-source.html Tue Mar 30 11:56:28 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ - - -TB10.1 Example Applications: examples/Graphics/GraphicsShell/Zoom.cpp Source File - - - - -

examples/Graphics/GraphicsShell/Zoom.cpp

00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
-00002 // All rights reserved.
-00003 // This component and the accompanying materials are made available
-00004 // under the terms of "Eclipse Public License v1.0"
-00005 // which accompanies this distribution, and is available
-00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
-00007 //
-00008 // Initial Contributors:
-00009 // Nokia Corporation - initial contribution.
-00010 //
-00011 // Contributors:
-00012 //
-00013 // Description:
-00014 //
-00015 
-00016 #include "GraphicsControl.h"
-00017 
-00018 // header for multi-bitmap file grbitmap.mbm containing 2 bitmaps to use
-00019 #include <grbmap2.mbg>
-00020 
-00021 #include <coemain.h>
-00022 
-00023 _LIT(KTxtCDrive,"\\");
-00024 _LIT(KTxtZDrive,"Z:");
-00025 
-00026 void CZoomControl::LoadBitmapL(CFbsBitmap* aBitMap,const TDesC& aPathAndFile,TInt aId,TBool aShareIfLoaded)
-00027         {
-00028         TParse mbfn;
-00029         
-00030         mbfn.Set(aPathAndFile,&KTxtCDrive,NULL);
-00031         if (!aBitMap->Load(mbfn.FullName(),aId,aShareIfLoaded))
-00032                 return;
-00033 
-00034         mbfn.Set(aPathAndFile,&KTxtZDrive,NULL);
-00035         User::LeaveIfError(aBitMap->Load(mbfn.FullName(),aId,aShareIfLoaded));
-00036         return;
-00037         }
-00038 
-00039 // Name of the multi-bitmap file containing the bitmap
-00040 // and bitmap mask files
-00041 _LIT(KTxtFileName,"\\resource\\apps\\grbmap2.mbm");
-00042 
-00043 void CZoomControl::UpdateModelL()
-00044         {
-00045         // set up name for bitmap sharing
-00046         TBool shareIfLoaded(ETrue);
-00047 
-00048         // set up two zoom factor objects (one for examples, one for commentary)
-00049         iLeftZf.SetGraphicsDeviceMap(iCoeEnv->ScreenDevice());
-00050         iRightZf.SetGraphicsDeviceMap(iCoeEnv->ScreenDevice());
-00051         //iLeftZf.SetDevice(iCoeEnv->ScreenDevice());
-00052         //iRightZf.SetDevice(iCoeEnv->ScreenDevice());
-00053         
-00054         // set the zoom factor of the objects (example is dependent on phase of example, commentary is fixed)
-00055         iLeftZf.SetZoomFactor(TZoomFactor::EZoomOneToOne*2*(Phase()+1)/5);
-00056         iRightZf.SetZoomFactor(TZoomFactor::EZoomOneToOne*2*(5-Phase())/5);
-00057 
-00058         // use graphics device maps for drawing and getting fonts
-00059         iLeftMap=&iLeftZf;
-00060         iRightMap=&iRightZf;
-00061 
-00062         if (Phase()==0) {
-00063                 iBitmap = new (ELeave) CFbsBitmap();
-00064                 LoadBitmapL(iBitmap,KTxtFileName,EMbmGrbmap2Smiley,shareIfLoaded);
-00065         }
-00066         
-00067         // set up descriptor for commentary area
-00068         _LIT(KFormat1,"Left zoom factor=%1.1f:1  Right zoom factor=%1.1f:1");
-00069         TBuf<128> commentaryText;
-00070         TReal leftValue = 2*(Phase()+1)/5.0;
-00071         TReal rightValue = 2*(5-Phase())/5.0;
-00072         commentaryText.Format(KFormat1,leftValue,rightValue);
-00073         iGraphObserver->NotifyStatus(commentaryText);
-00074         };
-00075 
-00076 void CZoomControl::Draw(const TRect& /* aRect */) const
-00077         {
-00078         // setup screen for example: get graphics context and draw surrounding rectangle
-00079         CWindowGc& gc=SystemGc();
-00080         gc.Clear();     
-00081         
-00082         // create a centered rectangle of the default size
-00083         TRect screenRect=Rect();
-00084         TInt bisect = (screenRect.iBr.iX-screenRect.iTl.iX)/2 + screenRect.iTl.iX;
-00085         TRect leftRect(screenRect.iTl,TPoint(bisect,screenRect.iBr.iY));
-00086         TRect rightRect(TPoint(bisect,screenRect.iTl.iY),screenRect.iBr);
-00087 
-00088         DrawLeft(leftRect,gc);
-00089         DrawRight(rightRect,gc);
-00090         }
-00091 
-00092 
-00093         _LIT(KTxtTimesNewRoman,"Times New Roman");
-00094         _LIT(KTxtGrzoomExampleText,"grzoom example text");
-00095 
-00096 void CZoomControl::DrawLeft(TRect screenRect,CWindowGc& SystemGc) const
-00097         {
-00098         // set up absolute font-spec and text box for 200 twip Times font
-00099         TFontSpec fontSpec(KTxtTimesNewRoman,200);
-00100         // find the nearest font to the specified one
-00101         CFont* screenFont;                                                                              
-00102         iLeftMap->GetNearestFontInTwips(screenFont,fontSpec);
-00103         // use it for this graphics context
-00104         SystemGc.UseFont(screenFont);
-00105         // get height of screen box
-00106     TInt screenHeight=screenRect.Height();
-00107         // get font height
-00108     TInt textHeight = screenFont->HeightInPixels();
-00109         // 1/2 font height below halfway down box
-00110     TInt exampleOffset=(screenHeight+textHeight)/2;
-00111     TInt exampleMargin=0;
-00112     SystemGc.DrawText(KTxtGrzoomExampleText,screenRect,exampleOffset,CGraphicsContext::ECenter,exampleMargin);
-00113         // discard and release font
-00114         SystemGc.DiscardFont();
-00115         iLeftMap->ReleaseFont(screenFont);      
-00116         
-00117         // set up example box in twips
-00118         TRect boxInTwips(TPoint(0,0),TPoint(500,300));
-00119         // convert rectangle co-ordinates into pixels
-00120         TRect boxInPixels = iLeftMap->TwipsToPixels(boxInTwips);
-00121         SystemGc.DrawRect(boxInPixels);
-00122 
-00123         // set up rectangle for bitmap to be stretched into
-00124         TRect bitmapRectInTwips(TPoint(0,0),TPoint(500,500));
-00125         TRect bitmapRectInPixels = iLeftMap->TwipsToPixels(bitmapRectInTwips);
-00126         bitmapRectInPixels.iTl.iY+=125;
-00127         bitmapRectInPixels.iBr.iY+=125;
-00128         bitmapRectInPixels.iTl.iX+=100;
-00129         bitmapRectInPixels.iBr.iX+=100;
-00130         // draw the bitmap, stretched into the rectangle
-00131         SystemGc.DrawBitmap(bitmapRectInPixels, iBitmap);
-00132         }
-00133 
-00134 void CZoomControl::DrawRight(TRect screenRect,CWindowGc& SystemGc) const
-00135         {
-00136         // set up colors: black and a white RGB color
-00137         TRgb black(0,0,0);
-00138         TRgb white(255,255,255); // appears as blank screen gray-green color
-00139     SystemGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
-00140     SystemGc.SetBrushColor(black);
-00141     SystemGc.SetPenColor(white);
-00142 
-00143         // set up absolute font-spec and text box for 200 twip Times font
-00144         TFontSpec fontSpec(KTxtTimesNewRoman,200);
-00145         // find the nearest font to the specified one
-00146         CFont* commentFont;
-00147         iRightMap->GetNearestFontInTwips(commentFont,fontSpec);
-00148         // use it for this graphics context
-00149         SystemGc.UseFont(commentFont);
-00150         // get font height
-00151     TInt textHeight = commentFont->HeightInPixels();
-00152     // get height of text box
-00153     TInt boxHeight=screenRect.Height();
-00154         // 1/2 font height below halfway down box
-00155     TInt commentOffset=(boxHeight+textHeight)/2;
-00156     TInt commentMargin=0;
-00157         // draw text
-00158     SystemGc.DrawText(KTxtGrzoomExampleText,screenRect,commentOffset,CGraphicsContext::ECenter,commentMargin);
-00159         // discard and release font
-00160         SystemGc.DiscardFont();
-00161         iRightMap->ReleaseFont(commentFont);
-00162         
-00163         // set up example box in twips
-00164         TRect boxInTwips(TPoint(0,0),TPoint(500,300));
-00165         // convert rectangle co-ordinates into pixels
-00166         TRect boxInPixels = iRightMap->TwipsToPixels(boxInTwips);
-00167         boxInPixels.Move(screenRect.iTl);
-00168         SystemGc.DrawRect(boxInPixels);
-00169 
-00170         // set up rectangle for bitmap to be stretched into
-00171         TRect bitmapRectInTwips(TPoint(0,0),TPoint(500,500));
-00172         TRect bitmapRectInPixels = iRightMap->TwipsToPixels(bitmapRectInTwips);
-00173         bitmapRectInPixels.Move(screenRect.iTl);
-00174         bitmapRectInPixels.iTl.iY+=125;
-00175         bitmapRectInPixels.iBr.iY+=125;
-00176         bitmapRectInPixels.iTl.iX+=100;
-00177         bitmapRectInPixels.iBr.iX+=100;
-00178         // draw the bitmap, stretched into the rectangle
-00179         SystemGc.DrawBitmap(bitmapRectInPixels, iBitmap);
-00180         }
-

Generated on Thu Jan 21 10:32:58 2010 for TB10.1 Example Applications by  - -doxygen 1.5.3
- -