imageeditor/plugins/DrawPlugin/src/imageeditordrawplugin.cpp
author qifeima <>
Thu, 03 Jun 2010 18:57:10 +0800
changeset 8 18b321db4884
parent 1 edfc90759b9f
permissions -rw-r--r--
*m enhance
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     1
/*
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     2
 * Copyright (c) 2010 Ixonos Plc.
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     3
 * All rights reserved.
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     4
 * This component and the accompanying materials are made available
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     5
 * under the terms of the "Eclipse Public License v1.0"
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     6
 * which accompanies this distribution, and is available
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     8
 *
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     9
 * Initial Contributors:
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    10
 * Nokia Corporation - Initial contribution
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    11
 *
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    12
 * Contributors:
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    13
 * Ixonos Plc
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    14
 *
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    15
 * Description: 
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    16
 * Freehand draw UI plugin that sends UI commands to 
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    17
 * corresponding filter plugin. (filterdraw.dll).
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    18
 *
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    19
 */
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    20
#include "ImageEditordrawPlugin.h"
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    21
#include "ImageEditordrawControl.h"
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    22
#include "ImageEditorPluginBaseDefs.h"
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    23
#include "DrawUtils.h"
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    24
#include "SystemParameters.h"
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    25
#include "drawpath.h"
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    26
#ifdef TEXT_INSERTION_IN_PORTRAIT_ONLY
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    27
#include <aknappui.h>
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    28
#endif
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    29
#include <aknquerydialog.h> 
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    30
//	CONSTANTS
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    31
_LIT (KPgnResourceFile, "draw.rsc");
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    32
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    33
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    34
// CreateImageEditorPlugin
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    35
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    36
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    37
EXPORT_C CImageEditorPluginBase * CreateImageEditorPluginL()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    38
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    39
	CImageEditorDrawPlugin * plugin = new (ELeave) CImageEditorDrawPlugin;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    40
	CleanupStack::PushL(plugin);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    41
	plugin->ConstructL();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    42
	CleanupStack::Pop(); // plugin
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    43
	return plugin;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    44
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    45
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    46
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    47
// CImageEditorDrawPlugin
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    48
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    49
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    50
CImageEditorDrawPlugin::CImageEditorDrawPlugin() :
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    51
	iLandscapeEnabled(EFalse)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    52
	{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    53
	}
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    54
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    55
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    56
// ConstructL
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    57
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    58
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    59
inline void CImageEditorDrawPlugin::ConstructL()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    60
	{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    61
	CImageEditorPluginBase::ConstructL(KPgnResourcePath, KPgnResourceFile);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    62
	iRgb = KRgbWhite;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    63
	iSize = TSize(8, 8);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    64
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    65
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    66
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    67
// ?description_if_needed
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    68
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    69
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    70
CImageEditorDrawPlugin::~CImageEditorDrawPlugin()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    71
	{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    72
	ReleasePlugin();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    73
	iSysPars = NULL;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    74
	iPaths.ResetAndDestroy();
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    75
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    76
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    77
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    78
// SetProperty
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    79
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    80
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    81
TInt CImageEditorDrawPlugin::SetProperty(TInt aPropertyId,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    82
		TDesC& aPropertyValue)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    83
	{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    84
	TInt err(KErrNone);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    85
	TLex parser;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    86
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    87
	//	Copy data
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    88
	switch (aPropertyId)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    89
		{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    90
		case KCapSystemParameters:
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    91
			{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    92
			parser.Assign(aPropertyValue);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    93
			TInt tempval = 0;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    94
			parser.Val(tempval);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    95
			iSysPars = (const CSystemParameters *) tempval;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    96
			err = KErrNone;
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    97
			break;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    98
			}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    99
		default:
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   100
			{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   101
			err = CImageEditorPluginBase::SetProperty(aPropertyId,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   102
					aPropertyValue);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   103
			break;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   104
			}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   105
		}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   106
	return err;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   107
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   108
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   109
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   110
// GetProperty
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   111
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   112
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   113
TInt CImageEditorDrawPlugin::GetProperty(TInt aPropertyId, TDes& aPropertyValue)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   114
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   115
	//	Clean buffer
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   116
	aPropertyValue.Zero();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   117
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   118
	//	Copy data
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   119
	switch (aPropertyId)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   120
		{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   121
		case KCapParamStruct:
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   122
			{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   123
			// Control found
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   124
			if (iControl)
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   125
				{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   126
				aPropertyValue.Copy(
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   127
						((CImageEditorDrawControl *) iControl)->GetParam());
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   128
				return KErrNone;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   129
				}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   130
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   131
			//	Control not found, return KErrNotReady
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   132
			else
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   133
				{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   134
				return KErrNotReady;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   135
				}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   136
			}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   137
		case KCapReadyToRender:
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   138
			{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   139
			TBool readytorender = ETrue;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   140
			if (iControl)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   141
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   142
				readytorender
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   143
						= ((CImageEditorDrawControl *) iControl)->IsReadyToRender();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   144
				}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   145
			aPropertyValue.AppendNum((TInt) readytorender);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   146
			return KErrNone;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   147
			}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   148
		case KCapIsLandscapeEnabled:
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   149
			{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   150
			aPropertyValue.AppendNum((TInt) iLandscapeEnabled);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   151
			return KErrNone;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   152
			}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   153
		case KCapIsSlowPlugin:
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   154
			{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   155
			aPropertyValue.AppendNum((TInt) ETrue);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   156
			return KErrNone;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   157
			}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   158
		default:
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   159
			{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   160
			return CImageEditorPluginBase::GetProperty(aPropertyId,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   161
					aPropertyValue);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   162
			}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   163
		}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   164
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   165
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   166
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   167
// InitPluginL
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   168
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   169
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   170
TInt CImageEditorDrawPlugin::InitPluginL(const TRect& aRect,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   171
		CCoeControl* aParent, CCoeControl*& aPluginControl)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   172
	{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   173
	//  Delete previous control
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   174
	ReleasePlugin();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   175
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   176
	//	Get pointer to the parameter descriptor array
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   177
	TBuf<256> readbuf;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   178
	TLex parser;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   179
	User::LeaveIfError(CImageEditorPluginBase::GetProperty(
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   180
			KCapPluginParamNames, readbuf));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   181
	parser.Assign(readbuf);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   182
	TInt tempval = 0;
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   183
	parser.Val(tempval);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   184
	//CDesCArray * pars = (CDesCArray *)tempval;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   185
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   186
#ifdef TEXT_INSERTION_IN_PORTRAIT_ONLY
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   187
	// Text input is always insterted in portrait mode.
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   188
	// Store the original orientation before forcing to portrait.
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   189
	CAknAppUiBase* appUi = static_cast<CAknAppUiBase *>(
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   190
			CEikonEnv::Static()->EikAppUi() );
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   191
	CAknAppUiBase::TAppUiOrientation originalOrientation =
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   192
	appUi->Orientation();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   193
	appUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationPortrait);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   194
#endif
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   195
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   196
	CalculatePositionOnView();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   197
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   198
	iControl = CImageEditorDrawControl::NewL(aRect, aParent, iPaths, iRgb, iSize,iDiplayToolPluginParam);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   199
	aPluginControl = iControl;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   200
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   201
	//  Set system parameters
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   202
	((CImageEditorDrawControl*) iControl)->SetSystemParameters(iSysPars);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   203
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   204
	iVisibleImageRectPrevFirst = iSysPars->VisibleImageRectPrev();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   205
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   206
	iLandscapeEnabled = ETrue;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   207
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   208
#ifdef TEXT_INSERTION_IN_PORTRAIT_ONLY
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   209
	// Set always back to original orientation, even if leaves
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   210
	CAknAppUiBase::TAppUiOrientation orientation = appUi->Orientation();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   211
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   212
	if (orientation != originalOrientation)
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   213
		{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   214
		appUi->SetOrientationL(originalOrientation);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   215
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   216
		// Send screen device change event to validate screen
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   217
		TWsEvent event;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   218
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   219
		RWsSession& rws = CEikonEnv::Static()->WsSession();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   220
		event.SetType( EEventScreenDeviceChanged );
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   221
		event.SetTimeNow();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   222
		event.SetHandle( rws.WsHandle() );
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   223
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   224
		User::LeaveIfError( rws.SendEventToAllWindowGroups(event) );
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   225
		}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   226
#else
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   227
#ifdef LANDSCAPE_ONLY
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   228
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   229
	appUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   230
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   231
	// Send screen device change event to validate screen
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   232
	TWsEvent event;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   233
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   234
	RWsSession& rws = CEikonEnv::Static()->WsSession();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   235
	event.SetType( EEventScreenDeviceChanged );
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   236
	event.SetTimeNow();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   237
	event.SetHandle( rws.WsHandle() );
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   238
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   239
	User::LeaveIfError( rws.SendEventToAllWindowGroups(event) );
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   240
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   241
#endif
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   242
#endif
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   243
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   244
	return KErrNone;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   245
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   246
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   247
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   248
// ProcessImageL
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   249
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   250
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   251
void CImageEditorDrawPlugin::ProcessImageL(CEditorImage * /*aImage*/)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   252
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   253
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   254
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   255
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   256
// ReleasePlugin
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   257
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   258
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   259
void CImageEditorDrawPlugin::ReleasePlugin()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   260
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   261
	delete iControl;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   262
	iControl = NULL;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   263
	}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   264
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   265
// CalculatePositionOnView
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   266
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   267
//
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   268
void CImageEditorDrawPlugin::CalculatePositionOnView()
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   269
	{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   270
	if (iPaths.Count() > 0)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   271
		{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   272
		// new image rect on preview
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   273
		TRect rectPrevLast = iSysPars->VisibleImageRectPrev(); 
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   274
		//real image rect
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   275
		TRect rectReal = iSysPars->VisibleImageRect();  
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   276
		//the old position of old image rect
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   277
		TInt xPositionPrevFirst = iVisibleImageRectPrevFirst.iTl.iX; 
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   278
		TInt yPositionPrevFirst = iVisibleImageRectPrevFirst.iTl.iY;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   279
		//the old width and height of old image rect
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   280
		TInt xPosFactorDivider = iVisibleImageRectPrevFirst.Width();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   281
		TInt yPosFactorDivider = iVisibleImageRectPrevFirst.Height();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   282
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   283
		for (TInt i(0); i < iPaths.Count(); ++i)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   284
			{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   285
			CDrawPath* path = iPaths[i];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   286
			CArrayFix<TPoint>* pathPoints = path->ItemArray();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   287
			if (pathPoints && (pathPoints->Count() > 0))
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   288
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   289
				for (TInt i(0); i < pathPoints->Count(); ++i)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   290
					{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   291
					//the old absolute point on screen 
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   292
					TPoint & point = (*pathPoints)[i];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   293
					//the relative position on old image rect
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   294
					TInt xPositionCompareFirst = point.iX - xPositionPrevFirst;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   295
					TInt yPositionCompareFirst = point.iY - yPositionPrevFirst;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   296
					//the relative position on new image rect
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   297
					TReal xPositionCompareLast = TReal(rectPrevLast.Width()
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   298
							* xPositionCompareFirst)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   299
							/ iVisibleImageRectPrevFirst.Width();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   300
					TReal yPositionCompareLast = TReal(rectPrevLast.Height()
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   301
							* yPositionCompareFirst)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   302
							/ iVisibleImageRectPrevFirst.Height();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   303
					//the new absolute position on screen
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   304
					TInt xPositionOnView = rectPrevLast.iTl.iX
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   305
							+ xPositionCompareLast;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   306
					TInt yPositionOnView = rectPrevLast.iTl.iY
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   307
							+ yPositionCompareLast;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   308
					point.SetXY(xPositionOnView, yPositionOnView);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   309
					}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   310
				}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   311
			}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   312
		}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   313
	}
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   314
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   315
// End of File