examples/Graphics/coverflow/src/coverflowappui.cpp

00001 /*
00002 Copyright (c) 2005-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 <avkon.hrh>
00032 #include <aknnotewrappers.h>
00033 #include <stringloader.h>
00034 #include <CoverflowApp.rsg>
00035 #include <f32file.h>
00036 #include <s32file.h>
00037 
00038 #include "CoverflowApp.pan"
00039 #include "CoverflowAppUi.h"
00040 #include "CoverflowAppView.h"
00041 //#include "CoverflowApph"
00042 #include "eglrendering.h"
00043 
00044 _LIT( KHelloFileName, "Hello.txt" );
00045 
00046 // ============================ MEMBER FUNCTIONS ===============================
00047 
00048 
00049 // -----------------------------------------------------------------------------
00050 // CCoverflowAppUi::ConstructL()
00051 // Symbian 2nd phase constructor can leave.
00052 // -----------------------------------------------------------------------------
00053 //
00054 void CCoverflowAppUi::ConstructL()
00055     {
00056     // Create the app framework.
00057         CAknAppUi::BaseConstructL(ENoAppResourceFile);
00058         iAppView = new(ELeave) CCoverflowAppView(*this);
00059         iAppView->ConstructL(ClientRect());
00060         AddToStackL(iAppView);
00061 
00062         iAppView->ActivateL();
00063         // Constructs object responsible for Demo.
00064         iDemo = CEGLRendering::NewL(iAppView->Window());
00065 
00066         iDemo->Start();
00067         // Construct ticker.
00068         TRect rcTicker(ClientRect());
00069 
00070     #ifdef PORTRAIT_MODE
00071         iTicker = CTicker::NewL(TRect(rcTicker.Width() - (KFontHeight + 4), 0, rcTicker.Width(),rcTicker.Height()), KNews);
00072     #else
00073         iTicker = CTicker::NewL(TRect(0,rcTicker.Height() - (KFontHeight + 4), rcTicker.Width(),rcTicker.Height()), KNews);
00074     #endif
00075 
00076         iPlayingTicker = EFalse;
00077 
00078         // Construct the dialogue Box.
00079         // Get a 212x76 pixel box in the centre of the window.
00080         TRect rcDialog(ClientRect());
00081 
00082     #ifdef PORTRAIT_MODE
00083         rcDialog.Shrink((rcDialog.Width() - 76) / 2, (rcDialog.Height() - 212) / 2);
00084     #else
00085         rcDialog.Shrink((rcDialog.Width() - 212) / 2, (rcDialog.Height() - 76) / 2);
00086     #endif
00087 
00088         iDialogBox = CDialogBox::NewL(rcDialog);
00089         iCallWindow = EFalse;   
00090 
00091     }
00092 // -----------------------------------------------------------------------------
00093 // CCoverflowAppUi::CCoverflowAppUi()
00094 // C++ default constructor can NOT contain any code, that might leave.
00095 // -----------------------------------------------------------------------------
00096 //
00097 CCoverflowAppUi::CCoverflowAppUi()
00098     {
00099     // No implementation required
00100     }
00101 
00102 // -----------------------------------------------------------------------------
00103 // CCoverflowAppUi::~CCoverflowAppUi()
00104 // Destructor.
00105 // -----------------------------------------------------------------------------
00106 //
00107 CCoverflowAppUi::~CCoverflowAppUi()
00108     {
00109     delete iDemo;
00110     if (iAppView)
00111         {
00112         RemoveFromStack(iAppView);
00113         delete iAppView;
00114         iAppView = NULL;
00115         }
00116     delete iTicker;
00117     delete iDialogBox;
00118     }
00119 
00125 TKeyResponse CCoverflowAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
00126     {
00127     TKeyResponse response = EKeyWasConsumed;
00128     switch (aKeyEvent.iCode)
00129         {
00130     case EKeyEscape:
00131         // Exit the application if the escape key is pressed.
00132         Exit();
00133         break;
00134 
00135     case EKeyDownArrow:
00136         // Enable or disable the ticker playback if down arrow key is pressed.
00137         if(!iPlayingTicker)
00138             {
00139             iTicker->Start();
00140             iPlayingTicker = ETrue;
00141             }
00142         else
00143             {
00144             iTicker->Stop();
00145             iPlayingTicker = EFalse;
00146             }
00147         break;
00148     case EKeyUpArrow:
00149         // Show or hide the call window if up arrow key is pressed.
00150         if(!iCallWindow)
00151             {
00152             iDialogBox->Start();
00153             iCallWindow = ETrue;
00154             }
00155         else
00156             {
00157             iDialogBox->Stop();
00158             iCallWindow = EFalse;
00159             }
00160         break;
00161     case EKeyTab:
00162         // Show or hide the semi-transparent green window around the call window if tab key is pressed.
00163         if(iCallWindow)
00164             {
00165             if(!iDialogBox->IsSemiTransparent())
00166                 iDialogBox->SetSemiTransparency();
00167             else
00168                 iDialogBox->RemoveSemiTransparency();
00169             }
00170         break;
00171     case EKeyRightArrow:
00172     case EKeyLeftArrow:
00173     case EKeyBackspace:
00174     case EKeySpace:
00175         response = iDemo->HandleKeyEventL(aKeyEvent);
00176         break;
00177     default:
00178         response = EKeyWasNotConsumed;
00179         }
00180     return response;
00181     }
00182 
00183 // End of File
00184 

Generated by  doxygen 1.6.2