imageeditor/ImageEditorUI/src/SingleParamControl.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  *
       
    17 */
       
    18 
       
    19 
       
    20 //  INCLUDES
       
    21 #include <fbs.h>
       
    22 #include <aknview.h>
       
    23 #include <aknutils.h>
       
    24 #include <AknIconUtils.h>
       
    25 #include <ImageEditorUi.mbg>
       
    26 #include <AknLayoutScalable_Avkon.cdl.h>
       
    27 #include <AknLayoutScalable_Apps.cdl.h>
       
    28 #include <eiklabel.h>
       
    29 
       
    30 #ifdef RD_TACTILE_FEEDBACK 
       
    31 #include <touchfeedback.h>
       
    32 #endif /* RD_TACTILE_FEEDBACK  */
       
    33 
       
    34 #include "ImageEditorUI.hrh"
       
    35 #include "ImageEditorUiDefs.h"
       
    36 #include "SingleParamControl.h"
       
    37 #include "PreviewControlBase.h"
       
    38 #include "SingleParamControlObserver.h"
       
    39 #include "PluginInfo.h"
       
    40 #include "CustomControlPanics.h"
       
    41 
       
    42 // constants
       
    43 const TReal KTouchSensitivity = 0.5;
       
    44 const TInt KBorderPartsNum = 9;
       
    45 const TInt KSliderPartsNum = 4;
       
    46 const TInt KTouchSliderPartsNum = 7;
       
    47 const TInt KSliderWidth = 20;
       
    48 const TInt KScrollRepeatTimeout = 250000; // 0.25 seconds
       
    49 
       
    50 //=============================================================================
       
    51 EXPORT_C CSingleParamControl * CSingleParamControl::NewL (
       
    52 		const TRect & aRect,
       
    53 		CCoeControl * aParent,
       
    54 		TBool aActionOnButtonRelease
       
    55 )
       
    56 	{
       
    57 	CSingleParamControl * self = new (ELeave) CSingleParamControl;
       
    58 	CleanupStack::PushL (self);
       
    59 	self->ConstructL (aRect, aParent, aActionOnButtonRelease);
       
    60 	CleanupStack::Pop (); // self
       
    61 	return self;
       
    62 	}
       
    63 
       
    64 //=============================================================================
       
    65 EXPORT_C CSingleParamControl::CSingleParamControl()
       
    66 : iDragging( EFalse ),
       
    67 iActionOnButtonRelease( EFalse ),
       
    68 iTouchRect(0,0,0,0),
       
    69 iMinimumValue(0),
       
    70 iMaximumValue(1),
       
    71 iStep(0),
       
    72 iStepInPixels(0),
       
    73 iNumberOfSteps(0),
       
    74 iPosition(0),
       
    75 iMarkerPressed( EFalse )
       
    76 	{
       
    77 	}
       
    78 
       
    79 //=============================================================================
       
    80 EXPORT_C void CSingleParamControl::ConstructL (
       
    81 		const TRect & /*aRect*/,
       
    82 		CCoeControl * aParent,
       
    83 		TBool aActionOnButtonRelease
       
    84 )
       
    85 	{
       
    86 	//	Set parent
       
    87 	SetContainerWindowL (*aParent);
       
    88 
       
    89 	TFileName iconFile (KImageEditorUiMifFile);
       
    90 
       
    91 	// create popup and slider graphics
       
    92 	for ( TInt i = 0; i < KBorderPartsNum; ++i )
       
    93 		{
       
    94 		CEikImage* image = new (ELeave) CEikImage;
       
    95 
       
    96 		image->CreatePictureFromFileL(iconFile,
       
    97 				EMbmImageeditoruiQgn_graf_popup_trans_center + 2*i,
       
    98 				EMbmImageeditoruiQgn_graf_popup_trans_center_mask + 2*i);
       
    99 
       
   100 		CleanupStack::PushL( image );
       
   101 		image->SetContainerWindowL( *this );
       
   102 		iBorders.AppendL( image );
       
   103 		CleanupStack::Pop( image );
       
   104 		}
       
   105 	if( AknLayoutUtils::PenEnabled() )
       
   106 		{
       
   107 		for ( TInt i = 0; i < KTouchSliderPartsNum; ++i )
       
   108 			{
       
   109 			CEikImage* image = new (ELeave) CEikImage;
       
   110 
       
   111 			image->CreatePictureFromFileL(iconFile,
       
   112 					EMbmImageeditoruiQgn_graf_nslider_end_left + 2*i,
       
   113 					EMbmImageeditoruiQgn_graf_nslider_end_left_mask + 2*i);
       
   114 
       
   115 			CleanupStack::PushL( image );
       
   116 			image->SetContainerWindowL( *this );
       
   117 			iScrollBar.AppendL( image );
       
   118 			CleanupStack::Pop( image );
       
   119 			}
       
   120 		}
       
   121 	else
       
   122 		{
       
   123 		for ( TInt i = 0; i < KSliderPartsNum; ++i )
       
   124 			{
       
   125 			CEikImage* image = new (ELeave) CEikImage;
       
   126 
       
   127 			image->CreatePictureFromFileL(iconFile,
       
   128 					EMbmImageeditoruiQgn_graf_nslider_imed_end_left + 2*i,
       
   129 					EMbmImageeditoruiQgn_graf_nslider_imed_end_left_mask + 2*i);
       
   130 
       
   131 			CleanupStack::PushL( image );
       
   132 			image->SetContainerWindowL( *this );
       
   133 			iScrollBar.AppendL( image );
       
   134 			CleanupStack::Pop( image );
       
   135 			}
       
   136 		}
       
   137 
       
   138 	iText = new (ELeave) CEikLabel;
       
   139 	iText->SetContainerWindowL( *this );
       
   140 	iActionOnButtonRelease = aActionOnButtonRelease;
       
   141 
       
   142 #ifdef RD_TACTILE_FEEDBACK 
       
   143     iTouchFeedBack = MTouchFeedback::Instance();
       
   144 #endif /* RD_TACTILE_FEEDBACK  */
       
   145 	
       
   146 	EnableDragEvents();
       
   147 
       
   148 	//	Activate control
       
   149 	ActivateL();
       
   150 	}
       
   151 
       
   152 //=============================================================================
       
   153 EXPORT_C CSingleParamControl::~CSingleParamControl()
       
   154 	{
       
   155 	iBorders.ResetAndDestroy();
       
   156 	iScrollBar.ResetAndDestroy();
       
   157 	if (iIcon)
       
   158 		{
       
   159 		delete iIcon;
       
   160 		}
       
   161 	delete iText;
       
   162 
       
   163 	iParObserver = NULL;
       
   164 	iItem = NULL;
       
   165 	iEditorView = NULL;
       
   166 	}
       
   167 
       
   168 //=============================================================================
       
   169 EXPORT_C void CSingleParamControl::SetView (CAknView * aView)
       
   170 	{
       
   171 	iEditorView = aView;
       
   172 	}
       
   173 
       
   174 EXPORT_C void CSingleParamControl::SetIcon(CEikImage* aIcon)
       
   175 	{
       
   176 	iIcon = aIcon;
       
   177 	}
       
   178 
       
   179 EXPORT_C void CSingleParamControl::SetCaption(const TDesC& aText)
       
   180 	{
       
   181 	iText->SetTextL( aText );
       
   182 	}
       
   183 
       
   184 //=============================================================================
       
   185 EXPORT_C void CSingleParamControl::SetSelectedUiItemL (CPluginInfo * aItem)
       
   186 	{
       
   187 	iItem = aItem;
       
   188 	}
       
   189 
       
   190 //=============================================================================
       
   191 EXPORT_C TKeyResponse CSingleParamControl::OfferKeyEventL (
       
   192 		const TKeyEvent & aKeyEvent,
       
   193 		TEventCode aType
       
   194 )
       
   195 	{
       
   196 	if ( Busy() )
       
   197 		{
       
   198 		return EKeyWasConsumed;
       
   199 		}
       
   200 	else
       
   201 		{
       
   202 		if (EEventKey == aType)
       
   203 			{
       
   204 			switch (aKeyEvent.iCode)
       
   205 				{
       
   206 
       
   207 				case EKeyRightArrow:
       
   208 					{
       
   209 					if ( iPosition == iMaximumValue )
       
   210 						{
       
   211 						return EKeyWasConsumed;
       
   212 						}
       
   213 					MoveSlider(1);
       
   214 					if( iActionOnButtonRelease )
       
   215 						{
       
   216 						iEditorView->HandleCommandL (EImageEditorCmdRender);
       
   217 						DrawDeferred();
       
   218 						}				
       
   219 					return EKeyWasConsumed;
       
   220 					}
       
   221 				case EKeyLeftArrow:
       
   222 					{
       
   223 					if ( iPosition == iMinimumValue )
       
   224 						{
       
   225 						return EKeyWasConsumed;
       
   226 						}
       
   227 					MoveSlider(-1);
       
   228 					if( iActionOnButtonRelease )
       
   229 						{
       
   230 						iEditorView->HandleCommandL (EImageEditorCmdRender);
       
   231 						DrawDeferred();
       
   232 						}	
       
   233 					return EKeyWasConsumed;
       
   234 					}
       
   235 
       
   236 				case EKeyOK:
       
   237 				case EKeyEnter:
       
   238 					{
       
   239 					// Cancel plug-in if no changes made
       
   240 					iEditorView->HandleCommandL (EImageEditorApplyPlugin);
       
   241 					return EKeyWasConsumed;
       
   242 					}
       
   243 
       
   244 				case EKeyDownArrow:
       
   245 				case EKeyUpArrow:
       
   246 					{
       
   247 					return EKeyWasConsumed;
       
   248 					}
       
   249 
       
   250 				default:
       
   251 					{
       
   252 					break;
       
   253 					}
       
   254 				}
       
   255 			}
       
   256 		return EKeyWasNotConsumed;
       
   257 		}
       
   258 	}
       
   259 
       
   260 //=============================================================================
       
   261 EXPORT_C void CSingleParamControl::HandlePointerEventL(const TPointerEvent &aPointerEvent)
       
   262 	{
       
   263 	if( AknLayoutUtils::PenEnabled() )
       
   264 		{
       
   265 		if( iTouchRect.Contains( aPointerEvent.iPosition ) )
       
   266 			{
       
   267 			TRect markerRect = iScrollBar[KSliderPartsNum - 1]->Rect();
       
   268 			markerRect.iTl.iX -= KSliderWidth / 2;
       
   269 			markerRect.iBr.iX += KSliderWidth / 2;
       
   270 			// marker pressed?
       
   271 			if( markerRect.Contains( aPointerEvent.iPosition ) )
       
   272 				{
       
   273 				if( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   274 					{
       
   275 					iDragging = ETrue;
       
   276 					iMarkerPressed = ETrue;
       
   277 					
       
   278 #ifdef RD_TACTILE_FEEDBACK
       
   279 					if ( iTouchFeedBack )
       
   280 						{
       
   281 						iTouchFeedBack->InstantFeedback( ETouchFeedbackBasic );
       
   282 						RDebug::Printf( "ImageEditor::SingleParamControl: ETouchFeedback" );
       
   283 						}
       
   284 #endif /* RD_TACTILE_FEEDBACK  */
       
   285 					
       
   286 					DrawDeferred();
       
   287 					return;
       
   288 					}
       
   289 				}
       
   290 
       
   291 			// marker dragged?
       
   292 			if (iDragging)
       
   293 				{
       
   294 				if( aPointerEvent.iType == TPointerEvent::EButton1Up
       
   295 						|| aPointerEvent.iType == TPointerEvent::EDrag )
       
   296 					{
       
   297 					TInt markerCenter = iScrollBar[KSliderPartsNum - 1]->Rect().iTl.iX
       
   298 					+ (iScrollBar[KSliderPartsNum - 1]->Rect().iBr.iX
       
   299 							- iScrollBar[KSliderPartsNum - 1]->Rect().iTl.iX) / 2;
       
   300 
       
   301 					if(aPointerEvent.iPosition.iX> iScrollBar[KSliderPartsNum - 1]->Rect().iBr.iX)
       
   302 						{
       
   303 						MoveSlider((((TReal) (aPointerEvent.iPosition.iX
       
   304 														- markerCenter))
       
   305 										/ iStepInPixels) + KTouchSensitivity);
       
   306 						}
       
   307 					else if(aPointerEvent.iPosition.iX < iScrollBar[KSliderPartsNum - 1]->Rect().iTl.iX)
       
   308 						{
       
   309 						MoveSlider((((TReal) (aPointerEvent.iPosition.iX
       
   310 														- markerCenter))
       
   311 										/ iStepInPixels) - KTouchSensitivity);
       
   312 						}
       
   313 					}
       
   314 				if( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   315 					{
       
   316 					if( iActionOnButtonRelease )
       
   317 						{
       
   318 						iEditorView->HandleCommandL (EImageEditorCmdRender);
       
   319 						}
       
   320 					iDragging = EFalse;
       
   321 					iMarkerPressed = EFalse;
       
   322 					DrawDeferred();
       
   323 					}
       
   324 				if( iActionOnButtonRelease )
       
   325 					{
       
   326 					DrawDeferred();
       
   327 					}
       
   328 				return;
       
   329 				}
       
   330 
       
   331 			// normal moving
       
   332 			if( aPointerEvent.iType == TPointerEvent::EButton1Down
       
   333 					|| aPointerEvent.iType == TPointerEvent::EButtonRepeat )
       
   334 				{
       
   335 				iMarkerPressed = ETrue;
       
   336 				if(aPointerEvent.iPosition.iX> iScrollBar[KSliderPartsNum - 1]->Rect().iBr.iX)
       
   337 					{
       
   338 					MoveSlider(1);
       
   339 					if( iActionOnButtonRelease )
       
   340 						{
       
   341 						iEditorView->HandleCommandL (EImageEditorCmdRender);
       
   342 						DrawDeferred();
       
   343 						}	
       
   344 					}
       
   345 				else if(aPointerEvent.iPosition.iX < iScrollBar[KSliderPartsNum - 1]->Rect().iTl.iX)
       
   346 					{
       
   347 					MoveSlider(-1);
       
   348 					if( iActionOnButtonRelease )
       
   349 						{
       
   350 						iEditorView->HandleCommandL (EImageEditorCmdRender);
       
   351 						DrawDeferred();
       
   352 						}
       
   353 					}
       
   354 				Window().RequestPointerRepeatEvent( KScrollRepeatTimeout, iTouchRect );
       
   355 
       
   356 #ifdef RD_TACTILE_FEEDBACK
       
   357 					if ( iTouchFeedBack &&
       
   358 							((aPointerEvent.iPosition.iX < markerRect.iTl.iX) ||
       
   359 							(aPointerEvent.iPosition.iX > markerRect.iBr.iX)) )
       
   360 						{
       
   361 						iTouchFeedBack->InstantFeedback( ETouchFeedbackBasic );
       
   362 						RDebug::Printf( "ImageEditor::SingleParamControl: ETouchFeedback" );
       
   363 						}
       
   364 #endif /* RD_TACTILE_FEEDBACK  */
       
   365 					
       
   366 				return;
       
   367 				}
       
   368 			}
       
   369 		if (iDragging && iMarkerPressed)
       
   370 			{
       
   371 			iEditorView->HandleCommandL (EImageEditorCmdRender);
       
   372 			}
       
   373 		
       
   374 		iDragging = EFalse;
       
   375 		iMarkerPressed = EFalse;
       
   376 		DrawDeferred();
       
   377 		return;
       
   378 		}
       
   379 	}
       
   380 
       
   381 //=============================================================================
       
   382 EXPORT_C void CSingleParamControl::HandlePluginCommandL (const TInt aCommand)
       
   383 	{
       
   384 	//  If soft key 1 pressed
       
   385 	if (aCommand == EAknSoftkeyOk)
       
   386 		{
       
   387 		// Cancel plug-in if no changes made
       
   388 		iEditorView->HandleCommandL (EImageEditorApplyPlugin);
       
   389 		}
       
   390 
       
   391 	//  If soft key 2 pressed
       
   392 
       
   393 	else if (aCommand == EAknSoftkeyCancel)
       
   394 		{
       
   395 		iEditorView->HandleCommandL (EImageEditorCancelPlugin);
       
   396 		}
       
   397 
       
   398 	//  Default functionality
       
   399 
       
   400 	else
       
   401 		{
       
   402 		CImageEditorControlBase::HandlePluginCommandL (aCommand);
       
   403 		}
       
   404 	}
       
   405 
       
   406 //=============================================================================
       
   407 EXPORT_C TInt CSingleParamControl::GetSoftkeyIndexL()
       
   408 	{
       
   409 	return 0;
       
   410 	}
       
   411 
       
   412 //=============================================================================
       
   413 EXPORT_C TPtrC CSingleParamControl::GetNaviPaneTextL (
       
   414 		TBool& aLeftNaviPaneScrollButtonVisibile,
       
   415 		TBool& aRightNaviPaneScrollButtonVisible )
       
   416 	{
       
   417 	aLeftNaviPaneScrollButtonVisibile = EFalse;
       
   418 	aRightNaviPaneScrollButtonVisible = EFalse;
       
   419 
       
   420 	// Don't show any text in navi pane
       
   421 	// The whole if-branch should probably be removed for good
       
   422 	TBool showNaviPaneText ( EFalse );
       
   423 
       
   424 	if ( iItem && showNaviPaneText )
       
   425 		{
       
   426 		return iItem->PluginName()->Des();
       
   427 		}
       
   428 	else
       
   429 		{
       
   430 		return TPtrC();
       
   431 		}
       
   432 	}
       
   433 
       
   434 //=============================================================================
       
   435 EXPORT_C void CSingleParamControl::SetParObserver (MSingleParControlObserver * aObserver)
       
   436 	{
       
   437 	iParObserver = aObserver;
       
   438 	}
       
   439 
       
   440 //=============================================================================
       
   441 EXPORT_C void CSingleParamControl::Draw (const TRect & aRect) const
       
   442 	{
       
   443 	TInt variety = 0;
       
   444 	if( AknLayoutUtils::PenEnabled() )
       
   445 		{
       
   446 		variety = 1;
       
   447 		}
       
   448 
       
   449 	TAknLayoutRect layoutRect;
       
   450 	layoutRect.LayoutRect( Rect(), AknLayoutScalable_Apps::popup_imed_adjust2_window(variety) );
       
   451 	TRect parentRect = layoutRect.Rect();
       
   452 
       
   453 	// centralize the slider
       
   454 	TPoint topLeft = parentRect.iTl;
       
   455 	topLeft.iX = (Rect().Width() - parentRect.Width()) / 2;
       
   456 	parentRect.SetRect(topLeft, parentRect.Size());
       
   457 
       
   458 	TAknWindowComponentLayout l = AknLayoutScalable_Apps::slider_imed_adjust_pane(variety);
       
   459 	TAknWindowLineLayout lineLayout = l.LayoutLine();
       
   460 	layoutRect.LayoutRect(parentRect, lineLayout);
       
   461 
       
   462 	TRect markerRect = layoutRect.Rect();
       
   463 	TUint sliderTabWidth = KSliderWidth;
       
   464 	TUint sliderBitmapWidth = layoutRect.Rect().Width() - sliderTabWidth;
       
   465 	if ( iMinimumValue < iMaximumValue )
       
   466 		{
       
   467 		if(AknLayoutUtils::LayoutMirrored())
       
   468 			{
       
   469         	markerRect.iTl.iX += (iPosition - iMinimumValue)
       
   470 			* sliderBitmapWidth
       
   471 			/ (iMaximumValue - iMinimumValue);
       
   472 			}
       
   473 		else
       
   474 			{
       
   475 			markerRect.iTl.iX += (iPosition - iMinimumValue)
       
   476 			* sliderBitmapWidth
       
   477 			/ (iMaximumValue - iMinimumValue);
       
   478 			}
       
   479 		iScrollBar[KSliderPartsNum - 1]->SetPosition(markerRect.iTl);
       
   480 		if( AknLayoutUtils::PenEnabled() )
       
   481 			{
       
   482 			iScrollBar[KTouchSliderPartsNum - 1]->SetPosition(markerRect.iTl);
       
   483 			}
       
   484 		}
       
   485 
       
   486 	if (iPreview)
       
   487 		{
       
   488 		CPreviewControlBase::DrawPreviewImage (aRect);
       
   489 		}
       
   490 	}
       
   491 
       
   492 //=============================================================================
       
   493 EXPORT_C TInt CSingleParamControl::CountComponentControls() const
       
   494 	{
       
   495 	TInt count = iBorders.Count();
       
   496 	count += iScrollBar.Count();
       
   497 
       
   498 	if( AknLayoutUtils::PenEnabled() )
       
   499 		{
       
   500 		count--;
       
   501 		}
       
   502 
       
   503 	if (iIcon)
       
   504 		{
       
   505 		count++;
       
   506 		}
       
   507 	count++;
       
   508 
       
   509 	return count;
       
   510 	}
       
   511 
       
   512 //=============================================================================
       
   513 EXPORT_C CCoeControl* CSingleParamControl::ComponentControl(TInt aIndex) const
       
   514 	{
       
   515 	if ( aIndex < iBorders.Count() )
       
   516 		{
       
   517 		return iBorders[aIndex];
       
   518 		}
       
   519 
       
   520 	TInt touchSelected = 0;
       
   521 	if( AknLayoutUtils::PenEnabled() )
       
   522 		{
       
   523 		touchSelected++;
       
   524 		}
       
   525 
       
   526 	if ( aIndex < iBorders.Count() + iScrollBar.Count() - touchSelected )
       
   527 		{
       
   528 		if ( iMarkerPressed && (aIndex - iBorders.Count() == 3) )
       
   529 			{
       
   530 			return iScrollBar[aIndex - iBorders.Count() + 3];
       
   531 			}
       
   532 		return iScrollBar[aIndex - iBorders.Count()];
       
   533 		}
       
   534 	if ( aIndex == iBorders.Count() + iScrollBar.Count() - touchSelected )
       
   535 		{
       
   536 		return iText;
       
   537 		}
       
   538 	return iIcon;
       
   539 	}
       
   540 
       
   541 //=============================================================================
       
   542 EXPORT_C void CSingleParamControl::SizeChanged()
       
   543 	{
       
   544 	CountImageSizesAndPositions();
       
   545 	}
       
   546 
       
   547 //=============================================================================
       
   548 EXPORT_C void CSingleParamControl::SetSliderMinimumAndMaximum(TInt aMin, TInt aMax)
       
   549 	{
       
   550 	iMinimumValue = aMin;
       
   551 	iMaximumValue = aMax;
       
   552 	}
       
   553 
       
   554 //=============================================================================
       
   555 EXPORT_C void CSingleParamControl::SetSliderPosition(TInt aPosition)
       
   556 	{
       
   557 	__ASSERT_ALWAYS( aPosition >= iMinimumValue, Panic(EHorizontalSliderPanicIndexUnderflow) );
       
   558 	__ASSERT_ALWAYS( aPosition <= iMaximumValue, Panic(EHorizontalSliderPanicIndexOverflow) );
       
   559 
       
   560 	iPosition = aPosition;
       
   561 	}
       
   562 
       
   563 //=============================================================================
       
   564 EXPORT_C void CSingleParamControl::SetSliderStep(TUint aStep)
       
   565 	{
       
   566 	iStep = aStep;
       
   567 
       
   568 	TInt variety = 0;
       
   569 	if( AknLayoutUtils::PenEnabled() )
       
   570 		{
       
   571 		variety = 1;
       
   572 		}
       
   573 
       
   574 	TAknLayoutRect layoutRect;
       
   575 	layoutRect.LayoutRect( Rect(), AknLayoutScalable_Apps::popup_imed_adjust2_window(variety) );
       
   576 	TRect parentRect = layoutRect.Rect();
       
   577 	TAknWindowComponentLayout l = AknLayoutScalable_Apps::slider_imed_adjust_pane(variety);
       
   578 	TAknWindowLineLayout lineLayout = l.LayoutLine();
       
   579 	layoutRect.LayoutRect(parentRect, lineLayout);
       
   580 
       
   581 	TUint sliderTabWidth = iScrollBar[KSliderPartsNum - 1]->Size().iWidth;
       
   582 	TUint sliderBitmapWidth = layoutRect.Rect().Width() - sliderTabWidth;
       
   583 
       
   584 	iStepInPixels = sliderBitmapWidth;
       
   585 	if ( iMinimumValue < iMaximumValue )
       
   586 		{
       
   587 		iStepInPixels = iStep * sliderBitmapWidth
       
   588 		/ (iMaximumValue - iMinimumValue);
       
   589 		}
       
   590 	}
       
   591 
       
   592 //=============================================================================
       
   593 EXPORT_C void CSingleParamControl::SetSliderStepAmount(TUint8 aAmount)
       
   594 	{
       
   595 		{
       
   596 		iNumberOfSteps = aAmount;
       
   597 
       
   598 		if(aAmount == 0)
       
   599 			{
       
   600 			iStep = 0;
       
   601 			}
       
   602 		else
       
   603 			{
       
   604 			iStep = (iMaximumValue - iMinimumValue) / aAmount;
       
   605 			}
       
   606 		}
       
   607 	}
       
   608 
       
   609 //=============================================================================
       
   610 EXPORT_C TInt CSingleParamControl::Position() const
       
   611 	{
       
   612 	return iPosition;
       
   613 	}
       
   614 
       
   615 //=============================================================================
       
   616 EXPORT_C void CSingleParamControl::CountImageSizesAndPositions()
       
   617 	{
       
   618 	TInt variety = 0;
       
   619 	if( AknLayoutUtils::PenEnabled() )
       
   620 		{
       
   621 		variety = 1;
       
   622 		}
       
   623 
       
   624 	TAknLayoutRect layoutRect;
       
   625 	layoutRect.LayoutRect( Rect(), AknLayoutScalable_Apps::popup_imed_adjust2_window(variety) );
       
   626 	TRect parentRect = layoutRect.Rect();
       
   627 
       
   628 	// centralize the slider
       
   629 	TPoint topLeft = parentRect.iTl;
       
   630 	topLeft.iX = (Rect().Width() - parentRect.Width()) / 2;
       
   631 	parentRect.SetRect(topLeft, parentRect.Size());
       
   632 
       
   633 	// determine popup border layouts
       
   634 	if(AknLayoutUtils::LayoutMirrored())
       
   635 		{
       
   636 		AknLayoutUtils::LayoutControl( iBorders[1], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g3().LayoutLine() );
       
   637 		AknLayoutUtils::LayoutControl( iBorders[2], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g2().LayoutLine() );
       
   638 		AknLayoutUtils::LayoutControl( iBorders[3], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g5().LayoutLine() );
       
   639 		AknLayoutUtils::LayoutControl( iBorders[4], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g4().LayoutLine() );
       
   640 		AknLayoutUtils::LayoutControl( iBorders[5], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g7().LayoutLine() );
       
   641 		AknLayoutUtils::LayoutControl( iBorders[6], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g6().LayoutLine() );
       
   642 		}
       
   643 	else
       
   644 		{
       
   645 		AknLayoutUtils::LayoutControl( iBorders[1], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g2().LayoutLine() );
       
   646 		AknLayoutUtils::LayoutControl( iBorders[2], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g3().LayoutLine() );
       
   647 		AknLayoutUtils::LayoutControl( iBorders[3], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g4().LayoutLine() );
       
   648 		AknLayoutUtils::LayoutControl( iBorders[4], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g5().LayoutLine() );
       
   649 		AknLayoutUtils::LayoutControl( iBorders[5], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g6().LayoutLine() );
       
   650 		AknLayoutUtils::LayoutControl( iBorders[6], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g7().LayoutLine() );
       
   651 		}
       
   652 	AknLayoutUtils::LayoutControl( iBorders[0], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g1().LayoutLine() );
       
   653 	AknLayoutUtils::LayoutControl( iBorders[7], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g8().LayoutLine() );
       
   654 	AknLayoutUtils::LayoutControl( iBorders[8], parentRect, AknLayoutScalable_Avkon::bg_tb_trans_pane_g9().LayoutLine() );
       
   655 
       
   656 	// Images need to be resized separately, because the standard LayoutImage
       
   657 	// tries to preserve the aspect ratio and we don't want that.
       
   658 	//
       
   659 	for ( TInt i = 0; i < iBorders.Count(); ++i )
       
   660 		{
       
   661 		AknIconUtils::SetSize(
       
   662 				const_cast<CFbsBitmap*>( iBorders[i]->Bitmap() ),
       
   663 				iBorders[i]->Size(), EAspectRatioNotPreserved );
       
   664 		}
       
   665 
       
   666 	// determine icon layout
       
   667 	if (iIcon)
       
   668 		{
       
   669 		AknLayoutUtils::LayoutControl( iIcon, parentRect, AknLayoutScalable_Apps::popup_imed_adjust2_window_g1(variety).LayoutLine() );
       
   670 		AknIconUtils::SetSize(
       
   671 				const_cast<CFbsBitmap*>( iIcon->Bitmap() ),
       
   672 				iIcon->Size(), EAspectRatioNotPreserved );
       
   673 		}
       
   674 
       
   675 	// determine caption layout
       
   676 	TAknLayoutText layoutText;
       
   677 	layoutText.LayoutText( parentRect, AknLayoutScalable_Apps::popup_imed_adjust2_window_t1(variety) );
       
   678 	TRgb color = layoutText.Color();
       
   679 	iText->SetFont(layoutText.Font());
       
   680 	iText->OverrideColorL( EColorLabelText, color );
       
   681 	iText->SetExtent(layoutText.TextRect().iTl, layoutText.TextRect().Size());
       
   682 	if(AknLayoutUtils::LayoutMirrored())
       
   683 		{
       
   684 		iText->SetAlignment( EHRightVTop );
       
   685 		}
       
   686 	else
       
   687 		{
       
   688 		iText->SetAlignment( EHLeftVTop );
       
   689 		}
       
   690 
       
   691 	// determine scrollbar layouts
       
   692 	if( AknLayoutUtils::PenEnabled() )
       
   693 		{
       
   694 		if(AknLayoutUtils::LayoutMirrored())
       
   695 			{
       
   696 			AknLayoutUtils::LayoutControl( iScrollBar[4], parentRect, AknLayoutScalable_Apps::popup_imed_adjust2_window_g3(0).LayoutLine() );
       
   697 			AknLayoutUtils::LayoutControl( iScrollBar[5], parentRect, AknLayoutScalable_Apps::popup_imed_adjust2_window_g2(0).LayoutLine() );
       
   698 			}
       
   699 		else
       
   700 			{
       
   701 			AknLayoutUtils::LayoutControl( iScrollBar[4], parentRect, AknLayoutScalable_Apps::popup_imed_adjust2_window_g2(0).LayoutLine() );
       
   702 			AknLayoutUtils::LayoutControl( iScrollBar[5], parentRect, AknLayoutScalable_Apps::popup_imed_adjust2_window_g3(0).LayoutLine() );
       
   703 			}
       
   704 		}
       
   705 	TAknWindowComponentLayout l = AknLayoutScalable_Apps::slider_imed_adjust_pane(variety);
       
   706 	TAknWindowLineLayout lineLayout = l.LayoutLine();
       
   707 	layoutRect.LayoutRect(parentRect, lineLayout);
       
   708 	if(AknLayoutUtils::LayoutMirrored())
       
   709 		{
       
   710 		AknLayoutUtils::LayoutControl( iScrollBar[0], layoutRect.Rect(), AknLayoutScalable_Apps::slider_imed_adjust_pane_g2(variety).LayoutLine() );
       
   711 		AknLayoutUtils::LayoutControl( iScrollBar[1], layoutRect.Rect(), AknLayoutScalable_Apps::slider_imed_adjust_pane_g1(variety).LayoutLine() );
       
   712 		}
       
   713 	else
       
   714 		{
       
   715 		AknLayoutUtils::LayoutControl( iScrollBar[0], layoutRect.Rect(), AknLayoutScalable_Apps::slider_imed_adjust_pane_g1(variety).LayoutLine() );
       
   716 		AknLayoutUtils::LayoutControl( iScrollBar[1], layoutRect.Rect(), AknLayoutScalable_Apps::slider_imed_adjust_pane_g2(variety).LayoutLine() );
       
   717 		}
       
   718 	AknLayoutUtils::LayoutControl( iScrollBar[2], layoutRect.Rect(), AknLayoutScalable_Apps::slider_imed_adjust_pane_g3(variety).LayoutLine() );
       
   719 	AknLayoutUtils::LayoutControl( iScrollBar[3], layoutRect.Rect(), AknLayoutScalable_Apps::slider_imed_adjust_pane_g4(variety).LayoutLine() );
       
   720 	iScrollBar[3]->SetSize(TSize(KSliderWidth, iScrollBar[3]->Size().iHeight));
       
   721 	if( AknLayoutUtils::PenEnabled() )
       
   722 		{
       
   723 		AknLayoutUtils::LayoutControl( iScrollBar[6], layoutRect.Rect(), AknLayoutScalable_Apps::slider_imed_adjust_pane_g4(variety).LayoutLine() );
       
   724 		iScrollBar[6]->SetSize(TSize(KSliderWidth, iScrollBar[6]->Size().iHeight));
       
   725 		}
       
   726 	for ( TInt i = 0; i < iScrollBar.Count(); ++i )
       
   727 		{
       
   728 		AknIconUtils::SetSize(
       
   729 				const_cast<CFbsBitmap*>( iScrollBar[i]->Bitmap() ),
       
   730 				iScrollBar[i]->Size(), EAspectRatioNotPreserved );
       
   731 		}
       
   732 
       
   733 	// set touch area
       
   734 	if( AknLayoutUtils::PenEnabled() )
       
   735 		{
       
   736 		iTouchRect.iTl.iX = iScrollBar[4]->Rect().iTl.iX;
       
   737 		iTouchRect.iTl.iY = iScrollBar[0]->Rect().iTl.iY;
       
   738 		iTouchRect.iBr.iX = iScrollBar[5]->Rect().iBr.iX;
       
   739 		iTouchRect.iBr.iY = iScrollBar[1]->Rect().iBr.iY;
       
   740 		}
       
   741 
       
   742 	// slider tab width
       
   743 	TUint sliderTabWidth = KSliderWidth;
       
   744 	// slider bitmap is actually a bit longer but this resolves the problem
       
   745 	// where the tab is drawn outside of the slider when in maximum position
       
   746 	TUint sliderBitmapWidth = layoutRect.Rect().Width() - sliderTabWidth;
       
   747 	iStepInPixels = sliderBitmapWidth;
       
   748 	if ( iMinimumValue < iMaximumValue )
       
   749 		{
       
   750 		iStepInPixels = iStep * sliderBitmapWidth
       
   751 		/ (iMaximumValue - iMinimumValue);
       
   752 		}
       
   753 	}
       
   754 
       
   755 EXPORT_C void CSingleParamControl::MoveSlider(TInt aSteps)
       
   756 	{
       
   757 	iPosition += iStep * aSteps;
       
   758 
       
   759 	if(iPosition> iMaximumValue)
       
   760 		{
       
   761 		iPosition = iMaximumValue;
       
   762 		}
       
   763 	if(iPosition < iMinimumValue)
       
   764 		{
       
   765 		iPosition = iMinimumValue;
       
   766 		}
       
   767 
       
   768 	if(aSteps < 0)
       
   769 		{
       
   770 		for ( TInt i = 0; i> aSteps; i-- )
       
   771 			{
       
   772 			iParObserver->ParamOperation(MSingleParControlObserver::EParamOperationSubtract);
       
   773 			}
       
   774 		}
       
   775 	else
       
   776 		{
       
   777 		for ( TInt i = 0; i < aSteps; i++ )
       
   778 			{
       
   779 			iParObserver->ParamOperation(MSingleParControlObserver::EParamOperationAdd);
       
   780 			}
       
   781 		}
       
   782 	
       
   783 	if( !iActionOnButtonRelease )
       
   784 		{
       
   785 		iEditorView->HandleCommandL (EImageEditorCmdRender);
       
   786 		}
       
   787 	}
       
   788 
       
   789 // End of File
       
   790 
       
   791