1 /* |
|
2 * Copyright (c) 2009 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 contains CMenuListBox class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "MenuListBox.h" |
|
20 #include <aknview.h> |
|
21 |
|
22 // ================= MEMBER FUNCTIONS ======================= |
|
23 // --------------------------------------------------------- |
|
24 // CMainMenuView::CMenuListBox |
|
25 // |
|
26 // c++ constructor |
|
27 // --------------------------------------------------------- |
|
28 // |
|
29 CMenuListBox::CMenuListBox(TAppUIViewNumber aViewId) |
|
30 : CAknSingleStyleListBox(), iViewId(aViewId) |
|
31 { |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------- |
|
35 // CMenuListBox::ConstructL |
|
36 // |
|
37 // Symbian OS two-phased constructor |
|
38 // --------------------------------------------------------- |
|
39 // |
|
40 void CMenuListBox::ConstructL() |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // CMenuListBox::~CMenuListBox |
|
47 // |
|
48 // Destructor |
|
49 // --------------------------------------------------------- |
|
50 // |
|
51 CMenuListBox::~CMenuListBox() |
|
52 { |
|
53 |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------- |
|
57 // CMenuListBox::NewL |
|
58 // |
|
59 // Symbian OS public constructor |
|
60 // @param aViewId - id of view to identify position in array where focus position will be saved to |
|
61 // or retrieved from |
|
62 // |
|
63 // @return - pointer to an instance of CMenuListBOx |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 CMenuListBox* CMenuListBox::NewL(TAppUIViewNumber aViewId) |
|
67 { |
|
68 CMenuListBox* self = new(ELeave) CMenuListBox(aViewId); |
|
69 CleanupStack::PushL(self); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop(self); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CMenuListBox::SaveFocusPosition |
|
77 // |
|
78 // Saves current focus position to CAppUiAppUi object |
|
79 // --------------------------------------------------------- |
|
80 // |
|
81 void CMenuListBox::SaveFocusPosition() |
|
82 { |
|
83 ((CAppUIAppUi*)iCoeEnv->AppUi())->SaveFocusPosition(iViewId, this->CurrentItemIndex()); |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // CMenuListBox::SetPreviousFocus |
|
88 // |
|
89 // Retrieves previous focus position from CAppUiAppUi object and sets focus |
|
90 // to that position |
|
91 // --------------------------------------------------------- |
|
92 // |
|
93 void CMenuListBox::SetPreviousFocus() |
|
94 { |
|
95 TInt previousPosition = ((CAppUIAppUi*)iCoeEnv->AppUi())->GetFocusPosition(iViewId); |
|
96 if(previousPosition != KErrNotFound) |
|
97 { |
|
98 if(previousPosition < this->Model()->NumberOfItems() && previousPosition != 0) |
|
99 { |
|
100 this->SetCurrentItemIndex(previousPosition); |
|
101 } |
|
102 if(previousPosition >= this->Model()->NumberOfItems()) |
|
103 { |
|
104 this->SetCurrentItemIndex(0); // setting current item to first element if pervious position is grater then current. |
|
105 } |
|
106 this->SetTopItemIndex(0); |
|
107 } |
|
108 } |
|