27
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2006 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: MsgEditorView implementation*
|
|
15 |
*/
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
// ========== INCLUDE FILES ================================
|
|
20 |
|
|
21 |
#include <eikenv.h> // for CEikonEnv
|
|
22 |
#include <eikappui.h> // for CEikAppUi
|
|
23 |
#include <barsread.h> // for TResourceReader
|
|
24 |
#include <eikrted.h> // for CEikRichTextEditor
|
|
25 |
#include <eikscrlb.h>
|
|
26 |
#include <AknUtils.h> // for AknUtils
|
|
27 |
#include <txtrich.h> // for automatic highlight
|
|
28 |
#include <aknappui.h>
|
|
29 |
#include <applayout.cdl.h> // LAF
|
|
30 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
31 |
|
|
32 |
#include <bautils.h> // NearestLanguageFile
|
|
33 |
#include <data_caging_path_literals.hrh>
|
|
34 |
|
|
35 |
#include <aknnavi.h>
|
|
36 |
#include <aknnavide.h>
|
|
37 |
#include <AknStatuspaneUtils.h>
|
|
38 |
|
|
39 |
#include <AknsBasicBackgroundControlContext.h> // for skins support
|
|
40 |
#include <AknsDrawUtils.h>
|
|
41 |
|
|
42 |
#include <MsgEditorAppUi.rsg>
|
|
43 |
#include <StringLoader.h>
|
|
44 |
|
|
45 |
#include "MsgEditorCommon.h" //
|
|
46 |
#include "MsgEditorView.h" // for CMsgEditorView
|
|
47 |
#include "MsgEditorObserver.h" // for MMsgEditorObserver
|
|
48 |
#include "MsgHeader.h" // for CMsgHeader
|
|
49 |
#include "MsgBody.h" // for CMsgBody
|
|
50 |
#include "MsgExpandableControl.h" // for MsgExpandableControl
|
|
51 |
#include "MsgBodyControl.h" // for MsgBodyControl
|
|
52 |
#include "MsgAddressControl.h" // for MsgAddressControl
|
|
53 |
#include "MsgAttachmentControl.h" // for MsgAttachmentControl
|
|
54 |
#include "MsgAddressControlEditor.h" // for MsgAddressControlEditor
|
|
55 |
#include "MsgEditorPanic.h" // for MsgEditor panics
|
|
56 |
#include "MsgEditorLogging.h"
|
|
57 |
|
|
58 |
// ========== EXTERNAL DATA STRUCTURES =====================
|
|
59 |
|
|
60 |
// ========== EXTERNAL FUNCTION PROTOTYPES =================
|
|
61 |
|
|
62 |
// ========== CONSTANTS ====================================
|
|
63 |
|
|
64 |
// ========== MACROS =======================================
|
|
65 |
|
|
66 |
// ========== LOCAL CONSTANTS AND MACROS ===================
|
|
67 |
|
|
68 |
const TInt KMsgControlIndexHeader = 0;
|
|
69 |
const TInt KMsgControlIndexBody = 1;
|
|
70 |
const TInt KMsgNumberOfControls = 2;
|
|
71 |
|
|
72 |
const TInt KMsgMaximumScrollPartLength = 64;
|
|
73 |
_LIT( KMsgEditorAppUiResourceFileName, "msgeditorappui.rsc" );
|
|
74 |
|
|
75 |
// ========== MODULE DATA STRUCTURES =======================
|
|
76 |
|
|
77 |
// ========== LOCAL FUNCTION PROTOTYPES ====================
|
|
78 |
|
|
79 |
// ========== LOCAL FUNCTIONS ==============================
|
|
80 |
|
|
81 |
// ========== MEMBER FUNCTIONS =============================
|
|
82 |
|
|
83 |
// ---------------------------------------------------------
|
|
84 |
// CMsgEditorView::CMsgEditorView
|
|
85 |
//
|
|
86 |
// Constructor.
|
|
87 |
// ---------------------------------------------------------
|
|
88 |
//
|
|
89 |
CMsgEditorView::CMsgEditorView( MMsgEditorObserver& aObserver,
|
|
90 |
TUint32 aEditorModeFlags ):
|
|
91 |
iEditorObserver( aObserver ),
|
|
92 |
iCurrentFocus( EMsgNoneFocused ),
|
|
93 |
iEditorModeFlags( aEditorModeFlags ),
|
|
94 |
iLineHeight( MsgEditorCommons::MsgBaseLineDelta() ),
|
|
95 |
iBaseLineOffset( MsgEditorCommons::MsgBaseLineOffset() ),
|
|
96 |
iResourceLoader( *iCoeEnv ),
|
|
97 |
iPrevFocus( EMsgNoneFocused ),
|
|
98 |
iMoveUpDownEvent( EFalse)
|
|
99 |
{
|
|
100 |
}
|
|
101 |
|
|
102 |
// ---------------------------------------------------------
|
|
103 |
// CMsgEditorView::ConstructL
|
|
104 |
//
|
|
105 |
// Constructs the editor view by creating the window, the header and the body.
|
|
106 |
// ---------------------------------------------------------
|
|
107 |
//
|
|
108 |
void CMsgEditorView::ConstructL()
|
|
109 |
{
|
|
110 |
CreateWindowL();
|
|
111 |
|
|
112 |
if ( AknStatuspaneUtils::FlatLayoutActive() )
|
|
113 |
{
|
|
114 |
CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
|
|
115 |
if ( statusPane )
|
|
116 |
{
|
|
117 |
CAknNavigationControlContainer* naviPane =
|
|
118 |
static_cast<CAknNavigationControlContainer*>( statusPane->ControlL(
|
|
119 |
TUid::Uid( EEikStatusPaneUidNavi ) ) );
|
|
120 |
|
|
121 |
if ( naviPane )
|
|
122 |
{
|
|
123 |
naviPane->SetPreferredNaviDecoratorLayoutStyle(
|
|
124 |
CAknNavigationDecorator::ENaviControlLayoutNormal );
|
|
125 |
}
|
|
126 |
}
|
|
127 |
}
|
|
128 |
|
|
129 |
iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMainMessage,
|
|
130 |
Rect(),
|
|
131 |
EFalse );
|
|
132 |
|
|
133 |
// T9: Add control to stack to make FEP work. View does not accept key
|
|
134 |
// events from CT9FepControl::HandleChangeInFocus(). Key events are
|
|
135 |
// handled first by editor app ui which routes them to view.
|
|
136 |
iEikonEnv->EikAppUi()->AddToStackL( this,
|
|
137 |
ECoeStackPriorityDefault,
|
|
138 |
ECoeStackFlagRefusesAllKeys );
|
|
139 |
|
|
140 |
Window().SetShadowDisabled( ETrue );
|
|
141 |
|
|
142 |
// Disables automatic background color drawing
|
|
143 |
// on window server.
|
|
144 |
Window().SetBackgroundColor();
|
|
145 |
|
|
146 |
CreateScrollBarL();
|
|
147 |
CreateHeaderL();
|
|
148 |
CreateBodyL();
|
|
149 |
}
|
|
150 |
|
|
151 |
// ---------------------------------------------------------
|
|
152 |
// CMsgEditorView::~CMsgEditorView
|
|
153 |
//
|
|
154 |
// Destructor.
|
|
155 |
// ---------------------------------------------------------
|
|
156 |
//
|
|
157 |
EXPORT_C CMsgEditorView::~CMsgEditorView()
|
|
158 |
{
|
|
159 |
iEikonEnv->EikAppUi()->RemoveFromStack( this );
|
|
160 |
|
|
161 |
delete iHeader;
|
|
162 |
delete iBody;
|
|
163 |
delete iScrollBar;
|
|
164 |
delete iBgContext;
|
|
165 |
|
|
166 |
iResourceLoader.Close();
|
|
167 |
|
|
168 |
delete iScrollPopText;
|
|
169 |
}
|
|
170 |
|
|
171 |
// ---------------------------------------------------------
|
|
172 |
// CMsgEditorView::NewL
|
|
173 |
//
|
|
174 |
// Factory method.
|
|
175 |
// ---------------------------------------------------------
|
|
176 |
//
|
|
177 |
EXPORT_C CMsgEditorView* CMsgEditorView::NewL( MMsgEditorObserver& aObserver,
|
|
178 |
TUint32 aEditorModeFlags )
|
|
179 |
{
|
|
180 |
CMsgEditorView* self = new( ELeave ) CMsgEditorView( aObserver, aEditorModeFlags );
|
|
181 |
|
|
182 |
CleanupStack::PushL( self );
|
|
183 |
self->ConstructL();
|
|
184 |
CleanupStack::Pop( self );
|
|
185 |
|
|
186 |
return self;
|
|
187 |
}
|
|
188 |
|
|
189 |
// ---------------------------------------------------------
|
|
190 |
// CMsgEditorView::MopNext
|
|
191 |
//
|
|
192 |
// From MObjectProvider.
|
|
193 |
// ---------------------------------------------------------
|
|
194 |
//
|
|
195 |
EXPORT_C MObjectProvider* CMsgEditorView::MopNext()
|
|
196 |
{
|
|
197 |
return iEikonEnv->EikAppUi();
|
|
198 |
}
|
|
199 |
|
|
200 |
// ---------------------------------------------------------
|
|
201 |
// CMsgEditorView::ExecuteL
|
|
202 |
//
|
|
203 |
// Prepares the editor view for showing it on the screen.
|
|
204 |
// ---------------------------------------------------------
|
|
205 |
//
|
|
206 |
EXPORT_C void CMsgEditorView::ExecuteL( const TRect& aRect,
|
|
207 |
TInt aControlIdForFocus )
|
|
208 |
{
|
|
209 |
TRect rect( aRect );
|
|
210 |
rect.iBr.iY = rect.iTl.iY + MsgEditorCommons::EditorViewHeigth();
|
|
211 |
|
|
212 |
AdjustComponentDistances();
|
|
213 |
|
|
214 |
SetViewRect( rect );
|
|
215 |
iSize = rect.Size();
|
|
216 |
|
|
217 |
// Set initial size for controls.
|
|
218 |
TSize editorSize( rect.Size() );
|
|
219 |
SetAndGetSizeL( editorSize, ETrue );
|
|
220 |
|
|
221 |
// Enable here so that size affecting events are processed
|
|
222 |
// from header & body controls after this point.
|
|
223 |
iStateFlags |= EMsgStateInitializing;
|
|
224 |
|
|
225 |
SizeChanged();
|
|
226 |
ActivateL();
|
|
227 |
|
|
228 |
iScrollParts = 1;
|
|
229 |
|
|
230 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgScrollParts,
|
|
231 |
&iScrollParts,
|
|
232 |
NULL,
|
|
233 |
NULL );
|
|
234 |
|
|
235 |
if ( aControlIdForFocus != EMsgComponentIdNull )
|
|
236 |
{
|
|
237 |
SetFocusByControlIdL( aControlIdForFocus );
|
|
238 |
}
|
|
239 |
|
|
240 |
if ( aControlIdForFocus == EMsgComponentIdNull ||
|
|
241 |
iCurrentFocus == EMsgNoneFocused )
|
|
242 |
{
|
|
243 |
iCurrentFocus = EMsgHeaderFocused;
|
|
244 |
|
|
245 |
TInt newFocus = iHeader->FirstFocusableControl( 0, EMsgFocusDown );
|
|
246 |
if ( newFocus == KErrNotFound )
|
|
247 |
{
|
|
248 |
iPrevFocus = EMsgHeaderFocused;
|
|
249 |
iCurrentFocus = EMsgBodyFocused;
|
|
250 |
newFocus = iBody->FirstFocusableControl( 0, EMsgFocusDown );
|
|
251 |
|
|
252 |
if ( newFocus == KErrNotFound )
|
|
253 |
{
|
|
254 |
iPrevFocus = EMsgNoneFocused;
|
|
255 |
iCurrentFocus = EMsgNoneFocused;
|
|
256 |
}
|
|
257 |
else
|
|
258 |
{
|
|
259 |
iBody->ChangeFocusTo( newFocus, ENoDrawNow );
|
|
260 |
}
|
|
261 |
}
|
|
262 |
else
|
|
263 |
{
|
|
264 |
iHeader->ChangeFocusTo( newFocus, ENoDrawNow );
|
|
265 |
}
|
|
266 |
}
|
|
267 |
|
|
268 |
UpdateScrollBarL();
|
|
269 |
|
|
270 |
SetComponentsInitialized();
|
|
271 |
|
|
272 |
iStateFlags &= ~EMsgStateInitializing;
|
|
273 |
iStateFlags |= EMsgStateInitialized;
|
|
274 |
|
|
275 |
// Has to be called after EMsgStateInitialized flag is set on since
|
|
276 |
// otherwise control that have suppress text formatting are not
|
|
277 |
// resized correctly.
|
|
278 |
NotifyControlsForEvent( EMsgViewEventPrepareForViewing, 0 );
|
|
279 |
|
|
280 |
DrawNow();
|
|
281 |
iCoeEnv->WsSession().Flush();
|
|
282 |
}
|
|
283 |
|
|
284 |
// ---------------------------------------------------------
|
|
285 |
// CMsgEditorView::ControlById
|
|
286 |
//
|
|
287 |
// Finds a control from the header and the body by id and returns a pointer to it.
|
|
288 |
// ---------------------------------------------------------
|
|
289 |
//
|
|
290 |
EXPORT_C CMsgBaseControl* CMsgEditorView::ControlById( TInt aControlId ) const
|
|
291 |
{
|
|
292 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
293 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
294 |
|
|
295 |
CMsgBaseControl* component = iHeader->Component( aControlId );
|
|
296 |
|
|
297 |
if ( !component )
|
|
298 |
{
|
|
299 |
component = iBody->Component( aControlId );
|
|
300 |
}
|
|
301 |
|
|
302 |
return component;
|
|
303 |
}
|
|
304 |
|
|
305 |
// ---------------------------------------------------------
|
|
306 |
// CMsgEditorView::FocusedControl
|
|
307 |
//
|
|
308 |
// Returns a pointer to a focused control. If no control is focused, returns NULL.
|
|
309 |
// ---------------------------------------------------------
|
|
310 |
//
|
|
311 |
EXPORT_C CMsgBaseControl* CMsgEditorView::FocusedControl() const
|
|
312 |
{
|
|
313 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
314 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
315 |
|
|
316 |
if ( iCurrentFocus == EMsgHeaderFocused )
|
|
317 |
{
|
|
318 |
return iHeader->FocusedControl();
|
|
319 |
}
|
|
320 |
else if ( iCurrentFocus == EMsgBodyFocused )
|
|
321 |
{
|
|
322 |
return iBody->FocusedControl();
|
|
323 |
}
|
|
324 |
else
|
|
325 |
{
|
|
326 |
return NULL;
|
|
327 |
}
|
|
328 |
}
|
|
329 |
|
|
330 |
// ---------------------------------------------------------
|
|
331 |
// CMsgEditorView::SetFocus
|
|
332 |
//
|
|
333 |
// Sets focus to a control aControlId.
|
|
334 |
// ---------------------------------------------------------
|
|
335 |
//
|
|
336 |
EXPORT_C void CMsgEditorView::SetFocus( TInt aControlId )
|
|
337 |
{
|
|
338 |
__ASSERT_DEBUG( iStateFlags & EMsgStateInitialized,
|
|
339 |
Panic( EMsgFunctionCalledBeforeInitialization ) );
|
|
340 |
|
|
341 |
TRAP_IGNORE(
|
|
342 |
{
|
|
343 |
SetFocusByControlIdL( aControlId );
|
|
344 |
UpdateScrollBarL();
|
|
345 |
} );
|
|
346 |
}
|
|
347 |
|
|
348 |
// ---------------------------------------------------------
|
|
349 |
// CMsgEditorView::AddControlFromResourceL
|
|
350 |
//
|
|
351 |
// Constructs a control of type aControlType from resource and adds it to
|
|
352 |
// a form component aFormComponent. The control is added to a position aIndex.
|
|
353 |
//
|
|
354 |
// Leaves with KErrNotFound if aControlType is incorrect.
|
|
355 |
// ---------------------------------------------------------
|
|
356 |
//
|
|
357 |
EXPORT_C TInt CMsgEditorView::AddControlFromResourceL( TInt aResourceId,
|
|
358 |
TInt aControlType,
|
|
359 |
TInt aIndex,
|
|
360 |
TMsgFormComponent aFormComponent )
|
|
361 |
{
|
|
362 |
CMsgBaseControl* control = NULL;
|
|
363 |
|
|
364 |
switch (aControlType)
|
|
365 |
{
|
|
366 |
case EMsgExpandableControl:
|
|
367 |
{
|
|
368 |
control = new ( ELeave ) CMsgExpandableControl( *this );
|
|
369 |
break;
|
|
370 |
}
|
|
371 |
case EMsgAddressControl:
|
|
372 |
{
|
|
373 |
control = new ( ELeave ) CMsgAddressControl( *this );
|
|
374 |
break;
|
|
375 |
}
|
|
376 |
case EMsgAttachmentControl:
|
|
377 |
{
|
|
378 |
control = new ( ELeave ) CMsgAttachmentControl( *this, *this );
|
|
379 |
break;
|
|
380 |
}
|
|
381 |
default:
|
|
382 |
{
|
|
383 |
control = iEditorObserver.CreateCustomControlL( aControlType );
|
|
384 |
if ( control == NULL )
|
|
385 |
{
|
|
386 |
User::Leave( KErrNotSupported );
|
|
387 |
}
|
|
388 |
break;
|
|
389 |
}
|
|
390 |
}
|
|
391 |
|
|
392 |
CleanupStack::PushL( control );
|
|
393 |
control->SetControlType( aControlType );
|
|
394 |
control->SetMopParent( this );
|
|
395 |
|
|
396 |
control->ConstructFromResourceL( aResourceId );
|
|
397 |
|
|
398 |
TInt controlId = control->ControlId();
|
|
399 |
DoAddControlL( control, controlId, aIndex, aFormComponent );
|
|
400 |
CleanupStack::Pop(); //control
|
|
401 |
|
|
402 |
return controlId;
|
|
403 |
}
|
|
404 |
|
|
405 |
// ---------------------------------------------------------
|
|
406 |
// CMsgEditorView::AddControlL
|
|
407 |
//
|
|
408 |
// Adds a control given by aControl to a form component aFormComponent.
|
|
409 |
// The control is added to a position aIndex with control id aControlId.
|
|
410 |
// ---------------------------------------------------------
|
|
411 |
//
|
|
412 |
EXPORT_C void CMsgEditorView::AddControlL( CMsgBaseControl* aControl,
|
|
413 |
TInt aControlId,
|
|
414 |
TInt aIndex,
|
|
415 |
TMsgFormComponent aFormComponent )
|
|
416 |
{
|
|
417 |
DoAddControlL( aControl, aControlId, aIndex, aFormComponent );
|
|
418 |
}
|
|
419 |
|
|
420 |
// ---------------------------------------------------------
|
|
421 |
// CMsgEditorView::RemoveControlL
|
|
422 |
//
|
|
423 |
// Removes the control aControlId from the header or the body and returns pointer
|
|
424 |
// to it. If a control cannot be found, returns NULL.
|
|
425 |
// ---------------------------------------------------------
|
|
426 |
//
|
|
427 |
EXPORT_C CMsgBaseControl* CMsgEditorView::RemoveControlL( TInt aControlId )
|
|
428 |
{
|
|
429 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
430 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
431 |
|
|
432 |
if ( iStateFlags & EMsgStateInitialized ) // Control is removed on run-time.
|
|
433 |
{
|
|
434 |
if ( FocusedControl() == ControlById( aControlId ) &&
|
|
435 |
iHeader->CountMsgControls() + iBody->CountMsgControls() > 1 )
|
|
436 |
{
|
|
437 |
// Try to move focus to different control as focused control is removed and
|
|
438 |
// there is more than one control loaded.
|
|
439 |
MMsgEditorObserver::TMsgFocusEvent focusEvent = MMsgEditorObserver::EMsgFocusNone;
|
|
440 |
|
|
441 |
if ( !RotateFocusL( EMsgFocusUp, focusEvent ) )
|
|
442 |
{
|
|
443 |
if ( !RotateFocusL( EMsgFocusDown, focusEvent ) )
|
|
444 |
{
|
|
445 |
//__ASSERT_DEBUG(EFalse, Panic(EMsgFocusLost));
|
|
446 |
// There are no focusing component left. Remove the focus from current control.
|
|
447 |
FocusedControl()->SetFocus( EFalse );
|
|
448 |
}
|
|
449 |
}
|
|
450 |
|
|
451 |
iCoeEnv->SyncNotifyFocusObserversOfChangeInFocus();
|
|
452 |
}
|
|
453 |
}
|
|
454 |
|
|
455 |
// Remove a component from the header.
|
|
456 |
CMsgBaseControl* control = iHeader->RemoveControlL( aControlId );
|
|
457 |
|
|
458 |
if ( control == NULL )
|
|
459 |
{
|
|
460 |
// If a component could not be found in the header, remove it from the body.
|
|
461 |
control = iBody->RemoveControlL( aControlId );
|
|
462 |
}
|
|
463 |
|
|
464 |
if ( iStateFlags & EMsgStateInitialized ) // Control is removed on run-time.
|
|
465 |
{
|
|
466 |
if ( control != NULL )
|
|
467 |
{
|
|
468 |
CleanupStack::PushL( control );
|
|
469 |
RefreshViewL();
|
|
470 |
EnsureCorrectViewPosition();
|
|
471 |
CleanupStack::Pop(); // control
|
|
472 |
}
|
|
473 |
}
|
|
474 |
else if ( iHeader->CountMsgControls() == 0 )
|
|
475 |
{
|
|
476 |
iFormOffset = 0;
|
|
477 |
}
|
|
478 |
|
|
479 |
if ( control )
|
|
480 |
{
|
|
481 |
// This is needed atleast for japanese pictographs to not
|
|
482 |
// draw into current control area.
|
|
483 |
control->MakeVisible( EFalse );
|
|
484 |
}
|
|
485 |
|
|
486 |
return control;
|
|
487 |
}
|
|
488 |
|
|
489 |
// ---------------------------------------------------------
|
|
490 |
// CMsgEditorView::DeleteControlL
|
|
491 |
//
|
|
492 |
// Removes the control aControlId from the header or the body and returns pointer
|
|
493 |
// to it. If a control cannot be found, returns NULL.
|
|
494 |
// ---------------------------------------------------------
|
|
495 |
//
|
|
496 |
EXPORT_C void CMsgEditorView::DeleteControlL( TInt aControlId )
|
|
497 |
{
|
|
498 |
CMsgBaseControl* baseControl = RemoveControlL( aControlId );
|
|
499 |
delete baseControl;
|
|
500 |
}
|
|
501 |
|
|
502 |
// ---------------------------------------------------------
|
|
503 |
// CMsgEditorView::FormComponent
|
|
504 |
//
|
|
505 |
// Returns a reference to a form component.
|
|
506 |
// ---------------------------------------------------------
|
|
507 |
//
|
|
508 |
EXPORT_C CCoeControl& CMsgEditorView::FormComponent( TMsgFormComponent aFormComponent ) const
|
|
509 |
{
|
|
510 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
511 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
512 |
|
|
513 |
switch ( aFormComponent )
|
|
514 |
{
|
|
515 |
case EMsgHeader:
|
|
516 |
{
|
|
517 |
return *iHeader;
|
|
518 |
}
|
|
519 |
case EMsgBody:
|
|
520 |
{
|
|
521 |
return *iBody;
|
|
522 |
}
|
|
523 |
default:
|
|
524 |
{
|
|
525 |
__ASSERT_DEBUG( EFalse, Panic( EMsgIncorrectFormComponent ) );
|
|
526 |
// Just to make compiler happy.
|
|
527 |
return *iBody;
|
|
528 |
}
|
|
529 |
}
|
|
530 |
}
|
|
531 |
|
|
532 |
// ---------------------------------------------------------
|
|
533 |
// CMsgEditorView::HandleScreenSizeChangeL
|
|
534 |
//
|
|
535 |
// Prepares the editor view for viewing it on the screen after screen size change.
|
|
536 |
// ---------------------------------------------------------
|
|
537 |
//
|
|
538 |
EXPORT_C void CMsgEditorView::HandleScreenSizeChangeL( const TRect& aRect )
|
|
539 |
{
|
|
540 |
__ASSERT_DEBUG( iStateFlags & EMsgStateInitialized,
|
|
541 |
Panic( EMsgFunctionCalledBeforeInitialization ) );
|
|
542 |
|
|
543 |
SetViewRect( aRect );
|
|
544 |
RefreshViewL();
|
|
545 |
}
|
|
546 |
|
|
547 |
|
|
548 |
// ---------------------------------------------------------
|
|
549 |
// CMsgEditorView::ResetControls
|
|
550 |
//
|
|
551 |
// Reset all controls.
|
|
552 |
// ---------------------------------------------------------
|
|
553 |
//
|
|
554 |
EXPORT_C void CMsgEditorView::ResetControls()
|
|
555 |
{
|
|
556 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
557 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
558 |
|
|
559 |
iHeader->ResetControls();
|
|
560 |
iBody->ResetControls();
|
|
561 |
}
|
|
562 |
|
|
563 |
// ---------------------------------------------------------
|
|
564 |
// CMsgEditorView::ResetControls
|
|
565 |
//
|
|
566 |
// Reset controls from header or body.
|
|
567 |
// ---------------------------------------------------------
|
|
568 |
//
|
|
569 |
EXPORT_C void CMsgEditorView::ResetControls( TMsgFormComponent aFormComponent )
|
|
570 |
{
|
|
571 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
572 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
573 |
|
|
574 |
switch ( aFormComponent )
|
|
575 |
{
|
|
576 |
case EMsgHeader:
|
|
577 |
{
|
|
578 |
iHeader->ResetControls();
|
|
579 |
break;
|
|
580 |
}
|
|
581 |
case EMsgBody:
|
|
582 |
{
|
|
583 |
iBody->ResetControls();
|
|
584 |
break;
|
|
585 |
}
|
|
586 |
default:
|
|
587 |
{
|
|
588 |
__ASSERT_DEBUG( EFalse, Panic( EMsgIncorrectFormComponent ) );
|
|
589 |
}
|
|
590 |
}
|
|
591 |
}
|
|
592 |
|
|
593 |
// ---------------------------------------------------------
|
|
594 |
// CMsgEditorView::IsAnyControlModified
|
|
595 |
//
|
|
596 |
// Checks if any control owned by view is modified.
|
|
597 |
// ---------------------------------------------------------
|
|
598 |
//
|
|
599 |
EXPORT_C TBool CMsgEditorView::IsAnyControlModified() const
|
|
600 |
{
|
|
601 |
TInt i;
|
|
602 |
CMsgBaseControl* ctrl;
|
|
603 |
TInt countHeader = iHeader->CountMsgControls();
|
|
604 |
TInt countBody = iBody->CountMsgControls();
|
|
605 |
|
|
606 |
for ( i = 0; i < countHeader; i++ )
|
|
607 |
{
|
|
608 |
ctrl = iHeader->MsgControl( i );
|
|
609 |
if ( ctrl && ctrl->IsModified() )
|
|
610 |
{
|
|
611 |
return ETrue;
|
|
612 |
}
|
|
613 |
}
|
|
614 |
|
|
615 |
for ( i = 0; i < countBody; i++ )
|
|
616 |
{
|
|
617 |
ctrl = iBody->MsgControl( i );
|
|
618 |
if ( ctrl && ctrl->IsModified() )
|
|
619 |
{
|
|
620 |
return ETrue;
|
|
621 |
}
|
|
622 |
}
|
|
623 |
|
|
624 |
return EFalse;
|
|
625 |
}
|
|
626 |
|
|
627 |
// ---------------------------------------------------------
|
|
628 |
// CMsgEditorView::SetControlsModified
|
|
629 |
//
|
|
630 |
// Updates modified flag of controls owned by view.
|
|
631 |
// ---------------------------------------------------------
|
|
632 |
//
|
|
633 |
EXPORT_C void CMsgEditorView::SetControlsModified( TBool aFlag )
|
|
634 |
{
|
|
635 |
TInt i;
|
|
636 |
CMsgBaseControl* ctrl;
|
|
637 |
TInt countHeader = iHeader->CountMsgControls();
|
|
638 |
TInt countBody = iBody->CountMsgControls();
|
|
639 |
|
|
640 |
for ( i = 0; i < countHeader; i++ )
|
|
641 |
{
|
|
642 |
ctrl = iHeader->MsgControl( i );
|
|
643 |
if ( ctrl )
|
|
644 |
{
|
|
645 |
ctrl->SetModified( aFlag );
|
|
646 |
}
|
|
647 |
}
|
|
648 |
|
|
649 |
for ( i = 0; i < countBody; i++ )
|
|
650 |
{
|
|
651 |
ctrl = iBody->MsgControl( i );
|
|
652 |
if ( ctrl )
|
|
653 |
{
|
|
654 |
ctrl->SetModified( aFlag );
|
|
655 |
}
|
|
656 |
}
|
|
657 |
}
|
|
658 |
|
|
659 |
// ---------------------------------------------------------
|
|
660 |
// CMsgEditorView::OfferKeyEventL
|
|
661 |
//
|
|
662 |
// Handles key events.
|
|
663 |
// ---------------------------------------------------------
|
|
664 |
//
|
|
665 |
EXPORT_C TKeyResponse CMsgEditorView::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
666 |
TEventCode aType )
|
|
667 |
{
|
|
668 |
CMsgBaseControl* ctrl = FocusedControl();
|
|
669 |
|
|
670 |
// Is this needed?
|
|
671 |
if ( ctrl && ctrl->ControlType() == EMsgAddressControl && aType == EEventKeyUp )
|
|
672 |
{
|
|
673 |
return ctrl->OfferKeyEventL( aKeyEvent, aType );
|
|
674 |
}
|
|
675 |
|
|
676 |
if ( ( !( iStateFlags & EMsgStateInitialized ) ) || ( aType != EEventKey ) )
|
|
677 |
{
|
|
678 |
return EKeyWasNotConsumed;
|
|
679 |
}
|
|
680 |
|
|
681 |
TKeyResponse keyResp( EKeyWasNotConsumed );
|
|
682 |
TBool focusRotated = EFalse;
|
|
683 |
TBool forceScrollUp = EFalse;
|
|
684 |
MMsgEditorObserver::TMsgFocusEvent focusEvent = MMsgEditorObserver::EMsgFocusNone;
|
|
685 |
|
|
686 |
switch ( aKeyEvent.iCode )
|
|
687 |
{
|
|
688 |
case EKeyUpArrow:
|
|
689 |
{
|
|
690 |
if ( ctrl )
|
|
691 |
{
|
|
692 |
// No focus change allowed if selection is ongoing.
|
|
693 |
if ( !( aKeyEvent.iModifiers & EModifierShift ) &&
|
|
694 |
ctrl->IsFocusChangePossible( EMsgFocusUp ) )
|
|
695 |
{
|
|
696 |
if ( RotateFocusL( EMsgFocusUp, focusEvent ) )
|
|
697 |
{
|
|
698 |
focusRotated = ETrue;
|
|
699 |
keyResp = EKeyWasConsumed; // focus changed.
|
|
700 |
}
|
|
701 |
else
|
|
702 |
{
|
|
703 |
// the cursor is in the topmost control.
|
|
704 |
TInt delta = -iFormOffset;
|
|
705 |
ScrollForm( delta, ETrue );
|
|
706 |
|
|
707 |
keyResp = EKeyWasNotConsumed;
|
|
708 |
}
|
|
709 |
}
|
|
710 |
}
|
|
711 |
else
|
|
712 |
{
|
|
713 |
// no focused control: set focus event if many parts.
|
|
714 |
if ( iScrollParts > 1 )
|
|
715 |
{
|
|
716 |
focusEvent = MMsgEditorObserver::EMsgFocusAtTop;
|
|
717 |
}
|
|
718 |
}
|
|
719 |
break;
|
|
720 |
}
|
|
721 |
case EKeyDownArrow:
|
|
722 |
{
|
|
723 |
if ( ctrl )
|
|
724 |
{
|
|
725 |
// No focus change allowed if selection is ongoing.
|
|
726 |
if ( !( aKeyEvent.iModifiers & EModifierShift ) &&
|
|
727 |
ctrl->IsFocusChangePossible( EMsgFocusDown ) )
|
|
728 |
{
|
|
729 |
if ( RotateFocusL( EMsgFocusDown, focusEvent ) )
|
|
730 |
{
|
|
731 |
focusRotated = ETrue;
|
|
732 |
keyResp = EKeyWasConsumed;
|
|
733 |
}
|
|
734 |
else
|
|
735 |
{
|
|
736 |
keyResp = EKeyWasNotConsumed;
|
|
737 |
}
|
|
738 |
}
|
|
739 |
}
|
|
740 |
else
|
|
741 |
{
|
|
742 |
// no focused control: set focus event if many parts.
|
|
743 |
if ( iScrollParts > 1 )
|
|
744 |
{
|
|
745 |
focusEvent = MMsgEditorObserver::EMsgFocusAtBottom;
|
|
746 |
}
|
|
747 |
}
|
|
748 |
break;
|
|
749 |
}
|
|
750 |
default:
|
|
751 |
{
|
|
752 |
break;
|
|
753 |
}
|
|
754 |
}
|
|
755 |
|
|
756 |
if ( ctrl && keyResp == EKeyWasNotConsumed )
|
|
757 |
{
|
|
758 |
keyResp = ctrl->OfferKeyEventL( aKeyEvent, aType );
|
|
759 |
}
|
|
760 |
|
|
761 |
if ( focusEvent != MMsgEditorObserver::EMsgFocusNone )
|
|
762 |
{
|
|
763 |
MMsgEditorObserver::TMsgAfterFocusEventFunc after =
|
|
764 |
MMsgEditorObserver::EMsgAfterFocusNone;
|
|
765 |
|
|
766 |
#ifdef RD_SCALABLE_UI_V2
|
|
767 |
if ( focusEvent == MMsgEditorObserver::EMsgFocusAtTop )
|
|
768 |
{
|
|
769 |
iVisiblePart--;
|
|
770 |
}
|
|
771 |
else if ( focusEvent == MMsgEditorObserver::EMsgFocusAtBottom )
|
|
772 |
{
|
|
773 |
iVisiblePart++;
|
|
774 |
}
|
|
775 |
|
|
776 |
iVisiblePart = Max( 0, Min( iScrollParts - 1, iVisiblePart ) );
|
|
777 |
#endif
|
|
778 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgHandleFocusChange,
|
|
779 |
&focusEvent,
|
|
780 |
&after,
|
|
781 |
&iVisiblePart );
|
|
782 |
|
|
783 |
if ( after != MMsgEditorObserver::EMsgAfterFocusNone )
|
|
784 |
{
|
|
785 |
forceScrollUp = SetAfterFocusL( after );
|
|
786 |
}
|
|
787 |
}
|
|
788 |
|
|
789 |
iMoveUpDownEvent = ETrue;
|
|
790 |
EnsureCorrectFormPosition( ( aKeyEvent.iCode == EKeyDownArrow ) && focusRotated, forceScrollUp );
|
|
791 |
iMoveUpDownEvent = EFalse;
|
|
792 |
|
|
793 |
UpdateScrollBarL();
|
|
794 |
|
|
795 |
return keyResp;
|
|
796 |
}
|
|
797 |
|
|
798 |
// ---------------------------------------------------------
|
|
799 |
// CMsgEditorView::HandlePointerEventL
|
|
800 |
//
|
|
801 |
// Handles pointer event processing and propagation.
|
|
802 |
// ---------------------------------------------------------
|
|
803 |
//
|
|
804 |
#ifdef RD_SCALABLE_UI_V2
|
|
805 |
void CMsgEditorView::HandlePointerEventL( const TPointerEvent& aPointerEvent )
|
|
806 |
{
|
|
807 |
if ( AknLayoutUtils::PenEnabled() )
|
|
808 |
{
|
|
809 |
TBool handled( EFalse );
|
|
810 |
|
|
811 |
if ( IsFocused() )
|
|
812 |
{
|
|
813 |
TPointerEvent pointerEvent( aPointerEvent );
|
|
814 |
|
|
815 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgControlPointerEvent,
|
|
816 |
ControlFromPosition( aPointerEvent.iPosition, ETrue ),
|
|
817 |
&pointerEvent,
|
|
818 |
&handled );
|
|
819 |
}
|
|
820 |
|
|
821 |
if ( !handled )
|
|
822 |
{
|
|
823 |
CCoeControl::HandlePointerEventL( aPointerEvent );
|
|
824 |
}
|
|
825 |
}
|
|
826 |
}
|
|
827 |
#else
|
|
828 |
void CMsgEditorView::HandlePointerEventL( const TPointerEvent& /*aPointerEvent*/ )
|
|
829 |
{
|
|
830 |
}
|
|
831 |
#endif // RD_SCALABLE_UI_V2
|
|
832 |
|
|
833 |
|
|
834 |
// ---------------------------------------------------------
|
|
835 |
// CMsgEditorView::ViewInitialized
|
|
836 |
//
|
|
837 |
// Returns whether view is initialized.
|
|
838 |
// ---------------------------------------------------------
|
|
839 |
//
|
|
840 |
TBool CMsgEditorView::ViewInitialized() const
|
|
841 |
{
|
|
842 |
return iStateFlags & EMsgStateInitialized;
|
|
843 |
}
|
|
844 |
|
|
845 |
// ---------------------------------------------------------
|
|
846 |
// CMsgEditorView::ViewRect
|
|
847 |
//
|
|
848 |
// Returns the current view rectangle.
|
|
849 |
// ---------------------------------------------------------
|
|
850 |
//
|
|
851 |
TRect CMsgEditorView::ViewRect() const
|
|
852 |
{
|
|
853 |
return iViewRect;
|
|
854 |
}
|
|
855 |
|
|
856 |
// ---------------------------------------------------------
|
|
857 |
// CMsgEditorView::HandleBaseControlEventRequestL
|
|
858 |
//
|
|
859 |
// Handles an event from a control.
|
|
860 |
// ---------------------------------------------------------
|
|
861 |
//
|
|
862 |
TBool CMsgEditorView::HandleBaseControlEventRequestL( CMsgBaseControl* aControl,
|
|
863 |
TMsgControlEventRequest aRequest,
|
|
864 |
TInt aDelta )
|
|
865 |
{
|
|
866 |
if ( !( iStateFlags & EMsgStateInitialized ) )
|
|
867 |
{
|
|
868 |
// Allow processing of possible height & position changing
|
|
869 |
// events when view is currently being initialized.
|
|
870 |
if ( !( iStateFlags & EMsgStateInitializing ) ||
|
|
871 |
!( aRequest == EMsgEnsureCorrectFormPosition ||
|
|
872 |
aRequest == EMsgHeightChanged ) )
|
|
873 |
{
|
|
874 |
return ETrue;
|
|
875 |
}
|
|
876 |
}
|
|
877 |
|
|
878 |
TBool done( EFalse );
|
|
879 |
MMsgEditorObserver::TMsgFocusEvent focusEvent = MMsgEditorObserver::EMsgFocusNone;
|
|
880 |
|
|
881 |
switch ( aRequest )
|
|
882 |
{
|
|
883 |
case EMsgCheckIfFocusIsAboveThis:
|
|
884 |
{
|
|
885 |
TBool isAbove = EFalse;
|
|
886 |
TInt componentIndex = iHeader->ComponentIndexFromId( aControl->ControlId() );
|
|
887 |
if ( componentIndex != KErrNotFound )
|
|
888 |
{
|
|
889 |
// control found in header.
|
|
890 |
isAbove = iCurrentFocus == EMsgHeaderFocused
|
|
891 |
? iHeader->CurrentFocus() < componentIndex
|
|
892 |
: EFalse;
|
|
893 |
}
|
|
894 |
else
|
|
895 |
{
|
|
896 |
// control found in body.
|
|
897 |
componentIndex = iBody->ComponentIndexFromId( aControl->ControlId() );
|
|
898 |
isAbove = iCurrentFocus == EMsgBodyFocused
|
|
899 |
? iBody->CurrentFocus() < componentIndex
|
|
900 |
: ETrue;
|
|
901 |
}
|
|
902 |
return isAbove;
|
|
903 |
}
|
|
904 |
|
|
905 |
case EMsgEnsureCorrectFormPosition:
|
|
906 |
{
|
|
907 |
if ( iStateFlags & EMsgEnsureCorrectFormPositionRequestIssued )
|
|
908 |
{
|
|
909 |
// prevents recursion.
|
|
910 |
return EFalse;
|
|
911 |
}
|
|
912 |
break;
|
|
913 |
}
|
|
914 |
case EMsgRotateFocusUp:
|
|
915 |
{
|
|
916 |
done = RotateFocusL( EMsgFocusUp, focusEvent );
|
|
917 |
break;
|
|
918 |
}
|
|
919 |
case EMsgRotateFocusDown:
|
|
920 |
{
|
|
921 |
done = RotateFocusL( EMsgFocusDown, focusEvent );
|
|
922 |
break;
|
|
923 |
}
|
|
924 |
case EMsgHeightChanged:
|
|
925 |
{
|
|
926 |
if ( iStateFlags & EMsgStateRefreshing )
|
|
927 |
{
|
|
928 |
done = ETrue;
|
|
929 |
}
|
|
930 |
else if ( aControl &&
|
|
931 |
aControl->ControlModeFlags() & EMsgControlModeBodyMaxHeight )
|
|
932 |
{
|
|
933 |
// Special handling is needed when maximum height body control's height is changed.
|
|
934 |
// Currently this is happening when control is reseted. Special handling is
|
|
935 |
// needed as last line of body control's text should be shown on the
|
|
936 |
// last visible editor line if editor total height permits it. If editor total
|
|
937 |
// does not permit this then editor should show it's topmost line.
|
|
938 |
TInt bottomYPos( aControl->Position().iY + aControl->VirtualHeight() );
|
|
939 |
TInt distanceFromBottom( Rect().iBr.iY - bottomYPos );
|
|
940 |
|
|
941 |
if ( distanceFromBottom > 0 )
|
|
942 |
{
|
|
943 |
TInt delta = Abs( iFormOffset ) < distanceFromBottom ? -iFormOffset :
|
|
944 |
distanceFromBottom;
|
|
945 |
|
|
946 |
if ( delta )
|
|
947 |
{
|
|
948 |
ScrollForm( delta, ETrue );
|
|
949 |
}
|
|
950 |
}
|
|
951 |
|
|
952 |
if ( ViewInitialized() )
|
|
953 |
{
|
|
954 |
UpdateScrollBarL();
|
|
955 |
}
|
|
956 |
|
|
957 |
done = ETrue;
|
|
958 |
}
|
|
959 |
else
|
|
960 |
{
|
|
961 |
done = HandleHeightChangedL( aControl, aDelta );
|
|
962 |
|
|
963 |
if ( ViewInitialized() )
|
|
964 |
{
|
|
965 |
UpdateScrollBarL();
|
|
966 |
}
|
|
967 |
}
|
|
968 |
return done;
|
|
969 |
}
|
|
970 |
case EMsgScrollForm:
|
|
971 |
{
|
|
972 |
done = ScrollForm( aDelta, ETrue );
|
|
973 |
break;
|
|
974 |
}
|
|
975 |
case EMsgUpdateScrollbar:
|
|
976 |
{
|
|
977 |
UpdateScrollBarL();
|
|
978 |
return ETrue;
|
|
979 |
}
|
|
980 |
default:
|
|
981 |
{
|
|
982 |
break;
|
|
983 |
}
|
|
984 |
}
|
|
985 |
|
|
986 |
done = EnsureCorrectFormPosition( EFalse );
|
|
987 |
|
|
988 |
if ( iStateFlags & EMsgStateRefreshing ||
|
|
989 |
iStateFlags & EMsgStateInitializing )
|
|
990 |
{
|
|
991 |
return done;
|
|
992 |
}
|
|
993 |
|
|
994 |
UpdateScrollBarL();
|
|
995 |
|
|
996 |
return done;
|
|
997 |
}
|
|
998 |
|
|
999 |
// ---------------------------------------------------------
|
|
1000 |
// CMsgEditorView::HandleBaseControlEventRequestL
|
|
1001 |
//
|
|
1002 |
// Handles an event from a control.
|
|
1003 |
// ---------------------------------------------------------
|
|
1004 |
//
|
|
1005 |
TBool CMsgEditorView::HandleBaseControlEventRequestL( CMsgBaseControl* aControl,
|
|
1006 |
TMsgControlEventRequest aRequest )
|
|
1007 |
{
|
|
1008 |
return HandleBaseControlEventRequestL( aControl, aRequest, 0 );
|
|
1009 |
}
|
|
1010 |
|
|
1011 |
// ---------------------------------------------------------
|
|
1012 |
// CMsgEditorView::HandleEditObserverEventRequestL
|
|
1013 |
//
|
|
1014 |
// Handles an event from a control.
|
|
1015 |
// ---------------------------------------------------------
|
|
1016 |
//
|
|
1017 |
TInt CMsgEditorView::HandleEditObserverEventRequestL( const CCoeControl* /*aControl*/,
|
|
1018 |
TMsgControlEventRequest aRequest,
|
|
1019 |
TAny* aArg1,
|
|
1020 |
TAny* aArg2,
|
|
1021 |
TAny* aArg3 )
|
|
1022 |
{
|
|
1023 |
switch ( aRequest )
|
|
1024 |
{
|
|
1025 |
case EMsgDenyCut:
|
|
1026 |
{
|
|
1027 |
CEikEdwin::TClipboardFunc cb = CEikEdwin::ECut;
|
|
1028 |
TInt arg = 0;
|
|
1029 |
|
|
1030 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgDenyClipboardOperation,
|
|
1031 |
&cb,
|
|
1032 |
&arg,
|
|
1033 |
NULL );
|
|
1034 |
return arg;
|
|
1035 |
}
|
|
1036 |
case EMsgDenyCopy:
|
|
1037 |
{
|
|
1038 |
CEikEdwin::TClipboardFunc cb = CEikEdwin::ECopy;
|
|
1039 |
TInt arg = 0;
|
|
1040 |
|
|
1041 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgDenyClipboardOperation,
|
|
1042 |
&cb,
|
|
1043 |
&arg,
|
|
1044 |
NULL );
|
|
1045 |
return arg;
|
|
1046 |
}
|
|
1047 |
case EMsgDenyPaste:
|
|
1048 |
{
|
|
1049 |
CEikEdwin::TClipboardFunc cb = CEikEdwin::EPaste;
|
|
1050 |
TInt arg = 0;
|
|
1051 |
|
|
1052 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgDenyClipboardOperation,
|
|
1053 |
&cb,
|
|
1054 |
&arg,
|
|
1055 |
NULL );
|
|
1056 |
return arg;
|
|
1057 |
}
|
|
1058 |
case EMsgStateFlags:
|
|
1059 |
{
|
|
1060 |
return iStateFlags;
|
|
1061 |
}
|
|
1062 |
case EMsgGetNaviIndicators:
|
|
1063 |
{
|
|
1064 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgGetNaviIndicators,
|
|
1065 |
aArg1,
|
|
1066 |
aArg2,
|
|
1067 |
aArg3 );
|
|
1068 |
return 0;
|
|
1069 |
}
|
|
1070 |
case EMsgButtonPressed:
|
|
1071 |
{
|
|
1072 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgButtonEvent,
|
|
1073 |
aArg1,
|
|
1074 |
aArg2,
|
|
1075 |
aArg3 );
|
|
1076 |
return 0;
|
|
1077 |
}
|
|
1078 |
default:
|
|
1079 |
{
|
|
1080 |
break;
|
|
1081 |
}
|
|
1082 |
}
|
|
1083 |
return 0;
|
|
1084 |
}
|
|
1085 |
|
|
1086 |
// ---------------------------------------------------------
|
|
1087 |
// CMsgEditorView::CountComponentControls
|
|
1088 |
//
|
|
1089 |
// Returns a number of controls.
|
|
1090 |
// ---------------------------------------------------------
|
|
1091 |
//
|
|
1092 |
TInt CMsgEditorView::CountComponentControls() const
|
|
1093 |
{
|
|
1094 |
TInt countScrollBarComponents( 0 );
|
|
1095 |
|
|
1096 |
if ( iScrollBar )
|
|
1097 |
{
|
|
1098 |
countScrollBarComponents = iScrollBar->CountComponentControls();
|
|
1099 |
}
|
|
1100 |
|
|
1101 |
return KMsgNumberOfControls + countScrollBarComponents;
|
|
1102 |
}
|
|
1103 |
|
|
1104 |
// ---------------------------------------------------------
|
|
1105 |
// CMsgEditorView::ComponentControl
|
|
1106 |
//
|
|
1107 |
// Returns a control of index aIndex.
|
|
1108 |
// ---------------------------------------------------------
|
|
1109 |
//
|
|
1110 |
CCoeControl* CMsgEditorView::ComponentControl( TInt aIndex ) const
|
|
1111 |
{
|
|
1112 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
1113 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
1114 |
|
|
1115 |
TInt countScrollBarComponents( 0 );
|
|
1116 |
|
|
1117 |
if ( iScrollBar )
|
|
1118 |
{
|
|
1119 |
countScrollBarComponents = iScrollBar->CountComponentControls();
|
|
1120 |
}
|
|
1121 |
|
|
1122 |
switch ( aIndex )
|
|
1123 |
{
|
|
1124 |
case KMsgControlIndexHeader:
|
|
1125 |
{
|
|
1126 |
return iHeader;
|
|
1127 |
}
|
|
1128 |
case KMsgControlIndexBody:
|
|
1129 |
{
|
|
1130 |
return iBody;
|
|
1131 |
}
|
|
1132 |
default:
|
|
1133 |
{
|
|
1134 |
if ( iScrollBar &&
|
|
1135 |
aIndex >= KMsgNumberOfControls &&
|
|
1136 |
aIndex < countScrollBarComponents + KMsgNumberOfControls )
|
|
1137 |
{
|
|
1138 |
return iScrollBar->ComponentControl( aIndex - KMsgNumberOfControls );
|
|
1139 |
}
|
|
1140 |
else
|
|
1141 |
{
|
|
1142 |
__ASSERT_DEBUG( EFalse, Panic( EMsgIncorrectComponentIndex ) );
|
|
1143 |
}
|
|
1144 |
return NULL;
|
|
1145 |
}
|
|
1146 |
}
|
|
1147 |
}
|
|
1148 |
|
|
1149 |
// ---------------------------------------------------------
|
|
1150 |
// CMsgEditorView::SizeChanged
|
|
1151 |
//
|
|
1152 |
// Sets new position for all the controls.
|
|
1153 |
// ---------------------------------------------------------
|
|
1154 |
//
|
|
1155 |
void CMsgEditorView::SizeChanged()
|
|
1156 |
{
|
|
1157 |
MEBLOGGER_ENTERFN( "CMsgEditorView::SizeChanged" );
|
|
1158 |
|
|
1159 |
if ( iBgContext )
|
|
1160 |
{
|
|
1161 |
iBgContext->SetRect( Rect() );
|
|
1162 |
iBgContext->SetParentPos( PositionRelativeToScreen() );
|
|
1163 |
}
|
|
1164 |
|
|
1165 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
1166 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
1167 |
|
|
1168 |
TPoint bodyPosition( MsgEditorCommons::MsgBodyPane().iTl.iX, 0 );
|
|
1169 |
TPoint headerPosition( MsgEditorCommons::MsgHeaderPane().iTl.iX, iFormOffset );
|
|
1170 |
|
|
1171 |
//MEBLOGGER_WRITEF(_L("MEB: CMsgEditorView::SizeChanged: header height %d "), iHeader->Size().iHeight);
|
|
1172 |
//MEBLOGGER_WRITEF(_L("MEB: CMsgEditorView::SizeChanged: body height %d "), iBody->Size().iHeight);
|
|
1173 |
|
|
1174 |
iHeader->SetExtent( headerPosition, iHeader->Size() );
|
|
1175 |
bodyPosition.iY = iHeader->Rect().iBr.iY /* + 1 */;
|
|
1176 |
iBody->SetExtent( bodyPosition, iBody->Size() );
|
|
1177 |
|
|
1178 |
MEBLOGGER_LEAVEFN( "CMsgEditorView::SizeChanged" );
|
|
1179 |
}
|
|
1180 |
|
|
1181 |
// ---------------------------------------------------------
|
|
1182 |
// CMsgEditorView::FocusChanged
|
|
1183 |
//
|
|
1184 |
// Sets focus off or on from focused control. This is called
|
|
1185 |
// when e.g. options menu is shown. Removed e.g. cursor from
|
|
1186 |
// text fields.
|
|
1187 |
// ---------------------------------------------------------
|
|
1188 |
//
|
|
1189 |
void CMsgEditorView::FocusChanged( TDrawNow /*aDrawNow*/ )
|
|
1190 |
{
|
|
1191 |
if ( iHeader && iBody )
|
|
1192 |
{
|
|
1193 |
CMsgBaseControl* ctrl = FocusedControl();
|
|
1194 |
|
|
1195 |
if ( ctrl )
|
|
1196 |
{
|
|
1197 |
if ( !( ctrl->IsNonFocusing() ) )
|
|
1198 |
{
|
|
1199 |
ctrl->SetFocus( IsFocused(), IsFocused() ? EDrawNow: ENoDrawNow );
|
|
1200 |
}
|
|
1201 |
}
|
|
1202 |
|
|
1203 |
if ( IsFocused() )
|
|
1204 |
{
|
|
1205 |
NotifyControlsForEvent( EMsgViewEventViewFocusGain, 0 );
|
|
1206 |
}
|
|
1207 |
else
|
|
1208 |
{
|
|
1209 |
NotifyControlsForEvent( EMsgViewEventViewFocusLost, 0 );
|
|
1210 |
}
|
|
1211 |
}
|
|
1212 |
}
|
|
1213 |
|
|
1214 |
// ---------------------------------------------------------
|
|
1215 |
// CMsgEditorView::HandleResourceChange
|
|
1216 |
//
|
|
1217 |
//
|
|
1218 |
// ---------------------------------------------------------
|
|
1219 |
//
|
|
1220 |
void CMsgEditorView::HandleResourceChange( TInt aType )
|
|
1221 |
{
|
|
1222 |
// Updates child control layouts. Must be called before
|
|
1223 |
// layout switch is handled here as AdjustComponentDistances
|
|
1224 |
// expects controls to have correct height. Child control
|
|
1225 |
// height may vary if layout is using different font.
|
|
1226 |
CCoeControl::HandleResourceChange( aType );
|
|
1227 |
|
|
1228 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
1229 |
{
|
|
1230 |
iScrollBar->SetScrollBarFrameObserver( this );
|
|
1231 |
|
|
1232 |
TInt invisibleLines( iFormOffset / iLineHeight );
|
|
1233 |
|
|
1234 |
iLineHeight = MsgEditorCommons::MsgBaseLineDelta();
|
|
1235 |
iBaseLineOffset = MsgEditorCommons::MsgBaseLineOffset();
|
|
1236 |
|
|
1237 |
// Correct the form offset to be multiple of current line height
|
|
1238 |
iFormOffset = invisibleLines * iLineHeight;
|
|
1239 |
|
|
1240 |
TRect mainPane = MsgEditorCommons::MsgMainPane();
|
|
1241 |
SetViewRect( mainPane );
|
|
1242 |
iSize = mainPane.Size();
|
|
1243 |
|
|
1244 |
AknLayoutUtils::LayoutVerticalScrollBar(
|
|
1245 |
iScrollBar,
|
|
1246 |
TRect( TPoint( 0, 0 ), mainPane.Size() ),
|
|
1247 |
AknLayoutScalable_Apps::scroll_pane_cp017().LayoutLine() );
|
|
1248 |
|
|
1249 |
TRAP_IGNORE( RefreshViewL() );
|
|
1250 |
|
|
1251 |
EnsureCorrectViewPosition();
|
|
1252 |
}
|
|
1253 |
}
|
|
1254 |
|
|
1255 |
// ---------------------------------------------------------
|
|
1256 |
// CMsgEditorView::HandleControlEventL
|
|
1257 |
// ---------------------------------------------------------
|
|
1258 |
//
|
|
1259 |
#ifdef RD_SCALABLE_UI_V2
|
|
1260 |
void CMsgEditorView::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType )
|
|
1261 |
{
|
|
1262 |
if ( aControl != iHeader &&
|
|
1263 |
aControl != iBody )
|
|
1264 |
{
|
|
1265 |
switch( aEventType )
|
|
1266 |
{
|
|
1267 |
case MCoeControlObserver::EEventPrepareFocusTransition:
|
|
1268 |
{
|
|
1269 |
// These things must be done before pointer event is handled.
|
|
1270 |
CMsgBaseControl* baseControl = static_cast<CMsgBaseControl*>( aControl );
|
|
1271 |
|
|
1272 |
if ( baseControl &&
|
|
1273 |
( baseControl->ControlType() == EMsgBodyControl ||
|
|
1274 |
baseControl->ControlType() == EMsgXhtmlBodyControl ) &&
|
|
1275 |
baseControl->ItemFinder() &&
|
|
1276 |
static_cast<CMsgBodyControl*>( baseControl )->Editor().TextView() )
|
|
1277 |
{
|
|
1278 |
TInt componentIndex = iBody->ComponentIndexFromId( baseControl->ControlId() );
|
|
1279 |
baseControl->SetupAutomaticFindAfterFocusChangeL( iBody->CurrentFocus() <= componentIndex );
|
|
1280 |
}
|
|
1281 |
|
|
1282 |
break;
|
|
1283 |
}
|
|
1284 |
case MCoeControlObserver::EEventRequestFocus:
|
|
1285 |
{
|
|
1286 |
// These things are done when pointer event is handled and focus should be changed.
|
|
1287 |
// NOTE: CMsgAddressControlEditor is relying on focus not to set before
|
|
1288 |
// pointer event is processed. Otherwise it is impossible to
|
|
1289 |
// determine whether control has been focused before or not.
|
|
1290 |
CMsgBaseControl* baseControl = static_cast<CMsgBaseControl*>( aControl );
|
|
1291 |
SetFocusByControlIdL( baseControl->ControlId(), ETrue, EFalse );
|
|
1292 |
|
|
1293 |
UpdateScrollBarL();
|
|
1294 |
}
|
|
1295 |
default:
|
|
1296 |
{
|
|
1297 |
break;
|
|
1298 |
}
|
|
1299 |
}
|
|
1300 |
}
|
|
1301 |
//MEBLOGGER_WRITEF(_L("MEB: CMsgEditorView::HandleControlEventL"));
|
|
1302 |
}
|
|
1303 |
#else
|
|
1304 |
void CMsgEditorView::HandleControlEventL( CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/ )
|
|
1305 |
{
|
|
1306 |
//MEBLOGGER_WRITEF(_L("MEB: CMsgEditorView::HandleControlEventL"));
|
|
1307 |
}
|
|
1308 |
#endif // RD_SCALABLE_UI_V2
|
|
1309 |
|
|
1310 |
// ---------------------------------------------------------
|
|
1311 |
// CMsgEditorView::CreateHeaderL
|
|
1312 |
//
|
|
1313 |
// Creates the header.
|
|
1314 |
// ---------------------------------------------------------
|
|
1315 |
//
|
|
1316 |
void CMsgEditorView::CreateHeaderL()
|
|
1317 |
{
|
|
1318 |
__ASSERT_DEBUG( iHeader == NULL, Panic( EMsgHeaderAlreadyExists ) );
|
|
1319 |
|
|
1320 |
TMargins margins;
|
|
1321 |
|
|
1322 |
margins.iLeft = 0;
|
|
1323 |
margins.iRight = 0;
|
|
1324 |
margins.iTop = 0;
|
|
1325 |
margins.iBottom = 0;
|
|
1326 |
|
|
1327 |
iHeader = CMsgHeader::NewL( *this, margins );
|
|
1328 |
iHeader->SetObserver( this );
|
|
1329 |
}
|
|
1330 |
|
|
1331 |
// ---------------------------------------------------------
|
|
1332 |
// CMsgEditorView::CreateBodyL
|
|
1333 |
//
|
|
1334 |
// Creates the body. Creates also the default body control if requested.
|
|
1335 |
// ---------------------------------------------------------
|
|
1336 |
//
|
|
1337 |
void CMsgEditorView::CreateBodyL()
|
|
1338 |
{
|
|
1339 |
__ASSERT_DEBUG( iBody == NULL, Panic( EMsgBodyAlreadyExists ) );
|
|
1340 |
|
|
1341 |
TMargins margins;
|
|
1342 |
|
|
1343 |
margins.iLeft = 0;
|
|
1344 |
margins.iRight = 0;
|
|
1345 |
margins.iTop = 0;
|
|
1346 |
margins.iBottom = 0;
|
|
1347 |
|
|
1348 |
iBody = CMsgBody::NewL( *this, margins );
|
|
1349 |
iBody->SetObserver( this );
|
|
1350 |
|
|
1351 |
if ( !( iEditorModeFlags & EMsgDoNotUseDefaultBodyControl ) )
|
|
1352 |
{
|
|
1353 |
CMsgBaseControl* bodyControl = CMsgBodyControl::NewL( this );
|
|
1354 |
bodyControl->SetControlType( EMsgBodyControl );
|
|
1355 |
DoAddControlL( bodyControl, EMsgComponentIdBody, EMsgFirstControl, EMsgBody );
|
|
1356 |
}
|
|
1357 |
}
|
|
1358 |
|
|
1359 |
// ---------------------------------------------------------
|
|
1360 |
// CMsgEditorView::CreateScrollBarL
|
|
1361 |
//
|
|
1362 |
// Creates the scroll bar.
|
|
1363 |
// ---------------------------------------------------------
|
|
1364 |
//
|
|
1365 |
void CMsgEditorView::CreateScrollBarL()
|
|
1366 |
{
|
|
1367 |
__ASSERT_DEBUG( iScrollBar == NULL, Panic( EMsgScrollBarAlreadyExists ) );
|
|
1368 |
|
|
1369 |
iScrollBar = new ( ELeave ) CEikScrollBarFrame(
|
|
1370 |
this, // CCoeControl* aParentWindow
|
|
1371 |
this // MEikScrollBarObserver* aObserver
|
|
1372 |
);
|
|
1373 |
|
|
1374 |
// Check which type of scrollbar is to be shown
|
|
1375 |
if ( AknLayoutUtils::DefaultScrollBarType( iAvkonAppUi ) == CEikScrollBarFrame::EDoubleSpan )
|
|
1376 |
{
|
|
1377 |
// For EDoubleSpan type scrollbar
|
|
1378 |
// non-window owning scrollbar
|
|
1379 |
iScrollBar->CreateDoubleSpanScrollBarsL( EFalse, EFalse, ETrue, EFalse );
|
|
1380 |
iScrollBar->SetTypeOfVScrollBar( CEikScrollBarFrame::EDoubleSpan );
|
|
1381 |
|
|
1382 |
AknLayoutUtils::LayoutVerticalScrollBar(
|
|
1383 |
iScrollBar,
|
|
1384 |
TRect( TPoint( 0, 0 ),
|
|
1385 |
MsgEditorCommons::MsgMainPane().Size() ),
|
|
1386 |
AknLayoutScalable_Apps::scroll_pane_cp017().LayoutLine() );
|
|
1387 |
}
|
|
1388 |
else
|
|
1389 |
{
|
|
1390 |
// For EArrowHead type scrollbar
|
|
1391 |
iScrollBar->SetTypeOfVScrollBar( CEikScrollBarFrame::EArrowHead );
|
|
1392 |
}
|
|
1393 |
|
|
1394 |
iScrollBar->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
|
|
1395 |
CEikScrollBarFrame::EAuto );
|
|
1396 |
}
|
|
1397 |
|
|
1398 |
// ---------------------------------------------------------
|
|
1399 |
// CMsgEditorView::UpdateScrollBarL
|
|
1400 |
//
|
|
1401 |
// Updates the scroll bar.
|
|
1402 |
// ---------------------------------------------------------
|
|
1403 |
//
|
|
1404 |
void CMsgEditorView::UpdateScrollBarL()
|
|
1405 |
{
|
|
1406 |
TInt height( 0 );
|
|
1407 |
TInt pos( 0 );
|
|
1408 |
TInt windowSize( iViewRect.Height() - iBaseLineOffset );
|
|
1409 |
|
|
1410 |
// Round height up to the next full line height.
|
|
1411 |
MsgEditorCommons::RoundToNextLine( windowSize, iLineHeight );
|
|
1412 |
|
|
1413 |
GetVirtualFormHeightAndPos( height, pos );
|
|
1414 |
|
|
1415 |
// Round height up to the next full line height.
|
|
1416 |
MsgEditorCommons::RoundToNextLine( height, iLineHeight );
|
|
1417 |
|
|
1418 |
if ( pos < iLineHeight )
|
|
1419 |
{
|
|
1420 |
pos = 0;
|
|
1421 |
}
|
|
1422 |
|
|
1423 |
// Round position up to the next full line height.
|
|
1424 |
MsgEditorCommons::RoundToNextLine( pos, iLineHeight );
|
|
1425 |
|
|
1426 |
#ifdef _DEBUG
|
|
1427 |
// CAknScrollIndicator::SetPosition has an __ASSERT_DEBUG
|
|
1428 |
// for range check even if the control handles out-of-range
|
|
1429 |
// values properly.
|
|
1430 |
if ( pos > height ) pos = height;
|
|
1431 |
if ( pos < -1 ) pos = -1;
|
|
1432 |
|
|
1433 |
#endif
|
|
1434 |
|
|
1435 |
if ( iScrollBar->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan )
|
|
1436 |
{
|
|
1437 |
TAknDoubleSpanScrollBarModel vDsSbarModel;
|
|
1438 |
vDsSbarModel.SetScrollSpan( height );
|
|
1439 |
vDsSbarModel.SetWindowSize( windowSize );
|
|
1440 |
|
|
1441 |
pos = Max( 0, Min( height - windowSize, pos ) );
|
|
1442 |
|
|
1443 |
vDsSbarModel.SetFocusPosition( pos );
|
|
1444 |
|
|
1445 |
TEikScrollBarFrameLayout layout;
|
|
1446 |
layout.iTilingMode = TEikScrollBarFrameLayout::EInclusiveRectConstant;
|
|
1447 |
|
|
1448 |
// It seems to be important that we have separate
|
|
1449 |
// variable for "inclusiveRect" and "clientRect"
|
|
1450 |
TRect inclusiveRect( Rect() );
|
|
1451 |
TRect clientRect( Rect() );
|
|
1452 |
|
|
1453 |
iScrollBar->TileL( NULL, &vDsSbarModel, clientRect, inclusiveRect, layout );
|
|
1454 |
iScrollBar->SetVFocusPosToThumbPos( vDsSbarModel.FocusPosition() );
|
|
1455 |
|
|
1456 |
iViewFocusPosition = vDsSbarModel.FocusPosition();
|
|
1457 |
}
|
|
1458 |
else
|
|
1459 |
{
|
|
1460 |
TEikScrollBarModel vertModel;
|
|
1461 |
vertModel.iScrollSpan = height;
|
|
1462 |
vertModel.iThumbSpan = windowSize;
|
|
1463 |
vertModel.iThumbPosition = pos;
|
|
1464 |
|
|
1465 |
TEikScrollBarFrameLayout layout;
|
|
1466 |
|
|
1467 |
TRect rect( Rect() );
|
|
1468 |
iScrollBar->TileL( NULL, &vertModel, rect, rect, layout );
|
|
1469 |
iScrollBar->SetVFocusPosToThumbPos( vertModel.iThumbPosition );
|
|
1470 |
|
|
1471 |
iViewFocusPosition = vertModel.iThumbPosition;
|
|
1472 |
}
|
|
1473 |
|
|
1474 |
MsgEditorCommons::RoundToNextLine( iViewFocusPosition, iLineHeight );
|
|
1475 |
}
|
|
1476 |
|
|
1477 |
|
|
1478 |
// ---------------------------------------------------------
|
|
1479 |
// CMsgEditorView::GetVirtualFormHeightAndPos
|
|
1480 |
//
|
|
1481 |
// Return virtual height and virtual Y position of the form.
|
|
1482 |
// This function assumes that only body can contain controls which virtual
|
|
1483 |
// height must be calculated. Also this funtion assumes that only the
|
|
1484 |
// currently focused control in the body can contain text above visible
|
|
1485 |
// text view.
|
|
1486 |
// ---------------------------------------------------------
|
|
1487 |
//
|
|
1488 |
void CMsgEditorView::GetVirtualFormHeightAndPos( TInt& aHeight, TInt& aPos )
|
|
1489 |
{
|
|
1490 |
TInt screenHeight = MsgEditorCommons::EditorViewHeigth() - iBaseLineOffset;
|
|
1491 |
|
|
1492 |
TInt scrollPartsHeight( 0 );
|
|
1493 |
TInt abovePartHeight( 0 );
|
|
1494 |
|
|
1495 |
TInt bodyHeight( iBody->VirtualHeight() );
|
|
1496 |
|
|
1497 |
TInt headerHeight( 0 );
|
|
1498 |
|
|
1499 |
TBool headerLoaded( iHeader->CountMsgControls() );
|
|
1500 |
if ( headerLoaded )
|
|
1501 |
{
|
|
1502 |
// Header loaded so get header height and subtract base line offset
|
|
1503 |
// from it as header first control contains it and it is not scrollable
|
|
1504 |
// area.
|
|
1505 |
headerHeight = iHeader->VirtualHeight() - iBaseLineOffset;
|
|
1506 |
}
|
|
1507 |
else
|
|
1508 |
{
|
|
1509 |
// No header so baseline offset is added to the first body control's distance.
|
|
1510 |
// Baseline offset is not scrollable area so it must be subtracted from body height.
|
|
1511 |
bodyHeight -= iBaseLineOffset;
|
|
1512 |
}
|
|
1513 |
|
|
1514 |
iVisiblePartHeight = bodyHeight + headerHeight;
|
|
1515 |
|
|
1516 |
// Visible height is always at least one screen height.
|
|
1517 |
iVisiblePartHeight = Max( screenHeight, iVisiblePartHeight );
|
|
1518 |
|
|
1519 |
// Calculate total scroll parts high excluding visible part and
|
|
1520 |
// height of the scroll parts above visible part.
|
|
1521 |
TInt singlePartHeight = Max( screenHeight, iVisiblePartHeight / 10 );
|
|
1522 |
for ( TInt current = 0; current < iScrollParts; current++ )
|
|
1523 |
{
|
|
1524 |
if ( current != iVisiblePart )
|
|
1525 |
{
|
|
1526 |
scrollPartsHeight += singlePartHeight;
|
|
1527 |
|
|
1528 |
if ( current < iVisiblePart )
|
|
1529 |
{
|
|
1530 |
abovePartHeight = scrollPartsHeight;
|
|
1531 |
}
|
|
1532 |
}
|
|
1533 |
}
|
|
1534 |
|
|
1535 |
aHeight = iVisiblePartHeight + scrollPartsHeight;
|
|
1536 |
|
|
1537 |
if ( iCurrentFocus == EMsgBodyFocused )
|
|
1538 |
{
|
|
1539 |
TInt bodyExt = abovePartHeight + iBody->VirtualExtension();
|
|
1540 |
|
|
1541 |
if ( headerLoaded )
|
|
1542 |
{
|
|
1543 |
// Remove visible header pixels from header height.
|
|
1544 |
TInt visiblePixels( iHeader->Position().iY + iHeader->Size().iHeight - iBaseLineOffset );
|
|
1545 |
if ( visiblePixels > 0 )
|
|
1546 |
{
|
|
1547 |
headerHeight -= visiblePixels;
|
|
1548 |
}
|
|
1549 |
}
|
|
1550 |
else
|
|
1551 |
{
|
|
1552 |
// No header so baseline offset is added to the first body control's distance.
|
|
1553 |
// Baseline offset is not scrollable area so it must be subtracted from body extension.
|
|
1554 |
bodyExt -= iBaseLineOffset;
|
|
1555 |
}
|
|
1556 |
|
|
1557 |
aPos = headerHeight + bodyExt;
|
|
1558 |
|
|
1559 |
if ( iVisiblePart == ( iScrollParts - 1 ) )
|
|
1560 |
{
|
|
1561 |
// This ensures that if we at the end of the scroll area then scroll position is also
|
|
1562 |
// at the end.
|
|
1563 |
CMsgBaseControl* ctrl = FocusedControl();
|
|
1564 |
|
|
1565 |
if ( ctrl &&
|
|
1566 |
ctrl->IsCursorLocation( EMsgBottom ) &&
|
|
1567 |
NextFocusableFormControl( iBody,
|
|
1568 |
iBody->CurrentFocus() + 1,
|
|
1569 |
EMsgFocusDown ) == KErrNotFound )
|
|
1570 |
{
|
|
1571 |
// Further scrolling (down) not possible.
|
|
1572 |
aPos = aHeight;
|
|
1573 |
|
|
1574 |
if ( iScrollBar->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan )
|
|
1575 |
{
|
|
1576 |
// Focus position is top of the view.
|
|
1577 |
aPos -= screenHeight;
|
|
1578 |
}
|
|
1579 |
}
|
|
1580 |
}
|
|
1581 |
}
|
|
1582 |
else
|
|
1583 |
{
|
|
1584 |
aPos = abovePartHeight + iHeader->VirtualExtension() - iBaseLineOffset;
|
|
1585 |
}
|
|
1586 |
}
|
|
1587 |
|
|
1588 |
// ---------------------------------------------------------
|
|
1589 |
// CMsgEditorView::SetAndGetSizeL
|
|
1590 |
//
|
|
1591 |
// Sets sizes for the header and the body and returns their total size aSize
|
|
1592 |
// as a reference. The function does not set new sizes for the controls if
|
|
1593 |
// the aInit argument is EFalse. If aInit == ETrue, this function sets the size
|
|
1594 |
// so that only a total height can change.
|
|
1595 |
// ---------------------------------------------------------
|
|
1596 |
//
|
|
1597 |
void CMsgEditorView::SetAndGetSizeL( TSize& aSize, TBool aInit )
|
|
1598 |
{
|
|
1599 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
1600 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
1601 |
|
|
1602 |
if ( aInit && iStateFlags & EMsgStateInitialized )
|
|
1603 |
{
|
|
1604 |
// Size changing at run time. Set intializing flag on.
|
|
1605 |
iStateFlags |= EMsgStateInitializing;
|
|
1606 |
}
|
|
1607 |
|
|
1608 |
TSize editorSize( aSize );
|
|
1609 |
TSize headerSize( 0, 0 );
|
|
1610 |
TSize bodySize( 0, 0 );
|
|
1611 |
|
|
1612 |
headerSize = aSize;
|
|
1613 |
iHeader->SetAndGetSizeL( headerSize, aInit );
|
|
1614 |
|
|
1615 |
bodySize = aSize;
|
|
1616 |
iBody->SetAndGetSizeL( bodySize, aInit );
|
|
1617 |
|
|
1618 |
editorSize.iHeight = headerSize.iHeight + bodySize.iHeight;
|
|
1619 |
|
|
1620 |
// View size must always be the size of client rect. Don't change "iSize"!
|
|
1621 |
aSize = editorSize;
|
|
1622 |
|
|
1623 |
if ( aInit && iStateFlags & EMsgStateInitialized )
|
|
1624 |
{
|
|
1625 |
iStateFlags &= ~EMsgStateInitializing;
|
|
1626 |
}
|
|
1627 |
}
|
|
1628 |
|
|
1629 |
// ---------------------------------------------------------
|
|
1630 |
// CMsgEditorView::RefreshViewL
|
|
1631 |
//
|
|
1632 |
// Sets the positions for the controls and re-draws the view.
|
|
1633 |
// ---------------------------------------------------------
|
|
1634 |
//
|
|
1635 |
void CMsgEditorView::RefreshViewL()
|
|
1636 |
{
|
|
1637 |
iStateFlags |= EMsgStateRefreshing;
|
|
1638 |
|
|
1639 |
// Component must know their correct height by now.
|
|
1640 |
AdjustComponentDistances();
|
|
1641 |
|
|
1642 |
TSize editorSize( iViewRect.Size() );
|
|
1643 |
|
|
1644 |
// Called after AdjustComponentDistances because that
|
|
1645 |
// information is used on some components to calculate
|
|
1646 |
// their sizes
|
|
1647 |
SetAndGetSizeL( editorSize, ETrue );
|
|
1648 |
SizeChanged();
|
|
1649 |
|
|
1650 |
UpdateScrollBarL();
|
|
1651 |
|
|
1652 |
NotifyControlsForEvent( EMsgViewEventPrepareForViewing, 0 );
|
|
1653 |
DrawDeferred();
|
|
1654 |
|
|
1655 |
iStateFlags &= ~EMsgStateRefreshing;
|
|
1656 |
|
|
1657 |
EnsureCorrectFormPosition( EFalse );
|
|
1658 |
}
|
|
1659 |
|
|
1660 |
// ---------------------------------------------------------
|
|
1661 |
// CMsgEditorView::NotifyControlsForEvent
|
|
1662 |
//
|
|
1663 |
// Notifies controls for an event.
|
|
1664 |
// ---------------------------------------------------------
|
|
1665 |
//
|
|
1666 |
void CMsgEditorView::NotifyControlsForEvent( TMsgViewEvent aEvent, TInt aParam )
|
|
1667 |
{
|
|
1668 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
1669 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
1670 |
|
|
1671 |
iHeader->NotifyControlsForEvent( aEvent, aParam );
|
|
1672 |
iBody->NotifyControlsForEvent( aEvent, aParam );
|
|
1673 |
}
|
|
1674 |
|
|
1675 |
// ---------------------------------------------------------
|
|
1676 |
// CMsgEditorView::SetFocusByControlIdL
|
|
1677 |
//
|
|
1678 |
// Sets focus to a control aControlId. aSetCursorPos specified
|
|
1679 |
// whether cursor position should be set or not.
|
|
1680 |
// ---------------------------------------------------------
|
|
1681 |
//
|
|
1682 |
void CMsgEditorView::SetFocusByControlIdL( TInt aControlId,
|
|
1683 |
TBool aCorrectFormPosition,
|
|
1684 |
TBool aSetCursorPos )
|
|
1685 |
{
|
|
1686 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
1687 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
1688 |
__ASSERT_DEBUG( aControlId >= 0, Panic( EMsgIncorrectControlId ) );
|
|
1689 |
|
|
1690 |
NotifyControlsForEvent( EMsgViewEventFocusMoveStarting, 0 );
|
|
1691 |
|
|
1692 |
ReportFocusMovement( MMsgEditorObserver::EMsgFocusMovingFrom );
|
|
1693 |
|
|
1694 |
TInt componentIndex = iHeader->ComponentIndexFromId( aControlId );
|
|
1695 |
|
|
1696 |
if ( componentIndex != KErrNotFound )
|
|
1697 |
{
|
|
1698 |
// Control where focus is wanted to be moved was found from header.
|
|
1699 |
if ( iCurrentFocus == EMsgBodyFocused )
|
|
1700 |
{
|
|
1701 |
if (IsReadOnly()) // viewer
|
|
1702 |
{
|
|
1703 |
iBody->NotifyControlsForEvent( EMsgViewEventPrepareFocusTransitionUp, 0 );
|
|
1704 |
iBody->SetFocus( EFalse,
|
|
1705 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
1706 |
ENoDrawNow );
|
|
1707 |
}
|
|
1708 |
else
|
|
1709 |
{
|
|
1710 |
iBody->SetFocus( EFalse,
|
|
1711 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
1712 |
ENoDrawNow );
|
|
1713 |
iBody->NotifyControlsForEvent( EMsgViewEventPrepareFocusTransitionUp, 0 );
|
|
1714 |
}
|
|
1715 |
}
|
|
1716 |
|
|
1717 |
TMsgFocus previousMsgPart = iCurrentFocus;
|
|
1718 |
iCurrentFocus = EMsgHeaderFocused;
|
|
1719 |
|
|
1720 |
TInt delta = componentIndex - iHeader->CurrentFocus();
|
|
1721 |
|
|
1722 |
if ( delta != 0 )
|
|
1723 |
{
|
|
1724 |
iHeader->SetFocus( EFalse,
|
|
1725 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
1726 |
ENoDrawNow );
|
|
1727 |
iHeader->NotifyControlsForEvent( delta > 0 ? EMsgViewEventPrepareFocusTransitionDown :
|
|
1728 |
EMsgViewEventPrepareFocusTransitionUp,
|
|
1729 |
0 );
|
|
1730 |
}
|
|
1731 |
|
|
1732 |
// Do real focus movement when focus is moved between
|
|
1733 |
// message parts or when focus is moved inside message part
|
|
1734 |
// to different component. Do it also if currently focused
|
|
1735 |
// control does not have focus really.
|
|
1736 |
if ( componentIndex != iHeader->CurrentFocus() ||
|
|
1737 |
previousMsgPart != iCurrentFocus ||
|
|
1738 |
!iHeader->FocusedControl()->IsFocused() )
|
|
1739 |
{
|
|
1740 |
if ( !iHeader->ChangeFocusTo( componentIndex,
|
|
1741 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
1742 |
ENoDrawNow ) )
|
|
1743 |
{
|
|
1744 |
__ASSERT_DEBUG( EFalse, Panic( EMsgNonFocusingControl ) );
|
|
1745 |
}
|
|
1746 |
}
|
|
1747 |
}
|
|
1748 |
else
|
|
1749 |
{
|
|
1750 |
componentIndex = iBody->ComponentIndexFromId( aControlId );
|
|
1751 |
|
|
1752 |
if ( componentIndex != KErrNotFound )
|
|
1753 |
{
|
|
1754 |
// Control where focus is wanted to be moved was found from body.
|
|
1755 |
if ( iCurrentFocus == EMsgHeaderFocused )
|
|
1756 |
{
|
|
1757 |
if (IsReadOnly())
|
|
1758 |
{
|
|
1759 |
iHeader->NotifyControlsForEvent( EMsgViewEventPrepareFocusTransitionDown, 0 );
|
|
1760 |
iHeader->SetFocus( EFalse,
|
|
1761 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
1762 |
ENoDrawNow );
|
|
1763 |
}
|
|
1764 |
else
|
|
1765 |
{
|
|
1766 |
|
|
1767 |
iHeader->SetFocus( EFalse,
|
|
1768 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
1769 |
ENoDrawNow );
|
|
1770 |
iHeader->NotifyControlsForEvent( EMsgViewEventPrepareFocusTransitionDown, 0 );
|
|
1771 |
}
|
|
1772 |
}
|
|
1773 |
TMsgFocus previousMsgPart = iCurrentFocus;
|
|
1774 |
iPrevFocus = iCurrentFocus;
|
|
1775 |
iCurrentFocus = EMsgBodyFocused;
|
|
1776 |
|
|
1777 |
TInt delta = componentIndex - iBody->CurrentFocus();
|
|
1778 |
|
|
1779 |
if ( delta != 0 )
|
|
1780 |
{
|
|
1781 |
iBody->SetFocus( EFalse,
|
|
1782 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
1783 |
ENoDrawNow );
|
|
1784 |
iBody->NotifyControlsForEvent( delta ? EMsgViewEventPrepareFocusTransitionDown :
|
|
1785 |
EMsgViewEventPrepareFocusTransitionUp,
|
|
1786 |
0 );
|
|
1787 |
}
|
|
1788 |
|
|
1789 |
// Do real focus movement when focus is moved between
|
|
1790 |
// message parts or when focus is moved inside message part
|
|
1791 |
// to different component. Do it also if currently focused
|
|
1792 |
// control does not have focus really.
|
|
1793 |
if ( componentIndex != iBody->CurrentFocus() ||
|
|
1794 |
previousMsgPart != iCurrentFocus ||
|
|
1795 |
!iBody->FocusedControl()->IsFocused() )
|
|
1796 |
{
|
|
1797 |
CMsgBaseControl* ctrl = iBody->MsgControl( componentIndex );
|
|
1798 |
|
|
1799 |
if ( aSetCursorPos &&
|
|
1800 |
ctrl &&
|
|
1801 |
( ctrl->ControlType() == EMsgBodyControl ||
|
|
1802 |
ctrl->ControlType() == EMsgXhtmlBodyControl ) &&
|
|
1803 |
ctrl->ItemFinder() &&
|
|
1804 |
static_cast<CMsgBodyControl*>( ctrl )->Editor().TextView() )
|
|
1805 |
{
|
|
1806 |
ctrl->SetupAutomaticFindAfterFocusChangeL( iBody->CurrentFocus() <= componentIndex );
|
|
1807 |
}
|
|
1808 |
|
|
1809 |
if ( !iBody->ChangeFocusTo( componentIndex,
|
|
1810 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
1811 |
ENoDrawNow ) )
|
|
1812 |
{
|
|
1813 |
__ASSERT_DEBUG( EFalse, Panic( EMsgNonFocusingControl ) );
|
|
1814 |
}
|
|
1815 |
}
|
|
1816 |
}
|
|
1817 |
else
|
|
1818 |
{
|
|
1819 |
__ASSERT_DEBUG( EFalse, Panic( EMsgNoFocusingControlExist ) );
|
|
1820 |
}
|
|
1821 |
}
|
|
1822 |
|
|
1823 |
NotifyControlsForEvent( EMsgViewEventFocusMoveFinished, 0 );
|
|
1824 |
|
|
1825 |
ReportFocusMovement( MMsgEditorObserver::EMsgFocusMovedTo );
|
|
1826 |
|
|
1827 |
if ( aCorrectFormPosition )
|
|
1828 |
{
|
|
1829 |
EnsureCorrectFormPosition( IsReadOnly() );
|
|
1830 |
}
|
|
1831 |
|
|
1832 |
if ( aSetCursorPos &&
|
|
1833 |
IsReadOnly() &&
|
|
1834 |
FocusedControl() )
|
|
1835 |
{
|
|
1836 |
FocusedControl()->NotifyViewEvent( EMsgViewEventSetCursorLastPos, 0 );
|
|
1837 |
}
|
|
1838 |
}
|
|
1839 |
|
|
1840 |
// ---------------------------------------------------------
|
|
1841 |
// CMsgEditorView::DoAddControlL
|
|
1842 |
//
|
|
1843 |
// Does an actual add operation for the control by setting all the necessary
|
|
1844 |
// observers etc.
|
|
1845 |
// ---------------------------------------------------------
|
|
1846 |
//
|
|
1847 |
void CMsgEditorView::DoAddControlL( CMsgBaseControl* aControl,
|
|
1848 |
TInt aControlId,
|
|
1849 |
TInt aIndex,
|
|
1850 |
TMsgFormComponent aFormComponent )
|
|
1851 |
{
|
|
1852 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
1853 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
1854 |
|
|
1855 |
// set readonly for control here because readonly flag
|
|
1856 |
// may be needed before ActivateL call.
|
|
1857 |
TUint32 flags = aControl->ControlModeFlags();
|
|
1858 |
if ( IsReadOnly() ||
|
|
1859 |
flags & EMsgControlModeReadOnly )
|
|
1860 |
{
|
|
1861 |
flags |= EMsgControlModeReadOnly;
|
|
1862 |
}
|
|
1863 |
else
|
|
1864 |
{
|
|
1865 |
flags &= ~EMsgControlModeReadOnly;
|
|
1866 |
}
|
|
1867 |
aControl->SetControlModeFlags( flags );
|
|
1868 |
|
|
1869 |
if ( !aControl->OwnsWindow() )
|
|
1870 |
{
|
|
1871 |
aControl->SetContainerWindowL( *this );
|
|
1872 |
}
|
|
1873 |
|
|
1874 |
aControl->SetObserver( this );
|
|
1875 |
aControl->SetBaseControlObserver( *this );
|
|
1876 |
|
|
1877 |
if ( iEdwinObserver )
|
|
1878 |
{
|
|
1879 |
CEikRichTextEditor* editor = NULL;
|
|
1880 |
|
|
1881 |
if ( aControl->ControlType() == EMsgExpandableControl ||
|
|
1882 |
aControl->ControlType() == EMsgAddressControl )
|
|
1883 |
{
|
|
1884 |
editor = &static_cast<CMsgExpandableControl*>( aControl )->Editor();
|
|
1885 |
}
|
|
1886 |
else if ( aControl->ControlType() == EMsgBodyControl ||
|
|
1887 |
aControl->ControlType() == EMsgXhtmlBodyControl )
|
|
1888 |
{
|
|
1889 |
editor = &static_cast<CMsgBodyControl*>( aControl )->Editor();
|
|
1890 |
}
|
|
1891 |
|
|
1892 |
if ( editor )
|
|
1893 |
{
|
|
1894 |
editor->AddEdwinObserverL( iEdwinObserver );
|
|
1895 |
}
|
|
1896 |
}
|
|
1897 |
|
|
1898 |
aControl->MakeVisible( ETrue );
|
|
1899 |
aControl->ActivateL();
|
|
1900 |
|
|
1901 |
// this calls PrepareForReadOnly and sets flags again
|
|
1902 |
// but it doesn't matter.
|
|
1903 |
aControl->SetReadOnly( flags & EMsgControlModeReadOnly );
|
|
1904 |
|
|
1905 |
if ( aFormComponent == EMsgHeader )
|
|
1906 |
{
|
|
1907 |
iHeader->AddControlL( aControl, aControlId, aIndex );
|
|
1908 |
}
|
|
1909 |
else if ( aFormComponent == EMsgBody )
|
|
1910 |
{
|
|
1911 |
iBody->AddControlL( aControl, aControlId, aIndex );
|
|
1912 |
|
|
1913 |
if ( iHeader->CountMsgControls() == 0 )
|
|
1914 |
{
|
|
1915 |
iCurrentFocus = EMsgBodyFocused;
|
|
1916 |
}
|
|
1917 |
}
|
|
1918 |
else
|
|
1919 |
{
|
|
1920 |
__ASSERT_DEBUG( EFalse, Panic( EMsgIncorrectFormComponent ) );
|
|
1921 |
}
|
|
1922 |
|
|
1923 |
if ( aControl->UniqueHandle() == KErrNotFound )
|
|
1924 |
{
|
|
1925 |
// Control added first time. Set unique handle.
|
|
1926 |
aControl->SetUniqueHandle( iUniqueHandlePool );
|
|
1927 |
iUniqueHandlePool++;
|
|
1928 |
}
|
|
1929 |
|
|
1930 |
if ( iStateFlags & EMsgStateInitialized ) // Control is added on run-time.
|
|
1931 |
{
|
|
1932 |
TRAPD( err, RefreshViewL() );
|
|
1933 |
|
|
1934 |
if ( err != KErrNone )
|
|
1935 |
{
|
|
1936 |
// if RefreshViewL fails, remove the added control from internal
|
|
1937 |
// structures, i.e. transfer ownership back to caller.
|
|
1938 |
if ( aFormComponent == EMsgHeader )
|
|
1939 |
{
|
|
1940 |
iHeader->RemoveControlL( aControlId ); // does not leave.
|
|
1941 |
}
|
|
1942 |
else if ( aFormComponent == EMsgBody )
|
|
1943 |
{
|
|
1944 |
iBody->RemoveControlL( aControlId ); // does not leave.
|
|
1945 |
}
|
|
1946 |
|
|
1947 |
User::Leave( err );
|
|
1948 |
}
|
|
1949 |
else
|
|
1950 |
{
|
|
1951 |
// Set control initialized as it has been successfully added & activated.
|
|
1952 |
flags = aControl->ControlModeFlags();
|
|
1953 |
flags |= EMsgControlModeInitialized;
|
|
1954 |
aControl->SetControlModeFlags( flags );
|
|
1955 |
}
|
|
1956 |
}
|
|
1957 |
}
|
|
1958 |
|
|
1959 |
// ---------------------------------------------------------
|
|
1960 |
// CMsgEditorView::RotateFocusL
|
|
1961 |
//
|
|
1962 |
// Rotates focus up or down depending aDirection argument. Returns ETrue if
|
|
1963 |
// operation can be done.
|
|
1964 |
// ---------------------------------------------------------
|
|
1965 |
//
|
|
1966 |
TBool CMsgEditorView::RotateFocusL( TMsgFocusDirection aDirection,
|
|
1967 |
MMsgEditorObserver::TMsgFocusEvent& aFocusEvent )
|
|
1968 |
{
|
|
1969 |
__ASSERT_DEBUG( iHeader != NULL, Panic( EMsgHeaderNotExists ) );
|
|
1970 |
__ASSERT_DEBUG( iBody != NULL, Panic( EMsgBodyNotExists ) );
|
|
1971 |
|
|
1972 |
TBool startAutoFind = EFalse;
|
|
1973 |
TBool setMaxHeight = EFalse;
|
|
1974 |
|
|
1975 |
TInt newFocus = KErrNotFound;
|
|
1976 |
TInt controlIndex = 0;
|
|
1977 |
|
|
1978 |
CMsgFormComponent* currForm = NULL;
|
|
1979 |
CMsgFormComponent* nextForm = NULL;
|
|
1980 |
|
|
1981 |
if ( iCurrentFocus == EMsgHeaderFocused )
|
|
1982 |
{
|
|
1983 |
currForm = iHeader;
|
|
1984 |
controlIndex = iHeader->CurrentFocus();
|
|
1985 |
|
|
1986 |
if ( aDirection == EMsgFocusDown )
|
|
1987 |
{
|
|
1988 |
newFocus = NextFocusableFormControl( iHeader, controlIndex + 1, EMsgFocusDown );
|
|
1989 |
|
|
1990 |
if ( newFocus != KErrNotFound )
|
|
1991 |
{
|
|
1992 |
nextForm = iHeader;
|
|
1993 |
}
|
|
1994 |
else
|
|
1995 |
{
|
|
1996 |
newFocus = NextFocusableFormControl( iBody, 0, EMsgFocusDown );
|
|
1997 |
|
|
1998 |
if ( newFocus != KErrNotFound )
|
|
1999 |
{
|
|
2000 |
startAutoFind = ETrue;
|
|
2001 |
nextForm = iBody;
|
|
2002 |
aFocusEvent = MMsgEditorObserver::EMsgFocusToBody;
|
|
2003 |
}
|
|
2004 |
else
|
|
2005 |
{
|
|
2006 |
TInt currentlyFocused = iBody->CurrentFocus();
|
|
2007 |
|
|
2008 |
if ( IsFocusable( iBody->MsgControl( currentlyFocused ), EMsgFocusDown ) )
|
|
2009 |
{
|
|
2010 |
// Refocus the currently focused control.
|
|
2011 |
nextForm = iBody;
|
|
2012 |
startAutoFind = ETrue;
|
|
2013 |
newFocus = currentlyFocused;
|
|
2014 |
}
|
|
2015 |
|
|
2016 |
aFocusEvent = MMsgEditorObserver::EMsgFocusAtBottom;
|
|
2017 |
}
|
|
2018 |
}
|
|
2019 |
}
|
|
2020 |
else if ( aDirection == EMsgFocusUp )
|
|
2021 |
{
|
|
2022 |
newFocus = NextFocusableFormControl( iHeader, controlIndex - 1, EMsgFocusUp );
|
|
2023 |
|
|
2024 |
if ( newFocus != KErrNotFound )
|
|
2025 |
{
|
|
2026 |
nextForm = iHeader;
|
|
2027 |
}
|
|
2028 |
else
|
|
2029 |
{
|
|
2030 |
aFocusEvent = MMsgEditorObserver::EMsgFocusAtTop;
|
|
2031 |
}
|
|
2032 |
}
|
|
2033 |
}
|
|
2034 |
else if ( iCurrentFocus == EMsgBodyFocused )
|
|
2035 |
{
|
|
2036 |
currForm = iBody;
|
|
2037 |
controlIndex = iBody->CurrentFocus();
|
|
2038 |
|
|
2039 |
if ( aDirection == EMsgFocusDown )
|
|
2040 |
{
|
|
2041 |
newFocus = NextFocusableFormControl( iBody, controlIndex + 1, EMsgFocusDown );
|
|
2042 |
|
|
2043 |
if ( newFocus != KErrNotFound )
|
|
2044 |
{
|
|
2045 |
nextForm = iBody;
|
|
2046 |
}
|
|
2047 |
else
|
|
2048 |
{
|
|
2049 |
aFocusEvent = MMsgEditorObserver::EMsgFocusAtBottom;
|
|
2050 |
}
|
|
2051 |
}
|
|
2052 |
else if ( aDirection == EMsgFocusUp )
|
|
2053 |
{
|
|
2054 |
newFocus = NextFocusableFormControl( iBody, controlIndex - 1, EMsgFocusUp );
|
|
2055 |
|
|
2056 |
if ( newFocus != KErrNotFound )
|
|
2057 |
{
|
|
2058 |
nextForm = iBody;
|
|
2059 |
}
|
|
2060 |
else
|
|
2061 |
{
|
|
2062 |
newFocus = NextFocusableFormControl( iHeader, iHeader->CountMsgControls() - 1, EMsgFocusUp );
|
|
2063 |
setMaxHeight = ETrue;
|
|
2064 |
|
|
2065 |
if ( newFocus != KErrNotFound )
|
|
2066 |
{
|
|
2067 |
nextForm = iHeader;
|
|
2068 |
aFocusEvent = MMsgEditorObserver::EMsgFocusToHeader;
|
|
2069 |
}
|
|
2070 |
else
|
|
2071 |
{
|
|
2072 |
TInt currentlyFocused = iHeader->CurrentFocus();
|
|
2073 |
if ( IsFocusable( iHeader->MsgControl( currentlyFocused ), EMsgFocusUp ) )
|
|
2074 |
{
|
|
2075 |
// Refocus the currently focused control.
|
|
2076 |
nextForm = iHeader;
|
|
2077 |
newFocus = currentlyFocused;
|
|
2078 |
}
|
|
2079 |
|
|
2080 |
aFocusEvent = MMsgEditorObserver::EMsgFocusAtTop;
|
|
2081 |
}
|
|
2082 |
}
|
|
2083 |
}
|
|
2084 |
|
|
2085 |
if ( ( aFocusEvent == MMsgEditorObserver::EMsgFocusNone ||
|
|
2086 |
aFocusEvent == MMsgEditorObserver::EMsgFocusToBody ) &&
|
|
2087 |
( newFocus != controlIndex &&
|
|
2088 |
newFocus > KErrNotFound ) ) // for automatic highlight
|
|
2089 |
{
|
|
2090 |
// we assume that editor size is correct in this point
|
|
2091 |
startAutoFind = ETrue;
|
|
2092 |
}
|
|
2093 |
|
|
2094 |
}
|
|
2095 |
|
|
2096 |
if ( setMaxHeight )
|
|
2097 |
{
|
|
2098 |
CMsgBaseControl* ctrl = FocusedControl(); // for automatic highlight
|
|
2099 |
|
|
2100 |
if ( ctrl &&
|
|
2101 |
( ctrl->ControlType() == EMsgBodyControl ||
|
|
2102 |
ctrl->ControlType() == EMsgXhtmlBodyControl ) &&
|
|
2103 |
ctrl->ItemFinder() )
|
|
2104 |
{
|
|
2105 |
static_cast<CMsgBodyControl*>( ctrl )->Editor().SetMaximumHeight(
|
|
2106 |
MsgEditorCommons::MaxBodyHeight() );
|
|
2107 |
} // for automatic highlight
|
|
2108 |
}
|
|
2109 |
|
|
2110 |
if ( nextForm != NULL )
|
|
2111 |
{
|
|
2112 |
NotifyControlsForEvent( aDirection == EMsgFocusUp ? EMsgViewEventPrepareFocusTransitionUp :
|
|
2113 |
EMsgViewEventPrepareFocusTransitionDown,
|
|
2114 |
0 );
|
|
2115 |
|
|
2116 |
NotifyControlsForEvent( EMsgViewEventFocusMoveStarting, 0 );
|
|
2117 |
|
|
2118 |
ReportFocusMovement( MMsgEditorObserver::EMsgFocusMovingFrom );
|
|
2119 |
|
|
2120 |
if ( nextForm == currForm )
|
|
2121 |
{
|
|
2122 |
currForm->ChangeFocusTo( newFocus,
|
|
2123 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
2124 |
ENoDrawNow );
|
|
2125 |
}
|
|
2126 |
else
|
|
2127 |
{
|
|
2128 |
currForm->SetFocus( EFalse,
|
|
2129 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
2130 |
ENoDrawNow );
|
|
2131 |
iCurrentFocus = ( nextForm == iBody ) ? EMsgBodyFocused :
|
|
2132 |
EMsgHeaderFocused;
|
|
2133 |
|
|
2134 |
nextForm->ChangeFocusTo( newFocus,
|
|
2135 |
iStateFlags & EMsgStateInitialized ? EDrawNow :
|
|
2136 |
ENoDrawNow );
|
|
2137 |
}
|
|
2138 |
|
|
2139 |
CMsgBaseControl* focusedControl = FocusedControl();
|
|
2140 |
|
|
2141 |
if ( focusedControl )
|
|
2142 |
{
|
|
2143 |
if ( aDirection == EMsgFocusDown )
|
|
2144 |
{
|
|
2145 |
focusedControl->NotifyViewEvent( EMsgViewEventSetCursorFirstPos, 0 );
|
|
2146 |
}
|
|
2147 |
else if ( aDirection == EMsgFocusUp )
|
|
2148 |
{
|
|
2149 |
focusedControl->NotifyViewEvent( EMsgViewEventSetCursorLastPos, 0 );
|
|
2150 |
}
|
|
2151 |
}
|
|
2152 |
|
|
2153 |
NotifyControlsForEvent( EMsgViewEventFocusMoveFinished, 0 );
|
|
2154 |
|
|
2155 |
ReportFocusMovement( MMsgEditorObserver::EMsgFocusMovedTo );
|
|
2156 |
}
|
|
2157 |
else
|
|
2158 |
{
|
|
2159 |
CMsgBaseControl* focusedControl = FocusedControl();
|
|
2160 |
|
|
2161 |
if ( !IsReadOnly() && focusedControl && !startAutoFind )
|
|
2162 |
{
|
|
2163 |
// Focus is tried to move to direction that does not cause any focus
|
|
2164 |
// changes (either up when already at the topmost position or down when
|
|
2165 |
// already at the bottommost position) on editor.
|
|
2166 |
// => Set focused cursor position to either last or first position if we
|
|
2167 |
// are at last or first scroll part.
|
|
2168 |
if ( aDirection == EMsgFocusDown &&
|
|
2169 |
iVisiblePart == iScrollParts - 1 )
|
|
2170 |
{
|
|
2171 |
if ( focusedControl->ControlType() == EMsgBodyControl ||
|
|
2172 |
focusedControl->ControlType() == EMsgXhtmlBodyControl )
|
|
2173 |
{
|
|
2174 |
CEikRichTextEditor& editor = static_cast<CMsgBodyControl*>( focusedControl )->Editor();
|
|
2175 |
editor.SetCursorPosL( editor.TextLength(), EFalse );
|
|
2176 |
}
|
|
2177 |
else if ( focusedControl->ControlType() == EMsgExpandableControl ||
|
|
2178 |
focusedControl->ControlType() == EMsgAddressControl )
|
|
2179 |
{
|
|
2180 |
CEikRichTextEditor& editor =
|
|
2181 |
static_cast<CMsgExpandableControl*>( focusedControl )->Editor();
|
|
2182 |
editor.SetCursorPosL( editor.TextLength(), EFalse );
|
|
2183 |
|
|
2184 |
if ( focusedControl->ControlType() == EMsgAddressControl )
|
|
2185 |
{
|
|
2186 |
// Update the address field highlighting
|
|
2187 |
static_cast<CMsgAddressControlEditor&>( editor ).CheckHighlightingL();
|
|
2188 |
}
|
|
2189 |
}
|
|
2190 |
}
|
|
2191 |
else if ( aDirection == EMsgFocusUp &&
|
|
2192 |
iVisiblePart == 0)
|
|
2193 |
{
|
|
2194 |
if ( focusedControl->ControlType() == EMsgBodyControl ||
|
|
2195 |
focusedControl->ControlType() == EMsgXhtmlBodyControl )
|
|
2196 |
{
|
|
2197 |
CEikRichTextEditor& editor = static_cast<CMsgBodyControl*>( focusedControl )->Editor();
|
|
2198 |
editor.SetCursorPosL( 0, EFalse );
|
|
2199 |
}
|
|
2200 |
else if ( focusedControl->ControlType() == EMsgExpandableControl ||
|
|
2201 |
focusedControl->ControlType() == EMsgAddressControl )
|
|
2202 |
{
|
|
2203 |
CEikRichTextEditor& editor =
|
|
2204 |
static_cast<CMsgExpandableControl*>( focusedControl )->Editor();
|
|
2205 |
editor.SetCursorPosL( 0, EFalse );
|
|
2206 |
|
|
2207 |
if ( focusedControl->ControlType() == EMsgAddressControl )
|
|
2208 |
{
|
|
2209 |
// Update the address field highlighting
|
|
2210 |
static_cast<CMsgAddressControlEditor&>( editor ).CheckHighlightingL();
|
|
2211 |
}
|
|
2212 |
}
|
|
2213 |
}
|
|
2214 |
}
|
|
2215 |
}
|
|
2216 |
|
|
2217 |
if ( startAutoFind )
|
|
2218 |
{
|
|
2219 |
CMsgBaseControl* ctrl = (CMsgBaseControl*)iBody->MsgControl( newFocus );
|
|
2220 |
|
|
2221 |
if ( ctrl &&
|
|
2222 |
( ctrl->ControlType() == EMsgBodyControl ||
|
|
2223 |
ctrl->ControlType() == EMsgXhtmlBodyControl ) &&
|
|
2224 |
ctrl->ItemFinder() &&
|
|
2225 |
static_cast<CMsgBodyControl*>( ctrl )->Editor().TextView() )
|
|
2226 |
{
|
|
2227 |
ctrl->SetupAutomaticFindAfterFocusChangeL( aDirection == EMsgFocusDown );
|
|
2228 |
}
|
|
2229 |
}
|
|
2230 |
|
|
2231 |
return newFocus != KErrNotFound;
|
|
2232 |
}
|
|
2233 |
|
|
2234 |
// ---------------------------------------------------------
|
|
2235 |
// CMsgEditorView::EnsureCorrectFormPosition
|
|
2236 |
//
|
|
2237 |
// Ensures that the cursor is visible on the view and that the form position
|
|
2238 |
// is correct.
|
|
2239 |
// ---------------------------------------------------------
|
|
2240 |
//
|
|
2241 |
TBool CMsgEditorView::EnsureCorrectFormPosition( TBool /*aScrollDown*/, TBool /*aScrollUp*/ )
|
|
2242 |
{
|
|
2243 |
CMsgBaseControl* ctrl = FocusedControl();
|
|
2244 |
if ( !ctrl )
|
|
2245 |
{
|
|
2246 |
return EFalse;
|
|
2247 |
}
|
|
2248 |
else
|
|
2249 |
{
|
|
2250 |
if ( ctrl->ControlType() == EMsgBodyControl
|
|
2251 |
&& ctrl->ItemFinder()
|
|
2252 |
&& ctrl->IsReadOnly()
|
|
2253 |
&& !iMoveUpDownEvent )
|
|
2254 |
{
|
|
2255 |
TInt countHeader = iHeader->CountMsgControls();
|
|
2256 |
for ( TInt i = 0; i < countHeader; i++ )
|
|
2257 |
{
|
|
2258 |
CMsgBaseControl* headerCtrl = iHeader->MsgControl( i );
|
|
2259 |
if ( headerCtrl )
|
|
2260 |
{
|
|
2261 |
TInt controlType;
|
|
2262 |
controlType = headerCtrl->ControlType();
|
|
2263 |
if ( controlType == EMsgAddressControl ||
|
|
2264 |
controlType == EMsgExpandableControl ||
|
|
2265 |
controlType == EMsgAttachmentControl )
|
|
2266 |
{
|
|
2267 |
if ( ControlFullyVisible(headerCtrl) || iPrevFocus == EMsgHeaderFocused )
|
|
2268 |
{
|
|
2269 |
return EFalse; // Ignoring Scroll Event
|
|
2270 |
}
|
|
2271 |
}
|
|
2272 |
}
|
|
2273 |
}
|
|
2274 |
}
|
|
2275 |
}
|
|
2276 |
|
|
2277 |
iStateFlags |= EMsgEnsureCorrectFormPositionRequestIssued;
|
|
2278 |
|
|
2279 |
TInt delta = 0;
|
|
2280 |
TBool viewScrolled = ETrue;
|
|
2281 |
TRect lineRect = ctrl->IsReadOnly() ? ctrl->Rect() :
|
|
2282 |
ctrl->CurrentLineRect();
|
|
2283 |
|
|
2284 |
if ( lineRect.Height() )
|
|
2285 |
{
|
|
2286 |
if ( lineRect.iBr.iY > iViewRect.Height() )
|
|
2287 |
{
|
|
2288 |
// the view must be scrolled up.
|
|
2289 |
delta = iViewRect.Height() - lineRect.iBr.iY;
|
|
2290 |
}
|
|
2291 |
else if ( lineRect.iTl.iY < 0 &&
|
|
2292 |
lineRect.Height() <= iViewRect.Height() )
|
|
2293 |
{
|
|
2294 |
// the view must be scrolled down.
|
|
2295 |
delta = -lineRect.iTl.iY;
|
|
2296 |
}
|
|
2297 |
|
|
2298 |
// Adjust to next(/previous) baseline
|
|
2299 |
if ( delta > 0 )
|
|
2300 |
{
|
|
2301 |
MsgEditorCommons::RoundToNextLine( delta, iLineHeight );
|
|
2302 |
}
|
|
2303 |
else
|
|
2304 |
{
|
|
2305 |
MsgEditorCommons::RoundToPreviousLine( delta, iLineHeight );
|
|
2306 |
}
|
|
2307 |
}
|
|
2308 |
|
|
2309 |
if ( delta )
|
|
2310 |
{
|
|
2311 |
EnsureCorrectCursorPosition();
|
|
2312 |
|
|
2313 |
viewScrolled = EFalse;
|
|
2314 |
ScrollForm( delta, ETrue );
|
|
2315 |
}
|
|
2316 |
|
|
2317 |
iStateFlags &= ~EMsgEnsureCorrectFormPositionRequestIssued;
|
|
2318 |
|
|
2319 |
return viewScrolled;
|
|
2320 |
}
|
|
2321 |
|
|
2322 |
// ---------------------------------------------------------
|
|
2323 |
// CMsgEditorView::HandleHeightChangedL
|
|
2324 |
//
|
|
2325 |
// Handles the form's height change. Gets pointer aControl to a control which
|
|
2326 |
// height is changing. If aDeltaHeight > 0 the height is increasing.
|
|
2327 |
// Assumes that control's size has already been changed.
|
|
2328 |
// ---------------------------------------------------------
|
|
2329 |
//
|
|
2330 |
TBool CMsgEditorView::HandleHeightChangedL( CMsgBaseControl* /*aControl*/,
|
|
2331 |
TInt /*aDeltaHeight*/ )
|
|
2332 |
{
|
|
2333 |
MEBLOGGER_ENTERFN( "CMsgEditorView::HandleHeightChangedL" );
|
|
2334 |
|
|
2335 |
TSize headerSize = iHeader->Size();
|
|
2336 |
|
|
2337 |
TSize size( headerSize + iBody->Size() );
|
|
2338 |
TSize thisSize( iViewRect.Size() );
|
|
2339 |
|
|
2340 |
SetAndGetSizeL( thisSize, EFalse );
|
|
2341 |
|
|
2342 |
if ( size.iHeight != thisSize.iHeight )
|
|
2343 |
{
|
|
2344 |
SizeChanged();
|
|
2345 |
}
|
|
2346 |
|
|
2347 |
if ( ViewInitialized() )
|
|
2348 |
{
|
|
2349 |
if ( headerSize != iHeader->Size() )
|
|
2350 |
{
|
|
2351 |
DrawNow();
|
|
2352 |
}
|
|
2353 |
else
|
|
2354 |
{
|
|
2355 |
DrawDeferred();
|
|
2356 |
}
|
|
2357 |
}
|
|
2358 |
|
|
2359 |
MEBLOGGER_ENTERFN( "CMsgEditorView::HandleHeightChangedL" );
|
|
2360 |
|
|
2361 |
return ETrue;
|
|
2362 |
}
|
|
2363 |
|
|
2364 |
// ---------------------------------------------------------
|
|
2365 |
// CMsgEditorView::ScrollForm
|
|
2366 |
//
|
|
2367 |
// Scrolls the form up or down depending on aDelta. If aDelta > 0, the form
|
|
2368 |
// scrolls down. Form offset should also be less or equal to 0.
|
|
2369 |
// ---------------------------------------------------------
|
|
2370 |
//
|
|
2371 |
TBool CMsgEditorView::ScrollForm( TInt aDelta, TBool aUpdateScrollBarPos )
|
|
2372 |
{
|
|
2373 |
TBool result( ETrue );
|
|
2374 |
|
|
2375 |
if ( iFormOffset + aDelta > 0 )
|
|
2376 |
{
|
|
2377 |
// Scrolling form given amount of pixels would result form to go above
|
|
2378 |
// it's uppermost position.
|
|
2379 |
aDelta = -iFormOffset;
|
|
2380 |
|
|
2381 |
result = EFalse;
|
|
2382 |
}
|
|
2383 |
|
|
2384 |
if ( aDelta != 0 )
|
|
2385 |
{
|
|
2386 |
iFormOffset += aDelta;
|
|
2387 |
|
|
2388 |
// Real scrolling is performed here.
|
|
2389 |
SizeChanged();
|
|
2390 |
|
|
2391 |
// Do not redraw the screen if we are in the middle of state refreshing.
|
|
2392 |
if ( !( iStateFlags & EMsgStateRefreshing ) )
|
|
2393 |
{
|
|
2394 |
DrawNow();
|
|
2395 |
}
|
|
2396 |
|
|
2397 |
NotifyControlsForEvent( EMsgViewEventFormScrolled, aDelta );
|
|
2398 |
|
|
2399 |
if ( aUpdateScrollBarPos )
|
|
2400 |
{
|
|
2401 |
iViewFocusPosition -= aDelta;
|
|
2402 |
|
|
2403 |
const TAknDoubleSpanScrollBarModel* model = AknScrollBarModel();
|
|
2404 |
|
|
2405 |
if ( model )
|
|
2406 |
{
|
|
2407 |
iScrollBar->MoveThumbsBy( 0, -aDelta );
|
|
2408 |
}
|
|
2409 |
}
|
|
2410 |
}
|
|
2411 |
|
|
2412 |
return result;
|
|
2413 |
}
|
|
2414 |
|
|
2415 |
// ---------------------------------------------------------
|
|
2416 |
// CMsgEditorView::SetViewRect
|
|
2417 |
//
|
|
2418 |
// Sets view rect.
|
|
2419 |
// ---------------------------------------------------------
|
|
2420 |
//
|
|
2421 |
void CMsgEditorView::SetViewRect( const TRect& /*aRect*/ )
|
|
2422 |
{
|
|
2423 |
iViewRect = MsgEditorCommons::MsgMainPane();
|
|
2424 |
|
|
2425 |
Window().SetExtent( iViewRect.iTl, iViewRect.Size() );
|
|
2426 |
}
|
|
2427 |
|
|
2428 |
// ---------------------------------------------------------
|
|
2429 |
// CMsgEditorView::AdjustComponentDistances
|
|
2430 |
//
|
|
2431 |
// Set proper distances between controls to obey LAF coordinates.
|
|
2432 |
//
|
|
2433 |
// Note: Components must know their correct height when this function
|
|
2434 |
// is called.
|
|
2435 |
// ---------------------------------------------------------
|
|
2436 |
//
|
|
2437 |
void CMsgEditorView::AdjustComponentDistances()
|
|
2438 |
{
|
|
2439 |
TInt i;
|
|
2440 |
CMsgBaseControl* ctrl;
|
|
2441 |
TInt controlType;
|
|
2442 |
TInt countHeader = iHeader->CountMsgControls();
|
|
2443 |
TInt countBody = iBody->CountMsgControls();
|
|
2444 |
|
|
2445 |
TInt baseLine = iLineHeight;
|
|
2446 |
TInt firstComponentOffset = iBaseLineOffset;
|
|
2447 |
|
|
2448 |
// beforeOffset + control height + afterOffset
|
|
2449 |
// must be multiple of baseLine!
|
|
2450 |
TInt beforeOffset = 0;
|
|
2451 |
TInt afterOffset = 0;
|
|
2452 |
TInt distance = 0;
|
|
2453 |
|
|
2454 |
for ( i = 0; i < countHeader; i++ )
|
|
2455 |
{
|
|
2456 |
ctrl = iHeader->MsgControl( i );
|
|
2457 |
if ( ctrl )
|
|
2458 |
{
|
|
2459 |
controlType = ctrl->ControlType();
|
|
2460 |
|
|
2461 |
if ( controlType == EMsgAddressControl ||
|
|
2462 |
controlType == EMsgExpandableControl ||
|
|
2463 |
controlType == EMsgAttachmentControl )
|
|
2464 |
{
|
|
2465 |
distance = ( i == 0 ) ? firstComponentOffset :
|
|
2466 |
0;
|
|
2467 |
distance += afterOffset;
|
|
2468 |
|
|
2469 |
// At least in APAC there's offset in the header
|
|
2470 |
// fields. A header field is 21 pixels high whereas
|
|
2471 |
// the baseline is 19 pixels.
|
|
2472 |
TInt offset = -( ctrl->Size().iHeight % baseLine );
|
|
2473 |
// TODO: Minor MAGIC
|
|
2474 |
// header frames take 3 pixels so it's ok to
|
|
2475 |
// have offset of "-3".
|
|
2476 |
if ( offset < -3 )
|
|
2477 |
{
|
|
2478 |
offset += baseLine;
|
|
2479 |
}
|
|
2480 |
// divide offset evenly between before and after offset
|
|
2481 |
//beforeOffset = offset / 2;
|
|
2482 |
//afterOffset = offset - beforeOffset;
|
|
2483 |
//distance += beforeOffset;
|
|
2484 |
distance += offset;
|
|
2485 |
|
|
2486 |
ctrl->SetDistanceFromComponentAbove( distance );
|
|
2487 |
}
|
|
2488 |
}
|
|
2489 |
}
|
|
2490 |
|
|
2491 |
for ( i = 0; i < countBody; i++ )
|
|
2492 |
{
|
|
2493 |
ctrl = iBody->MsgControl( i );
|
|
2494 |
|
|
2495 |
if ( ctrl )
|
|
2496 |
{
|
|
2497 |
if ( i == 0 )
|
|
2498 |
{
|
|
2499 |
distance = ( countHeader == 0 ) ? firstComponentOffset :
|
|
2500 |
0;
|
|
2501 |
}
|
|
2502 |
else
|
|
2503 |
{
|
|
2504 |
distance = baseLine;
|
|
2505 |
}
|
|
2506 |
|
|
2507 |
distance += afterOffset;
|
|
2508 |
|
|
2509 |
controlType = ctrl->ControlType();
|
|
2510 |
|
|
2511 |
switch ( controlType )
|
|
2512 |
{
|
|
2513 |
case EMsgImageControl:
|
|
2514 |
case EMsgAudioControl:
|
|
2515 |
{
|
|
2516 |
// Image control height is always
|
|
2517 |
// multiple of baseLine
|
|
2518 |
beforeOffset = 0;
|
|
2519 |
afterOffset = 0;
|
|
2520 |
break;
|
|
2521 |
}
|
|
2522 |
case EMsgVideoControl:
|
|
2523 |
{
|
|
2524 |
// Video must be precisely at the top of the screen.
|
|
2525 |
beforeOffset = -firstComponentOffset;
|
|
2526 |
// Video control height is not multiple of baseLine
|
|
2527 |
// -> calculate offset
|
|
2528 |
afterOffset = firstComponentOffset -
|
|
2529 |
( ctrl->Size().iHeight % baseLine );
|
|
2530 |
break;
|
|
2531 |
}
|
|
2532 |
default:
|
|
2533 |
{
|
|
2534 |
beforeOffset = 0;
|
|
2535 |
afterOffset = 0;
|
|
2536 |
break;
|
|
2537 |
}
|
|
2538 |
}
|
|
2539 |
distance += beforeOffset;
|
|
2540 |
|
|
2541 |
ctrl->SetDistanceFromComponentAbove( distance );
|
|
2542 |
|
|
2543 |
// TODO: Is this the correct place to check this?!
|
|
2544 |
if ( !IsReadOnly() &&
|
|
2545 |
( controlType == EMsgBodyControl ||
|
|
2546 |
controlType == EMsgXhtmlBodyControl ) )
|
|
2547 |
{
|
|
2548 |
TUint32 flags = ctrl->ControlModeFlags();
|
|
2549 |
if ( iBody->ComponentIndexFromId( EMsgComponentIdBody ) ==
|
|
2550 |
countBody - 1 )
|
|
2551 |
{
|
|
2552 |
// In editor mode bodycontrol must have max height
|
|
2553 |
// if it's the last control in msg body even if it
|
|
2554 |
// has no text so that all editor lines are drawn.
|
|
2555 |
flags |= EMsgControlModeBodyMaxHeight;
|
|
2556 |
}
|
|
2557 |
else
|
|
2558 |
{
|
|
2559 |
flags &= ~EMsgControlModeBodyMaxHeight;
|
|
2560 |
}
|
|
2561 |
|
|
2562 |
ctrl->SetControlModeFlags( flags );
|
|
2563 |
}
|
|
2564 |
}
|
|
2565 |
}
|
|
2566 |
}
|
|
2567 |
|
|
2568 |
// ---------------------------------------------------------
|
|
2569 |
// CMsgEditorView::SetComponentsInitialized
|
|
2570 |
//
|
|
2571 |
// Set all controls initialized.
|
|
2572 |
// ---------------------------------------------------------
|
|
2573 |
//
|
|
2574 |
void CMsgEditorView::SetComponentsInitialized()
|
|
2575 |
{
|
|
2576 |
TInt i;
|
|
2577 |
CMsgBaseControl* ctrl;
|
|
2578 |
TInt countHeader = iHeader->CountMsgControls();
|
|
2579 |
TInt countBody = iBody->CountMsgControls();
|
|
2580 |
|
|
2581 |
TUint32 flags;
|
|
2582 |
|
|
2583 |
for ( i = 0; i < countHeader; i++ )
|
|
2584 |
{
|
|
2585 |
ctrl = iHeader->MsgControl( i );
|
|
2586 |
|
|
2587 |
if ( ctrl )
|
|
2588 |
{
|
|
2589 |
flags = ctrl->ControlModeFlags();
|
|
2590 |
flags |= EMsgControlModeInitialized;
|
|
2591 |
ctrl->SetControlModeFlags( flags );
|
|
2592 |
}
|
|
2593 |
}
|
|
2594 |
|
|
2595 |
for ( i = 0; i < countBody; i++ )
|
|
2596 |
{
|
|
2597 |
ctrl = iBody->MsgControl( i );
|
|
2598 |
|
|
2599 |
if ( ctrl )
|
|
2600 |
{
|
|
2601 |
flags = ctrl->ControlModeFlags();
|
|
2602 |
flags |= EMsgControlModeInitialized;
|
|
2603 |
ctrl->SetControlModeFlags( flags );
|
|
2604 |
}
|
|
2605 |
}
|
|
2606 |
}
|
|
2607 |
|
|
2608 |
|
|
2609 |
// ---------------------------------------------------------
|
|
2610 |
// CMsgEditorView::SetAfterFocusL
|
|
2611 |
//
|
|
2612 |
//
|
|
2613 |
//
|
|
2614 |
// ---------------------------------------------------------
|
|
2615 |
//
|
|
2616 |
TBool CMsgEditorView::SetAfterFocusL( MMsgEditorObserver::TMsgAfterFocusEventFunc aAfterFocus )
|
|
2617 |
{
|
|
2618 |
TBool forceScrollUp = EFalse;
|
|
2619 |
CMsgBaseControl* ctrl;
|
|
2620 |
TInt newFocus;
|
|
2621 |
CMsgBodyControl* body = static_cast<CMsgBodyControl*>( ControlById( EMsgComponentIdBody ) );
|
|
2622 |
CEikRichTextEditor* bodyEditor = NULL;
|
|
2623 |
|
|
2624 |
if ( body )
|
|
2625 |
{
|
|
2626 |
bodyEditor = &body->Editor();
|
|
2627 |
body->SetupAutomaticFindAfterFocusChangeL(
|
|
2628 |
aAfterFocus == MMsgEditorObserver::EMsgCursorToBodyBeginning );
|
|
2629 |
}
|
|
2630 |
|
|
2631 |
if ( aAfterFocus == MMsgEditorObserver::EMsgCursorToBodyBeginning )
|
|
2632 |
{
|
|
2633 |
newFocus = iBody->FirstFocusableControl( 0, EMsgFocusDown );
|
|
2634 |
|
|
2635 |
if ( newFocus != KErrNotFound )
|
|
2636 |
{
|
|
2637 |
ctrl = iBody->MsgControl( newFocus );
|
|
2638 |
SetFocusByControlIdL( ctrl->ControlId() );
|
|
2639 |
|
|
2640 |
if ( bodyEditor )
|
|
2641 |
{
|
|
2642 |
bodyEditor->SetCursorPosL( 0, EFalse );
|
|
2643 |
}
|
|
2644 |
}
|
|
2645 |
}
|
|
2646 |
else if ( aAfterFocus == MMsgEditorObserver::EMsgCursorToBodyEnd )
|
|
2647 |
{
|
|
2648 |
newFocus = iBody->FirstFocusableControl( iBody->CountMsgControls() - 1, EMsgFocusUp );
|
|
2649 |
|
|
2650 |
if ( newFocus == KErrNotFound )
|
|
2651 |
{
|
|
2652 |
// empty body perhaps...
|
|
2653 |
newFocus = iHeader->FirstFocusableControl( iHeader->CountMsgControls() - 1, EMsgFocusUp );
|
|
2654 |
|
|
2655 |
if ( newFocus != KErrNotFound )
|
|
2656 |
{
|
|
2657 |
ctrl = iHeader->MsgControl( newFocus );
|
|
2658 |
SetFocusByControlIdL( ctrl->ControlId(), EFalse );
|
|
2659 |
}
|
|
2660 |
}
|
|
2661 |
else
|
|
2662 |
{
|
|
2663 |
ctrl = iBody->MsgControl( newFocus );
|
|
2664 |
SetFocusByControlIdL( ctrl->ControlId(), EFalse );
|
|
2665 |
|
|
2666 |
if ( bodyEditor )
|
|
2667 |
{
|
|
2668 |
bodyEditor->SetCursorPosL( bodyEditor->TextLength(), EFalse );
|
|
2669 |
}
|
|
2670 |
|
|
2671 |
forceScrollUp = ETrue;
|
|
2672 |
}
|
|
2673 |
}
|
|
2674 |
return forceScrollUp;
|
|
2675 |
}
|
|
2676 |
|
|
2677 |
// ---------------------------------------------------------
|
|
2678 |
// CMsgEditorView::ItemFinder
|
|
2679 |
//
|
|
2680 |
// ---------------------------------------------------------
|
|
2681 |
//
|
|
2682 |
EXPORT_C CItemFinder* CMsgEditorView::ItemFinder()
|
|
2683 |
{
|
|
2684 |
if ( iBody )
|
|
2685 |
{
|
|
2686 |
CMsgBaseControl* ctrl;
|
|
2687 |
TInt countBody = iBody->CountMsgControls();
|
|
2688 |
|
|
2689 |
for ( TInt i = 0; i < countBody; i++ )
|
|
2690 |
{
|
|
2691 |
ctrl = iBody->MsgControl( i );
|
|
2692 |
if ( ctrl &&
|
|
2693 |
( ctrl->ControlType() == EMsgBodyControl ||
|
|
2694 |
ctrl->ControlType() == EMsgXhtmlBodyControl ) )
|
|
2695 |
{
|
|
2696 |
return ctrl->ItemFinder();
|
|
2697 |
}
|
|
2698 |
}
|
|
2699 |
}
|
|
2700 |
return 0;
|
|
2701 |
}
|
|
2702 |
|
|
2703 |
// ---------------------------------------------------------
|
|
2704 |
// CMsgEditorView::SetEdwinObserverL
|
|
2705 |
//
|
|
2706 |
// ---------------------------------------------------------
|
|
2707 |
//
|
|
2708 |
EXPORT_C void CMsgEditorView::SetEdwinObserverL( MEikEdwinObserver* aObserver )
|
|
2709 |
{
|
|
2710 |
iEdwinObserver = aObserver;
|
|
2711 |
|
|
2712 |
TInt headerControlCount = iHeader->CountMsgControls();
|
|
2713 |
TInt controlCount = headerControlCount + iBody->CountMsgControls();
|
|
2714 |
|
|
2715 |
for ( TInt controlIndex = 0; controlIndex < controlCount; controlIndex++ )
|
|
2716 |
{
|
|
2717 |
CMsgBaseControl* control = NULL;
|
|
2718 |
if ( controlIndex < headerControlCount )
|
|
2719 |
{
|
|
2720 |
control = iHeader->MsgControl( controlIndex );
|
|
2721 |
}
|
|
2722 |
else
|
|
2723 |
{
|
|
2724 |
control = iBody->MsgControl( controlIndex - headerControlCount );
|
|
2725 |
}
|
|
2726 |
|
|
2727 |
CEikRichTextEditor* editor = NULL;
|
|
2728 |
if ( control->ControlType() == EMsgExpandableControl ||
|
|
2729 |
control->ControlType() == EMsgAddressControl )
|
|
2730 |
{
|
|
2731 |
editor = &static_cast<CMsgExpandableControl*>( control )->Editor();
|
|
2732 |
}
|
|
2733 |
else if ( control->ControlType() == EMsgBodyControl ||
|
|
2734 |
control->ControlType() == EMsgXhtmlBodyControl )
|
|
2735 |
{
|
|
2736 |
editor = &static_cast<CMsgBodyControl*>( control )->Editor();
|
|
2737 |
}
|
|
2738 |
|
|
2739 |
if ( editor )
|
|
2740 |
{
|
|
2741 |
editor->RemoveEdwinObserver( iEdwinObserver );
|
|
2742 |
|
|
2743 |
if ( iEdwinObserver )
|
|
2744 |
{
|
|
2745 |
editor->AddEdwinObserverL( iEdwinObserver );
|
|
2746 |
}
|
|
2747 |
}
|
|
2748 |
}
|
|
2749 |
}
|
|
2750 |
|
|
2751 |
// ---------------------------------------------------------
|
|
2752 |
// CMsgEditorView::ControlFullyVisible
|
|
2753 |
//
|
|
2754 |
// If control's:
|
|
2755 |
// - top Y-coordinate is below or equal messaging main pane top Y-coordinate and
|
|
2756 |
// - bottom Y-coordinate is above or equal messaging main pane bottom Y-coordinate
|
|
2757 |
// then control is fully visible. Currently all controls are expected
|
|
2758 |
// to have equal width as messaging data pane.
|
|
2759 |
// ---------------------------------------------------------
|
|
2760 |
//
|
|
2761 |
TBool CMsgEditorView::ControlFullyVisible( CMsgBaseControl* aControl ) const
|
|
2762 |
{
|
|
2763 |
TBool retVal = EFalse;
|
|
2764 |
|
|
2765 |
if ( aControl )
|
|
2766 |
{
|
|
2767 |
TRect rect = aControl->Rect();
|
|
2768 |
if ( rect.iTl.iY >= 0 &&
|
|
2769 |
rect.iBr.iY <= MsgEditorCommons::EditorViewHeigth() )
|
|
2770 |
{
|
|
2771 |
retVal = ETrue;
|
|
2772 |
}
|
|
2773 |
}
|
|
2774 |
|
|
2775 |
return retVal;
|
|
2776 |
}
|
|
2777 |
|
|
2778 |
// ---------------------------------------------------------
|
|
2779 |
// CMsgEditorView::NextFocusableFormControl
|
|
2780 |
//
|
|
2781 |
// Searches then next focusable form control from given form component
|
|
2782 |
// starting from certain control and proceeding into given direction.
|
|
2783 |
//
|
|
2784 |
// Stops when either focusable control is found or there is no more
|
|
2785 |
// controls left. See CMsgEditorView::IsFocusable function for
|
|
2786 |
// description when control is focusable.
|
|
2787 |
// ---------------------------------------------------------
|
|
2788 |
//
|
|
2789 |
TInt CMsgEditorView::NextFocusableFormControl( CMsgFormComponent* aFormComponent,
|
|
2790 |
TInt aStart,
|
|
2791 |
TMsgFocusDirection aDirection )
|
|
2792 |
{
|
|
2793 |
TInt newFocus = aFormComponent->FirstFocusableControl( aStart, aDirection );
|
|
2794 |
TBool found = EFalse;
|
|
2795 |
|
|
2796 |
while ( newFocus != KErrNotFound &&
|
|
2797 |
!found )
|
|
2798 |
{
|
|
2799 |
found = IsFocusable( aFormComponent->MsgControl( newFocus ), aDirection );
|
|
2800 |
|
|
2801 |
if ( !found )
|
|
2802 |
{
|
|
2803 |
newFocus = aFormComponent->FirstFocusableControl(
|
|
2804 |
aDirection == EMsgFocusDown ? newFocus + 1 :
|
|
2805 |
newFocus - 1,
|
|
2806 |
aDirection );
|
|
2807 |
}
|
|
2808 |
}
|
|
2809 |
|
|
2810 |
return newFocus;
|
|
2811 |
}
|
|
2812 |
|
|
2813 |
// ---------------------------------------------------------
|
|
2814 |
// CMsgEditorView::MopSupplyObject
|
|
2815 |
//
|
|
2816 |
// ---------------------------------------------------------
|
|
2817 |
//
|
|
2818 |
EXPORT_C TTypeUid::Ptr CMsgEditorView::MopSupplyObject( TTypeUid aId )
|
|
2819 |
{
|
|
2820 |
if ( aId.iUid == MAknsControlContext::ETypeId )
|
|
2821 |
{
|
|
2822 |
return MAknsControlContext::SupplyMopObject( aId, iBgContext );
|
|
2823 |
}
|
|
2824 |
|
|
2825 |
return CCoeControl::MopSupplyObject( aId );
|
|
2826 |
}
|
|
2827 |
|
|
2828 |
// ---------------------------------------------------------
|
|
2829 |
// CMsgEditorView::HandleScrollEventL
|
|
2830 |
//
|
|
2831 |
// ---------------------------------------------------------
|
|
2832 |
//
|
|
2833 |
#ifdef RD_SCALABLE_UI_V2
|
|
2834 |
void CMsgEditorView::HandleScrollEventL( CEikScrollBar* aScrollBar,
|
|
2835 |
TEikScrollEvent aEventType )
|
|
2836 |
{
|
|
2837 |
switch ( aEventType )
|
|
2838 |
{
|
|
2839 |
case EEikScrollUp:
|
|
2840 |
{
|
|
2841 |
ScrollViewL( iLineHeight, EMsgScrollUp, ETrue );
|
|
2842 |
EnsureCorrectScrollPartL( AknScrollBarModel()->FocusPosition() );
|
|
2843 |
break;
|
|
2844 |
}
|
|
2845 |
case EEikScrollDown:
|
|
2846 |
{
|
|
2847 |
ScrollViewL( iLineHeight, EMsgScrollDown, ETrue );
|
|
2848 |
EnsureCorrectScrollPartL( AknScrollBarModel()->FocusPosition() );
|
|
2849 |
break;
|
|
2850 |
}
|
|
2851 |
case EEikScrollTop:
|
|
2852 |
{
|
|
2853 |
// Not supported yet.
|
|
2854 |
break;
|
|
2855 |
}
|
|
2856 |
case EEikScrollBottom:
|
|
2857 |
{
|
|
2858 |
// Not supported yet.
|
|
2859 |
break;
|
|
2860 |
}
|
|
2861 |
case EEikScrollThumbReleaseVert:
|
|
2862 |
{
|
|
2863 |
iScrollBar->DrawBackground( ETrue, ETrue );
|
|
2864 |
|
|
2865 |
EnsureCorrectScrollPartL( AknScrollBarModel()->FocusPosition() );
|
|
2866 |
iPopUpPart = -1;
|
|
2867 |
break;
|
|
2868 |
}
|
|
2869 |
case EEikScrollPageUp:
|
|
2870 |
case EEikScrollPageDown:
|
|
2871 |
{
|
|
2872 |
TInt scrolledPixels = iViewFocusPosition - AknScrollBarModel()->FocusPosition();
|
|
2873 |
|
|
2874 |
// Round to the previous full line.
|
|
2875 |
MsgEditorCommons::RoundToPreviousLine( scrolledPixels, iLineHeight );
|
|
2876 |
|
|
2877 |
if ( scrolledPixels != 0 )
|
|
2878 |
{
|
|
2879 |
ScrollViewL( Abs( scrolledPixels ),
|
|
2880 |
scrolledPixels > 0 ? EMsgScrollUp :
|
|
2881 |
EMsgScrollDown,
|
|
2882 |
EFalse );
|
|
2883 |
|
|
2884 |
EnsureCorrectScrollPartL( AknScrollBarModel()->FocusPosition() );
|
|
2885 |
|
|
2886 |
iScrollBar->DrawScrollBarsNow();
|
|
2887 |
}
|
|
2888 |
break;
|
|
2889 |
}
|
|
2890 |
case EEikScrollThumbDragVert:
|
|
2891 |
{
|
|
2892 |
TInt currentPart( CurrentScrollPart( AknScrollBarModel()->FocusPosition() ) );
|
|
2893 |
|
|
2894 |
if ( currentPart == iVisiblePart )
|
|
2895 |
{
|
|
2896 |
if ( iPopUpPart != -1 )
|
|
2897 |
{
|
|
2898 |
// Hide the popup if visible
|
|
2899 |
static_cast<CAknDoubleSpanScrollBar*>( aScrollBar )->SetScrollPopupInfoTextL( KNullDesC );
|
|
2900 |
iPopUpPart = -1;
|
|
2901 |
}
|
|
2902 |
}
|
|
2903 |
|
|
2904 |
if ( iPopUpPart == -1 )
|
|
2905 |
{
|
|
2906 |
TInt scrolledPixels = iViewFocusPosition - AknScrollBarModel()->FocusPosition();
|
|
2907 |
|
|
2908 |
// Round to the previous full line.
|
|
2909 |
MsgEditorCommons::RoundToPreviousLine( scrolledPixels, iLineHeight );
|
|
2910 |
|
|
2911 |
if ( scrolledPixels != 0 )
|
|
2912 |
{
|
|
2913 |
ScrollViewL( Abs( scrolledPixels ),
|
|
2914 |
scrolledPixels > 0 ? EMsgScrollUp :
|
|
2915 |
EMsgScrollDown,
|
|
2916 |
EFalse );
|
|
2917 |
}
|
|
2918 |
}
|
|
2919 |
|
|
2920 |
TInt pixelsScrolled = iViewFocusPosition - AknScrollBarModel()->FocusPosition();
|
|
2921 |
TMsgScrollDirection scrollDirection = pixelsScrolled > 0 ? EMsgScrollUp : EMsgScrollDown;
|
|
2922 |
|
|
2923 |
// If scrolled position is outside of visible part, then there is no need to
|
|
2924 |
// reset thumb position and no page number pop-up need be shown.
|
|
2925 |
if ( ( currentPart != iVisiblePart ) &&
|
|
2926 |
EnsureVisiblePartScrollComplete ( AknScrollBarModel()->FocusPosition(), scrollDirection ) )
|
|
2927 |
{
|
|
2928 |
// Thumb position is forced to the top most position of currently scrolled slide.
|
|
2929 |
TInt currentHeight( 0 );
|
|
2930 |
TInt screenHeight = iViewRect.Height() - iBaseLineOffset;
|
|
2931 |
|
|
2932 |
for ( TInt current = 0; current < currentPart; current++ )
|
|
2933 |
{
|
|
2934 |
if ( current == iVisiblePart )
|
|
2935 |
{
|
|
2936 |
currentHeight += iVisiblePartHeight;
|
|
2937 |
}
|
|
2938 |
else
|
|
2939 |
{
|
|
2940 |
currentHeight += screenHeight;
|
|
2941 |
}
|
|
2942 |
}
|
|
2943 |
|
|
2944 |
iScrollBar->DrawBackground( ETrue, EFalse );
|
|
2945 |
iScrollBar->SetVFocusPosToThumbPos( currentHeight );
|
|
2946 |
|
|
2947 |
if ( currentPart != iPopUpPart )
|
|
2948 |
{
|
|
2949 |
ShowScrollPopupInfoTextL( static_cast<CAknDoubleSpanScrollBar*>( aScrollBar ),
|
|
2950 |
currentPart + 1 );
|
|
2951 |
iPopUpPart = currentPart;
|
|
2952 |
}
|
|
2953 |
}
|
|
2954 |
else
|
|
2955 |
{
|
|
2956 |
iScrollBar->DrawScrollBarsNow();
|
|
2957 |
}
|
|
2958 |
break;
|
|
2959 |
}
|
|
2960 |
default:
|
|
2961 |
{
|
|
2962 |
break;
|
|
2963 |
}
|
|
2964 |
}
|
|
2965 |
}
|
|
2966 |
#else
|
|
2967 |
void CMsgEditorView::HandleScrollEventL( CEikScrollBar* /*aScrollBar*/,
|
|
2968 |
TEikScrollEvent /*aEventType*/ )
|
|
2969 |
{
|
|
2970 |
}
|
|
2971 |
#endif // RD_SCALABLE_UI_V2
|
|
2972 |
|
|
2973 |
// ---------------------------------------------------------
|
|
2974 |
// CMsgEditorView::Draw
|
|
2975 |
// Draws skin background for the view area. With video control
|
|
2976 |
// this should not be done since we might accidentally draw over
|
|
2977 |
// the video frame. In this case we only draw around the video control
|
|
2978 |
// and let the video control draw its own background when approriate.
|
|
2979 |
// ---------------------------------------------------------
|
|
2980 |
//
|
|
2981 |
void CMsgEditorView::Draw( const TRect& aRect ) const
|
|
2982 |
{
|
|
2983 |
CWindowGc& gc = SystemGc();
|
|
2984 |
|
|
2985 |
CMsgBaseControl* videoControl = iBody->Component( EMsgComponentIdVideo );
|
|
2986 |
|
|
2987 |
TBool backgroundDrawn( EFalse );
|
|
2988 |
if ( !videoControl )
|
|
2989 |
{
|
|
2990 |
backgroundDrawn = AknsDrawUtils::Background(
|
|
2991 |
AknsUtils::SkinInstance(),
|
|
2992 |
AknsDrawUtils::ControlContext( this ),
|
|
2993 |
this,
|
|
2994 |
gc,
|
|
2995 |
aRect );
|
|
2996 |
}
|
|
2997 |
else
|
|
2998 |
{
|
|
2999 |
backgroundDrawn = AknsDrawUtils::BackgroundBetweenRects(
|
|
3000 |
AknsUtils::SkinInstance(),
|
|
3001 |
AknsDrawUtils::ControlContext( this ),
|
|
3002 |
this,
|
|
3003 |
gc,
|
|
3004 |
aRect,
|
|
3005 |
videoControl->Rect() );
|
|
3006 |
}
|
|
3007 |
|
|
3008 |
|
|
3009 |
if ( !backgroundDrawn )
|
|
3010 |
{
|
|
3011 |
gc.SetBrushColor( AKN_LAF_COLOR( 0 ) );
|
|
3012 |
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
3013 |
gc.SetPenStyle( CGraphicsContext::ENullPen );
|
|
3014 |
gc.DrawRect( aRect );
|
|
3015 |
}
|
|
3016 |
}
|
|
3017 |
|
|
3018 |
// ---------------------------------------------------------
|
|
3019 |
// CMsgEditorView::ReportFocusMovement
|
|
3020 |
//
|
|
3021 |
// ---------------------------------------------------------
|
|
3022 |
//
|
|
3023 |
void CMsgEditorView::ReportFocusMovement( TInt aFocusEvent )
|
|
3024 |
{
|
|
3025 |
CMsgBaseControl* ctrl = FocusedControl();
|
|
3026 |
|
|
3027 |
TInt controlId = ctrl ? ctrl->ControlId() :
|
|
3028 |
EMsgComponentIdNull;
|
|
3029 |
|
|
3030 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgHandleFocusChange,
|
|
3031 |
&aFocusEvent,
|
|
3032 |
&controlId,
|
|
3033 |
NULL );
|
|
3034 |
}
|
|
3035 |
|
|
3036 |
// ---------------------------------------------------------
|
|
3037 |
// CMsgEditorView::ControlFromPosition
|
|
3038 |
//
|
|
3039 |
// ---------------------------------------------------------
|
|
3040 |
//
|
|
3041 |
CMsgBaseControl* CMsgEditorView::ControlFromPosition( TPoint aPosition,
|
|
3042 |
TBool aEvaluateHitTest ) const
|
|
3043 |
{
|
|
3044 |
CMsgBaseControl* control = NULL;
|
|
3045 |
|
|
3046 |
if ( iHeader->Rect().Contains( aPosition ) )
|
|
3047 |
{
|
|
3048 |
control = iHeader->ControlFromPosition( aPosition, aEvaluateHitTest );
|
|
3049 |
}
|
|
3050 |
else
|
|
3051 |
{
|
|
3052 |
control = iBody->ControlFromPosition( aPosition, aEvaluateHitTest );
|
|
3053 |
}
|
|
3054 |
|
|
3055 |
return control;
|
|
3056 |
}
|
|
3057 |
|
|
3058 |
// ---------------------------------------------------------
|
|
3059 |
// CMsgEditorView::EnsureVisiblePartScrollComplete
|
|
3060 |
//
|
|
3061 |
// Description
|
|
3062 |
// ---------------------------------------------------------
|
|
3063 |
|
|
3064 |
TBool CMsgEditorView::EnsureVisiblePartScrollComplete( TInt aFocusPosition,
|
|
3065 |
TMsgScrollDirection aDirection )
|
|
3066 |
{
|
|
3067 |
MEBLOGGER_ENTERFN( "CMsgEditorView::EnsureVisiblePartScrollComplete" );
|
|
3068 |
TInt scrollTillPosition( 0 );
|
|
3069 |
TBool result = ETrue;
|
|
3070 |
|
|
3071 |
TInt screenHeight = MsgEditorCommons::EditorViewHeigth() - iBaseLineOffset;
|
|
3072 |
|
|
3073 |
for ( TInt current = 0; current < iVisiblePart ; current++ )
|
|
3074 |
scrollTillPosition += screenHeight;
|
|
3075 |
|
|
3076 |
if ( aDirection == EMsgScrollDown )
|
|
3077 |
{
|
|
3078 |
scrollTillPosition += iVisiblePartHeight;
|
|
3079 |
|
|
3080 |
if ( aFocusPosition < scrollTillPosition )
|
|
3081 |
result = EFalse;
|
|
3082 |
}
|
|
3083 |
else
|
|
3084 |
{
|
|
3085 |
if ( aFocusPosition > scrollTillPosition )
|
|
3086 |
result = EFalse;
|
|
3087 |
}
|
|
3088 |
|
|
3089 |
MEBLOGGER_LEAVEFN( "CMsgEditorView::EnsureVisiblePartScrollComplete" );
|
|
3090 |
return result;
|
|
3091 |
}
|
|
3092 |
|
|
3093 |
// ---------------------------------------------------------
|
|
3094 |
// CMsgEditorView::ScrollViewL
|
|
3095 |
//
|
|
3096 |
// First bound check is made so that no scrolling below minimum &
|
|
3097 |
// above maximum is performed. This might happen with out check
|
|
3098 |
// when using scrollbar arrows. DoScrollViewL function is called
|
|
3099 |
// to perform the real scrolling. After all scrolling is done we
|
|
3100 |
// move the thumb position if this is requested by the caller.
|
|
3101 |
// ---------------------------------------------------------
|
|
3102 |
//
|
|
3103 |
void CMsgEditorView::ScrollViewL( TInt aPixelsToScroll,
|
|
3104 |
TMsgScrollDirection aDirection,
|
|
3105 |
TBool aMoveThumb )
|
|
3106 |
{
|
|
3107 |
MEBLOGGER_ENTERFN( "CMsgEditorView::ScrollViewL" );
|
|
3108 |
|
|
3109 |
const TAknDoubleSpanScrollBarModel* model = AknScrollBarModel();
|
|
3110 |
|
|
3111 |
// Maximum value for thumb [0..scrollSpan]
|
|
3112 |
TInt scrollSpan = model->ScrollSpan();
|
|
3113 |
|
|
3114 |
// Position of the topmost part of the thumb
|
|
3115 |
TInt thumbTopPos = iViewFocusPosition;
|
|
3116 |
|
|
3117 |
// Position of the downmost part of the thumb
|
|
3118 |
TInt thumbDownPos = thumbTopPos + model->WindowSize();
|
|
3119 |
|
|
3120 |
// Bound check
|
|
3121 |
if ( ( aDirection == EMsgScrollUp && thumbTopPos <= 0 ) ||
|
|
3122 |
( aDirection == EMsgScrollDown && thumbDownPos >= scrollSpan ) )
|
|
3123 |
{
|
|
3124 |
return;
|
|
3125 |
}
|
|
3126 |
|
|
3127 |
if ( CurrentScrollPart( iViewFocusPosition ) != iVisiblePart )
|
|
3128 |
{
|
|
3129 |
// No need to perform scrolling, if the visible part is completely
|
|
3130 |
// scrolled and the new scroll position is outside the visible part
|
|
3131 |
if ( EnsureVisiblePartScrollComplete ( iViewFocusPosition, aDirection ) )
|
|
3132 |
return;
|
|
3133 |
}
|
|
3134 |
|
|
3135 |
DoScrollViewL( aPixelsToScroll, aDirection );
|
|
3136 |
|
|
3137 |
if ( aMoveThumb )
|
|
3138 |
{
|
|
3139 |
// Scroll bar thumb is moved only if caller requests it. Scroll bar seems to
|
|
3140 |
// add/subtract 1 pixel depending of direction.
|
|
3141 |
TInt directionMultiplier( -1 );
|
|
3142 |
if ( aDirection == EMsgScrollDown )
|
|
3143 |
{
|
|
3144 |
directionMultiplier = 1;
|
|
3145 |
}
|
|
3146 |
|
|
3147 |
iScrollBar->SetVFocusPosToThumbPos( model->FocusPosition() -
|
|
3148 |
directionMultiplier * 1 +
|
|
3149 |
directionMultiplier * aPixelsToScroll );
|
|
3150 |
}
|
|
3151 |
|
|
3152 |
MEBLOGGER_LEAVEFN( "CMsgEditorView::ScrollViewL" );
|
|
3153 |
}
|
|
3154 |
|
|
3155 |
// ---------------------------------------------------------
|
|
3156 |
// CMsgEditorView::EnsureCorrectCursorPosition
|
|
3157 |
//
|
|
3158 |
// Ensures that cursor position relative to focus position
|
|
3159 |
// on all controls is on correct position.
|
|
3160 |
// ---------------------------------------------------------
|
|
3161 |
//
|
|
3162 |
void CMsgEditorView::EnsureCorrectCursorPosition()
|
|
3163 |
{
|
|
3164 |
CMsgFormComponent* currentForm = NULL;
|
|
3165 |
if ( iCurrentFocus == EMsgHeaderFocused )
|
|
3166 |
{
|
|
3167 |
iBody->NotifyControlsForEvent( EMsgViewEventSetCursorFirstPos, 0 );
|
|
3168 |
currentForm = iHeader;
|
|
3169 |
}
|
|
3170 |
else
|
|
3171 |
{
|
|
3172 |
iHeader->NotifyControlsForEvent( EMsgViewEventSetCursorLastPos, 0 );
|
|
3173 |
currentForm = iBody;
|
|
3174 |
}
|
|
3175 |
|
|
3176 |
TInt componentIndex = currentForm->ComponentIndexFromId( currentForm->FocusedControl()->ControlId() );
|
|
3177 |
|
|
3178 |
for ( TInt current = 0; current < currentForm->CountMsgControls(); current++ )
|
|
3179 |
{
|
|
3180 |
CMsgBaseControl* control = currentForm->MsgControl( current );
|
|
3181 |
TInt currentIndex = currentForm->ComponentIndexFromId( control->ControlId() );
|
|
3182 |
if ( currentIndex < componentIndex )
|
|
3183 |
{
|
|
3184 |
control->NotifyViewEvent( EMsgViewEventSetCursorLastPos, 0 );
|
|
3185 |
}
|
|
3186 |
else if ( currentIndex > componentIndex )
|
|
3187 |
{
|
|
3188 |
control->NotifyViewEvent( EMsgViewEventSetCursorFirstPos, 0 );
|
|
3189 |
}
|
|
3190 |
}
|
|
3191 |
}
|
|
3192 |
|
|
3193 |
// ---------------------------------------------------------
|
|
3194 |
// CMsgEditorView::EnsureCorrectScrollPartL
|
|
3195 |
//
|
|
3196 |
// Ensures that correct scroll part is visible. Performs scroll
|
|
3197 |
// part change if focus position is outside of currently visible scroll
|
|
3198 |
// part.
|
|
3199 |
// ---------------------------------------------------------
|
|
3200 |
//
|
|
3201 |
void CMsgEditorView::EnsureCorrectScrollPartL( TInt aFocusPosition )
|
|
3202 |
{
|
|
3203 |
TInt currentPart( CurrentScrollPart( aFocusPosition ) );
|
|
3204 |
if ( currentPart != iVisiblePart )
|
|
3205 |
{
|
|
3206 |
MMsgEditorObserver::TMsgFocusEvent focusEvent = MMsgEditorObserver::EMsgFocusNone;
|
|
3207 |
|
|
3208 |
if ( currentPart > iVisiblePart )
|
|
3209 |
{
|
|
3210 |
focusEvent = MMsgEditorObserver::EMsgFocusAtBottom;
|
|
3211 |
}
|
|
3212 |
else
|
|
3213 |
{
|
|
3214 |
focusEvent = MMsgEditorObserver::EMsgFocusAtTop;
|
|
3215 |
}
|
|
3216 |
|
|
3217 |
MMsgEditorObserver::TMsgAfterFocusEventFunc after =
|
|
3218 |
MMsgEditorObserver::EMsgAfterFocusNone;
|
|
3219 |
|
|
3220 |
iVisiblePart = currentPart;
|
|
3221 |
iEditorObserver.EditorObserver( MMsgEditorObserver::EMsgHandleFocusChange,
|
|
3222 |
&focusEvent,
|
|
3223 |
&after,
|
|
3224 |
&iVisiblePart );
|
|
3225 |
|
|
3226 |
if ( after != MMsgEditorObserver::EMsgAfterFocusNone )
|
|
3227 |
{
|
|
3228 |
SetAfterFocusL( after );
|
|
3229 |
}
|
|
3230 |
|
|
3231 |
EnsureCorrectFormPosition( EFalse, EFalse );
|
|
3232 |
|
|
3233 |
UpdateScrollBarL();
|
|
3234 |
}
|
|
3235 |
}
|
|
3236 |
|
|
3237 |
// ---------------------------------------------------------
|
|
3238 |
// CMsgEditorView::CurrentScrollPart
|
|
3239 |
//
|
|
3240 |
// Calculates the correct scroll part of the given focus position.
|
|
3241 |
// Current scroll part is evaluated based on position of top & bottom
|
|
3242 |
// of the view rectangle. If either one of the borders are on the
|
|
3243 |
// different scroll part than visible part then that part is returned
|
|
3244 |
// as current part.
|
|
3245 |
// ---------------------------------------------------------
|
|
3246 |
//
|
|
3247 |
TInt CMsgEditorView::CurrentScrollPart( TInt aFocusPosition )
|
|
3248 |
{
|
|
3249 |
TInt result( 0 );
|
|
3250 |
|
|
3251 |
TInt currentHeight( 0 );
|
|
3252 |
TInt topPart( -1 );
|
|
3253 |
TInt bottomPart( -1 );
|
|
3254 |
|
|
3255 |
TInt topPosition( aFocusPosition );
|
|
3256 |
TInt bottomPosition( topPosition + iViewRect.Height() - iBaseLineOffset );
|
|
3257 |
|
|
3258 |
TInt screenHeight = MsgEditorCommons::EditorViewHeigth() - iBaseLineOffset;
|
|
3259 |
|
|
3260 |
for ( TInt current = 0; current < iScrollParts; current++ )
|
|
3261 |
{
|
|
3262 |
if ( current == iVisiblePart )
|
|
3263 |
{
|
|
3264 |
currentHeight += iVisiblePartHeight;
|
|
3265 |
}
|
|
3266 |
else
|
|
3267 |
{
|
|
3268 |
currentHeight += screenHeight;
|
|
3269 |
}
|
|
3270 |
|
|
3271 |
if ( topPart == -1 &&
|
|
3272 |
topPosition < currentHeight )
|
|
3273 |
{
|
|
3274 |
topPart = current;
|
|
3275 |
}
|
|
3276 |
|
|
3277 |
if ( bottomPart == -1 &&
|
|
3278 |
bottomPosition <= currentHeight )
|
|
3279 |
{
|
|
3280 |
bottomPart = current;
|
|
3281 |
}
|
|
3282 |
}
|
|
3283 |
|
|
3284 |
if ( topPart == -1 )
|
|
3285 |
{
|
|
3286 |
topPart = iScrollParts - 1;
|
|
3287 |
}
|
|
3288 |
|
|
3289 |
if ( bottomPart == -1 )
|
|
3290 |
{
|
|
3291 |
bottomPart = iScrollParts - 1;
|
|
3292 |
}
|
|
3293 |
|
|
3294 |
if ( topPart == bottomPart )
|
|
3295 |
{
|
|
3296 |
result = topPart;
|
|
3297 |
}
|
|
3298 |
else
|
|
3299 |
{
|
|
3300 |
if ( topPart != iVisiblePart )
|
|
3301 |
{
|
|
3302 |
result = topPart;
|
|
3303 |
}
|
|
3304 |
else
|
|
3305 |
{
|
|
3306 |
result = bottomPart;
|
|
3307 |
}
|
|
3308 |
}
|
|
3309 |
return result;
|
|
3310 |
}
|
|
3311 |
|
|
3312 |
// ---------------------------------------------------------
|
|
3313 |
// CMsgEditorView::IsFocusable
|
|
3314 |
//
|
|
3315 |
// Determines if given control should receive focus when navigating
|
|
3316 |
// into given direction.
|
|
3317 |
//
|
|
3318 |
// On editor mode (i.e. non read-only) every control is focusable.
|
|
3319 |
//
|
|
3320 |
// On viewer mode (i.e. read-only) control is focusable if:
|
|
3321 |
// - force focus stop flag is set to control,
|
|
3322 |
// - control is not fully visible on the screen,
|
|
3323 |
// - focus change to given direction is not allowed or
|
|
3324 |
// - there is currently focused (i.e. currently shown and
|
|
3325 |
// highlighted) automatic finder item.
|
|
3326 |
// ---------------------------------------------------------
|
|
3327 |
//
|
|
3328 |
TBool CMsgEditorView::IsFocusable( CMsgBaseControl* aControl,
|
|
3329 |
TMsgFocusDirection aDirection ) const
|
|
3330 |
{
|
|
3331 |
if ( !aControl )
|
|
3332 |
{
|
|
3333 |
return EFalse;
|
|
3334 |
}
|
|
3335 |
|
|
3336 |
if ( aControl->IsReadOnly() )
|
|
3337 |
{
|
|
3338 |
if ( aControl->ControlModeFlags() & EMsgControlModeForceFocusStop ||
|
|
3339 |
!ControlFullyVisible( aControl ) ||
|
|
3340 |
!( aControl->IsFocusChangePossible( aDirection ) ) )
|
|
3341 |
{
|
|
3342 |
return ETrue;
|
|
3343 |
}
|
|
3344 |
else if ( aControl->ItemFinder() )
|
|
3345 |
{
|
|
3346 |
const CItemFinder::CFindItemExt& item = aControl->ItemFinder()->CurrentItemExt();
|
|
3347 |
|
|
3348 |
if ( item.iItemType != CItemFinder::ENoneSelected )
|
|
3349 |
{
|
|
3350 |
return ETrue;
|
|
3351 |
}
|
|
3352 |
}
|
|
3353 |
|
|
3354 |
return EFalse;
|
|
3355 |
}
|
|
3356 |
|
|
3357 |
return ETrue;
|
|
3358 |
}
|
|
3359 |
|
|
3360 |
// ---------------------------------------------------------
|
|
3361 |
// CMsgEditorView::ShowScrollPopupInfoTextL
|
|
3362 |
//
|
|
3363 |
// Loads the info text resouce if not yet loaded. Creates correct
|
|
3364 |
// text string based on this resource and given part number.
|
|
3365 |
// After this sets the created info text for the scroll bar.
|
|
3366 |
// ---------------------------------------------------------
|
|
3367 |
//
|
|
3368 |
void CMsgEditorView::ShowScrollPopupInfoTextL( CAknDoubleSpanScrollBar* aScrollBar, TInt aPartNumber )
|
|
3369 |
{
|
|
3370 |
if ( !iScrollPopText )
|
|
3371 |
{
|
|
3372 |
if ( !iCoeEnv->IsResourceAvailableL( R_QTN_MSG_PAGE_NUMBER_POPUP ) )
|
|
3373 |
{
|
|
3374 |
// Load the resource file containing page number popup if it has not yet
|
|
3375 |
// been loaded. This should not happen but better to be prepared for that also.
|
|
3376 |
TParse parse;
|
|
3377 |
User::LeaveIfError( parse.Set( KMsgEditorAppUiResourceFileName,
|
|
3378 |
&KDC_RESOURCE_FILES_DIR,
|
|
3379 |
NULL ) );
|
|
3380 |
|
|
3381 |
TFileName* fileName = new( ELeave ) TFileName( parse.FullName() );
|
|
3382 |
CleanupStack::PushL( fileName );
|
|
3383 |
|
|
3384 |
iResourceLoader.OpenL( *fileName );
|
|
3385 |
|
|
3386 |
CleanupStack::PopAndDestroy( fileName );
|
|
3387 |
}
|
|
3388 |
|
|
3389 |
iScrollPopText = StringLoader::LoadL( R_QTN_MSG_PAGE_NUMBER_POPUP, iCoeEnv );
|
|
3390 |
}
|
|
3391 |
|
|
3392 |
TBuf<KMsgMaximumScrollPartLength> buffer;
|
|
3393 |
StringLoader::Format( buffer, *iScrollPopText, KErrNotFound, aPartNumber );
|
|
3394 |
|
|
3395 |
aScrollBar->SetScrollPopupInfoTextL( buffer );
|
|
3396 |
}
|
|
3397 |
|
|
3398 |
// ---------------------------------------------------------
|
|
3399 |
// CMsgEditorView::EnsureCorrectViewPosition
|
|
3400 |
// ---------------------------------------------------------
|
|
3401 |
//
|
|
3402 |
void CMsgEditorView::EnsureCorrectViewPosition()
|
|
3403 |
{
|
|
3404 |
CMsgBaseControl* firstHeaderControl = iHeader->CountMsgControls() > 0 ? iHeader->MsgControl( 0 ) : NULL;
|
|
3405 |
|
|
3406 |
CMsgBaseControl* lastControlBody = iBody->CountMsgControls() > 0 ?
|
|
3407 |
iBody->MsgControl( iBody->CountMsgControls() - 1 ) : NULL;
|
|
3408 |
|
|
3409 |
if ( firstHeaderControl &&
|
|
3410 |
firstHeaderControl->Position().iY > iBaseLineOffset )
|
|
3411 |
{
|
|
3412 |
TInt pixelsToScroll( firstHeaderControl->Position().iY - iBaseLineOffset );
|
|
3413 |
TRAP_IGNORE( DoScrollViewL( pixelsToScroll,
|
|
3414 |
EMsgScrollDown ) );
|
|
3415 |
}
|
|
3416 |
else if ( lastControlBody &&
|
|
3417 |
lastControlBody->Rect().iBr.iY <= iViewRect.Height() - iLineHeight )
|
|
3418 |
{
|
|
3419 |
TInt pixelsToScroll( iViewRect.Height() - lastControlBody->Rect().iBr.iY );
|
|
3420 |
TRAP_IGNORE( DoScrollViewL( pixelsToScroll,
|
|
3421 |
EMsgScrollUp ) );
|
|
3422 |
}
|
|
3423 |
else
|
|
3424 |
{
|
|
3425 |
|
|
3426 |
CMsgBaseControl* ctrl = FocusedControl();
|
|
3427 |
if (( ctrl && ctrl->ControlModeFlags() & EMsgControlModeBodyMaxHeight) && ctrl->VirtualHeight() < MsgEditorCommons::MaxBodyHeight() )
|
|
3428 |
{
|
|
3429 |
// Special handling is required when we rotate the phone from
|
|
3430 |
// landscape to portrait or vice versa when the Editor is placed last
|
|
3431 |
TInt bottomYPos( ctrl->Position().iY + ctrl->VirtualHeight() );
|
|
3432 |
TInt distanceFromBottom( Rect().iBr.iY - bottomYPos );
|
|
3433 |
|
|
3434 |
if ( distanceFromBottom > 0 )
|
|
3435 |
{
|
|
3436 |
TInt delta = Abs( iFormOffset ) < distanceFromBottom ? -iFormOffset :
|
|
3437 |
distanceFromBottom;
|
|
3438 |
if ( delta )
|
|
3439 |
{
|
|
3440 |
ScrollForm( delta, ETrue );
|
|
3441 |
}
|
|
3442 |
}
|
|
3443 |
if ( ViewInitialized() )
|
|
3444 |
{
|
|
3445 |
TRAP_IGNORE(UpdateScrollBarL());
|
|
3446 |
}
|
|
3447 |
|
|
3448 |
}
|
|
3449 |
else if( ctrl )
|
|
3450 |
{
|
|
3451 |
TInt height( 0 );
|
|
3452 |
TInt pos( 0 );
|
|
3453 |
|
|
3454 |
GetVirtualFormHeightAndPos( height, pos );
|
|
3455 |
if(!ControlFullyVisible( ctrl ) && height > iViewRect.Height() )
|
|
3456 |
{
|
|
3457 |
TInt controlPixels( Abs(ctrl->Position().iY ));
|
|
3458 |
MsgEditorCommons::RoundToPreviousLine( controlPixels, iLineHeight );
|
|
3459 |
TRAP_IGNORE(DoScrollViewL(controlPixels,EMsgScrollDown));
|
|
3460 |
}
|
|
3461 |
}
|
|
3462 |
}
|
|
3463 |
}
|
|
3464 |
|
|
3465 |
// ---------------------------------------------------------
|
|
3466 |
// CMsgEditorView::DoScrollViewL
|
|
3467 |
//
|
|
3468 |
// First & last loaded control is
|
|
3469 |
// needed in order to do bound checking so that empty space above
|
|
3470 |
// or below loaded controls isn't shown. Actual scrolling is performed
|
|
3471 |
// so that control from first or last visible (depends about the
|
|
3472 |
// scrolling direction) line is retrieved. If this control isn't fully
|
|
3473 |
// visible on the scroll we try to move it as much visible as allowed
|
|
3474 |
// by the scrollable pixels. When the control is fully visible it can
|
|
3475 |
// perform internal scrolling if needed. When it has finished internal
|
|
3476 |
// scrolling then we move the view one line up or down. This is continued
|
|
3477 |
// as long as there is pixels left. After all scrolling is done we
|
|
3478 |
// update our internal view focus position
|
|
3479 |
// that keeps count where the focus position on the view is really
|
|
3480 |
// located. Finally we draw the screen if needed.
|
|
3481 |
// ---------------------------------------------------------
|
|
3482 |
//
|
|
3483 |
void CMsgEditorView::DoScrollViewL( TInt& aPixelsToScroll,
|
|
3484 |
TMsgScrollDirection aDirection )
|
|
3485 |
{
|
|
3486 |
MEBLOGGER_ENTERFN( "CMsgEditorView::DoScrollViewL" );
|
|
3487 |
|
|
3488 |
TInt pixelsLeftToScroll( aPixelsToScroll );
|
|
3489 |
|
|
3490 |
TInt directionMultiplier( -1 );
|
|
3491 |
if ( aDirection == EMsgScrollDown )
|
|
3492 |
{
|
|
3493 |
directionMultiplier = 1;
|
|
3494 |
}
|
|
3495 |
|
|
3496 |
CMsgBaseControl* firstControl = iHeader->CountMsgControls() > 0 ? iHeader->MsgControl( 0 ) :
|
|
3497 |
iBody->MsgControl( 0 );
|
|
3498 |
|
|
3499 |
CMsgBaseControl* lastControl = iBody->CountMsgControls() > 0 ?
|
|
3500 |
iBody->MsgControl( iBody->CountMsgControls() - 1 ) :
|
|
3501 |
iHeader->MsgControl( iHeader->CountMsgControls() - 1 );
|
|
3502 |
|
|
3503 |
while ( pixelsLeftToScroll > 0 )
|
|
3504 |
{
|
|
3505 |
MEBLOGGER_WRITEF(_L("MEB: CMsgEditorView::DoScrollViewL: pixelsLeftToScroll %d "), pixelsLeftToScroll );
|
|
3506 |
|
|
3507 |
CMsgBaseControl* scrolledControl = NULL;
|
|
3508 |
|
|
3509 |
if ( aDirection == EMsgScrollUp )
|
|
3510 |
{
|
|
3511 |
// Control located at first visible line
|
|
3512 |
scrolledControl = ControlFromPosition( TPoint( iViewRect.Width() / 2, iLineHeight / 2 + iBaseLineOffset ), EFalse );
|
|
3513 |
}
|
|
3514 |
else
|
|
3515 |
{
|
|
3516 |
// Control located at last visible line
|
|
3517 |
scrolledControl = ControlFromPosition( TPoint( iViewRect.Width() / 2, iViewRect.Height() - iLineHeight / 2 ), EFalse );
|
|
3518 |
}
|
|
3519 |
|
|
3520 |
if ( scrolledControl )
|
|
3521 |
{
|
|
3522 |
// Assumption: Control will make internal scrolling only if
|
|
3523 |
// it's height is greater or equal to view height.
|
|
3524 |
if ( !ControlFullyVisible( scrolledControl ) )
|
|
3525 |
{
|
|
3526 |
// Calculate how many pixels needs to be scrolled in order
|
|
3527 |
// to control be fully visible.
|
|
3528 |
TInt controlPixels( Abs( scrolledControl->Position().iY ) );
|
|
3529 |
|
|
3530 |
if ( aDirection == EMsgScrollDown )
|
|
3531 |
{
|
|
3532 |
// Round to the previous full line.
|
|
3533 |
MsgEditorCommons::RoundToPreviousLine( controlPixels, iLineHeight );
|
|
3534 |
}
|
|
3535 |
else
|
|
3536 |
{
|
|
3537 |
// Round to the next full line.
|
|
3538 |
MsgEditorCommons::RoundToNextLine( controlPixels, iLineHeight );
|
|
3539 |
}
|
|
3540 |
|
|
3541 |
// Scroll form so that control is fully visible or
|
|
3542 |
// at minimum one line height and at maximum pixels left to scroll.
|
|
3543 |
TInt scrollFormByPixels = Max( iLineHeight, Min( pixelsLeftToScroll,
|
|
3544 |
controlPixels ) );
|
|
3545 |
|
|
3546 |
TInt oldYPos( scrolledControl->Position().iY );
|
|
3547 |
|
|
3548 |
// To disable drawing in the middle of scrolling.
|
|
3549 |
iStateFlags |= EMsgStateRefreshing;
|
|
3550 |
|
|
3551 |
if ( CurrentScrollPart( iViewFocusPosition - aPixelsToScroll + pixelsLeftToScroll + directionMultiplier * scrollFormByPixels ) != iVisiblePart )
|
|
3552 |
{
|
|
3553 |
// Do not scroll form if scrolling would make scroll part change.
|
|
3554 |
break;
|
|
3555 |
}
|
|
3556 |
|
|
3557 |
ScrollForm( -directionMultiplier * scrollFormByPixels, EFalse );
|
|
3558 |
|
|
3559 |
// Substract the pixels really moved.
|
|
3560 |
pixelsLeftToScroll -= Abs( oldYPos - scrolledControl->Position().iY );
|
|
3561 |
|
|
3562 |
MEBLOGGER_WRITEF(_L("MEB: CMsgEditorView::DoScrollViewL: pixelsLeftToScroll after fully visible %d "), pixelsLeftToScroll );
|
|
3563 |
}
|
|
3564 |
|
|
3565 |
if ( pixelsLeftToScroll > 0 )
|
|
3566 |
{
|
|
3567 |
// Perform internal scrolling for the control if there is still pixels left to scroll.
|
|
3568 |
pixelsLeftToScroll -= scrolledControl->ScrollL( pixelsLeftToScroll, aDirection );
|
|
3569 |
|
|
3570 |
MEBLOGGER_WRITEF(_L("MEB: CMsgEditorView::DoScrollViewL: pixelsLeftToScroll after internal scrolling %d "), pixelsLeftToScroll );
|
|
3571 |
}
|
|
3572 |
}
|
|
3573 |
|
|
3574 |
// After component's internal scrolling there is still some pixels left to scroll
|
|
3575 |
// move the view to correction direction one line.
|
|
3576 |
if ( pixelsLeftToScroll > 0 )
|
|
3577 |
{
|
|
3578 |
// Boundary check for form scrolling. Do not scroll up (down) if first (last) control is
|
|
3579 |
// fully visible. Also do not scroll form if scrolling would make scroll part change.
|
|
3580 |
if ( aDirection == EMsgScrollDown ? lastControl->Rect().iBr.iY > iViewRect.Height() :
|
|
3581 |
firstControl->Rect().iTl.iY < iViewRect.Height() &&
|
|
3582 |
CurrentScrollPart( iViewFocusPosition - aPixelsToScroll + pixelsLeftToScroll + directionMultiplier * iLineHeight ) == iVisiblePart )
|
|
3583 |
{
|
|
3584 |
|
|
3585 |
if ( pixelsLeftToScroll > 0 )
|
|
3586 |
{
|
|
3587 |
// To disable drawing in the middle of scrolling.
|
|
3588 |
iStateFlags |= EMsgStateRefreshing;
|
|
3589 |
|
|
3590 |
ScrollForm( -directionMultiplier * iLineHeight, EFalse );
|
|
3591 |
pixelsLeftToScroll -= iLineHeight;
|
|
3592 |
|
|
3593 |
MEBLOGGER_WRITEF(_L("MEB: CMsgEditorView::DoScrollViewL: pixelsLeftToScroll after single scrolling %d "), pixelsLeftToScroll );
|
|
3594 |
|
|
3595 |
}
|
|
3596 |
}
|
|
3597 |
else
|
|
3598 |
{
|
|
3599 |
break;
|
|
3600 |
}
|
|
3601 |
}
|
|
3602 |
}
|
|
3603 |
|
|
3604 |
iViewFocusPosition += directionMultiplier * ( aPixelsToScroll - pixelsLeftToScroll );
|
|
3605 |
|
|
3606 |
if ( iStateFlags & EMsgStateRefreshing )
|
|
3607 |
{
|
|
3608 |
iStateFlags &= ~EMsgStateRefreshing;
|
|
3609 |
DrawNow();
|
|
3610 |
}
|
|
3611 |
|
|
3612 |
MEBLOGGER_LEAVEFN( "CMsgEditorView::ScrollViewL" );
|
|
3613 |
}
|
|
3614 |
|
|
3615 |
|
|
3616 |
// End of File
|