uifw/EikStd/coctlsrc/EIKTBAR.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 <barsread.h>
       
    20 #include <coemain.h>
       
    21 #include <eiktbar.h>
       
    22 #include <eikbutb.h>
       
    23 #include <eikcmobs.h>
       
    24 #include <eikfctry.h>
       
    25 #include <eikpanic.h>
       
    26 #include <uikon.hrh>
       
    27 #include <eikenv.h>
       
    28 #include <eikapp.h>
       
    29 #include <eikappui.h>
       
    30 #include <eikdoc.h>
       
    31 #include <eikcmbut.h>
       
    32 #include <gulcolor.h>
       
    33 #include "LAFTBAR.H"
       
    34 
       
    35 
       
    36 EXPORT_C CEikToolBar::~CEikToolBar()
       
    37 	{
       
    38 	delete iBrushAndPenContext;
       
    39 	delete iControlTypes;
       
    40 	}	
       
    41 
       
    42 EXPORT_C CEikToolBar::CEikToolBar()
       
    43 	{
       
    44 	__DECLARE_NAME(_S("CEikToolBar"));
       
    45 	LafToolBar::GetDefaultBorder(iBorder);
       
    46 	}
       
    47 
       
    48 void CEikToolBar::BaseConstructL()
       
    49 	{
       
    50 	CreateWindowL();
       
    51 	Window().SetBackgroundColor(iEikonEnv->ControlColor(EColorToolbarBackground,*this));
       
    52 	RDrawableWindow* window=DrawableWindow();
       
    53 	window->SetPointerGrab(ETrue);
       
    54 	window->SetShadowDisabled(ETrue);
       
    55 	EnableDragEvents();
       
    56 	iBrushAndPenContext=CCoeBrushAndPenContext::NewL();
       
    57 	iBrushAndPenContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
    58 	iBrushAndPenContext->SetBrushColor(iEikonEnv->ControlColor(EColorToolbarBackground,*this));
       
    59 	iBrushAndPenContext->SetPenColor(iEikonEnv->ControlColor(EColorToolbarText,*this));
       
    60 	SetControlContext(iBrushAndPenContext);
       
    61 	}
       
    62 
       
    63 EXPORT_C void CEikToolBar::ConstructFromResourceL(TResourceReader& aReader)
       
    64 	{
       
    65 	if (!iControlTypes)
       
    66 		iControlTypes=new(ELeave) CArrayFixFlat<TInt>(4);
       
    67 	const TInt length=aReader.ReadInt16();
       
    68 	const TInt breadth=aReader.ReadInt16();
       
    69 	const TInt lines=aReader.ReadInt8();
       
    70 	iToolBarFlags=aReader.ReadInt32();
       
    71 	if (iToolBarFlags&EEikToolBarHorizontal)
       
    72 		CEikControlGroup::ConstructL(CEikControlGroup::EFromTopLeft,CEikControlGroup::ELayHorizontally);
       
    73 	else
       
    74 		CEikControlGroup::ConstructL(CEikControlGroup::EFromTopRight,CEikControlGroup::ELayVertically);
       
    75 	if (length)
       
    76 		SetLengthInPixels(length);
       
    77 	if (breadth)
       
    78 		SetBreadthInPixels(breadth);
       
    79 	SetNumberOfLines(lines,iToolBarFlags&EEikToolBarDistributeControlsEvenlyBetweenLines);
       
    80 	if (iToolBarFlags&EEikToolBarAllControlsSameSize)
       
    81 		SetControlsAllSameSize();
       
    82 
       
    83 	const TInt count=aReader.ReadInt16();
       
    84 	for (TInt ii=0;ii<count;++ii)
       
    85 		{
       
    86 		const TInt ctrlType=aReader.ReadInt16();
       
    87 		CCoeControl* ctrl=EikControlFactory::CreateByTypeL(ctrlType).iControl;
       
    88 		if (!ctrl)
       
    89 			ctrl=iCommandObserver->CreateCustomCommandControlL(ctrlType);
       
    90 		__ASSERT_DEBUG(ctrl, Panic(EEikPanicToolBarNullControl));
       
    91 		ctrl->SetNonFocusing();
       
    92 		CleanupStack::PushL(ctrl);
       
    93 		const TInt id=aReader.ReadInt16();
       
    94 		const TInt flags=aReader.ReadInt16();
       
    95 		TEikGroupControl groupCtrl(ctrl,id,aReader.ReadInt16(),flags);
       
    96 		AddControlL(groupCtrl); // ownership now taken by array
       
    97 		CleanupStack::Pop(); // ctrl
       
    98 		AddControlTypeL(ctrlType);
       
    99 		ctrl->ConstructFromResourceL(aReader);
       
   100 		}
       
   101 
       
   102 	aReader.ReadInt32(); // extension link
       
   103 	}
       
   104 
       
   105 EXPORT_C void CEikToolBar::SetDimmed(TBool aDimmed)
       
   106 	{
       
   107 	const TInt count=iControlArray->Count();
       
   108 	for (TInt ii=0;ii<count;ii++)
       
   109 		(*iControlArray)[ii].iControl->SetDimmed(aDimmed);
       
   110 	}
       
   111 
       
   112 EXPORT_C void CEikToolBar::ReduceRect(TRect& aBoundingRect) const
       
   113 	{
       
   114 	if (!IsVisible())
       
   115 		return;
       
   116 	if (iToolBarFlags&EEikToolBarHorizontal)
       
   117 		aBoundingRect.iTl.iY+=iSize.iHeight;
       
   118 	else
       
   119 		aBoundingRect.iBr.iX-=iSize.iWidth;
       
   120 	}
       
   121 
       
   122 EXPORT_C void CEikToolBar::SetBoundingRect(const TRect& aRect)
       
   123 	{
       
   124 	TSize size=aRect.Size();
       
   125 	SetLengthInPixels(iToolBarFlags&EEikToolBarHorizontal? size.iWidth: size.iHeight);
       
   126 	TSize thisSize=MinimumSize();
       
   127 	TPoint thisPos=aRect.iTl;
       
   128 	if (iToolBarFlags&EEikToolBarHorizontal)
       
   129 		iSize.iHeight=thisSize.iHeight;
       
   130 	else
       
   131 		{
       
   132 		thisPos.iX=aRect.iBr.iX-thisSize.iWidth;
       
   133 		iSize.iWidth=thisSize.iWidth;
       
   134 		}
       
   135 	CCoeControl::SetExtent(thisPos,iSize);
       
   136 	}
       
   137 
       
   138 EXPORT_C void CEikToolBar::StaticConstructL(MEikCommandObserver* aCommandObserver,TInt aResourceId)
       
   139 	{
       
   140 	BaseConstructL();
       
   141 	iCommandObserver=aCommandObserver;
       
   142 	if (aResourceId)
       
   143 		{
       
   144 		TResourceReader reader;
       
   145 		iCoeEnv->CreateResourceReaderLC(reader,aResourceId);
       
   146 		ConstructFromResourceL(reader);
       
   147 		CleanupStack::PopAndDestroy();
       
   148 		}
       
   149 	}
       
   150 
       
   151 EXPORT_C void CEikToolBar::ConstructL(MEikCommandObserver* aCommandObserver,TInt aResourceId,const TRect& aBoundingRect)
       
   152 	{
       
   153 	if (!iControlTypes)
       
   154 		iControlTypes=new(ELeave) CArrayFixFlat<TInt>(4);
       
   155 	StaticConstructL(aCommandObserver,aResourceId);
       
   156 	SetBoundingRect(aBoundingRect);
       
   157 	if (!(iToolBarFlags&EEikToolBarDelayActivation))
       
   158 		ActivateL();
       
   159 	}
       
   160 
       
   161 EXPORT_C void CEikToolBar::SetCommandObserver(MEikCommandObserver* aCommandObserver)
       
   162 	{
       
   163 	iCommandObserver=aCommandObserver;
       
   164 	}
       
   165 
       
   166 EXPORT_C void CEikToolBar::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEvent)
       
   167 	{
       
   168 	__ASSERT_DEBUG(iCommandObserver, Panic(EEikPanicToolBarHasNoObserver));
       
   169 	if (aEvent==EEventStateChanged)
       
   170 		{
       
   171 		TInt aCommand=ControlId(aControl);
       
   172 		iCommandObserver->ProcessCommandL(aCommand);
       
   173 		}
       
   174 	}
       
   175 
       
   176 EXPORT_C void CEikToolBar::AddControlL(CCoeControl* aControl,TInt aId)
       
   177 	{
       
   178 	CEikControlGroup::AddControlL(aControl,aId);
       
   179 	aControl->SetObserver(this);
       
   180 	}
       
   181 
       
   182 EXPORT_C void CEikToolBar::AddControlL(TEikGroupControl& aGroupControl)
       
   183 	{
       
   184 	CEikControlGroup::AddControlL(aGroupControl);
       
   185 	aGroupControl.iControl->SetObserver(this);
       
   186 	}
       
   187 
       
   188 EXPORT_C void CEikToolBar::CoordinateButtons(TInt aId,TInt aCount,TEikButtonCoordinator* aCoordinator)
       
   189 	{
       
   190 	TInt index=IndexById(aId);
       
   191 	while (aCount--)
       
   192 		((CEikButtonBase*)Control(index++))->SetCoordinator(aCoordinator);
       
   193 	}
       
   194 
       
   195 EXPORT_C TBool CEikToolBar::DelayActivation() const
       
   196 	{
       
   197 	return (iToolBarFlags&EEikToolBarDelayActivation);
       
   198 	}
       
   199 
       
   200 EXPORT_C void CEikToolBar::SetButtonStateOn(TInt aId,TBool aState)
       
   201 	{
       
   202 	CEikButtonBase* button=(CEikButtonBase*)ControlById(aId);
       
   203 	CEikButtonBase::TState bState=aState? CEikButtonBase::ESet: CEikButtonBase::EClear;
       
   204 	if (button->State()==bState)
       
   205 		return;
       
   206 	button->SetState(bState);
       
   207 	button->DrawDeferred();
       
   208 	}
       
   209 
       
   210 /**
       
   211  * Writes the internal state of the control and its components to aStream.
       
   212  * Does nothing in release mode.
       
   213  * Designed to be overidden and base called by subclasses.
       
   214  *
       
   215  * @internal
       
   216  * @since App-Framework_6.1
       
   217  */
       
   218 #ifndef _DEBUG
       
   219 EXPORT_C void CEikToolBar::WriteInternalStateL(RWriteStream&) const
       
   220 	{}
       
   221 #else
       
   222 EXPORT_C void CEikToolBar::WriteInternalStateL(RWriteStream& aWriteStream) const
       
   223 	{
       
   224 	_LIT(KLitEikTBarCtlStart, "<CEikToolBar>");
       
   225 	_LIT(KLitEikTBarCtlEnd, "<\\CEikToolBar>");
       
   226 	_LIT(KLitEikTBarFlgs,"<iToolBarFlags>");
       
   227 	_LIT(KLitEikTBarFlgsEnd,"<\\iToolBarFlags>");
       
   228 	_LIT(KLitEikTBarCntxt,"<iBrushAndPenContext>");
       
   229 	_LIT(KLitEikTBarCntxtEnd,"<\\iBrushAndPenContext>");
       
   230 	_LIT(KLitEikTBarCtlTypes,"<iControlTypes>");
       
   231 	_LIT(KLitEikTBarCtlTypesEnd,"<\\iControlTypes>");
       
   232 
       
   233 	aWriteStream << KLitEikTBarCtlStart;
       
   234 	aWriteStream << KLitEikTBarFlgs;
       
   235 	aWriteStream.WriteInt32L(iToolBarFlags);
       
   236 	aWriteStream << KLitEikTBarFlgsEnd;
       
   237 	aWriteStream << KLitEikTBarCntxt;
       
   238 	aWriteStream.WriteInt32L(iBrushAndPenContext->BrushStyle());
       
   239 	aWriteStream << iBrushAndPenContext->BrushColor();
       
   240 	if(&(iBrushAndPenContext->BrushBitmap()))
       
   241 		aWriteStream << iBrushAndPenContext->BrushBitmap();
       
   242 	aWriteStream << iBrushAndPenContext->PenColor();
       
   243 	aWriteStream << KLitEikTBarCntxtEnd;
       
   244 	aWriteStream << KLitEikTBarCtlTypes;
       
   245 	const TInt count=iControlTypes->Count();
       
   246 	for(TInt ii=0;ii<count;ii++)
       
   247 		{
       
   248 		aWriteStream.WriteInt32L((*iControlTypes)[ii]);
       
   249 		}
       
   250 	aWriteStream << KLitEikTBarCtlTypesEnd;
       
   251 	CEikControlGroup::WriteInternalStateL(aWriteStream);
       
   252 	aWriteStream << KLitEikTBarCtlEnd;
       
   253 	}
       
   254 #endif
       
   255 
       
   256 EXPORT_C void CEikToolBar::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
       
   257     { 
       
   258     CEikControlGroup::HandlePointerEventL(aPointerEvent); 
       
   259     }
       
   260 
       
   261 EXPORT_C void* CEikToolBar::ExtensionInterface( TUid /*aInterface*/ )
       
   262     {
       
   263     return NULL;
       
   264     }
       
   265 
       
   266 EXPORT_C void CEikToolBar::Reserved_2()
       
   267 	{}
       
   268 
       
   269 TInt CEikToolBar::ControlCount() const
       
   270 	{
       
   271 	return iControlArray->Count();
       
   272 	}
       
   273 
       
   274 /**
       
   275  * Gets the list of logical colors employed in the drawing of the control,
       
   276  * paired with an explanation of how they are used. Appends the list to aColorUseList.
       
   277  *
       
   278  * @since ER5U 
       
   279  */
       
   280 EXPORT_C void CEikToolBar::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const
       
   281 	{
       
   282 	CEikControlGroup::GetColorUseListL(aColorUseList);
       
   283 	LafToolBar::GetColorUseListL(aColorUseList);
       
   284 	}
       
   285 
       
   286 /**
       
   287  * Handles a change to the control's resources of type aType
       
   288  * which are shared across the environment, e.g. colors or fonts.
       
   289  *
       
   290  * @since ER5U 
       
   291  */
       
   292 EXPORT_C void CEikToolBar::HandleResourceChange(TInt aType)
       
   293 	{
       
   294 	CEikControlGroup::HandleResourceChange(aType);
       
   295 
       
   296 	if(aType==KEikMessageColorSchemeChange)
       
   297 		{
       
   298 		iBrushAndPenContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   299 		iBrushAndPenContext->SetBrushColor(iEikonEnv->ControlColor(EColorToolbarBackground,*this));
       
   300 		iBrushAndPenContext->SetPenColor(iEikonEnv->ControlColor(EColorToolbarText,*this));
       
   301 		Window().SetBackgroundColor(iEikonEnv->ControlColor(EColorToolbarBackground,*this));
       
   302 		}
       
   303 	}
       
   304 
       
   305 void CEikToolBar::AddControlTypeL(TInt aType)
       
   306 	{
       
   307 	iControlTypes->AppendL(aType);
       
   308 	}
       
   309 
       
   310 void CEikToolBar::RemoveControlType(TInt aIndex)
       
   311 	{
       
   312 	iControlTypes->Delete(aIndex);
       
   313 	}
       
   314 
       
   315 TBool CEikToolBar::ControlIsButton(TInt aIndex) const
       
   316 	{
       
   317 	if (ControlCount()!=iControlTypes->Count())
       
   318 		return EFalse;
       
   319 	const TInt type=(*iControlTypes)[aIndex];
       
   320 	switch (type)
       
   321 		{
       
   322 	case EEikCtCommandButton:
       
   323 	case EEikCtLabeledButton:
       
   324 	case EEikCtTextButton:
       
   325 	case EEikCtMenuButton:
       
   326 	case EEikCtBitmapButton:
       
   327 		return ETrue;
       
   328 	default:
       
   329 		break;
       
   330 		}
       
   331 	return EFalse;
       
   332 	}
       
   333 
       
   334 void CEikToolBar::SetCommandL(TInt aPosition,TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask)
       
   335 	{
       
   336 	ButtonByIndex(aPosition)->SetCommandL(aCommandId,aText,aBitmap,aMask);
       
   337 	SetCurrentId(aPosition,aCommandId);
       
   338 	}
       
   339 
       
   340 void CEikToolBar::SetCommandL(TInt /*aPosition*/,TInt /*aResourceId*/)
       
   341 	{
       
   342 
       
   343 	}
       
   344 
       
   345 void CEikToolBar::SetCommandSetL(TInt /*aResourceId*/)
       
   346 	{
       
   347 
       
   348 	}
       
   349 
       
   350 void CEikToolBar::AddCommandL(TInt /*aPosition*/,TInt /*aCommandId*/,const TDesC* /*aText*/,const CFbsBitmap* /*aBitmap*/,const CFbsBitmap* /*aMask*/)
       
   351 	{
       
   352 	User::Leave(KErrNotSupported);
       
   353 	}
       
   354 
       
   355 void CEikToolBar::AddCommandToStackL(TInt aPosition,TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask)
       
   356 	{
       
   357 	ButtonByIndex(aPosition)->AddCommandToStackL(CurrentId(aPosition),aText,aBitmap,aMask);
       
   358 	SetCurrentId(aPosition,aCommandId);
       
   359 	}
       
   360 
       
   361 void CEikToolBar::AddCommandToStackL(TInt /*aPosition*/,TInt /*aResourceId*/)
       
   362 	{
       
   363 
       
   364 	}
       
   365 
       
   366 void CEikToolBar::AddCommandSetToStackL(TInt /*aResourceId*/)
       
   367 	{
       
   368 
       
   369 	}
       
   370 
       
   371 void CEikToolBar::SetDefaultCommand(TInt /*aCommandId*/)
       
   372 	{
       
   373 	}
       
   374 
       
   375 TSize CEikToolBar::CalcMinimumSizeL(TInt /*aResourceId*/)
       
   376 	{
       
   377 	return MinimumSize();
       
   378 	}
       
   379 
       
   380 void CEikToolBar::SetMSKCommandObserver(MEikCommandObserver* /*aCommandObserver*/)
       
   381     {
       
   382     }
       
   383 
       
   384 void CEikToolBar::DimCommandByPosition(TInt /*aPosition*/,TBool /*aDimmed*/)
       
   385     {
       
   386     }
       
   387     
       
   388 TBool CEikToolBar::IsCommandDimmedByPosition(TInt /*aPosition*/) const
       
   389     {
       
   390     return EFalse;
       
   391     }
       
   392     
       
   393 void CEikToolBar::MakeCommandVisibleByPosition(TInt /*aPosition*/,TBool /*aVisible*/)
       
   394     {
       
   395     }
       
   396 
       
   397 TBool CEikToolBar::IsCommandVisibleByPosition(TInt /*aPosition*/) const
       
   398     {
       
   399     return EFalse;
       
   400     }
       
   401 
       
   402 void CEikToolBar::AnimateCommandByPosition(TInt /*aPosition*/)
       
   403     {
       
   404     }
       
   405 
       
   406 void CEikToolBar::RemoveCommandFromStack(TInt aPosition,TInt aCommandId)
       
   407 	{
       
   408 	if (aCommandId==CurrentId(aPosition))
       
   409 		{
       
   410 		SetCurrentId(aPosition,ButtonByIndex(aPosition)->PopCommandFromStack());
       
   411 		}
       
   412 	else
       
   413 		{
       
   414 		ButtonByIndex(aPosition)->RemoveCommandFromStack(aCommandId);
       
   415 		}
       
   416 	}
       
   417 
       
   418 TInt CEikToolBar::CurrentId(TInt aPosition) const
       
   419 	{
       
   420 	return CONST_CAST(CEikToolBar*,this)->GroupControlByIndex(IndexFromPosition(aPosition)).iId;
       
   421 	}
       
   422 
       
   423 void CEikToolBar::SetCurrentId(TInt aPosition,TInt aId)
       
   424 	{
       
   425 	GroupControlByIndex(IndexFromPosition(aPosition)).iId=aId;
       
   426 	}
       
   427 
       
   428 TInt CEikToolBar::IndexFromPosition(TInt aPos) const
       
   429 	{
       
   430 	const TInt count=iControlArray->Count();
       
   431 	for (TInt ii=0;ii<count;ii++)
       
   432 		{
       
   433 		if (ControlIsButton(ii))
       
   434 			{
       
   435 			if (aPos==0)
       
   436 				return ii;
       
   437 			else
       
   438 				--aPos;
       
   439 			}
       
   440 		}
       
   441 	return KErrNotFound;
       
   442 	}
       
   443 
       
   444 TEikGroupControl& CEikToolBar::GroupControlByIndex(TInt aIndex) const
       
   445 	{
       
   446 	return (*(ControlArray()))[aIndex];
       
   447 	}
       
   448 
       
   449 CEikCommandButton* CEikToolBar::ButtonByIndex(TInt aIndex) const
       
   450 	{
       
   451 	const TInt index=IndexFromPosition(aIndex);
       
   452 	if (index==KErrNotFound)
       
   453 		return NULL;
       
   454 	return STATIC_CAST(CEikCommandButton*,Control(index));
       
   455 	}
       
   456 
       
   457 TInt CEikToolBar::CommandPos(TInt aCommandId) const
       
   458 	{ // !!! does this need a sensible implementation?
       
   459 	const TInt ctrlIndex=IndexById(aCommandId);
       
   460 	TInt pos=KErrNotFound;
       
   461 	if (ctrlIndex!=KErrNotFound)
       
   462 		{
       
   463 		for (TInt ii=0;ii<=ctrlIndex;ii++)
       
   464 			if (ControlIsButton(ii))
       
   465 				++pos;
       
   466 		}
       
   467 	return pos;
       
   468 	}
       
   469 
       
   470 void CEikToolBar::DimCommand(TInt aCommandId,TBool aDimmed)
       
   471 	{
       
   472 	// !!! may want an overload that allows drawing as whole toolbar redraws will flicker
       
   473 	CCoeControl* ctrl=ControlById(aCommandId);
       
   474 	// __ASSERT_ALWAYS(ctrl,Panic(........
       
   475 	ctrl->SetDimmed(aDimmed);
       
   476 	}
       
   477 
       
   478 TBool CEikToolBar::IsCommandDimmed(TInt aCommandId) const
       
   479 	{
       
   480 	CCoeControl* ctrl=ControlById(aCommandId);
       
   481 	// __ASSERT_ALWAYS(ctrl,Panic(........
       
   482 	return ctrl->IsDimmed();
       
   483 	}
       
   484 
       
   485 CCoeControl* CEikToolBar::AsControl()
       
   486 	{
       
   487 	return this;
       
   488 	}
       
   489 
       
   490 const CCoeControl* CEikToolBar::AsControl() const
       
   491 	{
       
   492 	return this;
       
   493 	}
       
   494 
       
   495 void CEikToolBar::MakeCommandVisible(TInt aCommandId,TBool aVisible)
       
   496 	{
       
   497 	CCoeControl* ctrl=ControlById(aCommandId);
       
   498 	// __ASSERT_ALWAYS(ctrl,Panic(........
       
   499 	ctrl->MakeVisible(aVisible);
       
   500 	}
       
   501 
       
   502 TBool CEikToolBar::IsCommandVisible(TInt aCommandId) const
       
   503 	{
       
   504 	CCoeControl* ctrl=ControlById(aCommandId);
       
   505 	// __ASSERT_ALWAYS(ctrl,Panic(........
       
   506 	return ctrl->IsVisible();
       
   507 	}
       
   508 
       
   509 CCoeControl* CEikToolBar::GroupControlById(TInt aCommandId) const
       
   510 	{
       
   511 	return ControlById(aCommandId);
       
   512 	}
       
   513 
       
   514 CEikCommandButton* CEikToolBar::GroupControlAsButton(TInt aCommandId) const
       
   515 	{
       
   516 	CEikCommandButton* ret=NULL;
       
   517 	const TInt index=IndexById(aCommandId);
       
   518 	if (index!=KErrNotFound && ControlIsButton(index))
       
   519 		ret=STATIC_CAST(CEikCommandButton*,ControlById(aCommandId));
       
   520 	return ret;
       
   521 	}
       
   522 
       
   523 TInt CEikToolBar::CommandId(TInt aCommandPos) const
       
   524 	{
       
   525 	return CurrentId(aCommandPos);
       
   526 	}
       
   527 
       
   528 TInt CEikToolBar::ButtonCount() const
       
   529 	{
       
   530 	TInt numButtons=0;
       
   531 	const TInt ctrlCount=iControlArray->Count();
       
   532 	for (TInt ii=0;ii<ctrlCount;ii++)
       
   533 		{
       
   534 		if (ControlIsButton(ii))
       
   535 			++numButtons;
       
   536 		}
       
   537 	return numButtons;
       
   538 	}
       
   539 
       
   540 TUint CEikToolBar::ButtonGroupFlags() const
       
   541 	{
       
   542 	if (DelayActivation())
       
   543 		return CEikButtonGroupContainer::EDelayActivation;
       
   544 	return 0;
       
   545 	}