Update contrib.
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
23 #include "OstTraceDefinitions.h"
24 #ifdef OST_TRACE_COMPILER_IN_USE
25 #include "FRMSCRNDTraces.h"
28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
29 #include "FRMCONST_INTERNAL.H"
30 #include "FRMCONST_PARTNER.H"
31 #include "TAGMA_INTERNAL.H"
34 RScreenDisplay::RScreenDisplay(TDrawTextLayoutContext* const aDrawTextLayoutContext):
39 iDrawTextLayoutContext(aDrawTextLayoutContext),
40 iBackground(KRgbWhite)
44 void RScreenDisplay::Close()
51 void RScreenDisplay::Destroy()
59 void RScreenDisplay::DestroyContexts()
61 //Destroy the graphics contexts
70 void RScreenDisplay::ActivateContext()
74 iBackground = iDrawTextLayoutContext->iBackgroundColor;
75 const MFormParam* p = MFormParam::Get();
76 FormUtil::LogicalToActualColor(p,iBackground);
79 void RScreenDisplay::ActivateContext(CGraphicsContext *aGc)
81 //Activate a gc on the current window
85 //__ASSERT_DEBUG(aGc!=NULL,FormPanic());
87 ((CWindowGc *) aGc)->Activate(*iWin);
90 void RScreenDisplay::DeactivateContext()
93 DeactivateContext(iGc);
96 void RScreenDisplay::DeactivateContext(CGraphicsContext *aGc)
98 //Deactivate a gc on the current window
102 //__ASSERT_DEBUG(aGc!=NULL,FormPanic());
104 ((CWindowGc *) aGc)->Deactivate();
107 void RScreenDisplay::CreateContextL()
109 //Create and activate the main Graphics Context
114 OstTrace0( TRACE_DUMP, RSCREENDISPLAY_CREATECONTEXTL, "EFGcNotSet" );
116 __ASSERT_DEBUG(iGc==NULL,FormPanic(EFGcNotSet));
117 User::LeaveIfError(iGd->CreateBitmapContext(iGc));
119 iDrawTextLayoutContext->SetWindowGc((CWindowGc *)iGc);
121 iDrawTextLayoutContext->SetBitmapGc(iGc);
124 void RScreenDisplay::CreateContextL(CBitmapDevice *aGd)
126 //Create and activate the main Graphics Context
129 CBitmapContext* localGc;
131 //__ASSERT_DEBUG(iGc==NULL,FormPanic(EFGcNotSet));
132 User::LeaveIfError(aGd->CreateBitmapContext(localGc));
138 iDrawTextLayoutContext->SetWindowGc((CWindowGc *)iGc);
140 iDrawTextLayoutContext->SetBitmapGc(iGc);
143 void RScreenDisplay::SetWindow(RWindow *aWin)
150 void RScreenDisplay::SetGraphicsDeviceL(CBitmapDevice *aGd)
159 void RScreenDisplay::SetInvalidRect(const TRect& aRect)
166 void RScreenDisplay::SetInvalidRect(TInt aHeight)
168 //Set the clipping region to the top or bottom abs(aHeight) pixels of the screen
169 //aHeight<0 ==> bottom of the screen
173 iInvalidRect=iDrawTextLayoutContext->iViewRect;
175 iInvalidRect.iTl.iY=iInvalidRect.iBr.iY+aHeight;
177 iInvalidRect.iBr.iY=iInvalidRect.iTl.iY+aHeight;
180 void RScreenDisplay::SetInvalidRectHorizontal(TInt aWidth)
182 //Set the clipping region to the left or right abs(aHeight) pixels of the screen
183 //aWidth<0 ==> right of the screen
187 iInvalidRect=iDrawTextLayoutContext->TextArea();
189 iInvalidRect.iTl.iX=iInvalidRect.iBr.iX+aWidth;
191 iInvalidRect.iBr.iX=iInvalidRect.iTl.iX+aWidth;
194 void RScreenDisplay::SetRects(TUint aRects)
196 //Set the clipping region to the union of rectangles specified in the enum
203 void RScreenDisplay::AddRects(TUint aRects)
210 void RScreenDisplay::SubRects(TUint aRects)
214 iRects&=EFClipAllFlags-aRects;
218 TRect RScreenDisplay::ClippingRect()
222 TRect clipRect(iDrawTextLayoutContext->iViewRect);
224 if (!(iRects&EFClipViewRect))
226 if (iRects&EFClipTextArea)
227 clipRect=iDrawTextLayoutContext->TextArea();
228 else if (iRects&EFClipLineCursor)
229 clipRect=LineCursorMargin();
230 if (iRects&EFClipExtendedViewRect && iTextLayout)
231 iTextLayout->HighlightExtensions().ExtendRect(clipRect);
232 if (iRects&EFClipExtendedTextArea)
234 clipRect=iDrawTextLayoutContext->TextArea();
236 iTextLayout->HighlightExtensions().ExtendRect(clipRect);
239 if (iRects&EFClipInvalid)
240 clipRect.Intersection(iInvalidRect);
245 void RScreenDisplay::ResetClippingRect()
247 TRect clipRect=ClippingRect();
248 iGc->SetClippingRect(clipRect);
251 void RScreenDisplay::BlastBitmap(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aRect)
253 // Blast bitmap to screen
256 iGc->BitBlt(aPoint,aBitmap,aRect);
259 void RScreenDisplay::DrawPictureFrame(TFrameOverlay* aPictureFrame,const TRect& aLineRect)
261 // Draw a frame overlay, using XOR brush. Therefore if frame visible, the frame will disappear,
265 TRect clipRect=ClippingRect();
266 clipRect.Intersection(aLineRect);
267 iGc->SetClippingRect(clipRect);
268 iGc->SetPenSize(TSize(1,1));
269 aPictureFrame->XorDraw(*iGc);
273 void RScreenDisplay::Invalidate(TRect aRect)
275 //Invalidate the view rect
279 iWin->Invalidate(aRect);
282 void RScreenDisplay::SetTextCursor(TPoint aPos, const TTextCursor &aCursor)
284 //Display a cursor at position aPos
287 if (iWin && iGroupWin)
289 aPos.iX+=iDrawTextLayoutContext->iTextStartX;
290 iGroupWin->SetTextCursor(*iWin,aPos,aCursor,iDrawTextLayoutContext->TextArea());
294 void RScreenDisplay::RemoveTextCursor()
296 //Remove cursor from window
301 iGroupWin->CancelTextCursor();
304 void RScreenDisplay::ClearRect(const TRect& aRect)
306 //Clear a rectangle on the screen
311 TPoint top_left = iDrawTextLayoutContext->TopLeftText();
312 iTextLayout->DrawBackground(*iGc,top_left,aRect,iBackground);
317 iGc->SetBrushColor(iBackground);
322 void RScreenDisplay::InvertRect(TRect aRect,const TRgb aInvertColor)
324 aRect.Move(iDrawTextLayoutContext->iTextStartX,0);
325 iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
326 iGc->SetBrushColor(aInvertColor);
328 iGc->SetBrushColor(iBackground);
329 iGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
332 void RScreenDisplay::Scroll(TRect aRect,const TPoint& aBy,TBool aScrollBackground)
336 if (!aScrollBackground || (iTextLayout && iTextLayout->CustomDraw()))
339 iWin->Invalidate(aRect);
342 iWin->Scroll(aBy,aRect);
347 void RScreenDisplay::Flush()
353 TBool RScreenDisplay::IsLineCursor() const
355 return iDrawTextLayoutContext->IsGutterMargin();
358 TRect RScreenDisplay::LineCursorMargin() const
360 return iDrawTextLayoutContext->GutterMargin();
363 TPoint RScreenDisplay::TopLeftTextArea() const
365 return iDrawTextLayoutContext->TopLeftTextArea();
368 void RScreenDisplay::SetLayout(CTextLayout* aLayout)
370 iTextLayout = aLayout;
371 iTextLayout->SetWindow(iWin);
374 CTextLayout* RScreenDisplay::Layout()
379 TBool RScreenDisplay::UseWindowGc() const
381 return iDrawTextLayoutContext->UseWindowGc();