javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtshell.cpp
branchRCL_3
changeset 19 71c436fe3ce0
parent 17 0fd27995241b
child 21 4376525cdefb
equal deleted inserted replaced
18:9ac0a0a7da70 19:71c436fe3ce0
    27 // Main pane varieties
    27 // Main pane varieties
    28 static const TInt KSwtMainPainVarietyClassic = 3;
    28 static const TInt KSwtMainPainVarietyClassic = 3;
    29 static const TInt KSwtMainPainVarietySmallSpLandscape = 9;
    29 static const TInt KSwtMainPainVarietySmallSpLandscape = 9;
    30 static const TInt KSwtMainPainVarietySmallSpLandscapePen = 4;
    30 static const TInt KSwtMainPainVarietySmallSpLandscapePen = 4;
    31 
    31 
    32 // Area bottom pane varieties
       
    33 static const TInt KSwtAreaBottomPaneVarietyPortrait = 0;
       
    34 #ifdef RD_JAVA_S60_RELEASE_9_2
    32 #ifdef RD_JAVA_S60_RELEASE_9_2
    35 static const TInt KSwtAreaBottomPaneVarietyLandscape = 2;
       
    36 static const TInt KSwtRoundCornerBgColorDiff = 50;
    33 static const TInt KSwtRoundCornerBgColorDiff = 50;
    37 #endif // RD_JAVA_S60_RELEASE_9_2
    34 #endif // RD_JAVA_S60_RELEASE_9_2
    38 
    35 
    39 
    36 
    40 // ======== MEMBER FUNCTIONS ========
    37 // ======== MEMBER FUNCTIONS ========
   132 
   129 
   133 #ifdef RD_SCALABLE_UI_V2
   130 #ifdef RD_SCALABLE_UI_V2
   134     window.SetPointerGrab(ETrue);
   131     window.SetPointerGrab(ETrue);
   135 #endif //RD_SCALABLE_UI_V2
   132 #endif //RD_SCALABLE_UI_V2
   136 
   133 
   137     CCoeControl::SetRect(DefaultBounds());
   134     DoSetRect(DefaultBounds());
   138     SetMinimumSize(TSize());
   135     SetMinimumSize(TSize());
   139     UiUtils().RegisterShellL(*this);
   136     UiUtils().RegisterShellL(*this);
   140 
   137 
   141 #ifdef RD_SCALABLE_UI_V2
   138 #ifdef RD_SCALABLE_UI_V2
   142     if ((iStyle & KSwtStyleSystemModal) != 0 ||
   139     if ((iStyle & KSwtStyleSystemModal) != 0 ||
   207 
   204 
   208     ASSERT(!iFocusControl);
   205     ASSERT(!iFocusControl);
   209 }
   206 }
   210 
   207 
   211 // ---------------------------------------------------------------------------
   208 // ---------------------------------------------------------------------------
       
   209 // CSwtShell::DoSetRect
       
   210 // Note that calling SetRect on the Shell does not cause a PositionChanged!
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 void CSwtShell::DoSetRect(const TRect& aRect)
       
   214 {
       
   215     // Divert the job to UiUtils if this is the Shell of an editor open for
       
   216     // split view editing.
       
   217     MSwtUiUtils& utils = iDisplay.UiUtils();
       
   218     MSwtControl* splitInputView = utils.SplitInputView();
       
   219     if (splitInputView && (&(splitInputView->GetShell())) == this)
       
   220     {
       
   221         utils.SetSplitInputShellPos(aRect.iTl);
       
   222         CCoeControl::SetSize(aRect.Size());
       
   223     }
       
   224     else
       
   225     {
       
   226         CCoeControl::SetRect(aRect);
       
   227     }
       
   228 }
       
   229 
       
   230 // ---------------------------------------------------------------------------
   212 // CSwtShell::SwtHandleResourceChangeL
   231 // CSwtShell::SwtHandleResourceChangeL
   213 // From CSwtComposite
   232 // From CSwtComposite
   214 // ---------------------------------------------------------------------------
   233 // ---------------------------------------------------------------------------
   215 //
   234 //
   216 void CSwtShell::SwtHandleResourceChangeL(TInt aType)
   235 void CSwtShell::SwtHandleResourceChangeL(TInt aType)
   223                 static_cast<CAknsBasicBackgroundControlContext*>(GetControlContext());
   242                 static_cast<CAknsBasicBackgroundControlContext*>(GetControlContext());
   224             if (bg)
   243             if (bg)
   225             {
   244             {
   226                 bg->SetRect(iDisplay.Device().Bounds());
   245                 bg->SetRect(iDisplay.Device().Bounds());
   227             }
   246             }
   228             CCoeControl::SetRect(DefaultBounds());
   247             DoSetRect(DefaultBounds());
   229         }
   248         }
   230     }
   249     }
   231 
   250 
   232     CSwtDecorations::SwtHandleResourceChangeL(aType);
   251     CSwtDecorations::SwtHandleResourceChangeL(aType);
   233 }
   252 }
   392                 && capturingControl->IsFocusable())
   411                 && capturingControl->IsFocusable())
   393         {
   412         {
   394             capturingControl->SetSwtFocus(KSwtFocusByPointer);
   413             capturingControl->SetSwtFocus(KSwtFocusByPointer);
   395         }
   414         }
   396         capturingControl->HandlePointerEventL(aPointerEvent);
   415         capturingControl->HandlePointerEventL(aPointerEvent);
   397         capturingControl->PostMouseEventL(aPointerEvent);
       
   398         iDisplay.TryDetectLongTapL(aPointerEvent);
   416         iDisplay.TryDetectLongTapL(aPointerEvent);
   399         return;
   417         return;
   400     }
   418     }
   401 
   419 
   402     MSwtControl* ctrl = NULL;
       
   403 
       
   404     if (aPointerEvent.iType == TPointerEvent::EButton1Up)
       
   405         ctrl = iDisplay.UiUtils().GetPointerGrabbingControl();
       
   406 
       
   407     if (!iDisplay.RevertPointerEvent())
   420     if (!iDisplay.RevertPointerEvent())
   408     {
   421     {
   409         CSwtComposite::HandlePointerEventL(aPointerEvent);
   422         CSwtComposite::HandlePointerEventL(aPointerEvent);
   410     }
   423     }
   411 
       
   412     if (aPointerEvent.iType != TPointerEvent::EButton1Up)
       
   413         ctrl = iDisplay.UiUtils().GetPointerGrabbingControl();
       
   414 
       
   415     if (ctrl)
       
   416         ctrl->PostMouseEventL(aPointerEvent);
       
   417 
   424 
   418     iDisplay.TryDetectLongTapL(aPointerEvent);
   425     iDisplay.TryDetectLongTapL(aPointerEvent);
   419 }
   426 }
   420 #else
   427 #else
   421 void CSwtShell::HandlePointerEventL(const TPointerEvent& /*aPointerEvent*/)
   428 void CSwtShell::HandlePointerEventL(const TPointerEvent& /*aPointerEvent*/)
   588             FinishRedraw();
   595             FinishRedraw();
   589         }
   596         }
   590     }
   597     }
   591 }
   598 }
   592 
   599 
       
   600 void CSwtShell::SizeChanged()
       
   601 {
       
   602     CSwtDecorations::SizeChanged();
       
   603     MSwtUiUtils& utils = iDisplay.UiUtils();
       
   604     MSwtControl* splitInputView = utils.SplitInputView();
       
   605     if (splitInputView && (&(splitInputView->GetShell())) == this)
       
   606     {
       
   607         utils.AdjustSplitInputShellPos();
       
   608     }
       
   609 }
       
   610 
   593 // ---------------------------------------------------------------------------
   611 // ---------------------------------------------------------------------------
   594 // CSwtShell::Draw
   612 // CSwtShell::Draw
   595 // From MCoeControlBackground
   613 // From MCoeControlBackground
   596 // ---------------------------------------------------------------------------
   614 // ---------------------------------------------------------------------------
   597 //
   615 //
   624     // Shells never get the CoeControl focus, just active
   642     // Shells never get the CoeControl focus, just active
   625     return EFalse;
   643     return EFalse;
   626 }
   644 }
   627 
   645 
   628 // ---------------------------------------------------------------------------
   646 // ---------------------------------------------------------------------------
   629 // CSwtShell::DoSetFocus
   647 // CSwtShell::SetSwtFocus
   630 // From MSwtControl
   648 // From MSwtControl
   631 // ---------------------------------------------------------------------------
   649 // ---------------------------------------------------------------------------
   632 //
   650 //
   633 TBool CSwtShell::SetSwtFocus(TInt aReason /*=KSwtFocusByApi*/)
   651 TBool CSwtShell::SetSwtFocus(TInt aReason /*=KSwtFocusByApi*/)
   634 {
   652 {
   708     if (iIsMaximized || !iParent)
   726     if (iIsMaximized || !iParent)
   709     {
   727     {
   710         return;
   728         return;
   711     }
   729     }
   712 
   730 
   713     TPoint originalLocation(GetLocation());
   731     DoSetLocation(aPoint);
   714     iPosition = aPoint;
       
   715 
       
   716     Window().SetPosition(aPoint);
       
   717 
       
   718     // Post the MoveEvent if the location changed.
       
   719     if (GetLocation() != originalLocation)
       
   720     {
       
   721         PositionChanged();
       
   722     }
       
   723 
       
   724     // Drawing after everything else.
       
   725     if (!(iStyle & KSwtStyleNoRedrawResize))
       
   726     {
       
   727         Redraw();
       
   728     }
       
   729 }
   732 }
   730 
   733 
   731 // ---------------------------------------------------------------------------
   734 // ---------------------------------------------------------------------------
   732 // CSwtShell::SetWidgetSize
   735 // CSwtShell::SetWidgetSize
   733 // From MSwtControl
   736 // From MSwtControl
   741         return;
   744         return;
   742     }
   745     }
   743 
   746 
   744     TSize checkedSize(Max(aSize.iWidth, iMinSize.iWidth),
   747     TSize checkedSize(Max(aSize.iWidth, iMinSize.iWidth),
   745                       Max(aSize.iHeight, iMinSize.iHeight));
   748                       Max(aSize.iHeight, iMinSize.iHeight));
   746     SetSize(checkedSize);
   749 
   747 
   750     if (Size() != checkedSize)
   748     // Drawing only after everything else.
   751     {
   749     if (!(iStyle & KSwtStyleNoRedrawResize))
   752         SetSize(checkedSize);
   750     {
   753 
   751         Redraw();
   754         // Drawing only after everything else.
       
   755         if (!(iStyle & KSwtStyleNoRedrawResize))
       
   756         {
       
   757             Redraw();
       
   758         }
   752     }
   759     }
   753 }
   760 }
   754 
   761 
   755 // ---------------------------------------------------------------------------
   762 // ---------------------------------------------------------------------------
   756 // CSwtShell::SetBounds
   763 // CSwtShell::SetBounds
   763     if (iIsMaximized || !iParent)
   770     if (iIsMaximized || !iParent)
   764     {
   771     {
   765         return;
   772         return;
   766     }
   773     }
   767 
   774 
       
   775     TBool changed = EFalse;
   768     TSize checkedSize(Max(aRect.Size().iWidth, iMinSize.iWidth),
   776     TSize checkedSize(Max(aRect.Size().iWidth, iMinSize.iWidth),
   769                       Max(aRect.Size().iHeight, iMinSize.iHeight));
   777                       Max(aRect.Size().iHeight, iMinSize.iHeight));
   770     SetSize(checkedSize);
   778     if (Size() != checkedSize)
   771 
   779     {
   772     TPoint originalLocation(GetLocation());
   780         SetSize(checkedSize);
   773     iPosition = aRect.iTl;
   781         changed = ETrue;
   774     Window().SetPosition(aRect.iTl);
   782     }
   775     if (GetLocation() != originalLocation)
   783 
   776     {
   784     // Divert the job to UiUtils if this is the Shell of an editor open for
   777         PositionChanged();
   785     // split view editing.
   778     }
   786     MSwtUiUtils& utils = iDisplay.UiUtils();
   779 
   787     MSwtControl* splitInputView = utils.SplitInputView();
   780     // No need to recurse on the children, their positions within the
   788     if (splitInputView && (&(splitInputView->GetShell())) == this)
   781     // window do not change
   789     {
   782 
   790         utils.SetSplitInputShellPos(aRect.iTl);
   783     if (!(iStyle & KSwtStyleNoRedrawResize))
   791     }
       
   792     else
       
   793     {
       
   794         if (aRect.iTl != iPosition)
       
   795         {
       
   796             iPosition = aRect.iTl;
       
   797             Window().SetPosition(aRect.iTl);
       
   798             PositionChanged();
       
   799             changed = ETrue;
       
   800         }
       
   801 
       
   802         // No need to recurse on the children, their positions within the
       
   803         // window do not change
       
   804     }
       
   805 
       
   806     if (changed && !(iStyle & KSwtStyleNoRedrawResize))
   784     {
   807     {
   785         Redraw();
   808         Redraw();
   786     }
   809     }
   787 }
   810 }
   788 
   811 
   974     }
   997     }
   975 
   998 
   976     TRect newRect(TRect::EUninitialized);
   999     TRect newRect(TRect::EUninitialized);
   977     if (aMaximized)
  1000     if (aMaximized)
   978     {
  1001     {
   979         // Set bounds so as to cover the whole application area
  1002         TRect screenRect;
   980         RRegion clientRegion;
  1003         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screenRect);
   981         clientRegion.AddRect(iEikonEnv->EikAppUi()->ClientRect());
  1004         TInt variety(0);
   982         if (!IsMobileShell())
  1005         if (CSwtLafFacade::IsLandscapeOrientation())
   983         {
  1006         {
   984             TInt variety(KSwtAreaBottomPaneVarietyPortrait);
  1007             variety = AknLayoutUtils::PenEnabled() ?
   985 #ifdef RD_JAVA_S60_RELEASE_9_2
  1008                       KSwtMainPainVarietySmallSpLandscapePen :
   986             if (CSwtLafFacade::IsLandscapeOrientation())
  1009                       KSwtMainPainVarietySmallSpLandscape;
   987             {
  1010         }
   988                 variety = KSwtAreaBottomPaneVarietyLandscape;
  1011         else
   989             }
  1012         {
   990 #endif // RD_JAVA_S60_RELEASE_9_2
  1013             variety = KSwtMainPainVarietyClassic;
   991 
  1014         }
   992             clientRegion.SubRect(CSwtLafFacade::GetLayoutRect(
  1015         TAknLayoutRect layoutRect = CSwtLafFacade::GetComposeAndLayoutRect(
   993                                      CSwtLafFacade::EAreaBottomPane,
  1016                                         CSwtLafFacade::EMainPaneCompose, screenRect, variety);
   994                                      iDisplay.Device().Bounds(),
  1017         newRect = layoutRect.Rect();
   995                                      variety).Rect());
       
   996         }
       
   997         newRect = clientRegion.BoundingRect();
       
   998         clientRegion.Close();
       
   999         iNormalBounds.SetRect(iPosition, iSize);
  1018         iNormalBounds.SetRect(iPosition, iSize);
  1000     }
  1019     }
  1001     else
  1020     else
  1002     {
  1021     {
  1003         newRect = iNormalBounds;
  1022         newRect = iNormalBounds;
  1004     }
  1023     }
  1005 
  1024 
  1006     SetPosition(newRect.iTl);
  1025     SetBounds(newRect);
  1007     SetSize(newRect.Size());
       
  1008 
       
  1009     iIsMaximized = aMaximized;
  1026     iIsMaximized = aMaximized;
  1010     Redraw();
  1027     Redraw();
  1011 }
  1028 }
  1012 
  1029 
  1013 void CSwtShell::SetMinimized(TBool aMinimized)
  1030 void CSwtShell::SetMinimized(TBool aMinimized)
  1804     if (utils.GetActiveShell() == this)
  1821     if (utils.GetActiveShell() == this)
  1805     {
  1822     {
  1806         TRAP_IGNORE(utils.UpdateStatusPaneL());
  1823         TRAP_IGNORE(utils.UpdateStatusPaneL());
  1807     }
  1824     }
  1808 
  1825 
  1809     CCoeControl::SetRect(DefaultBounds());
  1826     DoSetRect(DefaultBounds());
  1810 
  1827 
  1811     SetRedraw(ETrue);
  1828     SetRedraw(ETrue);
  1812 }
  1829 }
  1813 
  1830 
  1814 // ---------------------------------------------------------------------------
  1831 // ---------------------------------------------------------------------------
  2088 {
  2105 {
  2089     return iIsTaskTip;
  2106     return iIsTaskTip;
  2090 }
  2107 }
  2091 
  2108 
  2092 // ---------------------------------------------------------------------------
  2109 // ---------------------------------------------------------------------------
       
  2110 // CSwtShell::DoSetLocation
       
  2111 // From MSwtShell
       
  2112 // ---------------------------------------------------------------------------
       
  2113 //
       
  2114 void CSwtShell::DoSetLocation(const TPoint& aPoint)
       
  2115 {
       
  2116     if (aPoint == iPosition)
       
  2117     {
       
  2118         return;
       
  2119     }
       
  2120 
       
  2121     // Divert the job to UiUtils if this is the Shell of an editor open for
       
  2122     // split view editing.
       
  2123     MSwtUiUtils& utils = iDisplay.UiUtils();
       
  2124     MSwtControl* splitInputView = utils.SplitInputView();
       
  2125     if (splitInputView && (&(splitInputView->GetShell())) == this)
       
  2126     {
       
  2127         utils.SetSplitInputShellPos(aPoint);
       
  2128         return;
       
  2129     }
       
  2130 
       
  2131     iPosition = aPoint;
       
  2132     Window().SetPosition(aPoint);
       
  2133 
       
  2134     // Post the MoveEvent if the location changed.
       
  2135     PositionChanged();
       
  2136 
       
  2137     // Drawing after everything else.
       
  2138     if (!(iStyle & KSwtStyleNoRedrawResize))
       
  2139     {
       
  2140         Redraw();
       
  2141     }
       
  2142 }
       
  2143 
       
  2144 
       
  2145 // ---------------------------------------------------------------------------
  2093 // CSwtShell::HandleStatusPaneSizeChange
  2146 // CSwtShell::HandleStatusPaneSizeChange
  2094 // From MEikStatusPaneObserver
  2147 // From MEikStatusPaneObserver
  2095 // ---------------------------------------------------------------------------
  2148 // ---------------------------------------------------------------------------
  2096 //
  2149 //
  2097 void CSwtShell::HandleStatusPaneSizeChange()
  2150 void CSwtShell::HandleStatusPaneSizeChange()
  2098 {
  2151 {
  2099     if (iIsMaximized  && (!iParent))
  2152     if (iIsMaximized  && (!iParent))
  2100     {
  2153     {
  2101         CCoeControl::SetRect(DefaultBounds());
  2154         DoSetRect(DefaultBounds());
  2102     }
  2155     }
  2103 }
  2156 }
  2104 
  2157 
  2105 void CSwtShell::FinishRedraw() const
  2158 void CSwtShell::FinishRedraw() const
  2106 {
  2159 {