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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "MemSpyContainer.h" |
|
19 |
|
20 // System includes |
|
21 #include <eikrted.h> // for example label control |
|
22 #include <txtrich.h> |
|
23 #include <apgtask.h> |
|
24 |
|
25 // Engine includes |
|
26 #include <memspy/engine/memspyengine.h> |
|
27 #include <memspy/engine/memspyengineobjectprocess.h> |
|
28 #include <memspy/engine/memspyengineobjectthread.h> |
|
29 #include <memspy/engine/memspyengineobjectcontainer.h> |
|
30 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h> |
|
31 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h> |
|
32 |
|
33 // User includes |
|
34 #include "MemSpyViewMainMenu.h" |
|
35 #include "MemSpyContainerObserver.h" |
|
36 |
|
37 |
|
38 |
|
39 /* |
|
40 CMemSpyContainer::CMemSpyContainer( CMemSpyEngine& aEngine, MMemSpyContainerObserver& aObserver ) |
|
41 : iEngine( aEngine ), iObserver( aObserver ) |
|
42 { |
|
43 } |
|
44 */ |
|
45 CMemSpyContainer::CMemSpyContainer( RMemSpySession& aSession, MMemSpyContainerObserver& aObserver ) |
|
46 : iMemSpySession( aSession ), iObserver( aObserver ) |
|
47 { |
|
48 } |
|
49 |
|
50 CMemSpyContainer::~CMemSpyContainer() |
|
51 { |
|
52 delete iPreviousView; |
|
53 delete iActiveView; |
|
54 } |
|
55 |
|
56 |
|
57 void CMemSpyContainer::ConstructL(const TRect& aRect) |
|
58 { |
|
59 CreateWindowL(); |
|
60 SetRect(aRect); |
|
61 PrepareTopLevelViewL(); |
|
62 ActivateL(); |
|
63 } |
|
64 |
|
65 |
|
66 void CMemSpyContainer::NavigateToParentViewL() |
|
67 { |
|
68 CMemSpyViewBase* parentView = iActiveView->PrepareParentViewL(); |
|
69 // |
|
70 if ( parentView == NULL ) |
|
71 { |
|
72 // Parent can be null, in which case, revert to top-level view |
|
73 PrepareTopLevelViewL(); |
|
74 } |
|
75 else |
|
76 { |
|
77 SetNewActiveViewL( parentView ); |
|
78 } |
|
79 } |
|
80 |
|
81 |
|
82 void CMemSpyContainer::NavigateToChildViewL() |
|
83 { |
|
84 CMemSpyViewBase* childView = iActiveView->PrepareChildViewL(); |
|
85 // |
|
86 if ( childView != NULL ) |
|
87 { |
|
88 SetNewActiveViewL( childView ); |
|
89 } |
|
90 } |
|
91 |
|
92 |
|
93 void CMemSpyContainer::HandleCommandL( TInt aCommand ) |
|
94 { |
|
95 switch( aCommand ) |
|
96 { |
|
97 case EMemSpyCmdViewRefresh: |
|
98 OnCmdViewRefreshL(); |
|
99 break; |
|
100 default: |
|
101 if ( iActiveView ) |
|
102 { |
|
103 iActiveView->HandleCommandL( aCommand ); |
|
104 } |
|
105 break; |
|
106 } |
|
107 } |
|
108 |
|
109 |
|
110 void CMemSpyContainer::OnCmdViewRefreshL() |
|
111 { |
|
112 if ( iActiveView ) |
|
113 { |
|
114 TRAPD(err, iActiveView->RefreshL()); |
|
115 if ( err != KErrNone ) |
|
116 { |
|
117 // Error during view refreshing (perhaps the thread doesn't exist anymore). |
|
118 // Try to replace the active view with its parent... |
|
119 NavigateToParentViewL(); |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 |
|
125 void CMemSpyContainer::SizeChanged() |
|
126 { |
|
127 if ( iActiveView ) |
|
128 { |
|
129 iActiveView->SetRect( Rect() ); |
|
130 } |
|
131 } |
|
132 |
|
133 |
|
134 TInt CMemSpyContainer::CountComponentControls() const |
|
135 { |
|
136 return 1; |
|
137 } |
|
138 |
|
139 |
|
140 CCoeControl* CMemSpyContainer::ComponentControl(TInt /*aIndex*/) const |
|
141 { |
|
142 return iActiveView; |
|
143 } |
|
144 |
|
145 |
|
146 void CMemSpyContainer::Draw(const TRect& aRect) const |
|
147 { |
|
148 CWindowGc& gc = SystemGc(); |
|
149 // |
|
150 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
151 gc.SetBrushColor(KRgbGray); |
|
152 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
153 gc.DrawRect(aRect); |
|
154 } |
|
155 |
|
156 |
|
157 TKeyResponse CMemSpyContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
158 { |
|
159 TKeyResponse response = EKeyWasNotConsumed; |
|
160 // |
|
161 if ( iActiveView ) |
|
162 { |
|
163 response = iActiveView->OfferKeyEventL( aKeyEvent, aType ); |
|
164 } |
|
165 // |
|
166 return response; |
|
167 } |
|
168 |
|
169 |
|
170 void CMemSpyContainer::HandleMemSpyViewEventL( TViewEventType aEvent, TMemSpyViewType /*aViewType*/, CMemSpyViewBase& aReportingView, TAny* /*aContext*/ ) |
|
171 { |
|
172 if ( aEvent == EEventItemActioned ) |
|
173 { |
|
174 // Get the view to generate a child |
|
175 CMemSpyViewBase* child = aReportingView.PrepareChildViewL(); |
|
176 if ( child == NULL ) |
|
177 { |
|
178 // View doesn't have a child - treat it as item activation and |
|
179 // report event to observer. |
|
180 |
|
181 } |
|
182 else |
|
183 { |
|
184 // Child view becomes the active one |
|
185 SetNewActiveViewL( child ); |
|
186 } |
|
187 } |
|
188 } |
|
189 |
|
190 |
|
191 CMemSpyViewBase* CMemSpyContainer::PrepareTopLevelViewL() |
|
192 { |
|
193 //CMemSpyViewMainMenu* view = new(ELeave) CMemSpyViewMainMenu( iEngine, *this ); |
|
194 CMemSpyViewMainMenu* view = new(ELeave) CMemSpyViewMainMenu( iMemSpySession, *this ); |
|
195 CleanupStack::PushL( view ); |
|
196 view->ConstructL( Rect(), *this ); |
|
197 SetNewActiveViewL( view ); |
|
198 CleanupStack::Pop( view ); |
|
199 return view; |
|
200 } |
|
201 |
|
202 |
|
203 void CMemSpyContainer::SetNewActiveViewL( CMemSpyViewBase* aNewView ) |
|
204 { |
|
205 delete iPreviousView; |
|
206 // |
|
207 iPreviousView = iActiveView; |
|
208 if ( iPreviousView ) |
|
209 { |
|
210 iPreviousView->MakeVisible( EFalse ); |
|
211 iPreviousView->SetFocus( EFalse ); |
|
212 } |
|
213 // |
|
214 iActiveView = aNewView; |
|
215 iActiveView->RefreshL(); |
|
216 iActiveView->SetFocus( ETrue ); |
|
217 // |
|
218 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
|
219 } |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|