Esempio n. 1
0
// @pymethod |PyCWinApp|AddDocTemplate|Adds a template to the application list.
static PyObject *
ui_app_add_doc_template(PyObject *self, PyObject *args)
{
	PyObject *obTemplate;
	if (!PyArg_ParseTuple(args,"O:AddDocTemplate",
	                      &obTemplate))     // @pyparm <o PyCDocTemplate>|template||The template to be added.
		return NULL;

	if (!ui_base_class::is_uiobject(obTemplate, &PyCDocTemplate::type))
		RETURN_TYPE_ERR("The parameter must be a template object");

	CDocTemplate *pTempl = PyCDocTemplate::GetTemplate(obTemplate);
	if (pTempl==NULL)
		return NULL;
	CWinApp *pApp = GetApp();
	if (!pApp) return NULL;
	// walk all templates in the application looking for it.
	CDocTemplate* pTemplate;
	POSITION pos = pApp->m_pDocManager ? pApp->m_pDocManager->GetFirstDocTemplatePosition() : NULL;
	while (pos != NULL) {
		pTemplate = pApp->m_pDocManager->GetNextDocTemplate(pos);
		if (pTemplate==pTempl)
			RETURN_ERR("The template is already in the application list");
	}
	GUI_BGN_SAVE;
	pApp->AddDocTemplate(pTempl);
	GUI_END_SAVE;
	RETURN_NONE;
}
//---------------------------------------------------------------------
// Function:	Initialize
// Description:	Initialization like InitInstace
// Parameters:	.
// Returns:		TRUE, if successful
//---------------------------------------------------------------------
BOOL CObjectTexture::Initialize()
{
	CString tName;
	HINSTANCE appInst;
	CMDIFrameWnd *mainWnd;
		
	// Register the doc templates we provide to the app
	CWinApp* pApp = AfxGetApp();
	ASSERT(pApp != NULL);
    if (pApp == NULL)
    {
        return FALSE;
    }

	mainWnd = DYNAMIC_DOWNCAST(CMDIFrameWnd, pApp->m_pMainWnd);

	// get the apps instance handle for loading resources
	appInst = AfxGetResourceHandle();
	// now tell the application to look in dll for resources
	AfxSetResourceHandle(ObjectTextureDLL.hModule);

	// use my string / icon resources
	// *** note IDR_TEXTURE type needs to be unique ID even between
	// dlls
	m_DocTemplate = new CMultiDocTemplate(IDR_TEXTURETYPE,
			RUNTIME_CLASS(CTextureDoc),
			RUNTIME_CLASS(CMDIChildWnd),
			RUNTIME_CLASS(CTextureView));

	pApp->AddDocTemplate(m_DocTemplate);

	VERIFY(MergeMenus(&m_DocTemplate->m_hMenuShared, *(m_ProgramInfo->curMenu), _T("&Window")));	
	VERIFY(MergeAccelerators(&m_DocTemplate->m_hAccelTable, *(m_ProgramInfo->curAccel)));

	// Initialze the image library
	ilInit();
	iluInit();
	ilutInit();

	// construct resource info
	m_ObjInfo.name.LoadString(IDS_OBJECT_NAME);
	m_ObjInfo.pageIndex = &m_PageIndex;

	m_ObjInfo.icon = (HICON)LoadImage(ObjectTextureDLL.hModule, MAKEINTRESOURCE(IDR_TEXTURETYPE), 
		IMAGE_ICON, 0, 0, LR_CREATEDIBSECTION);
	VERIFY(m_ObjInfo.icon != NULL);

	// value should be 1 - 1000
	m_ObjInfo.priority = IDR_TEXTURETYPE;
	m_ObjInfo.objFlags = OBJFLAGS_EXPORTABLE |
		OBJFLAGS_IMPORTABLE | OBJFLAGS_THUMBNAIL;

	AfxSetResourceHandle(appInst);

    return TRUE;

}
//---------------------------------------------------------------------
// Function:	Initialize
// Description:	DLL's Initialization function, like InitInstance
// Parameters:	.
// Returns:		TRUE, if successful.
//---------------------------------------------------------------------
BOOL CStateMachineEditor::Initialize()
{
	CString tName;
	HINSTANCE appInst;
		
	// Register the doc templates we provide to the app
	CWinApp* pApp = AfxGetApp();
	ASSERT(pApp != NULL);
    if (pApp == NULL)
    {
        return FALSE;
    }

	// get the apps instance handle for loading resources
	appInst = AfxGetResourceHandle();
	// now tell the application to look in dll for resources
	AfxSetResourceHandle(StateMachineEditorDLL.hModule);

	// use my string / icon resources
	// Note IDR_EXAMPLETYPE has to be a unique id even between DLLS
	// to get the ICONS right on the Window
	m_DocTemplate = new CMultiDocTemplate(IDR_STATEMACHINETYPE,
			RUNTIME_CLASS(CStateMachineEditorDoc),
			RUNTIME_CLASS(CStateMachineEditorFrm),
			RUNTIME_CLASS(CStateMachineEditorView));

	//// put this after setting the menu and accelerators so it won't allocate it's own
	pApp->AddDocTemplate(m_DocTemplate);

	// construct resource info
	m_ObjCollection.name.LoadString(IDS_RESOURCE_NAME);
	m_ObjCollection.pageIndex = &m_PageIndex;

	m_ObjCollection.hIcon = (HICON)LoadImage(StateMachineEditorDLL.hModule, MAKEINTRESOURCE(IDR_STATEMACHINETYPE), 
		IMAGE_ICON, 0, 0, LR_CREATEDIBSECTION);
	VERIFY(m_ObjCollection.hIcon != NULL);

	// value should be 1 - 1000
	m_ObjCollection.priority = IDR_STATEMACHINETYPE;
	m_ObjCollection.extensions = STATEMACHINE_EXTENSIONS;

	AfxSetResourceHandle(appInst);

    return TRUE;
}
BOOL CParticleEditor::Initialize( )
{
	CWinApp* pApp = AfxGetApp();
	ASSERT(pApp != NULL);
    if (pApp == NULL)
    {
        return FALSE;
    }

	// get the apps instance handle for loading resources
	m_AppInst = AfxGetResourceHandle();

	//Direct the application to look in dll for resources
	AfxSetResourceHandle(ParticleEditorDLL.hModule);

	// use my string / icon resources
	// Note IDR_EXAMPLETYPE has to be a unique id even between DLLS
	// to get the ICONS right on the Window
	m_DocTemplate = new CMultiDocTemplate(IDR_PARTICLETYPE,
			RUNTIME_CLASS(CParticleDoc),
			RUNTIME_CLASS(CParticleFrame),
			RUNTIME_CLASS(CParticleRenderView));

	// put this after setting the menu and accelerators so it won't allocate it's own
	pApp->AddDocTemplate(m_DocTemplate);

	// construct resource info
	m_ObjCollection.name.LoadString(IDS_RESOURCE_NAME);
	m_ObjCollection.pageIndex = &m_PageIndex;

	m_ObjCollection.hIcon = (HICON)LoadImage(ParticleEditorDLL.hModule, MAKEINTRESOURCE(IDR_PARTICLETYPE), 
		IMAGE_ICON, 0, 0, LR_CREATEDIBSECTION);
	VERIFY(m_ObjCollection.hIcon != NULL);

	// value should be 1 - 1000
	// NOTE: Against convention this was set at coding to 31000 even the example is set at 5000
	m_ObjCollection.priority = IDR_PARTICLETYPE; 
    m_ObjCollection.extensions = PARTICLE_EXTENSIONS;
    AfxSetResourceHandle(m_AppInst);

	return TRUE;
}
Esempio n. 5
0
// register plugin document templates
PLUGIN_EXPORT void PIRegisterDocTemplates()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CPluginSupportApp* pApp = (CPluginSupportApp*)AfxGetApp();
	CWinApp* pMainApp = pApp->GetMainApp();

	const PluginArray& array = pApp->GetPluginArray();
	for (int i=0; i<array.GetSize(); i++)
	{
		CPluginWrapper* pPluginWrapper = array.GetAt(i);
		for (int j = 0; j < pPluginWrapper->GetDocTemplateCount(); j++)
		{
			CDocTemplate* pDocTemplate = pPluginWrapper->GetDocTemplate(j);
			// plugin said it had one, but didn't supply it
			ASSERT(pDocTemplate);
			pMainApp->AddDocTemplate(pDocTemplate);
		}
	}
}