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 <biditext.h>
|
|
14 |
#include <aknappui.h>
|
|
15 |
#include <aknnavi.h>
|
|
16 |
#include <aknnavide.h>
|
|
17 |
#include <akntabgrp.h>
|
|
18 |
#include <coecntrl.h>
|
|
19 |
#include <eikon.hrh>
|
|
20 |
#include <AknsDrawUtils.h>
|
|
21 |
#include <swtlaffacade.h>
|
|
22 |
#include <coreuiavkoneswt.h>
|
|
23 |
#include "eswtmobileextensions.h"
|
|
24 |
#include "swtcontrolbase.h"
|
|
25 |
#include "swtuiutils.h"
|
|
26 |
#include "swtjavabufferdrawer.h"
|
|
27 |
|
|
28 |
|
|
29 |
// ======== MEMBER FUNCTIONS ========
|
|
30 |
|
|
31 |
|
|
32 |
EXPORT_C ASwtControlBase::ASwtControlBase(MSwtDisplay& aDisplay, TSwtPeer aPeer,
|
|
33 |
MSwtComposite* aParent, TInt aStyle)
|
|
34 |
: iDisplay(aDisplay)
|
|
35 |
, iPeer(aPeer)
|
|
36 |
, iParent(aParent)
|
|
37 |
, iCtrlFlags(0)
|
|
38 |
, iStyle(aStyle)
|
|
39 |
, iFont(NULL)
|
|
40 |
, iPopupMenu(NULL)
|
|
41 |
, iIsOnControlStack(EFalse)
|
|
42 |
, iStackedSetRedrawFalseNb(0)
|
|
43 |
, iBackgrdDefaultUsed(ETrue)
|
|
44 |
, iFocusFrame(NULL)
|
|
45 |
, iFocusChanged(EFalse)
|
|
46 |
{
|
|
47 |
ASSERT(iPeer!=NULL);
|
|
48 |
|
|
49 |
// Orientation not specified, find default
|
|
50 |
TInt orientation = iStyle & KSwtOrientationMask;
|
|
51 |
if (orientation!=KSwtStyleLeftToRight && orientation!=KSwtStyleRightToLeft)
|
|
52 |
{
|
|
53 |
if (iParent != NULL) // Inherit from parent
|
|
54 |
orientation = iParent->Control()->Style() & KSwtOrientationMask;
|
|
55 |
else // Based on user's locale
|
|
56 |
orientation = (TBidiText::ScriptDirectionality(User::Language())==TBidiText::ELeftToRight) ?
|
|
57 |
KSwtStyleLeftToRight : KSwtStyleRightToLeft;
|
|
58 |
|
|
59 |
iStyle &= ~KSwtOrientationMask;
|
|
60 |
iStyle |= orientation;
|
|
61 |
}
|
|
62 |
}
|
|
63 |
|
|
64 |
void ASwtControlBase::CreateFocusBackgroundL()
|
|
65 |
{
|
|
66 |
ASSERT(!iFocusFrame);
|
|
67 |
|
|
68 |
TRect rect(CoeControl().Rect());
|
|
69 |
TRect innerRect;
|
|
70 |
innerRect.iTl = CSwtLafFacade::GetLayoutRect(
|
|
71 |
CSwtLafFacade::EInputFieldSkinPlacingGeneralLine2, rect, 0).Rect().iBr;
|
|
72 |
innerRect.iBr = CSwtLafFacade::GetLayoutRect(
|
|
73 |
CSwtLafFacade::EInputFieldSkinPlacingGeneralLine5, rect, 0).Rect().iTl;
|
|
74 |
|
|
75 |
iFocusFrame = CAknsFrameBackgroundControlContext::NewL(
|
|
76 |
KAknsIIDQsnFrInput, rect, innerRect, EFalse /*parent absolute*/);
|
|
77 |
|
|
78 |
if (iBackgrdDefaultUsed)
|
|
79 |
{
|
|
80 |
iFocusFrame->SetParentContext(SwtMopSupplyCtrlContext(EFalse));
|
|
81 |
}
|
|
82 |
}
|
|
83 |
|
|
84 |
CAknsBasicBackgroundControlContext* ASwtControlBase::FocusBackgroundNow() const
|
|
85 |
{
|
|
86 |
if (HasHighlight(EFalse)) // not checking parents
|
|
87 |
{
|
|
88 |
return iFocusFrame;
|
|
89 |
}
|
|
90 |
else
|
|
91 |
{
|
|
92 |
return NULL;
|
|
93 |
}
|
|
94 |
}
|
|
95 |
|
|
96 |
void ASwtControlBase::RedrawFocusBackground()
|
|
97 |
{
|
|
98 |
MSwtCaptionedControl* captCtrl = GetNearestCaptionedControl();
|
|
99 |
if (captCtrl)
|
|
100 |
{
|
|
101 |
captCtrl->Composite()->Control()->Redraw();
|
|
102 |
}
|
|
103 |
else
|
|
104 |
{
|
|
105 |
Redraw();
|
|
106 |
}
|
|
107 |
}
|
|
108 |
|
|
109 |
void ASwtControlBase::InitControlBaseL()
|
|
110 |
{
|
|
111 |
RegisterWithParentL();
|
|
112 |
}
|
|
113 |
|
|
114 |
EXPORT_C ASwtControlBase::~ASwtControlBase()
|
|
115 |
{
|
|
116 |
delete iFocusFrame;
|
|
117 |
|
|
118 |
// RemoveRef here in case it goes through destruction before being
|
|
119 |
// registered (and Dispose() is not called)
|
|
120 |
if (iFont != NULL)
|
|
121 |
iFont->RemoveRef();
|
|
122 |
|
|
123 |
#ifdef _lint
|
|
124 |
//lint -esym(1740, ASwtControlBase::iPeer)
|
|
125 |
//lint -esym(1740, ASwtControlBase::iParent)
|
|
126 |
iFont = NULL;
|
|
127 |
iPopupMenu = NULL;
|
|
128 |
#endif
|
|
129 |
}
|
|
130 |
|
|
131 |
// From class MCoeControlBackground.
|
|
132 |
// Draw the Background. This method was called by the eSWT and Symbian drawing framework.
|
|
133 |
// If the control is a Composite then make sure not to draw the background to
|
|
134 |
// the areas that will be painted by the children. This is to avoid painting
|
|
135 |
// over them as this would cause flickering.
|
|
136 |
//
|
|
137 |
EXPORT_C void ASwtControlBase::Draw(CWindowGc& aGc, const CCoeControl& aControl,
|
|
138 |
const TRect& aRect) const
|
|
139 |
{
|
|
140 |
RRegion* clippingRegion = NULL;
|
|
141 |
const MSwtComposite* composite = CompositeInterface();
|
|
142 |
if (composite)
|
|
143 |
{
|
|
144 |
clippingRegion = SetupChildClippingRegion(composite, aGc, aRect);
|
|
145 |
}
|
|
146 |
|
|
147 |
TBool isDialogShell = IsShell() && iParent;
|
|
148 |
TBool isTaskTip = isDialogShell && ShellInterface()->IsTaskTip();
|
|
149 |
|
|
150 |
// Draw the background.
|
|
151 |
if (!IsDefaultBackgroundUse()
|
|
152 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
153 |
// Fill the round corners
|
|
154 |
|| (isDialogShell && !isTaskTip)
|
|
155 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
156 |
)
|
|
157 |
{
|
|
158 |
aGc.SetBrushColor(GetBackground());
|
|
159 |
aGc.Clear(aRect);
|
|
160 |
}
|
|
161 |
|
|
162 |
// Hopefully the highlight back is always semi transparent,
|
|
163 |
// otherwise the back color is lost.
|
|
164 |
MAknsControlContext* cc = SwtMopSupplyCtrlContext();
|
|
165 |
AknsDrawUtils::Background(AknsUtils::SkinInstance(), cc, &aControl, aGc, aRect);
|
|
166 |
|
|
167 |
// Cancel & destroy the clipping region
|
|
168 |
CancelChildClippingRegion(clippingRegion, aGc);
|
|
169 |
}
|
|
170 |
|
|
171 |
EXPORT_C void ASwtControlBase::DrawBorder(const TRect& /*aRect*/) const
|
|
172 |
{
|
|
173 |
TInt borderWidth = GetBorderWidth();
|
|
174 |
if (borderWidth > 0)
|
|
175 |
{
|
|
176 |
CWindowGc& gc = CoeControl().SystemGc();
|
|
177 |
gc.SetBrushStyle(CGraphicsContext::ENullBrush);
|
|
178 |
gc.SetPenColor(UiUtils().GetSystemColor(ESwtColorWidgetBorder));
|
|
179 |
gc.SetPenStyle(CGraphicsContext::ESolidPen);
|
|
180 |
gc.SetPenSize(TSize(borderWidth, borderWidth));
|
|
181 |
gc.DrawRect(CoeControl().Rect());
|
|
182 |
}
|
|
183 |
}
|
|
184 |
|
|
185 |
// In eSWT all border should have the same width/height.
|
|
186 |
EXPORT_C TInt ASwtControlBase::GetBorderWidth() const
|
|
187 |
{
|
|
188 |
if (HasBorderStyle())
|
|
189 |
{
|
|
190 |
return 1;
|
|
191 |
}
|
|
192 |
else
|
|
193 |
{
|
|
194 |
return 0;
|
|
195 |
}
|
|
196 |
}
|
|
197 |
|
|
198 |
// Window coords
|
|
199 |
EXPORT_C TRect ASwtControlBase::ClientRect() const
|
|
200 |
{
|
|
201 |
return BorderInnerRect();
|
|
202 |
}
|
|
203 |
|
|
204 |
TBool ASwtControlBase::HasBorderStyle() const
|
|
205 |
{
|
|
206 |
TBool res = (iStyle & KSwtStyleBorder);
|
|
207 |
const MSwtShell* shell = ShellInterface();
|
|
208 |
if (shell)
|
|
209 |
{
|
|
210 |
// TaskTip shells have the border.
|
|
211 |
res = shell->IsTaskTip() || (res && !(iStyle & KSwtStyleNoTrim) && iParent);
|
|
212 |
}
|
|
213 |
return res;
|
|
214 |
}
|
|
215 |
|
|
216 |
TSize ASwtControlBase::BorderSizeDelta() const
|
|
217 |
{
|
|
218 |
return TSize(GetBorderWidth()*2, GetBorderWidth()*2) ;
|
|
219 |
}
|
|
220 |
|
|
221 |
// Window coords
|
|
222 |
EXPORT_C TRect ASwtControlBase::BorderInnerRect() const
|
|
223 |
{
|
|
224 |
TRect borderInnerRect = CoeControl().Rect();
|
|
225 |
|
|
226 |
if (borderInnerRect.Height() != 0 && borderInnerRect.Width() != 0)
|
|
227 |
{
|
|
228 |
TInt w(GetBorderWidth());
|
|
229 |
borderInnerRect.Shrink(w, w);
|
|
230 |
}
|
|
231 |
|
|
232 |
return borderInnerRect;
|
|
233 |
}
|
|
234 |
|
|
235 |
EXPORT_C TRect ASwtControlBase::BorderOuterRect(const TRect& aRect) const
|
|
236 |
{
|
|
237 |
TRect borderOuterRect(aRect);
|
|
238 |
borderOuterRect.Grow(GetBorderWidth(), GetBorderWidth());
|
|
239 |
|
|
240 |
return borderOuterRect;
|
|
241 |
}
|
|
242 |
|
|
243 |
TKeyResponse ASwtControlBase::HandleDiagonalKeysL(const TKeyEvent& aKeyEvent, TEventCode aType,
|
|
244 |
TBool aTraversalDoIt, const TUint key1, const TStdScanCode scanCode1,
|
|
245 |
const TUint key2, const TStdScanCode scanCode2)
|
|
246 |
{
|
|
247 |
TKeyEvent keyTemp;
|
|
248 |
// send first event
|
|
249 |
keyTemp.iRepeats = 0;
|
|
250 |
keyTemp.iScanCode = scanCode1;
|
|
251 |
keyTemp.iModifiers = 32768;
|
|
252 |
keyTemp.iCode = 0;
|
|
253 |
HandleKeyL(keyTemp, EEventKeyDown, aTraversalDoIt); //DOWN
|
|
254 |
keyTemp = aKeyEvent;
|
|
255 |
keyTemp.iCode = key1;
|
|
256 |
keyTemp.iScanCode = scanCode1;
|
|
257 |
TKeyResponse firstResponse = HandleKeyL(keyTemp, aType, aTraversalDoIt); // KEYCODE
|
|
258 |
keyTemp.iRepeats = 0;
|
|
259 |
keyTemp.iScanCode = scanCode1;
|
|
260 |
keyTemp.iModifiers = 32768;
|
|
261 |
keyTemp.iCode = 0;
|
|
262 |
HandleKeyL(keyTemp, EEventKeyUp, aTraversalDoIt); // UP
|
|
263 |
|
|
264 |
// send second event
|
|
265 |
keyTemp.iRepeats = 0;
|
|
266 |
keyTemp.iScanCode = scanCode2;
|
|
267 |
keyTemp.iModifiers = 32768;
|
|
268 |
keyTemp.iCode = 0;
|
|
269 |
HandleKeyL(keyTemp, EEventKeyDown, aTraversalDoIt); // DOWN
|
|
270 |
keyTemp = aKeyEvent;
|
|
271 |
keyTemp.iCode = key2;
|
|
272 |
keyTemp.iScanCode = scanCode2;
|
|
273 |
TKeyResponse secondResponse = HandleKeyL(keyTemp, aType, aTraversalDoIt); // KEYCODE
|
|
274 |
keyTemp.iRepeats = 0;
|
|
275 |
keyTemp.iScanCode = scanCode2;
|
|
276 |
keyTemp.iModifiers = 32768;
|
|
277 |
keyTemp.iCode = 0;
|
|
278 |
HandleKeyL(keyTemp, EEventKeyUp, aTraversalDoIt); // UP
|
|
279 |
|
|
280 |
TKeyResponse response = EKeyWasNotConsumed;
|
|
281 |
if (EKeyWasConsumed == firstResponse && EKeyWasConsumed == secondResponse)
|
|
282 |
{
|
|
283 |
response = EKeyWasConsumed;
|
|
284 |
}
|
|
285 |
|
|
286 |
return response;
|
|
287 |
}
|
|
288 |
|
|
289 |
void ASwtControlBase::DrawComponentControls(const CCoeControl& aControl,
|
|
290 |
const TRect& aRect, CWindowGc& aGc, TBool aCanDrawOutsideRect)
|
|
291 |
{
|
|
292 |
const TInt count = aControl.CountComponentControls();
|
|
293 |
for (TInt i=0; i<count; ++i)
|
|
294 |
{
|
|
295 |
CCoeControl& compCtrl = *aControl.ComponentControl(i);
|
|
296 |
if (compCtrl.IsVisible())
|
|
297 |
{
|
|
298 |
if (compCtrl.OwnsWindow())
|
|
299 |
{
|
|
300 |
}
|
|
301 |
else
|
|
302 |
{
|
|
303 |
TRect drawRect(compCtrl.Rect());
|
|
304 |
drawRect.Intersection(aRect);
|
|
305 |
if (!drawRect.IsEmpty())
|
|
306 |
{
|
|
307 |
aGc.Reset();
|
|
308 |
aGc.SetClippingRect(drawRect);
|
|
309 |
compCtrl.DrawBackground(drawRect);
|
|
310 |
compCtrl.DrawForeground(drawRect);
|
|
311 |
}
|
|
312 |
|
|
313 |
if (aCanDrawOutsideRect)
|
|
314 |
{
|
|
315 |
DrawComponentControls(compCtrl, aRect, aGc, aCanDrawOutsideRect);
|
|
316 |
}
|
|
317 |
else if (!drawRect.IsEmpty())
|
|
318 |
{
|
|
319 |
DrawComponentControls(compCtrl, drawRect, aGc, aCanDrawOutsideRect);
|
|
320 |
}
|
|
321 |
}
|
|
322 |
}
|
|
323 |
}
|
|
324 |
}
|
|
325 |
|
|
326 |
TBool ASwtControlBase::RectContainsRect(const TRect& aContainer, const TRect& aContainee)
|
|
327 |
{
|
|
328 |
return (aContainer.iTl.iX <= aContainee.iTl.iX
|
|
329 |
&& aContainer.iTl.iY <= aContainee.iTl.iY
|
|
330 |
&& aContainer.iBr.iX >= aContainee.iBr.iX
|
|
331 |
&& aContainer.iBr.iY >= aContainee.iBr.iY);
|
|
332 |
}
|
|
333 |
|
|
334 |
void ASwtControlBase::FlushJavaBuffer(MSwtGc* aGc, TInt* aIntParams, TInt aIntCount, HBufC* aStrParams, RWindow* aWindow, const TRect& aDrawRect) const
|
|
335 |
{
|
|
336 |
iDisplay.JavaBufferDrawer().Draw(aGc, aIntParams, aIntCount, aStrParams, aWindow, aDrawRect);
|
|
337 |
}
|
|
338 |
|
|
339 |
EXPORT_C void ASwtControlBase::PostMouseEventL(const TPointerEvent& aPointerEvent)
|
|
340 |
{
|
|
341 |
TPoint eventPosition(aPointerEvent.iPosition);
|
|
342 |
|
|
343 |
// Is is essential that the coordinates posted to the queue are in screen
|
|
344 |
// coordinates to ensure the case where late mouse events are handled
|
|
345 |
// after the control has moved away from the current position.
|
|
346 |
TPoint pos(WindowToScreen(eventPosition));
|
|
347 |
|
|
348 |
// Compute the state mask
|
|
349 |
TInt stateMask = UiUtils().GetPointerEventStateMask(aPointerEvent.iModifiers);
|
|
350 |
|
|
351 |
// Handle double click (must be issued between Down and Up)
|
|
352 |
if (aPointerEvent.iModifiers & EModifierDoubleClick)
|
|
353 |
iDisplay.PostMouseEventL(iPeer, ESwtEventMouseDoubleClick, 0, pos, stateMask);
|
|
354 |
|
|
355 |
// Compute the event type and button number
|
|
356 |
TSwtEventType type;
|
|
357 |
TInt button = 0;
|
|
358 |
switch (aPointerEvent.iType)
|
|
359 |
{
|
|
360 |
case TPointerEvent::EButton1Down:
|
|
361 |
type = ESwtEventMouseDown;
|
|
362 |
button = KSwtMouseButton1;
|
|
363 |
break;
|
|
364 |
case TPointerEvent::EButton1Up:
|
|
365 |
type = ESwtEventMouseUp;
|
|
366 |
button = KSwtMouseButton1;
|
|
367 |
break;
|
|
368 |
case TPointerEvent::EButton2Down:
|
|
369 |
type = ESwtEventMouseDown;
|
|
370 |
button = KSwtMouseButton2;
|
|
371 |
break;
|
|
372 |
case TPointerEvent::EButton2Up:
|
|
373 |
type = ESwtEventMouseUp;
|
|
374 |
button = KSwtMouseButton2;
|
|
375 |
break;
|
|
376 |
case TPointerEvent::EButton3Down:
|
|
377 |
type = ESwtEventMouseDown;
|
|
378 |
button = KSwtMouseButton3;
|
|
379 |
break;
|
|
380 |
case TPointerEvent::EButton3Up:
|
|
381 |
type = ESwtEventMouseUp;
|
|
382 |
button = KSwtMouseButton3;
|
|
383 |
break;
|
|
384 |
case TPointerEvent::EDrag:
|
|
385 |
case TPointerEvent::EMove:
|
|
386 |
type = ESwtEventMouseMove;
|
|
387 |
break;
|
|
388 |
default:
|
|
389 |
return;
|
|
390 |
}
|
|
391 |
|
|
392 |
iDisplay.PostMouseEventL(iPeer, type, button, pos, stateMask);
|
|
393 |
}
|
|
394 |
|
|
395 |
EXPORT_C void ASwtControlBase::EnableFocusHighlight(TBool /*aEnable*/)
|
|
396 |
{
|
|
397 |
// Method is used only on 9.2 for list controls (Lists, ListView,
|
|
398 |
// ListBox and Table)
|
|
399 |
}
|
|
400 |
|
|
401 |
TPoint ASwtControlBase::ComputeLocationToSet(const TPoint& aLocation)
|
|
402 |
{
|
|
403 |
ASSERT(!IsShell());
|
|
404 |
return aLocation + iParent->Scrollable()->Control()->ClientRect().iTl; //lint !e613
|
|
405 |
}
|
|
406 |
|
|
407 |
EXPORT_C MSwtShell& ASwtControlBase::GetShell() const
|
|
408 |
{
|
|
409 |
if (!iShell)
|
|
410 |
{
|
|
411 |
MSwtShell* selfAsShell = const_cast<MSwtShell*>(ShellInterface());
|
|
412 |
if (selfAsShell)
|
|
413 |
iShell = selfAsShell;
|
|
414 |
else
|
|
415 |
iShell = &iParent->Control()->GetShell();
|
|
416 |
}
|
|
417 |
ASSERT(iShell);
|
|
418 |
return *iShell;
|
|
419 |
}
|
|
420 |
|
|
421 |
void ASwtControlBase::Invalidate(const TRect& aRect)
|
|
422 |
{
|
|
423 |
if (!aRect.IsEmpty() && CoeControl().IsVisible() && !(iCtrlFlags & MSwtControl::EFlagDoNotDraw))
|
|
424 |
ForceInvalidate(aRect);
|
|
425 |
}
|
|
426 |
|
|
427 |
void ASwtControlBase::ForceInvalidate(const TRect& aRect)
|
|
428 |
{
|
|
429 |
if (aRect.IsEmpty())
|
|
430 |
{
|
|
431 |
return;
|
|
432 |
}
|
|
433 |
|
|
434 |
MSwtShell& shell = GetShell();
|
|
435 |
MSwtControl* urgentPaintControl = shell.UrgentPaintControl();
|
|
436 |
if (urgentPaintControl)
|
|
437 |
{
|
|
438 |
// Redraw requests outside urgently painted controls are ignored.
|
|
439 |
if (IsDescentOf(*urgentPaintControl))
|
|
440 |
{
|
|
441 |
urgentPaintControl->PaintUrgently(aRect);
|
|
442 |
}
|
|
443 |
}
|
|
444 |
else
|
|
445 |
{
|
|
446 |
if (shell.AsyncPainting())
|
|
447 |
{
|
|
448 |
TRect dirtyRect(aRect);
|
|
449 |
MSwtControl* controlShell = shell.Control();
|
|
450 |
|
|
451 |
// Convert to Screen Coordinate
|
|
452 |
dirtyRect.Move(controlShell->CoeControl().PositionRelativeToScreen());
|
|
453 |
|
|
454 |
TBool mergeable = !(iStyle & KSwtStyleNoMergePaints);
|
|
455 |
TRAP_IGNORE(iDisplay.PostPaintEventL(JavaPeer(), controlShell->JavaPeer(), dirtyRect, mergeable));
|
|
456 |
}
|
|
457 |
else
|
|
458 |
{
|
|
459 |
static_cast<RWindow*>(shell.Control()->CoeControl().DrawableWindow())->Invalidate(aRect);
|
|
460 |
}
|
|
461 |
}
|
|
462 |
}
|
|
463 |
|
|
464 |
EXPORT_C void ASwtControlBase::DoPaint(const TRect& aRect) const
|
|
465 |
{
|
|
466 |
ASSERT(!IsShell());
|
|
467 |
const CCoeControl& ctrl = CoeControl();
|
|
468 |
ctrl.DrawBackground(aRect);
|
|
469 |
ctrl.DrawForeground(aRect);
|
|
470 |
}
|
|
471 |
|
|
472 |
EXPORT_C void ASwtControlBase::SetColorL(TLogicalColor aLogicalColor, const MSwtColor* aColor)
|
|
473 |
{
|
|
474 |
CCoeControl& coeCtrl = CoeControl();
|
|
475 |
TRgb color((aColor!=NULL) ? aColor->RgbValue() : iDisplay.CoeEnv()->Color(aLogicalColor));
|
|
476 |
coeCtrl.OverrideColorL(aLogicalColor, color);
|
|
477 |
}
|
|
478 |
|
|
479 |
EXPORT_C CSwtUiUtils& ASwtControlBase::UiUtils() const
|
|
480 |
{
|
|
481 |
return static_cast<CSwtUiUtils&>(iDisplay.UiUtils());
|
|
482 |
}
|
|
483 |
|
|
484 |
EXPORT_C void ASwtControlBase::DoDelete()
|
|
485 |
{
|
|
486 |
delete this;
|
|
487 |
}
|
|
488 |
|
|
489 |
EXPORT_C TRect ASwtControlBase::VisibleRect(TBool aVisibleBounds) const
|
|
490 |
{
|
|
491 |
// WINDOW COORDINATES!
|
|
492 |
if (!CoeControl().IsVisible())
|
|
493 |
return TRect(); // This is (0,0,0,0)
|
|
494 |
|
|
495 |
TRect rect((aVisibleBounds)? CoeControl().Rect() : ClientRect());
|
|
496 |
|
|
497 |
if (!IsShell())
|
|
498 |
{
|
|
499 |
rect = ClipToVisibleRect(rect);
|
|
500 |
}
|
|
501 |
|
|
502 |
return rect;
|
|
503 |
}
|
|
504 |
|
|
505 |
EXPORT_C TBool ASwtControlBase::HasHighlight(TBool aIncludingParents /*= ETrue*/) const
|
|
506 |
{
|
|
507 |
TBool res = iHighlightEnabled;
|
|
508 |
if (!res && aIncludingParents)
|
|
509 |
{
|
|
510 |
res = res || (iParent && iParent->Control()->HasHighlight(ETrue));
|
|
511 |
}
|
|
512 |
return res;
|
|
513 |
}
|
|
514 |
|
|
515 |
EXPORT_C void ASwtControlBase::SetHighlight(TBool aEnabled)
|
|
516 |
{
|
|
517 |
iHighlightEnabled = aEnabled;
|
|
518 |
|
|
519 |
// Prepare the frame
|
|
520 |
if (aEnabled && !iFocusFrame)
|
|
521 |
{
|
|
522 |
TRAP_IGNORE(const_cast<ASwtControlBase*>(this)->CreateFocusBackgroundL());
|
|
523 |
}
|
|
524 |
|
|
525 |
HandleHighlightChange();
|
|
526 |
}
|
|
527 |
|
|
528 |
EXPORT_C void ASwtControlBase::HandleHighlightChange()
|
|
529 |
{
|
|
530 |
// Do nothing here. Inherit where needed.
|
|
531 |
}
|
|
532 |
|
|
533 |
TRect ASwtControlBase::ClipToVisibleRect(const TRect& aRect) const
|
|
534 |
{
|
|
535 |
// WINDOW COORDINATES!
|
|
536 |
TRect rect = aRect;
|
|
537 |
MSwtComposite* composite = iParent;
|
|
538 |
while (composite != NULL)
|
|
539 |
{
|
|
540 |
MSwtControl* ctrl = composite->Control();
|
|
541 |
rect.Intersection(ctrl->ClientRect());
|
|
542 |
composite = (!ctrl->IsShell()) ? ctrl->GetParent() : NULL;
|
|
543 |
}
|
|
544 |
return rect;
|
|
545 |
}
|
|
546 |
|
|
547 |
// Hurts the performance of non overlapping drawing when there are a lot
|
|
548 |
// of control sibblings and does not really work for overlapping drawing
|
|
549 |
#if 0
|
|
550 |
void ASwtControlBase::VisibleRegion(RRegion& aRegion, TBool aVisibleBounds) const
|
|
551 |
{
|
|
552 |
// SCREEN COORDINATES!
|
|
553 |
aRegion.AddRect(TRect(CoeControl().PositionRelativeToScreen(),
|
|
554 |
aVisibleBounds ? CoeControl().Size() : ClientRect().Size()));
|
|
555 |
MSwtComposite* parent = iParent;
|
|
556 |
const MSwtControl* children = this;
|
|
557 |
|
|
558 |
while (parent && !children->IsShell())
|
|
559 |
{
|
|
560 |
const RSwtControlArray* siblings = parent->Children();
|
|
561 |
|
|
562 |
for (TInt i = siblings->Find(children)-1; i >= 0; i--)
|
|
563 |
{
|
|
564 |
MSwtControl* control = (*siblings)[i];
|
|
565 |
|
|
566 |
if (!control->IsShell() && control->CoeControl().IsVisible())
|
|
567 |
{
|
|
568 |
aRegion.SubRect(TRect(control->CoeControl().PositionRelativeToScreen(), control->CoeControl().Size()));
|
|
569 |
}
|
|
570 |
}
|
|
571 |
|
|
572 |
children = parent->Control();
|
|
573 |
parent = parent->Control()->GetParent();
|
|
574 |
}
|
|
575 |
}
|
|
576 |
#endif
|
|
577 |
|
|
578 |
TPoint ASwtControlBase::WindowToScreen(const TPoint& aPoint) const
|
|
579 |
{
|
|
580 |
const CCoeControl& coeControl = CoeControl();
|
|
581 |
const TPoint posInScreen(coeControl.PositionRelativeToScreen());
|
|
582 |
const TPoint posInWindow((coeControl.OwnsWindow()) ? TPoint(0,0) : coeControl.Position());
|
|
583 |
|
|
584 |
TInt x = (aPoint.iX - posInWindow.iX) + posInScreen.iX;
|
|
585 |
TInt y = (aPoint.iY - posInWindow.iY) + posInScreen.iY;
|
|
586 |
return TPoint(x,y);
|
|
587 |
}
|
|
588 |
|
|
589 |
void ASwtControlBase::FocusabilityChanged()
|
|
590 |
{
|
|
591 |
CCoeControl& coeCtrl = CoeControl();
|
|
592 |
MSwtShell& shell = GetShell();
|
|
593 |
|
|
594 |
if (!IsFocusable(EFalse))
|
|
595 |
{
|
|
596 |
if (coeCtrl.IsFocused())
|
|
597 |
{
|
|
598 |
// Composite losing focusability can mean that it has received a new child.
|
|
599 |
// Otherwise it means that the Composite itself has been disabled or hidden.
|
|
600 |
// If a Control loses focusability, let the parent find a new focus target.
|
|
601 |
// If a Composite loses focusability, find new target first in children then ancestors.
|
|
602 |
MSwtControl* newFocus = NULL;
|
|
603 |
MSwtComposite* comp = CompositeInterface();
|
|
604 |
if (comp)
|
|
605 |
{
|
|
606 |
TRAP_IGNORE((newFocus = shell.FindTraversalTargetL(ESwtTraverseArrowNext, *this)));
|
|
607 |
}
|
|
608 |
if (!newFocus)
|
|
609 |
{
|
|
610 |
TRAP_IGNORE((newFocus = shell.FindTraversalTargetL(ESwtTraverseParent, *this)));
|
|
611 |
}
|
|
612 |
if (newFocus)
|
|
613 |
{
|
|
614 |
newFocus->CoeControl().SetFocus(ETrue);
|
|
615 |
}
|
|
616 |
else
|
|
617 |
{
|
|
618 |
// This control was focused but now there's nothing focusable anymore
|
|
619 |
coeCtrl.SetFocus(EFalse);
|
|
620 |
shell.SetControlGainingFocus(NULL);
|
|
621 |
shell.SetControlGoingToStack(NULL);
|
|
622 |
if (UiUtils().NextFocusedControl() == this)
|
|
623 |
{
|
|
624 |
UiUtils().SetNextFocusedControl(NULL);
|
|
625 |
}
|
|
626 |
}
|
|
627 |
}
|
|
628 |
ASSERT(!coeCtrl.IsFocused());
|
|
629 |
}
|
|
630 |
else
|
|
631 |
{
|
|
632 |
if (UiUtils().GetActiveShell() == &shell && shell.FocusControl() == NULL)
|
|
633 |
coeCtrl.SetFocus(ETrue);
|
|
634 |
}
|
|
635 |
}
|
|
636 |
|
|
637 |
EXPORT_C void ASwtControlBase::HandleFocusChanged(TDrawNow /*aDrawNow*/)
|
|
638 |
{
|
|
639 |
CCoeControl& coeCtrl = CoeControl();
|
|
640 |
TBool focused = coeCtrl.IsFocused();
|
|
641 |
CSwtUiUtils& uiUtils = UiUtils();
|
|
642 |
MSwtShell* activeShell = uiUtils.GetActiveShell();
|
|
643 |
MSwtControl* oldFocus = (activeShell!=NULL) ? activeShell->FocusControl() : NULL;
|
|
644 |
TBool appFocus = uiUtils.IsAppFocused();
|
|
645 |
|
|
646 |
// Detect when SetFocus() has been called twice with the same parameter
|
|
647 |
if (oldFocus && ((focused && oldFocus == this)
|
|
648 |
|| (!focused && oldFocus != this)))
|
|
649 |
{
|
|
650 |
return;
|
|
651 |
}
|
|
652 |
|
|
653 |
MSwtShell& shell = GetShell();
|
|
654 |
|
|
655 |
// Make sure that UiUtils' information of the control that most
|
|
656 |
// recently had focus is up-to-date. This way the focus will be
|
|
657 |
// returned to the correct control once we regain application
|
|
658 |
// focus after losing it.
|
|
659 |
if (oldFocus == this)
|
|
660 |
{
|
|
661 |
uiUtils.SetNextFocusedControl(oldFocus);
|
|
662 |
}
|
|
663 |
|
|
664 |
// if app fails on next line check this issue:
|
|
665 |
// caller should call MSwtControl::SetFocus() or MSwtControl::ForceFocus()
|
|
666 |
// or Overridden function if posssible,
|
|
667 |
// instead of CCoeControl::SetFoucus directly
|
|
668 |
ASSERT(!(focused && !appFocus));
|
|
669 |
|
|
670 |
if (!focused)
|
|
671 |
{
|
|
672 |
// Remove current control from ControlStack since the control becomes unfocused
|
|
673 |
RemoveFromControlStack();
|
|
674 |
}
|
|
675 |
|
|
676 |
// Update the focus control
|
|
677 |
if (focused)
|
|
678 |
{
|
|
679 |
// Clear the urgent paint control if focus goes outside it.
|
|
680 |
// There cannot be an urgently painted control that is not
|
|
681 |
// focused or does not have a focused child.
|
|
682 |
MSwtControl* urgentPaintControl = shell.UrgentPaintControl();
|
|
683 |
if (urgentPaintControl && urgentPaintControl != this
|
|
684 |
&& !IsDescentOf(*urgentPaintControl))
|
|
685 |
{
|
|
686 |
shell.SetUrgentPaintControl(NULL);
|
|
687 |
}
|
|
688 |
|
|
689 |
// Activate our shell and remove focus from current owner
|
|
690 |
if (activeShell != &shell)
|
|
691 |
{
|
|
692 |
// This removes focus from oldFocus
|
|
693 |
uiUtils.SetActiveShell(shell, EFalse);
|
|
694 |
}
|
|
695 |
else
|
|
696 |
{
|
|
697 |
if (oldFocus)
|
|
698 |
{
|
|
699 |
// first add control before removing the control from controlstack
|
|
700 |
// so that it stop calling focusChanged of shell.
|
|
701 |
TRAP_IGNORE(AddToControlStackL(ECoeStackPriorityDefault));
|
|
702 |
oldFocus->CoeControl().SetFocus(EFalse);
|
|
703 |
}
|
|
704 |
}
|
|
705 |
|
|
706 |
ASSERT(!oldFocus || !oldFocus->CoeControl().IsFocused());
|
|
707 |
|
|
708 |
// Set ourselves as the new focus control
|
|
709 |
// Can't register a Shell with itself
|
|
710 |
if (shell.Control() != this)
|
|
711 |
{
|
|
712 |
shell.SetFocusControl(this);
|
|
713 |
}
|
|
714 |
}
|
|
715 |
else
|
|
716 |
{
|
|
717 |
shell.SetFocusControl(NULL);
|
|
718 |
}
|
|
719 |
|
|
720 |
// Notify parent of our new focus
|
|
721 |
MSwtComposite* parent = GetParent();
|
|
722 |
if (parent)
|
|
723 |
{
|
|
724 |
parent->ChildFocusChanged(*this);
|
|
725 |
}
|
|
726 |
|
|
727 |
|
|
728 |
// Notify Menu arranger
|
|
729 |
if (focused)
|
|
730 |
{
|
|
731 |
iDisplay.MenuArranger().ControlFocusGained(*this);
|
|
732 |
}
|
|
733 |
else
|
|
734 |
{
|
|
735 |
iDisplay.MenuArranger().ControlFocusLost();
|
|
736 |
}
|
|
737 |
|
|
738 |
// Notify Command arranger
|
|
739 |
MSwtCommandArranger* commandArranger = iDisplay.CommandArranger();
|
|
740 |
if (commandArranger) // commandArranger may be null as Mobile Extensions is optional
|
|
741 |
{
|
|
742 |
if (focused)
|
|
743 |
{
|
|
744 |
commandArranger->ControlFocusGained(*this);
|
|
745 |
}
|
|
746 |
else
|
|
747 |
{
|
|
748 |
commandArranger->ControlFocusLost();
|
|
749 |
}
|
|
750 |
}
|
|
751 |
|
|
752 |
// Post the focus event
|
|
753 |
TSwtEventType type((focused) ? ESwtEventFocusIn : ESwtEventFocusOut);
|
|
754 |
TRAP_IGNORE(iDisplay.PostFocusEventL(JavaPeer(), type));
|
|
755 |
|
|
756 |
if (focused)
|
|
757 |
{
|
|
758 |
// Add to ControlStack since the control becomes focused
|
|
759 |
TRAP_IGNORE(AddToControlStackL(ECoeStackPriorityDefault));
|
|
760 |
}
|
|
761 |
|
|
762 |
shell.UpdateHighlight();
|
|
763 |
}
|
|
764 |
|
|
765 |
TKeyResponse ASwtControlBase::OfferKeyEventToCommandAndMenuArrangersL(
|
|
766 |
const TKeyEvent& aKeyEvent,
|
|
767 |
TEventCode aType)
|
|
768 |
{
|
|
769 |
if ((aType == EEventKeyDown) || (aType==EEventKeyUp))
|
|
770 |
{
|
|
771 |
return EKeyWasNotConsumed;
|
|
772 |
}
|
|
773 |
|
|
774 |
MSwtShell* activeTopShell = iDisplay.UiUtils().GetParentTopShellOfActiveShell();
|
|
775 |
MSwtMenuArranger& menuArranger = iDisplay.MenuArranger();
|
|
776 |
if (activeTopShell
|
|
777 |
&& activeTopShell->FullScreenMode()
|
|
778 |
&& menuArranger.IsOptionsCommandAdded())
|
|
779 |
{
|
|
780 |
if (aKeyEvent.iCode == EKeyCBA1 || aKeyEvent.iCode == EKeyCBA2)
|
|
781 |
{
|
|
782 |
menuArranger.TryDisplayMenuBarL(EFalse);
|
|
783 |
return EKeyWasConsumed;
|
|
784 |
}
|
|
785 |
}
|
|
786 |
|
|
787 |
// If the OK and backspace keys are not used by the control, HandleKeyL() returns EKeyWasNotConsumed.
|
|
788 |
// Thus, this allows the command arranger calling the operations associated to these keys
|
|
789 |
MSwtCommandArranger* commandArranger = iDisplay.CommandArranger();
|
|
790 |
if (commandArranger != NULL)
|
|
791 |
{
|
|
792 |
// Clear command is called when backspace key is pressed
|
|
793 |
if (aKeyEvent.iCode == EKeyBackspace &&
|
|
794 |
!IsKeyUsed(EKeyBackspace) &&
|
|
795 |
commandArranger->IsClearOperationSet())
|
|
796 |
{
|
|
797 |
if (commandArranger->DoClearOperationL())
|
|
798 |
{
|
|
799 |
return EKeyWasConsumed;
|
|
800 |
}
|
|
801 |
}
|
|
802 |
else if (!AknLayoutUtils::MSKEnabled() ||
|
|
803 |
(activeTopShell && activeTopShell->FullScreenMode()))
|
|
804 |
{
|
|
805 |
// When the selection key is pressed, the default command is called otherwise
|
|
806 |
// a menu with the OK and SELECT commands is displayed
|
|
807 |
if (aKeyEvent.iCode == EKeyOK
|
|
808 |
&& !IsKeyUsed(EKeyOK)
|
|
809 |
&& commandArranger->IsContextSensitiveOperationSet())
|
|
810 |
{
|
|
811 |
if (commandArranger->DoContextSensitiveOperationL())
|
|
812 |
{
|
|
813 |
return EKeyWasConsumed;
|
|
814 |
}
|
|
815 |
}
|
|
816 |
}
|
|
817 |
else if (aKeyEvent.iCode == EKeyEnter && !IsKeyUsed(EKeyEnter))
|
|
818 |
{
|
|
819 |
if (commandArranger->HandleEnterKeyL())
|
|
820 |
{
|
|
821 |
return EKeyWasConsumed;
|
|
822 |
}
|
|
823 |
}
|
|
824 |
}
|
|
825 |
|
|
826 |
return EKeyWasNotConsumed;
|
|
827 |
}
|
|
828 |
|
|
829 |
TKeyResponse ASwtControlBase::HandleKeyL(const TKeyEvent& aKeyEvent,
|
|
830 |
TEventCode aType, TBool aTraversalDoIt)
|
|
831 |
{
|
|
832 |
// Follows implementation of diagonal Keys. Native diagonal keys are in eSWT
|
|
833 |
// replaced by two corresponding key events check if key is diagonal, if yes,
|
|
834 |
// change the traversalDoIt state
|
|
835 |
if (aKeyEvent.iCode == EKeyLeftUpArrow
|
|
836 |
|| aKeyEvent.iCode == EKeyRightUpArrow
|
|
837 |
|| aKeyEvent.iCode == EKeyLeftDownArrow
|
|
838 |
|| aKeyEvent.iCode == EKeyRightDownArrow)
|
|
839 |
{
|
|
840 |
aTraversalDoIt = EFalse;
|
|
841 |
}
|
|
842 |
|
|
843 |
switch (aKeyEvent.iCode)
|
|
844 |
{
|
|
845 |
case EKeyLeftUpArrow:
|
|
846 |
return HandleDiagonalKeysL(aKeyEvent, aType, aTraversalDoIt, EKeyLeftArrow,
|
|
847 |
EStdKeyLeftArrow, EKeyUpArrow, EStdKeyUpArrow);
|
|
848 |
case EKeyLeftDownArrow:
|
|
849 |
return HandleDiagonalKeysL(aKeyEvent, aType, aTraversalDoIt, EKeyLeftArrow,
|
|
850 |
EStdKeyLeftArrow, EKeyDownArrow, EStdKeyDownArrow);
|
|
851 |
case EKeyRightUpArrow:
|
|
852 |
return HandleDiagonalKeysL(aKeyEvent, aType, aTraversalDoIt, EKeyRightArrow,
|
|
853 |
EStdKeyRightArrow, EKeyUpArrow, EStdKeyUpArrow);
|
|
854 |
case EKeyRightDownArrow:
|
|
855 |
return HandleDiagonalKeysL(aKeyEvent, aType, aTraversalDoIt, EKeyRightArrow,
|
|
856 |
EStdKeyRightArrow, EKeyDownArrow, EStdKeyDownArrow);
|
|
857 |
}
|
|
858 |
|
|
859 |
// Offer key event to command arranger first
|
|
860 |
TKeyResponse keyResponse = OfferKeyEventToCommandAndMenuArrangersL(aKeyEvent, aType);
|
|
861 |
if (keyResponse == EKeyWasConsumed)
|
|
862 |
{
|
|
863 |
iTraverse = EFalse;
|
|
864 |
return EKeyWasConsumed;
|
|
865 |
}
|
|
866 |
|
|
867 |
// Traversal only on key event, not key down nor key up
|
|
868 |
if (aType != EEventKey)
|
|
869 |
{
|
|
870 |
if (!iTraverse
|
|
871 |
|
|
872 |
#ifndef RD_JAVA_S60_RELEASE_9_2
|
|
873 |
&& !(AknLayoutUtils::MSKEnabled()
|
|
874 |
&& aKeyEvent.iScanCode == EStdKeyDevice3
|
|
875 |
&& iDisplay.CommandArranger()->IsDefaultCommandSet())
|
|
876 |
#endif
|
|
877 |
)
|
|
878 |
{
|
|
879 |
iDisplay.PostKeyEventL(*this, aKeyEvent, aType);
|
|
880 |
}
|
|
881 |
iTraverse = EFalse;
|
|
882 |
return EKeyWasConsumed;
|
|
883 |
}
|
|
884 |
|
|
885 |
// In any case cancel the traverse state
|
|
886 |
iTraverse = EFalse;
|
|
887 |
|
|
888 |
TSwtTraversal detail(ESwtTraverseNone);
|
|
889 |
|
|
890 |
const TInt modifiers = aKeyEvent.iModifiers & ECtrlFuncShiftMask;
|
|
891 |
|
|
892 |
// If we press left or right arrow key and if there is a TabGroup displayed,
|
|
893 |
// we let the TabGroup manage the keys.
|
|
894 |
if (aTraversalDoIt && modifiers == 0
|
|
895 |
&& (aKeyEvent.iCode == EKeyRightArrow || aKeyEvent.iCode == EKeyLeftArrow))
|
|
896 |
{
|
|
897 |
keyResponse = OfferKeyEventToTabGroupL(aKeyEvent, aType);
|
|
898 |
if (keyResponse == EKeyWasConsumed)
|
|
899 |
{
|
|
900 |
return EKeyWasConsumed;
|
|
901 |
}
|
|
902 |
}
|
|
903 |
|
|
904 |
// Tab
|
|
905 |
if (aKeyEvent.iCode == EKeyTab)
|
|
906 |
{
|
|
907 |
switch (modifiers)
|
|
908 |
{
|
|
909 |
case 0: // Tab
|
|
910 |
case EModifierCtrl: // Ctrl+Tab
|
|
911 |
detail = ESwtTraverseTabNext;
|
|
912 |
break;
|
|
913 |
case EModifierShift: // Shift+Tab
|
|
914 |
case EModifierCtrl|EModifierShift: // Ctrl+Shift+Tab
|
|
915 |
detail = ESwtTraverseTabPrevious;
|
|
916 |
break;
|
|
917 |
default:
|
|
918 |
break;
|
|
919 |
}
|
|
920 |
}
|
|
921 |
else if (aKeyEvent.iCode == EKeyRightArrow ||
|
|
922 |
aKeyEvent.iCode == EKeyDownArrow)
|
|
923 |
{
|
|
924 |
detail = ESwtTraverseArrowNext;
|
|
925 |
}
|
|
926 |
else if (aKeyEvent.iCode == EKeyLeftArrow ||
|
|
927 |
aKeyEvent.iCode == EKeyUpArrow)
|
|
928 |
{
|
|
929 |
detail = ESwtTraverseArrowPrevious;
|
|
930 |
}
|
|
931 |
|
|
932 |
/*
|
|
933 |
* These two conditions are because workaround in Text. We simulate
|
|
934 |
* EEventKey from EEventKeyDown, so in this moment we haven't
|
|
935 |
* aKeyEvent.iCode value, only iScanCode.
|
|
936 |
*/
|
|
937 |
if (aType == EEventKey && aKeyEvent.iCode == 0)
|
|
938 |
{
|
|
939 |
if (aKeyEvent.iScanCode == EStdKeyLeftArrow)
|
|
940 |
{
|
|
941 |
detail = ESwtTraverseArrowPrevious;
|
|
942 |
}
|
|
943 |
if (aKeyEvent.iScanCode == EStdKeyRightArrow)
|
|
944 |
{
|
|
945 |
detail = ESwtTraverseArrowNext;
|
|
946 |
}
|
|
947 |
}
|
|
948 |
|
|
949 |
// Return (only if there is a default button or a default command)
|
|
950 |
if ((aKeyEvent.iCode==EKeyEnter || aKeyEvent.iCode==EKeyOK) && modifiers==0)
|
|
951 |
{
|
|
952 |
const MSwtShell& shell = GetShell();
|
|
953 |
if ((!ButtonInterface() || ((Style() & KSwtStylePush) == 0))
|
|
954 |
&& const_cast<MSwtShell&>(shell).Decorations()->DefaultButton())
|
|
955 |
{
|
|
956 |
detail = ESwtTraverseReturn;
|
|
957 |
}
|
|
958 |
|
|
959 |
if (shell.DefaultCommand())
|
|
960 |
{
|
|
961 |
detail = ESwtTraverseReturn;
|
|
962 |
}
|
|
963 |
}
|
|
964 |
|
|
965 |
// Escape (only for non top-level Shells)
|
|
966 |
if (aKeyEvent.iCode==EKeyEscape && modifiers==0)
|
|
967 |
{
|
|
968 |
if (GetShell().GetParentShell() != NULL)
|
|
969 |
detail = ESwtTraverseEscape;
|
|
970 |
}
|
|
971 |
|
|
972 |
// Send event
|
|
973 |
if (detail != ESwtTraverseNone)
|
|
974 |
{
|
|
975 |
iTraverse = aTraversalDoIt;
|
|
976 |
MSwtComposite* parent = this->GetParent();
|
|
977 |
if (parent)
|
|
978 |
{
|
|
979 |
// if the parent does not have a tablist.
|
|
980 |
// it means the parent should not be used as a composite.
|
|
981 |
// So don't post traverse event
|
|
982 |
CSwtPeerArray* tabList = parent->GetTabListL();
|
|
983 |
if (tabList)
|
|
984 |
{
|
|
985 |
delete tabList;
|
|
986 |
tabList = NULL;
|
|
987 |
iDisplay.PostTraverseEventL(*this, detail, aKeyEvent, aType, aTraversalDoIt);
|
|
988 |
}
|
|
989 |
}
|
|
990 |
else
|
|
991 |
{
|
|
992 |
iDisplay.PostTraverseEventL(*this, detail, aKeyEvent, aType, aTraversalDoIt);
|
|
993 |
}
|
|
994 |
}
|
|
995 |
else
|
|
996 |
{
|
|
997 |
iDisplay.PostKeyEventL(*this, aKeyEvent, aType);
|
|
998 |
}
|
|
999 |
|
|
1000 |
return EKeyWasConsumed;
|
|
1001 |
}
|
|
1002 |
|
|
1003 |
TKeyResponse ASwtControlBase::OfferKeyEventToTabGroupL(const TKeyEvent& aKeyEvent,TEventCode aType)
|
|
1004 |
{
|
|
1005 |
CEikStatusPane *sp = ((CAknAppUi*)iDisplay.CoeEnv()->EikAppUi())->StatusPane();
|
|
1006 |
ASSERT(sp != NULL);
|
|
1007 |
CAknNavigationControlContainer* naviCtrlCtnr = static_cast<CAknNavigationControlContainer*>
|
|
1008 |
(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
|
|
1009 |
ASSERT(naviCtrlCtnr != NULL);
|
|
1010 |
CAknNavigationDecorator* navi = naviCtrlCtnr->Top();
|
|
1011 |
if (navi != NULL && navi->ControlType() == CAknNavigationDecorator::ETabGroup) // if there is a tab group
|
|
1012 |
{
|
|
1013 |
CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>(navi->DecoratedControl());
|
|
1014 |
if (tabGroup != NULL && tabGroup->OfferKeyEventL(aKeyEvent, aType) == EKeyWasConsumed)
|
|
1015 |
{
|
|
1016 |
TSwtTraversal detail(ESwtTraverseNone);
|
|
1017 |
if (AknLayoutUtils::LayoutMirrored())
|
|
1018 |
{
|
|
1019 |
detail = (aKeyEvent.iCode == EKeyRightArrow ?
|
|
1020 |
ESwtTraversePagePrevious : ESwtTraversePageNext);
|
|
1021 |
}
|
|
1022 |
else
|
|
1023 |
{
|
|
1024 |
detail = (aKeyEvent.iCode == EKeyRightArrow ?
|
|
1025 |
ESwtTraversePageNext : ESwtTraversePagePrevious);
|
|
1026 |
}
|
|
1027 |
iDisplay.PostTraverseEventL(*this, detail, aKeyEvent, aType, ETrue);
|
|
1028 |
// The tab has consumed the key event.
|
|
1029 |
return EKeyWasConsumed;
|
|
1030 |
}
|
|
1031 |
}
|
|
1032 |
return EKeyWasNotConsumed;
|
|
1033 |
}
|
|
1034 |
|
|
1035 |
EXPORT_C void ASwtControlBase::RegisterWithParentL()
|
|
1036 |
{
|
|
1037 |
if (iParent != NULL)
|
|
1038 |
{
|
|
1039 |
// eSWT hierarchy controls.
|
|
1040 |
iParent->RegisterChildL(*this);
|
|
1041 |
}
|
|
1042 |
|
|
1043 |
// Set our DoNotDraw flag according to our parent flag
|
|
1044 |
if (iParent != NULL)
|
|
1045 |
{
|
|
1046 |
UpdateDoNotDrawFlag();
|
|
1047 |
}
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
EXPORT_C TTypeUid::Ptr ASwtControlBase::SwtMopSupplyObject(TTypeUid aId)
|
|
1051 |
{
|
|
1052 |
// MAknsControlContext is ask.
|
|
1053 |
if (aId.iUid == MAknsControlContext::ETypeId)
|
|
1054 |
{
|
|
1055 |
MAknsControlContext* bckgd = SwtMopSupplyCtrlContext();
|
|
1056 |
|
|
1057 |
// If a parent have is own background context and the color background was not set on it.
|
|
1058 |
// Return the Control Context of his background.
|
|
1059 |
if (bckgd != NULL)
|
|
1060 |
{
|
|
1061 |
return MAknsControlContext::SupplyMopObject(aId, bckgd);
|
|
1062 |
}
|
|
1063 |
}
|
|
1064 |
|
|
1065 |
// Else return Null
|
|
1066 |
return TTypeUid::Null();
|
|
1067 |
}
|
|
1068 |
|
|
1069 |
MAknsControlContext* ASwtControlBase::SwtMopSupplyCtrlContext(TBool aBeginSearchToThis) const
|
|
1070 |
{
|
|
1071 |
MAknsControlContext* background = NULL;
|
|
1072 |
if (aBeginSearchToThis)
|
|
1073 |
{
|
|
1074 |
background = FocusBackgroundNow();
|
|
1075 |
if (background)
|
|
1076 |
{
|
|
1077 |
return background;
|
|
1078 |
}
|
|
1079 |
}
|
|
1080 |
|
|
1081 |
MSwtComposite* parent = GetParent();
|
|
1082 |
TInt policy = FocusBackgroundPolicy();
|
|
1083 |
if (IsDefaultBackgroundUse())
|
|
1084 |
{
|
|
1085 |
background = aBeginSearchToThis ? GetControlContext() : NULL;
|
|
1086 |
while (!background && parent)
|
|
1087 |
{
|
|
1088 |
// If policy is ENoFocusBackgroundInCaptionedControl, bypass the caption highlight.
|
|
1089 |
if (policy == ENoFocusBackgroundInCaptionedControl
|
|
1090 |
&& parent->Control()->CaptionedControlInterface())
|
|
1091 |
{
|
|
1092 |
parent = parent->Control()->GetParent();
|
|
1093 |
ASSERT(parent);
|
|
1094 |
}
|
|
1095 |
|
|
1096 |
background = parent->Control()->GetControlContext();
|
|
1097 |
|
|
1098 |
// If the parent is a Shell we stop on it.
|
|
1099 |
if (parent->Control()->IsShell())
|
|
1100 |
{
|
|
1101 |
parent = NULL;
|
|
1102 |
}
|
|
1103 |
else
|
|
1104 |
{
|
|
1105 |
parent = parent->Control()->GetParent();
|
|
1106 |
}
|
|
1107 |
}
|
|
1108 |
}
|
|
1109 |
|
|
1110 |
return background;
|
|
1111 |
}
|
|
1112 |
|
|
1113 |
RRegion* ASwtControlBase::SetupChildClippingRegion(const MSwtComposite* aComposite,
|
|
1114 |
CWindowGc& aGc,
|
|
1115 |
const TRect& aDrawRect,
|
|
1116 |
const TPoint& aOffset /*= TPoint( 0, 0 )*/) const
|
|
1117 |
{
|
|
1118 |
ASSERT(aComposite);
|
|
1119 |
|
|
1120 |
TBool clippingRegionSet(EFalse);
|
|
1121 |
RRegion* clippingRegion = NULL;
|
|
1122 |
if (aComposite)
|
|
1123 |
{
|
|
1124 |
TInt childCount(0);
|
|
1125 |
const RSwtControlArray* children = aComposite->Children();
|
|
1126 |
if (children)
|
|
1127 |
{
|
|
1128 |
childCount = children->Count();
|
|
1129 |
}
|
|
1130 |
// If this control has children then proceed with setting
|
|
1131 |
// a clipping region to exclude them.
|
|
1132 |
if (childCount > 0)
|
|
1133 |
{
|
|
1134 |
clippingRegion = new RRegion(aDrawRect, childCount + 1);
|
|
1135 |
if (clippingRegion)
|
|
1136 |
{
|
|
1137 |
for (TInt i = 0; i < childCount; ++i)
|
|
1138 |
{
|
|
1139 |
MSwtControl* child = (*children)[ i ];
|
|
1140 |
// Shells are window owning so they will get clipped anyway.
|
|
1141 |
// No point in adding overhead by handling them manually here.
|
|
1142 |
// Also controls that are not visible should not be clipped.
|
|
1143 |
if (child && !child->IsShell() && child->CoeControl().IsVisible()
|
|
1144 |
&& !child->HasDoNotDrawFlag())
|
|
1145 |
{
|
|
1146 |
clippingRegion->SubRect(child->CoeControl().Rect());
|
|
1147 |
}
|
|
1148 |
}
|
|
1149 |
if (!clippingRegion->CheckError())
|
|
1150 |
{
|
|
1151 |
if (aOffset != TPoint(0, 0))
|
|
1152 |
{
|
|
1153 |
clippingRegion->Offset(aOffset);
|
|
1154 |
}
|
|
1155 |
if (aGc.SetClippingRegion(*clippingRegion) == KErrNone)
|
|
1156 |
{
|
|
1157 |
clippingRegionSet = ETrue;
|
|
1158 |
}
|
|
1159 |
}
|
|
1160 |
if (!clippingRegionSet)
|
|
1161 |
{
|
|
1162 |
if (clippingRegion)
|
|
1163 |
{
|
|
1164 |
clippingRegion->Destroy();
|
|
1165 |
}
|
|
1166 |
clippingRegion = NULL;
|
|
1167 |
}
|
|
1168 |
}
|
|
1169 |
}
|
|
1170 |
}
|
|
1171 |
return clippingRegion;
|
|
1172 |
}
|
|
1173 |
|
|
1174 |
void ASwtControlBase::CancelChildClippingRegion(RRegion* aClippingRegion,
|
|
1175 |
CWindowGc& aGc) const
|
|
1176 |
{
|
|
1177 |
// Cancel & destroy the clipping region
|
|
1178 |
if (aClippingRegion)
|
|
1179 |
{
|
|
1180 |
aGc.CancelClippingRegion();
|
|
1181 |
aClippingRegion->Destroy();
|
|
1182 |
}
|
|
1183 |
}
|
|
1184 |
|
|
1185 |
TPoint ASwtControlBase::ClientToWindow(const TPoint& aPoint) const
|
|
1186 |
{
|
|
1187 |
return aPoint + ClientRect().iTl;
|
|
1188 |
}
|
|
1189 |
|
|
1190 |
TRect ASwtControlBase::ClientToWindow(const TRect& aRect) const
|
|
1191 |
{
|
|
1192 |
const TRect clientRect(ClientRect());
|
|
1193 |
return TRect(aRect.iTl+clientRect.iTl, aRect.iBr+clientRect.iTl);
|
|
1194 |
}
|
|
1195 |
|
|
1196 |
TPoint ASwtControlBase::WindowToClient(const TPoint& aPoint) const
|
|
1197 |
{
|
|
1198 |
return aPoint - ClientRect().iTl;
|
|
1199 |
}
|
|
1200 |
|
|
1201 |
EXPORT_C const MSwtFont& ASwtControlBase::DefaultFont() const
|
|
1202 |
{
|
|
1203 |
return *(iDisplay.Device().GetSystemFont());
|
|
1204 |
}
|
|
1205 |
|
|
1206 |
void ASwtControlBase::HandleRectChanged()
|
|
1207 |
{
|
|
1208 |
// Rebound the focus highlight
|
|
1209 |
if (iFocusFrame)
|
|
1210 |
{
|
|
1211 |
TRect rect(CoeControl().Rect());
|
|
1212 |
TRect innerRect;
|
|
1213 |
innerRect.iTl = CSwtLafFacade::GetLayoutRect(
|
|
1214 |
CSwtLafFacade::EInputFieldSkinPlacingGeneralLine2, rect, 0).Rect().iBr;
|
|
1215 |
innerRect.iBr = CSwtLafFacade::GetLayoutRect(
|
|
1216 |
CSwtLafFacade::EInputFieldSkinPlacingGeneralLine5, rect, 0).Rect().iTl;
|
|
1217 |
iFocusFrame->SetFrameRects(rect, innerRect);
|
|
1218 |
}
|
|
1219 |
}
|
|
1220 |
|
|
1221 |
EXPORT_C void ASwtControlBase::HandleSizeChanged()
|
|
1222 |
{
|
|
1223 |
if (iPrevCoeSize == CoeControl().Size())
|
|
1224 |
{
|
|
1225 |
return;
|
|
1226 |
}
|
|
1227 |
|
|
1228 |
if (iPrevCoeSize != CoeControl().Size())
|
|
1229 |
{
|
|
1230 |
iPrevCoeSize = CoeControl().Size();
|
|
1231 |
TRAP_IGNORE(iDisplay.PostResizeEventL(iPeer));
|
|
1232 |
HandleRectChanged();
|
|
1233 |
}
|
|
1234 |
}
|
|
1235 |
|
|
1236 |
EXPORT_C void ASwtControlBase::HandlePositionChanged()
|
|
1237 |
{
|
|
1238 |
if (iPrevSwtPos == GetLocation() && iPrevCoePos == CoeControl().Position())
|
|
1239 |
{
|
|
1240 |
return;
|
|
1241 |
}
|
|
1242 |
|
|
1243 |
if (iPrevSwtPos != GetLocation())
|
|
1244 |
{
|
|
1245 |
iPrevSwtPos = GetLocation();
|
|
1246 |
TRAP_IGNORE(iDisplay.PostMoveEventL(iPeer));
|
|
1247 |
}
|
|
1248 |
|
|
1249 |
if (iPrevCoePos != CoeControl().Position())
|
|
1250 |
{
|
|
1251 |
iPrevCoePos = CoeControl().Position();
|
|
1252 |
HandleRectChanged();
|
|
1253 |
}
|
|
1254 |
}
|
|
1255 |
|
|
1256 |
//
|
|
1257 |
// Virtual methods from MSwtDrawable
|
|
1258 |
//
|
|
1259 |
EXPORT_C MSwtGc* ASwtControlBase::NewGcL()
|
|
1260 |
{
|
|
1261 |
CCoeControl& coeCtrl = CoeControl();
|
|
1262 |
|
|
1263 |
// Create the native GC
|
|
1264 |
CWsScreenDevice& device = static_cast<CWsScreenDevice&>(GraphicsDevice());
|
|
1265 |
CWindowGc* nativeGc = new(ELeave) CWindowGc(&device);
|
|
1266 |
TInt error = nativeGc->Construct();
|
|
1267 |
if (error)
|
|
1268 |
{
|
|
1269 |
delete nativeGc;
|
|
1270 |
User::Leave(error);
|
|
1271 |
}
|
|
1272 |
nativeGc->Activate(*coeCtrl.DrawableWindow());
|
|
1273 |
|
|
1274 |
// Set the GC's origin to the top-left of the client area
|
|
1275 |
const TRect clientRect(ClientRect()); // in window coords
|
|
1276 |
nativeGc->SetOrigin(clientRect.iTl);
|
|
1277 |
|
|
1278 |
// Compute the boundary rect (in GC coords)
|
|
1279 |
TRect boundaryRect(clientRect);
|
|
1280 |
if (!IsShell())
|
|
1281 |
{
|
|
1282 |
MSwtComposite* parent = GetParent();
|
|
1283 |
if (parent != NULL)
|
|
1284 |
boundaryRect.Intersection(static_cast<ASwtControlBase*>(parent->Control())->VisibleRect());
|
|
1285 |
}
|
|
1286 |
boundaryRect.Move(-clientRect.iTl);
|
|
1287 |
|
|
1288 |
// Compute the GC rect in screen coords
|
|
1289 |
const TRect gcScreenRect(WindowToScreen(clientRect.iTl), clientRect.Size());
|
|
1290 |
|
|
1291 |
// Get the colours & the font
|
|
1292 |
CEikonEnv* eikenv = iDisplay.CoeEnv();
|
|
1293 |
TRgb penCol(eikenv->ControlColor(EColorControlText, coeCtrl));
|
|
1294 |
TRgb brushCol(eikenv->ControlColor(EColorControlBackground, coeCtrl));
|
|
1295 |
const MSwtFont* font = GetFont();
|
|
1296 |
ASSERT(font!=NULL);
|
|
1297 |
|
|
1298 |
return iDisplay.Factory().NewWindowGcL(*this, nativeGc, DestroyNativeGc,
|
|
1299 |
penCol, brushCol, *font, boundaryRect, gcScreenRect);
|
|
1300 |
}
|
|
1301 |
|
|
1302 |
EXPORT_C CBitmapDevice& ASwtControlBase::GraphicsDevice()
|
|
1303 |
{
|
|
1304 |
return *static_cast<CWsScreenDevice*>(iDisplay.CoeEnv()->SystemGc().Device());
|
|
1305 |
}
|
|
1306 |
|
|
1307 |
EXPORT_C void ASwtControlBase::HandleUpdate()
|
|
1308 |
{
|
|
1309 |
// Nothing to do for controls
|
|
1310 |
}
|
|
1311 |
|
|
1312 |
void ASwtControlBase::DestroyNativeGc(CBitmapContext* aGc)
|
|
1313 |
{
|
|
1314 |
static_cast<CWindowGc*>(aGc)->Deactivate();
|
|
1315 |
delete aGc;
|
|
1316 |
}
|
|
1317 |
|
|
1318 |
//
|
|
1319 |
// Virtual methods from MSwtControl
|
|
1320 |
//
|
|
1321 |
EXPORT_C TSwtPeer ASwtControlBase::Dispose()
|
|
1322 |
{
|
|
1323 |
// Note that unregistration is done here rather than in the destructor.
|
|
1324 |
// The reason for it is that an object may go through destruction before
|
|
1325 |
// being registered.
|
|
1326 |
if (iParent) // This may be NULL because of top-level Shells
|
|
1327 |
{
|
|
1328 |
iParent->UnregisterChild(*this);
|
|
1329 |
}
|
|
1330 |
// If the control has a bad parent, such as combo, table or caption control
|
|
1331 |
// UnregisterChild does not kill the focus
|
|
1332 |
if (CoeControl().IsFocused())
|
|
1333 |
{
|
|
1334 |
CoeControl().SetFocus(EFalse);
|
|
1335 |
ASSERT(!CoeControl().IsFocused());
|
|
1336 |
}
|
|
1337 |
|
|
1338 |
// RemoveRef here in case iFont would be pointing to an MSwtFont
|
|
1339 |
// that is disposed in destructor of the object (e.g. iDefaultFont)
|
|
1340 |
if (iFont)
|
|
1341 |
{
|
|
1342 |
iFont->RemoveRef();
|
|
1343 |
iFont = NULL;
|
|
1344 |
}
|
|
1345 |
|
|
1346 |
Invalidate(CoeControl().Rect());
|
|
1347 |
|
|
1348 |
if (UiUtils().PointerCaptureControl() == this)
|
|
1349 |
{
|
|
1350 |
UiUtils().SetPointerCaptureControl(NULL);
|
|
1351 |
}
|
|
1352 |
if (UiUtils().NextFocusedControl() == this)
|
|
1353 |
{
|
|
1354 |
UiUtils().SetNextFocusedControl(NULL);
|
|
1355 |
}
|
|
1356 |
if (iDisplay.LongTapAnimationControl() == this)
|
|
1357 |
{
|
|
1358 |
iDisplay.CancelLongTapAnimation();
|
|
1359 |
}
|
|
1360 |
|
|
1361 |
RemoveFromControlStack();
|
|
1362 |
|
|
1363 |
GetShell().ControlDisposing(*this);
|
|
1364 |
|
|
1365 |
TSwtPeer peer(iPeer);
|
|
1366 |
DoDelete();
|
|
1367 |
return peer;
|
|
1368 |
}
|
|
1369 |
|
|
1370 |
EXPORT_C TSwtPeer ASwtControlBase::JavaPeer() const
|
|
1371 |
{
|
|
1372 |
return iPeer;
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
EXPORT_C TUint ASwtControlBase::Flags() const
|
|
1376 |
{
|
|
1377 |
return iCtrlFlags;
|
|
1378 |
}
|
|
1379 |
|
|
1380 |
EXPORT_C void ASwtControlBase::Paint(const TRect& aRect,
|
|
1381 |
TBool aPaintNatively /*= ETrue*/,
|
|
1382 |
MSwtGc* aGc /*= NULL*/,
|
|
1383 |
TInt* aIntParams /*= NULL*/,
|
|
1384 |
TInt aIntCount /*= 0*/,
|
|
1385 |
HBufC* aStrParams /*= NULL*/) const
|
|
1386 |
{
|
|
1387 |
// While emergency paints are required, painting is done by PaintUrgently
|
|
1388 |
// It is essential that paint events coming from Java are not served as
|
|
1389 |
// they can slow down considerably the kinetic scrolling.
|
|
1390 |
// The only reason for letting non-urgent paint controls still paint is
|
|
1391 |
// that there might be late paint event arriving after the urgent paint
|
|
1392 |
// has started as in the case of focus changes.
|
|
1393 |
MSwtShell& shell = GetShell();
|
|
1394 |
if (shell.UrgentPaintControl() == this)
|
|
1395 |
{
|
|
1396 |
return;
|
|
1397 |
}
|
|
1398 |
|
|
1399 |
if (iCtrlFlags & MSwtControl::EFlagDoNotDraw)
|
|
1400 |
{
|
|
1401 |
return;
|
|
1402 |
}
|
|
1403 |
|
|
1404 |
// Except Shells, Controls cannot draw over invisible parents.
|
|
1405 |
if (!GetVisibleRecursively())
|
|
1406 |
{
|
|
1407 |
return;
|
|
1408 |
}
|
|
1409 |
|
|
1410 |
const CCoeControl& coeCtrl = CoeControl();
|
|
1411 |
RWindow* window = static_cast<RWindow*>(coeCtrl.DrawableWindow());
|
|
1412 |
ASSERT(window);
|
|
1413 |
|
|
1414 |
TRect dirtyRect(aRect); // screen coordinates
|
|
1415 |
dirtyRect.Move(-window->Position()); // window coordinates
|
|
1416 |
dirtyRect.Intersection(VisibleRect(ETrue));
|
|
1417 |
if (dirtyRect.IsEmpty())
|
|
1418 |
{
|
|
1419 |
return;
|
|
1420 |
}
|
|
1421 |
|
|
1422 |
CWindowGc& systemGc = coeCtrl.SystemGc();
|
|
1423 |
MSwtComposite* comp = CompositeInterface();
|
|
1424 |
|
|
1425 |
window->Invalidate(dirtyRect);
|
|
1426 |
window->BeginRedraw(dirtyRect);
|
|
1427 |
|
|
1428 |
// Native controls draw here
|
|
1429 |
if (aPaintNatively)
|
|
1430 |
{
|
|
1431 |
systemGc.Activate(*window);
|
|
1432 |
systemGc.Reset();
|
|
1433 |
systemGc.SetClippingRect(dirtyRect);
|
|
1434 |
DoPaint(dirtyRect);
|
|
1435 |
|
|
1436 |
TBool isChildShell(EFalse);
|
|
1437 |
if (comp)
|
|
1438 |
{
|
|
1439 |
// GC intentionally reset only once for both scrollbar back and border.
|
|
1440 |
systemGc.Reset();
|
|
1441 |
systemGc.SetClippingRect(dirtyRect);
|
|
1442 |
comp->DrawScrollBarBackground(dirtyRect);
|
|
1443 |
|
|
1444 |
// For child Shells, the border is drawn right after the background.
|
|
1445 |
isChildShell = IsShell() && iParent;
|
|
1446 |
if (isChildShell)
|
|
1447 |
{
|
|
1448 |
if (HasBorderStyle())
|
|
1449 |
{
|
|
1450 |
DrawBorder(dirtyRect);
|
|
1451 |
}
|
|
1452 |
}
|
|
1453 |
}
|
|
1454 |
|
|
1455 |
// GC is reset inside DrawComponentControls
|
|
1456 |
DrawComponentControls(coeCtrl, dirtyRect, systemGc, CanDrawOutsideRect());
|
|
1457 |
|
|
1458 |
if (!isChildShell)
|
|
1459 |
{
|
|
1460 |
if (HasBorderStyle())
|
|
1461 |
{
|
|
1462 |
systemGc.Reset();
|
|
1463 |
systemGc.SetClippingRect(dirtyRect);
|
|
1464 |
DrawBorder(dirtyRect);
|
|
1465 |
}
|
|
1466 |
}
|
|
1467 |
}
|
|
1468 |
|
|
1469 |
// Java paint listener draws here
|
|
1470 |
if (aGc)
|
|
1471 |
{
|
|
1472 |
// Workaround, corrects the clipping region. Currently without this workaround
|
|
1473 |
// if we do a BitBlt from the command buffer and the GCs origin has been set to > (0, 0)
|
|
1474 |
// then clipping region will be wrong. Origin is applied to it twice. Adding some
|
|
1475 |
// operation here, before the potential BitBlt, will correct the problem. This is
|
|
1476 |
// a platform issue in 3.2 with pre-activated graphics contexts.
|
|
1477 |
#ifndef RD_SCALABLE_UI_V2
|
|
1478 |
aGc->BitmapContext().Plot(TPoint(-1,-1));
|
|
1479 |
#endif //RD_SCALABLE_UI_V2
|
|
1480 |
|
|
1481 |
// Clip Java GC so that it does not need to draw under children of the composite.
|
|
1482 |
CWindowGc& javaGc= static_cast<CWindowGc&>(aGc->BitmapContext());
|
|
1483 |
RRegion* javaGcClipRegion = NULL;
|
|
1484 |
TRect javaGcRect(dirtyRect); // window coordinates
|
|
1485 |
javaGcRect.Intersection(ClientRect()); // window coordinates
|
|
1486 |
if (comp)
|
|
1487 |
{
|
|
1488 |
javaGcClipRegion = SetupChildClippingRegion(
|
|
1489 |
comp,
|
|
1490 |
javaGc,
|
|
1491 |
javaGcRect,
|
|
1492 |
-ClientRect().iTl); // Java GC coordinates (relative to client area)
|
|
1493 |
}
|
|
1494 |
|
|
1495 |
// Flush Java GC
|
|
1496 |
FlushJavaBuffer(aGc, aIntParams, aIntCount, aStrParams, window, javaGcRect);
|
|
1497 |
CancelChildClippingRegion(javaGcClipRegion, javaGc);
|
|
1498 |
}
|
|
1499 |
|
|
1500 |
window->EndRedraw();
|
|
1501 |
|
|
1502 |
if (aPaintNatively)
|
|
1503 |
{
|
|
1504 |
systemGc.Deactivate();
|
|
1505 |
}
|
|
1506 |
|
|
1507 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
1508 |
iDisplay.CoeEnv()->WsSession().Finish();
|
|
1509 |
#endif
|
|
1510 |
}
|
|
1511 |
|
|
1512 |
EXPORT_C void ASwtControlBase::PaintUrgently(const TRect& aRect, TBool aInitDraw /*= ETrue*/) const
|
|
1513 |
{
|
|
1514 |
if (iCtrlFlags & MSwtControl::EFlagDoNotDraw)
|
|
1515 |
{
|
|
1516 |
return;
|
|
1517 |
}
|
|
1518 |
|
|
1519 |
// Except Shells, Controls cannot draw over invisible parents.
|
|
1520 |
if (!GetVisibleRecursively())
|
|
1521 |
{
|
|
1522 |
return;
|
|
1523 |
}
|
|
1524 |
|
|
1525 |
TRect dirtyRect(aRect); // window coordinates
|
|
1526 |
dirtyRect.Intersection(VisibleRect(ETrue));
|
|
1527 |
if (dirtyRect.IsEmpty())
|
|
1528 |
{
|
|
1529 |
return;
|
|
1530 |
}
|
|
1531 |
|
|
1532 |
const CCoeControl& coeCtrl = CoeControl();
|
|
1533 |
RWindow* window = static_cast<RWindow*>(coeCtrl.DrawableWindow());
|
|
1534 |
ASSERT(window);
|
|
1535 |
CWindowGc& systemGc = coeCtrl.SystemGc();
|
|
1536 |
|
|
1537 |
if (aInitDraw)
|
|
1538 |
{
|
|
1539 |
systemGc.Activate(*window);
|
|
1540 |
window->Invalidate(dirtyRect);
|
|
1541 |
window->BeginRedraw(dirtyRect);
|
|
1542 |
}
|
|
1543 |
|
|
1544 |
systemGc.Reset();
|
|
1545 |
systemGc.SetClippingRect(dirtyRect);
|
|
1546 |
DoPaint(dirtyRect);
|
|
1547 |
|
|
1548 |
TBool isChildShell(EFalse);
|
|
1549 |
MSwtComposite* comp = CompositeInterface();
|
|
1550 |
if (comp)
|
|
1551 |
{
|
|
1552 |
// GC intentionally reset only once for both scrollbar back and border.
|
|
1553 |
systemGc.Reset();
|
|
1554 |
systemGc.SetClippingRect(dirtyRect);
|
|
1555 |
comp->DrawScrollBarBackground(dirtyRect);
|
|
1556 |
|
|
1557 |
// For child Shells, the border is drawn right after the background.
|
|
1558 |
isChildShell = IsShell() && iParent;
|
|
1559 |
if (isChildShell)
|
|
1560 |
{
|
|
1561 |
if (HasBorderStyle())
|
|
1562 |
{
|
|
1563 |
DrawBorder(dirtyRect);
|
|
1564 |
}
|
|
1565 |
}
|
|
1566 |
}
|
|
1567 |
|
|
1568 |
// GC is reset inside DrawComponentControls
|
|
1569 |
DrawComponentControls(coeCtrl, dirtyRect, systemGc, CanDrawOutsideRect());
|
|
1570 |
|
|
1571 |
if (!isChildShell)
|
|
1572 |
{
|
|
1573 |
if (HasBorderStyle())
|
|
1574 |
{
|
|
1575 |
systemGc.Reset();
|
|
1576 |
systemGc.SetClippingRect(dirtyRect);
|
|
1577 |
DrawBorder(dirtyRect);
|
|
1578 |
}
|
|
1579 |
}
|
|
1580 |
|
|
1581 |
if (comp)
|
|
1582 |
{
|
|
1583 |
const RSwtControlArray* children = comp->Children();
|
|
1584 |
const TInt count = children->Count();
|
|
1585 |
for (TInt i = 0; i < count; i++)
|
|
1586 |
{
|
|
1587 |
MSwtControl* child = (*children)[i];
|
|
1588 |
if (!child->IsShell())
|
|
1589 |
child->PaintUrgently(dirtyRect, EFalse);
|
|
1590 |
}
|
|
1591 |
}
|
|
1592 |
|
|
1593 |
if (aInitDraw)
|
|
1594 |
{
|
|
1595 |
window->EndRedraw();
|
|
1596 |
systemGc.Deactivate();
|
|
1597 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
1598 |
iDisplay.CoeEnv()->WsSession().Finish();
|
|
1599 |
#endif
|
|
1600 |
}
|
|
1601 |
}
|
|
1602 |
|
|
1603 |
EXPORT_C TBool ASwtControlBase::IsPaintingUrgently() const
|
|
1604 |
{
|
|
1605 |
MSwtControl* urgentPaintControl = GetShell().UrgentPaintControl();
|
|
1606 |
return urgentPaintControl
|
|
1607 |
&& (urgentPaintControl == this || IsDescentOf(*urgentPaintControl));
|
|
1608 |
}
|
|
1609 |
|
|
1610 |
EXPORT_C TBool ASwtControlBase::IsFocusable(TInt aReason /*=KSwtFocusByApi*/) const
|
|
1611 |
{
|
|
1612 |
const CCoeControl& coeCtrl = CoeControl();
|
|
1613 |
|
|
1614 |
// Invisible or disabled control can never get the focus (not even forced)
|
|
1615 |
if (!coeCtrl.IsVisible() || coeCtrl.IsDimmed())
|
|
1616 |
return EFalse;
|
|
1617 |
|
|
1618 |
MSwtComposite* parent = GetParent();
|
|
1619 |
|
|
1620 |
// Go through the whole ancestor chain, if any of the ancestors is
|
|
1621 |
// disabled or invisible, return EFalse.
|
|
1622 |
while (parent)
|
|
1623 |
{
|
|
1624 |
MSwtControl* parentCtrl = parent->Control();
|
|
1625 |
|
|
1626 |
if (!parentCtrl->GetEnabled() || !parentCtrl->GetVisible())
|
|
1627 |
{
|
|
1628 |
return EFalse;
|
|
1629 |
}
|
|
1630 |
|
|
1631 |
if (!parentCtrl->IsShell())
|
|
1632 |
{
|
|
1633 |
parent = parentCtrl->GetParent();
|
|
1634 |
}
|
|
1635 |
else
|
|
1636 |
{
|
|
1637 |
parent = NULL;
|
|
1638 |
}
|
|
1639 |
}
|
|
1640 |
|
|
1641 |
return ((aReason == KSwtFocusByForce) || !coeCtrl.IsNonFocusing());
|
|
1642 |
}
|
|
1643 |
|
|
1644 |
EXPORT_C TBool ASwtControlBase::SetSwtFocus(TInt aReason /*=KSwtFocusByApi*/)
|
|
1645 |
{
|
|
1646 |
ASSERT(!IsShell());
|
|
1647 |
|
|
1648 |
CCoeControl& coeCtrl = CoeControl();
|
|
1649 |
if (coeCtrl.IsFocused())
|
|
1650 |
{
|
|
1651 |
return ETrue;
|
|
1652 |
}
|
|
1653 |
|
|
1654 |
MSwtShell& shell = GetShell();
|
|
1655 |
if (!IsFocusable(aReason))
|
|
1656 |
{
|
|
1657 |
// remember the control which is not focusible because its parent shell is invisible currently
|
|
1658 |
// the control can get the focus later whenever the shell becomes visible.
|
|
1659 |
|
|
1660 |
if (shell.Control()->GetVisible())
|
|
1661 |
{
|
|
1662 |
// don't need to remember the control when the control itself is a shell
|
|
1663 |
// or its parent shell is visible.
|
|
1664 |
return EFalse;
|
|
1665 |
}
|
|
1666 |
|
|
1667 |
const CCoeControl& coeCtrl = CoeControl();
|
|
1668 |
if ((aReason != KSwtFocusByForce) && coeCtrl.IsNonFocusing())
|
|
1669 |
{
|
|
1670 |
// don't remember non-focusing control
|
|
1671 |
return EFalse;
|
|
1672 |
}
|
|
1673 |
|
|
1674 |
// Go through the whole ancestor chain, if any of the ancestors is
|
|
1675 |
// disabled, don't remember the control.
|
|
1676 |
TBool rememberIt(ETrue);
|
|
1677 |
MSwtComposite* parent = GetParent();
|
|
1678 |
while (parent)
|
|
1679 |
{
|
|
1680 |
MSwtControl* parentCtrl = parent->Control();
|
|
1681 |
if (!parentCtrl->GetEnabled())
|
|
1682 |
{
|
|
1683 |
rememberIt = EFalse;
|
|
1684 |
break;
|
|
1685 |
}
|
|
1686 |
|
|
1687 |
if (!parentCtrl->IsShell())
|
|
1688 |
{
|
|
1689 |
parent = parentCtrl->GetParent();
|
|
1690 |
}
|
|
1691 |
else
|
|
1692 |
{
|
|
1693 |
break;
|
|
1694 |
}
|
|
1695 |
}
|
|
1696 |
|
|
1697 |
if (rememberIt)
|
|
1698 |
{
|
|
1699 |
shell.SetToBeFocusedControl(this);
|
|
1700 |
}
|
|
1701 |
|
|
1702 |
return EFalse;
|
|
1703 |
}
|
|
1704 |
|
|
1705 |
|
|
1706 |
CSwtUiUtils& uiUtils = UiUtils();
|
|
1707 |
|
|
1708 |
if (uiUtils.GetActiveShell()==&shell || uiUtils.CanBeActive(shell))
|
|
1709 |
{
|
|
1710 |
if (uiUtils.IsAppFocused())
|
|
1711 |
{
|
|
1712 |
// Focus if we can (Shell must be able to be active)
|
|
1713 |
coeCtrl.SetFocus(ETrue);
|
|
1714 |
}
|
|
1715 |
else
|
|
1716 |
{
|
|
1717 |
// Set next focused control
|
|
1718 |
uiUtils.SetNextFocusedControl(this);
|
|
1719 |
}
|
|
1720 |
}
|
|
1721 |
|
|
1722 |
return coeCtrl.IsFocused();
|
|
1723 |
}
|
|
1724 |
|
|
1725 |
EXPORT_C TInt ASwtControlBase::FocusBackgroundPolicy() const
|
|
1726 |
{
|
|
1727 |
return EDefaultFocusBackground;
|
|
1728 |
};
|
|
1729 |
|
|
1730 |
EXPORT_C TInt ASwtControlBase::PressBackgroundPolicy() const
|
|
1731 |
{
|
|
1732 |
return ENoPressBackground;
|
|
1733 |
};
|
|
1734 |
|
|
1735 |
EXPORT_C TBool ASwtControlBase::GetEnabled() const
|
|
1736 |
{
|
|
1737 |
return (CoeControl().IsDimmed()) ? EFalse : ETrue;
|
|
1738 |
}
|
|
1739 |
|
|
1740 |
EXPORT_C TBool ASwtControlBase::GetVisible() const
|
|
1741 |
{
|
|
1742 |
return !(iCtrlFlags & MSwtControl::EFlagInvisible);
|
|
1743 |
}
|
|
1744 |
|
|
1745 |
EXPORT_C TBool ASwtControlBase::GetVisibleRecursively() const
|
|
1746 |
{
|
|
1747 |
if (!IsShell() && iParent && !iParent->Control()->GetVisibleRecursively())
|
|
1748 |
{
|
|
1749 |
return EFalse;
|
|
1750 |
}
|
|
1751 |
return GetVisible();
|
|
1752 |
}
|
|
1753 |
|
|
1754 |
EXPORT_C TBool ASwtControlBase::IsDefaultBackgroundUse() const
|
|
1755 |
{
|
|
1756 |
return iBackgrdDefaultUsed;
|
|
1757 |
}
|
|
1758 |
|
|
1759 |
EXPORT_C MAknsControlContext* ASwtControlBase::GetControlContext() const
|
|
1760 |
{
|
|
1761 |
if (CaptionedControlInterface())
|
|
1762 |
{
|
|
1763 |
return FocusBackgroundNow();
|
|
1764 |
}
|
|
1765 |
else
|
|
1766 |
{
|
|
1767 |
return NULL;
|
|
1768 |
}
|
|
1769 |
}
|
|
1770 |
|
|
1771 |
EXPORT_C TRgb ASwtControlBase::GetBackground() const
|
|
1772 |
{
|
|
1773 |
return iDisplay.CoeEnv()->ControlColor(EColorControlBackground, CoeControl());
|
|
1774 |
}
|
|
1775 |
|
|
1776 |
EXPORT_C TRgb ASwtControlBase::GetForeground() const
|
|
1777 |
{
|
|
1778 |
return iDisplay.CoeEnv()->ControlColor(EColorControlText, CoeControl());
|
|
1779 |
}
|
|
1780 |
|
|
1781 |
EXPORT_C void ASwtControlBase::SetBackgroundL(const MSwtColor* aColor)
|
|
1782 |
{
|
|
1783 |
DoSetBackgroundL(aColor);
|
|
1784 |
Redraw();
|
|
1785 |
}
|
|
1786 |
|
|
1787 |
void ASwtControlBase::DoSetBackgroundL(const MSwtColor* aColor)
|
|
1788 |
{
|
|
1789 |
SetColorL(EColorControlBackground, aColor);
|
|
1790 |
if (aColor)
|
|
1791 |
{
|
|
1792 |
iBackgrdDefaultUsed = EFalse;
|
|
1793 |
// Not using FocusBackgroundNow() intentionally
|
|
1794 |
if (iFocusFrame)
|
|
1795 |
{
|
|
1796 |
iFocusFrame->SetParentContext(NULL);
|
|
1797 |
}
|
|
1798 |
}
|
|
1799 |
else
|
|
1800 |
{
|
|
1801 |
iBackgrdDefaultUsed = ETrue;
|
|
1802 |
// Not using FocusBackgroundNow() intentionally
|
|
1803 |
if (iFocusFrame)
|
|
1804 |
{
|
|
1805 |
iFocusFrame->SetParentContext(SwtMopSupplyCtrlContext(EFalse));
|
|
1806 |
}
|
|
1807 |
}
|
|
1808 |
}
|
|
1809 |
|
|
1810 |
EXPORT_C void ASwtControlBase::SetForegroundL(const MSwtColor* aColor)
|
|
1811 |
{
|
|
1812 |
DoSetForegroundL(aColor);
|
|
1813 |
Redraw();
|
|
1814 |
}
|
|
1815 |
|
|
1816 |
void ASwtControlBase::DoSetForegroundL(const MSwtColor* aColor)
|
|
1817 |
{
|
|
1818 |
SetColorL(EColorControlText, aColor);
|
|
1819 |
}
|
|
1820 |
|
|
1821 |
EXPORT_C const MSwtFont* ASwtControlBase::GetFont() const
|
|
1822 |
{
|
|
1823 |
return (iFont!=NULL) ? iFont : &DefaultFont();
|
|
1824 |
}
|
|
1825 |
|
|
1826 |
EXPORT_C TRect ASwtControlBase::GetBounds() const
|
|
1827 |
{
|
|
1828 |
return TRect(GetLocation(), CoeControl().Size());
|
|
1829 |
}
|
|
1830 |
|
|
1831 |
EXPORT_C TPoint ASwtControlBase::GetLocation() const
|
|
1832 |
{
|
|
1833 |
TRect parentClientRect(iParent->Scrollable()->Control()->ClientRect()); //lint !e613
|
|
1834 |
return CoeControl().Position() - parentClientRect.iTl;
|
|
1835 |
}
|
|
1836 |
|
|
1837 |
EXPORT_C const MSwtMenu* ASwtControlBase::GetPopupMenu() const
|
|
1838 |
{
|
|
1839 |
return iPopupMenu;
|
|
1840 |
}
|
|
1841 |
|
|
1842 |
EXPORT_C const MSwtMenu* ASwtControlBase::GetControlMenu() const
|
|
1843 |
{
|
|
1844 |
return NULL;
|
|
1845 |
}
|
|
1846 |
|
|
1847 |
EXPORT_C MSwtComposite* ASwtControlBase::GetParent() const
|
|
1848 |
{
|
|
1849 |
return iParent;
|
|
1850 |
}
|
|
1851 |
|
|
1852 |
EXPORT_C TBool ASwtControlBase::IsDescentOf(const MSwtControl& aControl) const
|
|
1853 |
{
|
|
1854 |
MSwtComposite* aParent = aControl.CompositeInterface();
|
|
1855 |
if (!aParent)
|
|
1856 |
{
|
|
1857 |
return EFalse;
|
|
1858 |
}
|
|
1859 |
|
|
1860 |
MSwtComposite* parent = GetParent();
|
|
1861 |
while (parent)
|
|
1862 |
{
|
|
1863 |
if (parent == aParent)
|
|
1864 |
{
|
|
1865 |
return ETrue;
|
|
1866 |
}
|
|
1867 |
parent = parent->Control()->GetParent();
|
|
1868 |
}
|
|
1869 |
|
|
1870 |
return EFalse;
|
|
1871 |
}
|
|
1872 |
|
|
1873 |
EXPORT_C MSwtShell& ASwtControlBase::GetTopShell() const
|
|
1874 |
{
|
|
1875 |
const MSwtControl* ctrl = this;
|
|
1876 |
while (ctrl && ctrl->GetParent())
|
|
1877 |
{
|
|
1878 |
ctrl = ctrl->GetParent()->Control();
|
|
1879 |
}
|
|
1880 |
MSwtShell* shell = const_cast<MSwtShell*>(ctrl->ShellInterface());
|
|
1881 |
ASSERT(shell);
|
|
1882 |
return *shell;
|
|
1883 |
}
|
|
1884 |
|
|
1885 |
EXPORT_C MSwtCaptionedControl* ASwtControlBase::GetNearestCaptionedControl(TBool aIncludeSelf /*= ETrue*/) const
|
|
1886 |
{
|
|
1887 |
MSwtCaptionedControl* res = NULL;
|
|
1888 |
const MSwtControl* ctrl = aIncludeSelf ? this : (GetParent() ? GetParent()->Control() : NULL);
|
|
1889 |
while (ctrl)
|
|
1890 |
{
|
|
1891 |
if (ctrl->CaptionedControlInterface())
|
|
1892 |
{
|
|
1893 |
return ctrl->CaptionedControlInterface();
|
|
1894 |
}
|
|
1895 |
ctrl = ctrl->GetParent() ? ctrl->GetParent()->Control() : NULL;
|
|
1896 |
}
|
|
1897 |
return res;
|
|
1898 |
}
|
|
1899 |
|
|
1900 |
EXPORT_C TSize ASwtControlBase::GetWidgetSize() const
|
|
1901 |
{
|
|
1902 |
return CoeControl().Size();
|
|
1903 |
}
|
|
1904 |
|
|
1905 |
EXPORT_C void ASwtControlBase::SetWidgetSize(const TSize& aSize)
|
|
1906 |
{
|
|
1907 |
ASSERT(!IsShell());
|
|
1908 |
|
|
1909 |
CCoeControl& coeCtrl = CoeControl();
|
|
1910 |
TRect oldRect(coeCtrl.Rect());
|
|
1911 |
TRect newRect(coeCtrl.Position(), aSize);
|
|
1912 |
|
|
1913 |
if (newRect == oldRect)
|
|
1914 |
{
|
|
1915 |
return;
|
|
1916 |
}
|
|
1917 |
|
|
1918 |
MSwtShell& shell = GetShell();
|
|
1919 |
if (shell.UrgentPaintControl() == this)
|
|
1920 |
{
|
|
1921 |
shell.SetUrgentPaintControl(NULL);
|
|
1922 |
}
|
|
1923 |
|
|
1924 |
TBool urgent = EFalse;
|
|
1925 |
if (iParent->ScrolledCompositeContent() == this
|
|
1926 |
&& shell.UrgentPaintControl() == iParent->Control())
|
|
1927 |
{
|
|
1928 |
if (iParent->ScrolledCompositePysicsAction() != KSwtPhysicsNoAction)
|
|
1929 |
{
|
|
1930 |
// Cannot change the bounds of the content while flicking or panning
|
|
1931 |
return;
|
|
1932 |
}
|
|
1933 |
urgent = ETrue;
|
|
1934 |
}
|
|
1935 |
|
|
1936 |
if (!urgent)
|
|
1937 |
{
|
|
1938 |
// Do not invalidate outside parent's visible client area.
|
|
1939 |
if (iParent)
|
|
1940 |
{
|
|
1941 |
TRect parentVisibleRect(static_cast<ASwtControlBase*>(
|
|
1942 |
iParent->Control())->VisibleRect());
|
|
1943 |
oldRect.Intersection(parentVisibleRect);
|
|
1944 |
newRect.Intersection(parentVisibleRect);
|
|
1945 |
}
|
|
1946 |
|
|
1947 |
// Invalidate uncovered regions.
|
|
1948 |
RRegion invalidRegion;
|
|
1949 |
invalidRegion.Clear();
|
|
1950 |
invalidRegion.AddRect(oldRect);
|
|
1951 |
invalidRegion.SubRect(newRect);
|
|
1952 |
if (!invalidRegion.IsEmpty())
|
|
1953 |
{
|
|
1954 |
ASSERT(invalidRegion.Count() <= 2);
|
|
1955 |
for (TInt i = 0; i < invalidRegion.Count(); i++)
|
|
1956 |
{
|
|
1957 |
Invalidate(invalidRegion[i]);
|
|
1958 |
}
|
|
1959 |
}
|
|
1960 |
invalidRegion.Close();
|
|
1961 |
}
|
|
1962 |
|
|
1963 |
// Set and redraw new rect
|
|
1964 |
coeCtrl.SetSize(aSize);
|
|
1965 |
if (!(iStyle & KSwtStyleNoRedrawResize))
|
|
1966 |
{
|
|
1967 |
if (urgent)
|
|
1968 |
{
|
|
1969 |
iParent->Control()->PaintUrgently(iParent->Control()->CoeControl().Rect());
|
|
1970 |
}
|
|
1971 |
else
|
|
1972 |
{
|
|
1973 |
Redraw();
|
|
1974 |
}
|
|
1975 |
}
|
|
1976 |
}
|
|
1977 |
|
|
1978 |
EXPORT_C TBool ASwtControlBase::IsFocusControl()
|
|
1979 |
{
|
|
1980 |
ASSERT(!IsShell());
|
|
1981 |
return CoeControl().IsFocused();
|
|
1982 |
}
|
|
1983 |
|
|
1984 |
EXPORT_C void ASwtControlBase::MoveAbove(const MSwtControl* aControl)
|
|
1985 |
{
|
|
1986 |
ASSERT(!IsShell());
|
|
1987 |
ASSERT(iParent!=NULL);
|
|
1988 |
iParent->MoveChildAbove(*this, aControl);
|
|
1989 |
}
|
|
1990 |
|
|
1991 |
EXPORT_C void ASwtControlBase::MoveBelow(const MSwtControl* aControl)
|
|
1992 |
{
|
|
1993 |
ASSERT(!IsShell());
|
|
1994 |
ASSERT(iParent!=NULL);
|
|
1995 |
iParent->MoveChildBelow(*this, aControl);
|
|
1996 |
}
|
|
1997 |
|
|
1998 |
EXPORT_C void ASwtControlBase::Redraw()
|
|
1999 |
{
|
|
2000 |
RedrawRegion(TRect(TPoint(0, 0), CoeControl().Size()));
|
|
2001 |
}
|
|
2002 |
|
|
2003 |
// aRect is in Control coords / relative to itself!
|
|
2004 |
EXPORT_C void ASwtControlBase::RedrawRegion(const TRect& aRect)
|
|
2005 |
{
|
|
2006 |
if (!GetVisibleRecursively() || (iCtrlFlags & MSwtControl::EFlagDoNotDraw))
|
|
2007 |
{
|
|
2008 |
return;
|
|
2009 |
}
|
|
2010 |
|
|
2011 |
CCoeControl& coeCtrl = CoeControl();
|
|
2012 |
TRect rectInWindow(aRect);
|
|
2013 |
if (!coeCtrl.OwnsWindow())
|
|
2014 |
{
|
|
2015 |
rectInWindow.Move(coeCtrl.Position()); // In window coords
|
|
2016 |
}
|
|
2017 |
TRect dirtyRect(VisibleRect(ETrue)); // In window coords
|
|
2018 |
dirtyRect.Intersection(rectInWindow); // In window coords
|
|
2019 |
if (dirtyRect.IsEmpty())
|
|
2020 |
{
|
|
2021 |
return;
|
|
2022 |
}
|
|
2023 |
|
|
2024 |
MSwtShell& shell = GetShell();
|
|
2025 |
MSwtControl* urgentPaintControl = shell.UrgentPaintControl();
|
|
2026 |
if (urgentPaintControl)
|
|
2027 |
{
|
|
2028 |
// Redraw requests outside urgently painted controls are ignored.
|
|
2029 |
if (urgentPaintControl == this || IsDescentOf(*urgentPaintControl))
|
|
2030 |
{
|
|
2031 |
PaintUrgently(dirtyRect);
|
|
2032 |
}
|
|
2033 |
}
|
|
2034 |
else
|
|
2035 |
{
|
|
2036 |
if (shell.AsyncPainting())
|
|
2037 |
{
|
|
2038 |
TRect ctrlRect(coeCtrl.Rect());
|
|
2039 |
MSwtControl* controlShell = shell.Control();
|
|
2040 |
TSwtPeer peerOfTheTargetControl(controlShell->JavaPeer());
|
|
2041 |
if (RectContainsRect(ctrlRect, dirtyRect))
|
|
2042 |
{
|
|
2043 |
peerOfTheTargetControl = JavaPeer();
|
|
2044 |
}
|
|
2045 |
|
|
2046 |
dirtyRect.Move(controlShell->CoeControl().PositionRelativeToScreen()); // Screen coords
|
|
2047 |
TBool mergeable = !(iStyle & KSwtStyleNoMergePaints);
|
|
2048 |
TRAP_IGNORE(iDisplay.PostPaintEventL(JavaPeer(), peerOfTheTargetControl, dirtyRect, mergeable));
|
|
2049 |
}
|
|
2050 |
else
|
|
2051 |
{
|
|
2052 |
PaintUrgently(dirtyRect);
|
|
2053 |
}
|
|
2054 |
}
|
|
2055 |
}
|
|
2056 |
|
|
2057 |
EXPORT_C void ASwtControlBase::SetRedraw(TBool aRedraw)
|
|
2058 |
{
|
|
2059 |
if (aRedraw)
|
|
2060 |
{
|
|
2061 |
if (iStackedSetRedrawFalseNb > 0)
|
|
2062 |
{
|
|
2063 |
--iStackedSetRedrawFalseNb;
|
|
2064 |
}
|
|
2065 |
}
|
|
2066 |
else
|
|
2067 |
{
|
|
2068 |
++iStackedSetRedrawFalseNb;
|
|
2069 |
}
|
|
2070 |
|
|
2071 |
UpdateDoNotDrawFlag();
|
|
2072 |
|
|
2073 |
if (!(iCtrlFlags & MSwtControl::EFlagDoNotDraw))
|
|
2074 |
{
|
|
2075 |
|
|
2076 |
//For Shell the drawing are doing in Java Side.
|
|
2077 |
if (!IsShell())
|
|
2078 |
{
|
|
2079 |
// We mark this Control as needed to be redraw.
|
|
2080 |
// Redraw() is prefered instead DrawDeferred() because it directly post a
|
|
2081 |
// PaintEvent on this Control whereas DrawDeferred
|
|
2082 |
// notify the Windows server that the windows container need to be redraw.
|
|
2083 |
Redraw();
|
|
2084 |
}
|
|
2085 |
}
|
|
2086 |
}
|
|
2087 |
|
|
2088 |
TBool ASwtControlBase::ParentHasDoNotDrawFlag()
|
|
2089 |
{
|
|
2090 |
MSwtControl* parent = NULL;
|
|
2091 |
|
|
2092 |
if (iParent!=NULL)
|
|
2093 |
parent = iParent->Control();
|
|
2094 |
|
|
2095 |
while (parent != NULL)
|
|
2096 |
{
|
|
2097 |
if (parent->Flags() & MSwtControl::EFlagDoNotDraw)
|
|
2098 |
{
|
|
2099 |
return ETrue;
|
|
2100 |
}
|
|
2101 |
else if (!parent->GetParent() || parent->IsShell())
|
|
2102 |
{
|
|
2103 |
return EFalse;
|
|
2104 |
}
|
|
2105 |
else
|
|
2106 |
{
|
|
2107 |
parent = parent->GetParent()->Control();
|
|
2108 |
}
|
|
2109 |
}
|
|
2110 |
|
|
2111 |
return EFalse;
|
|
2112 |
}
|
|
2113 |
|
|
2114 |
EXPORT_C TBool ASwtControlBase::HasDoNotDrawFlag() const
|
|
2115 |
{
|
|
2116 |
return (iCtrlFlags & MSwtControl::EFlagDoNotDraw);
|
|
2117 |
}
|
|
2118 |
|
|
2119 |
EXPORT_C void ASwtControlBase::UpdateDoNotDrawFlag()
|
|
2120 |
{
|
|
2121 |
if (iStackedSetRedrawFalseNb == 0 && !ParentHasDoNotDrawFlag())
|
|
2122 |
{
|
|
2123 |
iCtrlFlags &= ~MSwtControl::EFlagDoNotDraw;
|
|
2124 |
}
|
|
2125 |
else
|
|
2126 |
{
|
|
2127 |
iCtrlFlags |= MSwtControl::EFlagDoNotDraw;
|
|
2128 |
}
|
|
2129 |
}
|
|
2130 |
|
|
2131 |
EXPORT_C void ASwtControlBase::SetFontL(const MSwtFont* aFont)
|
|
2132 |
{
|
|
2133 |
DoSetFontL(aFont);
|
|
2134 |
Redraw();
|
|
2135 |
}
|
|
2136 |
|
|
2137 |
void ASwtControlBase::DoSetFontL(const MSwtFont* aFont)
|
|
2138 |
{
|
|
2139 |
if (iFont != NULL)
|
|
2140 |
iFont->RemoveRef();
|
|
2141 |
iFont = aFont;
|
|
2142 |
if (iFont != NULL)
|
|
2143 |
iFont->AddRef();
|
|
2144 |
}
|
|
2145 |
|
|
2146 |
EXPORT_C void ASwtControlBase::SetVisible(TBool aVisible)
|
|
2147 |
{
|
|
2148 |
CCoeControl& coeCtrl = CoeControl();
|
|
2149 |
MSwtShell& shell = GetShell();
|
|
2150 |
TBool redrawFocusedCtrl = (&shell == UiUtils().GetActiveShell())
|
|
2151 |
&& (shell.FocusControl() != this);
|
|
2152 |
TInt oldCount = 0;
|
|
2153 |
TInt newCount = 0;
|
|
2154 |
|
|
2155 |
if (redrawFocusedCtrl)
|
|
2156 |
{
|
|
2157 |
oldCount = shell.Composite()->CountFocusableChildren(2);
|
|
2158 |
}
|
|
2159 |
|
|
2160 |
if (aVisible)
|
|
2161 |
{
|
|
2162 |
iCtrlFlags &= ~MSwtControl::EFlagInvisible;
|
|
2163 |
}
|
|
2164 |
else
|
|
2165 |
{
|
|
2166 |
if (shell.UrgentPaintControl() == this)
|
|
2167 |
{
|
|
2168 |
shell.SetUrgentPaintControl(NULL);
|
|
2169 |
}
|
|
2170 |
}
|
|
2171 |
|
|
2172 |
coeCtrl.MakeVisible(aVisible);
|
|
2173 |
|
|
2174 |
if (!aVisible)
|
|
2175 |
iCtrlFlags |= MSwtControl::EFlagInvisible;
|
|
2176 |
|
|
2177 |
if (aVisible)
|
|
2178 |
{
|
|
2179 |
Redraw();
|
|
2180 |
}
|
|
2181 |
else
|
|
2182 |
{
|
|
2183 |
Invalidate(coeCtrl.Rect());
|
|
2184 |
}
|
|
2185 |
|
|
2186 |
if (!IsShell())
|
|
2187 |
{
|
|
2188 |
FocusabilityChanged();
|
|
2189 |
}
|
|
2190 |
|
|
2191 |
if (redrawFocusedCtrl)
|
|
2192 |
{
|
|
2193 |
newCount = shell.Composite()->CountFocusableChildren(2);
|
|
2194 |
}
|
|
2195 |
|
|
2196 |
if (redrawFocusedCtrl
|
|
2197 |
&& ((oldCount >= 2 && newCount == 1)
|
|
2198 |
|| (oldCount == 1 && newCount >= 2)))
|
|
2199 |
{
|
|
2200 |
MSwtControl* focusedCtrl = GetShell().FocusControl();
|
|
2201 |
if (focusedCtrl)
|
|
2202 |
{
|
|
2203 |
static_cast<ASwtControlBase*>(focusedCtrl)->RedrawFocusBackground();
|
|
2204 |
}
|
|
2205 |
}
|
|
2206 |
}
|
|
2207 |
|
|
2208 |
EXPORT_C void ASwtControlBase::SetLocation(const TPoint& aPoint)
|
|
2209 |
{
|
|
2210 |
ASSERT(!IsShell());
|
|
2211 |
|
|
2212 |
TPoint oldLocation(GetLocation());
|
|
2213 |
TPoint newLocation = ComputeLocationToSet(aPoint);
|
|
2214 |
CCoeControl& coeCtrl = CoeControl();
|
|
2215 |
TRect oldRect(coeCtrl.Rect());
|
|
2216 |
TRect newRect(newLocation, coeCtrl.Size());
|
|
2217 |
|
|
2218 |
if (oldLocation == newLocation)
|
|
2219 |
{
|
|
2220 |
return;
|
|
2221 |
}
|
|
2222 |
|
|
2223 |
MSwtShell& shell = GetShell();
|
|
2224 |
if (shell.UrgentPaintControl() == this)
|
|
2225 |
{
|
|
2226 |
shell.SetUrgentPaintControl(NULL);
|
|
2227 |
}
|
|
2228 |
|
|
2229 |
TBool urgent = EFalse;
|
|
2230 |
if (iParent->ScrolledCompositeContent() == this
|
|
2231 |
&& shell.UrgentPaintControl() == iParent->Control())
|
|
2232 |
{
|
|
2233 |
if (iParent->ScrolledCompositePysicsAction() != KSwtPhysicsNoAction)
|
|
2234 |
{
|
|
2235 |
// Cannot change the bounds of the content while flicking or panning
|
|
2236 |
return;
|
|
2237 |
}
|
|
2238 |
urgent = ETrue;
|
|
2239 |
}
|
|
2240 |
|
|
2241 |
if (!urgent)
|
|
2242 |
{
|
|
2243 |
// Do not invalidate outside parent's visible client area.
|
|
2244 |
if (iParent)
|
|
2245 |
{
|
|
2246 |
TRect parentVisibleRect(static_cast<ASwtControlBase*>(
|
|
2247 |
iParent->Control())->VisibleRect());
|
|
2248 |
oldRect.Intersection(parentVisibleRect);
|
|
2249 |
newRect.Intersection(parentVisibleRect);
|
|
2250 |
}
|
|
2251 |
|
|
2252 |
// Invalidate uncovered regions.
|
|
2253 |
if (newRect.Intersects(oldRect))
|
|
2254 |
{
|
|
2255 |
RRegion invalidRegion;
|
|
2256 |
invalidRegion.Clear();
|
|
2257 |
invalidRegion.AddRect(oldRect);
|
|
2258 |
invalidRegion.SubRect(newRect);
|
|
2259 |
ASSERT(invalidRegion.Count() <= 2);
|
|
2260 |
for (TInt i = 0; i < invalidRegion.Count(); i++)
|
|
2261 |
{
|
|
2262 |
Invalidate(invalidRegion[i]);
|
|
2263 |
}
|
|
2264 |
invalidRegion.Close();
|
|
2265 |
}
|
|
2266 |
else
|
|
2267 |
{
|
|
2268 |
Invalidate(oldRect);
|
|
2269 |
}
|
|
2270 |
}
|
|
2271 |
|
|
2272 |
// Set and redraw new rect
|
|
2273 |
coeCtrl.SetPosition(newLocation);
|
|
2274 |
if (!(iStyle & KSwtStyleNoRedrawResize))
|
|
2275 |
{
|
|
2276 |
if (urgent)
|
|
2277 |
{
|
|
2278 |
iParent->Control()->PaintUrgently(iParent->Control()->CoeControl().Rect());
|
|
2279 |
}
|
|
2280 |
else
|
|
2281 |
{
|
|
2282 |
Redraw();
|
|
2283 |
}
|
|
2284 |
}
|
|
2285 |
}
|
|
2286 |
|
|
2287 |
EXPORT_C void ASwtControlBase::SetEnabled(TBool aEnabled)
|
|
2288 |
{
|
|
2289 |
CCoeControl& coeCtrl = CoeControl();
|
|
2290 |
MSwtShell& shell = GetShell();
|
|
2291 |
TBool redrawFocusedCtrl = (&shell == UiUtils().GetActiveShell())
|
|
2292 |
&& (shell.FocusControl() != this);
|
|
2293 |
TInt oldCount = 0;
|
|
2294 |
TInt newCount = 0;
|
|
2295 |
|
|
2296 |
if (redrawFocusedCtrl)
|
|
2297 |
{
|
|
2298 |
oldCount = shell.Composite()->CountFocusableChildren(2);
|
|
2299 |
}
|
|
2300 |
|
|
2301 |
if (aEnabled)
|
|
2302 |
{
|
|
2303 |
iCtrlFlags &= ~MSwtControl::EFlagDisabled;
|
|
2304 |
}
|
|
2305 |
|
|
2306 |
coeCtrl.SetFocusing(aEnabled);
|
|
2307 |
coeCtrl.SetDimmed(!aEnabled);
|
|
2308 |
|
|
2309 |
if (!aEnabled)
|
|
2310 |
iCtrlFlags |= MSwtControl::EFlagDisabled;
|
|
2311 |
|
|
2312 |
if (!IsShell())
|
|
2313 |
{
|
|
2314 |
// If we got disabled this will find a new focused item.
|
|
2315 |
FocusabilityChanged();
|
|
2316 |
}
|
|
2317 |
|
|
2318 |
Redraw();
|
|
2319 |
|
|
2320 |
if (redrawFocusedCtrl)
|
|
2321 |
{
|
|
2322 |
newCount = shell.Composite()->CountFocusableChildren(2);
|
|
2323 |
}
|
|
2324 |
|
|
2325 |
if (redrawFocusedCtrl
|
|
2326 |
&& ((oldCount >= 2 && newCount == 1)
|
|
2327 |
|| (oldCount == 1 && newCount >= 2)))
|
|
2328 |
{
|
|
2329 |
MSwtControl* focusedCtrl = GetShell().FocusControl();
|
|
2330 |
if (focusedCtrl)
|
|
2331 |
{
|
|
2332 |
static_cast<ASwtControlBase*>(focusedCtrl)->RedrawFocusBackground();
|
|
2333 |
}
|
|
2334 |
}
|
|
2335 |
}
|
|
2336 |
|
|
2337 |
EXPORT_C void ASwtControlBase::SetBounds(const TRect& aRect)
|
|
2338 |
{
|
|
2339 |
// Must NOT call SetExtent if we want component controls to be relocated.
|
|
2340 |
ASSERT(!IsShell());
|
|
2341 |
|
|
2342 |
CCoeControl& coeCtrl = CoeControl();
|
|
2343 |
TSize oldSize(coeCtrl.Size());
|
|
2344 |
TSize newSize(aRect.Size());
|
|
2345 |
TPoint oldLocation(GetLocation());
|
|
2346 |
TPoint newLocation(ComputeLocationToSet(aRect.iTl));
|
|
2347 |
TRect oldRect(coeCtrl.Rect());
|
|
2348 |
TRect newRect(newLocation, newSize);
|
|
2349 |
|
|
2350 |
if (oldLocation == newLocation && oldSize == newSize)
|
|
2351 |
{
|
|
2352 |
return;
|
|
2353 |
}
|
|
2354 |
|
|
2355 |
MSwtShell& shell = GetShell();
|
|
2356 |
if (shell.UrgentPaintControl() == this)
|
|
2357 |
{
|
|
2358 |
shell.SetUrgentPaintControl(NULL);
|
|
2359 |
}
|
|
2360 |
|
|
2361 |
TBool urgent = EFalse;
|
|
2362 |
if (iParent->ScrolledCompositeContent() == this
|
|
2363 |
&& shell.UrgentPaintControl() == iParent->Control())
|
|
2364 |
{
|
|
2365 |
if (iParent->ScrolledCompositePysicsAction() != KSwtPhysicsNoAction)
|
|
2366 |
{
|
|
2367 |
// Cannot change the bounds of the content while flicking or panning
|
|
2368 |
return;
|
|
2369 |
}
|
|
2370 |
urgent = ETrue;
|
|
2371 |
}
|
|
2372 |
|
|
2373 |
if (!urgent)
|
|
2374 |
{
|
|
2375 |
// Do not invalidate outside parent's visible client area.
|
|
2376 |
if (iParent)
|
|
2377 |
{
|
|
2378 |
TRect parentVisibleRect(static_cast<ASwtControlBase*>(
|
|
2379 |
iParent->Control())->VisibleRect());
|
|
2380 |
oldRect.Intersection(parentVisibleRect);
|
|
2381 |
newRect.Intersection(parentVisibleRect);
|
|
2382 |
}
|
|
2383 |
|
|
2384 |
// Invalidate uncovered regions.
|
|
2385 |
if (newRect.Intersects(oldRect))
|
|
2386 |
{
|
|
2387 |
RRegion invalidRegion;
|
|
2388 |
invalidRegion.Clear();
|
|
2389 |
invalidRegion.AddRect(oldRect);
|
|
2390 |
invalidRegion.SubRect(newRect);
|
|
2391 |
ASSERT(invalidRegion.Count() <= 4);
|
|
2392 |
for (TInt i = 0; i < invalidRegion.Count(); i++)
|
|
2393 |
{
|
|
2394 |
Invalidate(invalidRegion[i]);
|
|
2395 |
}
|
|
2396 |
invalidRegion.Close();
|
|
2397 |
}
|
|
2398 |
else
|
|
2399 |
{
|
|
2400 |
Invalidate(oldRect);
|
|
2401 |
}
|
|
2402 |
}
|
|
2403 |
|
|
2404 |
// Set and invalidate new rect
|
|
2405 |
if (oldLocation != newLocation)
|
|
2406 |
{
|
|
2407 |
coeCtrl.SetPosition(newLocation);
|
|
2408 |
}
|
|
2409 |
if (oldSize != newSize)
|
|
2410 |
{
|
|
2411 |
coeCtrl.SetSize(newSize);
|
|
2412 |
}
|
|
2413 |
|
|
2414 |
if (!(iStyle & KSwtStyleNoRedrawResize))
|
|
2415 |
{
|
|
2416 |
if (urgent)
|
|
2417 |
{
|
|
2418 |
iParent->Control()->PaintUrgently(iParent->Control()->CoeControl().Rect());
|
|
2419 |
}
|
|
2420 |
else
|
|
2421 |
{
|
|
2422 |
Redraw();
|
|
2423 |
}
|
|
2424 |
}
|
|
2425 |
}
|
|
2426 |
|
|
2427 |
EXPORT_C void ASwtControlBase::SetPopupMenuL(const MSwtMenu* aMenu)
|
|
2428 |
{
|
|
2429 |
if (aMenu)
|
|
2430 |
{
|
|
2431 |
GetShell().InstallCba();
|
|
2432 |
}
|
|
2433 |
|
|
2434 |
const MSwtMenu* oldMenu = iPopupMenu;
|
|
2435 |
iPopupMenu = aMenu;
|
|
2436 |
|
|
2437 |
if (iPopupMenu == NULL && oldMenu != NULL)
|
|
2438 |
{
|
|
2439 |
iDisplay.MenuArranger().HandleMenuChangedL(*oldMenu, MSwtMenuArranger::ESwtMenuRemoved);
|
|
2440 |
}
|
|
2441 |
else if (iPopupMenu != NULL)
|
|
2442 |
{
|
|
2443 |
iDisplay.MenuArranger().HandleMenuChangedL(*iPopupMenu, MSwtMenuArranger::ESwtMenuAdded);
|
|
2444 |
}
|
|
2445 |
}
|
|
2446 |
|
|
2447 |
EXPORT_C void ASwtControlBase::SetCapture(TBool aCapture)
|
|
2448 |
{
|
|
2449 |
if (aCapture)
|
|
2450 |
{
|
|
2451 |
UiUtils().SetPointerCaptureControl(this);
|
|
2452 |
}
|
|
2453 |
else
|
|
2454 |
{
|
|
2455 |
if (UiUtils().PointerCaptureControl() == this)
|
|
2456 |
{
|
|
2457 |
UiUtils().SetPointerCaptureControl(NULL);
|
|
2458 |
}
|
|
2459 |
}
|
|
2460 |
}
|
|
2461 |
|
|
2462 |
EXPORT_C TInt ASwtControlBase::Style() const
|
|
2463 |
{
|
|
2464 |
return iStyle;
|
|
2465 |
}
|
|
2466 |
|
|
2467 |
EXPORT_C void ASwtControlBase::Update() const
|
|
2468 |
{
|
|
2469 |
if (iCtrlFlags & MSwtControl::EFlagDoNotDraw)
|
|
2470 |
return;
|
|
2471 |
}
|
|
2472 |
|
|
2473 |
EXPORT_C void ASwtControlBase::ComputeTabListL(RSwtControlArray& aList)
|
|
2474 |
{
|
|
2475 |
User::LeaveIfError(aList.Append(this));
|
|
2476 |
}
|
|
2477 |
|
|
2478 |
EXPORT_C TPoint ASwtControlBase::ToControl(const TPoint& aPoint) const
|
|
2479 |
{
|
|
2480 |
const TPoint clientOriginInScreen(WindowToScreen(ClientRect().iTl));
|
|
2481 |
return aPoint - clientOriginInScreen;
|
|
2482 |
}
|
|
2483 |
|
|
2484 |
EXPORT_C TPoint ASwtControlBase::ToDisplay(const TPoint& aPoint) const
|
|
2485 |
{
|
|
2486 |
const TPoint clientOriginInScreen(WindowToScreen(ClientRect().iTl));
|
|
2487 |
return aPoint + clientOriginInScreen;
|
|
2488 |
}
|
|
2489 |
|
|
2490 |
EXPORT_C TBool ASwtControlBase::CbaButtonIsUsed(TInt /*aCbaButtonIndex*/) const
|
|
2491 |
{
|
|
2492 |
return EFalse;
|
|
2493 |
}
|
|
2494 |
|
|
2495 |
EXPORT_C TBool ASwtControlBase::IsKeyUsed(TUint /*aKeyCode*/) const
|
|
2496 |
{
|
|
2497 |
// By default, we assume that the control doesn't use key
|
|
2498 |
return EFalse;
|
|
2499 |
}
|
|
2500 |
|
|
2501 |
EXPORT_C TBool ASwtControlBase::MSKSelCmdEnabled() const
|
|
2502 |
{
|
|
2503 |
return EFalse;
|
|
2504 |
}
|
|
2505 |
|
|
2506 |
EXPORT_C TBool ASwtControlBase::ForceTraverseEvent(TSwtTraversal aDetail, TBool aDoIt)
|
|
2507 |
{
|
|
2508 |
TRAPD(ignore, iDisplay.ForceTraverseEventL(*this, aDetail, aDoIt));
|
|
2509 |
return (ignore == KErrNone);
|
|
2510 |
}
|
|
2511 |
|
|
2512 |
EXPORT_C void ASwtControlBase::AddToControlStackL(TInt aPriority)
|
|
2513 |
{
|
|
2514 |
if (!iIsOnControlStack)
|
|
2515 |
{
|
|
2516 |
iIsOnControlStack = ETrue;
|
|
2517 |
TRAPD(error, iDisplay.CoeEnv()->EikAppUi()->AddToStackL(&CoeControl(), aPriority));
|
|
2518 |
if (error!=KErrNone)
|
|
2519 |
{
|
|
2520 |
iIsOnControlStack = EFalse;
|
|
2521 |
User::Leave(error);
|
|
2522 |
}
|
|
2523 |
if (!IsShell())
|
|
2524 |
{
|
|
2525 |
GetShell().SetControlGoingToStack(this);
|
|
2526 |
GetShell().SetControlGainingFocus(NULL);
|
|
2527 |
}
|
|
2528 |
}
|
|
2529 |
}
|
|
2530 |
EXPORT_C HBufC* ASwtControlBase::MSKLabelL() const
|
|
2531 |
{
|
|
2532 |
return KNullDesC().Alloc();
|
|
2533 |
}
|
|
2534 |
|
|
2535 |
EXPORT_C void ASwtControlBase::RemoveFromControlStack()
|
|
2536 |
{
|
|
2537 |
if (iIsOnControlStack)
|
|
2538 |
{
|
|
2539 |
iDisplay.CoeEnv()->EikAppUi()->RemoveFromStack(&CoeControl());
|
|
2540 |
iIsOnControlStack = EFalse;
|
|
2541 |
if (!IsShell())
|
|
2542 |
{
|
|
2543 |
if (
|
|
2544 |
iDisplay.MenuArranger().EikMenuBar()->IsDisplayed() ||
|
|
2545 |
iDisplay.CoeEnv()->EikAppUi()->IsDisplayingControlBetweenPriorities(
|
|
2546 |
ECoeStackPriorityMenu, ECoeStackPriorityCba))
|
|
2547 |
{
|
|
2548 |
GetShell().SetControlGainingFocus(this);
|
|
2549 |
}
|
|
2550 |
}
|
|
2551 |
}
|
|
2552 |
}
|
|
2553 |
|
|
2554 |
EXPORT_C TBool ASwtControlBase::IsOnControlStack() const
|
|
2555 |
{
|
|
2556 |
return iIsOnControlStack;
|
|
2557 |
}
|
|
2558 |
|
|
2559 |
#ifdef RD_SCALABLE_UI_V2
|
|
2560 |
EXPORT_C void ASwtControlBase::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
2561 |
{
|
|
2562 |
CoeControl().HandlePointerEventL(aPointerEvent);
|
|
2563 |
PostMouseEventL(aPointerEvent);
|
|
2564 |
}
|
|
2565 |
#else
|
|
2566 |
EXPORT_C void ASwtControlBase::HandlePointerEventL(const TPointerEvent& /*aPointerEvent*/)
|
|
2567 |
{
|
|
2568 |
ASSERT(EFalse);
|
|
2569 |
}
|
|
2570 |
#endif
|
|
2571 |
|
|
2572 |
#ifdef RD_SCALABLE_UI_V2
|
|
2573 |
EXPORT_C TBool ASwtControlBase::IsLongTapAnimationCandidate(const TPointerEvent& aPointerEvent) const
|
|
2574 |
{
|
|
2575 |
return (ClientRect().Contains(aPointerEvent.iPosition)
|
|
2576 |
&& iDisplay.CommandArranger()->ControlHasStylusPopupMenu(*this));
|
|
2577 |
}
|
|
2578 |
#else
|
|
2579 |
EXPORT_C TBool ASwtControlBase::IsLongTapAnimationCandidate(const TPointerEvent& /*aPointerEvent*/) const
|
|
2580 |
{
|
|
2581 |
return EFalse;
|
|
2582 |
}
|
|
2583 |
#endif
|
|
2584 |
|
|
2585 |
TBool ASwtControlBase::IsFocusedOrChildIsFocused() const
|
|
2586 |
{
|
|
2587 |
return (GetShell().FocusControl() == this) || ChildIsFocused();
|
|
2588 |
}
|
|
2589 |
|
|
2590 |
TBool ASwtControlBase::ChildIsFocused() const
|
|
2591 |
{
|
|
2592 |
MSwtControl* focusedControl = GetShell().FocusControl();
|
|
2593 |
return focusedControl && focusedControl->IsDescentOf(*this);
|
|
2594 |
}
|
|
2595 |
|
|
2596 |
EXPORT_C void ASwtControlBase::DoControlSpecificFeedback(
|
|
2597 |
const TBool& /*aFirstTap*/, const TBool& /*aTappedToChildRect*/,
|
|
2598 |
const TPointerEvent& /*aPointerEvent*/) const
|
|
2599 |
{
|
|
2600 |
//Do nothing here. Each child class will implement
|
|
2601 |
//this function according to its needs.
|
|
2602 |
//Note that this function is not called by platform.
|
|
2603 |
}
|