|
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 * Brightness plugin plugin base class. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /// INCLUDES |
|
22 #include "ImageEditorBrightnessPlugin.h" |
|
23 #include "SingleParamControl.h" |
|
24 #include <brightness.mbg> |
|
25 |
|
26 /// CONSTANTS |
|
27 _LIT (KPgnResourceFile, "brightness.rsc"); |
|
28 |
|
29 const long KParamMin = -100; |
|
30 const long KParamMax = 100; |
|
31 const long KParamStep = 10; |
|
32 const long KParamDef = 0; |
|
33 const TInt KBrightnessHSTitleIndex = 0; |
|
34 |
|
35 // brightness tag |
|
36 _LIT (KBrightnessTag, "brightness "); |
|
37 _LIT (KResourceDir, "\\resource\\apps\\"); |
|
38 |
|
39 //============================================================================= |
|
40 EXPORT_C CImageEditorPluginBase * CreateImageEditorPlugin () |
|
41 { |
|
42 CImageEditorBrightnessPlugin * plugin = new (ELeave) CImageEditorBrightnessPlugin; |
|
43 CleanupStack::PushL(plugin); |
|
44 plugin->ConstructL(); |
|
45 CleanupStack::Pop(); // plugin |
|
46 return plugin; |
|
47 } |
|
48 |
|
49 //============================================================================= |
|
50 CImageEditorBrightnessPlugin::CImageEditorBrightnessPlugin () : |
|
51 CImageEditorPluginBase() |
|
52 { |
|
53 |
|
54 } |
|
55 |
|
56 //============================================================================= |
|
57 void CImageEditorBrightnessPlugin::ConstructL () |
|
58 { |
|
59 CImageEditorPluginBase::ConstructL (KPgnResourcePath, KPgnResourceFile); |
|
60 } |
|
61 |
|
62 //============================================================================= |
|
63 CImageEditorBrightnessPlugin::~CImageEditorBrightnessPlugin () |
|
64 { |
|
65 ReleasePlugin(); |
|
66 } |
|
67 |
|
68 //============================================================================= |
|
69 TInt CImageEditorBrightnessPlugin::SetProperty ( |
|
70 TInt /*aPropertyId*/, |
|
71 TDesC & /*aPropertyValue*/ |
|
72 ) |
|
73 { |
|
74 return KErrNotSupported; |
|
75 } |
|
76 |
|
77 //============================================================================= |
|
78 TInt CImageEditorBrightnessPlugin::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 (KBrightnessTag); |
|
92 aPropertyValue.AppendNum (iBrightness); |
|
93 return KErrNone; |
|
94 } |
|
95 default: |
|
96 { |
|
97 return CImageEditorPluginBase::GetProperty (aPropertyId, aPropertyValue); |
|
98 } |
|
99 } |
|
100 } |
|
101 |
|
102 //============================================================================= |
|
103 TInt CImageEditorBrightnessPlugin::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 vertical 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 EMbmBrightnessQgn_indi_imed_bright_super, |
|
125 EMbmBrightnessQgn_indi_imed_bright_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)[KBrightnessHSTitleIndex] ); |
|
136 |
|
137 return KErrNone; |
|
138 } |
|
139 |
|
140 //============================================================================= |
|
141 void CImageEditorBrightnessPlugin::ProcessImageL (CEditorImage * /*aImage*/ ) |
|
142 { |
|
143 // Own image processing functionality here |
|
144 } |
|
145 |
|
146 //============================================================================= |
|
147 void CImageEditorBrightnessPlugin::ReleasePlugin () |
|
148 { |
|
149 delete iControl; |
|
150 iControl = 0; |
|
151 } |
|
152 |
|
153 //============================================================================= |
|
154 void CImageEditorBrightnessPlugin::ParamOperation (const TParamOperation aOperation) |
|
155 { |
|
156 switch (aOperation) |
|
157 { |
|
158 case EParamOperationSubtract: |
|
159 { |
|
160 |
|
161 iBrightness -= KParamStep; |
|
162 if ( iBrightness < KParamMin ) |
|
163 { |
|
164 iBrightness = KParamMin; |
|
165 } |
|
166 break; |
|
167 } |
|
168 case EParamOperationAdd: |
|
169 { |
|
170 iBrightness += KParamStep; |
|
171 if ( iBrightness > KParamMax ) |
|
172 { |
|
173 iBrightness = KParamMax; |
|
174 } |
|
175 break; |
|
176 } |
|
177 case EParamOperationDefault: |
|
178 { |
|
179 iBrightness = KParamDef; |
|
180 break; |
|
181 } |
|
182 default: |
|
183 { |
|
184 break; |
|
185 } |
|
186 } |
|
187 } |
|
188 |
|
189 //============================================================================= |
|
190 TReal CImageEditorBrightnessPlugin::GetParam () const |
|
191 { |
|
192 return (TReal)( (TReal)iBrightness / (KParamMax - KParamMin) ); |
|
193 } |
|
194 |
|
195 // End of File |