|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <techview/eikon.rsg> |
|
17 #include <techview/eikchlst.h> |
|
18 #include "plugininfoarray.h" |
|
19 |
|
20 #include "TImageDisplayDlgs.h" |
|
21 // |
|
22 // CDisplayModeDialog |
|
23 // |
|
24 |
|
25 CDisplayModeDialog::CDisplayModeDialog(TDisplayMode& aDisplayMode): |
|
26 iDisplayMode(aDisplayMode) |
|
27 { |
|
28 } |
|
29 |
|
30 const TInt KNumDispMode = 10; |
|
31 const TDisplayMode KDispMode[KNumDispMode] = |
|
32 { EGray2, EGray4, EGray16, EGray256, EColor16, |
|
33 EColor256, EColor4K, EColor64K, EColor16M , EColor16MU |
|
34 }; |
|
35 |
|
36 void CDisplayModeDialog::PreLayoutDynInitL() |
|
37 { |
|
38 TInt choice = -1; |
|
39 |
|
40 for (TInt index=0; index<KNumDispMode; index++) |
|
41 { |
|
42 if (KDispMode[index]==iDisplayMode) |
|
43 { |
|
44 choice = index; |
|
45 break; |
|
46 } |
|
47 } |
|
48 |
|
49 ASSERT(choice>=0); // should always match something |
|
50 SetChoiceListCurrentItem(EVideoIdDisplayMode,choice); |
|
51 } |
|
52 |
|
53 TBool CDisplayModeDialog::OkToExitL(TInt /*aButtonId*/) |
|
54 { |
|
55 const TInt chosenIndex = ChoiceListCurrentItem(EVideoIdDisplayMode); |
|
56 ASSERT(chosenIndex<KNumDispMode); |
|
57 iDisplayMode = KDispMode[chosenIndex]; |
|
58 return ETrue; |
|
59 } |
|
60 |
|
61 |
|
62 CMaxReductionDialog::CMaxReductionDialog(TInt& aMaxReduction ):iMaxReduction(aMaxReduction) |
|
63 { |
|
64 } |
|
65 |
|
66 void CMaxReductionDialog::PreLayoutDynInitL() |
|
67 { |
|
68 SetNumberEditorValue(EImageMaxAllowedReduction, iMaxReduction); |
|
69 } |
|
70 |
|
71 TBool CMaxReductionDialog::OkToExitL(TInt /*aButtonId*/) |
|
72 { |
|
73 iMaxReduction = NumberEditorValue(EImageMaxAllowedReduction); |
|
74 return ETrue; |
|
75 } |
|
76 |
|
77 CScalingQualityDialog::CScalingQualityDialog(TInt& aQualityValueRef): |
|
78 iQualityValueRef(aQualityValueRef) |
|
79 { |
|
80 } |
|
81 |
|
82 void CScalingQualityDialog::PreLayoutDynInitL() |
|
83 { |
|
84 ASSERT(iQualityValueRef>=0); // should always match something |
|
85 SetChoiceListCurrentItem(EImageScalingQuality, iQualityValueRef); |
|
86 } |
|
87 |
|
88 TBool CScalingQualityDialog::OkToExitL(TInt /*aButtonId*/) |
|
89 { |
|
90 iQualityValueRef = ChoiceListCurrentItem(EImageScalingQuality); |
|
91 return ETrue; |
|
92 } |
|
93 |
|
94 CDrmContentIdDialog::CDrmContentIdDialog(TDes& aContentId): |
|
95 iContentId(aContentId) |
|
96 { |
|
97 } |
|
98 |
|
99 void CDrmContentIdDialog::PreLayoutDynInitL() |
|
100 { |
|
101 SetEdwinTextL(EImageDrmContentId, &iContentId); |
|
102 } |
|
103 |
|
104 TBool CDrmContentIdDialog::OkToExitL(TInt /*aButtonId*/) |
|
105 { |
|
106 GetEdwinText(iContentId, EImageDrmContentId); |
|
107 return ETrue; |
|
108 } |
|
109 |
|
110 CClipRectParamsDialog::CClipRectParamsDialog(TBool& aEnabled, TRect& aClipRect): |
|
111 iEnabled(aEnabled), iClipRect(aClipRect) |
|
112 { |
|
113 } |
|
114 |
|
115 void CClipRectParamsDialog::PreLayoutDynInitL() |
|
116 { |
|
117 SetCheckBoxState(EImageUseClipRect, CEikButtonBase::TState(iEnabled)); |
|
118 SetNumberEditorValue(EImageClipRectTlx,iClipRect.iTl.iX); |
|
119 SetNumberEditorValue(EImageClipRectTly,iClipRect.iTl.iY); |
|
120 SetNumberEditorValue(EImageClipRectBrx,iClipRect.iBr.iX); |
|
121 SetNumberEditorValue(EImageClipRectBry,iClipRect.iBr.iY); |
|
122 HandleControlStateChangeL(EImageUseClipRect); |
|
123 } |
|
124 |
|
125 TBool CClipRectParamsDialog::OkToExitL(TInt /*aButtonId*/) |
|
126 { |
|
127 iEnabled = CheckBoxState(EImageUseClipRect); |
|
128 iClipRect.iTl.iX = NumberEditorValue(EImageClipRectTlx); |
|
129 iClipRect.iTl.iY = NumberEditorValue(EImageClipRectTly); |
|
130 iClipRect.iBr.iX = NumberEditorValue(EImageClipRectBrx); |
|
131 iClipRect.iBr.iY = NumberEditorValue(EImageClipRectBry); |
|
132 return ETrue; |
|
133 } |
|
134 |
|
135 void CClipRectParamsDialog::HandleControlStateChangeL(TInt aControlId) |
|
136 { |
|
137 if (aControlId != EImageUseClipRect) |
|
138 { |
|
139 return; |
|
140 } |
|
141 const TBool disabled=(CEikButtonBase::EClear==CheckBoxState(EImageUseClipRect)); |
|
142 SetLineDimmedNow(EImageClipRectTlx,disabled); |
|
143 SetLineDimmedNow(EImageClipRectTly,disabled); |
|
144 SetLineDimmedNow(EImageClipRectBrx,disabled); |
|
145 SetLineDimmedNow(EImageClipRectBry,disabled); |
|
146 } |
|
147 // |
|
148 // CVideoBackgroundColorDialog |
|
149 // |
|
150 |
|
151 CVideoBackgroundColorDialog::CVideoBackgroundColorDialog(TInt& aColor16, TBool& aOverride): |
|
152 iColor16(aColor16), iOverride(aOverride) |
|
153 { |
|
154 } |
|
155 |
|
156 void CVideoBackgroundColorDialog::PreLayoutDynInitL() |
|
157 { |
|
158 CEikButtonBase::TState state = iOverride ? CEikButtonBase::ESet : CEikButtonBase::EClear; |
|
159 SetCheckBoxState(EVideoIdOverrideBackgroundColor, state); |
|
160 SetChoiceListCurrentItem(EVideoIdBackgroundColor,iColor16); |
|
161 if (!iOverride) |
|
162 SetLineDimmedNow(EVideoIdBackgroundColor,ETrue); |
|
163 } |
|
164 |
|
165 TBool CVideoBackgroundColorDialog::OkToExitL(TInt /*aButtonId*/) |
|
166 { |
|
167 iColor16 = ChoiceListCurrentItem(EVideoIdBackgroundColor); |
|
168 CEikButtonBase::TState state = CheckBoxState(EVideoIdOverrideBackgroundColor); |
|
169 iOverride = state != CEikButtonBase::EClear; |
|
170 return ETrue; |
|
171 } |
|
172 |
|
173 void CVideoBackgroundColorDialog::HandleControlStateChangeL(TInt aControlId) |
|
174 { |
|
175 if (aControlId == EVideoIdOverrideBackgroundColor) |
|
176 { |
|
177 CEikButtonBase::TState state = CheckBoxState(EVideoIdOverrideBackgroundColor); |
|
178 TBool isSet = state != CEikButtonBase::EClear; |
|
179 SetLineDimmedNow(EVideoIdBackgroundColor,!isSet); |
|
180 } |
|
181 } |
|
182 |
|
183 // |
|
184 // CVideoCurrentFrameDialog |
|
185 // |
|
186 |
|
187 CVideoCurrentFrameDialog::CVideoCurrentFrameDialog(TInt& aCurrentFrame,TInt aNumberOfFrames): |
|
188 iCurrentFrame(aCurrentFrame), |
|
189 iNumberOfFrames(aNumberOfFrames) |
|
190 {} |
|
191 |
|
192 void CVideoCurrentFrameDialog::PreLayoutDynInitL() |
|
193 { |
|
194 SetNumberEditorValue(EVideoIdNumberOfFrames,iNumberOfFrames); |
|
195 SetLineDimmedNow(EVideoIdNumberOfFrames,ETrue); |
|
196 const TInt lastFrame = iNumberOfFrames - 1; |
|
197 SetNumberEditorMinAndMax(EVideoIdCurrentFrameNumber,0,lastFrame); |
|
198 SetNumberEditorValue(EVideoIdCurrentFrameNumber,Min(iCurrentFrame,lastFrame)); |
|
199 } |
|
200 |
|
201 TBool CVideoCurrentFrameDialog::OkToExitL(TInt /*aButtonId*/) |
|
202 { |
|
203 iCurrentFrame = NumberEditorValue(EVideoIdCurrentFrameNumber); |
|
204 return ETrue; |
|
205 } |
|
206 |
|
207 // |
|
208 // CVideoSaveAsDialog |
|
209 // |
|
210 |
|
211 CVideoSaveAsDialog::CVideoSaveAsDialog(TDes* aFileName,TFileSaveInfo& aSaveInfo): |
|
212 CEikFileSaveAsDialog(aFileName), |
|
213 iSaveInfo(aSaveInfo) |
|
214 {} |
|
215 |
|
216 void CVideoSaveAsDialog::PreLayoutDynInitL() |
|
217 { |
|
218 SetTypeL(); |
|
219 CEikFileSaveAsDialog::PreLayoutDynInitL(); |
|
220 } |
|
221 |
|
222 void CVideoSaveAsDialog::SetTypeL() |
|
223 { |
|
224 const TUid imageType = iSaveInfo.iImageTypeUid; |
|
225 |
|
226 if(imageType == KImageTypeBMPUid) |
|
227 SetLabelL(EVideoIdSaveAsFormat,R_VIDEO_FILE_FORMAT_BMP); |
|
228 else if(imageType == KImageTypeGIFUid) |
|
229 SetLabelL(EVideoIdSaveAsFormat,R_VIDEO_FILE_FORMAT_GIF); |
|
230 else if(imageType == KImageTypeJPGUid) |
|
231 SetLabelL(EVideoIdSaveAsFormat,R_VIDEO_FILE_FORMAT_JPEG); |
|
232 else if(imageType == KImageTypeMBMUid) |
|
233 SetLabelL(EVideoIdSaveAsFormat,R_VIDEO_FILE_FORMAT_MBM); |
|
234 else if(imageType == KImageTypePNGUid) |
|
235 SetLabelL(EVideoIdSaveAsFormat,R_VIDEO_FILE_FORMAT_PNG); |
|
236 else |
|
237 SetLabelL(EVideoIdSaveAsFormat,R_VIDEO_FILE_FORMAT_CUSTOM); |
|
238 |
|
239 } |
|
240 |
|
241 TBool CVideoSaveAsDialog::OkToExitL(TInt aButtonId) |
|
242 { |
|
243 if (aButtonId == EVideoIdSaveAsFormat) |
|
244 { |
|
245 CEikDialog* dialog = new(ELeave) CVideoFormatDialog(iSaveInfo); |
|
246 if (dialog->ExecuteLD(R_VIDEO_FILE_FORMAT_DIALOG)) |
|
247 SetTypeL(); |
|
248 |
|
249 return EFalse; |
|
250 } |
|
251 |
|
252 return CEikFileSaveAsDialog::OkToExitL(aButtonId); |
|
253 } |
|
254 |
|
255 // |
|
256 // CVideoFormatDialog |
|
257 // |
|
258 |
|
259 CVideoFormatDialog::CVideoFormatDialog(TFileSaveInfo& aSaveInfo): |
|
260 iSaveInfo(aSaveInfo) |
|
261 {} |
|
262 |
|
263 void CVideoFormatDialog::PreLayoutDynInitL() |
|
264 { |
|
265 CEikChoiceList* formatList = STATIC_CAST(CEikChoiceList*,Control(EVideoIdFileFormatType)); |
|
266 |
|
267 //Add the available encoders to the dialog |
|
268 iEncoderList = CPluginInfoArray::NewL(); |
|
269 formatList->SetArrayL(iEncoderList); //ownership of iEncoderList passed to dialog |
|
270 |
|
271 const TInt noOfEncoders = iEncoderList->MdcaCount(); |
|
272 if(noOfEncoders == 0) |
|
273 User::Leave(KErrNotFound); |
|
274 |
|
275 //Find the index for the selected encoder (via ImageTypeUid) |
|
276 //if it is not found use the first |
|
277 TInt index; |
|
278 for(index=noOfEncoders-1; index > 0; index--) |
|
279 { |
|
280 if(iEncoderList->ImageType(index) == iSaveInfo.iImageTypeUid) |
|
281 break; |
|
282 } |
|
283 iSaveInfo.iImageTypeUid = iEncoderList->ImageType(index); |
|
284 |
|
285 SetChoiceListCurrentItem(EVideoIdFileFormatType,index); |
|
286 SetChoiceListCurrentItem(EVideoIdFileFormatBpp,iSaveInfo.iBpp); |
|
287 SetChoiceListCurrentItem(EVideoIdFileFormatColor,iSaveInfo.iColor); |
|
288 SetNumberEditorValue(EVideoIdFileFormatFactor,iSaveInfo.iQualityFactor); |
|
289 SetChoiceListCurrentItem(EVideoIdFileFormatSampling,iSaveInfo.iSampling); |
|
290 SetChoiceListCurrentItem(EVideoIdFileFormatCompression,iSaveInfo.iCompression); |
|
291 |
|
292 ValidateControlState(); |
|
293 } |
|
294 |
|
295 void CVideoFormatDialog::HandleControlStateChangeL(TInt /*aControlId*/) |
|
296 { |
|
297 ValidateControlState(); |
|
298 } |
|
299 |
|
300 void CVideoFormatDialog::ValidateControlState() |
|
301 { |
|
302 TInt type = ChoiceListCurrentItem(EVideoIdFileFormatType); |
|
303 TInt bpp = ChoiceListCurrentItem(EVideoIdFileFormatBpp); |
|
304 TInt color = ChoiceListCurrentItem(EVideoIdFileFormatColor); |
|
305 TInt compression = ChoiceListCurrentItem(EVideoIdFileFormatCompression); |
|
306 |
|
307 TBool bppVisible = ETrue; |
|
308 TBool colorVisible = ETrue; |
|
309 TBool factorVisible = EFalse; |
|
310 TBool samplingVisible = EFalse; |
|
311 TBool compressionVisible = EFalse; |
|
312 |
|
313 |
|
314 const TUid imageType = iEncoderList->ImageType(type); |
|
315 |
|
316 if(imageType == KImageTypeBMPUid) |
|
317 { |
|
318 colorVisible = EFalse; |
|
319 if (bpp == 1) |
|
320 bpp = 2; |
|
321 else if ((bpp > 3) && (bpp < 6)) |
|
322 bpp = 6; |
|
323 else if (bpp > 6) |
|
324 bpp = 0; |
|
325 } |
|
326 else if(imageType == KImageTypeGIFUid) |
|
327 { |
|
328 bppVisible = EFalse; |
|
329 colorVisible = EFalse; |
|
330 } |
|
331 else if(imageType == KImageTypeJPGUid) |
|
332 { |
|
333 bppVisible = EFalse; |
|
334 factorVisible = ETrue; |
|
335 if (color) |
|
336 samplingVisible = ETrue; |
|
337 } |
|
338 else if(imageType == KImageTypeMBMUid) |
|
339 { |
|
340 if (color == 0) |
|
341 { |
|
342 if (bpp > 3) |
|
343 bpp = 0; |
|
344 } |
|
345 else |
|
346 { |
|
347 if (bpp < 2) |
|
348 bpp = 2; |
|
349 } |
|
350 } |
|
351 else if(imageType == KImageTypePNGUid) |
|
352 { |
|
353 if ((bpp > 3) && (bpp < 6)) |
|
354 bpp = 6; |
|
355 else if (bpp > 6) |
|
356 bpp = 0; |
|
357 compressionVisible = ETrue; |
|
358 } |
|
359 else //Custom encoder |
|
360 { |
|
361 bppVisible = EFalse; |
|
362 colorVisible = EFalse; |
|
363 } |
|
364 |
|
365 SetChoiceListCurrentItem(EVideoIdFileFormatBpp,bpp); |
|
366 SetChoiceListCurrentItem(EVideoIdFileFormatColor,color); |
|
367 SetChoiceListCurrentItem(EVideoIdFileFormatCompression,compression); |
|
368 |
|
369 MakeLineVisible(EVideoIdFileFormatBpp,bppVisible); |
|
370 MakeLineVisible(EVideoIdFileFormatColor,colorVisible); |
|
371 MakeLineVisible(EVideoIdFileFormatFactor,factorVisible); |
|
372 MakeLineVisible(EVideoIdFileFormatSampling,samplingVisible); |
|
373 MakeLineVisible(EVideoIdFileFormatCompression,compressionVisible); |
|
374 } |
|
375 |
|
376 TBool CVideoFormatDialog::OkToExitL(TInt /*aButtonId*/) |
|
377 { |
|
378 TInt type = ChoiceListCurrentItem(EVideoIdFileFormatType); |
|
379 iSaveInfo.iImageTypeUid = iEncoderList->ImageType(type); |
|
380 iSaveInfo.iBpp = ChoiceListCurrentItem(EVideoIdFileFormatBpp); |
|
381 iSaveInfo.iColor = ChoiceListCurrentItem(EVideoIdFileFormatColor); |
|
382 iSaveInfo.iQualityFactor = NumberEditorValue(EVideoIdFileFormatFactor); |
|
383 iSaveInfo.iSampling = ChoiceListCurrentItem(EVideoIdFileFormatSampling); |
|
384 iSaveInfo.iCompression = ChoiceListCurrentItem(EVideoIdFileFormatCompression); |
|
385 |
|
386 return ETrue; |
|
387 } |