sdkcreationmw/sdkruntimes/MIDP/DebugAgent/src/JavaDebugAgentSettingsScreen.cpp
changeset 0 b26acd06ea60
equal deleted inserted replaced
-1:000000000000 0:b26acd06ea60
       
     1 /*
       
     2 * Copyright (c) 2006 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 "JavaDebugAgent.hrh"
       
    20 #include "JavaDebugAgentRes.h"
       
    21 #include "JavaDebugAgentSettings.h"
       
    22 #include "JavaDebugAgentSettingsScreen.h"
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 //  List box
       
    27 //
       
    28 // ---------------------------------------------------------------------------
       
    29 
       
    30 #define SUPER CAknSettingItemList
       
    31 
       
    32 CJavaDebugAgentSettingsScreen* 
       
    33 CJavaDebugAgentSettingsScreen::NewL(CJavaDebugAgentSettings* aSettings, 
       
    34                                     TInt aListResId)
       
    35 {
       
    36     CJavaDebugAgentSettingsScreen* self;
       
    37     self = new(ELeave)CJavaDebugAgentSettingsScreen(aSettings);
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL(aListResId);
       
    40     CleanupStack::Pop(self);
       
    41     return self;
       
    42 }
       
    43 
       
    44 CJavaDebugAgentSettingsScreen::CJavaDebugAgentSettingsScreen(
       
    45     CJavaDebugAgentSettings* aSettings) :
       
    46     iSettings(aSettings)
       
    47 {
       
    48 }
       
    49 
       
    50 CJavaDebugAgentSettingsScreen::~CJavaDebugAgentSettingsScreen()
       
    51 {
       
    52 }
       
    53 
       
    54 void CJavaDebugAgentSettingsScreen::ConstructL(TInt aListResId)
       
    55 {
       
    56     ConstructFromResourceL(aListResId);
       
    57 }
       
    58 
       
    59 CAknSettingItem* CJavaDebugAgentSettingsScreen::CreateSettingItemL(TInt aSetId)
       
    60 {
       
    61     CJavaDebugAgentSettings::TParam* param = iSettings->FindParam(aSetId);
       
    62     if (!param) User::Leave(KErrArgument);
       
    63     CAknSettingItem* item = param->CreateSettingItemL();
       
    64     switch (aSetId)
       
    65     {
       
    66     case EJavaDebugAgentAutoCleanItem:
       
    67         delete iAutoCleanItem;
       
    68         iAutoCleanItem = (CJavaDebugAgentSettingsBooleanItem*)item;
       
    69         item = iAutoCleanItem;
       
    70         break;
       
    71 
       
    72     case EJavaDebugAgentFileLogItem:
       
    73         delete iFileLogItem;
       
    74         iFileLogItem = (CJavaDebugAgentSettingsBooleanItem*)item;
       
    75         break;
       
    76     }
       
    77     return item;
       
    78 }
       
    79 
       
    80 TBool CJavaDebugAgentSettingsScreen::ChangeValueL(TInt aSettingId)
       
    81 {
       
    82     CJavaDebugAgentSettingsBooleanItem* changeItem = NULL;
       
    83     switch (aSettingId)
       
    84     {
       
    85     case EJavaDebugAgentAutoCleanItem:
       
    86         changeItem = iAutoCleanItem;
       
    87         break;
       
    88 
       
    89     case EJavaDebugAgentFileLogItem:
       
    90         changeItem = iFileLogItem;
       
    91         break;
       
    92 
       
    93     default:
       
    94         return EFalse;
       
    95     }
       
    96 
       
    97     changeItem->ChangeValueL();
       
    98     changeItem->StoreL();
       
    99     changeItem->LoadL();
       
   100     changeItem->UpdateListBoxTextL();
       
   101     ListBox()->DrawDeferred();
       
   102     return ETrue;
       
   103 }
       
   104 
       
   105 void CJavaDebugAgentSettingsScreen::HandleListBoxEventL(
       
   106     CEikListBox* aListBox, TListBoxEvent aEventType)
       
   107 {
       
   108     TInt index;
       
   109     switch(aEventType) {
       
   110     case EEventEnterKeyPressed:
       
   111     case EEventItemDoubleClicked:
       
   112         index = aListBox->CurrentItemIndex();
       
   113         if (index >= 0 && index < ListBox()->Model()->NumberOfItems())
       
   114         {
       
   115             CAknSettingItem* item = SettingItemArray()->At(index);
       
   116             if (ChangeValueL(item->Identifier()))
       
   117             {
       
   118                 // Event has been handled
       
   119                 return;
       
   120             }
       
   121         }
       
   122         // NO BREAK
       
   123     default:
       
   124         SUPER::HandleListBoxEventL(aListBox, aEventType);
       
   125         break;
       
   126     }
       
   127 }
       
   128 
       
   129 // CCoeControl
       
   130 void CJavaDebugAgentSettingsScreen::SizeChanged()
       
   131 {
       
   132     ListBox()->SetRect(Rect());
       
   133     SUPER::SizeChanged();
       
   134 }
       
   135 
       
   136 /**
       
   137  * Local Variables:
       
   138  * c-basic-offset: 4
       
   139  * indent-tabs-mode: nil
       
   140  * End:
       
   141  */