classicui_pub/buttons_api/tsrc/src/testsdkbuttonsblockseikmnbut.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  Test api in eikmnbut.h
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // [INCLUDE FILES]
       
    21 #include <e32svr.h>
       
    22 #include <stifparser.h>
       
    23 #include <stiftestinterface.h>
       
    24 #include <testsdkbuttons.rsg>
       
    25 #include <s32mem.h>
       
    26 
       
    27 #include "testsdkbuttons.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 // Observer class for test function
       
    31 class CTestMenuObserver : public CBase, public MEikMenuObserver
       
    32     {
       
    33     // from MEikMenuObserver, no need
       
    34     void SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/){}
       
    35     // from MEikMenuObserver, no need
       
    36     void ProcessCommandL(TInt /*aCommandId*/){}
       
    37     };
       
    38 // ============================ MEMBER FUNCTIONS ===============================
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CTestSDKButtons::TestMenuBtConstructorL
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 TInt CTestSDKButtons::TestMenuBtConstructorL( CStifItemParser& /*aItem*/ )
       
    45     {
       
    46     CEikMenuButton* menubutton = new ( ELeave ) CEikMenuButton;
       
    47     CleanupStack::PushL( menubutton );
       
    48     STIF_ASSERT_NOT_NULL( menubutton );
       
    49     CleanupStack::PopAndDestroy( menubutton );
       
    50     
       
    51     return KErrNone;
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CTestSDKButtons::TestMenuBtConstructFromResourceL
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 TInt CTestSDKButtons::TestMenuBtConstructFromResourceL( CStifItemParser& /*aItem*/ )
       
    59     {
       
    60     CEikMenuButton* menubutton = new ( ELeave ) CEikMenuButton;
       
    61     CleanupStack::PushL( menubutton );
       
    62     TResourceReader reader;
       
    63     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_TEST_MENU_BUTTON );
       
    64     menubutton->ConstructFromResourceL( reader );
       
    65     
       
    66     CleanupStack::PopAndDestroy( 2 );
       
    67     
       
    68     return KErrNone;
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CTestSDKButtons::TestMenuBtLaunchPopupMenuL
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 TInt CTestSDKButtons::TestMenuBtLaunchPopupMenuL( CStifItemParser& /*aItem*/ )
       
    76     {
       
    77     CTestMenuObserver* ob = new ( ELeave ) CTestMenuObserver;
       
    78     CleanupStack::PushL( ob );
       
    79     CEikMenuButton* menubutton = new ( ELeave ) CEikMenuButton;
       
    80     CleanupStack::PushL( menubutton );
       
    81     TResourceReader reader;
       
    82     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_TEST_MENU_BUTTON );
       
    83     menubutton->ConstructFromResourceL( reader );
       
    84     menubutton->SetContainerWindowL( *iContainer );
       
    85     iContainer->SetComponentControlL( menubutton );
       
    86     TPointerEvent event;
       
    87     menubutton->HandlePointerEventL( event );
       
    88 //    menubutton->LaunchPopupMenuL( ob );
       
    89     CleanupStack::PopAndDestroy( 3 );
       
    90     
       
    91     return KErrNone;
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CTestSDKButtons::TestMenuBtSetMenuPaneIdL
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 TInt CTestSDKButtons::TestMenuBtSetMenuPaneIdL( CStifItemParser& /*aItem*/ )
       
    99     {
       
   100     TInt menupaneid = 0;
       
   101     CEikMenuButton* menubutton = new ( ELeave ) CEikMenuButton;
       
   102     CleanupStack::PushL( menubutton );
       
   103     TResourceReader reader;
       
   104     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_TEST_MENU_BUTTON );
       
   105     menubutton->ConstructFromResourceL( reader );
       
   106     
       
   107     menubutton->SetMenuPaneId( menupaneid );
       
   108     
       
   109     CleanupStack::PopAndDestroy( 2 );
       
   110     
       
   111     return KErrNone;
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CTestSDKButtons::TestMenuBtAnimateL
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 TInt CTestSDKButtons::TestMenuBtAnimateL( CStifItemParser& /*aItem*/ )
       
   119     {
       
   120     CEikMenuButton* menubutton = new ( ELeave ) CEikMenuButton;
       
   121     CleanupStack::PushL( menubutton );
       
   122     menubutton->Animate();
       
   123     CleanupStack::PopAndDestroy( menubutton );
       
   124     
       
   125     return KErrNone;
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CTestSDKButtons::TestMenuBtWriteInternalStateL
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 TInt CTestSDKButtons::TestMenuBtWriteInternalStateL( CStifItemParser& /*aItem*/ )
       
   133     {
       
   134     class CTestEikMenuButton : public CEikMenuButton
       
   135         {
       
   136     public:
       
   137         /*Constructor*/
       
   138         CTestEikMenuButton(){}
       
   139         /*Deconstructor*/
       
   140         ~CTestEikMenuButton(){}
       
   141         void DoWriteInternalStateL( RWriteStream aStream )
       
   142             {
       
   143             WriteInternalStateL( aStream );
       
   144             }
       
   145         };
       
   146     CTestEikMenuButton* menubutton = new ( ELeave ) CTestEikMenuButton;
       
   147     CleanupStack::PushL( menubutton );
       
   148     TResourceReader reader;
       
   149     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_TEST_MENU_BUTTON );
       
   150     menubutton->ConstructFromResourceL( reader );
       
   151     const TInt KHBufSize = 4096;
       
   152     HBufC8* buf = HBufC8::NewL( KHBufSize );
       
   153     CleanupStack::PushL( buf );
       
   154     TPtr8 ptr = buf->Des();
       
   155     RDesWriteStream stream;
       
   156     CleanupClosePushL( stream );
       
   157     stream.Open( ptr );
       
   158     menubutton->DoWriteInternalStateL( stream );
       
   159     stream.CommitL();
       
   160     stream.Close();
       
   161     CleanupStack::PopAndDestroy( 4 );// menubutton, reader, buf, stream
       
   162     
       
   163     return KErrNone;
       
   164     }
       
   165 
       
   166 // End of file