calendarui/editors/src/KoreanLunarTypeField.cpp
branchRCL_3
changeset 31 97232defd20e
equal deleted inserted replaced
30:bd7edf625bdd 31:97232defd20e
       
     1 /*
       
     2 * Copyright (c) 2010 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 //debug
       
    19 #include "calendarui_debug.h"
       
    20 
       
    21 #include "KoreanLunarTypeField.h"
       
    22 
       
    23 #include "CalenDefaultEditors.hrh"
       
    24 
       
    25 #include <CalenDefaultEditorsData.rsg>
       
    26 
       
    27 #include <AknPopupField.h>
       
    28 #include <AknQueryValueText.h>
       
    29 #include <badesca.h>
       
    30 #include <calentry.h>
       
    31 #include <eikcapc.h> 
       
    32 
       
    33 
       
    34 // CONSTRUCTION AND DESTRUCTION METHODS
       
    35 CKoreanLunarTypeField* CKoreanLunarTypeField::NewL(CCalenUnifiedEditor& aForm)
       
    36     {
       
    37     TRACE_ENTRY_POINT;
       
    38     
       
    39     CKoreanLunarTypeField* self = 
       
    40         new( ELeave ) CKoreanLunarTypeField(aForm);
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop();
       
    44     
       
    45     TRACE_EXIT_POINT;
       
    46     return self;
       
    47     }
       
    48 
       
    49 CKoreanLunarTypeField::CKoreanLunarTypeField(CCalenUnifiedEditor& aForm)
       
    50     : iUniEditor(aForm)
       
    51     {
       
    52     TRACE_ENTRY_POINT;
       
    53     TRACE_EXIT_POINT;
       
    54     }
       
    55 
       
    56 void CKoreanLunarTypeField::ConstructL()
       
    57     {
       
    58     TRACE_ENTRY_POINT;
       
    59     
       
    60     iTypeArrayText = iUniEditor.ControlEnv()->ReadDesCArrayResourceL( R_KOREAN_LUNAR_TYPE_POPUP_ITEMS );
       
    61 
       
    62     // create textarray
       
    63     iTypeArray = CAknQueryValueTextArray::NewL();
       
    64     iTypeArray->SetArray(*iTypeArrayText);
       
    65 
       
    66     iTypeTextValues = CAknQueryValueText::NewL();
       
    67     iTypeTextValues->SetArrayL(iTypeArray);
       
    68     
       
    69     TRACE_EXIT_POINT;
       
    70     }
       
    71 
       
    72 CKoreanLunarTypeField::~CKoreanLunarTypeField()
       
    73     {
       
    74     TRACE_ENTRY_POINT;
       
    75     
       
    76     delete iTypeArrayText;
       
    77     delete iTypeArray;
       
    78     delete iTypeTextValues;
       
    79     
       
    80     TRACE_EXIT_POINT;
       
    81     }
       
    82 
       
    83 void CKoreanLunarTypeField::PreLayoutDynInitL()
       
    84     {
       
    85     TRACE_ENTRY_POINT;
       
    86     SetDataToFormL();
       
    87     CAknPopupField* pops =
       
    88         static_cast<CAknPopupField*>( iUniEditor.Control(EKoreanLunarTypeSelectSolarLunarLeap) );
       
    89     pops->SetQueryValueL(iTypeTextValues);
       
    90     
       
    91     TRACE_EXIT_POINT;
       
    92     }
       
    93 
       
    94 void CKoreanLunarTypeField::SetDataToFormL()
       
    95     {
       
    96     TRACE_ENTRY_POINT;
       
    97    //TInt pos = (TInt)Type();
       
    98      TInt pos = iUniEditor.Edited().CalendarType();
       
    99     iTypeTextValues->SetCurrentValueIndex( pos );
       
   100     
       
   101     TRACE_EXIT_POINT;
       
   102     }
       
   103 
       
   104 void CKoreanLunarTypeField::ReadDataFromFormL( TBool /*aContinueOnError*/ )
       
   105     {
       
   106     TRACE_ENTRY_POINT;
       
   107     
       
   108     TInt pos = iTypeTextValues->CurrentValueIndex();
       
   109     iUniEditor.Edited().SetCalendarTypeL( static_cast<TLunarCalendarType>( pos ) );
       
   110     
       
   111     TRACE_EXIT_POINT;
       
   112     }
       
   113 
       
   114 void CKoreanLunarTypeField::PrepareForFocusTransitionL( TInt aFocusedId )
       
   115     {
       
   116 	TRACE_ENTRY_POINT;
       
   117 	
       
   118 	switch( aFocusedId )
       
   119 	    {
       
   120     	//case ECalenNoteType:
       
   121 		case ECalenEditorEventType:
       
   122     		{
       
   123 	    	TBool continueOnError = EFalse;
       
   124 		    ReadDataFromFormL( continueOnError );
       
   125 		    break;
       
   126             }
       
   127     	default: 
       
   128 	    	break;
       
   129 	    }
       
   130 	TRACE_EXIT_POINT;
       
   131     }
       
   132 
       
   133 TLunarCalendarType CKoreanLunarTypeField::Type()
       
   134     {
       
   135 	TRACE_ENTRY_POINT;
       
   136     TInt pos = iTypeTextValues->CurrentValueIndex();
       
   137     
       
   138 	TRACE_EXIT_POINT;
       
   139     return static_cast<TLunarCalendarType>( pos );
       
   140     }
       
   141 
       
   142 
       
   143 void CKoreanLunarTypeField::HandleControlStateChangeL( TInt aControlId )
       
   144 	{
       
   145     TRACE_ENTRY_POINT;
       
   146     iUniEditor.EditorFields().OnLunarTypeChangedL( Type() );
       
   147     TRACE_EXIT_POINT;
       
   148 	}
       
   149 	
       
   150 // End of File
       
   151