File : API\core\tools\ITool.h Namespace : core::tools
struct tToolInfo { ZPtr<core::tools::ITool> m_pTool; long m_nIndex; bool operator == (const tToolInfo& info) const { return m_pTool == info.m_pTool && m_nIndex == info.m_nIndex; } }; // currently selected tools are stored in form above // and provided as a sequence below. typedef ZSequence<tToolInfo> tToolInfoSeq;
Struct tToolInfo is used to present tools that support multy-tool layout (or implements several tools in one class). Structure includes tool interface pointer and tool ordinal index. If tool does not support multy-tool layout, tool index is set to -1.
Sequences of these structs (tToolInfoSeq) is used to present currently selected tools (IModeler::getToolsSelection).
Tools can inherit from core::layout::IMultyToolLayout interface to have several tools implemented in one class. These are multy-tool layout. When dealing with such a tool, an interface pointer to ITool interfaec is not enough and tool's index required. Before invoking methods of such a tool make sure to set current tool. If you don't invoking tool methods, or even requesting tool title might give you wrong result.
// // code fragment. just an example. //------------------------------------------------------- // @name : CZMToolBar::addTool // This will add a tool (button) into toolbar // @param core::tools::ITool* pTool : tool to add // @param DWORD& dwID : ret-val ID // // @return ZRESULT : //------------------------------------------------------- ZRESULT CZMToolBar::addTool(core::tools::ITool* pTool, DWORD& dwID, long nIndex) { if (NULL == pTool) return ZRESULT_INVALID_ARG; //get title, hint. ZPtr<core::layout::ILayout> pLay; ZPtr<core::INamed> pNamed; ZPtr<core::layout::IMultyToolLayout> pMultyToolLayout; ZString strTitle, strName; pTool->getLayout(&pLay); if (ZRESULT_OK != pTool->QueryInterface(IID_(core::INamed), (void**)&pNamed)) return ZRESULT_FAIL; //multy-tool layout stuff: if (-1 != nIndex && ZRESULT_OK == pLay->QueryInterface( IID_(core::layout::IMultyToolLayout), (void**)&pMultyToolLayout)) pMultyToolLayout->setCurrentTool(nIndex); //localization; pNamed->getTitle(strTitle); pNamed->getName(strName); ... return ZRESULT_OK; }