Click here to Skip to main content
15,895,084 members
Articles / Desktop Programming / MFC

CDiagramEditor - DIY vector and dialog editor

Rate me:
Please Sign up or sign in to vote.
4.96/5 (165 votes)
23 Jun 2006Public Domain11 min read 512.2K   36.8K   302  
A feature rich vector editor skeleton.
<html>
<head>
<style>
body{font-size: 10pt;color: black;font-family: Verdana, Helvetica, Arial, sans-serif;background-color: #ffffff}
p{font-size: 10pt;color: black;font-family: Verdana, Helvetica, Arial, sans-serif;}
h2{font-size: 13pt;color: #ff9900;font-family: Verdana, Helvetica, Arial, sans-serif;font-weight: bold;}
h3{color: #ff9900;font-weight: bold;font-size: 11pt;font-family: Arial, sans-serif;}
table{background-color:#f0f0ff;}
td{font-size: 10pt;color: black;font-family: Verdana, Helvetica, Arial, sans-serif;padding:4px;}
pre{padding-right: 7pt;padding-left: 7pt;padding-bottom: 7pt;font: 9pt 'Courier New', Courier, mono;width: 100%;padding-top: 7pt;white-space: pre;background-color: #fbedbb}
code{color: #990000;font-family: 'Courier New', Courier, mono;}
A:link{text-decoration: none}
A:visited{text-decoration: none}
A:active{text-decoration: underline}
A:hover{text-decoration: underline}
A.top:link{font-size:8pt;color:red;font-family:Verdana,Helvetica,Arial,sans-serif;}
A.top:visited{font-size:8pt;color:red;font-family:Verdana,Helvetica,Arial,sans-serif;}
A.top:active{font-size:8pt;color:red;font-family:Verdana,Helvetica,Arial,sans-serif;}
A.top:hoover{font-size:8pt;color:red;font-family:Verdana,Helvetica,Arial,sans-serif;}
</style>
</head>
<body>
<h2>CDiagramPropertyDlg</h2><h3>Overview</h3>
<blockquote>
<b>Purpose</b><br>
<code>CDiagramPropertyDlg</code> represents a property dialog for a <code>CDiagramEntity</code> object.<br>
<p><b>Description</b><br>
The class is a pure virtual class derived from <code>CDialog</code>.<br>
<p><b>Usage</b><br>
Create a property dialog in the resource editor, but map it to <code>CDiagramPropertyDlg</code> instead of <code>CDialog</code>. Add an override of the pure virtual function <code>SetValues</code>. This function is expected to put data from <code>m_entity</code> in appropriate fields in the dialog. Set data in <code>m_entity</code> as appropriate (from an Apply-button handler or whatever appropriate), and call <code>Redraw()</code> if needed. In the <code>CDiagramEntity</code>-derived class, add a member of the <code>CDiagramPropertyDlg</code>-derived class, and call <code>SetPropertyDialog</code> in the constructor. The dialog is displayed as a modeless dialog. <code>CDiagramEditor</code> will hide the dialog automatically when another object is selected, no special Close-button is necessary.
<p><a class='top' href='index.html'>[back to the index page]</a>
</blockquote>
<a name='contents'></a><h3>Contents</h3>
<b>- C -</b><br>
<a href='#CDiagramPropertyDlgUINTresCWndparent:CDialogresparent'>CDiagramPropertyDlg( UINT res, CWnd* parent ) : CDialog( res, parent )</a><br>
<a href='#CreateUINTnIDTemplateCWndpParentWnd'>Create( UINT nIDTemplate, CWnd* pParentWnd )</a><br>
<p>
<b>- G -</b><br>
<a href='#GetEntityconst'>GetEntity() const</a><br>
<a href='#GetRedrawWnd'>GetRedrawWnd()</a><br>
<p>
<b>- R -</b><br>
<a href='#Redraw'>Redraw()</a><br>
<p>
<b>- S -</b><br>
<a href='#SetEntityCDiagramEntityentity'>SetEntity( CDiagramEntity* entity )</a><br>
<a href='#SetRedrawWndCWndredrawWnd'>SetRedrawWnd( CWnd* redrawWnd )</a><br>
<p><h3>Functions</h3><hr>
<code><b><a name='CDiagramPropertyDlgUINTresCWndparent:CDialogresparent'></a>CDiagramPropertyDlg( UINT res, CWnd* parent ) : CDialog( res, parent )</b></code>
<blockquote>
<b>Description</b><br>
constructor
<br><b>Access</b><br>
Public
<br><br><b>Parameters</b><br>
<code>UINT res  </code> -  Resource ID of the dialog template.<br><code>CWnd* parent </code> -  Parent of the dialog - the <code>CDiagramEditor</code>.<br>
<b>Returns</b><br>
void
<br><br><b>Usage</b><br>
-<p>
<a class='top' href='#contents'>[back to the contents]</a>&nbsp;<a class='top' href='index.html'>[back to the index page]</a></p>
</blockquote>
<hr>
<code><b><a name='CreateUINTnIDTemplateCWndpParentWnd'></a>BOOL Create( UINT nIDTemplate, CWnd* pParentWnd )</b></code>
<blockquote>
<b>Description</b><br>
Creates the dialog.
<br><b>Access</b><br>
Public
<br><br><b>Parameters</b><br>
<code>UINT nIDTemplate </code> -  Resource id of dialog template.<br><code>CWnd* pParentWnd </code> -  Parent of dialog (normally the <code>CDiagramEditor</code>)<br>
<b>Returns</b><br>
<code>BOOL    </code> -  <code>TRUE</code> if window was created ok.
<br><br><b>Usage</b><br>
Called internally to create the property dialog.<p>
<a class='top' href='#contents'>[back to the contents]</a>&nbsp;<a class='top' href='index.html'>[back to the index page]</a></p>
</blockquote>
<hr>
<code><b><a name='GetEntityconst'></a>CDiagramEntity* GetEntity() const</b></code>
<blockquote>
<b>Description</b><br>
Returns the <code>CDiagramEntity</code> object of this dialog
<br><b>Access</b><br>
Public
<br><br><b>Parameters</b><br>
none<br>
<b>Returns</b><br>
<code>CDiagramEntity* </code> -  The object attached to this dialog
<br><br><b>Usage</b><br>
Call to get the <code>CDiagramEntity</code>-derived object associated to this dialog.<p>
<a class='top' href='#contents'>[back to the contents]</a>&nbsp;<a class='top' href='index.html'>[back to the index page]</a></p>
</blockquote>
<hr>
<code><b><a name='GetRedrawWnd'></a>CWnd* GetRedrawWnd()</b></code>
<blockquote>
<b>Description</b><br>
Get the window that should be redrawn when changes are made in this dialog.
<br><b>Access</b><br>
Public
<br><br><b>Parameters</b><br>
none<br>
<b>Returns</b><br>
<code>CWnd* </code> -  The window
<br><br><b>Usage</b><br>
Call to get the window that should be redrawn when applying changes in the box. This member is used as the editor will not redraw properly in a MDI-application (<code>GetParent()</code> returns the frame instead of the editor).<p>
<a class='top' href='#contents'>[back to the contents]</a>&nbsp;<a class='top' href='index.html'>[back to the index page]</a></p>
</blockquote>
<hr>
<code><b><a name='Redraw'></a>void Redraw()</b></code>
<blockquote>
<b>Description</b><br>
Redraw the parent window of the dialog.
<br><b>Access</b><br>
Public
<br><br><b>Parameters</b><br>
none<br>
<b>Returns</b><br>
void
<br><br><b>Usage</b><br>
Call to redraw the editor window when applying changes in the box. This member is used as the editor will not redraw properly in a MDI-application (<code>GetParent()</code> returns the frame instead of the editor).<p>
<a class='top' href='#contents'>[back to the contents]</a>&nbsp;<a class='top' href='index.html'>[back to the index page]</a></p>
</blockquote>
<hr>
<code><b><a name='SetEntityCDiagramEntityentity'></a>void SetEntity( CDiagramEntity* entity )</b></code>
<blockquote>
<b>Description</b><br>
Sets the <code>CDiagramEntity</code>-entity derived object that is associated with this dialog.
<br><b>Access</b><br>
Public
<br><br><b>Parameters</b><br>
<code>CDiagramEntity* entity </code> -  Set the object for this dialog.<br>
<b>Returns</b><br>
void
<br><br><b>Usage</b><br>
Call to set the <code>CDiagramEntity</code>-derived object to be associated with this dialog.<p>
<a class='top' href='#contents'>[back to the contents]</a>&nbsp;<a class='top' href='index.html'>[back to the index page]</a></p>
</blockquote>
<hr>
<code><b><a name='SetRedrawWndCWndredrawWnd'></a>void SetRedrawWnd( CWnd* redrawWnd )</b></code>
<blockquote>
<b>Description</b><br>
Set the window that should be redrawn in response to changes in this dialog.
<br><b>Access</b><br>
Public
<br><br><b>Parameters</b><br>
<code>CWnd* redrawWnd </code> -  Normally the editor.<br>
<b>Returns</b><br>
void
<br><br><b>Usage</b><br>
Call to set the window that should be redrawn when applying changes in the box. This member is used as the editor will not redraw properly in a MDI-application (<code>GetParent()</code> returns the frame instead of the editor).<p>
<a class='top' href='#contents'>[back to the contents]</a>&nbsp;<a class='top' href='index.html'>[back to the index page]</a></p>
</blockquote>
<hr>
<b><small>Copyright 2004 Johan Rosengren Abstrakt Mekanik AB</small></b>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Software Developer (Senior) Abstrakt Mekanik AB
Sweden Sweden
45 years old, married, three kids.

Started with computers more than 20 years ago on a CBM-64.

Read Theoretical Philosophy at the University of Lund.

Working as a C++ consultant developer.

Science-fiction freak. Enjoy vintage punkrock.

Comments and Discussions