|
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 // Part of the MVS Application for TechView |
|
15 // |
|
16 |
|
17 |
|
18 #include "MVSCropDialog.h" |
|
19 #include "MVSApp.hrh" |
|
20 #include <techview/eikmfne.h> |
|
21 #include <coecntrl.h> |
|
22 #include <techview/eikhopbt.h> |
|
23 #include <techview/eiklabel.h> |
|
24 #include "MVSAppUI.h" |
|
25 |
|
26 const TUint KMicroSecs = 1000000; |
|
27 |
|
28 void CMVSCropDialog::SetupDialogLD(TTimeIntervalMicroSeconds aPosition, |
|
29 TTimeIntervalMicroSeconds aClipLength, |
|
30 TTimeIntervalMicroSeconds aCropStart, |
|
31 TTimeIntervalMicroSeconds aCropEnd, |
|
32 CMVSAppUi* aAppUi) |
|
33 { |
|
34 CMVSCropDialog* dialog = new (ELeave) CMVSCropDialog(aPosition, aClipLength, |
|
35 aCropStart, aCropEnd, aAppUi); |
|
36 dialog->ExecuteLD(R_MVS_DIALOG_CROP); |
|
37 } |
|
38 |
|
39 |
|
40 void CMVSCropDialog::PreLayoutDynInitL() |
|
41 { |
|
42 TInt start = I64INT(iCropStart.Int64()) > 1? (I64INT(iCropStart.Int64())/KMicroSecs) : 0; |
|
43 TInt finish = I64INT(iCropEnd.Int64()) > 1? (I64INT(iCropEnd.Int64())/KMicroSecs) : I64INT(iClipLength.Int64())/KMicroSecs; |
|
44 //check the current position is valid. |
|
45 if(I64INT(iPosition.Int64())/KMicroSecs < start) |
|
46 iPosition = start; |
|
47 else if (I64INT(iPosition.Int64())/KMicroSecs > finish) |
|
48 iPosition = finish; |
|
49 |
|
50 InitControl(TInt(EMVSCmdCropPositionNumber), I64INT(iPosition.Int64())/KMicroSecs, start, finish ); |
|
51 |
|
52 CEikHorOptionButtonList* button = static_cast<CEikHorOptionButtonList*>(Control(EMVSCmdCropLeftRight)); |
|
53 button->SetButtonById(EMVSHorOptButtonCropFromBeginning); |
|
54 } |
|
55 |
|
56 |
|
57 |
|
58 // |
|
59 //CCropDialog() |
|
60 // |
|
61 // C++ Constructor, initialises the object member variables to their |
|
62 // current settings. |
|
63 // |
|
64 CMVSCropDialog::CMVSCropDialog(TTimeIntervalMicroSeconds aPosition, |
|
65 TTimeIntervalMicroSeconds aClipLength, |
|
66 TTimeIntervalMicroSeconds aCropStart, |
|
67 TTimeIntervalMicroSeconds aCropEnd, |
|
68 CMVSAppUi* aAppUi) |
|
69 : iPosition(aPosition), iCropStart(aCropStart), iCropEnd(aCropEnd), iCropFromBeginning(EFalse), iAppUi(aAppUi) |
|
70 { |
|
71 if (I64INT(aCropEnd.Int64()) > 1) |
|
72 { |
|
73 iClipLength = aCropEnd; |
|
74 } |
|
75 else |
|
76 { |
|
77 iClipLength = aClipLength; |
|
78 } |
|
79 } |
|
80 |
|
81 |
|
82 |
|
83 TBool CMVSCropDialog::OkToExitL(TInt aButtonId) |
|
84 { |
|
85 //Get a pointer to the Option Button List control |
|
86 CEikHorOptionButtonList* button = static_cast<CEikHorOptionButtonList*>(Control(EMVSCmdCropLeftRight)); |
|
87 //Get a pointer to the number editor |
|
88 CEikNumberEditor* control = static_cast<CEikNumberEditor*> ( Control(EMVSCmdCropPositionNumber) ); |
|
89 TInt position = control->Number()*KMicroSecs; |
|
90 TInt64 pos64(position); |
|
91 iPosition = TTimeIntervalMicroSeconds(pos64); |
|
92 if(iPosition > iClipLength) |
|
93 { |
|
94 iPosition = iClipLength; |
|
95 } |
|
96 if(iPosition < iCropStart) |
|
97 { |
|
98 iPosition = iCropStart; |
|
99 } |
|
100 TInt buttonId = button->LabeledButtonId(); |
|
101 switch (aButtonId) |
|
102 { |
|
103 case(EMVSButtonUpdate): |
|
104 //update prog info based on num-editor |
|
105 if(buttonId == EMVSHorOptButtonCropFromBeginning) //'From Beginning' selected |
|
106 { |
|
107 iCropFromBeginning = ETrue; |
|
108 iCropStart = iPosition; |
|
109 } |
|
110 else |
|
111 { |
|
112 iCropFromBeginning = EFalse; |
|
113 iCropStart = iPosition; |
|
114 } |
|
115 iAppUi->SetCropL(iCropStart, iCropFromBeginning); |
|
116 break; |
|
117 |
|
118 case(EMVSButtonCancel): |
|
119 break; |
|
120 |
|
121 default: |
|
122 break; |
|
123 } |
|
124 return ETrue; |
|
125 } |
|
126 |
|
127 |
|
128 void CMVSCropDialog::InitControl( const TInt aId, const TInt aPos, const TInt aStart, const TInt aFinish ) |
|
129 { |
|
130 CEikNumberEditor* control = static_cast<CEikNumberEditor*> ( Control(aId) ); |
|
131 control->SetNumber(aPos); |
|
132 control->SetMinimumAndMaximum( aStart, aFinish ); |
|
133 } |
|
134 |
|
135 |