examples/Graphics/coverflow/src/coverflowappui.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : CoverflowAppui.cpp
00004 *  Part of     : CoverflowApp
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2005-2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include <avkon.hrh>
00018 #include <aknnotewrappers.h>
00019 #include <stringloader.h>
00020 #include <CoverflowApp.rsg>
00021 #include <f32file.h>
00022 #include <s32file.h>
00023 
00024 #include "CoverflowApp.pan"
00025 #include "CoverflowAppUi.h"
00026 #include "CoverflowAppView.h"
00027 //#include "CoverflowApph"
00028 #include "eglrendering.h"
00029 
00030 _LIT( KHelloFileName, "Hello.txt" );
00031 
00032 // ============================ MEMBER FUNCTIONS ===============================
00033 
00034 
00035 // -----------------------------------------------------------------------------
00036 // CCoverflowAppUi::ConstructL()
00037 // Symbian 2nd phase constructor can leave.
00038 // -----------------------------------------------------------------------------
00039 //
00040 void CCoverflowAppUi::ConstructL()
00041     {
00042     // Create the app framework.
00043         CAknAppUi::BaseConstructL(ENoAppResourceFile);
00044         iAppView = new(ELeave) CCoverflowAppView(*this);
00045         iAppView->ConstructL(ClientRect());
00046         AddToStackL(iAppView);
00047 
00048         iAppView->ActivateL();
00049         // Constructs object responsible for Demo.
00050         iDemo = CEGLRendering::NewL(iAppView->Window());
00051 
00052         iDemo->Start();
00053         // Construct ticker.
00054         TRect rcTicker(ClientRect());
00055 
00056     #ifdef PORTRAIT_MODE
00057         iTicker = CTicker::NewL(TRect(rcTicker.Width() - (KFontHeight + 4), 0, rcTicker.Width(),rcTicker.Height()), KNews);
00058     #else
00059         iTicker = CTicker::NewL(TRect(0,rcTicker.Height() - (KFontHeight + 4), rcTicker.Width(),rcTicker.Height()), KNews);
00060     #endif
00061 
00062         iPlayingTicker = EFalse;
00063 
00064         // Construct the dialogue Box.
00065         // Get a 212x76 pixel box in the centre of the window.
00066         TRect rcDialog(ClientRect());
00067 
00068     #ifdef PORTRAIT_MODE
00069         rcDialog.Shrink((rcDialog.Width() - 76) / 2, (rcDialog.Height() - 212) / 2);
00070     #else
00071         rcDialog.Shrink((rcDialog.Width() - 212) / 2, (rcDialog.Height() - 76) / 2);
00072     #endif
00073 
00074         iDialogBox = CDialogBox::NewL(rcDialog);
00075         iCallWindow = EFalse;   
00076 
00077     }
00078 // -----------------------------------------------------------------------------
00079 // CCoverflowAppUi::CCoverflowAppUi()
00080 // C++ default constructor can NOT contain any code, that might leave.
00081 // -----------------------------------------------------------------------------
00082 //
00083 CCoverflowAppUi::CCoverflowAppUi()
00084     {
00085     // No implementation required
00086     }
00087 
00088 // -----------------------------------------------------------------------------
00089 // CCoverflowAppUi::~CCoverflowAppUi()
00090 // Destructor.
00091 // -----------------------------------------------------------------------------
00092 //
00093 CCoverflowAppUi::~CCoverflowAppUi()
00094     {
00095     delete iDemo;
00096     if (iAppView)
00097         {
00098         RemoveFromStack(iAppView);
00099         delete iAppView;
00100         iAppView = NULL;
00101         }
00102     delete iTicker;
00103     delete iDialogBox;
00104     }
00105 
00111 TKeyResponse CCoverflowAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
00112     {
00113     TKeyResponse response = EKeyWasConsumed;
00114     switch (aKeyEvent.iCode)
00115         {
00116     case EKeyEscape:
00117         // Exit the application if the escape key is pressed.
00118         Exit();
00119         break;
00120 
00121     case EKeyDownArrow:
00122         // Enable or disable the ticker playback if down arrow key is pressed.
00123         if(!iPlayingTicker)
00124             {
00125             iTicker->Start();
00126             iPlayingTicker = ETrue;
00127             }
00128         else
00129             {
00130             iTicker->Stop();
00131             iPlayingTicker = EFalse;
00132             }
00133         break;
00134     case EKeyUpArrow:
00135         // Show or hide the call window if up arrow key is pressed.
00136         if(!iCallWindow)
00137             {
00138             iDialogBox->Start();
00139             iCallWindow = ETrue;
00140             }
00141         else
00142             {
00143             iDialogBox->Stop();
00144             iCallWindow = EFalse;
00145             }
00146         break;
00147     case EKeyTab:
00148         // Show or hide the semi-transparent green window around the call window if tab key is pressed.
00149         if(iCallWindow)
00150             {
00151             if(!iDialogBox->IsSemiTransparent())
00152                 iDialogBox->SetSemiTransparency();
00153             else
00154                 iDialogBox->RemoveSemiTransparency();
00155             }
00156         break;
00157     case EKeyRightArrow:
00158     case EKeyLeftArrow:
00159     case EKeyBackspace:
00160     case EKeySpace:
00161         response = iDemo->HandleKeyEventL(aKeyEvent);
00162         break;
00163     default:
00164         response = EKeyWasNotConsumed;
00165         }
00166     return response;
00167     }
00168 
00169 // End of File
00170 

Generated by  doxygen 1.6.2