66
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved. This program and the accompanying materials
|
|
4 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
5 |
* which accompanies this distribution, and is available at
|
|
6 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
7 |
*
|
|
8 |
* Contributors:
|
|
9 |
* Nokia Corporation - S60 implementation
|
|
10 |
*******************************************************************************/
|
|
11 |
|
|
12 |
|
|
13 |
#include <AknDef.h>
|
|
14 |
#include <AknsBasicBackgroundControlContext.h>
|
|
15 |
#include <swtlaffacade.h>
|
|
16 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
17 |
#include <gfxtranseffect/gfxtranseffect.h>
|
|
18 |
#include <akntransitionutils.h>
|
|
19 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
20 |
#include <coreuiavkoneswt.h>
|
|
21 |
|
|
22 |
#include "eswtmobileextensions.h"
|
|
23 |
#include "swtuiutils.h"
|
|
24 |
#include "swtshell.h"
|
|
25 |
|
|
26 |
|
|
27 |
// Main pane varieties
|
|
28 |
static const TInt KSwtMainPainVarietyClassic = 3;
|
|
29 |
static const TInt KSwtMainPainVarietySmallSpLandscape = 9;
|
|
30 |
static const TInt KSwtMainPainVarietySmallSpLandscapePen = 4;
|
|
31 |
|
|
32 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
33 |
static const TInt KSwtRoundCornerBgColorDiff = 50;
|
|
34 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
35 |
|
|
36 |
|
|
37 |
// ======== MEMBER FUNCTIONS ========
|
|
38 |
|
|
39 |
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
// CSwtShell::NewL
|
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
CSwtShell* CSwtShell::NewL(MSwtDisplay& aDisplay, TSwtPeer aPeer,
|
|
45 |
MSwtShell* aParent, TInt aStyle)
|
|
46 |
{
|
|
47 |
CSwtShell* self = new(ELeave) CSwtShell(aDisplay, aPeer,
|
|
48 |
aParent, aStyle);
|
|
49 |
CleanupStack::PushL(self);
|
|
50 |
self->ConstructL();
|
|
51 |
self->InitControlBaseL();
|
|
52 |
CleanupStack::Pop(self);
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
// CSwtShell::CSwtShell
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CSwtShell::CSwtShell(MSwtDisplay& aDisplay, TSwtPeer aPeer,
|
|
61 |
MSwtShell* aParent, TInt aStyle)
|
|
62 |
: CSwtDecorations(aDisplay, aPeer,
|
|
63 |
aParent ? aParent->Composite() : NULL, aStyle, EFalse, EFalse)
|
|
64 |
, iMinSize(-1, -1)
|
|
65 |
, iSavedStyle(aStyle)
|
|
66 |
, iHasCba(aParent == NULL)
|
|
67 |
{
|
|
68 |
SetFocusing(EFalse);
|
|
69 |
// Top-level Shells are considered as always maximised
|
|
70 |
if (!iParent)
|
|
71 |
{
|
|
72 |
iIsMaximized = ETrue;
|
|
73 |
}
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// CSwtShell::~CSwtShell
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
CSwtShell::~CSwtShell()
|
|
81 |
{
|
|
82 |
// Do all the destruction in DoDelete().
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// CSwtShell::ConstructL
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
void CSwtShell::ConstructL()
|
|
90 |
{
|
|
91 |
// Create the window
|
|
92 |
//
|
|
93 |
// When created, the window does not inherit the control's visibility.
|
|
94 |
// The workaround is to make the control visible, create the window and
|
|
95 |
// finally make the control invisible again.
|
|
96 |
|
|
97 |
// WARNING! Avkon expects window owning parent control to be always ready
|
|
98 |
// to draw! See CCoeControl::DrawNow(). This might cause various problems!
|
|
99 |
CCoeControl::MakeVisible(ETrue);
|
|
100 |
CreateWindowL();
|
|
101 |
CCoeControl::MakeVisible(EFalse);
|
|
102 |
|
|
103 |
// Shells are by default invisible
|
|
104 |
iCtrlFlags |= MSwtControl::EFlagInvisible;
|
|
105 |
|
|
106 |
// Essential for clearing up tactile feedback when Button gets invisible.
|
|
107 |
SetMopParent(iEikonEnv->EikAppUi());
|
|
108 |
|
|
109 |
// The rect must be in window coordinates, not screen
|
|
110 |
CSwtDecorations::ConstructL();
|
|
111 |
|
|
112 |
// Set priority based on the shell style. See TSwtWinPriority.
|
|
113 |
// 0 ordinal position means highest z position.
|
|
114 |
TInt ordinalPos(1);
|
|
115 |
if (!iParent)
|
|
116 |
{
|
|
117 |
ordinalPos = 0;
|
|
118 |
}
|
|
119 |
RWindow& window = Window();
|
|
120 |
if (iStyle & KSwtStyleOnTop)
|
|
121 |
{
|
|
122 |
iWindowPriority = ESwtWinPriorityDefault;
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
iWindowPriority = ESwtWinPriorityShell;
|
|
127 |
}
|
|
128 |
window.SetOrdinalPosition(ordinalPos, iWindowPriority);
|
|
129 |
|
|
130 |
#ifdef RD_SCALABLE_UI_V2
|
|
131 |
window.SetPointerGrab(ETrue);
|
|
132 |
#endif //RD_SCALABLE_UI_V2
|
|
133 |
|
|
134 |
DoSetRect(DefaultBounds());
|
|
135 |
SetMinimumSize(TSize());
|
|
136 |
UiUtils().RegisterShellL(*this);
|
|
137 |
|
|
138 |
#ifdef RD_SCALABLE_UI_V2
|
|
139 |
if ((iStyle & KSwtStyleSystemModal) != 0 ||
|
|
140 |
(iStyle & KSwtStyleApplicationModal) != 0)
|
|
141 |
{
|
|
142 |
CCoeControl::SetGloballyCapturing(ETrue);
|
|
143 |
CCoeControl::SetPointerCapture(ETrue);
|
|
144 |
}
|
|
145 |
#endif //RD_SCALABLE_UI_V2
|
|
146 |
|
|
147 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
148 |
GfxTransEffect::Enable();
|
|
149 |
GfxTransEffect::Register(this,
|
|
150 |
iParent ? KGfxOptionsMenuControlUid : KGfxInformationNoteControlUid, EFalse);
|
|
151 |
|
|
152 |
// Window transparency cannot be enabled as it breaks the async drawing.
|
|
153 |
// Since transparency cannot be enabled, set the initial background
|
|
154 |
// color to something closer to the theme's background.
|
|
155 |
if (iParent)
|
|
156 |
{
|
|
157 |
TRgb bgColor = iDisplay.UiUtils().GetSystemColor(ESwtColorWidgetBackground);
|
|
158 |
|
|
159 |
TInt r = bgColor.Green();
|
|
160 |
r -= KSwtRoundCornerBgColorDiff;
|
|
161 |
if (r < 0)
|
|
162 |
r = 0;
|
|
163 |
|
|
164 |
TInt g = bgColor.Green();
|
|
165 |
g -= KSwtRoundCornerBgColorDiff;
|
|
166 |
if (g < 0)
|
|
167 |
g = 0;
|
|
168 |
|
|
169 |
TInt b = bgColor.Blue();
|
|
170 |
b -= KSwtRoundCornerBgColorDiff;
|
|
171 |
if (b < 0)
|
|
172 |
b = 0;
|
|
173 |
|
|
174 |
bgColor.SetRed(b);
|
|
175 |
bgColor.SetGreen(b);
|
|
176 |
bgColor.SetBlue(b);
|
|
177 |
|
|
178 |
OverrideColorL(EColorControlBackground, bgColor);
|
|
179 |
}
|
|
180 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
181 |
}
|
|
182 |
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
// CSwtShell::GetTopShell
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
MSwtShell& CSwtShell::GetTopShell() const
|
|
188 |
{
|
|
189 |
return UiUtils().GetControlTopShell(*this);
|
|
190 |
}
|
|
191 |
|
|
192 |
// ---------------------------------------------------------------------------
|
|
193 |
// CSwtShell::RemoveAndRememberFocus
|
|
194 |
// ---------------------------------------------------------------------------
|
|
195 |
//
|
|
196 |
void CSwtShell::RemoveAndRememberFocus()
|
|
197 |
{
|
|
198 |
ASSERT(iFocusControl && iFocusControl->CoeControl().IsFocused());
|
|
199 |
ASSERT(!iFocusMemory);
|
|
200 |
|
|
201 |
iFocusMemory = iFocusControl;
|
|
202 |
// This sets iFocusControl to NULL
|
|
203 |
iFocusControl->CoeControl().SetFocus(EFalse);
|
|
204 |
|
|
205 |
ASSERT(!iFocusControl);
|
|
206 |
}
|
|
207 |
|
|
208 |
// ---------------------------------------------------------------------------
|
|
209 |
// CSwtShell::DoSetRect
|
|
210 |
// Note that calling SetRect on the Shell does not cause a PositionChanged!
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
void CSwtShell::DoSetRect(const TRect& aRect)
|
|
214 |
{
|
|
215 |
// Divert the job to UiUtils if this is the Shell of an editor open for
|
|
216 |
// split view editing.
|
|
217 |
MSwtUiUtils& utils = iDisplay.UiUtils();
|
|
218 |
MSwtControl* splitInputView = utils.SplitInputView();
|
|
219 |
if (splitInputView && (&(splitInputView->GetShell())) == this)
|
|
220 |
{
|
|
221 |
utils.SetSplitInputShellPos(aRect.iTl);
|
|
222 |
CCoeControl::SetSize(aRect.Size());
|
|
223 |
}
|
|
224 |
else
|
|
225 |
{
|
|
226 |
CCoeControl::SetRect(aRect);
|
|
227 |
}
|
|
228 |
}
|
|
229 |
|
|
230 |
// ---------------------------------------------------------------------------
|
|
231 |
// CSwtShell::SwtHandleResourceChangeL
|
|
232 |
// From CSwtComposite
|
|
233 |
// ---------------------------------------------------------------------------
|
|
234 |
//
|
|
235 |
void CSwtShell::SwtHandleResourceChangeL(TInt aType)
|
|
236 |
{
|
|
237 |
if (aType == KEikDynamicLayoutVariantSwitch)
|
|
238 |
{
|
|
239 |
if (!iParent)
|
|
240 |
{
|
|
241 |
CAknsBasicBackgroundControlContext* bg =
|
|
242 |
static_cast<CAknsBasicBackgroundControlContext*>(GetControlContext());
|
|
243 |
if (bg)
|
|
244 |
{
|
|
245 |
bg->SetRect(iDisplay.Device().Bounds());
|
|
246 |
}
|
|
247 |
DoSetRect(DefaultBounds());
|
|
248 |
}
|
|
249 |
}
|
|
250 |
|
|
251 |
CSwtDecorations::SwtHandleResourceChangeL(aType);
|
|
252 |
}
|
|
253 |
|
|
254 |
// ---------------------------------------------------------------------------
|
|
255 |
// CSwtShell::CSwtShell
|
|
256 |
// From ASwtControlBase
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
//
|
|
259 |
void CSwtShell::DoPaint(const TRect& aRect) const
|
|
260 |
{
|
|
261 |
// Set Draw called by eSWT drawing framework flag
|
|
262 |
const_cast<CSwtShell *>(this)->iDrawCalledByOurFrwk = ETrue;
|
|
263 |
|
|
264 |
// Restore title visibility so that it is drawn. See Draw method
|
|
265 |
if (AsyncPainting())
|
|
266 |
{
|
|
267 |
if (iTitle)
|
|
268 |
{
|
|
269 |
iTitle->MakeVisible(this->IsVisible());
|
|
270 |
}
|
|
271 |
}
|
|
272 |
CoeControl().DrawBackground(aRect);
|
|
273 |
|
|
274 |
CSwtComposite::Draw(aRect);
|
|
275 |
|
|
276 |
// Additional drawing code is to be added here instead of Draw()
|
|
277 |
|
|
278 |
// Unset Draw called by eSWT drawing framework flag
|
|
279 |
const_cast<CSwtShell *>(this)->iDrawCalledByOurFrwk = EFalse;
|
|
280 |
}
|
|
281 |
|
|
282 |
// ---------------------------------------------------------------------------
|
|
283 |
// CSwtShell::BorderInnerRect
|
|
284 |
// From ASwtControlBase
|
|
285 |
// ---------------------------------------------------------------------------
|
|
286 |
//
|
|
287 |
TRect CSwtShell::BorderInnerRect() const
|
|
288 |
{
|
|
289 |
if (!iParent)
|
|
290 |
{
|
|
291 |
return CSwtComposite::BorderInnerRect();
|
|
292 |
}
|
|
293 |
else
|
|
294 |
{
|
|
295 |
return CSwtDecorations::BorderInnerRect();
|
|
296 |
}
|
|
297 |
}
|
|
298 |
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
// CSwtShell::BorderOuterRect
|
|
301 |
// From ASwtControlBase
|
|
302 |
// ---------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
TRect CSwtShell::BorderOuterRect(const TRect& aRect) const
|
|
305 |
{
|
|
306 |
if (!iParent)
|
|
307 |
{
|
|
308 |
return CSwtComposite::BorderOuterRect(aRect);
|
|
309 |
}
|
|
310 |
else
|
|
311 |
{
|
|
312 |
return CSwtDecorations::BorderOuterRect(aRect);
|
|
313 |
}
|
|
314 |
}
|
|
315 |
|
|
316 |
// ---------------------------------------------------------------------------
|
|
317 |
// CSwtShell::DoDelete
|
|
318 |
// From ASwtControlBase
|
|
319 |
// ---------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
void CSwtShell::DoDelete()
|
|
322 |
{
|
|
323 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
324 |
GfxTransEffect::Deregister(this);
|
|
325 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
326 |
|
|
327 |
CSwtUiUtils& uiUtils = UiUtils();
|
|
328 |
if (uiUtils.GetActiveShell() == this)
|
|
329 |
{
|
|
330 |
iDisplay.MenuArranger().ActiveShellLost();
|
|
331 |
// Notify Command arranger
|
|
332 |
MSwtCommandArranger* commandArranger = iDisplay.CommandArranger();
|
|
333 |
// commandArranger may be null as Mobile Extensions is optional
|
|
334 |
if (commandArranger)
|
|
335 |
{
|
|
336 |
commandArranger->ActiveShellLost();
|
|
337 |
}
|
|
338 |
}
|
|
339 |
|
|
340 |
uiUtils.UnregisterShell(*this);
|
|
341 |
iFullTabList.Close();
|
|
342 |
delete iTitleText;
|
|
343 |
iTitleText = NULL;
|
|
344 |
|
|
345 |
iFocusControl = NULL;
|
|
346 |
iPrevFocusControl = NULL;
|
|
347 |
iFocusMemory = NULL;
|
|
348 |
iDefaultCommand = NULL;
|
|
349 |
iControlGoingToStack= NULL;
|
|
350 |
iControlGainingFocus= NULL;
|
|
351 |
iTitleText = NULL;
|
|
352 |
|
|
353 |
// Last step must always be this!
|
|
354 |
UiUtils().GarbageCollect(*this);
|
|
355 |
}
|
|
356 |
|
|
357 |
// ---------------------------------------------------------------------------
|
|
358 |
// CSwtShell::OfferKeyEventL
|
|
359 |
// From CCoeControl
|
|
360 |
// ---------------------------------------------------------------------------
|
|
361 |
//
|
|
362 |
TKeyResponse CSwtShell::OfferKeyEventL(const TKeyEvent& aKeyEvent,
|
|
363 |
TEventCode aType)
|
|
364 |
{
|
|
365 |
// Offer key event to command arranger first
|
|
366 |
TKeyResponse keyResponse = OfferKeyEventToCommandAndMenuArrangersL(aKeyEvent, aType);
|
|
367 |
if (keyResponse != EKeyWasConsumed)
|
|
368 |
{
|
|
369 |
// Now to the tab group.
|
|
370 |
// Tab groups are usually handled in HandleHeyL but this call
|
|
371 |
// is needed for cases where there are no focusable controls
|
|
372 |
keyResponse = OfferKeyEventToTabGroupL(aKeyEvent, aType);
|
|
373 |
}
|
|
374 |
if (keyResponse == EKeyWasConsumed)
|
|
375 |
{
|
|
376 |
return EKeyWasConsumed;
|
|
377 |
}
|
|
378 |
|
|
379 |
return CSwtDecorations::OfferKeyEventL(aKeyEvent, aType);
|
|
380 |
}
|
|
381 |
|
|
382 |
// ---------------------------------------------------------------------------
|
|
383 |
// CSwtShell::HandlePointerEventL
|
|
384 |
// This is the entry point for all pointer events targeted at any of the children
|
|
385 |
// of this Shell except for Browser's case.
|
|
386 |
// From CCoeControl
|
|
387 |
// ---------------------------------------------------------------------------
|
|
388 |
//
|
|
389 |
#ifdef RD_SCALABLE_UI_V2
|
|
390 |
void CSwtShell::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
391 |
{
|
|
392 |
CSwtUiUtils& utils = UiUtils();
|
|
393 |
|
|
394 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down)
|
|
395 |
{
|
|
396 |
utils.SetNaviKeyInput(EFalse);
|
|
397 |
|
|
398 |
// Ignore pointer events outside modal Shells.
|
|
399 |
MSwtShell *activeShell = utils.GetActiveShell();
|
|
400 |
if (!activeShell || (activeShell && activeShell != this &&
|
|
401 |
!((activeShell->Control()->Style() & KSwtStylePrimaryModal) != 0
|
|
402 |
&& activeShell->Control()->IsDescentOf(*this))))
|
|
403 |
{
|
|
404 |
utils.SetActiveShell(*this, ETrue);
|
|
405 |
}
|
|
406 |
}
|
|
407 |
|
|
408 |
MSwtControl* capturingControl = utils.PointerCaptureControl();
|
|
409 |
if (capturingControl && capturingControl != this)
|
|
410 |
{
|
|
411 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down
|
|
412 |
&& capturingControl->IsFocusable())
|
|
413 |
{
|
|
414 |
capturingControl->SetSwtFocus(KSwtFocusByPointer);
|
|
415 |
}
|
|
416 |
capturingControl->HandlePointerEventL(aPointerEvent);
|
|
417 |
iDisplay.TryDetectLongTapL(aPointerEvent);
|
|
418 |
return;
|
|
419 |
}
|
|
420 |
|
|
421 |
if (!iDisplay.RevertPointerEvent())
|
|
422 |
{
|
|
423 |
CSwtComposite::HandlePointerEventL(aPointerEvent);
|
|
424 |
}
|
|
425 |
|
|
426 |
iDisplay.TryDetectLongTapL(aPointerEvent);
|
|
427 |
}
|
|
428 |
#else
|
|
429 |
void CSwtShell::HandlePointerEventL(const TPointerEvent& /*aPointerEvent*/)
|
|
430 |
{
|
|
431 |
}
|
|
432 |
#endif //RD_SCALABLE_UI_V2
|
|
433 |
|
|
434 |
// ---------------------------------------------------------------------------
|
|
435 |
// CSwtShell::MakeVisible
|
|
436 |
// From CCoeControl
|
|
437 |
// ---------------------------------------------------------------------------
|
|
438 |
//
|
|
439 |
void CSwtShell::MakeVisible(TBool aVisible)
|
|
440 |
{
|
|
441 |
// Remove focus from its owner before making it invisible
|
|
442 |
if (!aVisible && iFocusControl)
|
|
443 |
{
|
|
444 |
RemoveAndRememberFocus();
|
|
445 |
}
|
|
446 |
|
|
447 |
if (aVisible && !iBgContext)
|
|
448 |
{
|
|
449 |
TRAP_IGNORE(CreateBackgroundL());
|
|
450 |
}
|
|
451 |
|
|
452 |
CSwtUiUtils& utils = UiUtils();
|
|
453 |
|
|
454 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
455 |
TBool doEffect = (IsVisible() != aVisible) && (iDisplay.IsUiReady() || iParent);
|
|
456 |
if (doEffect)
|
|
457 |
{
|
|
458 |
GfxTransEffect::Begin(this, aVisible ? KGfxControlAppearAction : KGfxControlDisappearAction);
|
|
459 |
GfxTransEffect::SetDemarcation(this, Rect());
|
|
460 |
}
|
|
461 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
462 |
|
|
463 |
CSwtDecorations::MakeVisible(aVisible);
|
|
464 |
|
|
465 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
466 |
if (doEffect)
|
|
467 |
{
|
|
468 |
GfxTransEffect::End(this);
|
|
469 |
}
|
|
470 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
471 |
|
|
472 |
utils.ShellActivabilityChanged(*this);
|
|
473 |
|
|
474 |
// Done already if the Shell became active
|
|
475 |
if (aVisible && utils.GetActiveShell() != this)
|
|
476 |
{
|
|
477 |
if (!iFullScreen && HasCba())
|
|
478 |
{
|
|
479 |
utils.SetCbaVisible(ETrue);
|
|
480 |
}
|
|
481 |
}
|
|
482 |
}
|
|
483 |
|
|
484 |
// ---------------------------------------------------------------------------
|
|
485 |
// CSwtShell::SetDimmed
|
|
486 |
// From CCoeControl
|
|
487 |
// ---------------------------------------------------------------------------
|
|
488 |
//
|
|
489 |
void CSwtShell::SetDimmed(TBool aDimmed)
|
|
490 |
{
|
|
491 |
CSwtDecorations::SetDimmed(aDimmed);
|
|
492 |
UiUtils().ShellActivabilityChanged(*this);
|
|
493 |
}
|
|
494 |
|
|
495 |
// ---------------------------------------------------------------------------
|
|
496 |
// CSwtShell::FocusChanged
|
|
497 |
// From CCoeControl
|
|
498 |
// ---------------------------------------------------------------------------
|
|
499 |
//
|
|
500 |
void CSwtShell::FocusChanged(TDrawNow /*aDrawNow*/)
|
|
501 |
{
|
|
502 |
// Shells cannot gain ( nor lose ) focus, they can only be active but we may
|
|
503 |
// still end up here because of the app UI's AddToStackL().
|
|
504 |
if (IsFocused())
|
|
505 |
{
|
|
506 |
CCoeControl::SetFocus(EFalse);
|
|
507 |
if (iControlGoingToStack)
|
|
508 |
{
|
|
509 |
// This control child is added to control stack,
|
|
510 |
// the Symbian framework will manages its focus.
|
|
511 |
// When the SWT application goes to background,
|
|
512 |
// Symbian will unfocus the control child.
|
|
513 |
// The SWT application still runs,
|
|
514 |
// and the fact that the control child is unfocused could perhaps
|
|
515 |
// cause some conflicts in this SWT native implementation.
|
|
516 |
TRAP_IGNORE(iControlGoingToStack->AddToControlStackL(
|
|
517 |
ECoeStackPriorityDefault));
|
|
518 |
}
|
|
519 |
if (iControlGainingFocus)
|
|
520 |
{
|
|
521 |
iControlGainingFocus->SetSwtFocus();
|
|
522 |
iControlGainingFocus = NULL;
|
|
523 |
}
|
|
524 |
}
|
|
525 |
}
|
|
526 |
|
|
527 |
// ---------------------------------------------------------------------------
|
|
528 |
// CSwtShell::Draw
|
|
529 |
// From CCoeControl
|
|
530 |
// Draw (additional drawing must be placed in DoPaint(), cannot be put here)
|
|
531 |
// Areas inside aRect which are not drawn will turn black or transparent in 9.2!
|
|
532 |
// ---------------------------------------------------------------------------
|
|
533 |
//
|
|
534 |
void CSwtShell::Draw(const TRect& aRect) const
|
|
535 |
{
|
|
536 |
if (iCtrlFlags & EFlagDoNotDraw)
|
|
537 |
{
|
|
538 |
return;
|
|
539 |
}
|
|
540 |
|
|
541 |
if (iUrgentPaintControl)
|
|
542 |
{
|
|
543 |
const TRect rect(iUrgentPaintControl->CoeControl().Rect());
|
|
544 |
if (aRect.iTl.iX < rect.iTl.iX
|
|
545 |
|| aRect.iTl.iY < rect.iTl.iY
|
|
546 |
|| aRect.iBr.iX > rect.iBr.iX
|
|
547 |
|| aRect.iBr.iY > rect.iBr.iY)
|
|
548 |
{
|
|
549 |
// We cannot afford not to draw around the urgently painted control,
|
|
550 |
// therefore draw the whole Shell urgently.
|
|
551 |
ASwtControlBase::PaintUrgently(aRect, EFalse);
|
|
552 |
}
|
|
553 |
else
|
|
554 |
{
|
|
555 |
// The urgently painted control and its children are drawn exclusively.
|
|
556 |
iUrgentPaintControl->PaintUrgently(aRect, EFalse);
|
|
557 |
}
|
|
558 |
FinishRedraw();
|
|
559 |
}
|
|
560 |
else if (CoeControl().DrawableWindow()->IsFaded())
|
|
561 |
{
|
|
562 |
// This is to fix horible flickering in faded lists,
|
|
563 |
// when menus or modal Shells are open partially on top.
|
|
564 |
ASwtControlBase::PaintUrgently(aRect, EFalse);
|
|
565 |
FinishRedraw();
|
|
566 |
}
|
|
567 |
else
|
|
568 |
{
|
|
569 |
if (AsyncPainting())
|
|
570 |
{
|
|
571 |
// Wait for eSWT drawing framework before drawing title so that everything
|
|
572 |
// is drawn at the same time (don't draw title when it is Symbian drawing
|
|
573 |
// framework that is calling Draw method )
|
|
574 |
if (iTitle && this->IsVisible())
|
|
575 |
{
|
|
576 |
iTitle->MakeVisible(EFalse);
|
|
577 |
}
|
|
578 |
|
|
579 |
// Post a paint event
|
|
580 |
TRect paintRect(Rect());
|
|
581 |
paintRect.Intersection(aRect); // In window coords
|
|
582 |
if (!paintRect.IsEmpty())
|
|
583 |
{
|
|
584 |
TBool mergeable = !(iStyle & KSwtStyleNoMergePaints);
|
|
585 |
paintRect.Move(iPosition); // In screen coords
|
|
586 |
TRAP_IGNORE(iDisplay.PostPaintEventL(iPeer, iPeer, paintRect, mergeable));
|
|
587 |
}
|
|
588 |
}
|
|
589 |
else
|
|
590 |
{
|
|
591 |
// Extra attention must be payed to the fact that after ::Draw,
|
|
592 |
// ::DrawComponentControls is called. This means that the eSWT
|
|
593 |
// children will be drawn before the "native" children, like
|
|
594 |
// scrollbars, title panes, etc. Watch out for overlapping.
|
|
595 |
ASwtControlBase::PaintUrgently(aRect, EFalse);
|
|
596 |
FinishRedraw();
|
|
597 |
}
|
|
598 |
}
|
|
599 |
}
|
|
600 |
|
|
601 |
void CSwtShell::SizeChanged()
|
|
602 |
{
|
|
603 |
CSwtDecorations::SizeChanged();
|
|
604 |
MSwtUiUtils& utils = iDisplay.UiUtils();
|
|
605 |
MSwtControl* splitInputView = utils.SplitInputView();
|
|
606 |
if (splitInputView && (&(splitInputView->GetShell())) == this)
|
|
607 |
{
|
|
608 |
utils.AdjustSplitInputShellPos();
|
|
609 |
}
|
|
610 |
}
|
|
611 |
|
|
612 |
// ---------------------------------------------------------------------------
|
|
613 |
// CSwtShell::Draw
|
|
614 |
// From MCoeControlBackground
|
|
615 |
// ---------------------------------------------------------------------------
|
|
616 |
//
|
|
617 |
void CSwtShell::Draw(CWindowGc& aGc, const CCoeControl& aControl,
|
|
618 |
const TRect& aRect) const
|
|
619 |
{
|
|
620 |
// Wait for eSWT drawing framework before drawing background so that
|
|
621 |
// everything is drawn at the same time (don't draw background when it is
|
|
622 |
// Symbian drawing framework that is calling Draw method)
|
|
623 |
if (AsyncPainting())
|
|
624 |
{
|
|
625 |
if (iUrgentPaintControl || iDrawCalledByOurFrwk)
|
|
626 |
{
|
|
627 |
CSwtDecorations::Draw(aGc, aControl, aRect);
|
|
628 |
}
|
|
629 |
}
|
|
630 |
else
|
|
631 |
{
|
|
632 |
CSwtDecorations::Draw(aGc, aControl, aRect);
|
|
633 |
}
|
|
634 |
}
|
|
635 |
|
|
636 |
// ---------------------------------------------------------------------------
|
|
637 |
// CSwtShell::IsFocusable
|
|
638 |
// From MSwtControl
|
|
639 |
// ---------------------------------------------------------------------------
|
|
640 |
//
|
|
641 |
TBool CSwtShell::IsFocusable(TInt /*aReason*/) const
|
|
642 |
{
|
|
643 |
// Shells never get the CoeControl focus, just active
|
|
644 |
return EFalse;
|
|
645 |
}
|
|
646 |
|
|
647 |
// ---------------------------------------------------------------------------
|
|
648 |
// CSwtShell::SetSwtFocus
|
|
649 |
// From MSwtControl
|
|
650 |
// ---------------------------------------------------------------------------
|
|
651 |
//
|
|
652 |
TBool CSwtShell::SetSwtFocus(TInt aReason /*=KSwtFocusByApi*/)
|
|
653 |
{
|
|
654 |
if (aReason != KSwtFocusByForce)
|
|
655 |
{
|
|
656 |
// Pass focus to children
|
|
657 |
CSwtComposite::SetSwtFocus(aReason);
|
|
658 |
}
|
|
659 |
|
|
660 |
if (UiUtils().SetActiveShell(*this, ETrue))
|
|
661 |
{
|
|
662 |
if ((aReason == KSwtFocusByForce) && iFocusControl)
|
|
663 |
{
|
|
664 |
RemoveAndRememberFocus();
|
|
665 |
}
|
|
666 |
return ETrue;
|
|
667 |
}
|
|
668 |
|
|
669 |
return EFalse;
|
|
670 |
}
|
|
671 |
|
|
672 |
// ---------------------------------------------------------------------------
|
|
673 |
// CSwtShell::GetVisible
|
|
674 |
// From MSwtControl
|
|
675 |
// ---------------------------------------------------------------------------
|
|
676 |
//
|
|
677 |
TBool CSwtShell::GetVisible() const
|
|
678 |
{
|
|
679 |
return CCoeControl::IsVisible();
|
|
680 |
}
|
|
681 |
|
|
682 |
// ---------------------------------------------------------------------------
|
|
683 |
// CSwtShell::GetBounds
|
|
684 |
// From MSwtControl
|
|
685 |
// ---------------------------------------------------------------------------
|
|
686 |
//
|
|
687 |
TRect CSwtShell::GetBounds() const
|
|
688 |
{
|
|
689 |
// A Shell must return screen coordinates. A Shell is window owning and, as
|
|
690 |
// such, iPosition is its window's position in screen coordinates.
|
|
691 |
return TRect(iPosition, iSize);
|
|
692 |
}
|
|
693 |
|
|
694 |
// ---------------------------------------------------------------------------
|
|
695 |
// CSwtShell::GetLocation
|
|
696 |
// From MSwtControl
|
|
697 |
// ---------------------------------------------------------------------------
|
|
698 |
//
|
|
699 |
TPoint CSwtShell::GetLocation() const
|
|
700 |
{
|
|
701 |
// A Shell must return screen coordinates. A Shell is window owning and,
|
|
702 |
// as such, iPosition is its window's position in screen coordinates.
|
|
703 |
return iPosition;
|
|
704 |
}
|
|
705 |
|
|
706 |
// ---------------------------------------------------------------------------
|
|
707 |
// CSwtShell::Redraw
|
|
708 |
// From MSwtControl
|
|
709 |
// ---------------------------------------------------------------------------
|
|
710 |
//
|
|
711 |
void CSwtShell::Redraw()
|
|
712 |
{
|
|
713 |
if (!(iCtrlFlags & EFlagDoNotDraw))
|
|
714 |
{
|
|
715 |
CSwtDecorations::Redraw();
|
|
716 |
}
|
|
717 |
}
|
|
718 |
|
|
719 |
// ---------------------------------------------------------------------------
|
|
720 |
// CSwtShell::SetLocation
|
|
721 |
// From MSwtControl
|
|
722 |
// ---------------------------------------------------------------------------
|
|
723 |
//
|
|
724 |
void CSwtShell::SetLocation(const TPoint& aPoint)
|
|
725 |
{
|
|
726 |
// Maximised Shells cannot be moved
|
|
727 |
if (iIsMaximized || !iParent)
|
|
728 |
{
|
|
729 |
return;
|
|
730 |
}
|
|
731 |
|
|
732 |
DoSetLocation(aPoint);
|
|
733 |
}
|
|
734 |
|
|
735 |
// ---------------------------------------------------------------------------
|
|
736 |
// CSwtShell::SetWidgetSize
|
|
737 |
// From MSwtControl
|
|
738 |
// ---------------------------------------------------------------------------
|
|
739 |
//
|
|
740 |
void CSwtShell::SetWidgetSize(const TSize& aSize)
|
|
741 |
{
|
|
742 |
// Maximised Shells cannot be moved
|
|
743 |
if (iIsMaximized || !iParent)
|
|
744 |
{
|
|
745 |
return;
|
|
746 |
}
|
|
747 |
|
|
748 |
TSize checkedSize(Max(aSize.iWidth, iMinSize.iWidth),
|
|
749 |
Max(aSize.iHeight, iMinSize.iHeight));
|
|
750 |
|
|
751 |
if (Size() != checkedSize)
|
|
752 |
{
|
|
753 |
SetSize(checkedSize);
|
|
754 |
|
|
755 |
// Drawing only after everything else.
|
|
756 |
if (!(iStyle & KSwtStyleNoRedrawResize))
|
|
757 |
{
|
|
758 |
Redraw();
|
|
759 |
}
|
|
760 |
}
|
|
761 |
}
|
|
762 |
|
|
763 |
// ---------------------------------------------------------------------------
|
|
764 |
// CSwtShell::SetBounds
|
|
765 |
// From MSwtControl
|
|
766 |
// ---------------------------------------------------------------------------
|
|
767 |
//
|
|
768 |
void CSwtShell::SetBounds(const TRect& aRect)
|
|
769 |
{
|
|
770 |
// Maximised Shells cannot be moved
|
|
771 |
if (iIsMaximized || !iParent)
|
|
772 |
{
|
|
773 |
return;
|
|
774 |
}
|
|
775 |
|
|
776 |
TBool changed = EFalse;
|
|
777 |
TSize checkedSize(Max(aRect.Size().iWidth, iMinSize.iWidth),
|
|
778 |
Max(aRect.Size().iHeight, iMinSize.iHeight));
|
|
779 |
if (Size() != checkedSize)
|
|
780 |
{
|
|
781 |
SetSize(checkedSize);
|
|
782 |
changed = ETrue;
|
|
783 |
}
|
|
784 |
|
|
785 |
// Divert the job to UiUtils if this is the Shell of an editor open for
|
|
786 |
// split view editing.
|
|
787 |
MSwtUiUtils& utils = iDisplay.UiUtils();
|
|
788 |
MSwtControl* splitInputView = utils.SplitInputView();
|
|
789 |
if (splitInputView && (&(splitInputView->GetShell())) == this)
|
|
790 |
{
|
|
791 |
utils.SetSplitInputShellPos(aRect.iTl);
|
|
792 |
}
|
|
793 |
else
|
|
794 |
{
|
|
795 |
if (aRect.iTl != iPosition)
|
|
796 |
{
|
|
797 |
iPosition = aRect.iTl;
|
|
798 |
Window().SetPosition(aRect.iTl);
|
|
799 |
PositionChanged();
|
|
800 |
changed = ETrue;
|
|
801 |
}
|
|
802 |
|
|
803 |
// No need to recurse on the children, their positions within the
|
|
804 |
// window do not change
|
|
805 |
}
|
|
806 |
|
|
807 |
if (changed && !(iStyle & KSwtStyleNoRedrawResize))
|
|
808 |
{
|
|
809 |
Redraw();
|
|
810 |
}
|
|
811 |
}
|
|
812 |
|
|
813 |
// ---------------------------------------------------------------------------
|
|
814 |
// CSwtShell::IsFocusControl
|
|
815 |
// From MSwtControl
|
|
816 |
// ---------------------------------------------------------------------------
|
|
817 |
//
|
|
818 |
TBool CSwtShell::IsFocusControl()
|
|
819 |
{
|
|
820 |
if ((UiUtils().GetActiveShell() == this) && (!iFocusControl))
|
|
821 |
{
|
|
822 |
return ETrue;
|
|
823 |
}
|
|
824 |
|
|
825 |
return EFalse;
|
|
826 |
}
|
|
827 |
|
|
828 |
// ---------------------------------------------------------------------------
|
|
829 |
// CSwtShell::MoveAbove
|
|
830 |
// From MSwtControl
|
|
831 |
// ---------------------------------------------------------------------------
|
|
832 |
//
|
|
833 |
void CSwtShell::MoveAbove(const MSwtControl* aControl)
|
|
834 |
{
|
|
835 |
if (iParent)
|
|
836 |
{
|
|
837 |
iParent->MoveChildAbove(*this, aControl);
|
|
838 |
}
|
|
839 |
|
|
840 |
if (!aControl || aControl->IsShell())
|
|
841 |
{
|
|
842 |
TInt newPosition;
|
|
843 |
if (aControl)
|
|
844 |
{
|
|
845 |
// Use OrdinalPosition() instead of FullOrdinalPosition() since
|
|
846 |
// FullOrdinalPosition() can be called only when the window
|
|
847 |
// priorities are not changed inside a window group. See
|
|
848 |
// TSwtWinPriority
|
|
849 |
TInt paramPosition = aControl->CoeControl().DrawableWindow()->
|
|
850 |
OrdinalPosition();
|
|
851 |
newPosition = (paramPosition > 0) ? paramPosition - 1 : 0;
|
|
852 |
}
|
|
853 |
else
|
|
854 |
{
|
|
855 |
newPosition = 0;
|
|
856 |
}
|
|
857 |
|
|
858 |
SetZPosition(newPosition);
|
|
859 |
}
|
|
860 |
}
|
|
861 |
|
|
862 |
// ---------------------------------------------------------------------------
|
|
863 |
// CSwtShell::MoveBelow
|
|
864 |
// From MSwtControl
|
|
865 |
// ---------------------------------------------------------------------------
|
|
866 |
//
|
|
867 |
void CSwtShell::MoveBelow(const MSwtControl* aControl)
|
|
868 |
{
|
|
869 |
if (iParent)
|
|
870 |
{
|
|
871 |
iParent->MoveChildBelow(*this, aControl);
|
|
872 |
}
|
|
873 |
|
|
874 |
if (!aControl || aControl->IsShell())
|
|
875 |
{
|
|
876 |
TInt newPosition;
|
|
877 |
if (aControl)
|
|
878 |
{
|
|
879 |
// Use OrdinalPosition() instead of FullOrdinalPosition() since
|
|
880 |
// FullOrdinalPosition() can be called only when the window
|
|
881 |
// priorities are not changed inside a window group. See
|
|
882 |
// TSwtWinPriority
|
|
883 |
newPosition = aControl->CoeControl().DrawableWindow()->
|
|
884 |
OrdinalPosition() + 1;
|
|
885 |
}
|
|
886 |
else
|
|
887 |
{
|
|
888 |
newPosition = -1;
|
|
889 |
}
|
|
890 |
|
|
891 |
SetZPosition(newPosition);
|
|
892 |
}
|
|
893 |
}
|
|
894 |
|
|
895 |
// ---------------------------------------------------------------------------
|
|
896 |
// CSwtShell::HideSilently
|
|
897 |
// From MSwtControl
|
|
898 |
// ---------------------------------------------------------------------------
|
|
899 |
//
|
|
900 |
void CSwtShell::HideSilently()
|
|
901 |
{
|
|
902 |
iSilentlyHidden = ETrue;
|
|
903 |
RWindow& window = Window();
|
|
904 |
// It may seem odd that 0 is used here since 0 means closest to the screen.
|
|
905 |
// Ordinal position -1 creates some flickering quirks witht the status pane.
|
|
906 |
// It is ok to use 0 as the ordinal priority is the one that really counts.
|
|
907 |
window.SetOrdinalPosition(0, ESwtWinPriorityInactiveTopShell);
|
|
908 |
const TInt childCount = iChildren.Count();
|
|
909 |
for (TInt i = 0; i < childCount; i++)
|
|
910 |
{
|
|
911 |
MSwtControl* child = iChildren[i];
|
|
912 |
if (child->IsShell())
|
|
913 |
{
|
|
914 |
child->HideSilently();
|
|
915 |
}
|
|
916 |
}
|
|
917 |
}
|
|
918 |
|
|
919 |
// ---------------------------------------------------------------------------
|
|
920 |
// CSwtShell::ShowSilently
|
|
921 |
// From MSwtControl
|
|
922 |
// ---------------------------------------------------------------------------
|
|
923 |
//
|
|
924 |
void CSwtShell::ShowSilently()
|
|
925 |
{
|
|
926 |
if (GetVisible())
|
|
927 |
{
|
|
928 |
iSilentlyHidden = EFalse;
|
|
929 |
RWindow& window = Window();
|
|
930 |
// Bring to front of the z order
|
|
931 |
// Will cause a deferred redraw
|
|
932 |
window.SetOrdinalPosition(0, iWindowPriority);
|
|
933 |
}
|
|
934 |
const TInt childCount = iChildren.Count();
|
|
935 |
for (TInt i = 0; i < childCount; i++)
|
|
936 |
{
|
|
937 |
MSwtControl* child = iChildren[i];
|
|
938 |
if (child->IsShell())
|
|
939 |
{
|
|
940 |
child->ShowSilently();
|
|
941 |
}
|
|
942 |
}
|
|
943 |
}
|
|
944 |
|
|
945 |
// ---------------------------------------------------------------------------
|
|
946 |
// CSwtShell::SetVisible
|
|
947 |
// From MSwtControl
|
|
948 |
// ---------------------------------------------------------------------------
|
|
949 |
//
|
|
950 |
void CSwtShell::SetVisible(TBool aVisible)
|
|
951 |
{
|
|
952 |
// A DrawNow() is absolutely mandatory if the ui is set to be ready.
|
|
953 |
CSwtDecorations::SetVisible(aVisible);
|
|
954 |
|
|
955 |
TBool paintingUrgently = !AsyncPainting();
|
|
956 |
if (aVisible && paintingUrgently && !iDisplay.IsUiReady())
|
|
957 |
{
|
|
958 |
iDisplay.SetUiReady(iParent == NULL);
|
|
959 |
}
|
|
960 |
// Otherwise will be done from Java.
|
|
961 |
}
|
|
962 |
|
|
963 |
// ---------------------------------------------------------------------------
|
|
964 |
// CSwtShell::ChildFocusChanged
|
|
965 |
// From MSwtComposite
|
|
966 |
// ---------------------------------------------------------------------------
|
|
967 |
//
|
|
968 |
void CSwtShell::ChildFocusChanged(MSwtControl& aControl)
|
|
969 |
{
|
|
970 |
// This method's only purpose is to stop recursion, therefore nothing
|
|
971 |
// to be done here. Ensure the shell is indeed the active one if the
|
|
972 |
// control is focused
|
|
973 |
ASSERT((aControl.CoeControl().IsFocused()) ?
|
|
974 |
UiUtils().GetActiveShell() == this : true);
|
|
975 |
(void) aControl;
|
|
976 |
}
|
|
977 |
|
|
978 |
// ---------------------------------------------------------------------------
|
|
979 |
// CSwtShell::SetMaximized
|
|
980 |
// From MSwtDecorations
|
|
981 |
// ---------------------------------------------------------------------------
|
|
982 |
//
|
|
983 |
void CSwtShell::SetMaximized(TBool aMaximized)
|
|
984 |
{
|
|
985 |
// Top-level or full-screen Shells cannot be maximised
|
|
986 |
// but maximized true brings the application to foreground if it is not.
|
|
987 |
if (!iParent || iFullScreen)
|
|
988 |
{
|
|
989 |
if (aMaximized && !UiUtils().IsAppFocused())
|
|
990 |
{
|
|
991 |
UiUtils().ChangeAppFocus(*this, ETrue);
|
|
992 |
return;
|
|
993 |
}
|
|
994 |
}
|
|
995 |
if (aMaximized == iIsMaximized)
|
|
996 |
{
|
|
997 |
return;
|
|
998 |
}
|
|
999 |
|
|
1000 |
TRect newRect(TRect::EUninitialized);
|
|
1001 |
if (aMaximized)
|
|
1002 |
{
|
|
1003 |
TRect screenRect;
|
|
1004 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screenRect);
|
|
1005 |
TInt variety(0);
|
|
1006 |
if (CSwtLafFacade::IsLandscapeOrientation())
|
|
1007 |
{
|
|
1008 |
variety = AknLayoutUtils::PenEnabled() ?
|
|
1009 |
KSwtMainPainVarietySmallSpLandscapePen :
|
|
1010 |
KSwtMainPainVarietySmallSpLandscape;
|
|
1011 |
}
|
|
1012 |
else
|
|
1013 |
{
|
|
1014 |
variety = KSwtMainPainVarietyClassic;
|
|
1015 |
}
|
|
1016 |
TAknLayoutRect layoutRect = CSwtLafFacade::GetComposeAndLayoutRect(
|
|
1017 |
CSwtLafFacade::EMainPaneCompose, screenRect, variety);
|
|
1018 |
newRect = layoutRect.Rect();
|
|
1019 |
iNormalBounds.SetRect(iPosition, iSize);
|
|
1020 |
}
|
|
1021 |
else
|
|
1022 |
{
|
|
1023 |
newRect = iNormalBounds;
|
|
1024 |
}
|
|
1025 |
|
|
1026 |
if (!aMaximized)
|
|
1027 |
{
|
|
1028 |
iIsMaximized = EFalse;
|
|
1029 |
}
|
|
1030 |
SetBounds(newRect);
|
|
1031 |
if (aMaximized)
|
|
1032 |
{
|
|
1033 |
iIsMaximized = ETrue;
|
|
1034 |
}
|
|
1035 |
Redraw();
|
|
1036 |
}
|
|
1037 |
|
|
1038 |
void CSwtShell::SetMinimized(TBool aMinimized)
|
|
1039 |
{
|
|
1040 |
if (iParent) // minimized is not supported for second level shells
|
|
1041 |
{
|
|
1042 |
return;
|
|
1043 |
}
|
|
1044 |
else
|
|
1045 |
{
|
|
1046 |
if (UiUtils().IsAppFocused() == aMinimized) //Is there anything to do?
|
|
1047 |
{
|
|
1048 |
if (aMinimized)
|
|
1049 |
{
|
|
1050 |
if (UiUtils().GetParentTopShellOfActiveShell() == this) // only active toplevel shells can send to bground
|
|
1051 |
{
|
|
1052 |
UiUtils().ChangeAppFocus(*this, EFalse);
|
|
1053 |
}
|
|
1054 |
}
|
|
1055 |
else
|
|
1056 |
{
|
|
1057 |
UiUtils().ChangeAppFocus(*this, ETrue);
|
|
1058 |
}
|
|
1059 |
}
|
|
1060 |
}
|
|
1061 |
}
|
|
1062 |
|
|
1063 |
TBool CSwtShell::GetMinimized() const
|
|
1064 |
{
|
|
1065 |
if (iParent)
|
|
1066 |
{
|
|
1067 |
return EFalse;
|
|
1068 |
}
|
|
1069 |
else
|
|
1070 |
{
|
|
1071 |
return !UiUtils().IsAppFocused();
|
|
1072 |
}
|
|
1073 |
}
|
|
1074 |
// ---------------------------------------------------------------------------
|
|
1075 |
// CSwtShell::GetText
|
|
1076 |
// From MSwtDecorations
|
|
1077 |
// ---------------------------------------------------------------------------
|
|
1078 |
//
|
|
1079 |
const TDesC* CSwtShell::GetText() const
|
|
1080 |
{
|
|
1081 |
// If this is a Top Level Shell.
|
|
1082 |
if (!GetParent())
|
|
1083 |
{
|
|
1084 |
return iTitleText;
|
|
1085 |
}
|
|
1086 |
else
|
|
1087 |
{
|
|
1088 |
return CSwtDecorations::GetText();
|
|
1089 |
}
|
|
1090 |
}
|
|
1091 |
|
|
1092 |
// ---------------------------------------------------------------------------
|
|
1093 |
// CSwtShell::SetTextL
|
|
1094 |
// From MSwtDecorations
|
|
1095 |
// ---------------------------------------------------------------------------
|
|
1096 |
//
|
|
1097 |
void CSwtShell::SetTextL(const TDesC& aText)
|
|
1098 |
{
|
|
1099 |
// If this is a Top Level Shell.
|
|
1100 |
if (!GetParent())
|
|
1101 |
{
|
|
1102 |
if (iTitleText)
|
|
1103 |
{
|
|
1104 |
delete iTitleText;
|
|
1105 |
iTitleText = NULL;
|
|
1106 |
}
|
|
1107 |
|
|
1108 |
iTitleText = aText.AllocL();
|
|
1109 |
|
|
1110 |
// If this is the current active Shell so the name in the task List
|
|
1111 |
// is update with TitleText.
|
|
1112 |
if (UiUtils().GetActiveShell() == this)
|
|
1113 |
{
|
|
1114 |
UiUtils().UpdateStatusPaneL();
|
|
1115 |
}
|
|
1116 |
}
|
|
1117 |
else
|
|
1118 |
{
|
|
1119 |
CSwtDecorations::SetTextL(aText);
|
|
1120 |
}
|
|
1121 |
}
|
|
1122 |
|
|
1123 |
// ---------------------------------------------------------------------------
|
|
1124 |
// CSwtShell::SetImageL
|
|
1125 |
// From MSwtDecorations
|
|
1126 |
// ---------------------------------------------------------------------------
|
|
1127 |
//
|
|
1128 |
void CSwtShell::SetImageL(const MSwtImage* aImage)
|
|
1129 |
{
|
|
1130 |
CSwtDecorations::SetImageL(aImage);
|
|
1131 |
if (!iParent)
|
|
1132 |
{
|
|
1133 |
// If this is the current active Shell so the image in the Context pane
|
|
1134 |
// is updated.
|
|
1135 |
if (UiUtils().GetActiveShell() == this)
|
|
1136 |
{
|
|
1137 |
UiUtils().UpdateStatusPaneL();
|
|
1138 |
}
|
|
1139 |
}
|
|
1140 |
}
|
|
1141 |
|
|
1142 |
// ---------------------------------------------------------------------------
|
|
1143 |
// CSwtShell::SetMenuBar
|
|
1144 |
// From MSwtDecorations
|
|
1145 |
// ---------------------------------------------------------------------------
|
|
1146 |
//
|
|
1147 |
void CSwtShell::SetMenuBar(const MSwtMenu* aMenuBar)
|
|
1148 |
{
|
|
1149 |
if (aMenuBar)
|
|
1150 |
{
|
|
1151 |
InstallCba();
|
|
1152 |
}
|
|
1153 |
CSwtDecorations::SetMenuBar(aMenuBar);
|
|
1154 |
}
|
|
1155 |
|
|
1156 |
// ---------------------------------------------------------------------------
|
|
1157 |
// CSwtShell::Decorations
|
|
1158 |
// From MSwtShell
|
|
1159 |
// ---------------------------------------------------------------------------
|
|
1160 |
//
|
|
1161 |
MSwtDecorations* CSwtShell::Decorations()
|
|
1162 |
{
|
|
1163 |
return this;
|
|
1164 |
}
|
|
1165 |
|
|
1166 |
// ---------------------------------------------------------------------------
|
|
1167 |
// CSwtShell::GetParentShell
|
|
1168 |
// From MSwtShell
|
|
1169 |
// ---------------------------------------------------------------------------
|
|
1170 |
//
|
|
1171 |
MSwtShell* CSwtShell::GetParentShell()
|
|
1172 |
{
|
|
1173 |
return static_cast<CSwtShell*>(iParent);
|
|
1174 |
}
|
|
1175 |
|
|
1176 |
// ---------------------------------------------------------------------------
|
|
1177 |
// CSwtShell::ForceActive
|
|
1178 |
// From MSwtShell
|
|
1179 |
// ---------------------------------------------------------------------------
|
|
1180 |
//
|
|
1181 |
void CSwtShell::ForceActive()
|
|
1182 |
{
|
|
1183 |
UiUtils().SetActiveShell(*this, ETrue);
|
|
1184 |
}
|
|
1185 |
|
|
1186 |
// ---------------------------------------------------------------------------
|
|
1187 |
// CSwtShell::GetChildShellsPeersL
|
|
1188 |
// From MSwtShell
|
|
1189 |
// ---------------------------------------------------------------------------
|
|
1190 |
//
|
|
1191 |
CSwtPeerArray* CSwtShell::GetChildShellsPeersL()
|
|
1192 |
{
|
|
1193 |
const TInt childCount = iChildren.Count();
|
|
1194 |
if (iChildren.Count() == 0)
|
|
1195 |
{
|
|
1196 |
return NULL;
|
|
1197 |
}
|
|
1198 |
|
|
1199 |
CSwtPeerArray* array = new(ELeave) CSwtPeerArray(KChildrenGranularity);
|
|
1200 |
CleanupStack::PushL(array);
|
|
1201 |
|
|
1202 |
for (TInt i = 0; i < childCount; ++i)
|
|
1203 |
{
|
|
1204 |
MSwtControl* child = iChildren[i];
|
|
1205 |
if (child->IsShell())
|
|
1206 |
{
|
|
1207 |
array->AppendL(child->JavaPeer());
|
|
1208 |
}
|
|
1209 |
}
|
|
1210 |
|
|
1211 |
CleanupStack::Pop(array);
|
|
1212 |
return array;
|
|
1213 |
}
|
|
1214 |
|
|
1215 |
// ---------------------------------------------------------------------------
|
|
1216 |
// CSwtShell::Display
|
|
1217 |
// From MSwtShell
|
|
1218 |
// ---------------------------------------------------------------------------
|
|
1219 |
//
|
|
1220 |
MSwtDisplay& CSwtShell::Display() const
|
|
1221 |
{
|
|
1222 |
return iDisplay;
|
|
1223 |
}
|
|
1224 |
|
|
1225 |
// ---------------------------------------------------------------------------
|
|
1226 |
// CSwtShell::FullScreenMode
|
|
1227 |
// From MSwtShell
|
|
1228 |
// ---------------------------------------------------------------------------
|
|
1229 |
//
|
|
1230 |
TBool CSwtShell::FullScreenMode() const
|
|
1231 |
{
|
|
1232 |
return iFullScreen;
|
|
1233 |
}
|
|
1234 |
|
|
1235 |
// ---------------------------------------------------------------------------
|
|
1236 |
// CSwtShell::GetImeInputMode
|
|
1237 |
// From MSwtShell
|
|
1238 |
// IME stands for Input Method Editor. This is Microsoft's method of allowing
|
|
1239 |
// to enter the thousands of different characters used in East Asian languages
|
|
1240 |
// using a standard 101-key keyboard.
|
|
1241 |
// There are four IME types: Japanese, Korean, Chinese Simplified and
|
|
1242 |
// Chinese Traditional.
|
|
1243 |
// IMEs use different ways of writing Eastern characters: roman, katakana,
|
|
1244 |
// hiragana or the numeric codes ( the unicode values ).
|
|
1245 |
// There are different flags used to control how a key stroke is converted into
|
|
1246 |
// an asian character. The flats are:
|
|
1247 |
// - NONE if set means the IME is not in use. This is the only behaviour we
|
|
1248 |
// support on non APAC variants of eSWT. We do this by returning 0 in SWT.
|
|
1249 |
// - ROMAN if set means that the roman conversion method is used.
|
|
1250 |
// - FULLSHAPE (known as DBCS in SWT) if set means that two bytes are used
|
|
1251 |
// instead of one.
|
|
1252 |
// - KATAKANA (known as phonetic in SWT) if set means that katakana is used.
|
|
1253 |
// If not set it means that hiragana is used.
|
|
1254 |
// - NATIVE if set means that one of the native methods is used. If not set
|
|
1255 |
// it means that alpha numeric codes are used.
|
|
1256 |
// ---------------------------------------------------------------------------
|
|
1257 |
//
|
|
1258 |
TInt CSwtShell::GetImeInputMode() const
|
|
1259 |
{
|
|
1260 |
return 0;
|
|
1261 |
}
|
|
1262 |
|
|
1263 |
// ---------------------------------------------------------------------------
|
|
1264 |
// CSwtShell::GetMinimumSize
|
|
1265 |
// From MSwtShell
|
|
1266 |
// ---------------------------------------------------------------------------
|
|
1267 |
//
|
|
1268 |
TSize CSwtShell::GetMinimumSize() const
|
|
1269 |
{
|
|
1270 |
// Top-level Shells have always the same minimum size: the application area
|
|
1271 |
if (!iParent)
|
|
1272 |
{
|
|
1273 |
return iEikonEnv->EikAppUi()->ClientRect().Size();
|
|
1274 |
}
|
|
1275 |
|
|
1276 |
// If there is a user-specified minimum size: use it
|
|
1277 |
if (iMinSize != TSize(-1,-1))
|
|
1278 |
{
|
|
1279 |
return iMinSize;
|
|
1280 |
}
|
|
1281 |
|
|
1282 |
// The minimum size if the size of the trimmings
|
|
1283 |
TRect trim(0, 0, 0, 0);
|
|
1284 |
ComputeTrim(trim);
|
|
1285 |
return trim.Size();
|
|
1286 |
}
|
|
1287 |
|
|
1288 |
|
|
1289 |
// ---------------------------------------------------------------------------
|
|
1290 |
// CSwtShell::SetImeInputMode
|
|
1291 |
// From MSwtShell
|
|
1292 |
// ---------------------------------------------------------------------------
|
|
1293 |
//
|
|
1294 |
void CSwtShell::SetImeInputMode(TInt /*aMode*/)
|
|
1295 |
{
|
|
1296 |
//Do nothing
|
|
1297 |
}
|
|
1298 |
|
|
1299 |
// ---------------------------------------------------------------------------
|
|
1300 |
// CSwtShell::SetMinimumSize
|
|
1301 |
// From MSwtShell
|
|
1302 |
// ---------------------------------------------------------------------------
|
|
1303 |
//
|
|
1304 |
void CSwtShell::SetMinimumSize(const TSize& aMinimumSize)
|
|
1305 |
{
|
|
1306 |
// The minimum size of top-level Shells cannot be modified
|
|
1307 |
if (!iParent)
|
|
1308 |
{
|
|
1309 |
return;
|
|
1310 |
}
|
|
1311 |
|
|
1312 |
// The absolute minimum size: the size of the trimmings
|
|
1313 |
TRect trim(0, 0, 0, 0);
|
|
1314 |
ComputeTrim(trim);
|
|
1315 |
const TSize trimSize(trim.Size());
|
|
1316 |
|
|
1317 |
// Adjust the specified minimum size to be no less than the absolute minimum
|
|
1318 |
iMinSize.iWidth = Max(aMinimumSize.iWidth, trimSize.iWidth);
|
|
1319 |
iMinSize.iHeight = Max(aMinimumSize.iHeight, trimSize.iHeight);
|
|
1320 |
|
|
1321 |
// Adjust current size to be at least as big as the minimum size
|
|
1322 |
TSize newSize(Max(iMinSize.iWidth,iSize.iWidth),
|
|
1323 |
Max(iMinSize.iHeight,iSize.iHeight));
|
|
1324 |
if (newSize != iSize)
|
|
1325 |
{
|
|
1326 |
SetSize(newSize);
|
|
1327 |
}
|
|
1328 |
}
|
|
1329 |
|
|
1330 |
// ---------------------------------------------------------------------------
|
|
1331 |
// CSwtShell::SetStyle
|
|
1332 |
// From MSwtShell
|
|
1333 |
// ---------------------------------------------------------------------------
|
|
1334 |
//
|
|
1335 |
void CSwtShell::SetStyle(TInt aStyle)
|
|
1336 |
{
|
|
1337 |
iStyle = aStyle;
|
|
1338 |
}
|
|
1339 |
|
|
1340 |
// ---------------------------------------------------------------------------
|
|
1341 |
// CSwtShell::GetFullTabListL
|
|
1342 |
// From MSwtShell
|
|
1343 |
// ---------------------------------------------------------------------------
|
|
1344 |
//
|
|
1345 |
const RSwtControlArray& CSwtShell::GetFullTabListL()
|
|
1346 |
{
|
|
1347 |
if (iFullTabList.Count() == 0)
|
|
1348 |
{
|
|
1349 |
ComputeTabListL(iFullTabList); // codescanner::leave
|
|
1350 |
}
|
|
1351 |
|
|
1352 |
#ifdef _DEBUG
|
|
1353 |
// Make sure the list contains no Shell
|
|
1354 |
const TInt count = iFullTabList.Count();
|
|
1355 |
for (TInt i=0; i < count; ++i)
|
|
1356 |
{
|
|
1357 |
ASSERT(!iFullTabList[i]->IsShell());
|
|
1358 |
}
|
|
1359 |
#endif
|
|
1360 |
|
|
1361 |
return iFullTabList;
|
|
1362 |
}
|
|
1363 |
|
|
1364 |
// ---------------------------------------------------------------------------
|
|
1365 |
// CSwtShell::CSwtShell
|
|
1366 |
// From MSwtShell
|
|
1367 |
// ---------------------------------------------------------------------------
|
|
1368 |
//
|
|
1369 |
void CSwtShell::ResetTabList()
|
|
1370 |
{
|
|
1371 |
iFullTabList.Reset();
|
|
1372 |
}
|
|
1373 |
|
|
1374 |
// ---------------------------------------------------------------------------
|
|
1375 |
// CSwtShell::FindTraversalTargetL
|
|
1376 |
// From MSwtShell
|
|
1377 |
// ---------------------------------------------------------------------------
|
|
1378 |
//
|
|
1379 |
MSwtControl* CSwtShell::FindTraversalTargetL(TInt aDetail,
|
|
1380 |
MSwtControl& aFocusControl, RSwtControlArray* aExcludedControls)
|
|
1381 |
{
|
|
1382 |
MSwtControl* ctrl = &aFocusControl;
|
|
1383 |
MSwtControl* newFocus = NULL;
|
|
1384 |
|
|
1385 |
// Tab traversal, use the tab list
|
|
1386 |
if (aDetail == ESwtTraverseTabNext || aDetail == ESwtTraverseTabPrevious ||
|
|
1387 |
aDetail == ESwtTraverseArrowNext || aDetail == ESwtTraverseArrowPrevious)
|
|
1388 |
{
|
|
1389 |
// If Shell itself force focused, start from the first child.
|
|
1390 |
if (ctrl->ShellInterface() == this)
|
|
1391 |
{
|
|
1392 |
ctrl = NULL;
|
|
1393 |
if (iChildren.Count())
|
|
1394 |
{
|
|
1395 |
ctrl = iChildren[0];
|
|
1396 |
}
|
|
1397 |
}
|
|
1398 |
|
|
1399 |
if (!ctrl)
|
|
1400 |
{
|
|
1401 |
return this;
|
|
1402 |
}
|
|
1403 |
|
|
1404 |
const RSwtControlArray& tabList = GetFullTabListL();
|
|
1405 |
const TInt oldIndex = tabList.Find(ctrl);
|
|
1406 |
|
|
1407 |
if (oldIndex == KErrNotFound)
|
|
1408 |
{
|
|
1409 |
// A control can be excluded from tablist. If so, just set traverse
|
|
1410 |
// target to the nearest control which is in the tablist
|
|
1411 |
MSwtControl* control = ctrl;
|
|
1412 |
MSwtComposite* parent = control->GetParent();
|
|
1413 |
const RSwtControlArray* children;
|
|
1414 |
while (control && parent)
|
|
1415 |
{
|
|
1416 |
children = parent->Children();
|
|
1417 |
ASSERT(children);
|
|
1418 |
TInt controlIndex = children->Find(control);
|
|
1419 |
if (controlIndex < 0)
|
|
1420 |
{
|
|
1421 |
// The control has a parent and its parent does not know this child,
|
|
1422 |
// which means the parents should not be used as a composite
|
|
1423 |
break;
|
|
1424 |
}
|
|
1425 |
// find the nearest control in the tablist from sibling
|
|
1426 |
const TInt count = children->Count();
|
|
1427 |
const TInt inc = (aDetail == ESwtTraverseTabNext || aDetail == ESwtTraverseArrowNext) ? 1 : count-1;
|
|
1428 |
TInt i = controlIndex;
|
|
1429 |
while ((i = (i + inc) % count) != controlIndex)
|
|
1430 |
{
|
|
1431 |
MSwtControl* ctl = tabList[i];
|
|
1432 |
if ((tabList.Find(ctl) != KErrNotFound)
|
|
1433 |
&& (ctl->IsFocusable())
|
|
1434 |
&& ((!aExcludedControls)
|
|
1435 |
|| (aExcludedControls->Find(ctl) == KErrNotFound)))
|
|
1436 |
{
|
|
1437 |
newFocus = ctl;
|
|
1438 |
break;
|
|
1439 |
}
|
|
1440 |
}
|
|
1441 |
// goes to the parent level
|
|
1442 |
control = parent->Control();
|
|
1443 |
parent = control->GetParent();
|
|
1444 |
}
|
|
1445 |
}
|
|
1446 |
else
|
|
1447 |
{
|
|
1448 |
//ASSERT( oldIndex != KErrNotFound );
|
|
1449 |
const TInt count = tabList.Count();
|
|
1450 |
const TInt inc = (aDetail == ESwtTraverseTabNext
|
|
1451 |
|| aDetail == ESwtTraverseArrowNext) ? 1 : count - 1;
|
|
1452 |
|
|
1453 |
TInt i = oldIndex;
|
|
1454 |
while ((i = (i + inc) % count) != oldIndex)
|
|
1455 |
{
|
|
1456 |
MSwtControl* ctl = tabList[i];
|
|
1457 |
if ((ctl->IsFocusable()) && ((!aExcludedControls)
|
|
1458 |
|| (aExcludedControls->Find(ctl) == KErrNotFound)))
|
|
1459 |
{
|
|
1460 |
newFocus = ctl;
|
|
1461 |
break;
|
|
1462 |
}
|
|
1463 |
}
|
|
1464 |
}
|
|
1465 |
}
|
|
1466 |
else if (aDetail == ESwtTraverseParent)
|
|
1467 |
{
|
|
1468 |
MSwtControl* parentCtrl = NULL;
|
|
1469 |
MSwtComposite* parent = aFocusControl.GetParent();
|
|
1470 |
while (parent)
|
|
1471 |
{
|
|
1472 |
parentCtrl = parent->Control();
|
|
1473 |
|
|
1474 |
RSwtControlArray tabList;
|
|
1475 |
parentCtrl->ComputeTabListL(tabList);
|
|
1476 |
TInt count = tabList.Count();
|
|
1477 |
for (TInt i = 0; i < count; i++)
|
|
1478 |
{
|
|
1479 |
MSwtControl* ctrl = tabList[i];
|
|
1480 |
if (ctrl != &aFocusControl && ctrl->IsFocusable())
|
|
1481 |
{
|
|
1482 |
newFocus = ctrl;
|
|
1483 |
break; // for
|
|
1484 |
}
|
|
1485 |
}
|
|
1486 |
tabList.Close();
|
|
1487 |
|
|
1488 |
if (newFocus)
|
|
1489 |
{
|
|
1490 |
break; // while
|
|
1491 |
}
|
|
1492 |
|
|
1493 |
if (parentCtrl->IsFocusable())
|
|
1494 |
{
|
|
1495 |
newFocus = parentCtrl;
|
|
1496 |
break; // while
|
|
1497 |
}
|
|
1498 |
|
|
1499 |
if (parentCtrl->IsShell())
|
|
1500 |
{
|
|
1501 |
break;
|
|
1502 |
}
|
|
1503 |
|
|
1504 |
parent = parentCtrl->GetParent();
|
|
1505 |
}
|
|
1506 |
}
|
|
1507 |
|
|
1508 |
if (newFocus == &aFocusControl)
|
|
1509 |
{
|
|
1510 |
newFocus = NULL;
|
|
1511 |
}
|
|
1512 |
|
|
1513 |
return newFocus;
|
|
1514 |
}
|
|
1515 |
|
|
1516 |
// ---------------------------------------------------------------------------
|
|
1517 |
// CSwtShell::SetFocusControl
|
|
1518 |
// From MSwtShell
|
|
1519 |
// ---------------------------------------------------------------------------
|
|
1520 |
//
|
|
1521 |
void CSwtShell::SetFocusControl(MSwtControl* aControl)
|
|
1522 |
{
|
|
1523 |
// If this Shell is active, then the specified control must be either NULL
|
|
1524 |
// or already focused
|
|
1525 |
ASSERT(UiUtils().GetActiveShell() != this || !aControl
|
|
1526 |
|| aControl->CoeControl().IsFocused());
|
|
1527 |
// Old focus control must first be removed before setting new one
|
|
1528 |
ASSERT(!iFocusControl || !aControl);
|
|
1529 |
ASSERT(aControl != iFocusControl || !aControl);
|
|
1530 |
ASSERT(aControl != this);
|
|
1531 |
ASSERT(!aControl || !aControl->IsShell());
|
|
1532 |
|
|
1533 |
if (aControl)
|
|
1534 |
{
|
|
1535 |
iFocusMemory = NULL;
|
|
1536 |
}
|
|
1537 |
|
|
1538 |
// The control which gain the Focus.
|
|
1539 |
if (aControl)
|
|
1540 |
{
|
|
1541 |
// The Control which gain he Focus is a Push Button
|
|
1542 |
MSwtButton* focusedButton = aControl->ButtonInterface();
|
|
1543 |
if (focusedButton && (aControl->Style() & KSwtStylePush))
|
|
1544 |
{
|
|
1545 |
// Set the Focused Button to Default.
|
|
1546 |
SetFocusedDefaultButton(focusedButton);
|
|
1547 |
}
|
|
1548 |
else
|
|
1549 |
{
|
|
1550 |
// If the focused Control is not a Push Button,
|
|
1551 |
// then set the DefaultButton on the Shell to DefaultButton.
|
|
1552 |
if (OriginalDefaultButton())
|
|
1553 |
{
|
|
1554 |
const_cast<MSwtButton*>(OriginalDefaultButton())->SetDefault(ETrue);
|
|
1555 |
}
|
|
1556 |
}
|
|
1557 |
}
|
|
1558 |
// The control which lost Focus.
|
|
1559 |
else if (iFocusControl)
|
|
1560 |
{
|
|
1561 |
// The Control which lost he Focus is a Push Button
|
|
1562 |
if (iFocusControl->ButtonInterface()
|
|
1563 |
&& (iFocusControl->Style() & KSwtStylePush))
|
|
1564 |
{
|
|
1565 |
// So remove the DefaultButton status on it.
|
|
1566 |
SetFocusedDefaultButton(NULL);
|
|
1567 |
}
|
|
1568 |
}
|
|
1569 |
|
|
1570 |
DoSetFocusControl(aControl);
|
|
1571 |
}
|
|
1572 |
|
|
1573 |
// ---------------------------------------------------------------------------
|
|
1574 |
// CSwtShell::HasModalChild
|
|
1575 |
// From MSwtShell
|
|
1576 |
// ---------------------------------------------------------------------------
|
|
1577 |
//
|
|
1578 |
TBool CSwtShell::HasModalChild() const
|
|
1579 |
{
|
|
1580 |
ASSERT(EFalse);
|
|
1581 |
return EFalse;
|
|
1582 |
}
|
|
1583 |
|
|
1584 |
// ---------------------------------------------------------------------------
|
|
1585 |
// CSwtShell::ActivityChanged
|
|
1586 |
// From MSwtShell
|
|
1587 |
// ---------------------------------------------------------------------------
|
|
1588 |
//
|
|
1589 |
void CSwtShell::ActivityChanged(TBool aIsActive, TBool aSetFocus)
|
|
1590 |
{
|
|
1591 |
iControlGainingFocus = NULL;
|
|
1592 |
iControlGoingToStack = NULL;
|
|
1593 |
|
|
1594 |
// Becoming active
|
|
1595 |
if (aIsActive)
|
|
1596 |
{
|
|
1597 |
ASSERT(!iFocusControl);
|
|
1598 |
|
|
1599 |
TRAP_IGNORE(AddToControlStackL(ECoeStackPriorityDefault));
|
|
1600 |
|
|
1601 |
// Set the top level Shell title in the task list.
|
|
1602 |
const TDesC* titleText = GetText();
|
|
1603 |
|
|
1604 |
// Find a focus control
|
|
1605 |
MSwtControl* newFocusControl = NULL;
|
|
1606 |
|
|
1607 |
if (aSetFocus)
|
|
1608 |
{
|
|
1609 |
if (!iFocusMemory)
|
|
1610 |
{
|
|
1611 |
// First focusable one in the tab list
|
|
1612 |
const RSwtControlArray* tabList = NULL;
|
|
1613 |
TRAP_IGNORE((tabList=&GetFullTabListL()));
|
|
1614 |
if (tabList)
|
|
1615 |
{
|
|
1616 |
const TInt count= tabList->Count();
|
|
1617 |
for (TInt i=0; i<count; ++i)
|
|
1618 |
{
|
|
1619 |
MSwtControl* ctrl = (*tabList)[i];
|
|
1620 |
if (ctrl->IsFocusable())
|
|
1621 |
{
|
|
1622 |
newFocusControl = ctrl;
|
|
1623 |
break;
|
|
1624 |
}
|
|
1625 |
}
|
|
1626 |
}
|
|
1627 |
}
|
|
1628 |
else if (!iFocusMemory->IsFocusable())
|
|
1629 |
{
|
|
1630 |
TRAP_IGNORE((newFocusControl = FindTraversalTargetL(
|
|
1631 |
ESwtTraverseTabPrevious, *iFocusMemory)));
|
|
1632 |
}
|
|
1633 |
else
|
|
1634 |
{
|
|
1635 |
newFocusControl = iFocusMemory;
|
|
1636 |
}
|
|
1637 |
}
|
|
1638 |
|
|
1639 |
iFocusMemory = NULL;
|
|
1640 |
|
|
1641 |
TRAP_IGNORE(iDisplay.PostShellEventL(iPeer, ESwtEventActivate));
|
|
1642 |
|
|
1643 |
if (newFocusControl)
|
|
1644 |
{
|
|
1645 |
// Give focus to the focus control
|
|
1646 |
ASSERT(!newFocusControl->IsShell());
|
|
1647 |
CCoeControl& coeFocusCtrl = newFocusControl->CoeControl();
|
|
1648 |
if (!coeFocusCtrl.IsFocused())
|
|
1649 |
{
|
|
1650 |
// This will set iFocusControl to the correct value
|
|
1651 |
coeFocusCtrl.SetFocus(ETrue);
|
|
1652 |
ASSERT(&iFocusControl->CoeControl() == &coeFocusCtrl);
|
|
1653 |
}
|
|
1654 |
ASSERT(coeFocusCtrl.IsFocused());
|
|
1655 |
}
|
|
1656 |
else
|
|
1657 |
{
|
|
1658 |
// No focusable Control found, the Shell is active on its own.
|
|
1659 |
// Clear the next focusable Control in UiUtils. If this is not
|
|
1660 |
// done, when returning from screen saver, the app will jump
|
|
1661 |
// to the parent Shell of the next focusable control
|
|
1662 |
UiUtils().SetNextFocusedControl(NULL);
|
|
1663 |
}
|
|
1664 |
|
|
1665 |
MSwtUiUtils& utils = iDisplay.UiUtils();
|
|
1666 |
if (!iFullScreen)
|
|
1667 |
{
|
|
1668 |
if (HasCba())
|
|
1669 |
{
|
|
1670 |
// Shell has CBA, force CBA visible
|
|
1671 |
utils.SetCbaVisible(ETrue);
|
|
1672 |
}
|
|
1673 |
else
|
|
1674 |
{
|
|
1675 |
if (iParent)
|
|
1676 |
{
|
|
1677 |
// Child Shell does not have CBA.
|
|
1678 |
// It can be made invisible if topmost shell is fullscreen.
|
|
1679 |
MSwtShell* topMostShell = utils.TopMostTopShell();
|
|
1680 |
if (topMostShell && topMostShell->FullScreenMode())
|
|
1681 |
{
|
|
1682 |
utils.SetCbaVisible(EFalse);
|
|
1683 |
}
|
|
1684 |
}
|
|
1685 |
// Top Shells which are not fullscreen always have CBA
|
|
1686 |
}
|
|
1687 |
}
|
|
1688 |
else
|
|
1689 |
{
|
|
1690 |
utils.SetCbaVisible(EFalse);
|
|
1691 |
}
|
|
1692 |
}
|
|
1693 |
// Becoming inactive
|
|
1694 |
else
|
|
1695 |
{
|
|
1696 |
TRAP_IGNORE(iDisplay.PostShellEventL(iPeer, ESwtEventDeactivate));
|
|
1697 |
if (iFocusControl)
|
|
1698 |
{
|
|
1699 |
RemoveAndRememberFocus();
|
|
1700 |
}
|
|
1701 |
RemoveFromControlStack();
|
|
1702 |
|
|
1703 |
// Just in case we were in the middle of kinetic action
|
|
1704 |
SetUrgentPaintControl(NULL);
|
|
1705 |
}
|
|
1706 |
|
|
1707 |
// Notify Menu arranger
|
|
1708 |
if (aIsActive)
|
|
1709 |
{
|
|
1710 |
iDisplay.MenuArranger().ActiveShellGained(*this);
|
|
1711 |
}
|
|
1712 |
else
|
|
1713 |
{
|
|
1714 |
iDisplay.MenuArranger().ActiveShellLost();
|
|
1715 |
}
|
|
1716 |
|
|
1717 |
// Notify Command arranger
|
|
1718 |
MSwtCommandArranger* commandArranger = iDisplay.CommandArranger();
|
|
1719 |
if (commandArranger)
|
|
1720 |
{
|
|
1721 |
if (aIsActive)
|
|
1722 |
{
|
|
1723 |
commandArranger->ActiveShellGained(*this);
|
|
1724 |
}
|
|
1725 |
else
|
|
1726 |
{
|
|
1727 |
commandArranger->ActiveShellLost();
|
|
1728 |
}
|
|
1729 |
}
|
|
1730 |
}
|
|
1731 |
|
|
1732 |
// ---------------------------------------------------------------------------
|
|
1733 |
// CSwtShell::SetZPosition
|
|
1734 |
// From MSwtShell
|
|
1735 |
// ---------------------------------------------------------------------------
|
|
1736 |
//
|
|
1737 |
void CSwtShell::SetZPosition(TInt aZPosition)
|
|
1738 |
{
|
|
1739 |
Window().SetOrdinalPosition(aZPosition);
|
|
1740 |
|
|
1741 |
// Set our children at the same position ( to avoid having them behind us )
|
|
1742 |
const TInt count = iChildren.Count();
|
|
1743 |
// The foreground child is the first one, hence our looping backwards
|
|
1744 |
for (TInt i = count - 1; i >= 0; --i)
|
|
1745 |
{
|
|
1746 |
MSwtShell* childShell = iChildren[i]->ShellInterface();
|
|
1747 |
if (childShell)
|
|
1748 |
{
|
|
1749 |
childShell->SetZPosition(aZPosition);
|
|
1750 |
}
|
|
1751 |
}
|
|
1752 |
}
|
|
1753 |
|
|
1754 |
// ---------------------------------------------------------------------------
|
|
1755 |
// CSwtShell::FocusControl
|
|
1756 |
// From MSwtShell
|
|
1757 |
// ---------------------------------------------------------------------------
|
|
1758 |
//
|
|
1759 |
MSwtControl* CSwtShell::FocusControl() const
|
|
1760 |
{
|
|
1761 |
return iFocusControl;
|
|
1762 |
}
|
|
1763 |
|
|
1764 |
// ---------------------------------------------------------------------------
|
|
1765 |
// CSwtShell::SetDefaultCommand
|
|
1766 |
// From MSwtShell
|
|
1767 |
// ---------------------------------------------------------------------------
|
|
1768 |
//
|
|
1769 |
void CSwtShell::SetDefaultCommand(const MSwtCommand* aCommand)
|
|
1770 |
{
|
|
1771 |
iDefaultCommand = aCommand;
|
|
1772 |
}
|
|
1773 |
|
|
1774 |
// ---------------------------------------------------------------------------
|
|
1775 |
// CSwtShell::DefaultCommand
|
|
1776 |
// From MSwtShell
|
|
1777 |
// ---------------------------------------------------------------------------
|
|
1778 |
//
|
|
1779 |
const MSwtCommand* CSwtShell::DefaultCommand() const
|
|
1780 |
{
|
|
1781 |
return iDefaultCommand;
|
|
1782 |
}
|
|
1783 |
|
|
1784 |
// ---------------------------------------------------------------------------
|
|
1785 |
// CSwtShell::SetFullScreen
|
|
1786 |
// From MSwtShell
|
|
1787 |
// ---------------------------------------------------------------------------
|
|
1788 |
//
|
|
1789 |
void CSwtShell::SetFullScreen(TBool aFullScreen)
|
|
1790 |
{
|
|
1791 |
if (aFullScreen == iFullScreen)
|
|
1792 |
{
|
|
1793 |
return;
|
|
1794 |
}
|
|
1795 |
iFullScreen = aFullScreen;
|
|
1796 |
CSwtUiUtils& utils = UiUtils();
|
|
1797 |
SetRedraw(EFalse);
|
|
1798 |
MSwtShell* activeTopShell = utils.GetParentTopShellOfActiveShell();
|
|
1799 |
MSwtCommandArranger* commandArranger = iDisplay.CommandArranger();
|
|
1800 |
if (aFullScreen)
|
|
1801 |
{
|
|
1802 |
if (activeTopShell == this)
|
|
1803 |
{
|
|
1804 |
if (commandArranger)
|
|
1805 |
{
|
|
1806 |
commandArranger->ActiveShellGained(*this);
|
|
1807 |
}
|
|
1808 |
utils.SetCbaVisible(EFalse);
|
|
1809 |
}
|
|
1810 |
iStyle &= ~KSwtStyleTitle;
|
|
1811 |
}
|
|
1812 |
else
|
|
1813 |
{
|
|
1814 |
if (activeTopShell == this)
|
|
1815 |
{
|
|
1816 |
if (commandArranger)
|
|
1817 |
{
|
|
1818 |
commandArranger->ActiveShellGained(*this);
|
|
1819 |
}
|
|
1820 |
if (HasCba())
|
|
1821 |
{
|
|
1822 |
utils.SetCbaVisible(ETrue);
|
|
1823 |
}
|
|
1824 |
}
|
|
1825 |
iStyle = iSavedStyle;
|
|
1826 |
}
|
|
1827 |
|
|
1828 |
// Update status pane
|
|
1829 |
if (utils.GetActiveShell() == this)
|
|
1830 |
{
|
|
1831 |
TRAP_IGNORE(utils.UpdateStatusPaneL());
|
|
1832 |
}
|
|
1833 |
|
|
1834 |
DoSetRect(DefaultBounds());
|
|
1835 |
|
|
1836 |
SetRedraw(ETrue);
|
|
1837 |
}
|
|
1838 |
|
|
1839 |
// ---------------------------------------------------------------------------
|
|
1840 |
// CSwtShell::SetControlGoingToStack
|
|
1841 |
// From MSwtShell
|
|
1842 |
// ---------------------------------------------------------------------------
|
|
1843 |
//
|
|
1844 |
void CSwtShell::SetControlGoingToStack(MSwtControl* aControl)
|
|
1845 |
{
|
|
1846 |
iControlGoingToStack = aControl;
|
|
1847 |
}
|
|
1848 |
|
|
1849 |
// ---------------------------------------------------------------------------
|
|
1850 |
// CSwtShell::SetControlGainingFocus
|
|
1851 |
// From MSwtShell
|
|
1852 |
// ---------------------------------------------------------------------------
|
|
1853 |
//
|
|
1854 |
void CSwtShell::SetControlGainingFocus(MSwtControl* aControl)
|
|
1855 |
{
|
|
1856 |
iControlGainingFocus = aControl;
|
|
1857 |
}
|
|
1858 |
|
|
1859 |
// ---------------------------------------------------------------------------
|
|
1860 |
// CSwtUiUtils::DefaultBounds
|
|
1861 |
// From MSwtShell
|
|
1862 |
// ---------------------------------------------------------------------------
|
|
1863 |
//
|
|
1864 |
TRect CSwtShell::DefaultBounds() const
|
|
1865 |
{
|
|
1866 |
TRect rect;
|
|
1867 |
TInt variety(0);
|
|
1868 |
if (iParent)
|
|
1869 |
{
|
|
1870 |
// Dialog shells
|
|
1871 |
AknLayoutUtils::TAknCbaLocation cbaLocation(AknLayoutUtils::CbaLocation());
|
|
1872 |
|
|
1873 |
// variety numbers for right CBA are
|
|
1874 |
if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight)
|
|
1875 |
{
|
|
1876 |
variety = 9; // 13 - 7 (highest)
|
|
1877 |
}
|
|
1878 |
else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft)
|
|
1879 |
{
|
|
1880 |
variety = 16; // 20 - 14 (highest)
|
|
1881 |
}
|
|
1882 |
else
|
|
1883 |
{
|
|
1884 |
variety = 4; // 0 - 6 (highest)
|
|
1885 |
}
|
|
1886 |
|
|
1887 |
TRect mainPane;
|
|
1888 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EPopupParent, mainPane);
|
|
1889 |
rect = CSwtLafFacade::GetLayoutRect(CSwtLafFacade::EPopupWindowGeneral, mainPane, variety).Rect();
|
|
1890 |
|
|
1891 |
if (HasTitleStyle())
|
|
1892 |
{
|
|
1893 |
TInt h(CSwtLafFacade::GetLayoutRect(CSwtLafFacade::EHeadingPane, mainPane).Rect().Height());
|
|
1894 |
if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight
|
|
1895 |
|| cbaLocation == AknLayoutUtils::EAknCbaLocationLeft)
|
|
1896 |
{
|
|
1897 |
rect.iTl.iY -= h / 2;
|
|
1898 |
rect.iBr.iY += h / 2;
|
|
1899 |
}
|
|
1900 |
else
|
|
1901 |
{
|
|
1902 |
rect.iTl.iY -= h;
|
|
1903 |
}
|
|
1904 |
}
|
|
1905 |
}
|
|
1906 |
else
|
|
1907 |
{
|
|
1908 |
// Top shells
|
|
1909 |
TRect screenRect;
|
|
1910 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screenRect);
|
|
1911 |
if (FullScreenMode())
|
|
1912 |
{
|
|
1913 |
return screenRect;
|
|
1914 |
}
|
|
1915 |
if (CSwtLafFacade::IsLandscapeOrientation())
|
|
1916 |
{
|
|
1917 |
variety = AknLayoutUtils::PenEnabled() ?
|
|
1918 |
KSwtMainPainVarietySmallSpLandscapePen :
|
|
1919 |
KSwtMainPainVarietySmallSpLandscape;
|
|
1920 |
}
|
|
1921 |
else
|
|
1922 |
{
|
|
1923 |
variety = KSwtMainPainVarietyClassic;
|
|
1924 |
}
|
|
1925 |
|
|
1926 |
TAknLayoutRect layoutRect = CSwtLafFacade::GetComposeAndLayoutRect(
|
|
1927 |
CSwtLafFacade::EMainPaneCompose, screenRect, variety);
|
|
1928 |
rect = layoutRect.Rect();
|
|
1929 |
if (!HasCba())
|
|
1930 |
{
|
|
1931 |
rect.iBr = screenRect.iBr;
|
|
1932 |
}
|
|
1933 |
}
|
|
1934 |
|
|
1935 |
return rect;
|
|
1936 |
}
|
|
1937 |
|
|
1938 |
// ---------------------------------------------------------------------------
|
|
1939 |
// CSwtShell::SetToBeFocusedControl
|
|
1940 |
// From MSwtShell
|
|
1941 |
// ---------------------------------------------------------------------------
|
|
1942 |
//
|
|
1943 |
void CSwtShell::SetToBeFocusedControl(MSwtControl* aControl)
|
|
1944 |
{
|
|
1945 |
ASSERT(!iFocusControl || !iFocusControl->CoeControl().IsFocused());
|
|
1946 |
|
|
1947 |
if (iFocusControl)
|
|
1948 |
{
|
|
1949 |
DoSetFocusControl(NULL);
|
|
1950 |
}
|
|
1951 |
|
|
1952 |
iFocusMemory = aControl;
|
|
1953 |
}
|
|
1954 |
|
|
1955 |
// ---------------------------------------------------------------------------
|
|
1956 |
// CSwtShell::CheckFocusMemory
|
|
1957 |
// From MSwtShell
|
|
1958 |
// ---------------------------------------------------------------------------
|
|
1959 |
//
|
|
1960 |
void CSwtShell::CheckFocusMemory(MSwtControl& aUnregisteredControl)
|
|
1961 |
{
|
|
1962 |
// if shell still keeps reference to control, that is going to be
|
|
1963 |
// unregistered, that set the reference to another control
|
|
1964 |
if (iFocusMemory == &aUnregisteredControl)
|
|
1965 |
{
|
|
1966 |
iFocusMemory = NULL;
|
|
1967 |
TRAP_IGNORE((iFocusMemory=FindTraversalTargetL(
|
|
1968 |
ESwtTraverseTabPrevious, aUnregisteredControl)));
|
|
1969 |
}
|
|
1970 |
}
|
|
1971 |
|
|
1972 |
// ---------------------------------------------------------------------------
|
|
1973 |
// CSwtShell::SetUrgentPaintControl
|
|
1974 |
// From MSwtShell
|
|
1975 |
// ---------------------------------------------------------------------------
|
|
1976 |
//
|
|
1977 |
void CSwtShell::SetUrgentPaintControl(MSwtControl* aControl)
|
|
1978 |
{
|
|
1979 |
if (iUrgentPaintControl != aControl)
|
|
1980 |
{
|
|
1981 |
if (aControl)
|
|
1982 |
{
|
|
1983 |
iUrgentPaintControl = aControl;
|
|
1984 |
}
|
|
1985 |
else
|
|
1986 |
{
|
|
1987 |
iUrgentPaintControl = NULL;
|
|
1988 |
|
|
1989 |
// Request a full redraw from Window Server.
|
|
1990 |
// Mandatory at least for PaintListeners which call redraw()
|
|
1991 |
DrawDeferred();
|
|
1992 |
}
|
|
1993 |
}
|
|
1994 |
}
|
|
1995 |
|
|
1996 |
// ---------------------------------------------------------------------------
|
|
1997 |
// CSwtShell::UrgentPaintControl
|
|
1998 |
// From MSwtShell
|
|
1999 |
// ---------------------------------------------------------------------------
|
|
2000 |
//
|
|
2001 |
MSwtControl* CSwtShell::UrgentPaintControl() const
|
|
2002 |
{
|
|
2003 |
return iUrgentPaintControl;
|
|
2004 |
}
|
|
2005 |
|
|
2006 |
// ---------------------------------------------------------------------------
|
|
2007 |
// CSwtShell::AsyncPainting
|
|
2008 |
// From MSwtShell
|
|
2009 |
// ---------------------------------------------------------------------------
|
|
2010 |
//
|
|
2011 |
TBool CSwtShell::AsyncPainting() const
|
|
2012 |
{
|
|
2013 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
2014 |
return iAsyncPainting;
|
|
2015 |
#else
|
|
2016 |
return ETrue;
|
|
2017 |
#endif
|
|
2018 |
}
|
|
2019 |
|
|
2020 |
// ---------------------------------------------------------------------------
|
|
2021 |
// CSwtShell::SetAsyncPainting
|
|
2022 |
// From MSwtShell
|
|
2023 |
// ---------------------------------------------------------------------------
|
|
2024 |
//
|
|
2025 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
2026 |
void CSwtShell::SetAsyncPainting(TBool aStatus)
|
|
2027 |
{
|
|
2028 |
iAsyncPainting = aStatus;
|
|
2029 |
}
|
|
2030 |
#else
|
|
2031 |
void CSwtShell::SetAsyncPainting(TBool)
|
|
2032 |
{
|
|
2033 |
}
|
|
2034 |
#endif
|
|
2035 |
|
|
2036 |
// ---------------------------------------------------------------------------
|
|
2037 |
// CSwtShell::InstallCba
|
|
2038 |
// From MSwtShell
|
|
2039 |
// ---------------------------------------------------------------------------
|
|
2040 |
//
|
|
2041 |
void CSwtShell::InstallCba()
|
|
2042 |
{
|
|
2043 |
if (iHasCba)
|
|
2044 |
{
|
|
2045 |
return;
|
|
2046 |
}
|
|
2047 |
iHasCba = ETrue;
|
|
2048 |
MSwtUiUtils& utils = iDisplay.UiUtils();
|
|
2049 |
if (utils.GetActiveShell() == this)
|
|
2050 |
{
|
|
2051 |
utils.SetCbaVisible(ETrue);
|
|
2052 |
}
|
|
2053 |
}
|
|
2054 |
|
|
2055 |
// ---------------------------------------------------------------------------
|
|
2056 |
// CSwtShell::HasCba
|
|
2057 |
// From MSwtShell
|
|
2058 |
// ---------------------------------------------------------------------------
|
|
2059 |
//
|
|
2060 |
TBool CSwtShell::HasCba() const
|
|
2061 |
{
|
|
2062 |
return iHasCba;
|
|
2063 |
}
|
|
2064 |
|
|
2065 |
// ---------------------------------------------------------------------------
|
|
2066 |
// CSwtShell::SetTaskTip
|
|
2067 |
// From MSwtShell
|
|
2068 |
// ---------------------------------------------------------------------------
|
|
2069 |
//
|
|
2070 |
void CSwtShell::SetTaskTip()
|
|
2071 |
{
|
|
2072 |
iIsTaskTip = ETrue;
|
|
2073 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
2074 |
if (iParent && CAknEnv::Static()->TransparencyEnabled())
|
|
2075 |
{
|
|
2076 |
Window().SetRequiredDisplayMode(EColor16MA);
|
|
2077 |
if (Window().SetTransparencyAlphaChannel() == KErrNone)
|
|
2078 |
{
|
|
2079 |
Window().SetBackgroundColor(~0);
|
|
2080 |
}
|
|
2081 |
}
|
|
2082 |
GfxTransEffect::Deregister(this); // already registered in ConstructL
|
|
2083 |
GfxTransEffect::Register(this, KGfxDiscreetPopupControlUid, EFalse);
|
|
2084 |
#endif
|
|
2085 |
}
|
|
2086 |
|
|
2087 |
// ---------------------------------------------------------------------------
|
|
2088 |
// CSwtShell::IsTaskTip
|
|
2089 |
// From MSwtShell
|
|
2090 |
// ---------------------------------------------------------------------------
|
|
2091 |
//
|
|
2092 |
TBool CSwtShell::IsTaskTip() const
|
|
2093 |
{
|
|
2094 |
return iIsTaskTip;
|
|
2095 |
}
|
|
2096 |
|
|
2097 |
// ---------------------------------------------------------------------------
|
|
2098 |
// CSwtShell::DoSetLocation
|
|
2099 |
// From MSwtShell
|
|
2100 |
// ---------------------------------------------------------------------------
|
|
2101 |
//
|
|
2102 |
void CSwtShell::DoSetLocation(const TPoint& aPoint)
|
|
2103 |
{
|
|
2104 |
if (aPoint == iPosition)
|
|
2105 |
{
|
|
2106 |
return;
|
|
2107 |
}
|
|
2108 |
|
|
2109 |
// Divert the job to UiUtils if this is the Shell of an editor open for
|
|
2110 |
// split view editing.
|
|
2111 |
MSwtUiUtils& utils = iDisplay.UiUtils();
|
|
2112 |
MSwtControl* splitInputView = utils.SplitInputView();
|
|
2113 |
if (splitInputView && (&(splitInputView->GetShell())) == this)
|
|
2114 |
{
|
|
2115 |
utils.SetSplitInputShellPos(aPoint);
|
|
2116 |
return;
|
|
2117 |
}
|
|
2118 |
|
|
2119 |
iPosition = aPoint;
|
|
2120 |
Window().SetPosition(aPoint);
|
|
2121 |
|
|
2122 |
// Post the MoveEvent if the location changed.
|
|
2123 |
PositionChanged();
|
|
2124 |
|
|
2125 |
// Drawing after everything else.
|
|
2126 |
if (!(iStyle & KSwtStyleNoRedrawResize))
|
|
2127 |
{
|
|
2128 |
Redraw();
|
|
2129 |
}
|
|
2130 |
}
|
|
2131 |
|
|
2132 |
// ---------------------------------------------------------------------------
|
|
2133 |
// CSwtShell::HandleStatusPaneSizeChange
|
|
2134 |
// From MEikStatusPaneObserver
|
|
2135 |
// ---------------------------------------------------------------------------
|
|
2136 |
//
|
|
2137 |
void CSwtShell::HandleStatusPaneSizeChange()
|
|
2138 |
{
|
|
2139 |
if (iIsMaximized && (!iParent))
|
|
2140 |
{
|
|
2141 |
DoSetRect(DefaultBounds());
|
|
2142 |
}
|
|
2143 |
}
|
|
2144 |
|
|
2145 |
void CSwtShell::FinishRedraw() const
|
|
2146 |
{
|
|
2147 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
2148 |
iDisplay.CoeEnv()->WsSession().Finish();
|
|
2149 |
#endif
|
|
2150 |
}
|
|
2151 |
|
|
2152 |
// ---------------------------------------------------------------------------
|
|
2153 |
// CSwtShell::UpdateHighlight
|
|
2154 |
// ---------------------------------------------------------------------------
|
|
2155 |
//
|
|
2156 |
void CSwtShell::UpdateHighlight(TBool aDrawNow /*= EFalse*/)
|
|
2157 |
{
|
|
2158 |
// Turn off highlight for the previously focused control and its eventual
|
|
2159 |
// nearest captioned control parent.
|
|
2160 |
if (iPrevFocusControl)
|
|
2161 |
{
|
|
2162 |
MSwtCaptionedControl* captParent = iPrevFocusControl->GetNearestCaptionedControl(EFalse);
|
|
2163 |
MSwtControl* captParentCtrl = NULL;
|
|
2164 |
if (captParent)
|
|
2165 |
{
|
|
2166 |
MSwtComposite* captParentComp = captParent->Composite();
|
|
2167 |
if (captParentComp)
|
|
2168 |
{
|
|
2169 |
captParentCtrl = captParentComp->Control();
|
|
2170 |
DoSetHighlight(*captParentCtrl, EFalse);
|
|
2171 |
}
|
|
2172 |
}
|
|
2173 |
|
|
2174 |
DoSetHighlight(*iPrevFocusControl, EFalse);
|
|
2175 |
|
|
2176 |
if (aDrawNow)
|
|
2177 |
{
|
|
2178 |
if (captParentCtrl)
|
|
2179 |
captParentCtrl->Redraw();
|
|
2180 |
else
|
|
2181 |
iPrevFocusControl->Redraw();
|
|
2182 |
}
|
|
2183 |
else
|
|
2184 |
{
|
|
2185 |
if (captParentCtrl)
|
|
2186 |
captParentCtrl->CoeControl().DrawDeferred();
|
|
2187 |
else
|
|
2188 |
iPrevFocusControl->CoeControl().DrawDeferred();
|
|
2189 |
}
|
|
2190 |
|
|
2191 |
iPrevFocusControl = NULL;
|
|
2192 |
}
|
|
2193 |
|
|
2194 |
// Turn on highlight for the current focused control and its eventual
|
|
2195 |
// nearest captioned control parent.
|
|
2196 |
if (iFocusControl)
|
|
2197 |
{
|
|
2198 |
TBool ctrlHighlight = EFalse;
|
|
2199 |
TBool captHighlight = EFalse;
|
|
2200 |
|
|
2201 |
if (iFocusControl->Pressed())
|
|
2202 |
{
|
|
2203 |
// Always represent pressed state with highlight
|
|
2204 |
TInt pressPolicy = iFocusControl->PressBackgroundPolicy();
|
|
2205 |
ctrlHighlight = pressPolicy == EPressBackground;
|
|
2206 |
captHighlight = pressPolicy == EPressBackground
|
|
2207 |
|| pressPolicy == EEmbeddedPressBackground;
|
|
2208 |
}
|
|
2209 |
else
|
|
2210 |
{
|
|
2211 |
if (iDisplay.UiUtils().NaviKeyInput())
|
|
2212 |
{
|
|
2213 |
TBool noOtherFocusableCtrls(CountFocusableChildren(1, iFocusControl) == 0);
|
|
2214 |
if (noOtherFocusableCtrls)
|
|
2215 |
{
|
|
2216 |
// No highlight if there's only one focusable control
|
|
2217 |
ctrlHighlight = EFalse;
|
|
2218 |
captHighlight = EFalse;
|
|
2219 |
}
|
|
2220 |
else
|
|
2221 |
{
|
|
2222 |
captHighlight = ETrue;
|
|
2223 |
ctrlHighlight = ETrue;
|
|
2224 |
|
|
2225 |
TInt policy = iFocusControl->FocusBackgroundPolicy();
|
|
2226 |
if ((policy == ENoFocusBackground)
|
|
2227 |
|| (policy == EEmbeddedFocusBackground)
|
|
2228 |
|| (policy ==ENoFocusBackgroundInCaptionedControl))
|
|
2229 |
{
|
|
2230 |
ctrlHighlight = EFalse;
|
|
2231 |
}
|
|
2232 |
}
|
|
2233 |
}
|
|
2234 |
else
|
|
2235 |
{
|
|
2236 |
// No focus highlight with touch input
|
|
2237 |
ctrlHighlight = EFalse;
|
|
2238 |
captHighlight = EFalse;
|
|
2239 |
}
|
|
2240 |
}
|
|
2241 |
|
|
2242 |
TBool directlyCaptioned(EFalse);
|
|
2243 |
MSwtCaptionedControl* captParent = iFocusControl->GetNearestCaptionedControl(EFalse);
|
|
2244 |
MSwtControl* captParentCtrl = NULL;
|
|
2245 |
if (captParent)
|
|
2246 |
{
|
|
2247 |
MSwtComposite* captParentComp = captParent->Composite();
|
|
2248 |
if (captParentComp)
|
|
2249 |
{
|
|
2250 |
directlyCaptioned = iFocusControl->GetParent() == captParentComp;
|
|
2251 |
// When pressing, only the direct caption control gets "pressed" also.
|
|
2252 |
if (!directlyCaptioned && iFocusControl->Pressed())
|
|
2253 |
captHighlight = EFalse;
|
|
2254 |
captParentCtrl = captParentComp->Control();
|
|
2255 |
DoSetHighlight(*captParentCtrl, captHighlight);
|
|
2256 |
}
|
|
2257 |
}
|
|
2258 |
|
|
2259 |
if (!directlyCaptioned)
|
|
2260 |
{
|
|
2261 |
DoSetHighlight(*iFocusControl, ctrlHighlight);
|
|
2262 |
}
|
|
2263 |
|
|
2264 |
if (aDrawNow)
|
|
2265 |
{
|
|
2266 |
if (captParentCtrl)
|
|
2267 |
captParentCtrl->Redraw();
|
|
2268 |
else
|
|
2269 |
iFocusControl->Redraw();
|
|
2270 |
}
|
|
2271 |
else
|
|
2272 |
{
|
|
2273 |
if (captParentCtrl)
|
|
2274 |
captParentCtrl->CoeControl().DrawDeferred();
|
|
2275 |
else
|
|
2276 |
iFocusControl->CoeControl().DrawDeferred();
|
|
2277 |
}
|
|
2278 |
}
|
|
2279 |
}
|
|
2280 |
|
|
2281 |
void CSwtShell::DoSetFocusControl(MSwtControl* aControl)
|
|
2282 |
{
|
|
2283 |
iPrevFocusControl = iFocusControl;
|
|
2284 |
|
|
2285 |
// This must always be the only place to assign to iFocusControl!
|
|
2286 |
iFocusControl = aControl;
|
|
2287 |
}
|
|
2288 |
|
|
2289 |
void CSwtShell::DoSetHighlight(MSwtControl& aControl, TBool aEnabled)
|
|
2290 |
{
|
|
2291 |
if (aControl.HasHighlight(EFalse) != aEnabled) // not checking parents
|
|
2292 |
{
|
|
2293 |
aControl.SetHighlight(aEnabled);
|
|
2294 |
}
|
|
2295 |
}
|
|
2296 |
|
|
2297 |
void CSwtShell::ControlDisposing(const MSwtControl& aControl)
|
|
2298 |
{
|
|
2299 |
const MSwtControl* control = &aControl;
|
|
2300 |
|
|
2301 |
if (control == iPrevFocusControl)
|
|
2302 |
iPrevFocusControl = NULL;
|
|
2303 |
|
|
2304 |
if (control == iControlGoingToStack)
|
|
2305 |
iControlGoingToStack = NULL;
|
|
2306 |
|
|
2307 |
if (control == iControlGainingFocus)
|
|
2308 |
iControlGainingFocus = NULL;
|
|
2309 |
|
|
2310 |
if (control== iFocusControl)
|
|
2311 |
iFocusControl = NULL;
|
|
2312 |
|
|
2313 |
if (control == iFocusMemory)
|
|
2314 |
iFocusMemory = NULL;
|
|
2315 |
|
|
2316 |
if (control == iUrgentPaintControl)
|
|
2317 |
iUrgentPaintControl = NULL;
|
|
2318 |
}
|