examples/ForumNokia/ImageConverter/src/ShowInfoDialog.cpp

00001 /*
00002  * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003  *    
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *    
00007  *  * Redistributions of source code must retain the above copyright notice, this
00008  *    list of conditions and the following disclaimer.
00009  *  * Redistributions in binary form must reproduce the above copyright notice,
00010  *    this list of conditions and the following disclaimer in the documentation
00011  *    and/or other materials provided with the distribution.
00012  *  * Neither the name of Nokia Corporation nor the names of its contributors
00013  *    may be used to endorse or promote products derived from this software
00014  *    without specific prior written permission.
00015  *    
00016  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  *    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  *    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  *    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  *    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  *    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023  *    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *    
00027  *    Description:  
00028  */
00029 
00030 // INCLUDE FILES
00031 #include <ImageConversion.h>
00032 #include "ShowInfoDialog.h"
00033 
00034 const TInt KMaxInfoDescriptorLength = 100;
00035 
00036 CShowInfoDialog::CShowInfoDialog( CFrameInfoStrings* aInfoStrings ) : 
00037     iInfoStrings( aInfoStrings )
00038     {
00039     }
00040 
00041 CShowInfoDialog::~CShowInfoDialog()
00042     {
00043     iEikonEnv->ScreenDevice()->ReleaseFont(iFont);
00044     }
00045 
00046 void CShowInfoDialog::PreLayoutDynInitL()
00047     {
00048     CAknQueryDialog::PreLayoutDynInitL();
00049     SetEditableL(ETrue);    
00050     
00051     // Create font
00052     _LIT( KSeries60SansB, "Series 60 SansB" );
00053     TFontSpec fontSpec( KSeries60SansB, 75 );
00054     fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
00055     User::LeaveIfError(iEikonEnv->ScreenDevice()->GetNearestFontInTwips( iFont, fontSpec ));
00056     }
00057 
00058 void CShowInfoDialog::PostLayoutDynInitL()
00059     {
00060     CalculatePositionAndSize();
00061     }
00062 
00063 TBool CShowInfoDialog::OkToExitL(TInt /*aButtonId*/)
00064     {
00065     return ETrue;
00066     }
00067 
00068 TInt CShowInfoDialog::CountComponentControls() const
00069     {
00070     return( 0 ); 
00071     }
00072 
00073 CCoeControl* CShowInfoDialog::ComponentControl(TInt /*aIndex*/) const
00074     {
00075     return NULL;
00076     }
00077 
00078 void CShowInfoDialog::CalculatePositionAndSize()
00079     {
00080     TRect cRect;
00081     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,cRect);
00082     
00083     cRect.Shrink(25,25);
00084     SetExtent(cRect.iTl,cRect.Size());
00085     }
00086 
00087 void CShowInfoDialog::SetSizeAndPosition(const TSize &aSize)
00088     {
00089     CAknQueryDialog::SetSizeAndPosition( aSize );
00090     
00091     CalculatePositionAndSize();
00092     }
00093 
00094 void CShowInfoDialog::SizeChanged()
00095     {
00096     DrawNow();
00097     }
00098 
00099 void CShowInfoDialog::HandleResourceChange(TInt aType)
00100     {
00101     CAknQueryDialog::HandleResourceChange(aType);   
00102     }
00103 
00104 void CShowInfoDialog::Draw( const TRect& /*aRect*/ ) const
00105     {
00106     // Get the standard graphics context
00107     CWindowGc& gc = SystemGc();
00108     gc.SetPenStyle( CGraphicsContext::ENullPen );
00109     gc.SetBrushColor( KRgbBlack);
00110     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
00111 
00112     // Clear screen
00113     gc.Clear(Rect());
00114     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
00115     
00116     // Draw round rect
00117     gc.SetPenStyle( CGraphicsContext::ESolidPen );
00118     gc.SetPenColor(KRgbWhite);
00119     gc.DrawRect(Rect());
00120 
00121     // Draw image info texts
00122     gc.UseFont(iFont);
00123     TBuf<KMaxInfoDescriptorLength> desc;
00124     TPoint point = Rect().iTl;
00125     point.iX += 10;
00126     for( TInt i=0; i<iInfoStrings->Count(); i++ ) 
00127         {
00128         point.iY += 20;
00129         desc.Copy( iInfoStrings->String(i) );
00130         gc.DrawText(desc,point);
00131         }
00132     }
00133 
00134 
00135 
00136 

Generated by  doxygen 1.6.2