19 #include <MMIDCustomComponentContainer.h> |
19 #include <MMIDCustomComponentContainer.h> |
20 #include <lcdui.h> |
20 #include <lcdui.h> |
21 #include <aknappui.h> |
21 #include <aknappui.h> |
22 #include <aknnavi.h> |
22 #include <aknnavi.h> |
23 #include <j2me/jdebug.h> |
23 #include <j2me/jdebug.h> |
|
24 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
25 // Used with partial VKB |
|
26 #include <AknPriv.hrh> |
|
27 #endif // RD_JAVA_S60_RELEASE_9_2 |
24 |
28 |
25 // INTERNAL INCLUDES |
29 // INTERNAL INCLUDES |
26 #include "CMIDTextEditor.h" |
30 #include "CMIDTextEditor.h" |
27 #include "CMIDTextEditorEdwin.h" |
31 #include "CMIDTextEditorEdwin.h" |
28 #include "CMIDEditingStateIndicator.h" |
32 #include "CMIDEditingStateIndicator.h" |
156 // |
162 // |
157 void CMIDTextEditor::CustomComponentContainerDisposing() |
163 void CMIDTextEditor::CustomComponentContainerDisposing() |
158 { |
164 { |
159 DEBUG("CMIDTextEditor::CustomComponentContainerDisposing +"); |
165 DEBUG("CMIDTextEditor::CustomComponentContainerDisposing +"); |
160 |
166 |
161 // Remove container association. |
167 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
168 if (iFocusState) |
|
169 { |
|
170 iTextEdwin->CloseVKB(); |
|
171 } |
|
172 #endif // RD_JAVA_S60_RELEASE_9_2 |
|
173 |
|
174 // Call SetFocus on edwin |
|
175 iTextEdwin->SetFocus(EFalse); |
|
176 // Disable the custom indicators as in Avkon if not controlled by |
|
177 // the client application. |
|
178 if (iEditingStateIndicator->EnabledState() == |
|
179 CMIDEditingStateIndicator::EIndicatorStateRelative) |
|
180 { |
|
181 iEditingStateIndicator->MakeVisible(EFalse); |
|
182 } |
|
183 // Set editor window uninitialized |
|
184 iTextEdwin->Uninitialize(); |
162 iComponentContainer = NULL; |
185 iComponentContainer = NULL; |
163 |
|
164 // Uninitialize the text editor window. |
|
165 iTextEdwin->Uninitialize(); |
|
166 |
|
167 DEBUG("CMIDTextEditor::CustomComponentContainerDisposing -"); |
186 DEBUG("CMIDTextEditor::CustomComponentContainerDisposing -"); |
168 } |
187 } |
169 |
188 |
170 // --------------------------------------------------------------------------- |
189 // --------------------------------------------------------------------------- |
171 // CMIDTextEditor::SetObserver |
190 // CMIDTextEditor::SetObserver |
330 else |
349 else |
331 { |
350 { |
332 iNonScaledEditorSize = iTextEdwin->Size(); |
351 iNonScaledEditorSize = iTextEdwin->Size(); |
333 } |
352 } |
334 SetFontL(iNonScaledFont); |
353 SetFontL(iNonScaledFont); |
335 } |
354 |
336 |
355 if (iUtils) |
337 if (iUtils) |
356 { |
338 { |
357 // It sets edwin variables necessary for correct clipping. |
339 // It sets edwin variables necessary for correct clipping. |
358 iTextEdwin->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect()); |
340 iTextEdwin->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect()); |
359 iTextEdwin->SetScaling(IsScalingOn()); |
341 iTextEdwin->SetScaling(IsScalingOn()); |
360 |
342 |
361 // It sets indicator variables necessary for correct clipping. |
343 // It sets indicator variables necessary for correct clipping. |
362 iEditingStateIndicator->SetScalingOn(IsScalingOn()); |
344 iEditingStateIndicator->SetScalingOn(IsScalingOn()); |
363 iEditingStateIndicator->SetCanvasRect(iUtils->GetOnScreenCanvasRect()); |
345 iEditingStateIndicator->SetCanvasRect(iUtils->GetOnScreenCanvasRect()); |
364 } |
346 } |
365 } |
347 |
366 |
348 DEBUG("CMIDTextEditor::SetParentL -"); |
367 DEBUG("CMIDTextEditor::SetParentL -"); |
349 } |
368 } |
350 |
369 |
351 // --------------------------------------------------------------------------- |
370 // --------------------------------------------------------------------------- |
352 // CMIDTextEditor::SetDirectContainerL |
371 // CMIDTextEditor::SetDirectContainerL |
462 iFocusState = EFalse; |
481 iFocusState = EFalse; |
463 SetFocusStateL(ETrue); |
482 SetFocusStateL(ETrue); |
464 // Cursor is not shown automatically if the editor has focus. |
483 // Cursor is not shown automatically if the editor has focus. |
465 // So, set cursor visible. |
484 // So, set cursor visible. |
466 iTextEdwin->SetCursorVisible(ETrue); |
485 iTextEdwin->SetCursorVisible(ETrue); |
467 |
|
468 } |
486 } |
469 else |
487 else |
470 { |
488 { |
471 // MakeVisible automatically selects the editor's content |
489 // MakeVisible automatically selects the editor's content |
472 // Remove the selection at this point. The selection can be |
490 // Remove the selection at this point. The selection can be |
473 // set again with the API. |
491 // set again with the API. |
474 SetCursorPositionL(iTextEdwin->CursorPos()); |
492 SetCursorPositionL(iTextEdwin->CursorPos()); |
|
493 iTextEdwin->Redraw(); |
475 } |
494 } |
476 } |
495 } |
477 else if (!aVisible && iTextEdwin->IsVisible()) |
496 else if (!aVisible && iTextEdwin->IsVisible()) |
478 { |
497 { |
479 DEBUG("CMIDTextEditor::SetVisibleL, setting editor hidden"); |
498 DEBUG("CMIDTextEditor::SetVisibleL, setting editor hidden"); |
488 // Hide the text editor when it is visible. |
507 // Hide the text editor when it is visible. |
489 iTextEdwin->MakeVisible(EFalse); |
508 iTextEdwin->MakeVisible(EFalse); |
490 |
509 |
491 // Always disable indicator if the editor is hidden. |
510 // Always disable indicator if the editor is hidden. |
492 iEditingStateIndicator->MakeVisible(EFalse); |
511 iEditingStateIndicator->MakeVisible(EFalse); |
493 } |
512 iTextEdwin->Redraw(); |
494 |
513 } |
495 iTextEdwin->Redraw(); |
|
496 |
514 |
497 DEBUG("CMIDTextEditor::SetVisibleL -"); |
515 DEBUG("CMIDTextEditor::SetVisibleL -"); |
498 } |
516 } |
499 |
517 |
500 // --------------------------------------------------------------------------- |
518 // --------------------------------------------------------------------------- |
580 |
598 |
581 if ((aFocusState) && !(iFocusState)) |
599 if ((aFocusState) && !(iFocusState)) |
582 { |
600 { |
583 // Set focus if the text editor is not focused |
601 // Set focus if the text editor is not focused |
584 iFocusState = ETrue; |
602 iFocusState = ETrue; |
585 // Call SetFocus on edwin |
603 |
586 iTextEdwin->SetFocus(ETrue); |
|
587 // Send the information about new focused component to parent |
604 // Send the information about new focused component to parent |
588 iComponentContainer->SetFocusedComponent(this); |
605 iComponentContainer->SetFocusedComponent(this); |
589 |
606 |
590 // Set focus automatically selects the editor's content |
607 // If the editor is visible, give him focus. |
591 // Remove the selection at this point. The selection can be |
608 if (iTextEdwin->IsVisible()) |
592 // set again with the API. |
609 { |
593 SetCursorPositionL(iTextEdwin->CursorPos()); |
610 DEBUG("CMIDTextEditor::SetFocusStateL, visible - iTextEdwin->setFocus(true)"); |
594 |
611 // Call SetFocus on edwin |
595 // If the editor is not visible. do not show the cursor either. |
612 iTextEdwin->SetFocus(ETrue); |
596 if (!iTextEdwin->IsVisible()) |
613 // Set focus automatically selects the editor's content |
597 { |
614 // Remove the selection at this point. The selection can be |
598 DEBUG("CMIDTextEditor::SetFocusStateL, hiding cursor"); |
615 // set again with the API. |
599 |
616 SetCursorPositionL(iTextEdwin->CursorPos()); |
600 iTextEdwin->SetCursorVisible(EFalse); |
617 |
601 } |
618 if (iEditingStateIndicator->EnabledState() == |
602 else if (iEditingStateIndicator->EnabledState() == |
619 CMIDEditingStateIndicator::EIndicatorStateRelative) |
603 CMIDEditingStateIndicator::EIndicatorStateRelative) |
620 { |
604 { |
621 // Enable the custom indicators as in Avkon if not controlled |
605 // Enable the custom indicators as in Avkon if not controlled |
622 // by the client application |
606 // by the client application |
623 iEditingStateIndicator->MakeVisible(ETrue); |
607 iEditingStateIndicator->MakeVisible(ETrue); |
624 } |
|
625 iTextEdwin->Redraw(); |
608 } |
626 } |
609 } |
627 } |
610 else if (!(aFocusState) && (iFocusState)) |
628 else if (!(aFocusState) && (iFocusState)) |
611 { |
629 { |
612 // Remove focus if the text editor is focused. |
630 // Remove focus if the text editor is focused. |
2119 // (other items were commented in a header |
2136 // (other items were commented in a header |
2120 // --------------------------------------------------------------------------- |
2137 // --------------------------------------------------------------------------- |
2121 // |
2138 // |
2122 void CMIDTextEditor::HandleFullscreenModeChange() |
2139 void CMIDTextEditor::HandleFullscreenModeChange() |
2123 { |
2140 { |
|
2141 if (iUtils && iUtils->IsScalingEnabled()) |
|
2142 { |
|
2143 // We need reposition text editor. |
|
2144 HandleChangeForScaling(EFullscreenChange); |
|
2145 } |
|
2146 } |
|
2147 |
|
2148 TBool CMIDTextEditor::IsScalingOn() const |
|
2149 { |
|
2150 return iUtils && iComponentContainer && iUtils->IsScalingEnabled() |
|
2151 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
2152 && !iPartialVKBOpen |
|
2153 #endif // RD_JAVA_S60_RELEASE_9_2 |
|
2154 && iComponentContainer->IsFullScreen(); |
|
2155 } |
|
2156 |
|
2157 void CMIDTextEditor::HandleResourceChange(TInt aType) |
|
2158 { |
|
2159 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
2160 if ((aType == KAknSplitInputEnabled) || |
|
2161 (aType == KAknSplitInputDisabled)) |
|
2162 { |
|
2163 iPartialVKBOpen = (aType == KAknSplitInputEnabled); |
|
2164 if (iTextEdwin && iTextEdwin->IsFocused()) |
|
2165 { |
|
2166 // Inform edwin about the event. |
|
2167 iTextEdwin->HandleResourceChange(aType); |
|
2168 } |
|
2169 |
|
2170 if (iUtils && iComponentContainer && iUtils->IsScalingEnabled() && |
|
2171 iComponentContainer->IsFullScreen()) |
|
2172 { |
|
2173 // Reposition the text editor. |
|
2174 HandleChangeForScaling(EPartialVKBChange); |
|
2175 } |
|
2176 } |
|
2177 #endif // RD_JAVA_S60_RELEASE_9_2 |
|
2178 |
|
2179 if (aType == KEikDynamicLayoutVariantSwitch) |
|
2180 { |
|
2181 if (iUtils && iComponentContainer && iUtils->IsScalingEnabled() && |
|
2182 iComponentContainer->IsFullScreen()) |
|
2183 { |
|
2184 // Reposition the text editor. |
|
2185 HandleChangeForScaling(EResolutionChange); |
|
2186 } |
|
2187 } |
|
2188 } |
|
2189 |
|
2190 void CMIDTextEditor::HandleChangeForScaling(TChange aChange) |
|
2191 { |
2124 // It is needed to store iRowCountActive, because SetEditorSize resets it. |
2192 // It is needed to store iRowCountActive, because SetEditorSize resets it. |
2125 TBool rowCountActive = iRowCountActive; |
2193 TBool rowCountActive = iRowCountActive; |
2126 |
2194 |
2127 // Calling all functions which sets sizes and position of TextEditor. |
2195 // Calling all functions which sets sizes and position of TextEditor. |
2128 SetEditorSize(iNonScaledEditorSize.iWidth, iNonScaledEditorSize.iHeight); |
2196 SetEditorSize(iNonScaledEditorSize.iWidth, iNonScaledEditorSize.iHeight); |
2137 } |
2205 } |
2138 |
2206 |
2139 // restoring of iRowCountActive |
2207 // restoring of iRowCountActive |
2140 iRowCountActive = rowCountActive; |
2208 iRowCountActive = rowCountActive; |
2141 |
2209 |
2142 if (iUtils) |
2210 if ((aChange == EFullscreenChange) || (aChange == EResolutionChange)) |
2143 { |
2211 { |
2144 // It sets edwin variables necessary for correct clipping. |
2212 if (iUtils) |
2145 iTextEdwin->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect()); |
2213 { |
2146 iTextEdwin->SetScaling(IsScalingOn()); |
2214 // It sets edwin variable necessary for correct clipping. |
2147 |
2215 iTextEdwin->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect()); |
2148 // It sets indicator variables necessary for correct clipping. |
2216 |
2149 iEditingStateIndicator->SetScalingOn(IsScalingOn()); |
2217 // It sets indicator variable necessary for correct clipping. |
2150 iEditingStateIndicator->SetCanvasRect(iUtils->GetOnScreenCanvasRect()); |
2218 iEditingStateIndicator->SetCanvasRect(iUtils->GetOnScreenCanvasRect()); |
2151 } |
2219 } |
2152 } |
2220 if (aChange == EFullscreenChange) |
2153 |
2221 { |
2154 // --------------------------------------------------------------------------- |
2222 // If scaling is turn on or off, we need to inform edwin |
2155 // CMIDTextEditor::HandleResolutionChange |
2223 // and indicator about that. |
2156 // (other items were commented in a header |
2224 iTextEdwin->SetScaling(IsScalingOn()); |
2157 // --------------------------------------------------------------------------- |
2225 iEditingStateIndicator->SetScalingOn(IsScalingOn()); |
2158 // |
2226 } |
2159 void CMIDTextEditor::HandleResolutionChange() |
2227 } |
2160 { |
2228 |
2161 // It is needed to store iRowCountActive, because SetEditorSize resets it. |
2229 #ifdef RD_JAVA_S60_RELEASE_9_2 |
2162 TBool rowCountActive = iRowCountActive; |
2230 if (aChange == EPartialVKBChange) |
2163 |
2231 { |
2164 // Calling all functions which sets sizes and position of TextEditor. |
2232 if (iPartialVKBOpen) |
2165 SetEditorSize(iNonScaledEditorSize.iWidth, iNonScaledEditorSize.iHeight); |
2233 { |
2166 SetPosition(iNonScaledPosition.iX, iNonScaledPosition.iY); |
2234 // When partial keyboard is opening, the scalingmust be stoped. |
2167 if (iNonScaledFont) |
2235 // Setting edwin's variables, it is necessary for correct clipping. |
2168 { |
2236 iTextEdwin->SetOnScreenCanvasRect(iComponentContainer->Control().Rect()); |
2169 TRAPD(err, SetFontL(iNonScaledFont)); |
2237 iTextEdwin->SetScaling(EFalse); |
2170 if (err != KErrNone) |
2238 |
2171 { |
2239 // Setting indicator's variables, it is necessary for correct clipping. |
2172 DEBUG_INT("CMIDTextEditor::HandleFullscreenModeChange - error %d", err); |
2240 iEditingStateIndicator->SetScalingOn(EFalse); |
2173 } |
2241 iEditingStateIndicator->SetCanvasRect(iComponentContainer->Control().Rect()); |
2174 } |
2242 } |
2175 |
2243 else if (iUtils) |
2176 // restoring of iRowCountActive |
2244 { |
2177 iRowCountActive = rowCountActive; |
2245 // When partial keybord is closing, the scaling needs to be restored. |
2178 |
2246 // Setting edwin's variables, it is necessary for correct clipping. |
2179 if (iUtils) |
2247 iTextEdwin->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect()); |
2180 { |
2248 iTextEdwin->SetScaling(IsScalingOn()); |
2181 // It sets edwin variable necessary for correct clipping. |
2249 |
2182 iTextEdwin->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect()); |
2250 // Setting indicator's variables, it is necessary for correct clipping. |
2183 |
2251 iEditingStateIndicator->SetScalingOn(IsScalingOn()); |
2184 // It sets indicator variable necessary for correct clipping. |
2252 iEditingStateIndicator->SetCanvasRect(iUtils->GetOnScreenCanvasRect()); |
2185 iEditingStateIndicator->SetCanvasRect(iUtils->GetOnScreenCanvasRect()); |
2253 } |
2186 } |
2254 } |
2187 } |
2255 #endif // RD_JAVA_S60_RELEASE_9_2 |
2188 |
|
2189 TBool CMIDTextEditor::IsScalingOn() const |
|
2190 { |
|
2191 return iUtils && iComponentContainer && iUtils->IsScalingEnabled() && |
|
2192 iComponentContainer->IsFullScreen(); |
|
2193 } |
2256 } |
2194 |
2257 |
2195 // End of file |
2258 // End of file |