basiclocationinfodisplay/blid/ui/src/CBlidCurrentPositionDlg.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Provides blid main view class methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  SYSTEM INCLUDE FILES
       
    20 #include <aknlists.h>
       
    21 #include <blid.rsg>
       
    22 #include <avkon.hrh>
       
    23 #include <aknborders.h>
       
    24 
       
    25 //  USER INCLUDE FILES
       
    26 #include "CBlidCurrentPositionDlg.h"
       
    27 #include "CBlidBaseView.h"
       
    28 #include "CBlidOwnPosLBModel.h"
       
    29 #include "MBlidLocation.h"
       
    30 #include "CBlidEng.h"
       
    31 #include "CBlidDocument.h"
       
    32 
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 // ----------------------------------------------------------------------------
       
    36 // CBlidCurrentPositionDlg::NewLC
       
    37 // Two-phased constructor.
       
    38 // ----------------------------------------------------------------------------
       
    39 //
       
    40 CBlidCurrentPositionDlg* CBlidCurrentPositionDlg::NewL( CBlidBaseView& aView,
       
    41         						   						MBlidLocation* aLoc,
       
    42         						   						CBlidEng* aEng )
       
    43     {
       
    44     CBlidCurrentPositionDlg* self = new(ELeave)
       
    45         CBlidCurrentPositionDlg( aView, aLoc, aEng );
       
    46     CleanupStack::PushL(self);
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop(); // self
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // CBlidCurrentPositionDlg::CBlidCurrentPositionDlg
       
    54 // C++ default constructor can NOT contain any code, that
       
    55 // might leave.
       
    56 // ----------------------------------------------------------------------------
       
    57 //
       
    58 CBlidCurrentPositionDlg::CBlidCurrentPositionDlg(  CBlidBaseView& aView,
       
    59         						   				   MBlidLocation* aLoc,
       
    60         						   				   CBlidEng* aEng ):
       
    61     iView(aView)
       
    62     {
       
    63     iLoc = aLoc;
       
    64     iEng = aEng;
       
    65     isDlgExited = EFalse;
       
    66     isLmSaved = EFalse;
       
    67     }
       
    68 
       
    69 // ----------------------------------------------------------------------------
       
    70 // CBlidCurrentPositionDlg::ExecuteLD
       
    71 //
       
    72 // ----------------------------------------------------------------------------
       
    73 //    
       
    74 void CBlidCurrentPositionDlg::ExecuteLD()
       
    75     {
       
    76     CAknPopupList::ExecuteLD();
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CBlidCurrentPositionDlg::~CBlidCurrentPositionDlg
       
    81 // 
       
    82 // ----------------------------------------------------------------------------
       
    83 //
       
    84 CBlidCurrentPositionDlg::~CBlidCurrentPositionDlg()
       
    85     {
       
    86     delete iListBox;
       
    87     iLoc = NULL;
       
    88     }
       
    89 
       
    90 // ----------------------------------------------------------------------------
       
    91 // CBlidCurrentPositionDlg::ProcessCommandL
       
    92 // 
       
    93 // ----------------------------------------------------------------------------
       
    94 //
       
    95 void CBlidCurrentPositionDlg::ProcessCommandL(TInt aCommandId)
       
    96     {
       
    97     switch (aCommandId)
       
    98         {
       
    99         case EAknSoftkeySave:
       
   100             {
       
   101        		iView.SaveCurrentPositionL();
       
   102             break;
       
   103             }
       
   104         default:
       
   105             {
       
   106             isDlgExited = ETrue;
       
   107             CAknPopupList::ProcessCommandL(aCommandId);
       
   108             break;
       
   109             }
       
   110         }
       
   111     }    
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CBlidCurrentPositionDlg::ConstructL
       
   115 // Symbian 2nd phase constructor can leave.
       
   116 // ----------------------------------------------------------------------------
       
   117 //    
       
   118 void CBlidCurrentPositionDlg::ConstructL()
       
   119     {
       
   120     iListBox = new (ELeave) CAknSingleHeadingPopupMenuStyleListBox;
       
   121 
       
   122     CAknPopupList::ConstructL(iListBox, 
       
   123                               R_BLID_CURRENTLOCATION_SOFTKEYS_SAVE__EXIT,
       
   124                               AknPopupLayouts::EDynMenuWindow );
       
   125     
       
   126     iListBox->ConstructL(this, EAknListBoxDisableHighlight |
       
   127     								 EAknGenericListBoxFlags );
       
   128     
       
   129     SetBorder(AknBorderId::EAknBorderNotePopup);
       
   130 	
       
   131 	HBufC* textFromResourceFile;
       
   132     CEikonEnv* env = CEikonEnv::Static();
       
   133     textFromResourceFile = env->AllocReadResourceLC(R_BLID_TITLE_POSITION);
       
   134     SetTitleL( *textFromResourceFile );
       
   135     CleanupStack::PopAndDestroy();  // textFromResourceFile
       
   136         
       
   137     MDesCArray* model = CBlidOwnPosLBModel::NewLC( iLoc, iEng->SettingsModel());
       
   138     iListBox->Model()->SetItemTextArray( model );
       
   139     iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
       
   140     CleanupStack::Pop(); // model
       
   141 
       
   142     // Make scroll arrows
       
   143     iListBox->CreateScrollBarFrameL( ETrue );
       
   144     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   145         CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn );      
       
   146     }
       
   147     
       
   148 // ---------------------------------------------------------
       
   149 // CBlidCurrentPositionDlg::ChangeDlgSoftKey
       
   150 // ---------------------------------------------------------
       
   151 //    
       
   152 void CBlidCurrentPositionDlg::ChangeDlgSoftKey( )
       
   153 	{
       
   154 	if( !isDlgExited )
       
   155 		{
       
   156 		if( iLoc != NULL )
       
   157 			{
       
   158 			if( iLoc->IsGPSDataAvailable() )
       
   159 				{
       
   160 				ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeySave, ETrue );			
       
   161 				}
       
   162 			else
       
   163 				{
       
   164 				ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeySave, EFalse );			
       
   165 				}
       
   166 			DrawNow();					
       
   167 			}
       
   168 		}
       
   169 	}
       
   170 // End Of File