371 // |
316 // |
372 // ----------------------------------------------------------------------------- |
317 // ----------------------------------------------------------------------------- |
373 // |
318 // |
374 void CXnWidgetExtensionAdapter::Draw( const TRect& aRect ) const |
319 void CXnWidgetExtensionAdapter::Draw( const TRect& aRect ) const |
375 { |
320 { |
|
321 SystemGc().Clear( aRect ); |
376 CXnControlAdapter::Draw( aRect ); |
322 CXnControlAdapter::Draw( aRect ); |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // CXnWidgetExtensionAdapter::DoHandlePropertyChangeL |
|
327 // |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void CXnWidgetExtensionAdapter::DoHandlePropertyChangeL( CXnProperty* /*aProperty*/ ) |
|
331 { |
|
332 if( iNode.Node().IsLaidOut() && IsVisible() ) |
|
333 { |
|
334 ChangePopupPosition(); |
|
335 } |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // CXnWidgetExtensionAdapter::ChangePopupPosition |
|
340 // |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 void CXnWidgetExtensionAdapter::ChangePopupPosition() |
|
344 { |
|
345 if ( iPopup ) |
|
346 { |
|
347 // read position-hint property and set-up its variable |
|
348 CXnProperty* positionHintProp = NULL; |
|
349 TRAP_IGNORE( positionHintProp = iNode.Node().GetPropertyL( KPositionHint ) ); |
|
350 |
|
351 if ( positionHintProp ) |
|
352 { |
|
353 const TDesC8& displayHintVal = positionHintProp->StringValue(); |
|
354 |
|
355 if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveLeft ) |
|
356 { |
|
357 iPositionHint = EAboveLeft; |
|
358 } |
|
359 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveRight ) |
|
360 { |
|
361 iPositionHint = EAboveRight; |
|
362 } |
|
363 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowLeft ) |
|
364 { |
|
365 iPositionHint = EBelowLeft; |
|
366 } |
|
367 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowRight ) |
|
368 { |
|
369 iPositionHint = EBelowRight; |
|
370 } |
|
371 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KRight ) |
|
372 { |
|
373 iPositionHint = ERight; |
|
374 } |
|
375 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KLeft ) |
|
376 { |
|
377 iPositionHint = ELeft; |
|
378 } |
|
379 else |
|
380 { |
|
381 // if the value if of unknown type, use default one |
|
382 if ( AknLayoutUtils::LayoutMirrored() ) |
|
383 { |
|
384 iPositionHint = EAboveRight; |
|
385 } |
|
386 else |
|
387 { |
|
388 iPositionHint = EAboveLeft; |
|
389 } |
|
390 } |
|
391 |
|
392 if ( iPositionHint != ENone ) |
|
393 { |
|
394 // the popup is going visible and position-hind is available |
|
395 // calculate its position |
|
396 CalculatePosition(); |
|
397 } |
|
398 } |
|
399 } |
377 } |
400 } |
378 |
401 |
379 // ----------------------------------------------------------------------------- |
402 // ----------------------------------------------------------------------------- |
380 // CalculatePosition |
403 // CalculatePosition |
381 // This is used only for popup element with position hint |
404 // This is used only for popup element with position hint |
432 |
455 |
433 case EAboveLeft: |
456 case EAboveLeft: |
434 |
457 |
435 // if this position does not fit the screen, |
458 // if this position does not fit the screen, |
436 // and if below left is more suitable, use it |
459 // and if below left is more suitable, use it |
437 if ( spaceAbove < popupRect.Height() && spaceBelow > spaceAbove ) |
460 if ( spaceAbove < popupSize.iHeight && spaceBelow > spaceAbove ) |
438 { |
461 { |
439 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), |
462 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), |
440 TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iBr.iY + popupRect.Height() ) ); |
463 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) ); |
441 } |
464 } |
442 else |
465 else |
443 { |
466 { |
444 // use the above-left position |
467 // use the above-left position |
445 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupRect.Height() ), |
468 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ), |
446 TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iTl.iY ) ); |
469 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) ); |
447 |
470 |
448 } |
471 } |
449 break; |
472 break; |
450 |
473 |
451 case EAboveRight: |
474 case EAboveRight: |
452 |
475 |
453 // if this position does not fit the screen, |
476 // if this position does not fit the screen, |
454 // and if below right is more suitable, use it |
477 // and if below right is more suitable, use it |
455 if ( spaceAbove < popupRect.Height() && spaceBelow > spaceAbove ) |
478 if ( spaceAbove < popupSize.iHeight && spaceBelow > spaceAbove ) |
456 { |
479 { |
457 rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iBr.iY ), |
480 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ), |
458 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupRect.Height() ) ); |
481 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) ); |
459 } |
482 } |
460 else |
483 else |
461 { |
484 { |
462 // use the above-right position |
485 // use the above-right position |
463 rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iTl.iY - popupRect.Height() ), |
486 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ), |
464 TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) ); |
487 TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) ); |
465 } |
488 } |
466 break; |
489 break; |
467 |
490 |
468 case EBelowLeft: |
491 case EBelowLeft: |
469 |
492 |
470 // if this position does not fit the screen, |
493 // if this position does not fit the screen, |
471 // and if above left is more suitable, use it |
494 // and if above left is more suitable, use it |
472 if ( spaceBelow < popupRect.Height() && spaceBelow < spaceAbove ) |
495 if ( spaceBelow < popupSize.iHeight && spaceBelow < spaceAbove ) |
473 { |
496 { |
474 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupRect.Height() ), |
497 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ), |
475 TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iTl.iY ) ); |
498 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) ); |
476 } |
499 } |
477 else |
500 else |
478 { |
501 { |
479 // use the below-left position |
502 // use the below-left position |
480 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), |
503 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), |
481 TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iBr.iY + popupRect.Height() ) ); |
504 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) ); |
482 } |
505 } |
483 break; |
506 break; |
484 |
507 |
485 case EBelowRight: |
508 case EBelowRight: |
486 |
509 |
487 // if this position does not fit the screen, |
510 // if this position does not fit the screen, |
488 // and if above right is more suitable, use it |
511 // and if above right is more suitable, use it |
489 if ( spaceBelow < popupRect.Height() && spaceBelow < spaceAbove ) |
512 if ( spaceBelow < popupSize.iHeight && spaceBelow < spaceAbove ) |
490 { |
513 { |
491 rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iTl.iY - popupRect.Height() ), |
514 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ), |
492 TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) ); |
515 TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) ); |
493 } |
516 } |
494 else |
517 else |
495 { |
518 { |
496 // use the below-right position |
519 // use the below-right position |
497 rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iBr.iY ), |
520 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ), |
498 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupRect.Height() ) ); |
521 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) ); |
499 } |
522 } |
500 break; |
523 break; |
501 |
524 |
502 case ERight: |
525 case ERight: |
503 |
526 |
504 // if this position does not fit the screen, |
527 // if this position does not fit the screen, |
505 // and if left or above-left is more suitable, use it |
528 // and if left or above-left is more suitable, use it |
506 if ( spaceRight < popupRect.Width() ) |
529 if ( spaceRight < popupSize.iWidth ) |
507 { |
530 { |
508 // use the left position if the space is big enough |
531 // use the left position if the space is big enough |
509 if ( spaceLeft >= popupRect.Width() ) |
532 if ( spaceLeft >= popupSize.iWidth ) |
510 { |
533 { |
511 // use left position |
534 // use left position |
512 rect = TRect( TPoint( controlRect.iTl.iX - popupRect.Width(), controlRect.iTl.iY ), |
535 rect = TRect( TPoint( controlRect.iTl.iX - popupSize.iWidth, controlRect.iTl.iY ), |
513 TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupRect.Height() ) ); |
536 TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupSize.iHeight ) ); |
514 } |
537 } |
515 else if ( spaceAbove >= popupRect.Height() ) |
538 else if ( spaceAbove >= popupSize.iHeight ) |
516 { |
539 { |
517 // use the above-right position |
540 // use the above-right position |
518 rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iTl.iY - popupRect.Height() ), |
541 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ), |
519 TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) ); |
542 TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) ); |
520 } |
543 } |
521 else |
544 else |
522 { |
545 { |
523 // use the below-right position |
546 // use the below-right position |
524 rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iBr.iY ), |
547 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ), |
525 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupRect.Height() ) ); |
548 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) ); |
526 } |
549 } |
527 } |
550 } |
528 else |
551 else |
529 { |
552 { |
530 // use the right position |
553 // use the right position |
531 rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), |
554 rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), |
532 TPoint( controlRect.iBr.iX + popupRect.Width(), controlRect.iTl.iY + popupRect.Height() ) ); |
555 TPoint( controlRect.iBr.iX + popupSize.iWidth, controlRect.iTl.iY + popupSize.iHeight ) ); |
533 } |
556 } |
534 |
557 |
535 break; |
558 break; |
536 |
559 |
537 case ELeft: |
560 case ELeft: |
538 |
561 |
539 // if this position does not fit the screen, |
562 // if this position does not fit the screen, |
540 // and if right is more suitable, use it |
563 // and if right is more suitable, use it |
541 if ( spaceLeft < popupRect.Width() ) |
564 if ( spaceLeft < popupSize.iWidth ) |
542 { |
565 { |
543 // use the right position, if it the space is big enough |
566 // use the right position, if it the space is big enough |
544 if ( spaceRight >= popupRect.Width() ) |
567 if ( spaceRight >= popupSize.iWidth ) |
545 { |
568 { |
546 rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), |
569 rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), |
547 TPoint( controlRect.iBr.iX + popupRect.Width(), controlRect.iTl.iY + popupRect.Height() ) ); |
570 TPoint( controlRect.iBr.iX + popupSize.iWidth, controlRect.iTl.iY + popupSize.iHeight ) ); |
548 } |
571 } |
549 else if ( spaceAbove >= popupRect.Height() ) |
572 else if ( spaceAbove >= popupSize.iHeight ) |
550 { |
573 { |
551 // use the above-left position |
574 // use the above-left position |
552 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupRect.Height() ), |
575 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ), |
553 TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iTl.iY ) ); |
576 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) ); |
554 } |
577 } |
555 else |
578 else |
556 { |
579 { |
557 // use the below-left position |
580 // use the below-left position |
558 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), |
581 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), |
559 TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iBr.iY + popupRect.Height() ) ); |
582 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) ); |
560 } |
583 } |
561 } |
584 } |
562 else |
585 else |
563 { |
586 { |
564 // use the left position |
587 // use the left position |
565 rect = TRect( TPoint( controlRect.iTl.iX - popupRect.Width(), controlRect.iTl.iY ), |
588 rect = TRect( TPoint( controlRect.iTl.iX - popupSize.iWidth, controlRect.iTl.iY ), |
566 TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupRect.Height() ) ); |
589 TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupSize.iHeight ) ); |
567 } |
590 } |
568 break; |
591 break; |
569 default: |
592 default: |
570 break; |
593 break; |
571 } |
594 } |