|
1 /* |
|
2 * Copyright (c) 2002-2005 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: page manager,which is used by drop down list |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "peninputpages.h" |
|
20 |
|
21 // ======== MEMBER FUNCTIONS ======== |
|
22 |
|
23 // Implementation of Class CPages |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CPages::NewL |
|
27 // factory function |
|
28 // (other items were commented in a header). |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CPages* CPages::NewL() |
|
32 { |
|
33 CPages* self = new (ELeave) CPages(); |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL(); |
|
36 CleanupStack::Pop(); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CPages::~CPages |
|
42 // factory function |
|
43 // (other items were commented in a header). |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CPages::~CPages() |
|
47 { |
|
48 iFirstIndexList.Close(); |
|
49 iLastIndexList.Close(); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CPages::NewL |
|
54 // 2nd construct function |
|
55 // (other items were commented in a header). |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CPages::ConstructL() |
|
59 { |
|
60 Reset(); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CPages::Reset |
|
65 // reset page in the page list |
|
66 // (other items were commented in a header). |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CPages::Reset() |
|
70 { |
|
71 iFirstIndexList.Reset(); |
|
72 iLastIndexList.Reset(); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CPages::PageCount |
|
77 // get page count |
|
78 // (other items were commented in a header). |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 TInt CPages::PageCount() const |
|
82 { |
|
83 return iLastIndexList.Count(); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CPages::AddPage |
|
88 // add one page into the page list |
|
89 // (other items were commented in a header). |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CPages::AddPage(const TInt aFirstIndex, const TInt aLastIndex) |
|
93 { |
|
94 if ( aFirstIndex == aLastIndex ) |
|
95 { |
|
96 return; |
|
97 } |
|
98 |
|
99 const TInt index = iLastIndexList.Find(aLastIndex); |
|
100 |
|
101 if ( index == KErrNotFound) |
|
102 { |
|
103 iLastIndexList.Append(aLastIndex); |
|
104 iFirstIndexList.Append(aFirstIndex); |
|
105 } |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CPages::GetPreviousIndex |
|
110 // get the previous page |
|
111 // (other items were commented in a header). |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 TBool CPages::GetPreviousIndex(const TInt aLastIndex, |
|
115 TInt& aFirstIndexOfPrevious, |
|
116 TInt& aLastIndexOfPrevious) const |
|
117 { |
|
118 const TInt index = iLastIndexList.Find( aLastIndex ); |
|
119 |
|
120 if ( index != KErrNotFound ) // If found it |
|
121 { |
|
122 if ( index > 0 ) // If not the first page |
|
123 { |
|
124 aFirstIndexOfPrevious = iFirstIndexList[index-1]; |
|
125 aLastIndexOfPrevious = iLastIndexList[index-1]; |
|
126 } |
|
127 else // If is the first page |
|
128 { |
|
129 aFirstIndexOfPrevious = iFirstIndexList[0]; |
|
130 aLastIndexOfPrevious = iLastIndexList[0]; |
|
131 } |
|
132 return ETrue; |
|
133 } |
|
134 else |
|
135 { |
|
136 return EFalse; |
|
137 } |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CPages::GetPageIndexByPos |
|
142 // get the page of assigned position |
|
143 // (other items were commented in a header). |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TBool CPages::GetPageIndexByPos(const TInt aPos, |
|
147 TInt& aFirstIndex, |
|
148 TInt& aLastIndex) const |
|
149 { |
|
150 if ( ( aPos < 0 ) || ( aPos >= iLastIndexList.Count() ) ) |
|
151 { |
|
152 return EFalse; |
|
153 } |
|
154 |
|
155 aLastIndex = iLastIndexList[aPos]; |
|
156 aFirstIndex = iFirstIndexList[aPos]; |
|
157 |
|
158 return ETrue; |
|
159 } |
|
160 |
|
161 // End Of File |