javauis/lcdui_akn/lcdui/src/CMIDTextEditor.cpp
branchRCL_3
changeset 18 9ac0a0a7da70
parent 17 0fd27995241b
child 21 4376525cdefb
equal deleted inserted replaced
17:0fd27995241b 18:9ac0a0a7da70
   215     // and fullscreen mode changes.
   215     // and fullscreen mode changes.
   216     iNonScaledEditorSize = TSize(aWidth, aHeight);
   216     iNonScaledEditorSize = TSize(aWidth, aHeight);
   217 
   217 
   218     // If parent is in fullscreen mode then it tries scale input size.
   218     // If parent is in fullscreen mode then it tries scale input size.
   219     // Only setting otherwise.
   219     // Only setting otherwise.
   220     if (!iRowCountActive &&iComponentContainer &&
   220     if (IsScalingOn())
   221             iComponentContainer->IsFullScreen())
       
   222     {
   221     {
   223         iTextEdwin->SetSize(iUtils->DoScaling(aWidth, CMIDUtils::EHorizontal),
   222         iTextEdwin->SetSize(iUtils->DoScaling(aWidth, CMIDUtils::EHorizontal),
   224                             iUtils->DoScaling(aHeight, CMIDUtils::EVertical));
   223                             iUtils->DoScaling(aHeight, CMIDUtils::EVertical));
   225         // Update the size of the indicator. Height does not need to be
   224         // Update the size of the indicator. Height does not need to be
   226         // calculated.
   225         // calculated.
   258     DEBUG("CMIDTextEditor::EditorSize");
   257     DEBUG("CMIDTextEditor::EditorSize");
   259 
   258 
   260     TSize editorSize = iTextEdwin->Size();
   259     TSize editorSize = iTextEdwin->Size();
   261 
   260 
   262     // When scaling is on it has to descaled editor size.
   261     // When scaling is on it has to descaled editor size.
   263     if (iComponentContainer && iComponentContainer->IsFullScreen())
   262     if (IsScalingOn())
   264     {
   263     {
   265         editorSize = iUtils->DoDescaling(editorSize);
   264         editorSize = iUtils->DoDescaling(editorSize);
   266     }
   265     }
   267 
   266 
   268     return editorSize;
   267     return editorSize;
   312     }
   311     }
   313 
   312 
   314     // Store container. NULL is ok.
   313     // Store container. NULL is ok.
   315     iComponentContainer = aComponentContainer;
   314     iComponentContainer = aComponentContainer;
   316 
   315 
   317     if (iComponentContainer &&
   316     if (iComponentContainer)
   318             iComponentContainer->IsFullScreen())
       
   319     {
   317     {
   320         if (!iRowCountActive)
   318         if (!iRowCountActive)
   321         {
   319         {
   322             // When it is fullscreen we need call SetEditorSize to prevent wrong
   320             // We need call SetEditorSize to prevent wrong
   323             // scaling of TextEditor.
   321             // scaling of TextEditor.
   324             // (only for TextEditor not created with row counter)
   322             // (only for TextEditor not created with row counter)
   325             SetEditorSize(iTextEdwin->Size().iWidth, iTextEdwin->Size().iHeight);
   323             SetEditorSize(iTextEdwin->Size().iWidth, iTextEdwin->Size().iHeight);
   326         }
   324         }
       
   325         else
       
   326         {
       
   327             iNonScaledEditorSize = iTextEdwin->Size();
       
   328         }
   327         SetFontL(iNonScaledFont);
   329         SetFontL(iNonScaledFont);
       
   330     }
       
   331 
       
   332     if (iUtils)
       
   333     {
       
   334         // It sets edwin variables necessary for correct clipping.
       
   335         iTextEdwin->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect());
       
   336         iTextEdwin->SetScaling(IsScalingOn());
       
   337 
       
   338         // It sets indicator variables necessary for correct clipping.
       
   339         iEditingStateIndicator->SetScalingOn(IsScalingOn());
       
   340         iEditingStateIndicator->SetCanvasRect(iUtils->GetOnScreenCanvasRect());
   328     }
   341     }
   329 
   342 
   330     DEBUG("CMIDTextEditor::SetParentL -");
   343     DEBUG("CMIDTextEditor::SetParentL -");
   331 }
   344 }
   332 
   345 
   502     // and fullscreen mode changes.
   515     // and fullscreen mode changes.
   503     iNonScaledPosition = TPoint(aX, aY);
   516     iNonScaledPosition = TPoint(aX, aY);
   504 
   517 
   505     // If parent is in fullscreen mode then it tries scale input position.
   518     // If parent is in fullscreen mode then it tries scale input position.
   506     // Only setting otherwise.
   519     // Only setting otherwise.
   507     if (iComponentContainer && iComponentContainer->IsFullScreen())
   520     if (IsScalingOn())
   508     {
   521     {
   509         DEBUG_INT2("CMIDTextEditor::SetPosition DoScaling, aX=%d, aY=%d",
   522         DEBUG_INT2("CMIDTextEditor::SetPosition DoScaling, aX=%d, aY=%d",
   510                    iUtils->DoScaling(aX, CMIDUtils::EHorizontal),
   523                    iUtils->DoScaling(aX, CMIDUtils::EHorizontal),
   511                    iUtils->DoScaling(aY, CMIDUtils::EVertical));
   524                    iUtils->DoScaling(aY, CMIDUtils::EVertical));
   512         iTextEdwin->SetPosition(iUtils->DoScalingAndPositioning(TPoint(aX, aY)));
   525         iTextEdwin->SetPosition(iUtils->DoScalingAndPositioning(TPoint(aX, aY)));
   538     // to editor position on canvas.
   551     // to editor position on canvas.
   539     TPoint pos(aX, aY);
   552     TPoint pos(aX, aY);
   540     // If position will be found in formatted text, posInfo will be filled
   553     // If position will be found in formatted text, posInfo will be filled
   541     // with desired informations.
   554     // with desired informations.
   542     TTmPosInfo2 posInfo;
   555     TTmPosInfo2 posInfo;
   543     
   556 
   544     if (iTextEdwin->TextLayout()->FindXyPos(pos, posInfo))
   557     if (iTextEdwin->TextLayout()->FindXyPos(pos, posInfo))
   545     {
   558     {
   546         // Position was found. Try to set cursor to found position.
   559         // Position was found. Try to set cursor to found position.
   547         iTextEdwin->SetCursorPosL(posInfo.iDocPos.iPos, EFalse);
   560         iTextEdwin->SetCursorPosL(posInfo.iDocPos.iPos, EFalse);
   548     }
   561     }
   549 
   562 
   550     DEBUG("CMIDTextEditor::SetCaretXYL -");    
   563     DEBUG("CMIDTextEditor::SetCaretXYL -");
   551 }
   564 }
   552 
   565 
   553 // ---------------------------------------------------------------------------
   566 // ---------------------------------------------------------------------------
   554 // CMIDTextEditor::SetFocusStateL
   567 // CMIDTextEditor::SetFocusStateL
   555 // (other items are commented in the header file)
   568 // (other items are commented in the header file)
   580             DEBUG("CMIDTextEditor::SetFocusStateL, hiding cursor");
   593             DEBUG("CMIDTextEditor::SetFocusStateL, hiding cursor");
   581 
   594 
   582             iTextEdwin->SetCursorVisible(EFalse);
   595             iTextEdwin->SetCursorVisible(EFalse);
   583         }
   596         }
   584         else if (iEditingStateIndicator->EnabledState() ==
   597         else if (iEditingStateIndicator->EnabledState() ==
   585             CMIDEditingStateIndicator::EIndicatorStateRelative)
   598                  CMIDEditingStateIndicator::EIndicatorStateRelative)
   586         {
   599         {
   587             // Enable the custom indicators as in Avkon if not controlled
   600             // Enable the custom indicators as in Avkon if not controlled
   588             // by the client application
   601             // by the client application
   589             iEditingStateIndicator->MakeVisible(ETrue);
   602             iEditingStateIndicator->MakeVisible(ETrue);
   590         }
   603         }
   904     TInt rowCount = iTextEdwin->NumberOfLines();
   917     TInt rowCount = iTextEdwin->NumberOfLines();
   905     TInt height = lineHeight * rowCount;
   918     TInt height = lineHeight * rowCount;
   906 
   919 
   907     // If parent is in fullscreen mode,
   920     // If parent is in fullscreen mode,
   908     // then content height has to be descaled.
   921     // then content height has to be descaled.
   909     if (iComponentContainer && iComponentContainer->IsFullScreen())
   922     if (IsScalingOn())
   910     {
   923     {
   911         height = iUtils->DoDescaling(height, CMIDUtils::EHorizontal);
   924         height = iUtils->DoDescaling(height, CMIDUtils::EHorizontal);
   912     }
   925     }
   913 
   926 
   914     DEBUG_INT("CMIDTextEditor::ContentHeight - , contentHeight=%d",
   927     DEBUG_INT("CMIDTextEditor::ContentHeight - , contentHeight=%d",
  1074 
  1087 
  1075     // Do nothing if the editor state is equal to the requested state or
  1088     // Do nothing if the editor state is equal to the requested state or
  1076     // if the constraint modifier PASSWORD is set. Passwords are single
  1089     // if the constraint modifier PASSWORD is set. Passwords are single
  1077     // line editors due to CMIDEdwinUtils::CPasswordText implementation.
  1090     // line editors due to CMIDEdwinUtils::CPasswordText implementation.
  1078     if (aMultiline == iTextEdwin->IsWrapEnabled() ||
  1091     if (aMultiline == iTextEdwin->IsWrapEnabled() ||
  1079         iConstraints & MMIDTextField::EPassword)
  1092             iConstraints & MMIDTextField::EPassword)
  1080     {
  1093     {
  1081         DEBUG("CMIDTextEditor::SetMultilineL -, ignoring request");
  1094         DEBUG("CMIDTextEditor::SetMultilineL -, ignoring request");
  1082 
  1095 
  1083         return;
  1096         return;
  1084     }
  1097     }
  1102     iTextEdwin->SetWordWrapL(aMultiline);
  1115     iTextEdwin->SetWordWrapL(aMultiline);
  1103     // Text has been changed so inform the editor window that
  1116     // Text has been changed so inform the editor window that
  1104     // it needs to redraw itself again.
  1117     // it needs to redraw itself again.
  1105     iTextEdwin->HandleTextChangedL();
  1118     iTextEdwin->HandleTextChangedL();
  1106     // Cursor position handling is done in CMIDTextEditorEdwin
  1119     // Cursor position handling is done in CMIDTextEditorEdwin
  1107     iTextEdwin->SetCursorPosL(iTextEdwin->CursorPos(), EFalse); 
  1120     iTextEdwin->SetCursorPosL(iTextEdwin->CursorPos(), EFalse);
  1108 
  1121 
  1109     DEBUG("CMIDTextEditor::SetMultilineL -");
  1122     DEBUG("CMIDTextEditor::SetMultilineL -");
  1110 }
  1123 }
  1111 
  1124 
  1112 // ---------------------------------------------------------------------------
  1125 // ---------------------------------------------------------------------------
  1333 {
  1346 {
  1334     DEBUG("CMIDTextEditor::SetFontL +");
  1347     DEBUG("CMIDTextEditor::SetFontL +");
  1335 
  1348 
  1336     TFontSpec fontspec = (aFont->Font(ETrue))->FontSpecInTwips();
  1349     TFontSpec fontspec = (aFont->Font(ETrue))->FontSpecInTwips();
  1337     // If scaling is on, this code does scaling of size of font.
  1350     // If scaling is on, this code does scaling of size of font.
  1338     if (iComponentContainer && iComponentContainer->IsFullScreen())
  1351     if (IsScalingOn())
  1339     {
  1352     {
  1340         fontspec.iHeight=iUtils->DoScaling(fontspec.iHeight, CMIDUtils::EVertical);
  1353         fontspec.iHeight=iUtils->DoScaling(fontspec.iHeight, CMIDUtils::EVertical);
  1341     }
  1354     }
  1342 
  1355 
  1343     TCharFormat charFormat(fontspec.iTypeface.iName, fontspec.iHeight);
  1356     TCharFormat charFormat(fontspec.iTypeface.iName, fontspec.iHeight);
  1970 
  1983 
  1971 // ---------------------------------------------------------------------------
  1984 // ---------------------------------------------------------------------------
  1972 // CMIDTextEditor::CMIDTextEditor
  1985 // CMIDTextEditor::CMIDTextEditor
  1973 // ---------------------------------------------------------------------------
  1986 // ---------------------------------------------------------------------------
  1974 //
  1987 //
  1975 CMIDTextEditor::CMIDTextEditor() : iNonScaledFont(NULL),
  1988 CMIDTextEditor::CMIDTextEditor() : iNonScaledFont(NULL)
  1976         iNonScaledPosition(),
       
  1977         iNonScaledEditorSize()
       
  1978 {
  1989 {
  1979     // No implementation.
  1990     // No implementation.
  1980 }
  1991 }
  1981 
  1992 
  1982 // ---------------------------------------------------------------------------
  1993 // ---------------------------------------------------------------------------
  2106         }
  2117         }
  2107     }
  2118     }
  2108 
  2119 
  2109     // restoring of iRowCountActive
  2120     // restoring of iRowCountActive
  2110     iRowCountActive = rowCountActive;
  2121     iRowCountActive = rowCountActive;
       
  2122 
       
  2123     if (iUtils)
       
  2124     {
       
  2125         // It sets edwin variables necessary for correct clipping.
       
  2126         iTextEdwin->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect());
       
  2127         iTextEdwin->SetScaling(IsScalingOn());
       
  2128 
       
  2129         // It sets indicator variables necessary for correct clipping.
       
  2130         iEditingStateIndicator->SetScalingOn(IsScalingOn());
       
  2131         iEditingStateIndicator->SetCanvasRect(iUtils->GetOnScreenCanvasRect());
       
  2132     }
  2111 }
  2133 }
  2112 
  2134 
  2113 // ---------------------------------------------------------------------------
  2135 // ---------------------------------------------------------------------------
  2114 // CMIDTextEditor::HandleResolutionChange
  2136 // CMIDTextEditor::HandleResolutionChange
  2115 // (other items were commented in a header
  2137 // (other items were commented in a header
  2116 // ---------------------------------------------------------------------------
  2138 // ---------------------------------------------------------------------------
  2117 //
  2139 //
  2118 void CMIDTextEditor::HandleResolutionChange()
  2140 void CMIDTextEditor::HandleResolutionChange()
  2119 {
  2141 {
  2120     // Reset of scaling data is needed, because size of screen is changed.
       
  2121     iUtils->ResetScalingData();
       
  2122 
       
  2123     // It is needed to store iRowCountActive, because SetEditorSize resets it.
  2142     // It is needed to store iRowCountActive, because SetEditorSize resets it.
  2124     TBool rowCountActive = iRowCountActive;
  2143     TBool rowCountActive = iRowCountActive;
  2125 
  2144 
  2126     // Calling all functions which sets sizes and position of TextEditor.
  2145     // Calling all functions which sets sizes and position of TextEditor.
  2127     SetEditorSize(iNonScaledEditorSize.iWidth, iNonScaledEditorSize.iHeight);
  2146     SetEditorSize(iNonScaledEditorSize.iWidth, iNonScaledEditorSize.iHeight);
  2135         }
  2154         }
  2136     }
  2155     }
  2137 
  2156 
  2138     // restoring of iRowCountActive
  2157     // restoring of iRowCountActive
  2139     iRowCountActive = rowCountActive;
  2158     iRowCountActive = rowCountActive;
       
  2159 
       
  2160     if (iUtils)
       
  2161     {
       
  2162         // It sets edwin variable necessary for correct clipping.
       
  2163         iTextEdwin->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect());
       
  2164 
       
  2165         // It sets indicator variable necessary for correct clipping.
       
  2166         iEditingStateIndicator->SetCanvasRect(iUtils->GetOnScreenCanvasRect());
       
  2167     }
       
  2168 }
       
  2169 
       
  2170 TBool CMIDTextEditor::IsScalingOn() const
       
  2171 {
       
  2172     return iUtils && iComponentContainer && iUtils->IsScalingEnabled() &&
       
  2173            iComponentContainer->IsFullScreen();
  2140 }
  2174 }
  2141 
  2175 
  2142 // End of file
  2176 // End of file