|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * Contrast plugin plugin base class. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /// INCLUDES |
|
22 #include <eikenv.h> |
|
23 #include <contrast.mbg> |
|
24 #include "ImageEditorContrastPlugin.h" |
|
25 #include "SingleParamControl.h" |
|
26 |
|
27 /// CONSTANTS |
|
28 _LIT (KPgnResourceFile, "contrast.rsc"); |
|
29 |
|
30 const long KParamMin = -100; |
|
31 const long KParamMax = 100; |
|
32 const long KParamStep = 10; |
|
33 const long KParamDef = 0; |
|
34 const TInt KContrastHSTitleIndex = 0; |
|
35 |
|
36 _LIT (KContrastTag, "contrast "); |
|
37 _LIT (KResourceDir, "\\resource\\apps\\"); |
|
38 |
|
39 //============================================================================= |
|
40 EXPORT_C CImageEditorPluginBase * CreateImageEditorPlugin () |
|
41 { |
|
42 CImageEditorContrastPlugin * plugin = new (ELeave) CImageEditorContrastPlugin; |
|
43 CleanupStack::PushL(plugin); |
|
44 plugin->ConstructL(); |
|
45 CleanupStack::Pop(); // plugin |
|
46 return plugin; |
|
47 } |
|
48 |
|
49 //============================================================================= |
|
50 CImageEditorContrastPlugin::CImageEditorContrastPlugin () : |
|
51 CImageEditorPluginBase() |
|
52 { |
|
53 |
|
54 } |
|
55 |
|
56 //============================================================================= |
|
57 void CImageEditorContrastPlugin::ConstructL () |
|
58 { |
|
59 CImageEditorPluginBase::ConstructL (KPgnResourcePath, KPgnResourceFile); |
|
60 } |
|
61 |
|
62 //============================================================================= |
|
63 CImageEditorContrastPlugin::~CImageEditorContrastPlugin () |
|
64 { |
|
65 ReleasePlugin(); |
|
66 } |
|
67 |
|
68 //============================================================================= |
|
69 TInt CImageEditorContrastPlugin::SetProperty ( |
|
70 TInt /*aPropertyId*/, |
|
71 TDesC & /*aPropertyValue*/ |
|
72 ) |
|
73 { |
|
74 return KErrNotSupported; |
|
75 } |
|
76 |
|
77 //============================================================================= |
|
78 TInt CImageEditorContrastPlugin::GetProperty ( |
|
79 TInt aPropertyId, |
|
80 TDes & aPropertyValue |
|
81 ) |
|
82 { |
|
83 // Clean buffer |
|
84 aPropertyValue.Zero(); |
|
85 |
|
86 // Copy data |
|
87 switch (aPropertyId) |
|
88 { |
|
89 case KCapParamStruct: |
|
90 { |
|
91 aPropertyValue.Copy (KContrastTag); |
|
92 aPropertyValue.AppendNum (iContrast); |
|
93 return KErrNone; |
|
94 } |
|
95 default: |
|
96 { |
|
97 return CImageEditorPluginBase::GetProperty (aPropertyId, aPropertyValue); |
|
98 } |
|
99 } |
|
100 } |
|
101 |
|
102 //============================================================================= |
|
103 TInt CImageEditorContrastPlugin::InitPluginL ( |
|
104 const TRect & aRect, |
|
105 CCoeControl * aParent, |
|
106 CCoeControl *& aPluginControl |
|
107 ) |
|
108 { |
|
109 ReleasePlugin(); |
|
110 iControl = CSingleParamControl::NewL (aRect, aParent); |
|
111 ((CSingleParamControl *)iControl)->SetParObserver ( (MSingleParControlObserver*)this ); |
|
112 aPluginControl = iControl; |
|
113 |
|
114 // initialize horizontal slider |
|
115 ((CSingleParamControl *)iControl)->SetSliderMinimumAndMaximum(KParamMin, KParamMax); |
|
116 ((CSingleParamControl *)iControl)->SetSliderStep(KParamStep); |
|
117 ((CSingleParamControl *)iControl)->SetSliderPosition(KParamDef); |
|
118 TFileName iconFile (KResourceDir); |
|
119 TBuf<256> readbuf; |
|
120 User::LeaveIfError ( GetProperty (KCapIconName, readbuf) ); |
|
121 iconFile.Append(readbuf); |
|
122 CEikImage* icon = new (ELeave) CEikImage; |
|
123 icon->CreatePictureFromFileL(iconFile, |
|
124 EMbmContrastQgn_indi_imed_contrast_super, |
|
125 EMbmContrastQgn_indi_imed_contrast_super_mask); |
|
126 ((CSingleParamControl *)iControl)->SetIcon(icon); |
|
127 |
|
128 // Get caption from plugin properties |
|
129 User::LeaveIfError ( GetProperty (KCapPluginParamNames, readbuf) ); |
|
130 TLex parser; |
|
131 parser.Assign (readbuf); |
|
132 TInt tempval = 0; |
|
133 parser.Val ( tempval ); |
|
134 CDesCArray * parameters = (CDesCArray *)tempval; |
|
135 ((CSingleParamControl *)iControl)->SetCaption( (*parameters)[KContrastHSTitleIndex] ); |
|
136 |
|
137 return KErrNone; |
|
138 } |
|
139 |
|
140 //============================================================================= |
|
141 void CImageEditorContrastPlugin::ProcessImageL (CEditorImage * /*aImage*/ ) |
|
142 { |
|
143 // Own image processing functionality here |
|
144 } |
|
145 |
|
146 //============================================================================= |
|
147 void CImageEditorContrastPlugin::ReleasePlugin () |
|
148 { |
|
149 delete iControl; |
|
150 iControl = 0; |
|
151 } |
|
152 |
|
153 //============================================================================= |
|
154 void CImageEditorContrastPlugin::ParamOperation (const TParamOperation aOperation) |
|
155 { |
|
156 switch (aOperation) |
|
157 { |
|
158 case EParamOperationSubtract: |
|
159 { |
|
160 iContrast -= KParamStep; |
|
161 if (iContrast < KParamMin) |
|
162 { |
|
163 iContrast = KParamMin; |
|
164 } |
|
165 break; |
|
166 } |
|
167 case EParamOperationAdd: |
|
168 { |
|
169 iContrast += KParamStep; |
|
170 if ( iContrast > KParamMax ) |
|
171 { |
|
172 iContrast = KParamMax; |
|
173 } |
|
174 break; |
|
175 } |
|
176 case EParamOperationDefault: |
|
177 { |
|
178 iContrast = KParamDef; |
|
179 break; |
|
180 } |
|
181 default: |
|
182 { |
|
183 break; |
|
184 } |
|
185 } |
|
186 } |
|
187 |
|
188 //============================================================================= |
|
189 TReal CImageEditorContrastPlugin::GetParam () const |
|
190 { |
|
191 return (TReal)(iContrast) / (KParamMax - KParamMin); |
|
192 } |
|
193 |
|
194 // End of File |