|
1 /* |
|
2 * Copyright (c) 2002 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 * Container for main view. |
|
16 * Derived from CMceMainViewListContainer. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <aknlists.h> |
|
24 #include <msvids.h> |
|
25 |
|
26 #include <bldvariant.hrh> |
|
27 |
|
28 |
|
29 #include <mce.rsg> |
|
30 #include "MceMainViewListContainer.h" |
|
31 #include "MceMainViewListItemArray.h" |
|
32 #include "MceIds.hrh" |
|
33 #include "MceIds.h" |
|
34 |
|
35 #include <csxhelp/mce.hlp.hrh> |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 |
|
43 CMceMainViewListContainer::CMceMainViewListContainer() |
|
44 : iListBox( NULL ), |
|
45 iListItems( NULL ) |
|
46 { |
|
47 } |
|
48 |
|
49 CMceMainViewListContainer::~CMceMainViewListContainer() |
|
50 { |
|
51 delete iListBox; |
|
52 delete iListItems; |
|
53 } |
|
54 |
|
55 CMceMainViewListContainer* CMceMainViewListContainer::NewL( |
|
56 const TRect& aRect, |
|
57 //TODO: |
|
58 TMsvId /*aFolderId*/, |
|
59 //TODO |
|
60 TMceListType /*aListType*/ ) |
|
61 { |
|
62 CMceMainViewListContainer* self = new (ELeave) |
|
63 CMceMainViewListContainer(); |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL( aRect ); |
|
66 CleanupStack::Pop(); // self |
|
67 return self; |
|
68 } |
|
69 |
|
70 // ---------------------------------------------------- |
|
71 // CMceMainViewListContainer::CreateListItemsL |
|
72 // ---------------------------------------------------- |
|
73 void CMceMainViewListContainer::CreateListItemsL( |
|
74 CMsvSessionPtr aSession, |
|
75 CMceBitmapResolver& aBitmapResolver ) |
|
76 { |
|
77 if ( iListBox && !iListItems ) |
|
78 { |
|
79 iListItems = CMceMainViewListItemArray::NewL( |
|
80 aSession, KMsvRootIndexEntryId, |
|
81 EMceListTypeMainView, aBitmapResolver ); |
|
82 iListBox->Model()->SetItemTextArray( iListItems ); |
|
83 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
84 } |
|
85 } |
|
86 |
|
87 |
|
88 // ---------------------------------------------------- |
|
89 // CMceMainViewListContainer::GetHelpContext |
|
90 // returns helpcontext as aContext |
|
91 // ---------------------------------------------------- |
|
92 void CMceMainViewListContainer::GetHelpContext |
|
93 (TCoeHelpContext& aContext) const |
|
94 { |
|
95 aContext.iMajor = KMceApplicationUid; |
|
96 aContext.iContext = KMCE_HLP_MESSAGING; |
|
97 } |
|
98 |
|
99 void CMceMainViewListContainer::ConstructL( |
|
100 const TRect& aRect ) |
|
101 { |
|
102 CreateWindowL(); |
|
103 SetRect( aRect ); |
|
104 |
|
105 iListBox = new (ELeave) CAknDoubleLargeStyleListBox ; |
|
106 // CEikTextListBox* listBox = new (ELeave) CAknSingleLargeStyleListBox; |
|
107 iListBox->ConstructL( this, EAknListBoxSelectionList ); |
|
108 |
|
109 |
|
110 //iSelectedEntries = new (ELeave) CMsvEntrySelection; |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------- |
|
114 // CMceMainViewListContainer::CountComponentControls |
|
115 // ---------------------------------------------------- |
|
116 TInt CMceMainViewListContainer::CountComponentControls() const |
|
117 { |
|
118 return 1; // always only listbox |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------- |
|
122 // CMceMainViewListContainer::ComponentControl |
|
123 // ---------------------------------------------------- |
|
124 CCoeControl* CMceMainViewListContainer::ComponentControl(TInt /*aIndex*/) const |
|
125 { |
|
126 return iListBox; |
|
127 } |
|
128 |
|
129 // ---------------------------------------------------- |
|
130 // CMceMainViewListContainer::OfferKeyEventL |
|
131 // ---------------------------------------------------- |
|
132 TKeyResponse CMceMainViewListContainer::OfferKeyEventL( |
|
133 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
134 { |
|
135 if ( aType == EEventKeyUp) |
|
136 { |
|
137 SetMskL(); |
|
138 } |
|
139 if ( iListBox ) |
|
140 { |
|
141 return iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
142 } |
|
143 else |
|
144 { |
|
145 return EKeyWasConsumed; |
|
146 } |
|
147 } |
|
148 |
|
149 // ---------------------------------------------------- |
|
150 // CMceMainViewListContainer::SizeChanged |
|
151 // ---------------------------------------------------- |
|
152 void CMceMainViewListContainer::SizeChanged() |
|
153 { |
|
154 if (iListBox) |
|
155 { |
|
156 iListBox->SetRect( Rect() ); |
|
157 } |
|
158 } |
|
159 |
|
160 |
|
161 // ---------------------------------------------------- |
|
162 // CMceMainViewListContainer::CurrentItemIndex |
|
163 // ---------------------------------------------------- |
|
164 TInt CMceMainViewListContainer::CurrentItemIndex() const |
|
165 { |
|
166 return iListBox->CurrentItemIndex(); |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------- |
|
170 // CMceMainViewListContainer::CurrentItemId |
|
171 // ---------------------------------------------------- |
|
172 TMsvId CMceMainViewListContainer::CurrentItemId() const |
|
173 { |
|
174 return iListItems->ItemId( CurrentItemIndex() ); |
|
175 } |
|
176 |
|
177 // ---------------------------------------------------- |
|
178 // CMceMainViewListContainer::CurrentItemListItem |
|
179 // ---------------------------------------------------- |
|
180 TMceListItem CMceMainViewListContainer::CurrentItemListItem() const |
|
181 { |
|
182 return iListItems->Item( CurrentItemIndex() ); |
|
183 } |
|
184 |
|
185 // ---------------------------------------------------- |
|
186 // CMceMainViewListContainer::ItemIndex |
|
187 // ---------------------------------------------------- |
|
188 TInt CMceMainViewListContainer::ItemIndex( TMsvId aId ) const |
|
189 { |
|
190 return iListItems->ItemIndex( aId ); |
|
191 } |
|
192 |
|
193 // ---------------------------------------------------- |
|
194 // CMceMainViewListContainer::FocusChanged |
|
195 // ---------------------------------------------------- |
|
196 void CMceMainViewListContainer::FocusChanged(TDrawNow /*aDrawNow*/) |
|
197 { |
|
198 if (iListBox) |
|
199 { |
|
200 iListBox->SetFocus(IsFocused()); |
|
201 } |
|
202 } |
|
203 |
|
204 // ---------------------------------------------------- |
|
205 // CMceMainViewListContainer::SetMskL |
|
206 // ---------------------------------------------------- |
|
207 void CMceMainViewListContainer::SetMskL() |
|
208 { |
|
209 TInt currentItem = CurrentItemIndex(); |
|
210 TInt resourceId = R_MCE_MSK_BUTTON_OPEN; |
|
211 |
|
212 if ( currentItem == ListItems()->ExtraItemIndex( KMceWriteMessageListIdValue ) ) |
|
213 { |
|
214 resourceId = R_MCE_MSK_BUTTON_SELECT; |
|
215 } |
|
216 |
|
217 if ( resourceId != iCurrMskResource ) |
|
218 { |
|
219 iCurrMskResource = resourceId; |
|
220 CEikButtonGroupContainer* cba; |
|
221 cba = CEikButtonGroupContainer::Current(); |
|
222 if ( cba ) |
|
223 { |
|
224 const TInt KMSKPosition = 3; |
|
225 cba->SetCommandL( KMSKPosition, iCurrMskResource ); |
|
226 cba->DrawDeferred(); |
|
227 } |
|
228 } |
|
229 } |
|
230 |
|
231 |
|
232 |
|
233 // End of File |