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

📄 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 :	int& left	-	Current left margin.
					int& top	-	Current top margin.
					int& right	-	Current right margin.
					int& bottom	-	Current bottom margin.
					
	Usage :			Call to get the margins of the editor.

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

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

}

void CDiagramEditor::SetMarginColor( COLORREF marginColor )
/* ============================================================
	Function :		CDiagramEditor::SetMarginColor
	Description :	Set current margin colors.
	Access :		Public

	Return :		void
	Parameters :	COLORREF marginColor	-	The new color.
					
	Usage :			Call to set the margin color.

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

	m_marginColor = marginColor;

	if( m_hWnd )
		RedrawWindow();

}

COLORREF CDiagramEditor::GetMarginColor() const
/* ============================================================
	Function :		CDiagramEditor::GetMarginColor
	Description :	Returns the current margin colors.
	Access :		Public

	Return :		COLORREF	-	Margin colors.
	Parameters :	none

	Usage :			Call to get the margin color.

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

	return m_marginColor;

}

void CDiagramEditor::ShowMargin( BOOL show )
/* ============================================================
	Function :		CDiagramEditor::ShowMargin
	Description :	Show/hide margins.
	Access :		Public

	Return :		void
	Parameters :	BOOL show	-	"TRUE" to show margins, "FALSE" 
									to hide.
					
	Usage :			Call to show/hide the margins.

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

	m_margin = show;

	if( m_hWnd )
		RedrawWindow();

}

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

	Return :		BOOL	-	"TRUE" if the margins are 
								visible.
	Parameters :	none

	Usage :			Call to se if the margin visibility flag is 
					on.

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

	return m_margin;

}

void CDiagramEditor::SetRestraints( int restraint )
/* ============================================================
	Function :		CDiagramEditor::SetRestraints
	Description :	Sets current restraint mode
	Access :		Public

	Return :		void
	Parameters :	BOOL restraint	-	restraint mode, see Usage 
										below
					
	Usage :			The restraint mode can be one of the 
					following ( defined in DialogEditor.h):
						"RESTRAINT_NONE" No restraints.
						"RESTRAINT_VIRTUAL" No objects can be moved outside the virtual rectangle.
						"RESTRAINT_MARGIN" No objects can be moved outside the background margins.

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

	m_restraint = restraint;

}

int CDiagramEditor::GetRestraints() const
/* ============================================================
	Function :		CDiagramEditor::GetRestraints
	Description :	Returns the current restraint mode.
	Access :		Public

	Return :		int	-	The current restraint mode. See 
							Usage below

	Parameters :	none

	Usage :			The restraint mode can be one of the 
					following ( defined in DialogEditor.h):
						"RESTRAINT_NONE" No restraints.
						"RESTRAINT_VIRTUAL" No objects can be moved outside the virtual rectangle.
						"RESTRAINT_MARGIN" No objects can be moved outside the background margins.

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

	return m_restraint;

}

BOOL CDiagramEditor::GetMultidraw() const
/* ============================================================
	Function :		CDiagramEditor::GetMultidraw
	Description :	Returns the multi draw state
	Access :		Public

	Return :		BOOL	-	"TRUE" if multi draw is set
	Parameters :	none

	Usage :			Multi draw means that the user can continue 
					to add controls after one is placed.

   ============================================================*/
{
	return m_multiDraw;
}

void CDiagramEditor::SetMultidraw( BOOL multidraw )
/* ============================================================
	Function :		CDiagramEditor::SetMultidraw
	Description :	Sets the multi draw state.
	Access :		Public

	Return :		void
	Parameters :	BOOL multidraw	-	New multi draw state
					
	Usage :			Multi draw means that the user can continue 
					to add controls after one is placed.

   ============================================================*/
{
	m_multiDraw = multidraw;
	m_drawing = FALSE;
	m_interactMode = MODE_NONE;
	delete m_drawObj;
	m_drawObj = NULL;
}

void CDiagramEditor::SetZoom( double zoom )
/* ============================================================
	Function :		CDiagramEditor::SetZoom
	Description :	Set the current zoom level.
	Access :		Public

	Return :		void
	Parameters :	double zoom	-	New zoom level. 1.0 means 
					no zoom.
					
	Usage :			If the virtual screen should be zoomed in 
					to double size, the zoom value should be 
					2.0, for example.

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

	m_zoom = max( m_zoomMin, zoom );

	if( m_zoom != m_zoomMin )
		m_zoom = min( m_zoomMax, zoom );

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

}

double CDiagramEditor::GetZoom() const
/* ============================================================
	Function :		CDiagramEditor::GetZoom
	Description :	Returns the current zoom level of the editor. 
	Access :		Public

	Return :		double	-	The current zoom level. 1.0 is 
								no zoom.
	Parameters :	none

	Usage :			The zoom level is expressed as a double, 
					.25 means that all zoomed coordinates 
					should be multiplied with .25, for example.

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

	return m_zoom;

}

void CDiagramEditor::SetZoomFactor( double zoomFactor )
/* ============================================================
	Function :		CDiagramEditor::SetZoomFactor
	Description :	Sets a new zoom factor
	Access :		Public

	Return :		void
	Parameters :	double zoomFactor	-	The new zoom factor
					
	Usage :			The zoom factor is used when the + and - 
					keys are enabled to zoom. The default value 
					is 0.01.

   ============================================================*/
{
	m_zoomFactor = zoomFactor;
}

double CDiagramEditor::GetZoomFactor() const
/* ============================================================
	Function :		CDiagramEditor::GetZoomFactor
	Description :	Returns the current zoom factor
	Access :		Public

	Return :		double	-	The zoom factor
	Parameters :	none

	Usage :			The zoom factor is used when the + and - 
					keys are enabled to zoom. The default value 
					is 0.01.

   ============================================================*/
{
	return m_zoomFactor;
}

double CDiagramEditor::GetZoomMax() const
/* ============================================================
	Function :		CDiagramEditor::GetZoomMax
	Description :	Returns the maximum allowed zoom level
	Access :		Public

	Return :		double	-	The maximum zoom level
	Parameters :	none

	Usage :			The zoom level will never go below or above 
					the min and max zoom levels

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

	return m_zoomMax;

}

double CDiagramEditor::GetZoomMin() const
/* ============================================================
	Function :		CDiagramEditor::GetZoomMin
	Description :	Returns the minimum allowed zoom level
	Access :		Public

	Return :		double	-	The minimum zoom level
	Parameters :	none

	Usage :			The zoom level will never go below or above 
					the min and max zoom levels

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

	return m_zoomMin;

}

void CDiagramEditor::SetZoomMax( double zoommax )
/* ============================================================
	Function :		CDiagramEditor::SetZoomMax
	Description :	Sets the maximum zoom level
	Access :		Public

	Return :		void
	Parameters :	double zoommax	-	The new max zoom
					
	Usage :			The zoom level will never go below or above 
					the min and max zoom levels

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

	m_zoomMax = max( 0, zoommax );

}

void CDiagramEditor::SetZoomMin( double zoommin )
/* ============================================================
	Function :		CDiagramEditor::SetZoomMin
	Description :	Sets the mim zoom level
	Access :		Public

	Return :		void
	Parameters :	double zoommin	-	New minimum zoom level
					
	Usage :			The zoom level will never go below or above 
					the min and max zoom levels

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

	m_zoomMin = max( 0, zoommin );

}

void CDiagramEditor::SetModified( BOOL dirty )
/* ============================================================
	Function :		CDiagramEditor::SetModified
	Description :	Set the modified-state of the data for the 
					document.
	Access :		Public

	Return :		void
	Parameters :	BOOL dirty	-	"TRUE" if the data should be 
									set as modified.
					
	Usage :			Call to mark the data as modified/saved.

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

	if( m_objs )
		m_objs->SetModified( dirty );

}

BOOL CDiagramEditor::IsModified() const
/* ============================================================
	Function :		CDiagramEditor::IsModified
	Description :	Returns "TRUE" if the data in the editor is 
					modified.
	Access :		Public

	Return :		BOOL	-	"TRUE" if modified.
	Parameters :	none

	Usage :			Call to check if the data is modified.

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

	BOOL res = FALSE;
	if( m_objs )
		res = m_objs->IsModified();

	return res;

}

CSize CDiagramEditor::GetMarkerSize() const
/* ============================================================
	Function :		CDiagramEditor::GetMarkerSize
	Description :	Gets the current selection marker size for 
					the editor background.
	Access :		Public

	Return :		CSize	-	The current size.
	Parameters :	none

	Usage :			Call to get the selection marker size.

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

	return m_markerSize;

}

void CDiagramEditor::SetMarkerSize( CSize markerSize )
/* ============================================================
	Function :		CDiagramEditor::SetMarkerSize
	Description :	Sets the size of the selection markers for 
					the editor background.
	Access :		Public

	Return :		void
	Parameters :	CSize markerSize	-	New size of 
											markers.
					
	Usage :			Call to set the selection marker size.
					Will not set the selection marker size for 
					objects.

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

	m_markerSize = markerSize;

}

UINT CDiagramEditor::GetKeyboardInterface() const
/* ============================================================
	Function :		CDiagramEditor::GetKeyboardInterface
	Description :	Returns the flags for the keyboard 
					interface
	Access :		Public

	Return :		UINT	-	The current flags
	Parameters :	none

	Usage :			The keyboard interface decides what keys 
					should be reacted on. The following flags 
					can be used:
						"KEY_ARROW" Will handle arrow keys. If shift is pressed, the selected objects will be resized, moved otherwise.
						"KEY_PGUPDOWN" Will handle Pg up & pg down. If Ctrl is pressed, the selected object will move to the top or the bottom of the z-order, one step up or down otherwise.
						"KEY_DELETE" Will handle delete key. The selected object(s) will be deleted, put into the container clipboard if Ctrl is pressed.
						"KEY_ESCAPE" Will handle escape key. If multi-draw mode, no object type is selected for drawing.
						"KEY_INSERT" Will handle insert key. The selected object will be copied if Ctrl is pressed, duplicated otherwise.
						"KEY_PLUSMINUS" Will handle the plus- and minus key. Will zoom in or out.
						"KEY_CTRL" Will handle Ctrl+A,Z,X,C,V and Enter keys. A = Select all Z = Undo X = Cut C = Copy V = Paste Enter = Show property dialog for the selected object.
					KEY_ALL sets all flags. KEY_NONE no flags.

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

	return m_keyInterface;

}

void CDiagramEditor::SetKeyboardInterface( int keyInterface )
/* ============================================================
	Function :		CDiagramEditor::SetKeyboardInterface
	Description :	Sets the keyboard interface flag.
	Access :		Public

⌨️ 快捷键说明

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