Beispiel #1
0
wxGISAcceleratorTable::wxGISAcceleratorTable(IApplication* pApp, IGISConfig* pConf) : bHasChanges(true)
{
	m_AccelEntryArray.reserve(20);
	m_pConf = pConf;

	wxXmlNode* pAcceleratorsNodeCU = m_pConf->GetConfigNode(enumGISHKCU, wxString(wxT("accelerators")));
	wxXmlNode* pAcceleratorsNodeLM = m_pConf->GetConfigNode(enumGISHKLM, wxString(wxT("accelerators")));
	//merge two tables
	m_pApp = pApp;
	if(!pApp)
		return;

	//merge acc tables
	//if user delete key - it must be mark as deleted to avoid adding it fron LM table

	if(pAcceleratorsNodeCU)
	{
		wxXmlNode *child = pAcceleratorsNodeCU->GetChildren();
		while(child)
		{
			wxString sCmdName = child->GetPropVal(wxT("cmd_name"), NON);
			unsigned char nSubtype = wxAtoi(child->GetPropVal(wxT("subtype"), wxT("0")));
			ICommand* pCmd = m_pApp->GetCommand(sCmdName, nSubtype);
			if(pCmd)
			{
				wxString sFlags = child->GetPropVal(wxT("flags"), wxT("NORMAL"));
				WXDWORD Flags = GetFlags(sFlags);
				wxString sKey = child->GetPropVal(wxT("keycode"), wxT("A"));
				int nKey = GetKeyCode(sKey);
				Add(wxAcceleratorEntry(Flags, nKey, pCmd->GetID()));
			}
			child = child->GetNext();
		}
	}
	if(pAcceleratorsNodeLM)
	{
		wxXmlNode *child = pAcceleratorsNodeLM->GetChildren();
		while(child)
		{
			wxString sCmdName = child->GetPropVal(wxT("cmd_name"), NON);
			unsigned char nSubtype = wxAtoi(child->GetPropVal(wxT("subtype"), wxT("0")));
			ICommand* pCmd = m_pApp->GetCommand(sCmdName, nSubtype);
			if(pCmd)
			{
				wxString sFlags = child->GetPropVal(wxT("flags"), wxT("NORMAL"));
				WXDWORD Flags = GetFlags(sFlags);
				wxString sKey = child->GetPropVal(wxT("keycode"), wxT("A"));
				int nKey = GetKeyCode(sKey);
				Add(wxAcceleratorEntry(Flags, nKey, pCmd->GetID()));
			}
			child = child->GetNext();
		}
	}
}
Beispiel #2
0
void wxGISToolBar::Serialize(IApplication* pApp, wxXmlNode* pNode, bool bStore)
{
	if(bStore)
	{
		pNode->AddProperty(wxT("size"), wxString::Format(wxT("%u"), GetToolBitmapSize().GetWidth()));
		pNode->AddProperty(wxT("LeftDockable"), m_bLDock == true ? wxT("t") : wxT("f"));
		pNode->AddProperty(wxT("RightDockable"), m_bRDock == true ? wxT("t") : wxT("f"));
		wxGISCommandBar::Serialize(pApp, pNode, bStore);
	}
	else
	{
		m_bLDock = pNode->GetPropVal(wxT("LeftDockable"), wxT("f")) == wxT("f") ? false : true;
		m_bRDock = pNode->GetPropVal(wxT("RightDockable"), wxT("f")) == wxT("f") ? false : true;
		short iSize = wxAtoi(pNode->GetPropVal(wxT("size"), wxT("16")));
		SetToolBitmapSize(wxSize(iSize,iSize));

		wxAuiToolBarItemArray prepend_items;
		wxAuiToolBarItemArray append_items;
		ICommand* pCmd = pApp->GetCommand(wxT("wxGISCommonCmd"), 2);
		if(pCmd)
		{				
			wxAuiToolBarItem item;
			item.SetKind(wxITEM_SEPARATOR);
			append_items.Add(item);
			item.SetKind(pCmd->GetKind());
			item.SetId(pCmd->GetID());
			item.SetLabel(pCmd->GetCaption());
			append_items.Add(item);
		}
		SetCustomOverflowItems(prepend_items, append_items);
		wxGISCommandBar::Serialize(pApp, pNode, bStore);
		Realize();
	}
}