|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent - Internal Symbian test code |
|
19 */ |
|
20 |
|
21 #include <bautils.h> |
|
22 #include <eikenv.h> |
|
23 #include <eikapp.h> |
|
24 #include <eikdoc.h> |
|
25 |
|
26 #include "tvwappui.H" |
|
27 |
|
28 // |
|
29 // Constants. |
|
30 // |
|
31 |
|
32 const TInt KAppViewArrayGranularity=5; |
|
33 |
|
34 |
|
35 // |
|
36 // CTestVwAppUi. |
|
37 // |
|
38 |
|
39 CTestVwAppUi::CTestVwAppUi() |
|
40 :iAppViewArray(KAppViewArrayGranularity) |
|
41 { |
|
42 } |
|
43 |
|
44 CTestVwAppUi::~CTestVwAppUi() |
|
45 { |
|
46 const TInt numViews=iAppViewArray.Count(); |
|
47 for (TInt ii=numViews-1;ii>=0;--ii) |
|
48 { |
|
49 CTestVwAppView* thisView=iAppViewArray[ii]; |
|
50 DeregisterViewAndRemoveStack(*thisView); |
|
51 iAppViewArray.Delete(ii); |
|
52 delete thisView; |
|
53 } |
|
54 } |
|
55 |
|
56 void CTestVwAppUi::ConstructL() |
|
57 { |
|
58 CEikAppUi::ConstructL(); |
|
59 } |
|
60 |
|
61 void CTestVwAppUi::ActivateViewL(const TVwsViewId& aViewId,TUid aCustomMessageId,const TDesC16& aCustomMessage) |
|
62 { |
|
63 HBufC8* narrowMessage=HBufC8::NewLC(aCustomMessage.Size()); |
|
64 TPtr8 ptr=narrowMessage->Des(); |
|
65 ptr.Copy((TUint8*)aCustomMessage.Ptr(),aCustomMessage.Size()); |
|
66 |
|
67 CCoeAppUi::ActivateViewL(aViewId,aCustomMessageId,*narrowMessage); |
|
68 CleanupStack::PopAndDestroy(); // narrowMessage. |
|
69 } |
|
70 |
|
71 void CTestVwAppUi::AddViewL(CTestVwAppView* aView) |
|
72 { |
|
73 ASSERT(aView); |
|
74 iAppViewArray.AppendL(aView); |
|
75 TRAPD(err,RegisterViewAndAddStackL(*aView)); |
|
76 if (err) |
|
77 { |
|
78 iAppViewArray.Delete(AppViewIndex(aView)); |
|
79 User::Leave(err); |
|
80 } |
|
81 } |
|
82 |
|
83 void CTestVwAppUi::DeleteView(const TVwsViewId& aViewId) |
|
84 { |
|
85 const TInt viewIndex=AppViewIndex(aViewId); |
|
86 ASSERT(viewIndex!=KErrNotFound); |
|
87 CTestVwAppView* view=iAppViewArray[viewIndex]; |
|
88 DeregisterViewAndRemoveStack(*view); |
|
89 delete view; |
|
90 iAppViewArray.Delete(viewIndex); |
|
91 } |
|
92 |
|
93 CTestVwAppView* CTestVwAppUi::View(const TVwsViewId& aViewId) const |
|
94 { |
|
95 ASSERT(AppViewIndex(aViewId)!=KErrNotFound); |
|
96 return iAppViewArray[AppViewIndex(aViewId)]; |
|
97 } |
|
98 |
|
99 CTestVwAppView* CTestVwAppUi::ActiveView() const |
|
100 { |
|
101 TVwsViewId activeViewId; |
|
102 if (GetActiveViewId(activeViewId)==KErrNone) |
|
103 { |
|
104 return iAppViewArray[AppViewIndex(activeViewId)]; |
|
105 } |
|
106 |
|
107 return NULL; |
|
108 } |
|
109 |
|
110 void CTestVwAppUi::HandleModelChangeL() |
|
111 { |
|
112 CTestVwAppView* activeView=ActiveView(); |
|
113 if (activeView) |
|
114 { |
|
115 activeView->HandleModelChangeL(); |
|
116 } |
|
117 } |
|
118 |
|
119 TInt CTestVwAppUi::AppViewIndex(const TVwsViewId& aViewId) const |
|
120 { |
|
121 const TInt numAppViews=iAppViewArray.Count(); |
|
122 |
|
123 for (TInt ii=0;ii<numAppViews;ii++) |
|
124 { |
|
125 if (iAppViewArray[ii]->ViewId()==aViewId) |
|
126 return ii; |
|
127 } |
|
128 |
|
129 return KErrNotFound; |
|
130 } |
|
131 |
|
132 TInt CTestVwAppUi::AppViewIndex(CTestVwAppView* aView) const |
|
133 { |
|
134 TInt pos; |
|
135 TKeyArrayFix key(0,ECmpTInt); |
|
136 |
|
137 if (iAppViewArray.Find(aView,key,pos)==KErrNone) |
|
138 { |
|
139 return pos; |
|
140 } |
|
141 |
|
142 return KErrNotFound; |
|
143 } |
|
144 |