|
1 |
|
2 /* |
|
3 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 * All rights reserved. |
|
5 * This component and the accompanying materials are made available |
|
6 * under the terms of "Eclipse Public License v1.0" |
|
7 * which accompanies this distribution, and is available |
|
8 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 * |
|
10 * Initial Contributors: |
|
11 * Nokia Corporation - initial contribution. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Defines custom drawing for text editor edwin. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INTERNAL INCLUDES |
|
21 #include "CMIDTextEditorEdwinCustomDraw.h" |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <j2me/jdebug.h> |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // CMIDTextEditorEdwinCustomDraw::CMIDTextEditorEdwinCustomDraw |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CMIDTextEditorEdwinCustomDraw::CMIDTextEditorEdwinCustomDraw( |
|
31 const MLafEnv& aLafEnv, |
|
32 const MFormCustomDraw& aParentDraw, |
|
33 const CMIDTextEditorEdwin& aEdwin) : |
|
34 CLafEdwinCustomDrawBase(aLafEnv, aEdwin), |
|
35 iEdwin(aEdwin), iParentDraw(aParentDraw) |
|
36 { |
|
37 DEBUG("CMIDTextEditorEdwinCustomDraw::CMIDTextEditorEdwinCustomDraw"); |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CMIDTextEditorEdwinCustomDraw::~CMIDTextEditorEdwinCustomDraw |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CMIDTextEditorEdwinCustomDraw::~CMIDTextEditorEdwinCustomDraw() |
|
45 { |
|
46 DEBUG("CMIDTextEditorEdwinCustomDraw::~CMIDTextEditorEdwinCustomDraw"); |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CMIDTextEditorEdwinCustomDraw::DrawBackground |
|
51 // (other items were commented in the header file) |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 void CMIDTextEditorEdwinCustomDraw::DrawBackground( |
|
55 const TParam& aParam, |
|
56 const TRgb& aBackground, |
|
57 TRect& aDrawn) const |
|
58 { |
|
59 // Background drawing is not done by custom draw. |
|
60 |
|
61 // Check if CCoeControl::Draw() has been invoked for the editor window. |
|
62 // This guarantees that draw is not invoked all the time. Redraw |
|
63 // removes the issue with background transparency because if FEP tries |
|
64 // to draw the text without the CONE control framework, the editor gets |
|
65 // redrawn which guarantees that the text is not messed up due to |
|
66 // the editor's transparency. |
|
67 |
|
68 if (iEdwin.IsTransparent()) |
|
69 { |
|
70 iEdwin.Redraw(); |
|
71 } |
|
72 else |
|
73 { |
|
74 iParentDraw.DrawBackground(aParam, aBackground, aDrawn); |
|
75 } |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CMIDTextEditorEdwinCustomDraw::DrawLineGraphics |
|
80 // (other items were commented in the header file) |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CMIDTextEditorEdwinCustomDraw::DrawLineGraphics( |
|
84 const TParam& aParam, |
|
85 const TLineInfo& aLineInfo) const |
|
86 { |
|
87 iParentDraw.DrawLineGraphics(aParam, aLineInfo); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CMIDTextEditorEdwinCustomDraw::DrawText |
|
92 // (other items were commented in the header file) |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 void CMIDTextEditorEdwinCustomDraw::DrawText( |
|
96 const TParam& aParam, |
|
97 const TLineInfo& aLineInfo, |
|
98 const TCharFormat& aFormat, |
|
99 const TDesC& aText, |
|
100 const TPoint& aTextOrigin, |
|
101 TInt aExtraPixels) const |
|
102 { |
|
103 // If transparency is enabled, check that if draw has not been invoked |
|
104 // yet and issue redraw in that case. This removes the issue with |
|
105 // transparency so that the old content does not cause corruption to |
|
106 // the new text drawn on top of the old content. Otherwise it is ok |
|
107 // to draw the text because opaque background draws on top of the old |
|
108 // content in the editor. |
|
109 |
|
110 if (iEdwin.IsTransparent() && !iEdwin.DrawOngoing()) |
|
111 { |
|
112 iEdwin.Redraw(); |
|
113 return; |
|
114 } |
|
115 |
|
116 iParentDraw.DrawText( |
|
117 aParam, |
|
118 aLineInfo, |
|
119 aFormat, |
|
120 aText, |
|
121 aTextOrigin, |
|
122 aExtraPixels); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CMIDTextEditorEdwinCustomDraw::SystemColor |
|
127 // (other items were commented in the header file) |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 TRgb CMIDTextEditorEdwinCustomDraw::SystemColor( |
|
131 TUint aColorIndex, |
|
132 TRgb aDefaultColor) const |
|
133 { |
|
134 TRgb ret; |
|
135 |
|
136 // Return custom highlight color if retrieved by the system. |
|
137 if (aColorIndex == TLogicalRgb::ESystemSelectionBackgroundIndex) |
|
138 { |
|
139 iEdwin.GetColor(EColorControlHighlightBackground, ret); |
|
140 } |
|
141 else |
|
142 { |
|
143 // Other colors use parent's SystemColor. |
|
144 ret = iParentDraw.SystemColor(aColorIndex, aDefaultColor); |
|
145 } |
|
146 |
|
147 return ret; |
|
148 } |
|
149 |
|
150 // End of file |