⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 3D游戏场景编辑器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
// Called by: OnCreate()
// Calls: 
// Parameters:
// Returns:	
// Purpose: 
//==========================================================================================
BOOL CMainFrame::CreateBrushToolBar()
{
	char		szBuffer[MAX_TAB_NAME_LENGTH] ;
	HINSTANCE	hResources ;

	hResources = AfxGetResourceHandle() ;
							  
	if (!m_wndBrushToolBar.CreateEx(this,TBSTYLE_FLAT, WS_CHILD|WS_VISIBLE|CBRS_TOP|
			CBRS_GRIPPER | CBRS_TOOLTIPS|CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndBrushToolBar.LoadToolBar(IDR_BRUSHTOOLS) )
	{
		TRACE0("Failed to create stylebar\n");
		return FALSE;       // fail to create
	}
								//	set the font using global font var
	m_wndBrushToolBar.SetFont(&CGlobals::m_ControlBarFont);

								// Assign a title to bar
	::LoadString( hResources, IDS_TOOLBAR_BRUSH, szBuffer, sizeof szBuffer ) ;
	m_wndBrushToolBar.SetWindowText( szBuffer ) ;
	
								//	set button text for the brush toolbar
/*	m_wndBrushToolBar.SetButtonText(0, _T ("Camera"));
	m_wndBrushToolBar.SetButtonText(1, _T ("Brush"));
	m_wndBrushToolBar.SetButtonText(2, _T ("Template"));
	m_wndBrushToolBar.SetButtonText(4, _T ("Move"));
	m_wndBrushToolBar.SetButtonText(5, _T ("Rotate"));
	m_wndBrushToolBar.SetButtonText(6, _T ("Resize"));
	m_wndBrushToolBar.SetButtonText(7, _T ("Shear"));
	m_wndBrushToolBar.SetButtonText(9, _T ("Rotate45"));	// post 0.57
	m_wndBrushToolBar.SetButtonText(10, _T ("Center"));

	m_wndBrushToolBar.SetSizes(CSize(52,TOOLBAR_HEIGHT), CSize(16,TEXT_HEIGHT));
*/
								//	make it dockabale
	m_wndBrushToolBar.EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndBrushToolBar);	

	return TRUE;
}


//==========================================================================================
// CMainFrame::DockControlBarLeftOf
// Called by: OnCreate()
// Calls: 
// Parameters:
// Returns:	
// Purpose: helps organize the initial layout of the toolbars
//==========================================================================================
void CMainFrame::DockControlBarLeftOf(CToolBar* LeftOf,CToolBar* Bar)
{
	CRect rect;
	DWORD dw;
	UINT n;

	// get MFC to adjust the dimensions of all docked ToolBars
	// so that GetWindowRect will be accurate
	RecalcLayout();
	LeftOf->GetWindowRect(&rect);
	rect.OffsetRect(1,0);
	dw=LeftOf->GetBarStyle();
	n = 0;
	n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
	n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
	n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
	n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;

	// When we take the default parameters on rect, DockControlBar will dock
	// each Toolbar on a seperate line.  By calculating a rectangle, we in effect
	// are simulating a Toolbar being dragged to that location and docked.
	DockControlBar(Bar,n,&rect);
}


//	BEGIN BRUSHGROUP CODE

//==========================================================================================
// CMainFrame::CreateGroupBar
// Called by: OnCreate()
// Calls: 
// Parameters:
// Returns:	
// Purpose: 
//==========================================================================================
BOOL CMainFrame::CreateGroupBar()
{
	char		szBuffer[MAX_TAB_NAME_LENGTH] ;
	HINSTANCE	hResources ;
	CRect		rect;						//	for combobox

	hResources = AfxGetResourceHandle() ;

	if (!m_wndGroupBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD|WS_VISIBLE|CBRS_TOP|
			CBRS_GRIPPER | CBRS_TOOLTIPS|CBRS_FLYBY| CBRS_SIZE_DYNAMIC) ||
		!m_wndGroupBar.LoadToolBar(IDR_GROUPBAR))
	{
		TRACE0("Failed to create groupbar\n");
		return FALSE;       // fail to create
	}
							//	set the font using global font var
	m_wndGroupBar.SetFont(&CGlobals::m_ControlBarFont);

							// Assign a title to bar
	::LoadString( hResources, IDS_TOOLBAR_GROUP, szBuffer, sizeof szBuffer ) ;
	m_wndGroupBar.SetWindowText( szBuffer ) ;
/*
							// set button text for Object toolbar
	m_wndGroupBar.SetButtonText(0, _T ("All"));
	m_wndGroupBar.SetButtonText(1, _T ("Visible"));
	m_wndGroupBar.SetButtonText(2, _T ("Current"));
	m_wndGroupBar.SetButtonText(4, _T ("Add"));
	m_wndGroupBar.SetButtonText(5, _T ("Remove"));
	m_wndGroupBar.SetSizes(CSize(48,TOOLBAR_HEIGHT), CSize(16,TEXT_HEIGHT));
*/
	m_wndGroupBar.SetButtonInfo(6, IDC_GROUPBAR_COMBO, TBBS_SEPARATOR, 110);

							//	Set the dimensions for the length of the dropdown menu
	m_wndGroupBar.GetItemRect(6, &rect);
	rect.top = 3;
	rect.bottom = rect.top + 200;

					//	at position 6 (IDC_GROUPBAR_COMBO).
	if (!m_wndGroupBar.m_comboBox.Create( WS_CHILD |
			CBS_DROPDOWNLIST|CBS_SORT|WS_VISIBLE|WS_TABSTOP,
			rect, &m_wndGroupBar, IDC_GROUPBAR_COMBO))
	{
		TRACE0("Failed to create combo-box\n");
		return FALSE;
	}

	m_wndGroupBar.m_comboBox.SetFont(&CGlobals::m_ControlBarFont);

					//	make it dockabale	
	m_wndGroupBar.EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndGroupBar);

	return TRUE;
}


//==========================================================================================
// CMainFrame::OnGroupbar
// Called by: Menu
// Calls: 
// Parameters:
// Returns:	
// Purpose: shows or hides group bar
//==========================================================================================
void CMainFrame::OnGroupbar() 
{
	CControlBar* pBar = (CControlBar*)&m_wndGroupBar ;

	if( pBar )
	{
		ShowControlBar( pBar, (pBar->GetStyle() & WS_VISIBLE) == 0, FALSE ) ;
	}
}


//==========================================================================================
// CMainFrame::OnSelchangeGroupList
// Called by: MFC Messaging sys
// Calls: 
// Parameters:
// Returns:	
// Purpose: Set current group to the one selected from the groupbar combo box
//==========================================================================================
void CMainFrame::OnSelchangeGroupList ()
{
	pDoc = this->GetCurrentDoc ();
	int CurSel;

	CurSel = m_wndGroupBar.m_comboBox.GetCurSel ();
	if (CurSel != LB_ERR)
	{
		m_GroupsTab.SelectNone();	// deslect all from current group
		pDoc->mCurrentGroup = m_wndGroupBar.m_comboBox.GetItemData (CurSel);
		UpdateMainControls();
		m_GroupsTab.SelectNone();	// deslect all from group we just switched to.	

	}
	pDoc->UpdateAllViews(UAV_ALL3DVIEWS, NULL);
}


//==========================================================================================
// CMainFrame::OnUpdateGroupbar
// Called by: Menu messaging
// Calls: 
// Parameters:
// Returns:	
// Purpose: places or removes check mark next to menu item
//==========================================================================================
void CMainFrame::OnUpdateGroupbar(CCmdUI* pCmdUI) 
{
	
	CControlBar* pBar = (CControlBar*)&m_wndGroupBar ;
	if (pBar != NULL)
    {
		pCmdUI->SetCheck((pBar->GetStyle() & WS_VISIBLE) != 0);
	}
}


//==========================================================================================
// CMainFrame::OnBrushGroupsMakenewgroup
// Called by: Menu Messaging (why is it HERE?)
// Calls: 
// Parameters:
// Returns:	
// Purpose: 
//==========================================================================================
void CMainFrame::OnBrushGroupsMakenewgroup() 
{
	/*
	  Things to do here:
	    1) Get the current document
		2) Create a new group in that document's list
		3) Update the combo box with the group info
		4) Set the document's current group to the newly created group
	*/

	pDoc = this->GetCurrentDoc ();
	if (pDoc != NULL)
	{
		if (pDoc->MakeNewBrushGroup ( this ))
		{
			UpdateMainControls();		
		}
	}

}/* CMainFrame::OnBrushGroupsMakenewgroup */

//	END BRUSHGROUP CODE



//	END TOOLBAR CODE
//	****************************************************************************************
//	BEGIN PROPERTIES PANEL CODE



//=====================================================================================================================
// CMainFrame::CreatePropertiesDailogPanel
// Called by: OnCreate()
// Calls: 
// Parameters: void
// Returns:	BOOL
// Purpose: creates a CDialogBar, then places a CDialog onto that bar for handling
//			Properties controls				
//=====================================================================================================================
BOOL CMainFrame::CreatePropertiesPanel()
{
					//	create the Properties dialog. This will hold
					//	the properties controls for objects.
	if (!m_PropertiesPanel.Create(this, IDD_PROPERTIES_PANEL, CBRS_GRIPPER |
		CBRS_RIGHT|CBRS_TOOLTIPS|CBRS_FLYBY | CBRS_SIZE_DYNAMIC, IDD_PROPERTIES_PANEL))
	{
		TRACE0("Failed to create DlgBar\n");
		return FALSE;	
	}
							//	make it dockabale
	m_PropertiesPanel.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT );
	DockControlBar(&m_PropertiesPanel);

	return TRUE;
}


/*
//==========================================================================================
// CMainFrame::SetupPropBuildDialogControls
// Called by: CGenEditDoc::UpdateSelected() -- after an entity is clicked on in a view
// Calls: 
// Parameters:
// Returns:	
// Purpose: this sets up and displays controls on the properties panel
//==========================================================================================
bool	CMainFrame::SetupPropBuildDialogControls()
{
	return m_dPropBuildDialog.SetupPropControls();
}

*/
//=====================================================================================================================
// CMainFrame::OnPropertiesPanel
// Called by: Menu
// Calls: 
// Parameters: 
// Returns:	void
// Purpose: Menu command to show the panel if it isn't visible
//=====================================================================================================================
void CMainFrame::OnPropertiesPanel() 
{
		CDialogBar* pBar = (CDialogBar*)&m_PropertiesPanel ;

	if( pBar )
	{
		ShowControlBar( pBar, (pBar->GetStyle() & WS_VISIBLE) == 0, FALSE ) ;
	}
}


//=====================================================================================================================
// CMainFrame::HideAllPropDialogsBut
// Called by: the Create template dialogs, Entity, brush and Face dialogs, and Update(here)
// Calls: 
// Parameters: 
// Returns:	bool
// Purpose: prepares the property panel for showing the appropriate dialog
//=====================================================================================================================
bool CMainFrame::HideAllPropDialogsBut(CWnd *pWnd)
{
//	CDialogBar* pBar = (CDialogBar*)&m_PropertiesPanel;	//	post 0.57
//	if( pBar->IsWindowVisible() )
	{
		
		if ((m_dPropBrushAttributesDialog) && (m_dPropBrushAttributesDialog != pWnd))
		{
			m_dPropBrushAttributesDialog->DestroyWindow();
			delete m_dPropBrushAttributesDialog;		//	post 0.57
			m_dPropBrushAttributesDialog = NULL;
		}
		
		if ((m_dPropFaceAttributesDialog) && (m_dPropFaceAttributesDialog != pWnd))
		{
			m_dPropFaceAttributesDialog->DestroyWindow();
			delete m_dPropFaceAttributesDialog;
			m_dPropFaceAttributesDialog = NULL;
		}
		
		if ((m_dPropEntitiesDialog) && (m_dPropEntitiesDialog != pWnd))
		{
			m_dPropEntitiesDialog->DestroyWindow();
			delete m_dPropEntitiesDialog;
			m_dPropEntitiesDialog = NULL;
		}
		
		if (&m_createArchDialog != NULL && &m_createArchDialog != pWnd)
		{
			m_createArchDialog.DestroyWindow();
			m_createArchDialog.m_hWnd = NULL;	//	post 0.57
		}
		
		if (&m_createBoxDialog != NULL && &m_createBoxDialog != pWnd)
		{
			m_createBoxDialog.DestroyWindow();
			m_createBoxDialog.m_hWnd = NULL;	//	post 0.57
		}
		if (&m_createConeDialog != NULL && &m_createConeDialog != pWnd)
		{
			m_createConeDialog.DestroyWindow();
			m_createConeDialog.m_hWnd = NULL;	//	post 0.57
		}
		
		if (&m_createConeDialog!= NULL && &m_createCylDialog != pWnd)
		{
			m_createCylDialog.DestroyWindow();
			m_createCylDialog.m_hWnd = NULL;	//	post 0.57
		}
		
		if (&m_createSpheroidDialog != NULL && &m_createSpheroidDialog != pWnd)
		{
			m_createSpheroidDialog.DestroyWindow();
			m_createSpheroidDialog.m_hWnd = NULL;	//	post 0.57
		}
		
		if (&m_createStaircaseDialog != NULL && &m_createStaircaseDialog != pWnd)
		{
			m_createStaircaseDialog.DestroyWindow();
			m_createStaircaseDialog.m_hWnd = NULL;	//	post 0.57
		}
	}
	
	return true;
}




//=====================================================================================================================
// CMainFrame::OnUpdatePropertiesPanel
// Called by: Menu
// Calls: 
// Parameters: 
// Returns:	
// Purpose: places or removes check mark on the View menu
//=====================================================================================================================
void CMainFrame::OnUpdatePropertiesPanel(CCmdUI* pCmdUI) 
{
	CControlBar* pBar = (CControlBar*)&m_PropertiesPanel ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -