examples/sfexamples/MidiPlaying/src/MidiPlayingAppUi.cpp

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:
00015 // 
00016 
00017 // INCLUDES
00018 #include <eikapp.h>
00019 #include <f32file.h>
00020 #include <MidiPlaying.rsg>
00021 
00022 #include "MidiPlayingAppUi.h"
00023 #include "MidiPlayingMainView.h"
00024 #include "MidiPlaying.hrh"
00025 
00026 // CONSTANTS
00027 _LIT(KFileName, "\\data\\sample.mid");
00028 
00029 // MEMBER FUNCTIONS
00030 
00031 // --------------------------------------------------------------------------
00032 // Constructor
00033 // --------------------------------------------------------------------------
00034 void CMidiPlayingAppUi::ConstructL()
00035         {
00036 
00037         BaseConstructL(EAknEnableSkin);
00038         
00039         iMainView = CMidiPlayingMainView::NewL(ClientRect());
00040         
00041         iMidiPlayer = CMidiPlayer::NewL();
00042         }
00043         
00044 // --------------------------------------------------------------------------
00045 // Destructor
00046 // --------------------------------------------------------------------------
00047 CMidiPlayingAppUi::~CMidiPlayingAppUi()
00048     {
00049     delete iMidiPlayer;    
00050 
00051     if (iMainView)
00052         {
00053         delete iMainView;
00054         iMainView = NULL;
00055         }
00056 
00057     }
00058 
00059 // --------------------------------------------------------------------------
00060 // Handles user command.
00061 // --------------------------------------------------------------------------
00062 void CMidiPlayingAppUi::HandleCommandL(TInt aCommand)
00063         {
00064         switch ( aCommand )
00065                 {
00066 
00067                 // For S60, we need to handle this event, which is normally
00068                 // an event from the right soft key.
00069                 case EAknSoftkeyExit:
00070 
00071                 case EEikCmdExit:
00072                         {
00073                         Exit();
00074                         break;
00075                         }
00076                 
00077                 case EMidiPlayingPlay:
00078                         {
00079                         // Construct file name.
00080                         // It adds drive letter to KFileName, where drive letter
00081                         // is the same as the application's executable.
00082                         TParsePtrC parseAppPath(Application()->AppFullName());
00083                         TParse parseFileName;
00084                         parseFileName.Set(parseAppPath.Drive(), 0, &KFileName);
00085                         
00086                         iMidiPlayer->Play(parseFileName.FullName());
00087                         break;
00088                         }
00089                         
00090                 case EMidiPlayingStopPlaying:
00091                         {
00092                         iMidiPlayer->Stop();
00093                         break;
00094                         }
00095                 
00096                 default:
00097                         // Do nothing
00098                         break;
00099                 }
00100         }       
00101 
00102 
00103 // --------------------------------------------------------------------------
00104 // Handles screen resolution/size changes.
00105 // --------------------------------------------------------------------------
00106 void CMidiPlayingAppUi::HandleResourceChangeL(TInt aType)
00107         {
00108         CAknAppUi::HandleResourceChangeL(aType);
00109         iMainView->SetRect(ClientRect());
00110         }
00111 
00112 
00113 // End of File

Generated by  doxygen 1.6.2