uifw/EikStd/coctlsrc/EIKHKEYC.CPP
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 1997-1999 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 
       
    19 #include <eikhkeyc.h>
       
    20 #include <eikhkeyt.h>
       
    21 #include <eikcmobs.h>
       
    22 
       
    23 /**
       
    24  * Writes the internal state of the control and its components to aStream.
       
    25  * Does nothing in release mode.
       
    26  * Designed to be overidden and base called by subclasses.
       
    27  *
       
    28  * @internal
       
    29  * @since App-Framework_6.1
       
    30  */
       
    31 #ifndef _DEBUG
       
    32 EXPORT_C void CEikHotKeyControl::WriteInternalStateL(RWriteStream&) const
       
    33 	{}
       
    34 #else
       
    35 EXPORT_C void CEikHotKeyControl::WriteInternalStateL(RWriteStream& aWriteStream) const
       
    36 	{
       
    37 	_LIT(KEikLitBtpanCtlSt,"<CEikHotKeyControl>");
       
    38 	_LIT(KEikLitBtpanCtlEnd,"<\\CEikHotKeyControl>");
       
    39 	_LIT(KEikLitBtpanCtlHkeyObs, "<iObserver>");
       
    40 	_LIT(KEikLitBtpanCtlHkeyObsEnd, "<\\iObserver>");
       
    41 	_LIT(KEikLitBtpanCtlHkeyTab, "<iTable>");
       
    42 	_LIT(KEikLitBtpanCtlHkeyTabEnd, "<\\iTable>");
       
    43 
       
    44 	aWriteStream << KEikLitBtpanCtlSt;
       
    45 	aWriteStream << KEikLitBtpanCtlHkeyTab;
       
    46 
       
    47 	const TInt count=iTable->Count();
       
    48 	for(TInt i=0;i<count;i++)
       
    49 		{
       
    50 		const SEikHotKey& hkey=(*iTable)[i];
       
    51 		aWriteStream.WriteInt32L(hkey.iCommandId);
       
    52 		aWriteStream.WriteInt32L(hkey.iKeycode);
       
    53 		}
       
    54 	aWriteStream << KEikLitBtpanCtlHkeyTabEnd;
       
    55 	aWriteStream << KEikLitBtpanCtlHkeyObs;
       
    56 	aWriteStream.WriteInt32L((TInt)iObserver);
       
    57 	aWriteStream << KEikLitBtpanCtlHkeyObsEnd;
       
    58 	CCoeControl::WriteInternalStateL(aWriteStream);
       
    59 	aWriteStream << KEikLitBtpanCtlEnd;
       
    60 	}
       
    61 #endif
       
    62 
       
    63 TKeyResponse CEikHotKeyControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
    64     {
       
    65     if (aType!=EEventKey)
       
    66         return(EKeyWasNotConsumed);
       
    67     TInt command=iTable->CommandIdFromHotKey(aKeyEvent.iCode,aKeyEvent.iModifiers&(EModifierCtrl|EModifierShift|EModifierPureKeycode));
       
    68     if (!command)
       
    69         return(EKeyWasNotConsumed);
       
    70     iObserver->ProcessCommandL(command);
       
    71     return(EKeyWasConsumed);
       
    72     }
       
    73 
       
    74 CEikHotKeyControl::CEikHotKeyControl(CEikHotKeyTable* aTable,MEikCommandObserver* aObserver)
       
    75 	: iTable(aTable),
       
    76     iObserver(aObserver)
       
    77     {
       
    78 	MakeVisible(EFalse);
       
    79 	}
       
    80 
       
    81 CEikHotKeyControl::~CEikHotKeyControl()
       
    82     {
       
    83     delete(iTable);
       
    84     }