|
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: Methods for landmark editor base class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 // INCLUDE FILES |
|
25 #include <eikcapc.h> |
|
26 #include <eikimage.h> |
|
27 |
|
28 #include <AknIconUtils.h> |
|
29 #include <eikedwin.h> |
|
30 #include <eikenv.h> |
|
31 #include "LmkConsts.h" |
|
32 #include "landmarks.hrh" |
|
33 #include "CLmkUiUtils.h" |
|
34 |
|
35 #include "CLmkEditorFieldBase.h" |
|
36 #include "MLmkEditorUiBuilder.h" |
|
37 |
|
38 #include "avkon.loc" |
|
39 |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 |
|
43 // ---------------------------------------------------- |
|
44 // CLmkEditorFieldBase::CLmkEditorFieldBase |
|
45 // ---------------------------------------------------- |
|
46 // |
|
47 CLmkEditorFieldBase::CLmkEditorFieldBase |
|
48 ( MLmkFieldData& aField, |
|
49 MLmkEditorUiBuilder& aUiBuilder ) : |
|
50 iLmkItemField( aField ), iUiBuilder( aUiBuilder ) |
|
51 { |
|
52 iEnv = CEikonEnv::Static(); |
|
53 } |
|
54 |
|
55 // ---------------------------------------------------- |
|
56 // CLmkEditorFieldBase::BaseConstructL |
|
57 // ---------------------------------------------------- |
|
58 // |
|
59 void CLmkEditorFieldBase::BaseConstructL() |
|
60 { |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------- |
|
64 // CLmkEditorFieldBase::~CLmkEditorFieldBase |
|
65 // ---------------------------------------------------- |
|
66 // |
|
67 CLmkEditorFieldBase::~CLmkEditorFieldBase() |
|
68 { |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------- |
|
72 // CLmkEditorFieldBase::ControlId |
|
73 // ---------------------------------------------------- |
|
74 // |
|
75 TInt CLmkEditorFieldBase::ControlId() const |
|
76 { |
|
77 return iLmkItemField.UniqueFieldIdentity(); |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------- |
|
81 // CLmkEditorFieldBase::FieldId |
|
82 // ---------------------------------------------------- |
|
83 // |
|
84 TInt CLmkEditorFieldBase::FieldId() const |
|
85 { |
|
86 return 0; |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------- |
|
90 // CLmkEditorFieldBase::FieldLabel |
|
91 // ---------------------------------------------------- |
|
92 // |
|
93 TPtrC CLmkEditorFieldBase::FieldLabel() const |
|
94 { |
|
95 return iLmkItemField.Label(); |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------- |
|
99 // CLmkEditorFieldBase::SetFieldLabelL |
|
100 // ---------------------------------------------------- |
|
101 // |
|
102 void CLmkEditorFieldBase::SetFieldLabelL |
|
103 (HBufC* aLabel) |
|
104 { |
|
105 iUiBuilder.SetCurrentLineCaptionL(ControlId(),*aLabel); |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------- |
|
109 // CLmkEditorFieldBase::ControlTextL |
|
110 // ---------------------------------------------------- |
|
111 // |
|
112 HBufC* CLmkEditorFieldBase::ControlTextL() const |
|
113 { |
|
114 HBufC* textBuf = NULL; |
|
115 CCoeControl* ctrl = iUiBuilder.Control(ControlId()); |
|
116 if (ctrl) |
|
117 { |
|
118 textBuf = static_cast<CEikEdwin*>(ctrl)->GetTextInHBufL(); |
|
119 } |
|
120 return textBuf; |
|
121 } |
|
122 |
|
123 // ---------------------------------------------------- |
|
124 // CLmkEditorFieldBase::LandmarkItemField |
|
125 // ---------------------------------------------------- |
|
126 // |
|
127 MLmkFieldData& CLmkEditorFieldBase::LandmarkItemField() const |
|
128 { |
|
129 return iLmkItemField; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 //CLmkEditorFieldBase::GetNumberFieldValue() |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 TReal CLmkEditorFieldBase::GetNumberFieldValue() const |
|
137 { |
|
138 return 0; |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 //CLmkEditorFieldBase::FieldValue() |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 TReal CLmkEditorFieldBase::FieldValue() const |
|
146 { |
|
147 return 0; |
|
148 } |
|
149 // ----------------------------------------------------------------------------- |
|
150 //CLmkEditorFieldBase::LoadBitmapToFieldL |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CLmkEditorFieldBase::LoadBitmapToFieldL |
|
154 (MLmkEditorUiBuilder& aUiBuilder) |
|
155 { |
|
156 // Get the landmark field to which the Icon should be added |
|
157 MLmkFieldData& nameField = LandmarkItemField(); |
|
158 |
|
159 // Implemented only for Name field |
|
160 if ( nameField.FieldType() == EName ) |
|
161 { |
|
162 CEikImage* image = new(ELeave) CEikImage(); |
|
163 CleanupStack::PushL( image ); |
|
164 //TFileName defaultIconFile( CLmkUiUtils::LmkUiIconFileL() ); |
|
165 // No need to add iconFile to cleanupstack since it is a member variable from CLmkFieldData class |
|
166 HBufC* iconFile = nameField.IconPath(); |
|
167 TInt err = KErrNotFound; |
|
168 CFbsBitmap* bitmap = NULL; |
|
169 CFbsBitmap* mask = NULL; |
|
170 |
|
171 if (iconFile) // landmark has a defined icon |
|
172 { |
|
173 if ( nameField.IconId() != KErrNotFound ) |
|
174 { |
|
175 TRAP(err,AknIconUtils::CreateIconL( bitmap, mask, |
|
176 *iconFile, nameField.IconId(), |
|
177 nameField.IconId()+1 );); |
|
178 } |
|
179 image->SetPictureOwnedExternally(EFalse); |
|
180 image->SetPicture(bitmap, mask); |
|
181 image->CopyControlContextFrom(aUiBuilder.LineControl(ControlId())); |
|
182 image->SetContainerWindowL(*aUiBuilder.LineControl(ControlId())); |
|
183 image->SetNonFocusing(); |
|
184 image->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
185 |
|
186 delete aUiBuilder.LineControl(ControlId())->iBitmap; |
|
187 aUiBuilder.LineControl(ControlId())->iBitmap = image; |
|
188 |
|
189 TRect rect = aUiBuilder.LineControl(ControlId())->Rect(); |
|
190 rect.Resize(-1, -1); |
|
191 aUiBuilder.LineControl(ControlId())->SetRect(rect); |
|
192 rect.Resize(1, 1); |
|
193 aUiBuilder.LineControl(ControlId())->SetRect(rect); |
|
194 CleanupStack::Pop(image); |
|
195 } |
|
196 else |
|
197 { |
|
198 CleanupStack::PopAndDestroy(image); |
|
199 } |
|
200 |
|
201 } |
|
202 } |
|
203 |
|
204 // End of File |