javauis/eswt_akn/eswtapifacade/src/swtcomboproxy.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 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:  THIS FILE IS NOT INCLUDED INTO ECLIPSE CVS DELIVERY
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <aknchoicelist.h>
       
    21 #include "swtcomboproxy.h"
       
    22 
       
    23 
       
    24 const TInt KSwtAknComboCtrlsCount = 1;
       
    25 
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CSwtComboProxy::NewL
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 EXPORT_C CSwtComboProxy* CSwtComboProxy::NewL(CCoeControl* aParent, CDesCArray* aItemArray)
       
    35 {
       
    36     CSwtComboProxy* self = new(ELeave) CSwtComboProxy();
       
    37     CleanupStack::PushL(self);
       
    38     self->ConstructL(aParent, aItemArray);
       
    39     CleanupStack::Pop(self);
       
    40     return self;
       
    41 }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // CSwtComboProxy::~CSwtComboProxy
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C CSwtComboProxy::~CSwtComboProxy()
       
    48 {
       
    49     delete iDelegate;
       
    50     iDelegate = NULL;
       
    51 }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CSwtComboProxy::ShowChoiceListL
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 EXPORT_C TInt CSwtComboProxy::ShowChoiceListL()
       
    58 {
       
    59     return iDelegate->ShowChoiceListL();
       
    60 }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CSwtComboProxy::HideChoiceList
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 EXPORT_C void CSwtComboProxy::HideChoiceList()
       
    67 {
       
    68     iDelegate->HideChoiceList();
       
    69 }
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // CSwtComboProxy::SetSelectedIndex
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C void CSwtComboProxy::SetSelectedIndex(const TInt aIndex)
       
    76 {
       
    77     iDelegate->SetSelectedIndex(aIndex);
       
    78 }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // CSwtComboProxy::SelectedIndex
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 EXPORT_C TInt CSwtComboProxy::SelectedIndex() const
       
    85 {
       
    86     return iDelegate->SelectedIndex();
       
    87 }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CSwtComboProxy::SetItems
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 EXPORT_C void CSwtComboProxy::SetItems(CDesCArray* aArray)
       
    94 {
       
    95     iDelegate->SetItems(aArray);
       
    96 }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CSwtComboProxy::AddItemL
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 EXPORT_C TInt CSwtComboProxy::AddItemL(const TDesC* aDesC)
       
   103 {
       
   104     return iDelegate->AddItemL(aDesC);
       
   105 }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CSwtComboProxy::RemoveItem
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 EXPORT_C void CSwtComboProxy::RemoveItem(const TInt aIndex)
       
   112 {
       
   113     iDelegate->RemoveItem(aIndex);
       
   114 }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // CSwtComboProxy::SetFlags
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 EXPORT_C void CSwtComboProxy::SetFlags(const TInt aFlags)
       
   121 {
       
   122     iDelegate->SetFlags(aFlags);
       
   123 }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // CSwtComboProxy::Flags
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 EXPORT_C TInt CSwtComboProxy::Flags() const
       
   130 {
       
   131     return iDelegate->Flags();
       
   132 }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // CSwtComboProxy::CountComponentControls
       
   136 // From CCoeControl
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 EXPORT_C TInt CSwtComboProxy::CountComponentControls() const
       
   140 {
       
   141     return KSwtAknComboCtrlsCount;
       
   142 }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // CSwtComboProxy::ComponentControl
       
   146 // From CCoeControl
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 EXPORT_C CCoeControl* CSwtComboProxy::ComponentControl(TInt /*aIdx*/) const
       
   150 {
       
   151     return iDelegate;
       
   152 }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // CSwtComboProxy::MinimumSize
       
   156 // From CCoeControl
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C TSize CSwtComboProxy::MinimumSize()
       
   160 {
       
   161     return iDelegate->MinimumSize();
       
   162 }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // CSwtComboProxy::SetBackground
       
   166 // From CCoeControl
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 EXPORT_C void CSwtComboProxy::SetBackground(const MCoeControlBackground* aBackground)
       
   170 {
       
   171     iDelegate->SetBackground(aBackground);
       
   172 }
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // CSwtComboProxy::IsFocused
       
   176 // From CCoeControl
       
   177 // ---------------------------------------------------------------------------
       
   178 //
       
   179 EXPORT_C TBool CSwtComboProxy::IsFocused() const
       
   180 {
       
   181     return iDelegate->IsFocused();
       
   182 }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // CSwtComboProxy::IsFocused
       
   186 // From CCoeControl
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C void CSwtComboProxy::SetFocus(TBool aFocus, TDrawNow aDrawNow /*=ENoDrawNow*/)
       
   190 {
       
   191     iDelegate->SetFocus(aFocus, aDrawNow);
       
   192 }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // CSwtComboProxy::HandleResourceChange
       
   196 // From CCoeControl
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 EXPORT_C void CSwtComboProxy::HandleResourceChange(TInt aType)
       
   200 {
       
   201     iDelegate->HandleResourceChange(aType);
       
   202 }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // CSwtComboProxy::SizeChanged
       
   206 // From CCoeControl
       
   207 // ---------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C void CSwtComboProxy::SizeChanged()
       
   210 {
       
   211     iDelegate->SetRect(Rect());
       
   212 }
       
   213 
       
   214 // ---------------------------------------------------------------------------
       
   215 // CSwtComboProxy::HandleControlEventL
       
   216 // From MCoeControlObserver
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 EXPORT_C void CSwtComboProxy::HandleControlEventL(CCoeControl* aControl,
       
   220         TCoeEvent aEventType)
       
   221 {
       
   222     if (aControl == iDelegate)
       
   223     {
       
   224         if (Observer())
       
   225         {
       
   226             Observer()->HandleControlEventL(this, aEventType);
       
   227         }
       
   228     }
       
   229 }
       
   230 
       
   231 // ---------------------------------------------------------------------------
       
   232 // CSwtComboProxy::CSwtComboProxy
       
   233 // ---------------------------------------------------------------------------
       
   234 //
       
   235 CSwtComboProxy::CSwtComboProxy()
       
   236         : CAknControl()
       
   237 {
       
   238 }
       
   239 
       
   240 // ---------------------------------------------------------------------------
       
   241 // CSwtComboProxy::ConstructL
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 void CSwtComboProxy::ConstructL(CCoeControl* aParent, CDesCArray* aItemArray)
       
   245 {
       
   246     if (!aParent)
       
   247     {
       
   248         User::Leave(KErrArgument);
       
   249     }
       
   250 
       
   251     SetContainerWindowL(*aParent);
       
   252 
       
   253     iDelegate = CAknChoiceList::NewL(aParent, aItemArray);
       
   254     iDelegate->SetContainerWindowL(*this);
       
   255     iDelegate->SetObserver(this);
       
   256 
       
   257     SetComponentsToInheritVisibility(ETrue);
       
   258 }