// RcApOpenToolbar.h : Declaration of the CRcApOpenToolbar
/**
This example demonstrates how to create command for execution from the script.

Command is registered into system command factory by describing it in CRsCmdFactory::EnumCommandDesc and by 
creating it in CRsCmdFactory::CreateInstance when requested. 

After command is added it can be created using it's ID from every package using IRsSysFactory or from script. 

*/
#pragma once
#include "resource.h"



// IRcApOpenToolbar
[
	object,
	uuid("7ACB827C-BA2C-41ff-9257-AEE546841547"),
	helpstring("IRnWidgetExample Interface"),
	pointer_default(unique)
]
__interface IRcApOpenToolbar : IUnknown
{
};

// CRcApOpenToolbar
class ATL_NO_VTABLE CRcApOpenToolbar : 
    public CComObjectRootEx<CComGlobalsThreadModel>,
    public IRsUnknownNode,
    public IRsCommand,
	public IRcApOpenToolbar
{
private:
    CComPtr<IUnknown> m_spUnkAgg;

public:


    CRcApOpenToolbar()
	{
	}

	HRESULT FinalConstruct();
	
	void FinalRelease() 
	{
        m_spUnkAgg.Release();
	}

	STDMETHOD(Execute)(void);
    STDMETHOD(Undo)(void);
    STDMETHOD(Redo)(void);
    STDMETHOD(HasUndo)(RtBool* isUndoable);
    STDMETHOD(OnGetValue)(CONID con_id, IRsDataCache* pDataCache, VARIANT* pVtData, RtBool* pHandled);
    STDMETHOD(OnSetValue)(CONID con_id, IRsDataCache* pDataCache, VARIANT* pvtData, RtBool* pHandled);
    STDMETHOD(OnDefaultValue)(CONID con_id, VARIANT* pVtData, RtBool* pHandled);
    STDMETHOD(OnInvalidate)(CONID con_id, RtBool* pHandled);
    STDMETHOD(OnInitialize)(void);
    STDMETHOD(OnLoadDefault)(void);
    STDMETHOD(OnDestroy)(void);

    // IRsObject
    RS_DECLARE_IRS_OBJECT(IRcApOpenToolbar, L"ApOpenToolbar")

    BEGIN_COM_MAP(CRcApOpenToolbar)
        COM_INTERFACE_ENTRY(IRcApOpenToolbar)
        COM_INTERFACE_ENTRY(IRsUnknownNode)
        COM_INTERFACE_ENTRY(IRsCommand)
        COM_INTERFACE_ENTRY2(IUnknown, IRsUnknownNode)
        COM_INTERFACE_ENTRY2(IRsObject, IRsUnknownNode)
        COM_INTERFACE_ENTRY_AGGREGATE(DEF_GUIDNAME(IRsBaseNode), m_spUnkAgg.p)
        COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_spUnkAgg.p)    // Just for safety, the speed is slower only for unknown interfaces
    END_COM_MAP()

    DECLARE_GET_CONTROLLING_UNKNOWN()
    DECLARE_PROTECT_FINAL_CONSTRUCT()

	// position toolbar
	HRESULT SnapToolbarToActiveWindow(IRnFrameWindow* pToolbarFrame, IRnFrameWindow* pActiveFrame);
};
