Exemple #1
0
void ToolbarDlg::ShowToolbarList()
{
	if (!WindowID)
		return;

	// set the custom list gadget 
	CCustomList* pListGadget = CCustomList::GetGadget(GetReadWriteWindowID(), _R(IDC_BARLIST));
	if(!pListGadget)
	{
		ERROR2RAW("No list gadget");
		return;
	}
	pListGadget->SetColumnWidth(0,GetSystemMetrics(SM_CXMENUCHECK) + 10);

	CMainFrame* pFrame = GetMainFrame();
	ERROR3IF(pFrame == NULL, "Can't find Main Frame in ShowToolBarList");

	if(pFrame->IsChangingViewMode())
		return ;

	// Fetch the names and states of all defined bars...
	List* pBarList = MessageHandler::GetClassList(CC_RUNTIME_CLASS(DialogBarOp));
	ENSURE(pBarList,"Can't find list of DialogBarOps in ShowToolBarList");

	// Delete any existing list items...
	pListGadget->DeleteAllItems();

	// Add names of all bars to the list...
	// First do the infobar...
	pListGadget->AddItem(InfoBarName);
	pListGadget->SetSwitchState(InformationBarOp::IsVisible(), (pListGadget->GetItemCount() - 1), 0);

	// Scan the list of all barops and add the names of those which should be shown
	// to the user to the scrollable list.
	DialogBarOp* pBar = (DialogBarOp*)pBarList->GetHead();
	
	BOOL FoundControlBank = FALSE;
	BOOL ControlBankVisible = FALSE;
	while (pBar)
	{
		// Show any bar that's NOT a system bar and NOT an information bar
		// and NOT a Super Gallery put the Controlbank at the end
		if ( IS_A(pBar,DialogBarOp) )
		{
			// Put its name in the list
			String_32 BarName = pBar->GetName();
			if (BarName != ControlBankName)
			{	
				pListGadget->AddItem(BarName);
				pListGadget->SetSwitchState(pBar->IsVisible(), (pListGadget->GetItemCount() - 1), 0);
			}
			else
			{
				FoundControlBank = TRUE;
				ControlBankVisible = pBar->IsVisible();
			}
		}
		pBar = (DialogBarOp*)pBarList->GetNext(pBar);
	}
	
	if (FoundControlBank)
	{
		pListGadget->AddItem(ControlBankName);
		pListGadget->SetSwitchState(ControlBankVisible, (pListGadget->GetItemCount() - 1), 0);
	}
}