|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CHuiControl provides a base class for a generic logical |
|
15 * control element in the HUITK UI. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "uiacceltk/HuiControl.h" // Class definition |
|
22 #include "uiacceltk/HuiControlGroup.h" |
|
23 #include "uiacceltk/huieventhandler.h" |
|
24 #include "uiacceltk/HuiVisual.h" |
|
25 #include "uiacceltk/HuiDisplay.h" |
|
26 #include "HuiRosterImpl.h" |
|
27 #include "uiacceltk/HuiEnv.h" |
|
28 #include "HuiVisualFactory.h" |
|
29 #include "uiacceltk/HuiUtil.h" |
|
30 #include "uiacceltk/HuiStatic.h" |
|
31 #include "uiacceltk/HuiPanic.h" |
|
32 #include "uiacceltk/HuiProbe.h" |
|
33 |
|
34 |
|
35 EXPORT_C CHuiControl::CHuiControl(CHuiEnv& aEnv) |
|
36 : iEnv(aEnv), iFocusing(EFalse) |
|
37 { |
|
38 HUI_PROBE_ASSOCIATE_WITH_CURRENT_SESSION |
|
39 HUI_PROBE_REPORT_CONSTRUCTED |
|
40 |
|
41 // Generate an automatical ID for all controls. |
|
42 iId = CHuiStatic::GenerateId(); |
|
43 } |
|
44 |
|
45 // virtual second phase construtor |
|
46 EXPORT_C void CHuiControl::BaseConstructL() |
|
47 { |
|
48 } |
|
49 |
|
50 |
|
51 EXPORT_C CHuiControl::~CHuiControl() |
|
52 { |
|
53 // Cancel scheduled commands for this control. |
|
54 Env().CancelCommands(this); |
|
55 |
|
56 iOwnerGroup = NULL; |
|
57 iBoundDisplay = NULL; |
|
58 |
|
59 if(iHost) |
|
60 { |
|
61 iHost->RemoveConnection(this); |
|
62 iHost = NULL; |
|
63 } |
|
64 |
|
65 for(TInt i = iConnections.Count() - 1; i >= 0; --i) |
|
66 { |
|
67 RemoveConnection(iConnections[i].iControl); |
|
68 } |
|
69 iConnections.Reset(); |
|
70 |
|
71 // The visuals are owned by the control. |
|
72 iVisuals.ResetAndDestroy(); |
|
73 |
|
74 HUI_PROBE_REPORT_DESTRUCTED |
|
75 |
|
76 } |
|
77 |
|
78 |
|
79 EXPORT_C CHuiEnv& CHuiControl::Env() const |
|
80 { |
|
81 return iEnv; |
|
82 } |
|
83 |
|
84 |
|
85 EXPORT_C CHuiControlGroup* CHuiControl::ControlGroup() const |
|
86 { |
|
87 return iOwnerGroup; |
|
88 } |
|
89 |
|
90 |
|
91 void CHuiControl::SetControlGroup(CHuiControlGroup& aOwnerGroup) |
|
92 { |
|
93 iOwnerGroup = &aOwnerGroup; |
|
94 } |
|
95 |
|
96 |
|
97 EXPORT_C CHuiTextureManager& CHuiControl::TextureManager() const |
|
98 { |
|
99 return Env().TextureManager(); |
|
100 } |
|
101 |
|
102 |
|
103 EXPORT_C CHuiDisplay* CHuiControl::Display() const |
|
104 { |
|
105 return iBoundDisplay; |
|
106 } |
|
107 |
|
108 |
|
109 EXPORT_C void CHuiControl::BindDisplay(CHuiDisplay& aDisplay) |
|
110 { |
|
111 iBoundDisplay = &aDisplay; |
|
112 } |
|
113 |
|
114 |
|
115 EXPORT_C void CHuiControl::SetId(TInt aId) |
|
116 { |
|
117 iId = aId; |
|
118 } |
|
119 |
|
120 |
|
121 EXPORT_C TInt CHuiControl::Id() const |
|
122 { |
|
123 return iId; |
|
124 } |
|
125 |
|
126 |
|
127 EXPORT_C void CHuiControl::AppendL(CHuiVisual* aVisual) |
|
128 { |
|
129 User::LeaveIfError(iVisuals.Append(aVisual)); |
|
130 aVisual->SetOwner(*this); |
|
131 TRAPD(err, VisualAddedL(aVisual)); |
|
132 if(err != KErrNone) |
|
133 { |
|
134 // Can't leave the visual in the array of our owned visuals. |
|
135 iVisuals.Remove(iVisuals.Find(aVisual)); |
|
136 } |
|
137 } |
|
138 |
|
139 |
|
140 EXPORT_C void CHuiControl::AppendL(CHuiVisual* aVisual, CHuiLayout* aParentLayout) |
|
141 { |
|
142 TInt err = KErrNone; |
|
143 |
|
144 User::LeaveIfError(iVisuals.Append(aVisual)); |
|
145 |
|
146 // Append to the parent layout before notification. |
|
147 if(aParentLayout) |
|
148 { |
|
149 TRAP(err, aParentLayout->AppendL(aVisual)); |
|
150 } |
|
151 |
|
152 TRAP(err, VisualAddedL(aVisual)); |
|
153 if(err != KErrNone) |
|
154 { |
|
155 // Can't leave the visual in the array of our owned visuals. |
|
156 iVisuals.Remove(iVisuals.Find(aVisual)); |
|
157 } |
|
158 } |
|
159 |
|
160 |
|
161 EXPORT_C void CHuiControl::Remove(CHuiVisual* aVisual) |
|
162 { |
|
163 TInt index = iVisuals.Find(aVisual); |
|
164 if(index != KErrNotFound) |
|
165 { |
|
166 VisualRemoved(aVisual); |
|
167 iVisuals.Remove(index); |
|
168 } |
|
169 } |
|
170 |
|
171 |
|
172 EXPORT_C CHuiVisual* CHuiControl::AppendVisualL(THuiVisualType aVisualType, |
|
173 CHuiLayout* aParentLayout) |
|
174 { |
|
175 CHuiVisual* visual = Env().VisualFactory().NewVisualLC(aVisualType, *this); |
|
176 AppendL(visual, aParentLayout); |
|
177 // The visual is now owned by this control. |
|
178 CleanupStack::Pop(visual); |
|
179 return visual; |
|
180 } |
|
181 |
|
182 |
|
183 EXPORT_C CHuiLayout* CHuiControl::AppendLayoutL(THuiLayoutType aLayoutType, |
|
184 CHuiLayout* aParentLayout) |
|
185 { |
|
186 CHuiLayout* layout = Env().VisualFactory().NewLayoutLC(aLayoutType, *this); |
|
187 AppendL(layout, aParentLayout); |
|
188 // The visual is now owned by this control. |
|
189 CleanupStack::Pop(layout); |
|
190 return layout; |
|
191 } |
|
192 |
|
193 |
|
194 EXPORT_C CHuiVisual& CHuiControl::Visual(TInt aIndex) const |
|
195 { |
|
196 return *iVisuals[aIndex]; |
|
197 } |
|
198 |
|
199 |
|
200 EXPORT_C TInt CHuiControl::VisualCount() const |
|
201 { |
|
202 return iVisuals.Count(); |
|
203 } |
|
204 |
|
205 |
|
206 EXPORT_C CHuiVisual* CHuiControl::FindTag(const TDesC8& aTag) const |
|
207 { |
|
208 TInt i = 0; |
|
209 |
|
210 for(i = 0; i < iVisuals.Count(); ++i) |
|
211 { |
|
212 if(HuiUtil::TagMatches(iVisuals[i]->Tag(), aTag)) |
|
213 { |
|
214 return iVisuals[i]; |
|
215 } |
|
216 } |
|
217 |
|
218 return NULL; |
|
219 } |
|
220 |
|
221 |
|
222 EXPORT_C CHuiControl* CHuiControl::Host() const |
|
223 { |
|
224 return iHost; |
|
225 } |
|
226 |
|
227 |
|
228 EXPORT_C void CHuiControl::SetHost(CHuiControl* aHost) |
|
229 { |
|
230 // do not call this function directly. This should be only called by the |
|
231 // AddConnectionL and RemoveConnection functions. |
|
232 |
|
233 if ( aHost ) |
|
234 { |
|
235 // When adding a host, the host must be aware of this connection first. |
|
236 __ASSERT_ALWAYS( aHost->FindConnection(this) != KErrNotFound, USER_INVARIANT() ); |
|
237 } |
|
238 |
|
239 TRAPD(err, HostChangingL(aHost)); |
|
240 if(err != KErrNone) |
|
241 { |
|
242 if(aHost) |
|
243 { |
|
244 RemoveVisualsFromHostControl(*aHost); |
|
245 } |
|
246 return; |
|
247 } |
|
248 |
|
249 iHost = aHost; |
|
250 } |
|
251 |
|
252 |
|
253 EXPORT_C void CHuiControl::AddConnectionL(CHuiControl* aConnectedControl, TInt aRole) |
|
254 { |
|
255 // check that the connection does not exist: |
|
256 if ( FindConnection( aConnectedControl ) != KErrNotFound ) |
|
257 { |
|
258 User::Leave( KErrAlreadyExists ); |
|
259 } |
|
260 |
|
261 SConnection client; |
|
262 client.iControl = aConnectedControl; |
|
263 client.iRole = aRole; |
|
264 User::LeaveIfError(iConnections.Append(client)); |
|
265 |
|
266 // This control is now the client's host. |
|
267 aConnectedControl->SetHost(this); |
|
268 |
|
269 if ( aConnectedControl->Host() != this ) |
|
270 { |
|
271 // Adding Host failed -> remove connection |
|
272 iConnections.Remove( iConnections.Count()-1 ); |
|
273 User::Leave( KErrGeneral ); |
|
274 } |
|
275 else |
|
276 { |
|
277 // Host set OK |
|
278 ConnectionAddedL(aConnectedControl, aRole); |
|
279 } |
|
280 } |
|
281 |
|
282 |
|
283 EXPORT_C void CHuiControl::RemoveConnection(CHuiControl* aConnectedControl) |
|
284 { |
|
285 for(TInt i = 0; i < iConnections.Count(); ++i) |
|
286 { |
|
287 if(iConnections[i].iControl == aConnectedControl) |
|
288 { |
|
289 aConnectedControl->SetHost(NULL); |
|
290 const TInt role = iConnections[i].iRole; |
|
291 iConnections.Remove(i); |
|
292 |
|
293 ConnectionRemoved(aConnectedControl, role ); |
|
294 return; |
|
295 } |
|
296 } |
|
297 // The client must exist. |
|
298 __ASSERT_ALWAYS(EFalse, THuiPanic::Panic(THuiPanic::EInternal)); |
|
299 } |
|
300 |
|
301 |
|
302 EXPORT_C TInt CHuiControl::ConnectionCount() const |
|
303 { |
|
304 return iConnections.Count(); |
|
305 } |
|
306 |
|
307 |
|
308 EXPORT_C CHuiControl& CHuiControl::Connection(TInt aIndex) const |
|
309 { |
|
310 return *iConnections[aIndex].iControl; |
|
311 } |
|
312 |
|
313 // @deprecated |
|
314 EXPORT_C CHuiControl& CHuiControl::ConnectionByOrdinal(TInt aOrdinal) const |
|
315 { |
|
316 // First look based on role. |
|
317 for(TInt i = 0; i < iConnections.Count(); ++i) |
|
318 { |
|
319 if(iConnections[i].iRole == aOrdinal + 1) |
|
320 { |
|
321 return *iConnections[i].iControl; |
|
322 } |
|
323 } |
|
324 |
|
325 // Fall back to index. |
|
326 return Connection(aOrdinal); |
|
327 } |
|
328 |
|
329 |
|
330 EXPORT_C TInt CHuiControl::FindConnection(const CHuiControl* aConnected) const |
|
331 { |
|
332 for(TInt i = 0; i < iConnections.Count(); ++i) |
|
333 { |
|
334 if(iConnections[i].iControl == aConnected) |
|
335 { |
|
336 return i; |
|
337 } |
|
338 } |
|
339 return KErrNotFound; |
|
340 } |
|
341 |
|
342 |
|
343 EXPORT_C TInt CHuiControl::ConnectionRole(TInt aIndex) const |
|
344 { |
|
345 return iConnections[aIndex].iRole; |
|
346 } |
|
347 |
|
348 |
|
349 // @deprecated |
|
350 EXPORT_C TInt CHuiControl::ConnectionOrdinal(TInt aIndex) const |
|
351 { |
|
352 if(iConnections[aIndex].iRole) |
|
353 { |
|
354 return iConnections[aIndex].iRole - 1; |
|
355 } |
|
356 return aIndex; |
|
357 } |
|
358 |
|
359 |
|
360 EXPORT_C TInt CHuiControl::Role() const |
|
361 { |
|
362 return iRole; |
|
363 } |
|
364 |
|
365 |
|
366 EXPORT_C void CHuiControl::SetRole(TInt aRole) |
|
367 { |
|
368 iRole = aRole; |
|
369 } |
|
370 |
|
371 |
|
372 EXPORT_C TInt CHuiControl::HostId() const |
|
373 { |
|
374 return iHostId; |
|
375 } |
|
376 |
|
377 |
|
378 EXPORT_C void CHuiControl::SetHostId(TInt aHostId) |
|
379 { |
|
380 // If adding automatic visual host, there cannot be already one defined. |
|
381 __ASSERT_ALWAYS( !iHost, USER_INVARIANT() ); |
|
382 |
|
383 iHostId = aHostId; |
|
384 } |
|
385 |
|
386 |
|
387 EXPORT_C CHuiLayout* CHuiControl::ContainerLayout(const CHuiControl* /*aConnected*/) const |
|
388 { |
|
389 // Generic controls aren't able to provide container layouts. |
|
390 return NULL; |
|
391 } |
|
392 |
|
393 |
|
394 EXPORT_C void CHuiControl::VisualAddedL(CHuiVisual* aVisual) |
|
395 { |
|
396 // Add the new visual to the container layout. |
|
397 if(iHost && !aVisual->Layout()) |
|
398 { |
|
399 CHuiLayout* container = iHost->ContainerLayout(this); |
|
400 if(container) |
|
401 { |
|
402 container->AppendL(aVisual); |
|
403 } |
|
404 } |
|
405 else |
|
406 { |
|
407 // If the control has been bound to a display (for example, when |
|
408 // the control is shown), new visuals will be automatically shown. |
|
409 if(iBoundDisplay && |
|
410 (iOwnerGroup && iBoundDisplay->Roster().Find(iOwnerGroup) != KErrNotFound) && |
|
411 !aVisual->Layout() && !aVisual->Display()) |
|
412 { |
|
413 iBoundDisplay->Roster().ShowVisualL(aVisual); |
|
414 } |
|
415 } |
|
416 } |
|
417 |
|
418 |
|
419 EXPORT_C void CHuiControl::VisualRemoved(CHuiVisual* aVisual) |
|
420 { |
|
421 // Add the new visual to the container layout. |
|
422 if(iHost) |
|
423 { |
|
424 CHuiLayout* container = iHost->ContainerLayout(this); |
|
425 if(container) |
|
426 { |
|
427 container->Remove(aVisual); |
|
428 } |
|
429 } |
|
430 } |
|
431 |
|
432 |
|
433 EXPORT_C void CHuiControl::ConnectionAddedL(CHuiControl* /*aConnectedControl*/, TInt /*aRole*/) |
|
434 { |
|
435 // Do nothing. |
|
436 } |
|
437 |
|
438 |
|
439 EXPORT_C void CHuiControl::ConnectionRemoved(CHuiControl* /*aConnectedControl*/, TInt /*aRole*/) |
|
440 { |
|
441 // Do nothing. |
|
442 } |
|
443 |
|
444 |
|
445 void CHuiControl::RemoveVisualsFromHostControl( CHuiControl& aHostControl ) |
|
446 { |
|
447 __ASSERT_ALWAYS( &aHostControl != this, USER_INVARIANT() ); |
|
448 |
|
449 // Remove the visuals. |
|
450 for(TInt i = 0; i < iVisuals.Count(); ++i) |
|
451 { |
|
452 if ( iVisuals[i]->Layout() && &iVisuals[i]->Layout()->Owner() == &aHostControl ) |
|
453 { |
|
454 iVisuals[i]->Layout()->Remove(iVisuals[i]); |
|
455 |
|
456 // If the own control group is showing still in some roster, |
|
457 // we need to add the root visuals over there |
|
458 if ( iBoundDisplay ) |
|
459 { |
|
460 TRAP_IGNORE( iBoundDisplay->Roster().ShowVisualL( iVisuals[i] ) ) |
|
461 } |
|
462 } |
|
463 } |
|
464 } |
|
465 |
|
466 |
|
467 EXPORT_C void CHuiControl::HostChangingL(CHuiControl* aNewHost) |
|
468 { |
|
469 CHuiLayout* newContainer = 0; |
|
470 TInt i = 0; |
|
471 |
|
472 if(aNewHost) |
|
473 { |
|
474 // The container layout provided by the new host. |
|
475 newContainer = aNewHost->ContainerLayout(this); |
|
476 } |
|
477 |
|
478 if(iHost) |
|
479 { |
|
480 RemoveVisualsFromHostControl(*iHost); |
|
481 } |
|
482 |
|
483 if(newContainer) |
|
484 { |
|
485 for(i = 0; i < iVisuals.Count(); ++i) |
|
486 { |
|
487 // Only the visuals that aren't already attached to a layout |
|
488 // are added to the container layout. |
|
489 if(!iVisuals[i]->Layout()) |
|
490 { |
|
491 newContainer->AppendL(iVisuals[i]); |
|
492 } |
|
493 } |
|
494 } |
|
495 } |
|
496 |
|
497 |
|
498 void CHuiControl::ShowL(CHuiDisplay& aDisplay) |
|
499 { |
|
500 if(HostId()) |
|
501 { |
|
502 CHuiControl* host = Env().FindControl(HostId()); |
|
503 |
|
504 if(host) |
|
505 { |
|
506 host->AddConnectionL(this, Role()); |
|
507 } |
|
508 else |
|
509 { |
|
510 } |
|
511 } |
|
512 |
|
513 BindDisplay(aDisplay); |
|
514 |
|
515 // Show all the visuals on the specified display. |
|
516 for(TInt i = 0; i < iVisuals.Count(); ++i) |
|
517 { |
|
518 // The visuals that are part of a layout will be shown when the |
|
519 // layout is shown. |
|
520 if(!iVisuals[i]->Layout() && !iVisuals[i]->Display()) |
|
521 { |
|
522 aDisplay.Roster().ShowVisualL(iVisuals[i]); |
|
523 } |
|
524 } |
|
525 |
|
526 NotifyControlVisibility(ETrue, aDisplay); |
|
527 } |
|
528 |
|
529 |
|
530 void CHuiControl::Hide(CHuiDisplay& aDisplay) |
|
531 { |
|
532 NotifyControlVisibility(EFalse, aDisplay); |
|
533 |
|
534 // Show all the visuals on the specified display. |
|
535 for(TInt i = 0; i < iVisuals.Count(); ++i) |
|
536 { |
|
537 // The visuals that are part of a layout will be shown when the |
|
538 // layout is shown. |
|
539 if(!iVisuals[i]->Layout() && iVisuals[i]->Display() == &aDisplay) |
|
540 { |
|
541 aDisplay.RosterImpl().HideVisual(iVisuals[i]); |
|
542 } |
|
543 } |
|
544 |
|
545 // Unbind from display? |
|
546 if(iBoundDisplay == &aDisplay) |
|
547 { |
|
548 iBoundDisplay = NULL; |
|
549 } |
|
550 |
|
551 // Unlink from parent control if automated host id set. |
|
552 if(Host() && HostId() ) |
|
553 { |
|
554 Host()->RemoveConnection(this); |
|
555 } |
|
556 } |
|
557 |
|
558 |
|
559 EXPORT_C void CHuiControl::NotifyControlVisibility(TBool /*aIsVisible*/, |
|
560 CHuiDisplay& /*aDisplay*/) |
|
561 { |
|
562 // Nothing to do by default. |
|
563 } |
|
564 |
|
565 |
|
566 EXPORT_C TPoint CHuiControl::HostToDisplay(const TPoint& aPoint) const |
|
567 { |
|
568 if(!iHost) |
|
569 { |
|
570 return aPoint; |
|
571 } |
|
572 |
|
573 CHuiLayout* container = iHost->ContainerLayout(this); |
|
574 |
|
575 return container->LocalToDisplay(aPoint) + container->Pos().Target(); |
|
576 } |
|
577 |
|
578 |
|
579 EXPORT_C TPoint CHuiControl::DisplayToHost(const TPoint& aPoint) const |
|
580 { |
|
581 if(!iHost) |
|
582 { |
|
583 return aPoint; |
|
584 } |
|
585 |
|
586 CHuiLayout* container = iHost->ContainerLayout(this); |
|
587 |
|
588 return container->DisplayToLocal(aPoint) - container->Pos().Target(); |
|
589 } |
|
590 |
|
591 |
|
592 EXPORT_C TRect CHuiControl::Bounds() const |
|
593 { |
|
594 TPoint min; |
|
595 TPoint max; |
|
596 |
|
597 min.iX = KMaxTInt; |
|
598 min.iY = KMaxTInt; |
|
599 max.iX = KMinTInt; |
|
600 max.iY = KMinTInt; |
|
601 |
|
602 for(TInt i = 0; i < iVisuals.Count(); ++i) |
|
603 { |
|
604 TRect visualRect = iVisuals[i]->DisplayRectTarget(); |
|
605 |
|
606 min.iX = Min(min.iX, visualRect.iTl.iX); |
|
607 min.iY = Min(min.iY, visualRect.iTl.iY); |
|
608 max.iX = Max(max.iX, visualRect.iBr.iX); |
|
609 max.iY = Max(max.iY, visualRect.iBr.iY); |
|
610 } |
|
611 |
|
612 return TRect(min, max); |
|
613 } |
|
614 |
|
615 |
|
616 EXPORT_C TBool CHuiControl::HitTest(const TPoint& aPoint) const |
|
617 { |
|
618 return Bounds().Contains(aPoint); |
|
619 } |
|
620 |
|
621 |
|
622 |
|
623 EXPORT_C void CHuiControl::AcquireFocus() |
|
624 { |
|
625 |
|
626 /** @todo Focus should be set separately in each display the control |
|
627 has visuals in. */ |
|
628 |
|
629 for(TInt i = 0; i < iVisuals.Count(); ++i) |
|
630 { |
|
631 if(iVisuals[i]->Display()) |
|
632 { |
|
633 iVisuals[i]->Display()->Roster().SetFocus(*this /*Id()*/); |
|
634 //return; |
|
635 } |
|
636 } |
|
637 } |
|
638 |
|
639 |
|
640 EXPORT_C TBool CHuiControl::Focus() const |
|
641 { |
|
642 return iHasFocus; |
|
643 } |
|
644 |
|
645 |
|
646 void CHuiControl::SetFocus(CHuiDisplay& aDisplay, TBool aHasFocus) |
|
647 { |
|
648 if ( ( iHasFocus && !aHasFocus ) || ( !iHasFocus && aHasFocus ) ) |
|
649 { |
|
650 iHasFocus = aHasFocus; |
|
651 FocusChanged(aDisplay, aHasFocus); |
|
652 } |
|
653 } |
|
654 |
|
655 |
|
656 EXPORT_C TBool CHuiControl::IsFocusing() const |
|
657 { |
|
658 return iFocusing; |
|
659 } |
|
660 |
|
661 |
|
662 void CHuiControl::SetFocusing(TBool aFocusing) |
|
663 { |
|
664 iFocusing = aFocusing; |
|
665 } |
|
666 |
|
667 |
|
668 EXPORT_C void CHuiControl::FocusChanged(CHuiDisplay& /*aDisplay*/, TBool /*iFocused*/) |
|
669 { |
|
670 // Do nothing by default. |
|
671 } |
|
672 |
|
673 |
|
674 EXPORT_C TBool CHuiControl::AcceptInput() const |
|
675 { |
|
676 if(iOwnerGroup) |
|
677 { |
|
678 return iOwnerGroup->AcceptInput(); |
|
679 } |
|
680 return ETrue; |
|
681 } |
|
682 |
|
683 |
|
684 EXPORT_C TBool CHuiControl::OfferEventL(const THuiEvent& /*aEvent*/) |
|
685 { |
|
686 return EFalse; |
|
687 } |
|
688 |
|
689 |
|
690 EXPORT_C TRect CHuiControl::DisplayArea() const |
|
691 { |
|
692 if(iBoundDisplay) |
|
693 { |
|
694 return iBoundDisplay->VisibleArea(); |
|
695 } |
|
696 |
|
697 // The first visual shown on a display determines the display area. |
|
698 for(TInt i = 0; i < iVisuals.Count(); ++i) |
|
699 { |
|
700 if(iVisuals[i]->Display()) |
|
701 { |
|
702 return iVisuals[i]->Display()->VisibleArea(); |
|
703 } |
|
704 } |
|
705 |
|
706 if(!Env().DisplayCount()) |
|
707 { |
|
708 // No displays created in the environment yet. Assume device |
|
709 // native resolution. |
|
710 return TRect(TPoint(0, 0), HuiUtil::ScreenSize()); |
|
711 } |
|
712 |
|
713 // Assume it is the primary display, then. |
|
714 return Env().PrimaryDisplay().VisibleArea(); |
|
715 } |
|
716 |
|
717 |
|
718 EXPORT_C THuiRealPoint CHuiControl::DisplayCenter() const __SOFTFP |
|
719 { |
|
720 TRect area(DisplayArea()); |
|
721 return area.iTl + THuiRealPoint(area.Width()/2.f, area.Height()/2.f); |
|
722 } |
|
723 |
|
724 |
|
725 EXPORT_C void CHuiControl::CancelAllCommands() |
|
726 { |
|
727 iEnv.CancelCommands(this); |
|
728 |
|
729 for(TInt i = 0; i < iVisuals.Count(); ++i) |
|
730 { |
|
731 iEnv.CancelCommands(iVisuals[i]); |
|
732 } |
|
733 } |
|
734 |
|
735 |
|
736 void CHuiControl::ClearChanged() |
|
737 { |
|
738 } |
|
739 |
|
740 |
|
741 EXPORT_C void CHuiControl::VisualLayoutUpdated(CHuiVisual& /*aVisual*/) |
|
742 { |
|
743 // Nothing done by default. |
|
744 } |
|
745 |
|
746 |
|
747 EXPORT_C void CHuiControl::VisualDestroyed(CHuiVisual& aVisual) |
|
748 { |
|
749 Remove(&aVisual); |
|
750 } |
|
751 |
|
752 |
|
753 EXPORT_C void CHuiControl::VisualPrepareDrawFailed( |
|
754 #ifdef _DEBUG |
|
755 #ifdef __WINS__ |
|
756 #ifdef HUI_NO_DEBUG_OUTPUT_IN_WINS |
|
757 CHuiVisual& /*aVisual*/, |
|
758 TInt /*aErrorCode*/ |
|
759 #else |
|
760 CHuiVisual& /*aVisual*/, |
|
761 TInt /*aErrorCode*/ |
|
762 #endif |
|
763 #else |
|
764 CHuiVisual& /*aVisual*/, |
|
765 TInt /*aErrorCode*/ |
|
766 #endif |
|
767 #else |
|
768 CHuiVisual& /*aVisual*/, |
|
769 TInt /*aErrorCode*/ |
|
770 #endif |
|
771 ) |
|
772 { |
|
773 //HUI_DEBUG2(_L("CHuiControl::VisualPrepareDrawFailed() - ERROR! Visual 0x%x failed to prepare for drawing. Error Code %i. Panicing. (TIP: override this method for custom error handling)."), |
|
774 // &aVisual, aErrorCode); |
|
775 #ifdef _DEBUG |
|
776 HUI_PANIC(THuiPanic::EVisualPrepareDrawFailed) |
|
777 #endif |
|
778 } |
|
779 |
|
780 |
|
781 EXPORT_C MHuiEventHandler* CHuiControl::EventHandler() |
|
782 { |
|
783 return this; |
|
784 } |
|
785 |
|
786 |
|
787 HUI_SESSION_OBJECT_IMPL_EXPORT(CHuiControl, ETypeControl) |
|
788 |
|
789 EXPORT_C void CHuiControl::ControlExtension(const TUid& /*aExtensionUid*/, TAny** /*aExtensionParams*/) |
|
790 { |
|
791 |
|
792 } |
|
793 |
|
794 |