|
1 /* |
|
2 * Copyright (c) 2002 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: MsgBody implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ========== INCLUDE FILES ================================ |
|
21 |
|
22 #include <AknUtils.h> // for AknUtils |
|
23 |
|
24 #include "MsgEditorCommon.h" // |
|
25 #include "MsgBody.h" // for CMsgBody |
|
26 #include "MsgControlArray.h" // for CMsgControlArray |
|
27 |
|
28 #include "MsgEditorLogging.h" |
|
29 |
|
30 // ========== EXTERNAL DATA STRUCTURES ===================== |
|
31 |
|
32 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
|
33 |
|
34 // ========== CONSTANTS ==================================== |
|
35 |
|
36 // ========== MACROS ======================================= |
|
37 |
|
38 // ========== LOCAL CONSTANTS AND MACROS =================== |
|
39 |
|
40 // ========== MODULE DATA STRUCTURES ======================= |
|
41 |
|
42 // ========== LOCAL FUNCTION PROTOTYPES ==================== |
|
43 |
|
44 // ========== LOCAL FUNCTIONS ============================== |
|
45 |
|
46 // ========== MEMBER FUNCTIONS ============================= |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // CMsgBody::CMsgBody |
|
50 // |
|
51 // Constructor. |
|
52 // --------------------------------------------------------- |
|
53 // |
|
54 CMsgBody::CMsgBody( const TMargins& aMargins ) |
|
55 : CMsgFormComponent( aMargins ) |
|
56 { |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // CMsgBody::~CMsgBody |
|
61 // |
|
62 // Destructor. |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 CMsgBody::~CMsgBody() |
|
66 { |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CMsgBody::NewL |
|
71 // |
|
72 // Factory method that creates this control. |
|
73 // --------------------------------------------------------- |
|
74 // |
|
75 CMsgBody* CMsgBody::NewL( const CCoeControl& aParent, const TMargins& aMargins ) |
|
76 { |
|
77 CMsgBody* self = new ( ELeave ) CMsgBody( aMargins ); |
|
78 |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL( aParent ); |
|
81 CleanupStack::Pop(); |
|
82 |
|
83 return self; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // CMsgBody::ConstructL |
|
88 // |
|
89 // 2nd phase constructor. |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 void CMsgBody::ConstructL( const CCoeControl& aParent ) |
|
93 { |
|
94 CMsgFormComponent::BaseConstructL( aParent ); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // CMsgBody::SetAndGetSizeL |
|
99 // |
|
100 // Calculates and sets the size for the body and returns new size as reference |
|
101 // aSize. If aInit == ETrue, sets also size for the controls by calling |
|
102 // their SetAndGetSizeL functions. |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 void CMsgBody::SetAndGetSizeL( TSize& aSize, TBool aInit ) |
|
106 { |
|
107 aSize = MsgEditorCommons::MsgBodyPane().Size(); |
|
108 |
|
109 TInt marginsDeltaHeight = iMargins.iTop + iMargins.iBottom; |
|
110 TInt marginsDeltaWidth = iMargins.iLeft + iMargins.iRight; |
|
111 |
|
112 TSize bodySize( aSize.iWidth, marginsDeltaHeight ); |
|
113 TSize controlSize( 0, 0 ); |
|
114 |
|
115 controlSize.iWidth = aSize.iWidth - marginsDeltaWidth; |
|
116 CMsgBaseControl* control; |
|
117 TInt controls( iControls->Count() ); |
|
118 |
|
119 for ( TInt cc = 0; cc < controls; cc++ ) |
|
120 { |
|
121 controlSize.iHeight = aSize.iHeight; |
|
122 control = (*iControls)[cc]; |
|
123 |
|
124 if ( aInit ) |
|
125 { |
|
126 control->SetAndGetSizeL( controlSize ); |
|
127 } |
|
128 else |
|
129 { |
|
130 controlSize = control->Size(); |
|
131 } |
|
132 |
|
133 bodySize.iHeight += control->DistanceFromComponentAbove() + controlSize.iHeight; |
|
134 |
|
135 //MEBLOGGER_WRITEF(_L("MEB: CMsgBody::SetAndGetSizeL: bodySize.iHeight %d "), bodySize.iHeight); |
|
136 } |
|
137 |
|
138 SetSizeWithoutNotification( bodySize ); |
|
139 |
|
140 aSize = bodySize; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------- |
|
144 // CMsgBody::CountComponentControls |
|
145 // |
|
146 // Returns a number of controls. |
|
147 // --------------------------------------------------------- |
|
148 // |
|
149 TInt CMsgBody::CountComponentControls() const |
|
150 { |
|
151 return CMsgFormComponent::CountComponentControls(); |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------- |
|
155 // CMsgBody::ComponentControl |
|
156 // |
|
157 // Returns a control of index aIndex. |
|
158 // --------------------------------------------------------- |
|
159 // |
|
160 CCoeControl* CMsgBody::ComponentControl( TInt aIndex ) const |
|
161 { |
|
162 return CMsgFormComponent::ComponentControl( aIndex ); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // CMsgBody::SizeChanged |
|
167 // |
|
168 // Sets new position for all the controls. |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 void CMsgBody::SizeChanged() |
|
172 { |
|
173 MEBLOGGER_ENTERFN("CMsgBody::SizeChanged"); |
|
174 |
|
175 CMsgFormComponent::SizeChanged(); |
|
176 |
|
177 MEBLOGGER_LEAVEFN("CMsgBody::SizeChanged"); |
|
178 } |
|
179 |
|
180 // End of File |