uifw/EikStd/coctlsrc/EIKCMBUT.CPP
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <eikcmbut.h>
       
    20 #include <barsread.h>
       
    21 #include <gulbordr.h>
       
    22 #include <eikenv.h>
       
    23 #include <eiklabel.h>
       
    24 #include <eikimage.h>
       
    25 #include <eikpanic.h>
       
    26 #include <LAFCMBUT.H>
       
    27 
       
    28 #include "gulcolor.h"
       
    29 #include <AknIconUtils.h>
       
    30 
       
    31 const TInt KLayoutMask				=0x0007;
       
    32 const TInt KLayoutAndFontMask		=0x000f;
       
    33 const TInt KExcessMask				=0x00f0;
       
    34 const TInt KDisplayContentMask		=0x0f00;
       
    35 
       
    36 //
       
    37 // class CEikCommandStack
       
    38 //
       
    39 
       
    40 NONSHARABLE_CLASS(CEikCommandStack) : public CBase
       
    41 	{
       
    42 public:
       
    43 	class TStackableCommand
       
    44 		{
       
    45 	public:
       
    46 		TStackableCommand();
       
    47 		TStackableCommand(TInt aCommandId,HBufC* aText,CFbsBitmap* aBitmap,CFbsBitmap* aMask);
       
    48 	public:
       
    49 		void SetBitmapOwner(TBool aOwner);
       
    50 		void SetDimmed(TBool aDimmed);
       
    51 		void SetVisible(TBool aVisible);
       
    52 		inline TBool IsBitmapOwner() const;
       
    53 		inline TBool IsDimmed() const;
       
    54 		inline TBool IsVisible() const;
       
    55 	public:
       
    56 		TInt iCommandId;
       
    57 		HBufC* iText;
       
    58 		CFbsBitmap* iBitmap;
       
    59 		CFbsBitmap* iMask;
       
    60 	private:
       
    61 		enum TFlags
       
    62 			{
       
    63 			EBitmapOwner	=0x04,
       
    64 			EDimmed			=0x08,
       
    65 			EInvisible		=0x10,
       
    66 			};
       
    67 	private:
       
    68 		TInt iFlags;
       
    69 		};
       
    70 public:
       
    71 	static CEikCommandStack* NewL();
       
    72 	~CEikCommandStack();
       
    73 public:
       
    74 	void AddL(TInt aCommandId,const TDesC* aText,CFbsBitmap* aBitmap,CFbsBitmap* aMask);
       
    75 	TBool Remove(TInt aCommandId);
       
    76 	TStackableCommand Pop();
       
    77 	TInt Level() const;
       
    78 	TStackableCommand& StackableCommand(TInt aCommandId) const;
       
    79 	TStackableCommand& StackableCommandByPos(TInt aPos) const;
       
    80 private:
       
    81 	TInt Find(TInt aCommandId) const;
       
    82 	void Delete(TInt aIndex);
       
    83 private:
       
    84 	CArrayFix<TStackableCommand>* iCommands;
       
    85 	};
       
    86 
       
    87 CEikCommandStack::TStackableCommand::TStackableCommand()
       
    88 	: iCommandId(0), iText(NULL), iBitmap(NULL), iMask(NULL), iFlags(0)
       
    89 	{}
       
    90 
       
    91 CEikCommandStack::TStackableCommand::TStackableCommand(TInt aCommandId,HBufC* aText,
       
    92 													   CFbsBitmap* aBitmap,CFbsBitmap* aMask)
       
    93 	: iCommandId(aCommandId), iText(aText), iBitmap(aBitmap), iMask(aMask), iFlags(0)
       
    94 	{}
       
    95 
       
    96 void CEikCommandStack::TStackableCommand::SetBitmapOwner(TBool aOwner)
       
    97 	{
       
    98 	if (aOwner)
       
    99 		iFlags|=EBitmapOwner;
       
   100 	else
       
   101 		iFlags&=~EBitmapOwner;
       
   102 	}
       
   103 
       
   104 void CEikCommandStack::TStackableCommand::SetDimmed(TBool aDimmed)
       
   105 	{
       
   106 	if (aDimmed)
       
   107 		iFlags|=EDimmed;
       
   108 	else
       
   109 		iFlags&=~EDimmed;
       
   110 	}
       
   111 
       
   112 void CEikCommandStack::TStackableCommand::SetVisible(TBool aVisible)
       
   113 	{
       
   114 	if (!aVisible)
       
   115 		iFlags|=EInvisible;
       
   116 	else
       
   117 		iFlags&=~EInvisible;
       
   118 	}
       
   119 
       
   120 inline TBool CEikCommandStack::TStackableCommand::IsBitmapOwner() const
       
   121 	{return iFlags&EBitmapOwner;}
       
   122 inline TBool CEikCommandStack::TStackableCommand::IsDimmed() const
       
   123 	{return iFlags&EDimmed;}
       
   124 inline TBool CEikCommandStack::TStackableCommand::IsVisible() const
       
   125 	{return !(iFlags&EInvisible);}
       
   126 
       
   127 
       
   128 CEikCommandStack* CEikCommandStack::NewL()
       
   129 	{ // static
       
   130 	CEikCommandStack* self=new(ELeave) CEikCommandStack;
       
   131 	return self;
       
   132 	}
       
   133 
       
   134 CEikCommandStack::~CEikCommandStack()
       
   135 	{
       
   136 	if (iCommands)
       
   137 		{
       
   138 		for (TInt ii=iCommands->Count()-1;ii>=0;ii--)
       
   139 			{
       
   140 			Delete(ii);
       
   141 			}
       
   142 		}
       
   143 	}
       
   144 
       
   145 void CEikCommandStack::AddL(TInt aCommandId,const TDesC* aText,CFbsBitmap* aBitmap,CFbsBitmap* aMask)
       
   146 	{
       
   147 	CArrayFix<TStackableCommand>* commands=NULL;
       
   148 	if (iCommands)
       
   149 		{
       
   150 		commands=iCommands;
       
   151 		}
       
   152 	else
       
   153 		{
       
   154 		commands=new(ELeave) CArrayFixFlat<TStackableCommand>(1);
       
   155 		CleanupStack::PushL(commands);
       
   156 		}
       
   157 	HBufC* text=NULL;
       
   158 	if (aText)
       
   159 		text=aText->AllocLC();
       
   160 	TStackableCommand cmd(aCommandId,text,aBitmap,aMask);
       
   161 	commands->AppendL(cmd);
       
   162 	if (aText)
       
   163 		CleanupStack::Pop(); // text
       
   164 	if (!iCommands)
       
   165 		{
       
   166 		iCommands=commands;
       
   167 		CleanupStack::Pop(); // commands
       
   168 		}
       
   169 	}
       
   170 
       
   171 TBool CEikCommandStack::Remove(TInt aCommandId)
       
   172 	{
       
   173 	TBool removed=EFalse;
       
   174 	if (iCommands)
       
   175 		{
       
   176 		const TInt index=Find(aCommandId);
       
   177 		if (index!=KErrNotFound)
       
   178 			{
       
   179 			Delete(index);
       
   180 			removed=ETrue;
       
   181 			}
       
   182 		}
       
   183 	return removed;
       
   184 	}
       
   185 
       
   186 TInt CEikCommandStack::Level() const
       
   187 	{
       
   188 	return (iCommands? iCommands->Count() : 0);
       
   189 	}
       
   190 
       
   191 CEikCommandStack::TStackableCommand& CEikCommandStack::StackableCommand(TInt aCommandId) const
       
   192 	{
       
   193 	// __ASSERT_ALWAYS(iCommands,..........
       
   194 	// search backwards through the array in case there are two commands with the same id
       
   195 	TInt loop=iCommands->Count();
       
   196 	TInt index=KErrNotFound;
       
   197 	while (--loop>=0)
       
   198 		{
       
   199 		if ((*iCommands)[loop].iCommandId==aCommandId)
       
   200 			{
       
   201 			index=loop;
       
   202 			break;
       
   203 			}
       
   204 		}
       
   205 	// __ASSERT_ALWAYS(index!=KErrNotFound...
       
   206 	return (*iCommands)[index];
       
   207 	}
       
   208 
       
   209 CEikCommandStack::TStackableCommand& CEikCommandStack::StackableCommandByPos(TInt aPos) const
       
   210 	{
       
   211 	// __ASSERT_ALWAYS(iCommands,..........
       
   212 	// __ASSERT_ALWAYS(aPos>=0 && aPos<iCommands->Count(),...
       
   213 	return (*iCommands)[aPos];
       
   214 	}
       
   215 
       
   216 TInt CEikCommandStack::Find(TInt aCommandId) const
       
   217 	{
       
   218 	// __ASSERT_DEBUG(iCommands...
       
   219 	const TInt count=iCommands->Count();
       
   220 	for (TInt ii=0;ii<count;ii++)
       
   221 		{
       
   222 		TInt command=(*iCommands)[ii].iCommandId;
       
   223 		if (command==aCommandId)
       
   224 			return ii;
       
   225 		}
       
   226 	return KErrNotFound;
       
   227 	}
       
   228 
       
   229 CEikCommandStack::TStackableCommand CEikCommandStack::Pop()
       
   230 	// Relinquishes ownership of text and bitmap resources.
       
   231 	{
       
   232 	ASSERT(iCommands);
       
   233 	ASSERT(iCommands->Count());
       
   234 
       
   235 	TInt top=iCommands->Count()-1;
       
   236 	TStackableCommand poppedCommand=(*iCommands)[top];
       
   237 	iCommands->Delete(top);
       
   238 	if (iCommands->Count()==0)
       
   239 		{
       
   240 		delete iCommands;
       
   241 		iCommands=NULL;
       
   242 		}
       
   243 
       
   244 	return poppedCommand;
       
   245 	}
       
   246 
       
   247 void CEikCommandStack::Delete(TInt aIndex)
       
   248 	{
       
   249 	ASSERT(iCommands);
       
   250 	
       
   251 	TStackableCommand cmd=(*iCommands)[aIndex];
       
   252 	delete cmd.iText;
       
   253 	if (cmd.IsBitmapOwner())
       
   254 		{
       
   255 		delete cmd.iBitmap;
       
   256 		delete cmd.iMask;
       
   257 		}
       
   258 	iCommands->Delete(aIndex);
       
   259 	if (iCommands->Count()==0)
       
   260 		{
       
   261 		delete iCommands;
       
   262 		iCommands=NULL;
       
   263 		}
       
   264 	}
       
   265 
       
   266 //
       
   267 // class CEikCommandButtonBase
       
   268 //
       
   269 
       
   270 EXPORT_C CEikCommandButtonBase::~CEikCommandButtonBase()
       
   271 	{
       
   272 	delete iComponents[0];
       
   273 	delete iComponents[1];
       
   274 	delete iCommandStack;
       
   275 	}
       
   276 
       
   277 EXPORT_C CEikCommandButtonBase::CEikCommandButtonBase()
       
   278 	{
       
   279 	__DECLARE_NAME(_S("CEikCommandButton"));
       
   280 	LafCommandButtonBase::GetDefaultBorder(iBorder);
       
   281     iContext = this;
       
   282 	SetBehavior(EEikButtonStaysClear);
       
   283 	SetDisplayContent(EBoth); // default if button contains both
       
   284 	SetExcessSpace(EShare); // default if button contains both
       
   285 	SetButtonLayout(EFirstRightSecondLeft); // default if button contains both
       
   286 	SetNonFocusing();
       
   287 	}
       
   288 
       
   289 EXPORT_C void CEikCommandButtonBase::SetTextL(const TDesC& aText,CEikAlignedControl*& aComponent)
       
   290 	{
       
   291 	if (aComponent==NULL)
       
   292 		{
       
   293 		CEikLabel* label=new(ELeave) CEikLabel;
       
   294 		CleanupStack::PushL(label);
       
   295 		label->SetContainerWindowL(*this);
       
   296 		CleanupStack::Pop(); // label
       
   297 		label->SetFont(iCmdFlags&EDenseFont? iEikonEnv->DenseFont() : iEikonEnv->LegendFont());
       
   298 		label->SetAllMarginsTo(LafCommandButtonBase::LabelMargin());
       
   299 		aComponent=label;
       
   300 		}
       
   301 	STATIC_CAST(CEikLabel*,aComponent)->SetTextL(aText);
       
   302 	}
       
   303 
       
   304 
       
   305 EXPORT_C void CEikCommandButtonBase::SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask,CEikAlignedControl*& aComponent)
       
   306 	{
       
   307 	if (aMain)
       
   308 		{
       
   309 		CEikImage* image=new(ELeave) CEikImage;
       
   310 		CleanupStack::PushL(image);
       
   311 		image->SetContainerWindowL(*this);
       
   312 		image->SetPicture(aMain,aMask);
       
   313 		SetImageAttributes(image);
       
   314 		if (IsReadyToDraw())
       
   315 			image->ActivateL(); // won't leave
       
   316 		if (aComponent)
       
   317 			{
       
   318 			const TRect rect(aComponent->Rect());
       
   319 			if (rect.Width())
       
   320 				image->SetRect(rect);
       
   321 			delete aComponent;
       
   322 			}
       
   323 		CleanupStack::Pop(); // image
       
   324 		aComponent=image;
       
   325 		}
       
   326 	else if (aComponent)
       
   327 		{
       
   328 		delete aComponent;
       
   329 		aComponent=NULL;
       
   330 		SetNewComponentExtentL();
       
   331 		}
       
   332 	}
       
   333 
       
   334 EXPORT_C void CEikCommandButtonBase::SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask,CEikAlignedControl*& aComponent)
       
   335 	{
       
   336 	CEikImage* image=new(ELeave) CEikImage;
       
   337 	CleanupStack::PushL(image);
       
   338 	image->SetContainerWindowL(*this);
       
   339 	image->CreatePictureFromFileL(aFilename,aMain,aMask);
       
   340 	SetImageAttributes(image);
       
   341 	if (IsReadyToDraw())
       
   342 		image->ActivateL(); // won't leave
       
   343 	if (aComponent)
       
   344 		{
       
   345 		const TRect rect(aComponent->Rect());
       
   346 		if (rect.Width())
       
   347 			image->SetRect(rect); // won't leave
       
   348 		delete aComponent;
       
   349 		}
       
   350 	CleanupStack::Pop(); // image
       
   351 	aComponent=image;
       
   352 	}
       
   353 
       
   354 EXPORT_C void CEikCommandButtonBase::StartConstructFromResourceL(TResourceReader& aReader)
       
   355 	{
       
   356 	if (!iCommandStack)
       
   357 		{
       
   358 		iCommandStack=CEikCommandStack::NewL();
       
   359 		}
       
   360 
       
   361 	aReader.ReadInt8();
       
   362 	const TInt behavior=aReader.ReadInt16();
       
   363 	SetBehavior(STATIC_CAST(TButtonBehavior,behavior));
       
   364 	if(behavior==EEikButtonStaysClear)
       
   365 		{
       
   366 		SetState(EClear);
       
   367 		}
       
   368 	else if(behavior==EEikButtonStaysSet)
       
   369 		{
       
   370 		SetState(ESet);
       
   371 		}
       
   372 	const TInt layout=aReader.ReadInt16();
       
   373 	SetButtonLayout(STATIC_CAST(TLayout,(layout&KLayoutAndFontMask)));
       
   374 	SetExcessSpace(STATIC_CAST(TExcess,(layout&KExcessMask)));
       
   375 	aReader.ReadTPtrC();  // bubble help text 
       
   376 	aReader.ReadInt32(); // extension link
       
   377 	}
       
   378 
       
   379 EXPORT_C void CEikCommandButtonBase::ConstructLabelFromResourceL(TResourceReader& aReader,TWhichComponent aWhich)
       
   380 	{
       
   381 	if (!iCommandStack)
       
   382 		{
       
   383 		iCommandStack=CEikCommandStack::NewL();
       
   384 		}
       
   385 
       
   386 	TPtrC text=aReader.ReadTPtrC();
       
   387 	if (text.Length())
       
   388 		{
       
   389 		SetTextL(text,((CEikAlignedControl*&)(aWhich==EFirst? iComponents[0] : iComponents[1])));
       
   390 		CEikLabel* label=STATIC_CAST(CEikLabel*,(aWhich==EFirst? iComponents[0] : iComponents[1]));
       
   391 		label->SetAllMarginsTo(LafCommandButtonBase::LabelMargin());
       
   392 		label->SetContainerWindowL(*this);
       
   393 		}
       
   394 	}
       
   395 
       
   396 EXPORT_C void CEikCommandButtonBase::ConstructImageFromResourceL(TResourceReader& aReader,TWhichComponent aWhich)
       
   397 	{
       
   398 	if (!iCommandStack)
       
   399 		{
       
   400 		iCommandStack=CEikCommandStack::NewL();
       
   401 		}
       
   402 
       
   403 	TPtrC bitmapFile=aReader.ReadTPtrC();
       
   404 
       
   405 	const TInt bitmapId=aReader.ReadInt16();
       
   406 	const TInt bitmapMask=aReader.ReadInt16();
       
   407 
       
   408 	if (bitmapId!=-1)
       
   409 		SetPictureFromFileL(bitmapFile,bitmapId,bitmapMask,(aWhich==EFirst? iComponents[0] : iComponents[1]));
       
   410 	}
       
   411 
       
   412 TInt CEikCommandButtonBase::ButFlags() const	
       
   413 	{
       
   414 	return iCmdFlags;
       
   415 	}
       
   416 
       
   417 EXPORT_C void CEikCommandButtonBase::SetDefault(TBool aDefaultButton)
       
   418 	{
       
   419 	iDefault = aDefaultButton;
       
   420 	}
       
   421 
       
   422 TBool CEikCommandButtonBase::IsDefault() const
       
   423 	{
       
   424 	return iDefault;
       
   425 	}
       
   426 
       
   427 
       
   428 EXPORT_C TSize CEikCommandButtonBase::MinimumSize()
       
   429 	{
       
   430 	TSize size;
       
   431 	const TSize comp1Size=(iComponents[0] ? iComponents[0]->MinimumSize() : size);
       
   432 	const TSize comp2Size=(iComponents[1] ? iComponents[1]->MinimumSize() : size);
       
   433 	size=TSize(iMargins.iLeft + iMargins.iRight,iMargins.iTop + iMargins.iBottom);
       
   434     size+=iBorder.SizeDelta();
       
   435 	if (iComponents[1]==NULL || ((iCmdFlags&KDisplayContentMask)==EFirstOnly))
       
   436 		size+=comp1Size;
       
   437 	else if (iComponents[0]==NULL || ((iCmdFlags&KDisplayContentMask)==ESecondOnly))
       
   438 		size+=comp2Size;
       
   439 	else if (LayoutIsVertical())
       
   440 		{
       
   441 		size.iHeight+=comp1Size.iHeight+comp2Size.iHeight+LafCommandButtonBase::IntraComponentMargin();
       
   442 		size.iWidth+=Max(comp1Size.iWidth,comp2Size.iWidth);
       
   443 		}
       
   444 	else
       
   445 		{
       
   446 		size.iWidth+=comp1Size.iWidth+comp2Size.iWidth+LafCommandButtonBase::IntraComponentMargin();
       
   447 		size.iHeight+=Max(comp1Size.iHeight,comp2Size.iHeight);
       
   448 		}
       
   449 	return size;
       
   450 	}
       
   451 
       
   452 EXPORT_C void CEikCommandButtonBase::SetDimmed(TBool aDimmed)
       
   453 	{
       
   454 	CCoeControl::SetDimmed(aDimmed);
       
   455 	if (iComponents[0])
       
   456 		iComponents[0]->SetDimmed(aDimmed);
       
   457 	if (iComponents[1])
       
   458 		iComponents[1]->SetDimmed(aDimmed);
       
   459 	}
       
   460 
       
   461 EXPORT_C void CEikCommandButtonBase::SetContainerWindowL(const CCoeControl& aContainer)
       
   462 	{
       
   463 	CCoeControl::SetContainerWindowL(aContainer);
       
   464 	if (iComponents[0])
       
   465 		iComponents[0]->SetContainerWindowL(aContainer);
       
   466 	if (iComponents[1])
       
   467 		iComponents[1]->SetContainerWindowL(aContainer);
       
   468 	}
       
   469 
       
   470 CEikCommandStack* CEikCommandButtonBase::CommandStack() const
       
   471 	{
       
   472 	return iCommandStack;
       
   473 	}
       
   474 
       
   475 
       
   476 EXPORT_C void CEikCommandButtonBase::ActivateL()
       
   477 	{
       
   478 	iContext=this;
       
   479 	if (iComponents[0])
       
   480 		iComponents[0]->CopyControlContextFrom(this);
       
   481 	if (iComponents[1])
       
   482 		iComponents[1]->CopyControlContextFrom(this);
       
   483 	LafCommandButtonBase::GetBorder(iBorder, DrawState(), iButFlags,*this,IsDefault());
       
   484 	UpdateComponentAlignment();
       
   485 	CCoeControl::ActivateL();
       
   486 	}
       
   487 
       
   488 EXPORT_C void CEikCommandButtonBase::UpdateComponentAlignment()
       
   489 	{
       
   490 	const TInt layout=iCmdFlags&KLayoutAndFontMask;
       
   491 	if (layout==EFirstBottomSecondTop || layout==EFirstTopSecondBottom)
       
   492 		{
       
   493 		if (iComponents[0])
       
   494 			iComponents[0]->SetAlignment(EHCenterVCenter);
       
   495 		if (iComponents[1])
       
   496 			iComponents[1]->SetAlignment(EHCenterVCenter);
       
   497 		}
       
   498 	else
       
   499 		{
       
   500 		if (iComponents[0])
       
   501 			{
       
   502 			if (iComponents[1])
       
   503 				{
       
   504 				iComponents[0]->SetAlignment(layout==EFirstLeftSecondRight? EHLeftVCenter : EHRightVCenter);
       
   505 				iComponents[1]->SetAlignment(layout==EFirstLeftSecondRight? EHRightVCenter : EHLeftVCenter);
       
   506 				}
       
   507 			else
       
   508 				iComponents[0]->SetAlignment(EHCenterVCenter);
       
   509 			}
       
   510 		else
       
   511 			iComponents[1]->SetAlignment(EHCenterVCenter);
       
   512 		}
       
   513 	}
       
   514 
       
   515 EXPORT_C void CEikCommandButtonBase::SetButtonLayout(TLayout aLayout)
       
   516 	{
       
   517     iCmdFlags &= (~KLayoutAndFontMask);
       
   518 	iCmdFlags |= aLayout;
       
   519 	}
       
   520 
       
   521 EXPORT_C void CEikCommandButtonBase::SetExcessSpace(TExcess aExcess)
       
   522 	{
       
   523 	iCmdFlags&=~KExcessMask;
       
   524 	iCmdFlags|=aExcess;
       
   525 	}
       
   526 
       
   527 EXPORT_C void CEikCommandButtonBase::SetDisplayContent(TDisplayContent aContent)
       
   528 	{
       
   529 	iCmdFlags &= (~KDisplayContentMask);
       
   530 	iCmdFlags |= aContent;
       
   531 	}
       
   532 
       
   533 EXPORT_C TInt CEikCommandButtonBase::CountComponentControls() const
       
   534 	{
       
   535 	__ASSERT_DEBUG((iComponents[0]||iComponents[1]),Panic(EEikPanicButtonHasNoComponent));
       
   536 	if (iComponents[0] && iComponents[1] && ((iCmdFlags&KDisplayContentMask)==EBoth))
       
   537 		return 2;
       
   538 	return 1;
       
   539 	}
       
   540 
       
   541 EXPORT_C CCoeControl* CEikCommandButtonBase::ComponentControl(TInt aIndex) const
       
   542 	{
       
   543 	__ASSERT_DEBUG((iComponents[0]||iComponents[1]),Panic(EEikPanicButtonHasNoComponent));
       
   544 	if (iComponents[1]==NULL || ((iCmdFlags&KDisplayContentMask)==EFirstOnly))
       
   545 		return iComponents[0];
       
   546 	if (iComponents[0]==NULL || ((iCmdFlags&KDisplayContentMask)==ESecondOnly))
       
   547 		return iComponents[1];
       
   548 	if (aIndex==0)
       
   549 		return iComponents[0];
       
   550 	return iComponents[1];
       
   551 	}
       
   552 
       
   553 EXPORT_C void CEikCommandButtonBase::SizeChanged()
       
   554 	{
       
   555 	__ASSERT_DEBUG((iComponents[0]||iComponents[1]),Panic(EEikPanicButtonHasNoComponent));
       
   556     TRect innerRect=iBorder.InnerRect(Rect());
       
   557 	innerRect.SetRect(innerRect.iTl.iX+iMargins.iLeft,innerRect.iTl.iY+iMargins.iTop,
       
   558 						innerRect.iBr.iX-iMargins.iRight,innerRect.iBr.iY-iMargins.iBottom);
       
   559 	innerRect.Move(iDrawOffset,iDrawOffset);
       
   560 	if (iComponents[1]==NULL || ((iCmdFlags&KDisplayContentMask)==EFirstOnly))
       
   561 		iComponents[0]->SetRect(innerRect);
       
   562 	else if (iComponents[0]==NULL || ((iCmdFlags&KDisplayContentMask)==ESecondOnly))
       
   563 		iComponents[1]->SetRect(innerRect);
       
   564 	else
       
   565 		SetComponentExtents(innerRect);
       
   566 	}
       
   567 
       
   568 EXPORT_C void CEikCommandButtonBase::LayoutComponents()
       
   569 	{
       
   570 	SizeChanged();
       
   571 	}
       
   572 
       
   573 EXPORT_C void CEikCommandButtonBase::StateChanged()
       
   574 	{
       
   575 	TInt drawState = DrawState();
       
   576 	if (iBorder.HasBorder())
       
   577 		LafCommandButtonBase::GetBorder(iBorder, drawState, iButFlags,*this,IsDefault());
       
   578 	const TInt offset=LafCommandButtonBase::ComponentOffset(drawState, iButFlags);
       
   579 
       
   580 	if (offset==iDrawOffset)
       
   581 		return;
       
   582 
       
   583 	const TInt deltaOffset = offset-iDrawOffset;
       
   584 	const TPoint delta(deltaOffset,deltaOffset);
       
   585 	
       
   586 	if (iComponents[0])
       
   587 		iComponents[0]->SetPosition(iComponents[0]->Position()+delta);
       
   588 	
       
   589 	if (iComponents[1])
       
   590 		iComponents[1]->SetPosition(iComponents[1]->Position()+delta);
       
   591 	
       
   592 	iDrawOffset=offset;
       
   593 	}
       
   594 
       
   595 /**
       
   596  * Prepares the basic graphic contents according to the the type of command
       
   597  * button, e.g. pen and brush colors.
       
   598  *
       
   599  * @since ER5U 
       
   600  */
       
   601 EXPORT_C void CEikCommandButtonBase::PrepareContext(CWindowGc& aGc) const
       
   602 	{
       
   603 	LafCommandButtonBase::PrepareContext(aGc,DrawState(),iEikonEnv->LafEnv(),*this);
       
   604 	}
       
   605 
       
   606 EXPORT_C void CEikCommandButtonBase::Draw(const TRect& /*aRect*/) const
       
   607 	{
       
   608 	LafCommandButtonBase::Draw(iEikonEnv->LafEnv(),*this,SystemGc(),
       
   609 								iBorder,iDrawOffset,DrawState(),
       
   610 								iMargins,IsDefault());
       
   611     }
       
   612 
       
   613 
       
   614 EXPORT_C TKeyResponse CEikCommandButtonBase::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   615 	{
       
   616 	if(aKeyEvent.iCode==EKeyEnter && aType==EEventKey)
       
   617 		{
       
   618 		Animate();
       
   619 		return EKeyWasConsumed;
       
   620 		}
       
   621 	else
       
   622 		return EKeyWasNotConsumed;
       
   623 	}
       
   624 
       
   625 EXPORT_C void CEikCommandButtonBase::FocusChanged(TDrawNow aDrawNow)
       
   626 	{
       
   627 	if(aDrawNow && !IsNonFocusing())
       
   628 		DrawNow();
       
   629 	}
       
   630 
       
   631 void CEikCommandButtonBase::SetComponentExtents(const TRect& aRect)
       
   632 	{
       
   633 	TInt8 margin = (TInt8)(LafCommandButtonBase::IntraComponentMargin()>>1);
       
   634 	TSize comp1Size=iComponents[0]->MinimumSize();
       
   635 	TSize comp2Size=iComponents[1]->MinimumSize();
       
   636 
       
   637 	const TInt excess=(LayoutIsVertical()? 
       
   638 								aRect.Size().iHeight-(comp1Size+comp2Size).iHeight - LafCommandButtonBase::IntraComponentMargin():
       
   639 								aRect.Size().iWidth-(comp1Size+comp2Size).iWidth - LafCommandButtonBase::IntraComponentMargin());
       
   640 	switch (iCmdFlags&KExcessMask)
       
   641 		{
       
   642 	case EToFirst:
       
   643 		if (LayoutIsVertical())
       
   644 			comp1Size.iHeight+=excess;
       
   645 		else
       
   646 			comp1Size.iWidth+=excess;
       
   647 		break;
       
   648 	case EToSecond:
       
   649 		if (LayoutIsVertical())
       
   650 			comp2Size.iHeight+=excess;
       
   651 		else
       
   652 			comp2Size.iWidth+=excess;
       
   653 		break;
       
   654 	case EShare:
       
   655 		if (LayoutIsVertical())
       
   656 			{
       
   657 			comp2Size.iHeight+=excess>>1;
       
   658 			comp1Size.iHeight+=excess-(excess>>1);
       
   659 			}
       
   660 		else
       
   661 			{
       
   662 			comp2Size.iWidth+=excess>>1;
       
   663 			comp1Size.iWidth+=excess-(excess>>1);
       
   664 			}
       
   665 		break;
       
   666 		}
       
   667 	if (LayoutIsVertical())
       
   668 		{
       
   669 		comp2Size.iHeight+=margin;
       
   670 		comp1Size.iHeight+=margin;
       
   671 		}
       
   672 	else
       
   673 		{
       
   674 		comp2Size.iWidth+=margin;
       
   675 		comp1Size.iWidth+=margin;
       
   676 		}
       
   677 	TRect comp1Rect=aRect;
       
   678 	TRect comp2Rect=aRect;
       
   679     switch (iCmdFlags&KLayoutMask)
       
   680         {
       
   681     case EFirstTopSecondBottom:
       
   682 		comp2Rect.iTl.iY+=comp1Size.iHeight;
       
   683 		comp1Rect.iBr.iY=comp2Rect.iTl.iY;
       
   684 		iComponents[0]->iMargin.iBottom=margin;
       
   685 		iComponents[1]->iMargin.iTop=margin;
       
   686         break;
       
   687     case EFirstBottomSecondTop:
       
   688 		comp1Rect.iTl.iY+=comp2Size.iHeight;
       
   689 		comp2Rect.iBr.iY=comp1Rect.iTl.iY;
       
   690 		iComponents[0]->iMargin.iTop=margin;
       
   691 		iComponents[1]->iMargin.iBottom=margin;
       
   692         break;
       
   693     case EFirstLeftSecondRight:
       
   694 		comp2Rect.iTl.iX+=comp1Size.iWidth;
       
   695 		comp1Rect.iBr.iX=comp2Rect.iTl.iX;
       
   696 		iComponents[0]->iMargin.iRight=margin;
       
   697 		iComponents[1]->iMargin.iLeft=margin;
       
   698         break;
       
   699     case EFirstRightSecondLeft:
       
   700 		comp1Rect.iTl.iX+=comp2Size.iWidth;
       
   701 		comp2Rect.iBr.iX=comp1Rect.iTl.iX;
       
   702 		iComponents[0]->iMargin.iLeft=margin;
       
   703 		iComponents[1]->iMargin.iRight=margin;
       
   704         break;
       
   705 		}
       
   706 	iComponents[0]->SetRect(comp1Rect); // won't leave
       
   707 	iComponents[1]->SetRect(comp2Rect); // won't leave
       
   708 	}
       
   709 
       
   710 void CEikCommandButtonBase::SetImageAttributes(CEikImage* aImage)
       
   711 	{
       
   712 //	aImage->SetAlignment(EHCenterVCenter);
       
   713 	aImage->SetAllMarginsTo(LafCommandButtonBase::ImageMargin());
       
   714 	}
       
   715 
       
   716 void CEikCommandButtonBase::SetNewComponentExtentL()
       
   717 // only ever called when the image changes
       
   718 	{
       
   719     TRect innerRect=iBorder.InnerRect(Rect());
       
   720 	innerRect.SetRect(innerRect.iTl.iX+iMargins.iLeft,innerRect.iTl.iY+iMargins.iTop,
       
   721 					innerRect.iBr.iX-iMargins.iRight,innerRect.iBr.iY-iMargins.iBottom);
       
   722 	innerRect.Move(iDrawOffset,iDrawOffset);
       
   723 	if (!iComponents[1] || (iCmdFlags&KDisplayContentMask==EFirstOnly))
       
   724 		iComponents[0]->SetRect(innerRect);
       
   725 	else if (!iComponents[0] || (iCmdFlags&KDisplayContentMask==ESecondOnly))
       
   726 		iComponents[1]->SetRect(innerRect);
       
   727 	else
       
   728 		SetComponentExtents(innerRect);
       
   729 	}
       
   730 
       
   731 TBool CEikCommandButtonBase::LayoutIsVertical() const
       
   732 	{ // !! change back to TLayout values to simplify this routine again
       
   733 	TInt layout=iCmdFlags&KLayoutMask;
       
   734 	return (layout==EFirstBottomSecondTop || layout==EFirstTopSecondBottom);
       
   735 	}
       
   736 
       
   737 inline TInt CEikCommandButtonBase::Behavior() const
       
   738 	{return iButFlags&(EEikButtonStaysClear|EEikButtonStaysSet|EEikButtonLatches|EEikButtonReportsOnPointerDown);}
       
   739 
       
   740 inline void CEikCommandButtonBase::CheckCreateCommandStackL()
       
   741 	{
       
   742 	if (!iCommandStack)
       
   743 		{
       
   744 		iCommandStack=CEikCommandStack::NewL();
       
   745 		}
       
   746 	}
       
   747 
       
   748 /**
       
   749  * Gets the list of logical colors employed in the drawing of the control,
       
   750  * paired with an explanation of how they are used. Appends the list to aColorUseList.
       
   751  *
       
   752  * @since ER5U 
       
   753  */
       
   754 EXPORT_C void CEikCommandButtonBase::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const
       
   755 	{
       
   756 	CEikButtonBase::GetColorUseListL(aColorUseList);
       
   757 	LafCommandButtonBase::GetColorUseListL(aColorUseList);
       
   758 	}
       
   759 
       
   760 /**
       
   761  * Handles a change to the control's resources of type aType
       
   762  * which are shared across the environment, e.g. colors or fonts.
       
   763  *
       
   764  * @since ER5U 
       
   765  */
       
   766 EXPORT_C void CEikCommandButtonBase::HandleResourceChange(TInt aType)
       
   767 	{
       
   768 	CEikButtonBase::HandleResourceChange(aType);
       
   769 	}
       
   770 
       
   771 /**
       
   772  * Writes the internal state of the control and its components to aStream.
       
   773  * Does nothing in release mode.
       
   774  * Designed to be overidden and base called by subclasses.
       
   775  *
       
   776  * @internal
       
   777  * @since App-Framework_6.1
       
   778  */
       
   779 #ifndef _DEBUG
       
   780 EXPORT_C void CEikCommandButtonBase::WriteInternalStateL(RWriteStream&) const
       
   781 	{}
       
   782 #else
       
   783 EXPORT_C void CEikCommandButtonBase::WriteInternalStateL(RWriteStream& aWriteStream) const
       
   784 	{
       
   785 	_LIT(KLitEikCmdButBsCtlStart, "<CEikCommandButtonBase>");
       
   786 	_LIT(KLitEikCmdButBsCtlEnd, "<\\CEikCommandButtonBase>");
       
   787 	_LIT(KLitEikCmdButBsMrg,"<iMargins>");
       
   788 	_LIT(KLitEikCmdButBsMrgEnd,"<\\iMargins>");
       
   789     _LIT(KLitEikCmdButBsCmdFls,"<iCmdFlags>");
       
   790 	_LIT(KLitEikCmdButBsCmdFlsEnd,"<\\iCmdFlags>");
       
   791 	_LIT(KLitEikCmdButBsDrwOff,"<iDrawOffset>");
       
   792 	_LIT(KLitEikCmdButBsDrwOffEnd,"<\\iDrawOffset>");
       
   793 	_LIT(KLitEikCmdButBsCmdStck,"<iCommandStack>");
       
   794 	_LIT(KLitEikCmdButBsCmdStckEnd,"<\\iCommandStack>");
       
   795 	_LIT(KLitEikCmdButBsDef,"<iDefault>");
       
   796 	_LIT(KLitEikCmdButBsDefEnd,"<\\iDefault>");
       
   797 
       
   798 	aWriteStream << KLitEikCmdButBsCtlStart;
       
   799 	aWriteStream << KLitEikCmdButBsMrg;
       
   800 	aWriteStream.WriteInt8L(iMargins.iLeft);
       
   801 	aWriteStream.WriteInt8L(iMargins.iRight);
       
   802 	aWriteStream.WriteInt8L(iMargins.iTop);
       
   803 	aWriteStream.WriteInt8L(iMargins.iBottom);
       
   804 	aWriteStream << KLitEikCmdButBsMrgEnd;
       
   805     aWriteStream << KLitEikCmdButBsCmdFls;
       
   806 	aWriteStream.WriteInt32L(iCmdFlags);
       
   807 	aWriteStream << KLitEikCmdButBsCmdFlsEnd;
       
   808 	aWriteStream << KLitEikCmdButBsDrwOff;
       
   809 	aWriteStream.WriteInt32L(iDrawOffset);
       
   810 	aWriteStream << KLitEikCmdButBsDrwOffEnd;
       
   811 	aWriteStream << KLitEikCmdButBsCmdStck;
       
   812 	const TInt top=(iCommandStack ? iCommandStack->Level() : 0);
       
   813 	for(TInt level=0; level<top ; level++)
       
   814 		{
       
   815 		const CEikCommandStack::TStackableCommand& cmd=iCommandStack->StackableCommandByPos(level);
       
   816 		aWriteStream.WriteInt32L(cmd.iCommandId);
       
   817 		if(cmd.iText)
       
   818 			aWriteStream << cmd.iText;
       
   819 		if(cmd.iBitmap)
       
   820 			aWriteStream << cmd.iBitmap;
       
   821 		if(cmd.iMask)
       
   822 			aWriteStream << cmd.iBitmap;
       
   823 		}
       
   824 	aWriteStream << KLitEikCmdButBsCmdStckEnd;
       
   825 	aWriteStream << KLitEikCmdButBsDef;
       
   826 	aWriteStream.WriteInt32L(iDefault);
       
   827 	aWriteStream << KLitEikCmdButBsDefEnd;
       
   828 	CEikButtonBase::WriteInternalStateL(aWriteStream);
       
   829 	aWriteStream << KLitEikCmdButBsCtlEnd;	
       
   830 	}
       
   831 #endif
       
   832 
       
   833 EXPORT_C void CEikCommandButtonBase::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
   834     { 
       
   835     CEikButtonBase::HandlePointerEventL(aPointerEvent); 
       
   836     }
       
   837 
       
   838 EXPORT_C void* CEikCommandButtonBase::ExtensionInterface( TUid /*aInterface*/ )
       
   839     {
       
   840     return NULL;
       
   841     }
       
   842 
       
   843 EXPORT_C void CEikCommandButtonBase::Reserved_2()
       
   844 	{}
       
   845 EXPORT_C void CEikCommandButtonBase::Reserved_3()
       
   846 	{}
       
   847 EXPORT_C void CEikCommandButtonBase::Reserved_4()
       
   848 	{}
       
   849 
       
   850 //
       
   851 // class CEikCommandButton
       
   852 //
       
   853 
       
   854 
       
   855 EXPORT_C CEikCommandButton::CEikCommandButton()
       
   856 	{
       
   857 	iMargins = LafCommandButton::Margins();
       
   858 	}
       
   859 
       
   860 EXPORT_C CEikCommandButton::~CEikCommandButton()
       
   861 	{}
       
   862 
       
   863 EXPORT_C void CEikCommandButton::SetTextL(const TDesC& aText)
       
   864 	{
       
   865 	CEikCommandButtonBase::SetTextL(aText,iComponents[0]);
       
   866 	}
       
   867 
       
   868 EXPORT_C void CEikCommandButton::SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask)
       
   869 	{
       
   870 	CEikCommandButtonBase::SetPictureL(aMain,aMask,iComponents[1]);
       
   871 	}
       
   872 
       
   873 EXPORT_C void CEikCommandButton::SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask)
       
   874 	{
       
   875 	CEikCommandButtonBase::SetPictureFromFileL(aFilename,aMain,aMask,iComponents[1]);
       
   876 	}
       
   877 
       
   878 EXPORT_C CEikLabel* CEikCommandButton::Label() const
       
   879 	{
       
   880 	return STATIC_CAST(CEikLabel*,iComponents[0]);
       
   881 	}
       
   882 
       
   883 EXPORT_C CEikImage* CEikCommandButton::Picture() const
       
   884 	{
       
   885 	return STATIC_CAST(CEikImage*,iComponents[1]);
       
   886 	}
       
   887 
       
   888 EXPORT_C void CEikCommandButton::SetButtonLayout(TLayout aLayout)
       
   889 	{
       
   890 	CEikCommandButtonBase::SetButtonLayout(((CEikCommandButtonBase::TLayout)aLayout));
       
   891 	}
       
   892 
       
   893 EXPORT_C void CEikCommandButton::SetExcessSpace(TExcess aExcess)
       
   894 	{
       
   895 	CEikCommandButtonBase::SetExcessSpace(((CEikCommandButtonBase::TExcess)aExcess));
       
   896 	}
       
   897 
       
   898 EXPORT_C void CEikCommandButton::SetDisplayContent(TDisplayContent aContent)
       
   899 	{
       
   900 	CEikCommandButtonBase::SetDisplayContent(((CEikCommandButtonBase::TDisplayContent)aContent));
       
   901 	}
       
   902 
       
   903 EXPORT_C void CEikCommandButton::ConstructFromResourceL(TResourceReader& aReader)
       
   904 	{
       
   905 	StartConstructFromResourceL(aReader);
       
   906 	ConstructLabelFromResourceL(aReader,EFirst);
       
   907 	ConstructImageFromResourceL(aReader,ESecond);
       
   908 	if (!(iComponents[0] || iComponents[1]))
       
   909 		{
       
   910 		SetTextL(KNullDesC);
       
   911 		CEikLabel* label=static_cast<CEikLabel*>(iComponents[0]);
       
   912 		label->SetAllMarginsTo(LafCommandButtonBase::LabelMargin());
       
   913 		label->SetContainerWindowL(*this);
       
   914 		}
       
   915 	}
       
   916 
       
   917 EXPORT_C void CEikCommandButton::UpdateComponentAlignment()
       
   918 	{
       
   919 	const TInt layout=iCmdFlags&KLayoutAndFontMask;
       
   920 	if (layout==EFirstBottomSecondTop || layout==EFirstTopSecondBottom)
       
   921 		{
       
   922 		if (iComponents[0])
       
   923 			iComponents[0]->SetAlignment(EHCenterVCenter);
       
   924 		if (iComponents[1])
       
   925 			iComponents[1]->SetAlignment(EHCenterVCenter);
       
   926 		}
       
   927 	else
       
   928 		{
       
   929 		if (iComponents[0])
       
   930 			{
       
   931 			if (iComponents[1])
       
   932 				{
       
   933 				iComponents[0]->SetAlignment(EHLeftVCenter); // always align text on the left
       
   934 				iComponents[1]->SetAlignment(layout==EFirstLeftSecondRight? EHRightVCenter : EHLeftVCenter);
       
   935 				}
       
   936 			else
       
   937 				iComponents[0]->SetAlignment(EHCenterVCenter);
       
   938 			}
       
   939 		else
       
   940 			iComponents[1]->SetAlignment(EHCenterVCenter);
       
   941 		}
       
   942 	}
       
   943 
       
   944 /**
       
   945  * Sets aText as the text in the command button.  Sets aBitmap and aMask as the bitmap and mask of the command button.
       
   946  *
       
   947  * @since App-Framework_6.1
       
   948  */
       
   949 EXPORT_C void CEikCommandButton::SetCommandL(TInt /*aCommandId*/,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask)
       
   950 	{
       
   951 	// !!! no rollback
       
   952 	if (aText && Label()->BufferReserveLength())
       
   953 		UpdateLabelReserveLengthL(aText);
       
   954 	SetTextL(*aText);
       
   955 	SetPictureL(aBitmap,aMask);
       
   956 	}
       
   957 
       
   958 void CEikCommandButton::UpdateLabelReserveLengthL(const TDesC* aText)
       
   959 	{
       
   960 	TInt length=(aText? aText->Length() : 0);
       
   961 	CEikLabel* label=Label();
       
   962 	length=Max(length,label->Text()->Length());
       
   963 	if (length>label->BufferReserveLength())
       
   964 		label->SetBufferReserveLengthL(length);
       
   965 	}
       
   966 	
       
   967 EXPORT_C void CEikCommandButton::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
   968     { 
       
   969     CEikCommandButtonBase::HandlePointerEventL(aPointerEvent); 
       
   970     }	
       
   971 
       
   972 EXPORT_C void* CEikCommandButton::ExtensionInterface( TUid /*aInterface*/ )
       
   973     {
       
   974     return NULL;
       
   975     }
       
   976 
       
   977 struct SLabelCleanup
       
   978 	{
       
   979 	CEikLabel* iLabel;
       
   980 	TDesC* iText;
       
   981 	};
       
   982 LOCAL_C void CleanupLabel(TAny* aPtr)
       
   983 	{
       
   984 	SLabelCleanup& temp=*(SLabelCleanup*)aPtr;
       
   985 	temp.iLabel->SetTextL(*(temp.iText)); // won't leave as SetBufferReserveLengthL has been called
       
   986 	}
       
   987 
       
   988 struct SStackCleanup
       
   989 	{
       
   990 	CEikCommandStack* iStack;
       
   991 	TInt iCommandId;
       
   992 	};
       
   993 LOCAL_C void CleanupCommandStack(TAny* aPtr)
       
   994 	{
       
   995 	SStackCleanup& temp=*(SStackCleanup*)aPtr;
       
   996 	temp.iStack->Remove(temp.iCommandId);
       
   997 	}
       
   998 
       
   999 /**
       
  1000  * Sets the command button to respond to aCommandId.  Sets aText as the text in the command button.
       
  1001  * Sets aBitmap and aMask as the bitmap and mask of the command button.  The previous command can be
       
  1002  * restored on the command button by a subsequent call to PopCommandFromStack(). 
       
  1003  *
       
  1004  * @since App-Framework_6.1
       
  1005  */
       
  1006 EXPORT_C void CEikCommandButton::AddCommandToStackL(TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask)
       
  1007 	{
       
  1008 	//if (Extension()==NULL)
       
  1009 	//	InitExtensionL();
       
  1010 	CEikImage* image=Picture();
       
  1011 	CFbsBitmap* bitmap=(image? CONST_CAST(CFbsBitmap*,image->Bitmap()) : NULL);
       
  1012 	CFbsBitmap* mask=(image? CONST_CAST(CFbsBitmap*,image->Mask()) : NULL);
       
  1013 	CheckCreateCommandStackL();
       
  1014 	CEikCommandStack* stack=CommandStack();
       
  1015 	stack->AddL(aCommandId,Label()->Text(),bitmap,mask);
       
  1016 	SStackCleanup stackCleanup;
       
  1017 	stackCleanup.iStack=stack;
       
  1018 	stackCleanup.iCommandId=aCommandId;
       
  1019 	CleanupStack::PushL(TCleanupItem(CleanupCommandStack,&stackCleanup));
       
  1020 	CEikLabel* label=Label();
       
  1021 	SLabelCleanup labelCleanup;
       
  1022 	labelCleanup.iLabel=label;
       
  1023 	labelCleanup.iText=stack->StackableCommand(aCommandId).iText;
       
  1024 	UpdateLabelReserveLengthL(aText);
       
  1025 	TPtrC text;
       
  1026 	if (aText)
       
  1027 		text.Set(*aText);
       
  1028 	SetTextL(text); // won't leave as SetBufferReserveLengthL has been called
       
  1029 	CleanupStack::PushL(TCleanupItem(CleanupLabel,&labelCleanup));
       
  1030 	if (image)
       
  1031 		image->SetPictureOwnedExternally(ETrue);
       
  1032 	SetPictureL(aBitmap,aMask); // !!! may delete a CEikImage => rollback impossible
       
  1033 	if (aBitmap)
       
  1034 		Picture()->SetPictureOwnedExternally(EFalse);
       
  1035 	CleanupStack::Pop(2); // imageCleanup, stackCleanup
       
  1036 	CEikCommandStack::TStackableCommand& cmd=stack->StackableCommand(aCommandId);
       
  1037 	cmd.SetBitmapOwner(ETrue);
       
  1038 	cmd.SetDimmed(IsDimmed());
       
  1039 	cmd.SetVisible(IsVisible());
       
  1040 	SetDimmed(EFalse);
       
  1041 	MakeVisible(ETrue);
       
  1042 	}
       
  1043 
       
  1044 /**
       
  1045  * Removes the command which has aCommandId from the stack of commmands.
       
  1046  *
       
  1047  * @since App-Framework_6.1
       
  1048  */
       
  1049 EXPORT_C TBool CEikCommandButton::RemoveCommandFromStack(TInt aCommandId)
       
  1050 	{
       
  1051 	// __ASSERT_DEBUG(Extension()==NULL,.....
       
  1052 	CEikCommandStack* stack=CommandStack();
       
  1053 	return stack->Remove(aCommandId);
       
  1054 	}
       
  1055 
       
  1056 /**
       
  1057  * Pops the current command from the stack, if there is one.  Restores the command button to
       
  1058  * respond to the previous commandId before the last push to the stack.  The text, bitmap and mask
       
  1059  * are also restored to the previous values (before the last push was made).
       
  1060  *
       
  1061  * @since App-Framework_6.1
       
  1062  */
       
  1063 EXPORT_C TInt CEikCommandButton::PopCommandFromStack()
       
  1064 	{
       
  1065 	CEikCommandStack* stack=CommandStack();
       
  1066 	__ASSERT_DEBUG(stack,Panic(EEikPanicCommandStackIsNull));
       
  1067 	CEikCommandStack::TStackableCommand cmd=stack->Pop();
       
  1068 
       
  1069 	TPtrC text;
       
  1070 	if (cmd.iText)
       
  1071 		{
       
  1072 		text.Set(*(cmd.iText));
       
  1073 		}
       
  1074 	SetTextL(text); // won't leave as SetBufferReserveLengthL has been called
       
  1075 	delete cmd.iText;
       
  1076 	TRAP_IGNORE(SetPictureL(cmd.iBitmap,cmd.iMask));
       
  1077 	SetDimmed(cmd.IsDimmed());
       
  1078 	MakeVisible(cmd.IsVisible());
       
  1079 
       
  1080 	return cmd.iCommandId;
       
  1081 	}
       
  1082 
       
  1083 
       
  1084 //
       
  1085 // class CEikTwoPictureCommandButton
       
  1086 //
       
  1087 
       
  1088 const TInt KPictureOwnedExternally	=0x10;
       
  1089 
       
  1090 
       
  1091 EXPORT_C CEikTwoPictureCommandButton::CEikTwoPictureCommandButton()
       
  1092 	{
       
  1093 	LafTwoPictureCommandButton::GetDefaultBorder(iBorder);
       
  1094 	iMargins = LafTwoPictureCommandButton::Margins();
       
  1095 	}
       
  1096 
       
  1097 EXPORT_C CEikTwoPictureCommandButton::~CEikTwoPictureCommandButton()
       
  1098 	{
       
  1099 	if(IsSecondPictureOwnedExternally())
       
  1100 		return;
       
  1101     if (iSecondBitmap != iSecondMaskBitmap)
       
  1102     	delete CONST_CAST(CFbsBitmap*,iSecondBitmap);
       
  1103 	delete CONST_CAST(CFbsBitmap*,iSecondMaskBitmap);
       
  1104 	}
       
  1105 
       
  1106 /**
       
  1107  * Sets the text for the button label to aText.
       
  1108  */
       
  1109 EXPORT_C void CEikTwoPictureCommandButton::SetTextL(const TDesC& aText)
       
  1110 	{
       
  1111 	CEikCommandButtonBase::SetTextL(aText,iComponents[0]);
       
  1112 	}
       
  1113 
       
  1114 /**
       
  1115  * Sets both the pictures for the command button. The first picture is created from the image bitmap aMain
       
  1116  * and the mask bitmap aMask. The optional second picture is created from the image bitmap aSecondMain and mask
       
  1117  * bitmap aSecondMask.
       
  1118  */
       
  1119 EXPORT_C void CEikTwoPictureCommandButton::SetTwoPicturesL(const CFbsBitmap* aMain,const CFbsBitmap* aMask,const CFbsBitmap* aSecondMain,const CFbsBitmap* aSecondMask)
       
  1120 	{
       
  1121 	CEikCommandButtonBase::SetPictureL(aMain,aMask,iComponents[1]);
       
  1122 	SetSecondPicture(aSecondMain,aSecondMask);
       
  1123 	}
       
  1124 
       
  1125 /**
       
  1126  * Sets the first picture for the button by loading the image bitmap identified by aMain and the mask bitmap
       
  1127  * identified by aMask from the bitmap file named aFilename.
       
  1128  */
       
  1129 EXPORT_C void CEikTwoPictureCommandButton::SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask)
       
  1130 	{
       
  1131 	CEikCommandButtonBase::SetPictureFromFileL(aFilename,aMain,aMask,iComponents[1]);
       
  1132 	}
       
  1133 
       
  1134 /**
       
  1135  * Sets the second picture for the button by loading the image bitmap identified by aMain and the mask bitmap
       
  1136  * identified by aMask from the bitmap file named aFilename.
       
  1137  */
       
  1138 EXPORT_C void CEikTwoPictureCommandButton::SetSecondPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask)
       
  1139 	{
       
  1140 	CFbsBitmap* secondBitmap = iEikonEnv->CreateBitmapL(aFilename, aMain);
       
  1141 	//CFbsBitmap* secondBitmap = AknIconUtils::CreateIconL( aFilename, aMain );
       
  1142 	CFbsBitmap* secondMask = NULL;
       
  1143 	if(aMask!=-1)
       
  1144 		secondMask = iEikonEnv->CreateBitmapL(aFilename, aMask);
       
  1145 		//secondMask = AknIconUtils::CreateIconL( aFileName, aMask );
       
  1146 	SetSecondPicture(secondBitmap, secondMask);
       
  1147 	}
       
  1148 
       
  1149 /**
       
  1150  * Returns a pointer to the image control component of the button which displays the button pictures.
       
  1151  */
       
  1152 EXPORT_C CEikImage* CEikTwoPictureCommandButton::Picture() const
       
  1153 	{
       
  1154 	return STATIC_CAST(CEikImage*,iComponents[1]);
       
  1155 	}
       
  1156 
       
  1157 /**
       
  1158  * Sets the second picture for the button using aSecondMain as the image bitmap and aSecondMask as the mask bitmap.
       
  1159  * Takes ownership of the bitmaps unless the second picture has been set to be owned externally.
       
  1160  */
       
  1161 EXPORT_C void CEikTwoPictureCommandButton::SetSecondPicture(const CFbsBitmap* aSecondMain,const CFbsBitmap* aSecondMask)
       
  1162 	{
       
  1163 	if (!IsSecondPictureOwnedExternally())
       
  1164 		{
       
  1165 		if (iSecondBitmap!=iSecondMaskBitmap)
       
  1166     		delete const_cast<CFbsBitmap*>(iSecondBitmap);
       
  1167 		delete const_cast<CFbsBitmap*>(iSecondMaskBitmap);
       
  1168 		}
       
  1169 	iSecondBitmap=aSecondMain;
       
  1170 	iSecondMaskBitmap=aSecondMask;
       
  1171 	}
       
  1172 
       
  1173 void CEikTwoPictureCommandButton::SwapPictures(CEikImage* aImage)
       
  1174 	{
       
  1175 	if(iSecondBitmap)	// only swap if the second bitmap exists
       
  1176 		{
       
  1177 		const CFbsBitmap* tempBitmap = aImage->Bitmap();
       
  1178 		const CFbsBitmap* tempMaskBitmap = aImage->Mask();
       
  1179 		TBool oldImageOwnership = aImage->IsPictureOwnedExternally();
       
  1180 
       
  1181 		aImage->SetPictureOwnedExternally(ETrue);
       
  1182 		aImage->SetPicture(iSecondBitmap,iSecondMaskBitmap);
       
  1183 		aImage->SetPictureOwnedExternally(IsSecondPictureOwnedExternally());
       
  1184 
       
  1185 		SetSecondPictureOwnedExternally(oldImageOwnership);
       
  1186 		iSecondBitmap=tempBitmap;
       
  1187 		iSecondMaskBitmap=tempMaskBitmap;
       
  1188 
       
  1189 		SetImageAttributes(aImage);
       
  1190 		if (IsReadyToDraw())
       
  1191 			{
       
  1192 			TRAP_IGNORE(aImage->ActivateL());
       
  1193 			}
       
  1194 		}
       
  1195 	}
       
  1196 
       
  1197 EXPORT_C void CEikTwoPictureCommandButton::ConstructFromResourceL(TResourceReader& aReader)
       
  1198 	{
       
  1199 	StartConstructFromResourceL(aReader);
       
  1200 	ConstructLabelFromResourceL(aReader,EFirst);
       
  1201 	ConstructImagesFromResourceL(aReader,ESecond);
       
  1202 	}
       
  1203 
       
  1204 EXPORT_C void CEikTwoPictureCommandButton::ConstructImagesFromResourceL(TResourceReader& aReader,TWhichComponent /*aWhich*/)
       
  1205 	{
       
  1206 	CheckCreateCommandStackL();
       
  1207 	TPtrC bitmapFile=aReader.ReadTPtrC();
       
  1208 
       
  1209 	const TInt bitmapId=aReader.ReadInt16();
       
  1210 	const TInt bitmapMask=aReader.ReadInt16();
       
  1211 	if (bitmapId!=-1)
       
  1212 		SetPictureFromFileL(bitmapFile,bitmapId,bitmapMask);
       
  1213 
       
  1214 	const TInt bitmapSecondId=aReader.ReadInt16();
       
  1215 	const TInt bitmapSecondMask=aReader.ReadInt16();
       
  1216 	if (bitmapSecondId!=-1)
       
  1217 		SetSecondPictureFromFileL(bitmapFile,bitmapSecondId,bitmapSecondMask);
       
  1218 	}
       
  1219 
       
  1220 EXPORT_C void CEikTwoPictureCommandButton::Draw(const TRect& /*aRect*/) const
       
  1221 	{
       
  1222 	CWindowGc& gc=SystemGc();
       
  1223 	PrepareContext(gc);
       
  1224 	CEikCommandButtonBase::Draw(Rect());
       
  1225     }
       
  1226 
       
  1227 EXPORT_C void CEikTwoPictureCommandButton::StateChanged()
       
  1228 	{
       
  1229 	CEikImage* component = STATIC_CAST(CEikImage*, iComponents[1]);
       
  1230 	if (component == NULL)
       
  1231 		return;
       
  1232 	TInt state = DrawState();
       
  1233 	if ( (Behavior() == EEikButtonLatches) )
       
  1234 		{
       
  1235 		switch (state)
       
  1236 			{
       
  1237 		case EDrawClearPressed:
       
  1238 		case EDrawSetPressed:
       
  1239 			SwapPictures(component);
       
  1240 			break;
       
  1241 		default:
       
  1242 			break;
       
  1243 			}
       
  1244 		}
       
  1245 	else
       
  1246 		{
       
  1247 		switch (state)
       
  1248 			{
       
  1249 		case EDrawClearPressed:
       
  1250 		case EDrawClear:
       
  1251 			SwapPictures(component);
       
  1252 			break;
       
  1253 		default:
       
  1254 			break;
       
  1255 			}
       
  1256 		}
       
  1257 	if( iBorder.HasBorder() )
       
  1258 		CEikCommandButtonBase::StateChanged();
       
  1259     }
       
  1260     
       
  1261 EXPORT_C void CEikTwoPictureCommandButton::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
  1262     { 
       
  1263     CEikCommandButtonBase::HandlePointerEventL(aPointerEvent); 
       
  1264     }    
       
  1265 
       
  1266 EXPORT_C void* CEikTwoPictureCommandButton::ExtensionInterface( TUid /*aInterface*/ )
       
  1267     {
       
  1268     return NULL;
       
  1269     }
       
  1270 
       
  1271 EXPORT_C void CEikTwoPictureCommandButton::PrepareContext(CWindowGc& aGc) const
       
  1272 	{
       
  1273 	if (iBorder.HasBorder())
       
  1274 		LafCommandButtonBase::PrepareContext(aGc,DrawState(),iEikonEnv->LafEnv(),*this);
       
  1275 	else
       
  1276 		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1277 	}
       
  1278 
       
  1279 /**
       
  1280  * Sets the bitmaps used for the second button picture to be owned externally if aOwnership is ETrue.
       
  1281  */
       
  1282 EXPORT_C void CEikTwoPictureCommandButton::SetSecondPictureOwnedExternally(TBool aOwnership)
       
  1283 	{
       
  1284 	if (aOwnership)
       
  1285 		iPictureFlags|=KPictureOwnedExternally;
       
  1286 	else
       
  1287 		iPictureFlags&=~KPictureOwnedExternally;
       
  1288 	}
       
  1289 
       
  1290 /**
       
  1291  * Returns ETrue if the bitmaps for the second button picture are owned externally.
       
  1292  */
       
  1293 EXPORT_C TBool CEikTwoPictureCommandButton::IsSecondPictureOwnedExternally()
       
  1294 	{
       
  1295     if (iPictureFlags&KPictureOwnedExternally)
       
  1296 		return ETrue;
       
  1297 	else
       
  1298 		return EFalse;
       
  1299 	}
       
  1300 
       
  1301 EXPORT_C void CEikTwoPictureCommandButton::ActivateL()
       
  1302 	{
       
  1303 	__ASSERT_DEBUG(iSecondBitmap, Panic(EEikPanicButtonHasNoComponent));
       
  1304 	if (iBorder.HasBorder())
       
  1305 		CEikCommandButtonBase::ActivateL();
       
  1306 	else
       
  1307 		{
       
  1308 		if (iComponents[0])
       
  1309 			iComponents[0]->CopyControlContextFrom(this);
       
  1310 		if (iComponents[1])
       
  1311 			iComponents[1]->CopyControlContextFrom(this);
       
  1312 		UpdateComponentAlignment();
       
  1313 		CCoeControl::ActivateL();
       
  1314 		}
       
  1315 	}
       
  1316 
       
  1317 /**
       
  1318  * Writes the internal state of the control and its components to aStream.
       
  1319  * Does nothing in release mode.
       
  1320  * Designed to be overidden and base called by subclasses.
       
  1321  *
       
  1322  * @internal
       
  1323  * @since App-Framework_6.1
       
  1324  */
       
  1325 #ifndef _DEBUG
       
  1326 EXPORT_C void CEikTwoPictureCommandButton::WriteInternalStateL(RWriteStream&) const
       
  1327 	{}
       
  1328 #else
       
  1329 EXPORT_C void CEikTwoPictureCommandButton::WriteInternalStateL(RWriteStream& aWriteStream) const
       
  1330 	{
       
  1331 	_LIT(KLitEikTwPcCmdButCtlStart, "<CEikTwoPictureCommandButton>");
       
  1332 	_LIT(KLitEikTwPcCmdButCtlEnd, "<\\CEikTwoPictureCommandButton>");
       
  1333 	_LIT(KLitEikTwPcCmdButScndBmp,"<iSecondBitmap>");
       
  1334 	_LIT(KLitEikTwPcCmdButScndBmpEnd,"<\\iSecondBitmap>");
       
  1335 	_LIT(KLitEikTwPcCmdButScndMsk,"<iSecondMaskBitmap>");
       
  1336 	_LIT(KLitEikTwPcCmdButScndMskEnd,"<\\iSecondMaskBitmap>");
       
  1337 	_LIT(KLitEikTwPcCmdButPcFlgs,"<iPictureFlags>");
       
  1338 	_LIT(KLitEikTwPcCmdButPcFlgsEnd,"<\\iPictureFlags>");
       
  1339 	
       
  1340 	aWriteStream << KLitEikTwPcCmdButCtlStart;
       
  1341 	aWriteStream << KLitEikTwPcCmdButScndBmp;
       
  1342 	aWriteStream << *iSecondBitmap;
       
  1343 	aWriteStream << KLitEikTwPcCmdButScndBmpEnd;
       
  1344 	aWriteStream << KLitEikTwPcCmdButScndMsk;
       
  1345 	aWriteStream << *iSecondMaskBitmap;
       
  1346 	aWriteStream << KLitEikTwPcCmdButScndMskEnd;
       
  1347 	aWriteStream << KLitEikTwPcCmdButPcFlgs;
       
  1348 	aWriteStream.WriteInt32L(iPictureFlags);
       
  1349 	aWriteStream << KLitEikTwPcCmdButPcFlgsEnd;
       
  1350 	CEikCommandButtonBase::WriteInternalStateL(aWriteStream);
       
  1351 	aWriteStream << KLitEikTwPcCmdButCtlEnd;
       
  1352 	}
       
  1353 #endif
       
  1354 
       
  1355 //
       
  1356 // class CEikInverterCommandButton
       
  1357 //
       
  1358 
       
  1359 #define KBaseColor		KRgbDarkGray
       
  1360 #define KInverterColor	KRgbBlack
       
  1361 
       
  1362 
       
  1363 EXPORT_C CEikInverterCommandButton::CEikInverterCommandButton()
       
  1364 	{
       
  1365 	iMargins = LafInverterCommandButton::Margins();
       
  1366 	}
       
  1367 
       
  1368 EXPORT_C CEikInverterCommandButton::~CEikInverterCommandButton()
       
  1369 	{}
       
  1370 
       
  1371 EXPORT_C void CEikInverterCommandButton::PrepareContext(CWindowGc& aGc) const
       
  1372 	{
       
  1373 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1374 	TRgb penColor;
       
  1375 	TRgb brushColor;
       
  1376 	switch (DrawState())
       
  1377 		{
       
  1378 	case EDrawSet:
       
  1379 		penColor = KBaseColor;
       
  1380 		brushColor= KInverterColor;
       
  1381 		break;
       
  1382 	case EDrawClearPressed:
       
  1383 		penColor= KBaseColor;
       
  1384 		brushColor= KInverterColor;
       
  1385 		break;
       
  1386 	case EDrawClear:
       
  1387 		penColor= KInverterColor;
       
  1388 		brushColor=KBaseColor;
       
  1389 		break;
       
  1390 	case EDrawSetPressed:
       
  1391 		penColor= KInverterColor;
       
  1392 		brushColor= KBaseColor;
       
  1393 		break;
       
  1394 	default:
       
  1395 		break;
       
  1396 		}
       
  1397 	aGc.SetPenColor(penColor);
       
  1398 	aGc.SetBrushColor(brushColor);
       
  1399 	}
       
  1400 	
       
  1401 EXPORT_C void CEikInverterCommandButton::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
  1402     { 
       
  1403     CEikCommandButton::HandlePointerEventL(aPointerEvent); 
       
  1404     }	
       
  1405 
       
  1406 EXPORT_C void* CEikInverterCommandButton::ExtensionInterface( TUid /*aInterface*/ )
       
  1407     {
       
  1408     return NULL;
       
  1409     }
       
  1410 
       
  1411 EXPORT_C void CEikInverterCommandButton::WriteInternalStateL(RWriteStream& aWriteStream) const
       
  1412 	{
       
  1413 	_LIT(KLitEikInvCmdButCtlStart, "<CEikTwoPictureCommandButton>");
       
  1414 	_LIT(KLitEikInvCmdButCtlEnd, "<\\CEikTwoPictureCommandButton>");
       
  1415 	_LIT(KLitEikInvCmdButFlg,"<iFlag>");
       
  1416 	_LIT(KLitEikInvCmdButFlgEnd,"<\\iFlag>");
       
  1417 	aWriteStream << KLitEikInvCmdButCtlStart;
       
  1418 	aWriteStream << KLitEikInvCmdButFlg;
       
  1419 	aWriteStream.WriteInt32L(iFlag);
       
  1420 	aWriteStream << KLitEikInvCmdButFlgEnd;
       
  1421 	CEikCommandButton::WriteInternalStateL(aWriteStream);
       
  1422 	aWriteStream << KLitEikInvCmdButCtlEnd;
       
  1423 	}
       
  1424 
       
  1425 //
       
  1426 // class CEikTextButton
       
  1427 //
       
  1428 
       
  1429 EXPORT_C CEikTextButton::CEikTextButton()
       
  1430 	{
       
  1431 	iMargins = LafTextButton::Margins();
       
  1432 	}
       
  1433 
       
  1434 EXPORT_C CEikTextButton::~CEikTextButton()
       
  1435 	{}
       
  1436 
       
  1437 EXPORT_C void CEikTextButton::SetTextL(const TDesC& aText,TWhichComponent aWhich)
       
  1438 	{
       
  1439 	CEikCommandButtonBase::SetTextL(aText,(aWhich==EFirst? iComponents[0] : iComponents[1]));
       
  1440 	}
       
  1441 
       
  1442 EXPORT_C CEikLabel* CEikTextButton::Label(TWhichComponent aWhich) const
       
  1443 	{
       
  1444 	return STATIC_CAST(CEikLabel*,(aWhich==EFirst? iComponents[0] : iComponents[1]));
       
  1445 	}
       
  1446 
       
  1447 EXPORT_C void CEikTextButton::ConstructFromResourceL(TResourceReader& aReader)
       
  1448 	{
       
  1449 	StartConstructFromResourceL(aReader);
       
  1450 	ConstructLabelFromResourceL(aReader,EFirst);
       
  1451 	ConstructLabelFromResourceL(aReader,ESecond);
       
  1452 	}
       
  1453 
       
  1454 EXPORT_C void CEikTextButton::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
  1455     { 
       
  1456     CEikCommandButtonBase::HandlePointerEventL(aPointerEvent); 
       
  1457     }
       
  1458 
       
  1459 EXPORT_C void* CEikTextButton::ExtensionInterface( TUid /*aInterface*/ )
       
  1460     {
       
  1461     return NULL;
       
  1462     }
       
  1463 
       
  1464 //
       
  1465 // class CEikBitmapButton
       
  1466 //
       
  1467 
       
  1468 EXPORT_C CEikBitmapButton::CEikBitmapButton()
       
  1469 	{
       
  1470 	iMargins = LafBitmapButton::Margins();
       
  1471 	}
       
  1472 
       
  1473 EXPORT_C CEikBitmapButton::~CEikBitmapButton()
       
  1474 	{}
       
  1475 
       
  1476 EXPORT_C void CEikBitmapButton::SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask,TWhichComponent aWhich)
       
  1477 	{
       
  1478 	CEikCommandButtonBase::SetPictureL(aMain,aMask,(aWhich==EFirst? iComponents[0] : iComponents[1]));
       
  1479 	}
       
  1480 
       
  1481 EXPORT_C void CEikBitmapButton::SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask,TWhichComponent aWhich)
       
  1482 	{
       
  1483 	CEikCommandButtonBase::SetPictureFromFileL(aFilename,aMain,aMask,(aWhich==EFirst? iComponents[0] : iComponents[1]));
       
  1484 	}
       
  1485 
       
  1486 EXPORT_C CEikImage* CEikBitmapButton::Picture(TWhichComponent aWhich) const
       
  1487 	{
       
  1488 	return STATIC_CAST(CEikImage*,(aWhich==EFirst? iComponents[0] : iComponents[1]));
       
  1489 	}
       
  1490 
       
  1491 EXPORT_C void CEikBitmapButton::ConstructFromResourceL(TResourceReader& aReader)
       
  1492 	{
       
  1493 	StartConstructFromResourceL(aReader);
       
  1494 	ConstructImageFromResourceL(aReader,EFirst);
       
  1495 	ConstructImageFromResourceL(aReader,ESecond);
       
  1496 	}
       
  1497 
       
  1498 EXPORT_C void CEikBitmapButton::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
  1499     { 
       
  1500     CEikCommandButtonBase::HandlePointerEventL(aPointerEvent); 
       
  1501     }
       
  1502 
       
  1503 EXPORT_C void* CEikBitmapButton::ExtensionInterface( TUid /*aInterface*/ )
       
  1504     {
       
  1505     return NULL;
       
  1506     }