imageeditor/plugins/RedEyePlugin/src/ImageEditorRedEyeReductionPlugin.cpp
changeset 1 edfc90759b9f
equal deleted inserted replaced
0:57d4cdd99204 1:edfc90759b9f
       
     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 * Image editor RedEyeReduction plugin implementation.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #include <aknquerydialog.h> 
       
    23 
       
    24 #include "ImageEditorRedEyeReductionPlugin.h"
       
    25 #include "ImageEditorRedEyeReductionControl.h"
       
    26 #include "ImageEditorPluginBaseDefs.h"
       
    27 #include "DrawUtils.h"
       
    28 
       
    29 //	CONSTANTS
       
    30 _LIT (KPgnResourceFile, "redeyereduction.rsc");
       
    31 
       
    32 
       
    33 //=============================================================================
       
    34 EXPORT_C CImageEditorPluginBase * CreateImageEditorPlugin ()
       
    35 {
       
    36 	CImageEditorRedEyeReductionPlugin * plugin = new (ELeave) CImageEditorRedEyeReductionPlugin;
       
    37 	CleanupStack::PushL(plugin);
       
    38 	plugin->ConstructL();
       
    39 	CleanupStack::Pop(); // plugin
       
    40     return plugin;
       
    41 }
       
    42 
       
    43 //=============================================================================
       
    44 CImageEditorRedEyeReductionPlugin::CImageEditorRedEyeReductionPlugin ()
       
    45 {
       
    46 
       
    47 }
       
    48 
       
    49 //=============================================================================
       
    50 void CImageEditorRedEyeReductionPlugin::ConstructL ()
       
    51 {
       
    52     CImageEditorPluginBase::ConstructL (KPgnResourcePath, KPgnResourceFile);
       
    53 }
       
    54 
       
    55 //=============================================================================
       
    56 CImageEditorRedEyeReductionPlugin::~CImageEditorRedEyeReductionPlugin ()
       
    57 {
       
    58     ReleasePlugin();
       
    59     iSysPars = NULL;
       
    60     iControl = NULL;
       
    61 }
       
    62 
       
    63 //=============================================================================
       
    64 TInt CImageEditorRedEyeReductionPlugin::SetProperty (
       
    65 	TInt		aPropertyId, 
       
    66 	TDesC &		aPropertyValue
       
    67 	)
       
    68 {
       
    69 
       
    70     TLex	parser;
       
    71 
       
    72     //	Copy data
       
    73     switch (aPropertyId) 
       
    74     {
       
    75         case KCapSystemParameters:
       
    76         {
       
    77             parser.Assign (aPropertyValue);
       
    78             TInt tempval = 0;
       
    79             parser.Val (tempval);
       
    80             iSysPars = (const CSystemParameters *)tempval;
       
    81             return KErrNone;
       
    82         }
       
    83         default:
       
    84         {
       
    85             return CImageEditorPluginBase::SetProperty (aPropertyId, aPropertyValue);
       
    86         }
       
    87     }
       
    88 }
       
    89 
       
    90 //=============================================================================
       
    91 TInt CImageEditorRedEyeReductionPlugin::GetProperty (
       
    92 	TInt		aPropertyId, 
       
    93 	TDes  &		aPropertyValue
       
    94 	)
       
    95 {
       
    96 	//	Clean buffer
       
    97 	aPropertyValue.Zero();
       
    98 
       
    99 	//	Copy data
       
   100 	switch (aPropertyId) 
       
   101 	{
       
   102 		case KCapParamStruct:
       
   103 		{
       
   104 			TRect rect = ((CImageEditorRedEyeReductionControl *)iControl)->GetParam();
       
   105 			if (rect.iBr.iX <= 0 || rect.iBr.iY <= 0)
       
   106 			{
       
   107 				aPropertyValue.Copy (_L("nop"));
       
   108 			}
       
   109 			else
       
   110 			{
       
   111 				aPropertyValue.Copy (_L("ulc "));
       
   112 				aPropertyValue.AppendNum (rect.iTl.iX);
       
   113 				aPropertyValue.Append (_L(" ulr "));
       
   114 				aPropertyValue.AppendNum (rect.iTl.iY);
       
   115 				aPropertyValue.Append (_L(" lrc "));
       
   116 				aPropertyValue.AppendNum (rect.iBr.iX);
       
   117 				aPropertyValue.Append (_L(" lrr "));
       
   118 				aPropertyValue.AppendNum (rect.iBr.iY);
       
   119 			}
       
   120 			return KErrNone;
       
   121 		}
       
   122         case KCapReadyToRender:
       
   123 		{
       
   124             TBool readyToRender = EFalse;
       
   125             if (iControl)
       
   126                 {
       
   127                 readyToRender = ((CImageEditorRedEyeReductionControl *)iControl)->IsReadyToRender();
       
   128                 }
       
   129   
       
   130 			aPropertyValue.AppendNum ((TInt)readyToRender);
       
   131 			return KErrNone;
       
   132 		}
       
   133 		default:
       
   134 		{
       
   135 			return CImageEditorPluginBase::GetProperty (aPropertyId, aPropertyValue);
       
   136 		}
       
   137 	}
       
   138 }
       
   139 
       
   140 //=============================================================================
       
   141 TInt CImageEditorRedEyeReductionPlugin::InitPluginL (
       
   142 	const TRect &		aRect,
       
   143 	CCoeControl *		aParent,
       
   144 	CCoeControl *&		aPluginControl
       
   145 	)
       
   146 {
       
   147     //  Delete previous control
       
   148 	ReleasePlugin();
       
   149 
       
   150 	// Create the control
       
   151     iControl = CImageEditorRedEyeReductionControl::NewL (aRect, aParent);
       
   152     aPluginControl = iControl;
       
   153 
       
   154     //  Set system parameters
       
   155     ((CImageEditorRedEyeReductionControl*)iControl)->SetSystemParameters (iSysPars);
       
   156 
       
   157     return KErrNone;
       
   158 }
       
   159 
       
   160 //=============================================================================
       
   161 void CImageEditorRedEyeReductionPlugin::ProcessImageL (CEditorImage * /*aImage*/ )
       
   162 {
       
   163 
       
   164 }
       
   165 
       
   166 //=============================================================================
       
   167 void CImageEditorRedEyeReductionPlugin::ReleasePlugin ()
       
   168 {
       
   169 	delete iControl;
       
   170 	iControl = 0;
       
   171 }
       
   172 
       
   173 // End of File