|
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 class for bio controls |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "MsgBioBodyControl.h" // for CMsgBioBodyControl |
|
24 #include "MsgBioControlFactory.h" // for MMsgBioControlFactory |
|
25 #include "MsgEditorUtils.pan" // for MsgEditorUtils panics |
|
26 #include <MsgBaseControlObserver.h> // for MMsgBaseControlObserver |
|
27 #include <s32file.h> // for CFileStore |
|
28 #include <msvapi.h> // MTM server API |
|
29 #include <eikmenup.h> |
|
30 #include "msgbiocontrol.h" // for CMsgBioControl |
|
31 #include <msvapi.h> // CMsvSession |
|
32 #include "MsgEditorUtilsLog.h" |
|
33 |
|
34 // EXTERNAL DATA STRUCTURES |
|
35 // EXTERNAL FUNCTION PROTOTYPES |
|
36 // CONSTANTS |
|
37 // MACROS |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 |
|
41 const TInt KControlIdBioControl = 0; |
|
42 const TInt KNumberOfControls = 1; |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 // LOCAL FUNCTION PROTOTYPES |
|
46 // ==================== LOCAL FUNCTIONS ==================== |
|
47 |
|
48 |
|
49 // ================= MEMBER FUNCTIONS ======================= |
|
50 |
|
51 EXPORT_C CMsgBioBodyControl::~CMsgBioBodyControl() |
|
52 { |
|
53 delete iBioControl; |
|
54 delete iBioControlFactory; |
|
55 } |
|
56 |
|
57 EXPORT_C CMsgBioBodyControl* CMsgBioBodyControl::NewL( |
|
58 MMsgBioControlObserver& aBioControlObserver, |
|
59 const TUid& aBioMsgType, // Bio message type id |
|
60 TMsvId aId, |
|
61 TMsgBioMode aEditorOrViewerMode, |
|
62 CMsvSession& aSession) |
|
63 { |
|
64 LOG("CMsgBioBodyControl::NewL begin"); |
|
65 CMsgBioBodyControl* self = new(ELeave) CMsgBioBodyControl(aSession); |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(aBioControlObserver, aBioMsgType, aId, |
|
68 aEditorOrViewerMode); |
|
69 CleanupStack::Pop(self); |
|
70 LOG("CMsgBioBodyControl::NewL end"); |
|
71 return self; |
|
72 } |
|
73 |
|
74 void CMsgBioBodyControl::ConstructL( |
|
75 MMsgBioControlObserver& aBioControlObserver, |
|
76 const TUid& aBioMsgType, |
|
77 TMsvId aId, |
|
78 TMsgBioMode aEditorOrViewerMode) |
|
79 { |
|
80 LOG("CMsgBioBodyControl::ConstructL begin"); |
|
81 iControlType = EMsgBodyControl; |
|
82 |
|
83 iBioControlFactory = CMsgBioControlFactory::NewL(); |
|
84 iBioControl = iBioControlFactory->CreateControlL( |
|
85 aBioControlObserver, |
|
86 aBioMsgType, |
|
87 aEditorOrViewerMode, |
|
88 aId, |
|
89 &iSession); |
|
90 iBioControl->SetBioBodyControl( this ); |
|
91 LOG("CMsgBioBodyControl::ConstructL end"); |
|
92 } |
|
93 |
|
94 CMsgBioBodyControl::CMsgBioBodyControl(CMsvSession& aSession) : iSession(aSession) |
|
95 { |
|
96 } |
|
97 |
|
98 EXPORT_C TBool CMsgBioBodyControl::HandleBioCommandL(TInt aCommand) |
|
99 { |
|
100 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
101 |
|
102 return iBioControl->HandleBioCommandL(aCommand); |
|
103 } |
|
104 |
|
105 EXPORT_C HBufC* CMsgBioBodyControl::HeaderTextL(void) const |
|
106 { |
|
107 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
108 return iBioControl->HeaderTextL(); |
|
109 } |
|
110 |
|
111 EXPORT_C TRect CMsgBioBodyControl::CurrentLineRect() //virtual |
|
112 { |
|
113 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
114 TRect lineRect = iBioControl->CurrentLineRect(); |
|
115 lineRect.iTl.iX = Rect().iTl.iX; |
|
116 lineRect.iBr.iX = Rect().iBr.iX; |
|
117 |
|
118 //This is a translation to screen origin coordinates. |
|
119 lineRect.Move(TPoint(0, Position().iY)); |
|
120 |
|
121 return lineRect; |
|
122 } |
|
123 |
|
124 EXPORT_C void CMsgBioBodyControl::SetAndGetSizeL(TSize& aSize) |
|
125 { |
|
126 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
127 if (iBioControl->IsFileBased()) |
|
128 { |
|
129 iBioControl->SetSize(aSize); //from CCoeControl |
|
130 } |
|
131 else |
|
132 { |
|
133 iBioControl->SetAndGetSizeL(aSize); |
|
134 } |
|
135 SetSizeWithoutNotification(aSize); |
|
136 } |
|
137 |
|
138 //This is from CMsgBaseControl. |
|
139 EXPORT_C void CMsgBioBodyControl::ClipboardL(TMsgClipboardFunc /*aFunc*/) |
|
140 { |
|
141 } |
|
142 |
|
143 //This is from CMsgBaseControl. |
|
144 EXPORT_C void CMsgBioBodyControl::EditL(TMsgEditFunc /*aFunc*/) |
|
145 { |
|
146 } |
|
147 |
|
148 EXPORT_C TUint32 CMsgBioBodyControl::EditPermission() const |
|
149 { |
|
150 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
151 TUint32 editPerm(EMsgEditNone); |
|
152 TUint32 bioPerm(0); |
|
153 // Implementations should not leave but if it happens ignore. |
|
154 TRAP_IGNORE(bioPerm = iBioControl->OptionMenuPermissionsL()); |
|
155 if ( bioPerm & EMsgBioEditText) |
|
156 { |
|
157 editPerm |= EMsgEditCut; |
|
158 editPerm |= EMsgEditCopy; |
|
159 editPerm |= EMsgEditPaste; |
|
160 editPerm |= EMsgEditUndo; |
|
161 } |
|
162 return editPerm; |
|
163 } |
|
164 |
|
165 EXPORT_C TBool CMsgBioBodyControl::IsFocusChangePossible(TMsgFocusDirection aDirection) const |
|
166 { |
|
167 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
168 return iBioControl->IsFocusChangePossible(aDirection); |
|
169 } |
|
170 |
|
171 EXPORT_C TBool CMsgBioBodyControl::IsCursorLocation(TMsgCursorLocation aLocation) const |
|
172 { |
|
173 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
174 return iBioControl->IsCursorLocation(aLocation); |
|
175 } |
|
176 |
|
177 EXPORT_C TInt CMsgBioBodyControl::VirtualHeight() |
|
178 { |
|
179 return iBioControl->VirtualHeight(); |
|
180 } |
|
181 |
|
182 EXPORT_C TInt CMsgBioBodyControl::VirtualVisibleTop() |
|
183 { |
|
184 return iBioControl->VirtualVisibleTop(); |
|
185 } |
|
186 |
|
187 TKeyResponse CMsgBioBodyControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) //virtual |
|
188 { |
|
189 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
190 |
|
191 return iBioControl->OfferKeyEventL(aKeyEvent, aType); |
|
192 } |
|
193 |
|
194 EXPORT_C TBool CMsgBioBodyControl::HandleBaseControlEventRequestL( |
|
195 TMsgBioControlEventRequest aRequest, |
|
196 TInt aDelta) |
|
197 { |
|
198 TMsgControlEventRequest controlEvent; |
|
199 |
|
200 switch ( aRequest ) |
|
201 { |
|
202 case EMsgBioUpdateScrollBars: |
|
203 { |
|
204 controlEvent = EMsgEnsureCorrectFormPosition; |
|
205 break; |
|
206 } |
|
207 default: |
|
208 { |
|
209 controlEvent = EMsgEnsureCorrectFormPosition; |
|
210 break; |
|
211 } |
|
212 } |
|
213 |
|
214 return iBaseControlObserver->HandleBaseControlEventRequestL( |
|
215 this, controlEvent, aDelta); |
|
216 |
|
217 } |
|
218 |
|
219 // from CMsgBaseControl |
|
220 void CMsgBioBodyControl::PrepareForReadOnly(TBool /*aReadOnly*/) |
|
221 { |
|
222 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
223 } |
|
224 |
|
225 TInt CMsgBioBodyControl::CountComponentControls() const |
|
226 { |
|
227 return KNumberOfControls; |
|
228 } |
|
229 |
|
230 CCoeControl* CMsgBioBodyControl::ComponentControl(TInt aIndex) const |
|
231 { |
|
232 __ASSERT_DEBUG(aIndex == KControlIdBioControl, Panic(EMEUIncorrectComponentIndex)); |
|
233 if (aIndex == KControlIdBioControl) |
|
234 { |
|
235 return iBioControl; |
|
236 } |
|
237 return NULL; |
|
238 } |
|
239 |
|
240 void CMsgBioBodyControl::SizeChanged() |
|
241 { |
|
242 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
243 |
|
244 iBioControl->SetExtent(Position(), iBioControl->Size()); |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------- |
|
248 // The menu doesn't need to be restored when the focus |
|
249 // goes outside the body. Double check! |
|
250 // --------------------------------------------------------- |
|
251 // |
|
252 void CMsgBioBodyControl::FocusChanged(TDrawNow /*aDrawNow*/) |
|
253 { |
|
254 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
255 |
|
256 if (!iBioControl->IsNonFocusing()) |
|
257 { |
|
258 iBioControl->SetFocus(IsFocused()); |
|
259 } |
|
260 } |
|
261 |
|
262 void CMsgBioBodyControl::SetContainerWindowL(const CCoeControl& aContainer) //virtual |
|
263 { |
|
264 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
265 |
|
266 CCoeControl::SetContainerWindowL(aContainer); |
|
267 iBioControl->SetContainerWindowL(aContainer); |
|
268 } |
|
269 |
|
270 EXPORT_C void CMsgBioBodyControl::SetMenuCommandSetL(CEikMenuPane& aMenuPane) |
|
271 { |
|
272 iBioControl->SetMenuCommandSetL(aMenuPane); |
|
273 } |
|
274 |
|
275 EXPORT_C CMsgBioControl& CMsgBioBodyControl::BioControl(void) |
|
276 { |
|
277 __ASSERT_DEBUG(iBioControl, Panic(EMEUBioControlNotExist)); |
|
278 return *iBioControl; |
|
279 } |
|
280 |
|
281 #ifdef RD_SCALABLE_UI_V2 |
|
282 EXPORT_C TInt CMsgBioBodyControl::ScrollL( TInt aPixelsToScroll, |
|
283 TMsgScrollDirection aDirection ) |
|
284 { |
|
285 return iBioControl->ScrollL( aPixelsToScroll, aDirection ); |
|
286 } |
|
287 |
|
288 EXPORT_C void CMsgBioBodyControl::NotifyViewEvent( TMsgViewEvent aEvent, |
|
289 TInt aParam ) |
|
290 { |
|
291 iBioControl->NotifyViewEvent( aEvent, aParam ); |
|
292 } |
|
293 #else |
|
294 EXPORT_C TInt CMsgBioBodyControl::ScrollL( TInt /*aPixelsToScroll*/, |
|
295 TMsgScrollDirection /*aDirection*/ ) |
|
296 { |
|
297 return 0; |
|
298 } |
|
299 |
|
300 EXPORT_C void CMsgBioBodyControl::NotifyViewEvent( TMsgViewEvent /*aEvent*/, TInt /*aParam*/ ) |
|
301 { |
|
302 //no op |
|
303 } |
|
304 #endif //RD_SCALABLE_UI_V2 |
|
305 |
|
306 // End of File |