|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: PostcardTextDialogCustomDraw implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ========== INCLUDE FILES ================================ |
|
21 #include "PostcardTextDialogCustomDraw.h" |
|
22 #include "PostcardTextDialog.h" |
|
23 #include "PostcardLaf.h" |
|
24 |
|
25 #include <gulicon.h> |
|
26 #include <AknUtils.h> |
|
27 #include <eikedwin.h> |
|
28 |
|
29 #include <AknsUtils.h> |
|
30 #include <applayout.cdl.h> |
|
31 #include <aknlayoutscalable_apps.cdl.h> |
|
32 |
|
33 #include <msgeditor.mbg> |
|
34 |
|
35 #include <MsgEditorCommon.h> |
|
36 |
|
37 // ========== EXTERNAL DATA STRUCTURES ===================== |
|
38 |
|
39 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
|
40 |
|
41 // ========== CONSTANTS ==================================== |
|
42 |
|
43 // ========== MACROS ======================================= |
|
44 |
|
45 // ========== LOCAL CONSTANTS AND MACROS =================== |
|
46 |
|
47 // ========== MODULE DATA STRUCTURES ======================= |
|
48 |
|
49 // ========== LOCAL FUNCTION PROTOTYPES ==================== |
|
50 |
|
51 // ========== LOCAL FUNCTIONS ============================== |
|
52 |
|
53 // ========== MEMBER FUNCTIONS ============================= |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CPostcardTextDialogCustomDraw::NewL |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 CPostcardTextDialogCustomDraw* CPostcardTextDialogCustomDraw::NewL( |
|
60 const MFormCustomDraw* aParentCustomDraw, |
|
61 const CPostcardTextDialog* aParentControl ) |
|
62 { |
|
63 CPostcardTextDialogCustomDraw* self = new (ELeave) CPostcardTextDialogCustomDraw( aParentCustomDraw, |
|
64 aParentControl ); |
|
65 |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop( self ); |
|
69 |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // CPostcardTextDialogCustomDraw::ConstructL |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 void CPostcardTextDialogCustomDraw::ConstructL() |
|
78 { |
|
79 iIcon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), |
|
80 KAknsIIDQgnGrafLineMessageHorizontal, |
|
81 KMsgEditorMbm, |
|
82 EMbmMsgeditorQgn_graf_line_message_horizontal, |
|
83 EMbmMsgeditorQgn_graf_line_message_horizontal_mask ); |
|
84 |
|
85 ResolveLayouts(); |
|
86 } |
|
87 |
|
88 |
|
89 // --------------------------------------------------------- |
|
90 // CPostcardTextDialogCustomDraw::CPostcardTextDialogCustomDraw |
|
91 // --------------------------------------------------------- |
|
92 // |
|
93 CPostcardTextDialogCustomDraw::CPostcardTextDialogCustomDraw( |
|
94 const MFormCustomDraw* aParentCustomDraw, |
|
95 const CPostcardTextDialog* aParentControl ) : |
|
96 iParentCustomDraw( aParentCustomDraw ), |
|
97 iParentControl( aParentControl ) |
|
98 { |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // CPostcardTextDialogCustomDraw::~CPostcardTextDialogCustomDraw |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 CPostcardTextDialogCustomDraw::~CPostcardTextDialogCustomDraw() |
|
106 { |
|
107 delete iIcon; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // CPostcardTextDialogCustomDraw::ResolveLayouts |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 void CPostcardTextDialogCustomDraw::ResolveLayouts() |
|
115 { |
|
116 TRect dataPane = MsgEditorCommons::MsgDataPane(); |
|
117 |
|
118 TAknLayoutRect msgTextPane; |
|
119 msgTextPane.LayoutRect( dataPane, |
|
120 AknLayoutScalable_Apps::msg_text_pane( 0 ).LayoutLine() ); |
|
121 |
|
122 TAknLayoutRect msgBodyPane; |
|
123 msgBodyPane.LayoutRect( msgTextPane.Rect(), |
|
124 AknLayoutScalable_Apps::msg_body_pane().LayoutLine() ); |
|
125 |
|
126 TAknLayoutRect lineLayout; |
|
127 lineLayout.LayoutRect( msgBodyPane.Rect(), |
|
128 AknLayoutScalable_Apps::msg_body_pane_g1().LayoutLine() ); |
|
129 |
|
130 AknIconUtils::SetSize( iIcon->Bitmap(), |
|
131 lineLayout.Rect().Size(), |
|
132 EAspectRatioNotPreserved ); |
|
133 |
|
134 iLineDelta = MsgEditorCommons::MsgBaseLineDelta(); |
|
135 |
|
136 // Calculate first line rectangle's correct position. |
|
137 iFirstLineRect = TRect( TPoint( lineLayout.Rect().iTl.iX, |
|
138 iLineDelta - lineLayout.Rect().Height() ), |
|
139 lineLayout.Rect().Size() ); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CPostcardTextDialogCustomDraw::DrawBackground |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 void CPostcardTextDialogCustomDraw::DrawBackground( const TParam& aParam, |
|
147 const TRgb& aRgb, |
|
148 TRect& aDrawn ) const |
|
149 { |
|
150 iParentCustomDraw->DrawBackground( aParam, aRgb, aDrawn ); |
|
151 // Draw lines only in editor. CustomDraw object is created |
|
152 // only when a postcard is in editor state. |
|
153 DrawEditorLines( aParam ); |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------- |
|
157 // CPostcardTextDialogCustomDraw::DrawBackground |
|
158 // --------------------------------------------------------- |
|
159 // |
|
160 void CPostcardTextDialogCustomDraw::DrawLineGraphics( const TParam& aParam, |
|
161 const TLineInfo& aLineInfo ) const |
|
162 { |
|
163 iParentCustomDraw->DrawLineGraphics( aParam, aLineInfo ); |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------- |
|
167 // CPostcardTextDialogCustomDraw::DrawText |
|
168 // --------------------------------------------------------- |
|
169 // |
|
170 void CPostcardTextDialogCustomDraw::DrawText( const TParam& aParam, |
|
171 const TLineInfo& aLineInfo, |
|
172 const TCharFormat& aFormat, |
|
173 const TDesC& aText, |
|
174 const TPoint& aTextOrigin, |
|
175 TInt aExtraPixels ) const |
|
176 { |
|
177 iParentCustomDraw->DrawText( aParam, |
|
178 aLineInfo, |
|
179 aFormat, |
|
180 aText, |
|
181 aTextOrigin, |
|
182 aExtraPixels ); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------- |
|
186 // CPostcardTextDialogCustomDraw::DrawText |
|
187 // --------------------------------------------------------- |
|
188 // |
|
189 TRgb CPostcardTextDialogCustomDraw::SystemColor( TUint aColorIndex, TRgb aDefaultColor ) const |
|
190 { |
|
191 return iParentCustomDraw->SystemColor( aColorIndex, aDefaultColor ); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------- |
|
195 // CPostcardTextDialogCustomDraw::DrawEditorLines |
|
196 // --------------------------------------------------------- |
|
197 // |
|
198 void CPostcardTextDialogCustomDraw::DrawEditorLines( const TParam& aParam ) const |
|
199 { |
|
200 TRect currentRect( iFirstLineRect ); |
|
201 |
|
202 while ( currentRect.iBr.iY <= aParam.iDrawRect.iBr.iY ) |
|
203 { |
|
204 if ( currentRect.iTl.iY >= aParam.iDrawRect.iTl.iY ) |
|
205 { |
|
206 aParam.iGc.DrawBitmapMasked( currentRect, |
|
207 iIcon->Bitmap(), |
|
208 TRect( TPoint( 0 ,0 ), currentRect.Size() ), |
|
209 iIcon->Mask(), |
|
210 ETrue ); |
|
211 } |
|
212 |
|
213 currentRect.Move( 0, iLineDelta ); |
|
214 } |
|
215 } |
|
216 |
|
217 // End of File |