예제 #1
0
파일: commandbar.cpp 프로젝트: jacklibj/r5
void wxGISToolBar::RemoveCommand(size_t nIndex)
{
	size_t nRealIndex = nIndex;
	//count beforehead controls and check if labels exists
	for(size_t i = 0; i < nIndex; i++)
	{
		if(m_CommandArray[nIndex]->GetKind() == enumGISCommandControl)
		{
			IToolControl* pToolControl = dynamic_cast<IToolControl*>(m_CommandArray[nIndex]);
			if(pToolControl->HasToolLabel())
				nRealIndex++;
		}
	}
	//check if it's control
	if(m_CommandArray[nIndex]->GetKind() == enumGISCommandControl)
	{
		IToolControl* pToolControl = dynamic_cast<IToolControl*>(m_CommandArray[nIndex]);
		if(pToolControl->HasToolLabel())
		{
			DeleteByIndex(nRealIndex);
			DeleteByIndex(nRealIndex);
		}
		else
			DeleteByIndex(nRealIndex);
		wxDELETE(m_RemControlMap[nIndex]);
	}
	else
		DeleteByIndex(nRealIndex);
	wxGISCommandBar::RemoveCommand(nIndex);
	Realize();
}
예제 #2
0
void wxGISToolBar::AddCommand(wxGISCommand* pCmd)
{
	switch(pCmd->GetKind())
	{
	case enumGISCommandMenu:
		return;
	case enumGISCommandSeparator:
	case enumGISCommandCheck:
	case enumGISCommandRadio:
	case enumGISCommandNormal:
		{
		wxBitmap Bitmap = pCmd->GetBitmap();
		if(!Bitmap.IsOk())
			Bitmap = wxBitmap(tool_16_xpm);

		AddTool(pCmd->GetID(), wxStripMenuCodes(pCmd->GetCaption()), Bitmap, wxBitmap(), (wxItemKind)pCmd->GetKind(), pCmd->GetTooltip(), pCmd->GetMessage(), NULL);
		}
		break;
	case enumGISCommandDropDown:
		{
		wxBitmap Bitmap = pCmd->GetBitmap();
		if(!Bitmap.IsOk())
			Bitmap = wxBitmap(tool_16_xpm);

		AddTool(pCmd->GetID(), wxStripMenuCodes(pCmd->GetCaption()), Bitmap, wxBitmap(), (wxItemKind)enumGISCommandNormal, pCmd->GetTooltip(), pCmd->GetMessage(), NULL);
        SetToolDropDown(pCmd->GetID(), true);
		}
		break;
	case enumGISCommandControl:
		{
			IToolControl* pToolCtrl = dynamic_cast<IToolControl*>(pCmd);
			if(pToolCtrl)
			{
				IToolBarControl* pToolBarControl = pToolCtrl->GetControl();
				wxControl* pControl = dynamic_cast<wxControl*>(pToolBarControl);
				if(pControl)
				{
					if(pToolCtrl->HasToolLabel())
					{
						wxString sToolLabel = pToolCtrl->GetToolLabel();
						AddLabel(wxID_ANY, sToolLabel, sToolLabel.Len() * 5);
					}
					pControl->Reparent(this);
					AddControl(pControl);
					//add ctrl to remove map
					m_RemControlMap[m_CommandArray.size()] = pToolBarControl;
				}
				else return;
			}
			else return;
		}
		break;
	default: return;
	}
	wxGISCommandBar::AddCommand(pCmd);
	Realize();
}