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

📄 diagrameditor.cpp

📁 So you wanted to add a forms editor to your application? A dialog editor? Something that allows draw
💻 CPP
📖 第 1 页 / 共 5 页
字号:

	Return :		void
	Parameters :	const CSize& size	-	New virtual size.
					
	Usage :			The virtual page of the editor is the 
					'paper' where the user can draw. This 
					function marks the data as changed.

   ============================================================*/
{

	ASSERT( m_objs );
	SetInternalVirtualSize( size );
	m_objs->SetModified( TRUE );

}

void CDiagramEditor::SetInternalVirtualSize( const CSize& size )
/* ============================================================
	Function :		CDiagramEditor::SetInternalVirtualSize
	Description :	Changes the virtual page size without 
					setting the data as modified.
	Access :		Private

	Return :		void
	Parameters :	const CSize& size	-	New virtual size.
					
	Usage :			Internal function. 

   ============================================================*/
{
	if( m_objs && size != GetVirtualSize() )
	{

		m_objs->SetVirtualSize( size );

		SetupScrollbars();
		if( m_hWnd )
			RedrawWindow();

	}

}

CSize CDiagramEditor::GetVirtualSize() const
/* ============================================================
	Function :		CDiagramEditor::GetVirtualSize
	Description :	Returns the virtual size of the editor.
	Access :		Public

	Return :		CSize	-	The current virtual size.
	Parameters :	none

	Usage :			The virtual page of the editor is the 
					'paper' where the user can draw. 

   ============================================================*/
{

	CRect rect( 0, 0, 0, 0 );
	if( m_hWnd )
		GetClientRect( &rect );
	CSize size( CSize( 0, 0 ) );

	if( m_objs )
		size = m_objs->GetVirtualSize();

	if( size.cx == 0 )
		size.cx = rect.right;
	if( size.cy == 0 )
		size.cy = rect.bottom;

	return size;

}

void CDiagramEditor::SetBackgroundColor( COLORREF col )
/* ============================================================
	Function :		CDiagramEditor::SetBackgroundColor
	Description :	Sets the background color.
	Access :		Public

	Return :		void
	Parameters :	COLORREF col	-	New background color 
										to set.
					
	Usage :			The background is the virtual area of the 
					editor (might both be smaller or bigger 
					than the client rect).

   ============================================================*/
{

	m_bkgndCol = col;
	if( m_hWnd )
		RedrawWindow();

}

void CDiagramEditor::SetNonClientColor( COLORREF col )
/* ============================================================
	Function :		CDiagramEditor::SetNonClientColor
	Description :	Sets the non-client area color.
	Access :		Public

	Return :		void
	Parameters :	COLORREF col	-	New non-client area 
										color.
					
	Usage :			The non-client color is the color of the 
					area outside the virtual page.

   ============================================================*/
{

	m_nonClientBkgndCol = col;
	if( m_hWnd )
		RedrawWindow();

}

void CDiagramEditor::ShowGrid( BOOL grid )
/* ============================================================
	Function :		CDiagramEditor::ShowGrid
	Description :	Sets grid visibility.
	Access :		Public

	Return :		void
	Parameters :	BOOL grid	-	"TRUE" to show the grid, "FALSE" 
									to hide.
					
	Usage :			If the grid is visible, it will be drawn 
					using the grid pen style and color. The 
					grid lines will not be scaled with the 
					zoom (the space between them will of 
					course be, however)

   ============================================================*/
{

	m_grid = grid;
	if( m_hWnd )
		RedrawWindow();

}

BOOL CDiagramEditor::IsGridVisible() const
/* ============================================================
	Function :		CDiagramEditor::IsGridVisible
	Description :	Returns the visibility state of the grid.
	Access :		Public

	Return :		BOOL	-	"TRUE" if grid is visible.
	Parameters :	none

	Usage :			If the grid is visible, it will be drawn 
					using the grid pen style and color. The 
					grid lines will not be scaled with the 
					zoom (the space between them will of 
					course be, however)

   ============================================================*/
{

	return m_grid;

}

void CDiagramEditor::SetGridColor( COLORREF col )
/* ============================================================
	Function :		CDiagramEditor::SetGridColor
	Description :	Sets a new grid pen color.
	Access :		Public

	Return :		void
	Parameters :	COLORREF col	-	New grid pen color.
					
	Usage :			If the grid is visible, it will be drawn 
					using the grid pen style and color. The 
					grid lines will not be scaled with the 
					zoom (the space between them will of 
					course be, however)

   ============================================================*/
{

	m_gridCol = col;
	if( m_hWnd )
		RedrawWindow();

}

COLORREF CDiagramEditor::GetGridColor() const
/* ============================================================
	Function :		CDiagramEditor::GetGridColor
	Description :	Returns the current grid pen color.
	Access :		Public

	Return :		COLORREF	-	The current grid color.
	Parameters :	none

	Usage :			If the grid is visible, it will be drawn 
					using the grid pen style and color. The 
					grid lines will not be scaled with the 
					zoom (the space between them will of 
					course be, however)

   ============================================================*/
{

	return m_gridCol;

}

void CDiagramEditor::SetGridSize( CSize size )
/* ============================================================
	Function :		CDiagramEditor::SetGridSize
	Description :	Sets a new grid size.
	Access :		Public

	Return :		void
	Parameters :	CSize size	-	The new grid size.
					
	Usage :			If snap to grid is on, added, moved and 
					resized objects snap to the closest grid 
					position. If the background is resized, it 
					will also snap to the grid.

   ============================================================*/
{

	m_gridSize = size;
	if( m_hWnd )
		RedrawWindow();

}

CSize CDiagramEditor::GetGridSize() const
/* ============================================================
	Function :		CDiagramEditor::GetGridSize
	Description :	Gets the current grid size.
	Access :		Public

	Return :		CSize	-	The current grid size.
	Parameters :	none

	Usage :			If snap to grid is on, added, moved and 
					resized objects snap to the closest grid 
					position. If the background is resized, it 
					will also snap to the grid.

   ============================================================*/
{

	return m_gridSize;

}

void CDiagramEditor::SetGridPenStyle( int style )
/* ============================================================
	Function :		CDiagramEditor::SetGridPenStyle
	Description :	Sets the new grid pen style.
	Access :		Public

	Return :		void
	Parameters :	int style	-	The new pen style, one of 
									the style constants for 
									"CreatePen".
					
	Usage :			The grid (if visible) is drawn with a pen 
					created with the grid pen style. The grid 
					lines will not be scaled with the zoom 
					(the space between them will of course be, 
					however)

   ============================================================*/
{

	m_gridStyle = style;
	if( m_hWnd )
		RedrawWindow();

}

int CDiagramEditor::GetGridPenStyle() const
/* ============================================================
	Function :		CDiagramEditor::GetGridPenStyle
	Description :	Returns the pen style for the grid.
	Access :		Public

	Return :		int		-	The pen style, one of the style 
								constants for "CreatePen".
	Parameters :	none

	Usage :			The grid (if visible) is drawn with a pen 
					created with the grid pen style. The grid 
					lines will not be scaled with the zoom 
					(the space between them will of course be, 
					however)

   ============================================================*/
{

	return m_gridStyle;

}

void CDiagramEditor::SetSnapToGrid( BOOL snap )
/* ============================================================
	Function :		CDiagramEditor::SetSnapToGrid
	Description :	Enable/disable snap to grid.
	Access :		Public

	Return :		void
	Parameters :	BOOL snap	-	"TRUE" if objects should 
									snap to grid.
					
	Usage :			If snap to grid is on, added, moved and 
					resized objects snap to the closest grid 
					position. If the background is resized, it 
					will also snap to the grid.

   ============================================================*/
{

	m_snap = snap;

}

BOOL CDiagramEditor::GetSnapToGrid() const
/* ============================================================
	Function :		CDiagramEditor::GetSnapToGrid
	Description :	Gets the state of the snap-to-grid state.
	Access :		Public

	Return :		BOOL	-	"TRUE" if snap is on.
	Parameters :	none

	Usage :			If snap to grid is on, added, moved and 
					resized objects snap to the closest grid 
					position. If the background is resized, it 
					will also snap to the grid.

   ============================================================*/
{

	return m_snap;

}

void CDiagramEditor::SetResize( BOOL bgresize )
/* ============================================================
	Function :		CDiagramEditor::SetResize
	Description :	Enables/disables background resizing.
	Access :		Public

	Return :		void
	Parameters :	BOOL bgresize	-	"TRUE" if background 
										resizing is enabled.
					
	Usage :			If background resizing is enabled and the 
					user clicks between the resize zone value 
					and the virtual edge, the background is 
					displayed as selected.

   ============================================================*/
{

	m_bgResize = bgresize;

}

BOOL CDiagramEditor::GetResize() const
/* ============================================================
	Function :		CDiagramEditor::GetResize
	Description :	Returns the state of the background resize
					flag.
	Access :		Public

	Return :		BOOL	-	"TRUE" if background resizing is 
								enabled.
	Parameters :	none

	Usage :			If background resizing is enabled and the 
					user clicks between the resize zone value 
					and the virtual edge, the background is 
					displayed as selected.

   ============================================================*/
{

	return m_bgResize;

}

void CDiagramEditor::SetResizeZone( int bgresizezone )
/* ============================================================
	Function :		CDiagramEditor::SetResizeZone
	Description :	Sets a new resize zone for the editor.
	Access :		Public

	Return :		void
	Parameters :	int bgresizezone	-	New resize width.
					
	Usage :			If background resizing is enabled and the 
					user clicks between the resize zone value 
					and the virtual edge, the background is 
					displayed as selected.

   ============================================================*/
{

	m_bgResizeZone = bgresizezone;

}

int CDiagramEditor::GetResizeZone() const
/* ============================================================
	Function :		CDiagramEditor::GetResizeZone
	Description :	Returns the current resize zone.
	Access :		Public

	Return :		int		-	The resize zone in pixels.
	Parameters :	none

	Usage :			If background resizing is enabled and the 
					user clicks between the resize zone value 
					and the virtual edge, the background is 
					displayed as selected.

   ============================================================*/
{

	return m_bgResizeZone;

}

void CDiagramEditor::SetMargins( int left, int top, int right, int bottom )
/* ============================================================
	Function :		CDiagramEditor::SetMargins
	Description :	Sets margins for the virtual screen.
	Access :		Public

	Return :		void
	Parameters :	int left	-	New left margin.
					int top		-	New top margin.
					int right	-	New right margin.
					int bottom	-	New bottom margin.
					
	Usage :			Call to set new margins for the editor.

   ============================================================*/
{

	m_leftMargin = left;
	m_topMargin = top;
	m_rightMargin = right;
	m_bottomMargin = bottom;

}

void CDiagramEditor::GetMargins( int& left, int& top, int& right, int& bottom ) const
/* ============================================================
	Function :		CDiagramEditor::GetMargins
	Description :	Return the current margin.
	Access :		Public

⌨️ 快捷键说明

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