hello world

This commit is contained in:
Timothee 'TTimo' Besset
2011-11-22 15:28:15 -06:00
commit fb1609f554
2155 changed files with 1017022 additions and 0 deletions

213
neo/tools/Help/MT_help.htm Normal file
View File

@@ -0,0 +1,213 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="Generator" content="Microsoft Word 10 (filtered)">
<title>Material Types</title>
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
/* List Definitions */
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style>
</head>
<body bgcolor="white" lang="EN-US">
<div class="Section1">
<p class="MsoNormal" align="center" style='text-align:center'><b><span style='font-size:18.0pt'>Material Types</span></b></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal" align="right" style='text-align:right'>Version 1.00 Friday
13<sup>th</sup> June 2003 John J Scott</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Materials are defined by .mtt files in the base/materials/
folder. The name of the file is the name of the material (eg.
“materials/sand.mtt” is called “sand”).</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">A .mtt file looks like this </p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><span style='color:blue'>materialType</span></p>
<p class="MsoNormal"><span style='color:blue'>{</span></p>
<p class="MsoNormal"><span style='color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “A phrase that describes
this material type”</span></p>
<p class="MsoNormal"><span style='color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
rgb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
r,g,b</span></p>
<p class="MsoNormal"><span style='color:blue'>}</span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">The r, g and b components are defined as 0 to 255. (eg.
255,0,0 would be bright red)</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">The material type can be defined in the material in 2 ways </p>
<ol style='margin-top:0cm' start="1" type="1">
<li class="MsoNormal">
The keyword “materialType”</li>
</ol>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">The following material would have the material type of
“concrete”</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><span style='color:blue'>textures/wall/texture</span></p>
<p class="MsoNormal"><span style='color:blue'>{</span></p>
<p class="MsoNormal" style='text-indent:36.0pt'><span style='color:blue'>qer_editorimage            textures/wall/texture_d</span></p>
<p class="MsoNormal"><span style='color:blue'>&nbsp;</span></p>
<p class="MsoNormal"><b><span style='color:blue'>            materialType              concrete</span></b></p>
<p class="MsoNormal"><span style='color:blue'>&nbsp;</span></p>
<p class="MsoNormal" style='text-indent:36.0pt'><span style='color:blue'>bumpmap                     addnormals
( textures/wall/texture_local, heightmap ( textures/wall/texture_h, 1 ) )</span></p>
<p class="MsoNormal" style='text-indent:36.0pt'><span style='color:blue'>diffusemap                    textures/wall/texture_d</span></p>
<p class="MsoNormal" style='text-indent:36.0pt'><span style='color:blue'>specularmap                 textures/wall/texture_s</span></p>
<p class="MsoNormal"><span style='color:blue'>}</span></p>
<p class="MsoNormal"><span style='color:blue'>&nbsp;</span></p>
<ol style='margin-top:0cm' start="2" type="1">
<li class="MsoNormal" style='color:black'>
The keyword “materialImage” can be used to specify an image to indirect into.
The rgb values in the material image are compared with the rgb values defined
in the .mtt files to define the material type. Eg. A window frame would have
material type wood wherever the frame was, and material type glass wherever the
glass was.
</li>
</ol>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:black'>The following material will use
the hit image map “textures/wall/texture_hit” to work out the material type,
but return metal should the hit image not yield a valid material.</span></p>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:blue'>textures/wall/texture</span></p>
<p class="MsoNormal"><span style='color:blue'>{</span></p>
<p class="MsoNormal" style='text-indent:36.0pt'><span style='color:blue'>qer_editorimage            textures/wall/texture_d</span></p>
<p class="MsoNormal"><span style='color:blue'>&nbsp;</span></p>
<p class="MsoNormal"><b><span style='color:blue'>            materialType              metal</span></b></p>
<p class="MsoNormal"><b><span style='color:blue'>            materialImage            textures/wall/texture_hit</span></b></p>
<p class="MsoNormal"><span style='color:blue'>&nbsp;</span></p>
<p class="MsoNormal" style='text-indent:36.0pt'><span style='color:blue'>bumpmap                     addnormals
( textures/wall/texture_local, heightmap ( textures/wall/texture_h, 1 ) )</span></p>
<p class="MsoNormal" style='text-indent:36.0pt'><span style='color:blue'>diffusemap                    textures/wall/texture_d</span></p>
<p class="MsoNormal" style='text-indent:36.0pt'><span style='color:blue'>specularmap                 textures/wall/texture_s</span></p>
<p class="MsoNormal"><span style='color:blue'>}</span></p>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:black'>The currently defined materials
are </span></p>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<div align="center">
<table class="MsoTableGrid" border="1" cellspacing="0" cellpadding="0" style='border-collapse:collapse;border:none'>
<tr>
<td width="295" valign="top" style='width:221.4pt;border:solid windowtext 1.0pt;
padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal" align="center" style='text-align:center'><b><span style='color:black'>Material Type</span></b></p>
</td>
<td width="295" valign="top" style='width:221.4pt;border:solid windowtext 1.0pt;
border-left:none;padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal" align="center" style='text-align:center'><b><span style='color:black'>RGB Value</span></b></p>
</td>
</tr>
<tr>
<td width="295" valign="top" style='width:221.4pt;border:solid windowtext 1.0pt;
border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
</td>
<td width="295" valign="top" style='width:221.4pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
</td>
</tr>
<tr>
<td width="295" valign="top" style='width:221.4pt;border:solid windowtext 1.0pt;
border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>None</span></p>
</td>
<td width="295" valign="top" style='width:221.4pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>0,0,0</span></p>
</td>
</tr>
<tr>
<td width="295" valign="top" style='width:221.4pt;border:solid windowtext 1.0pt;
border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>Solidmetal</span></p>
</td>
<td width="295" valign="top" style='width:221.4pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>178,178,178</span></p>
</td>
</tr>
<tr>
<td width="295" valign="top" style='width:221.4pt;border:solid windowtext 1.0pt;
border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>HollowMetal</span></p>
</td>
<td width="295" valign="top" style='width:221.4pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>102,102,102</span></p>
</td>
</tr>
<tr>
<td width="295" valign="top" style='width:221.4pt;border:solid windowtext 1.0pt;
border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>Sand</span></p>
</td>
<td width="295" valign="top" style='width:221.4pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>255,255,0</span></p>
</td>
</tr>
<tr>
<td width="295" valign="top" style='width:221.4pt;border:solid windowtext 1.0pt;
border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>Flesh</span></p>
</td>
<td width="295" valign="top" style='width:221.4pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0cm 5.4pt 0cm 5.4pt'>
<p class="MsoNormal"><span style='color:black'>204,102,102</span></p>
</td>
</tr>
</table>
</div>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:black'>Notes -</span></p>
<ol style='margin-top:0cm' start="1" type="1">
<li class="MsoNormal" style='color:black'>
There are no limits to the dimensions of the material type image. However,
using half the width and height would be a good balance of accuracy vs. memory.
If more accuracy is required, go up to the same size. There is no gain (and
hence no point) in going larger than the material the hit image will be applied
to.</li>
<li class="MsoNormal" style='color:black'>
If the exact rgb values are used, loading up the hit images will be quick. It
will check for the nearest match, but this takes a little longer.</li>
<li class="MsoNormal" style='color:black'>
Generally, use a realistic colour for the material type. This way, the diffuse
map will work naturally as a quick and dirty starting point. For example, flesh
is pink so that any pink found on a hit material image will return a material
type of flesh.</li>
<li class="MsoNormal" style='color:black'>
Try to keep a good separation of material type rgb values. Having two very
close together makes the hit images harder to edit.</li>
</ol>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
<p class="MsoNormal"><span style='color:black'>&nbsp;</span></p>
</div>
</body>
</html>

View File

@@ -0,0 +1,239 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<title>Controls</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 10">
<meta name="Originator" content="Microsoft Word 10">
<link rel="File-List" href="MVH_Controls_filelist.xml">
<link rel="Edit-Time-Data" href="MVH_Controls_editdata.mso">
<style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";}
p {mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";}
span.SpellE {mso-style-name:""; mso-spl-e:yes;}
@page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;}
div.Section1 {page:Section1;}
--></style>
</head>
<body lang="EN-US" style='tab-interval:36.0pt'>
<div class="Section1">
<p><strong><i style='mso-bidi-font-style:normal'><span style='FONT-SIZE:14pt'>Toolbar
Buttons</span></i></strong><i style='mso-bidi-font-style:normal'><span style='FONT-SIZE:14pt'>
<o:p></o:p>
</span></i></p>
<table class="MsoTableGrid" border="1" cellspacing="0" cellpadding="0" width="100%" style='BORDER-RIGHT:medium none; BORDER-TOP:medium none; BORDER-LEFT:medium none; WIDTH:100%; BORDER-BOTTOM:medium none; BORDER-COLLAPSE:collapse; mso-border-alt:solid windowtext .5pt; mso-yfti-tbllook:480; mso-padding-alt:0cm 6.0pt 0cm 6.0pt; mso-border-insideh:.5pt solid windowtext; mso-border-insidev:.5pt solid windowtext'>
<tr style='mso-yfti-irow:0'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'><b style='mso-bidi-font-weight:
normal'>Button</b></p>
</td>
<td width="1152" valign="top">
<p align="center" style='TEXT-ALIGN:center'><b style='mso-bidi-font-weight:
normal'>Description</b></p>
</td>
</tr>
<tr style='mso-yfti-irow:1'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/openmesh.png"></p>
</td>
<td width="1152" valign="top" stle='width:864.0pt;border-top:none;border-left:&#13;&#10; none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;&#13;&#10; mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;&#13;&#10; mso-border-alt:solid windowtext .5pt;padding:0cm 6.0pt 0cm 6.0pt'>
<p style='TEXT-ALIGN:justify'>Opens a mesh file. The supported formats are MD5MESH,
LWO and ASE. This acts the same as the Open Mesh command in the File menu.</p>
</td>
</tr>
<tr style='mso-yfti-irow:2'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/openanim.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Opens an animation file. The supported format is
MD5ANIM. This acts the same as the Open
<span class="SpellE">Anim</span>
command in the File Menu.</p>
</td>
</tr>
<tr style='mso-yfti-irow:3'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/firstanim.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Go to the first animation in the sequence.</p>
</td>
</tr>
<tr style='mso-yfti-irow:4'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/prevanim.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Go to the previous animation in the sequence</p>
</td>
</tr>
<tr style='mso-yfti-irow:5'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/play.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Play the current sequence from the start.</p>
</td>
</tr>
<tr style='mso-yfti-irow:6'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/stop.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Stop the current sequence and retain the current
frame.</p>
</td>
</tr>
<tr style='mso-yfti-irow:7'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/nextanim.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Go to the next animation in the sequence.</p>
</td>
</tr>
<tr style='mso-yfti-irow:8'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/lastanim.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Go to the last animation in the sequence.</p>
</td>
</tr>
<tr style='mso-yfti-irow:9'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/animloop.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Loop the sequence of animations. This defaults to on.</p>
</td>
</tr>
<tr style='mso-yfti-irow:10'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/orgoff.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Remove the movement embedded into the animation. This
stops the models &#8220;walking&#8221; off the map, but can also make
animations where there is subtle movement look wrong.</p>
</td>
</tr>
<tr style='mso-yfti-irow:11'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/diffuse.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Toggle diffuse lighting on and off. This defaults to
on.</p>
</td>
</tr>
<tr style='mso-yfti-irow:12'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/specular.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Toggle
<span class="SpellE">specular</span>
lighting on and off. This defaults to on.</p>
</td>
</tr>
<tr style='mso-yfti-irow:13'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/showsurf.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Display the window containing the list of surfaces
that make up the model. This window can be used to turn selected surfaces on
and off, and to show the triangles that make up each surface.</p>
</td>
</tr>
<tr style='mso-yfti-irow:14'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/showbones.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Display the window containing the tree view of the
bones that make up the skeleton. In conjunction with the show skeleton option,
this allows the user to see which bones are where and at which orientation.</p>
</td>
</tr>
<tr style='mso-yfti-irow:15'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/showskel.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Cycles through the various show skeleton options.
Pressed once, it will show the skeleton and the mesh. Pressed again, it will
show the skeleton without the mesh. The bone window can be used to reduce the
data to a more manageable level.</p>
</td>
</tr>
<tr style='mso-yfti-irow:16'>
<td width="83" valign="top" height="44">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/showtris.png"></p>
</td>
<td width="1152" valign="top" height="44">
<p style='TEXT-ALIGN:justify'>Toggles primitive view on and off. Only surfaces
selected in the surface window will show their primitives. When this button is
first pressed, all surfaces are selected.</p>
</td>
</tr>
<TR style="mso-yfti-irow: 16">
<TD vAlign="top" width="83" height="44">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/showoverdraw.png"></p>
</TD>
<TD vAlign="top" width="1152" height="44">Toggles the show overdraw mode. This can
be used to check for models being textured multiple times.</TD>
</TR>
<tr style='mso-yfti-irow:17'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/shownorms.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Cycles through the various show normal and show
tangent options.</p>
</td>
</tr>
<tr style='mso-yfti-irow:18'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/resetcam.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Resets the camera to its initial viewing position.</p>
</td>
</tr>
<tr style='mso-yfti-irow:19;mso-yfti-lastrow:yes'>
<td width="83" valign="top">
<p align="center" style='TEXT-ALIGN:center'>
<img width="43" height="43" src="images/reloadtex.png"></p>
</td>
<td width="1152" valign="top">
<p style='TEXT-ALIGN:justify'>Reloads any changed textures. Does not reload any
material files.</p>
</td>
</tr>
</table>
<p><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<P><STRONG><EM><FONT size="4">Known issues</FONT></EM></STRONG></P>
<P><FONT size="3">* The animations always start from the first animation when the play
button is hit.</FONT></P>
<P>* The bounding box will still deform as if the model is animating while the
animation is stopped.</P>
<P>* Player cocking weapon sound on startup</P>
<P>* Player assets load on startup. This makes the startup longer than it should
be.</P>
<P>* Unchecking or deleting an animation in the sequence will continue to play that
animation until it finishes.</P>
<P>* Animations do not blend together</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
</body>
</html>

View File

@@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<P><FONT size="4"><STRONG><EM>Miscellaneous Controls</EM></STRONG></FONT></P>
<P><STRONG>Spawn Class Drop Down</STRONG></P>
<P>Collates the entity types by spawn class for easier navigation of ModView.
Whenever a new spawn class is selected, the entity type drop down box is
populated with all the entity types that have the just selected spawn class. A
loaded mesh will have the spawn class of "&lt;file&gt;".</P>
<P><STRONG>Entity Type Drop Down</STRONG></P>
<P>A list of entity types with the above selected spawn class. Whenever an entity
type is selected, the associated mesh is loaded and displayed. The def file is
parsed and the relevant animations are added to the "Animations Available" list
view box. A loaded mesh will have the entity type of it's filename within
chevrons. eg. "&lt;models/md5/meshes/player.md5mesh&gt;".</P>
<P><STRONG>Animations Available List</STRONG></P>
<P>This lists the animations found in the def file. You can select one or many and
move them to the current animation sequence with the "&gt;&gt;" button to the
right of this list. If an animation will not go to the sequence window, then it
was not found or there was some other problem with it. Loaded animations will
go here as their filename, and also to the "Animations Loaded" list. These
loaded animations will be remembered as associated to this spawn class/entity
type combination as long as ModView is running.</P>
<P><STRONG>Animations Loaded List</STRONG></P>
<P>This is the list of animations that have been successfully loaded and can be
played or stepped through using the toolbar controls. Unchecking a particular
animation in the list will temporarily disable the playback of this animation
in the sequence. Selecting one or more animations and pressing the delete key
will remove them from the list permenantly; that is, until you re add them from
the "Animations Available" list.</P>
<P><STRONG>Animation Frame Slider &amp; Text</STRONG></P>
<P>The slider displays the current frame of animation in the current sequence of
animations and takes into account deleted and disabled animations. Hitting
either end of the slider acts the same as pressing the stop toolbar control but
steps one frame at a time in the desired direction. Hitting the slider bar
either side of the button advances the animation ten frames in the desired
direction. The slider button can be dragged to&nbsp;a specific frame. The text
above this slider shows the exact frame number out of how many frames, and the
current playing animation in brackets.</P>
<P><STRONG>Timescale Slider</STRONG></P>
<P>The slider sets the global speed of the animation playback. It defaults to 1.0
and can go from the minimum of 0.02 to the maximum of 2.0 (double the playback
speed).</P>
<P><STRONG>Light Intensity Sliders</STRONG></P>
<P>There are six lights surrounding the model and these sliders adjust their
brightness. The range is from 0 (completely black) to 255 (bright white). The
starting default is 128 (medium grey). There are no current options for
multicoloured lights.</P>
<P>&nbsp;</P>
</body>
</html>

View File

@@ -0,0 +1,194 @@
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 10">
<meta name="Originator" content="Microsoft Word 10">
<link rel="File-List" href="MVH_Mouse_files/filelist.xml">
<title>Mouse controls</title>
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p
{mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
--></style>
</head>
<body lang="EN-US" style='tab-interval:36.0pt'>
<div class="Section1">
<p><em><b><span style='font-size:13.5pt'>Mouse controls</span></b></em></p>
<p>All these operations are performed while the mouse cursor is within the bounds
of the viewing window. The controls are based on the Maya scheme of control
with a few additions and changes.</p>
<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="100%" style='width:100.0%;border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-border-insideh:.5pt solid windowtext;
mso-border-insidev:.5pt solid windowtext'>
<tr style='mso-yfti-irow:0;height:30.25pt'>
<td width="10%" valign="top" style='width:10.74%;border:solid windowtext 1.0pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'><b style='mso-bidi-font-weight:normal'>Mouse
button<o:p></o:p></b></p>
</td>
<td width="9%" valign="top" style='width:9.26%;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'><b style='mso-bidi-font-weight:normal'>Shift<o:p></o:p></b></p>
</td>
<td width="80%" valign="top" style='width:80.0%;border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'><b style='mso-bidi-font-weight:normal'>Description<o:p></o:p></b></p>
</td>
</tr>
<tr style='mso-yfti-irow:1;height:30.25pt'>
<td width="10%" valign="top" style='width:10.74%;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>Left</p>
</td>
<td width="9%" valign="top" style='width:9.26%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>No</p>
</td>
<td width="80%" valign="top" style='width:80.0%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p style='margin-left:3.45pt'>Rotates the camera around the object in all three
dimensions.</p>
</td>
</tr>
<tr style='mso-yfti-irow:2;height:30.25pt'>
<td width="10%" valign="top" style='width:10.74%;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>Middle</p>
</td>
<td width="9%" valign="top" style='width:9.26%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>No</p>
</td>
<td width="80%" valign="top" style='width:80.0%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p style='margin-left:3.45pt'>Pans the camera around the object. Both the camera
and camera target move left, right, up and down relative to the model.</p>
</td>
</tr>
<tr style='mso-yfti-irow:3;height:30.25pt'>
<td width="10%" valign="top" style='width:10.74%;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>Right</p>
</td>
<td width="9%" valign="top" style='width:9.26%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>No</p>
</td>
<td width="80%" valign="top" style='width:80.0%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p style='margin-left:3.45pt'>Moving left and right alter the field of view from
the default value of 60. Moving up and down alter the distance between the
camera and the camera target.</p>
</td>
</tr>
<tr style='mso-yfti-irow:4;height:30.25pt'>
<td width="10%" valign="top" style='width:10.74%;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>Left</p>
</td>
<td width="9%" valign="top" style='width:9.26%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>Yes</p>
</td>
<td width="80%" valign="top" style='width:80.0%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:30.25pt'>
<p style='margin-left:3.45pt'>Pans the camera and model in the world. The camera,
camera target and model move left, right, up and down in the
<span class="SpellE">worild</span>.</p>
</td>
</tr>
<tr style='mso-yfti-irow:5;height:36.0pt'>
<td width="10%" valign="top" style='width:10.74%;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0cm 5.4pt 0cm 5.4pt;height:36.0pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>Middle</p>
</td>
<td width="9%" valign="top" style='width:9.26%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:36.0pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>Yes</p>
</td>
<td width="80%" valign="top" style='width:80.0%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:36.0pt'>
<p style='margin-left:3.45pt'>Modifies the pitch and yaw of the model. This rotates
the model while leaving everything else in place.</p>
</td>
</tr>
<tr style='mso-yfti-irow:6;mso-yfti-lastrow:yes;height:36.0pt'>
<td width="10%" valign="top" style='width:10.74%;border:solid windowtext 1.0pt;
border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;
padding:0cm 5.4pt 0cm 5.4pt;height:36.0pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>Right</p>
</td>
<td width="9%" valign="top" style='width:9.26%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:36.0pt'>
<p align="center" style='margin-left:3.45pt;text-align:center'>Yes</p>
</td>
<td width="80%" valign="top" style='width:80.0%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt;height:36.0pt'>
<p><span style='mso-spacerun:yes'></span>Pans the camera target in the world.</p>
</td>
</tr>
</table>
<p><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

View File

@@ -0,0 +1,84 @@
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 10">
<meta name="Originator" content="Microsoft Word 10">
<link rel="File-List" href="MVH_Overview_files/filelist.xml">
<title>Overview</title>
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
--></style>
</head>
<body lang="EN-US" style='tab-interval:36.0pt'>
<div class="Section1">
<p class="MsoNormal"><b style='mso-bidi-font-weight:normal'><i style='mso-bidi-font-style:
normal'><span style='font-size:14.0pt'>Overview<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><b style='mso-bidi-font-weight:normal'><i style='mso-bidi-font-style:
normal'><span style='font-size:14.0pt'><o:p>&nbsp;</o:p>
</span></i></b></p>
<p class="MsoNormal"><span class="SpellE">ModView</span>
is a tool to view Doom3/Quake4 models and animations. It supports any format
that the Doom3 engine can import.</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">There are two main ways to view models in this tool.</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><i style='mso-bidi-font-style:normal'>1. Directly from files.<o:p></o:p></i></p>
<p class="MsoNormal">Use the open mesh toolbar button to load up an MD5MESH, LWO or
ASE file. The model will be displayed in the view window with all the assets
the game can find.</p>
<p class="MsoNormal">Use the open animation toolbar button to load up an MD5ANIM
file. Hit the play toolbar button to see the model with that animation. If the
model has no bones, or the animation was not defined for that mesh, then
unpredictable results will happen.</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><i style='mso-bidi-font-style:normal'>2.
<span class="GramE">Via</span>
def files<o:p></o:p></i></p>
<p class="MsoNormal">Use the “Spawn Class” drop down list to pick a spawn
<span class="GramE">class,</span>
this will populate the “Entity Type” drop down list with every entity type that
has that spawn class. Select your desired entity type from that list and the
mesh will be loaded up for that entity type. The animations in the def file for
that entity type will appear in the “Animations Available” list view box. Add
these to the animation sequence using the &gt;&gt; button. Hit play to view
them.</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Loaded files have the spawn class of &lt;file&gt; and the
entity type of &lt;mesh name&gt;. Within sessions, any loaded animations for a
particular mesh will be remembered.</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Sounds based on frame commands will play when loading a model
through the def file system.
<span class="GramE">Directly loaded files will
not as they do not have the def file information.</span>
However, this means a def file is not required to load up and view a model.</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

56
neo/tools/Help/Tools.hhc Normal file
View File

@@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<!-- Sitemap 1.0 -->
</HEAD><BODY>
<OBJECT type="text/site properties">
<param name="Window Styles" value="0x800025">
<param name="ImageType" value="Folder">
</OBJECT>
<UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Tools">
</OBJECT>
<UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Quake 4 Tools">
<param name="Local" value="default.htm">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Material Types">
</OBJECT>
<UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Overview">
<param name="Local" value="MT_help.htm">
</OBJECT>
</UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="ModView">
</OBJECT>
<UL>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Overview">
<param name="Local" value="MVH_Overview.htm">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Mouse Controls">
<param name="Local" value="MVH_Mouse.htm">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Misc Controls">
<param name="Local" value="MVH_Misc.htm">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Toolbar Controls">
<param name="Local" value="MVH_Controls.htm">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Known Issues">
<param name="Local" value="MVH_Issues.htm">
</OBJECT>
</UL>
</UL>
</UL>
</BODY></HTML>

9
neo/tools/Help/Tools.hhk Normal file
View File

@@ -0,0 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
<!-- Sitemap 1.0 -->
</HEAD><BODY>
<UL>
</UL>
</BODY></HTML>

13
neo/tools/Help/Tools.hhp Normal file
View File

@@ -0,0 +1,13 @@
[OPTIONS]
Compatibility=1.1 or later
Compiled file=Tools.chm
Contents file=Tools.hhc
Default topic=default.htm
Display compile progress=No
Index file=Tools.hhk
Language=0x409 English (United States)
Title=Quake 4 Tools Help File
[INFOTYPES]

View File

@@ -0,0 +1,10 @@
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 7.0">
</HEAD>
<BODY>
<P>Quake 4 tools table of contents</P>
<P>&nbsp;</P>
</BODY>
</HTML>

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

628
neo/tools/af/DialogAF.cpp Normal file
View File

@@ -0,0 +1,628 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFName.h"
#include "DialogAFView.h"
#include "DialogAFProperties.h"
#include "DialogAFBody.h"
#include "DialogAFConstraint.h"
#ifdef ID_DEBUG_MEMORY
#undef new
#undef DEBUG_NEW
#define DEBUG_NEW new
#endif
// DialogAF
#define AFTAB_VIEW 0x01
#define AFTAB_PROPERTIES 0x02
#define AFTAB_BODIES 0x03
#define AFTAB_CONSTRAINTS 0x04
toolTip_t DialogAF::toolTips[] = {
{ IDC_COMBO_AF, "select an articulated figure for editing" },
{ IDC_BUTTON_AF_NEW, "create a new articulated figure" },
{ IDC_BUTTON_AF_DELETE, "delete the selected articulated figure" },
{ IDC_BUTTON_AF_SPAWN, "spawn ingame entity using the selected articulated figure" },
{ IDC_BUTTON_AF_TPOSE, "set ingame entity using the selected articulated figure back into T-Pose" },
{ IDC_BUTTON_AF_KILL, "kill ingame entity using the selected articulated figure" },
{ IDC_BUTTON_AF_SAVE, "save the selected articulated figure" },
{ IDCANCEL, "cancel all changes to all articulated figures" },
{ 0, NULL }
};
DialogAF *g_AFDialog = NULL;
IMPLEMENT_DYNAMIC(DialogAF, CDialog)
/*
================
DialogAF::DialogAF
================
*/
DialogAF::DialogAF( CWnd* pParent /*=NULL*/ )
: CDialog(DialogAF::IDD, pParent)
, file(NULL)
{
wndTabs = NULL;
wndTabDisplay = NULL;
}
/*
================
DialogAF::~DialogAF
================
*/
DialogAF::~DialogAF() {
}
/*
================
DialogAF::DoDataExchange
================
*/
void DialogAF::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAF)
DDX_Control(pDX, IDC_COMBO_AF, AFList);
//}}AFX_DATA_MAP
}
/*
================
DialogAF::LoadFile
================
*/
void DialogAF::LoadFile( idDeclAF *af ) {
file = af;
propertiesDlg->LoadFile( af );
bodyDlg->LoadFile( af );
constraintDlg->LoadFile( af );
if ( file ) {
// select file in AFList
int i = AFList.FindString( -1, file->GetName() );
if ( i != AFList.GetCurSel() ) {
AFList.SetCurSel( i );
}
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( file->modified );
GetDlgItem( IDC_BUTTON_AF_DELETE )->EnableWindow( true );
}
else {
AFList.SetCurSel( -1 );
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( false );
GetDlgItem( IDC_BUTTON_AF_DELETE )->EnableWindow( false );
}
}
/*
================
DialogAF::LoadFile
================
*/
void DialogAF::SaveFile( void ) {
if ( !file ) {
return;
}
propertiesDlg->SaveFile();
bodyDlg->SaveFile();
constraintDlg->SaveFile();
gameEdit->AF_UpdateEntities( file->GetName() );
}
/*
================
DialogAF::SetFileModified
================
*/
void DialogAF::SetFileModified( void ) {
if ( file ) {
file->modified = true;
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( true );
}
}
/*
================
DialogAF::ReloadFile
================
*/
void DialogAF::ReloadFile( void ) {
LoadFile( file );
}
/*
================
DialogAF::InitAFList
================
*/
void DialogAF::InitAFList( void ) {
int i, c;
AFList.ResetContent();
c = declManager->GetNumDecls( DECL_AF );
for ( i = 0; i < c; i++ ) {
AFList.AddString( static_cast<const idDeclAF *>( declManager->DeclByIndex( DECL_AF, i, false ) )->GetName() );
}
}
/*
================
DialogAF::AddTabItem
================
*/
void DialogAF::AddTabItem( int id, const char *name ) {
TCITEM item;
item.mask = TCIF_PARAM;
item.lParam = id;
int tab = wndTabs->InsertItem( wndTabs->GetItemCount(), name );
wndTabs->SetItem( tab, &item );
}
/*
================
DialogAF::SetTab
================
*/
void DialogAF::SetTab( int id ) {
int c = wndTabs->GetItemCount();
for ( int i = 0; i < c; i++ ) {
TCITEM item;
item.mask = TCIF_PARAM;
wndTabs->GetItem( i, &item );
if ( item.lParam == id ) {
wndTabs->SetCurSel(i);
return;
}
}
wndTabs->SetCurSel(0);
}
/*
================
DialogAF::SetTabChildPos
position the child dialog box
================
*/
void DialogAF::SetTabChildPos( void ) {
if ( wndTabDisplay ) {
wndTabDisplay->ShowWindow( SW_SHOW );
wndTabDisplay->SetWindowPos( wndTabs, 12, 60, 0, 0, SWP_NOSIZE );
}
}
/*
================
DialogAF::OnInitDialog
================
*/
BOOL DialogAF::OnInitDialog() {
CDialog::OnInitDialog();
com_editors |= EDITOR_AF;
// initialize list with articulated figure files
InitAFList();
// initialize tabs
wndTabs = (CTabCtrl *) GetDlgItem( IDC_DIALOG_AF_TAB_MODE );
AddTabItem( AFTAB_VIEW, "View" );
AddTabItem( AFTAB_PROPERTIES, "Properties" );
AddTabItem( AFTAB_BODIES, "Bodies" );
AddTabItem( AFTAB_CONSTRAINTS, "Constraints" );
SetTab( AFTAB_VIEW );
// create child dialog windows
viewDlg = new DialogAFView( this );
propertiesDlg = new DialogAFProperties( this );
bodyDlg = new DialogAFBody( this );
constraintDlg = new DialogAFConstraint( this );
// the body dialog may force the constraint dialog to reload the file
bodyDlg->constraintDlg = constraintDlg;
// the properties dialog may force the body or constraint dialog to reload the file
propertiesDlg->bodyDlg = bodyDlg;
propertiesDlg->constraintDlg = constraintDlg;
// set active child dialog
wndTabDisplay = viewDlg;
SetTabChildPos();
EnableToolTips( TRUE );
GetDlgItem( IDC_BUTTON_AF_DELETE )->EnableWindow( false );
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( false );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(DialogAF, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY(TCN_SELCHANGE, IDC_DIALOG_AF_TAB_MODE, OnTcnSelchangeTabMode)
ON_WM_DESTROY()
ON_WM_ACTIVATE()
ON_WM_MOVE()
ON_WM_SETFOCUS()
ON_CBN_SELCHANGE(IDC_COMBO_AF, OnCbnSelchangeComboAf)
ON_BN_CLICKED(IDC_BUTTON_AF_NEW, OnBnClickedButtonAfNew)
ON_BN_CLICKED(IDC_BUTTON_AF_DELETE, OnBnClickedButtonAfDelete)
ON_BN_CLICKED(IDC_BUTTON_AF_SAVE, OnBnClickedButtonAfSave)
ON_BN_CLICKED(IDC_BUTTON_AF_SPAWN, OnBnClickedButtonAfSpawn)
ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
ON_BN_CLICKED(IDC_BUTTON_AF_KILL, OnBnClickedButtonAfKill)
ON_BN_CLICKED(IDC_BUTTON_AF_TPOSE, OnBnClickedButtonAfTpose)
END_MESSAGE_MAP()
/*
================
AFEditorInit
================
*/
void AFEditorInit( const idDict *spawnArgs ) {
if ( renderSystem->IsFullScreen() ) {
common->Printf( "Cannot run the articulated figure editor in fullscreen mode.\n"
"Set r_fullscreen to 0 and vid_restart.\n" );
return;
}
if ( g_AFDialog == NULL ) {
InitAfx();
g_AFDialog = new DialogAF();
}
if ( g_AFDialog->GetSafeHwnd() == NULL) {
g_AFDialog->Create( IDD_DIALOG_AF );
/*
// FIXME: restore position
CRect rct;
g_AFDialog->SetWindowPos( NULL, rct.left, rct.top, 0, 0, SWP_NOSIZE );
*/
}
idKeyInput::ClearStates();
g_AFDialog->ShowWindow( SW_SHOW );
g_AFDialog->SetFocus();
if ( spawnArgs ) {
// select AF based on spawn args
const char *name = spawnArgs->GetString( "articulatedFigure" );
if ( name[0] == '\0' ) {
name = spawnArgs->GetString( "ragdoll" );
}
idDeclAF *decl = static_cast<idDeclAF *>( const_cast<idDecl *>( declManager->FindType( DECL_AF, name ) ) );
if ( decl ) {
g_AFDialog->LoadFile( decl );
}
}
}
/*
================
AFEditorRun
================
*/
void AFEditorRun( void ) {
#if _MSC_VER >= 1300
MSG *msg = AfxGetCurrentMessage(); // TODO Robert fix me!!
#else
MSG *msg = &m_msgCur;
#endif
while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
// pump message
if ( !AfxGetApp()->PumpMessage() ) {
}
}
}
/*
================
AFEditorShutdown
================
*/
void AFEditorShutdown( void ) {
delete g_AFDialog;
g_AFDialog = NULL;
}
// DialogAF message handlers
/*
================
DialogAF::OnActivate
================
*/
void DialogAF::OnActivate( UINT nState, CWnd *pWndOther, BOOL bMinimized ) {
CDialog::OnActivate( nState, pWndOther, bMinimized );
}
/*
================
DialogAF::OnToolTipNotify
================
*/
BOOL DialogAF::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
/*
================
DialogAF::OnSetFocus
================
*/
void DialogAF::OnSetFocus( CWnd *pOldWnd ) {
//SetActiveWindow();
CDialog::OnSetFocus( pOldWnd );
}
/*
================
DialogAF::OnDestroy
================
*/
void DialogAF::OnDestroy() {
com_editors &= ~EDITOR_AF;
return CDialog::OnDestroy();
}
/*
================
DialogAF::OnMove
================
*/
void DialogAF::OnMove( int x, int y ) {
if ( GetSafeHwnd() ) {
CRect rct;
GetWindowRect( rct );
// FIXME: save position
}
CDialog::OnMove( x, y );
}
/*
================
DialogAF::OnTcnSelchangeTabMode
tab control notification handler
================
*/
void DialogAF::OnTcnSelchangeTabMode( NMHDR *pNMHDR, LRESULT *pResult ) {
*pResult = 0;
// hide the current tab child dialog box, if any.
if ( wndTabDisplay != NULL ) {
wndTabDisplay->ShowWindow( SW_HIDE );
}
TCITEM item;
item.mask = TCIF_PARAM;
wndTabs->GetItem( wndTabs->GetCurSel(), &item );
// show the new tab child dialog box.
switch ( item.lParam ) {
case AFTAB_VIEW:
wndTabDisplay = viewDlg;
break;
case AFTAB_PROPERTIES:
wndTabDisplay = propertiesDlg;
break;
case AFTAB_BODIES:
wndTabDisplay = bodyDlg;
break;
case AFTAB_CONSTRAINTS:
wndTabDisplay = constraintDlg;
break;
}
SetTabChildPos();
}
/*
================
DialogAF::OnCbnSelchangeComboAf
================
*/
void DialogAF::OnCbnSelchangeComboAf() {
int index = AFList.GetCurSel();
if ( index < 0 || index >= declManager->GetNumDecls( DECL_AF ) ) {
InitAFList();
return;
}
if ( index != CB_ERR ) {
CString str;
AFList.GetLBText( index, str );
LoadFile( static_cast<idDeclAF *>( const_cast<idDecl *>( declManager->FindType( DECL_AF, str ) ) ) );
}
}
/*
================
DialogAF::OnBnClickedButtonAfNew
================
*/
void DialogAF::OnBnClickedButtonAfNew() {
DialogAFName nameDlg;
CString name;
idStr fileName;
nameDlg.SetComboBox( &AFList );
if ( nameDlg.DoModal() != IDOK ) {
return;
}
nameDlg.GetName( name );
CFileDialog dlgSave( FALSE, "map", NULL, OFN_OVERWRITEPROMPT, "AF Files (*.af)|*.af|All Files (*.*)|*.*||", AfxGetMainWnd() );
if ( dlgSave.DoModal() != IDOK ) {
return;
}
fileName = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile );
// create a new .af file
AFList.AddString( name );
AFList.SetCurSel( AFList.FindString( -1, name ) );
idDeclAF *decl = static_cast<idDeclAF *>( declManager->CreateNewDecl( DECL_AF, name, fileName ) );
LoadFile( decl );
AFDialogSetFileModified();
}
/*
================
DialogAF::OnBnClickedButtonAfDelete
================
*/
void DialogAF::OnBnClickedButtonAfDelete() {
int i;
i = AFList.GetCurSel();
if ( i != CB_ERR ) {
if ( MessageBox( "Are you sure you want to delete the articulated figure file ?", "Delete Articulated Figure", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
// FIXME: delete the currently selected .af file
}
}
}
/*
================
DialogAF::OnBnClickedButtonAfSpawn
================
*/
void DialogAF::OnBnClickedButtonAfSpawn() {
int index = AFList.GetCurSel();
if ( index != CB_ERR ) {
CString str;
AFList.GetLBText( index, str );
gameEdit->AF_SpawnEntity( str );
}
}
/*
================
DialogAF::OnBnClickedButtonAfTpose
================
*/
void DialogAF::OnBnClickedButtonAfTpose() {
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAF::OnBnClickedButtonAfKill
================
*/
void DialogAF::OnBnClickedButtonAfKill() {
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "deleteSelected\n" );
}
/*
================
DialogAF::OnBnClickedButtonAfSave
================
*/
void DialogAF::OnBnClickedButtonAfSave() {
// save the selected .af file
if ( file ) {
if ( file->Save() ) {
GetDlgItem( IDC_BUTTON_AF_SAVE )->EnableWindow( false );
}
else {
MessageBox( "Saving the file failed. Make sure the file is not read-only.", "Delete Articulated Figure", MB_OK );
}
}
}
/*
================
DialogAF::OnBnClickedCancel
================
*/
void DialogAF::OnBnClickedCancel() {
int i, c;
// check if there are modified .af files and come up with a warning if so
c = declManager->GetNumDecls( DECL_AF );
for ( i = 0; i < c; i++ ) {
if ( static_cast<const idDeclAF *>( declManager->DeclByIndex( DECL_AF, i ) )->modified ) {
if ( MessageBox( "Some articulated figures have been modified.\nCancel all changes ?", "Cancel", MB_YESNO | MB_ICONQUESTION ) != IDYES ) {
return;
}
break;
}
}
// reload all modified .af files
LoadFile( NULL );
gameEdit->AF_UndoChanges();
InitAFList();
OnCancel();
}
// General convenience routines
/*
================
AFDialogSetFileModified
================
*/
void AFDialogSetFileModified( void ) {
if ( g_AFDialog ) {
g_AFDialog->SetFileModified();
}
}
/*
================
AFDialogReloadFile
================
*/
void AFDialogReloadFile( void ) {
if ( g_AFDialog ) {
g_AFDialog->ReloadFile();
}
}

98
neo/tools/af/DialogAF.h Normal file
View File

@@ -0,0 +1,98 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
class idDeclAF;
class DialogAFView;
class DialogAFProperties;
class DialogAFBody;
class DialogAFConstraint;
// DialogAF dialog
class DialogAF : public CDialog {
DECLARE_DYNAMIC(DialogAF)
public:
DialogAF( CWnd* pParent = NULL ); // standard constructor
virtual ~DialogAF();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void ReloadFile( void );
void SetFileModified( void );
enum { IDD = IDD_DIALOG_AF };
protected:
virtual BOOL OnInitDialog();
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnSetFocus( CWnd *pOldWnd );
afx_msg void OnDestroy();
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg void OnMove( int x, int y );
afx_msg void OnTcnSelchangeTabMode( NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnCbnSelchangeComboAf();
afx_msg void OnBnClickedButtonAfNew();
afx_msg void OnBnClickedButtonAfDelete();
afx_msg void OnBnClickedButtonAfSpawn();
afx_msg void OnBnClickedButtonAfTpose();
afx_msg void OnBnClickedButtonAfKill();
afx_msg void OnBnClickedButtonAfSave();
afx_msg void OnBnClickedCancel();
DECLARE_MESSAGE_MAP()
private:
CTabCtrl * wndTabs;
CWnd * wndTabDisplay;
DialogAFView * viewDlg;
DialogAFProperties *propertiesDlg;
DialogAFBody * bodyDlg;
DialogAFConstraint *constraintDlg;
idDeclAF * file; // file being edited
//{{AFX_DATA(DialogAF)
CComboBox AFList; // list with .af files
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitAFList( void );
void AddTabItem( int id, const char *name );
void SetTab( int id );
void SetTabChildPos( void );
};
void AFDialogSetFileModified( void );
void AFDialogReloadFile( void );

File diff suppressed because it is too large Load Diff

160
neo/tools/af/DialogAFBody.h Normal file
View File

@@ -0,0 +1,160 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFBody dialog
class DialogAFBody : public CDialog {
DECLARE_DYNAMIC(DialogAFBody)
public:
DialogAFBody( CWnd* pParent = NULL ); // standard constructor
virtual ~DialogAFBody();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadBody( const char *name );
void SaveBody( void );
void UpdateFile( void );
DialogAFConstraint *constraintDlg;
enum { IDD = IDD_DIALOG_AF_BODY };
protected:
virtual BOOL OnInitDialog();
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnShowWindow( BOOL bShow, UINT nStatus );
afx_msg void OnCbnSelchangeComboBodies();
afx_msg void OnBnClickedButtonNewbody();
afx_msg void OnBnClickedButtonRenamebody();
afx_msg void OnBnClickedButtonDeletebody();
afx_msg void OnCbnSelchangeComboCmType();
afx_msg void OnEnChangeEditCmLength();
afx_msg void OnDeltaposSpinCmLength(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditCmHeight();
afx_msg void OnDeltaposSpinCmHeight(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditCmWidth();
afx_msg void OnDeltaposSpinCmWidth(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditCmNumsides();
afx_msg void OnDeltaposSpinCmNumsides(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnCbnSelchangeComboBoneJoint1();
afx_msg void OnCbnSelchangeComboBoneJoint2();
afx_msg void OnEnChangeEditCmDensity();
afx_msg void OnDeltaposSpinCmDensity(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditCmInertiascale();
afx_msg void OnBnClickedRadioOriginCoordinates();
afx_msg void OnBnClickedRadioOriginBonecenter();
afx_msg void OnBnClickedRadioOriginJoint();
afx_msg void OnEnChangeEditAfVectorX();
afx_msg void OnDeltaposSpinAfVectorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAfVectorY();
afx_msg void OnDeltaposSpinAfVectorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAfVectorZ();
afx_msg void OnDeltaposSpinAfVectorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnOnCbnSelchangeComboOriginBoneCenterJoint1();
afx_msg void OnOnCbnSelchangeComboOriginBoneCenterJoint2();
afx_msg void OnOnCbnSelchangeComboOriginJoint();
afx_msg void OnEnChangeEditAnglesPitch();
afx_msg void OnDeltaposSpinAnglesPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAnglesYaw();
afx_msg void OnDeltaposSpinAnglesYaw(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAnglesRoll();
afx_msg void OnDeltaposSpinAnglesRoll(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedCheckSelfcollision();
afx_msg void OnEnChangeEditContents();
afx_msg void OnEnChangeEditClipmask();
afx_msg void OnEnChangeEditLinearfriction();
afx_msg void OnDeltaposSpinLinearfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAngularfriction();
afx_msg void OnDeltaposSpinAngularfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditContactfriction();
afx_msg void OnDeltaposSpinContactfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditFrictionDirection();
afx_msg void OnEnChangeEditContactMotorDirection();
afx_msg void OnCbnSelchangeComboModifiedjoint();
afx_msg void OnBnClickedRadioModifyOrientation();
afx_msg void OnBnClickedRadioModifyPosition();
afx_msg void OnBnClickedRadioModifyBoth();
afx_msg void OnEnChangeEditContainedjoints();
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Body * body;
int numJoints;
//{{AFX_DATA(DialogAFBody)
CComboBox bodyList; // list with bodies
CComboBox cm_comboType;
float cm_length;
float cm_height;
float cm_width;
CComboBox cm_comboBoneJoint1;
CComboBox cm_comboBoneJoint2;
float cm_numSides;
float cm_density;
CEdit cm_inertiaScale;
float cm_origin_x;
float cm_origin_y;
float cm_origin_z;
CComboBox cm_originBoneCenterJoint1;
CComboBox cm_originBoneCenterJoint2;
CComboBox cm_originJoint;
float cm_angles_pitch;
float cm_angles_yaw;
float cm_angles_roll;
BOOL m_selfCollision;
CEdit m_editContents;
CEdit m_editClipMask;
float m_linearFriction;
float m_angularFriction;
float m_contactFriction;
CEdit m_frictionDirection;
CEdit m_contactMotorDirection;
CComboBox m_comboModifiedJoint;
CEdit m_editContainedJoints;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitBodyList( void );
void InitJointLists( void );
void InitCollisionModelType( void );
void InitModifiedJointList( void );
void InitNewRenameDeleteButtons( void );
void ValidateCollisionModelLength( bool update );
void ValidateCollisionModelHeight( bool update );
void ValidateCollisionModelWidth( bool update );
void ValidateCollisionModelNumSides( bool update );
void ValidateCollisionModelDensity( bool update );
};

View File

@@ -0,0 +1,561 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFName.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintFixed.h"
#include "DialogAFConstraintBallAndSocket.h"
#include "DialogAFConstraintUniversal.h"
#include "DialogAFConstraintHinge.h"
#include "DialogAFConstraintSlider.h"
#include "DialogAFConstraintSpring.h"
#ifdef ID_DEBUG_MEMORY
#undef new
#undef DEBUG_NEW
#define DEBUG_NEW new
#endif
typedef struct {
declAFConstraintType_t type;
const char *name;
} c_type_t;
c_type_t constraintTypes[] = {
{ DECLAF_CONSTRAINT_FIXED, "fixed" },
{ DECLAF_CONSTRAINT_BALLANDSOCKETJOINT, "ball and socket" },
{ DECLAF_CONSTRAINT_UNIVERSALJOINT, "universal" },
{ DECLAF_CONSTRAINT_HINGE, "hinge" },
{ DECLAF_CONSTRAINT_SLIDER, "slider" },
{ DECLAF_CONSTRAINT_SPRING, "spring" },
{ DECLAF_CONSTRAINT_INVALID, NULL }
};
const char *ConstraintTypeToString( declAFConstraintType_t type ) {
for ( int i = 0; constraintTypes[i].name; i++ ) {
if ( constraintTypes[i].type == type ) {
return constraintTypes[i].name;
}
}
return "";
}
declAFConstraintType_t StringToConstraintType( const char *str ) {
for ( int i = 0; constraintTypes[i].name; i++ ) {
if ( idStr::Icmp( constraintTypes[i].name, str ) == 0 ) {
return constraintTypes[i].type;
}
}
return DECLAF_CONSTRAINT_INVALID;
}
// DialogAFConstraint dialog
toolTip_t DialogAFConstraint::toolTips[] = {
{ IDC_COMBO_CONSTRAINTS, "select contraint for editing" },
{ IDC_BUTTON_NEWCONSTRAINT, "create a new constraint" },
{ IDC_BUTTON_RENAMECONSTRAINT, "rename the selected constraint" },
{ IDC_BUTTON_DELETECONSTRAINT, "delete the selected constraint" },
{ IDC_COMBO_CONSTRAINT_TYPE, "constraint type" },
{ IDC_COMBO_CONSTRAINT_BODY1, "first constrained body" },
{ IDC_COMBO_CONSTRAINT_BODY2, "second constrained body" },
{ IDC_EDIT_CONSTRAINT_FRICTION, "constraint friction" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraint, CDialog)
/*
================
DialogAFConstraint::DialogAFConstraint
================
*/
DialogAFConstraint::DialogAFConstraint( CWnd* pParent /*=NULL*/ )
: CDialog(DialogAFConstraint::IDD, pParent)
, m_friction(0)
, constraint(NULL)
, file(NULL)
, constraintDlg(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraint::~DialogAFConstraint
================
*/
DialogAFConstraint::~DialogAFConstraint() {
}
/*
================
DialogAFConstraint::DoDataExchange
================
*/
void DialogAFConstraint::DoDataExchange( CDataExchange* pDX ) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraint)
DDX_Control(pDX, IDC_COMBO_CONSTRAINTS, m_comboConstraintList);
DDX_Control(pDX, IDC_COMBO_CONSTRAINT_TYPE, m_comboConstraintType);
DDX_Control(pDX, IDC_COMBO_CONSTRAINT_BODY1, m_comboBody1List);
DDX_Control(pDX, IDC_COMBO_CONSTRAINT_BODY2, m_comboBody2List);
DDX_Text(pDX, IDC_EDIT_CONSTRAINT_FRICTION, m_friction);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraint::InitConstraintList
================
*/
void DialogAFConstraint::InitConstraintList( void ) {
CString str;
m_comboConstraintList.ResetContent();
if ( !file ) {
return;
}
for ( int i = 0; i < file->constraints.Num(); i++ ) {
m_comboConstraintList.AddString( file->constraints[i]->name.c_str() );
}
if ( m_comboConstraintList.GetCount() != 0 ) {
m_comboConstraintList.SetCurSel( 0 );
m_comboConstraintList.GetLBText( 0, str );
LoadConstraint( str );
}
}
/*
================
DialogAFConstraint::InitConstraintTypeDlg
================
*/
void DialogAFConstraint::InitConstraintTypeDlg( void ) {
CString str;
RECT rect;
if ( !file || !constraint ) {
return;
}
UpdateData( TRUE );
if ( constraintDlg ) {
constraintDlg->ShowWindow( SW_HIDE );
}
GetSafeComboBoxSelection( &m_comboConstraintType, str, -1 );
switch( StringToConstraintType( str ) ) {
case DECLAF_CONSTRAINT_FIXED:
fixedDlg->LoadConstraint( constraint );
constraintDlg = fixedDlg;
break;
case DECLAF_CONSTRAINT_BALLANDSOCKETJOINT:
ballAndSocketDlg->LoadConstraint( constraint );
constraintDlg = ballAndSocketDlg;
break;
case DECLAF_CONSTRAINT_UNIVERSALJOINT:
universalDlg->LoadConstraint( constraint );
constraintDlg = universalDlg;
break;
case DECLAF_CONSTRAINT_HINGE:
hingeDlg->LoadConstraint( constraint );
constraintDlg = hingeDlg;
break;
case DECLAF_CONSTRAINT_SLIDER:
sliderDlg->LoadConstraint( constraint );
constraintDlg = sliderDlg;
break;
case DECLAF_CONSTRAINT_SPRING:
springDlg->LoadConstraint( constraint );
constraintDlg = springDlg;
break;
}
if ( constraintDlg ) {
constraintDlg->ShowWindow( SW_SHOW );
constraintDlg->GetWindowRect( &rect );
constraintDlg->MoveWindow( 0, 117, rect.right - rect.left, rect.bottom - rect.top );
}
}
/*
================
DialogAFConstraint::InitBodyLists
================
*/
void DialogAFConstraint::InitBodyLists( void ) {
m_comboBody1List.ResetContent();
m_comboBody2List.ResetContent();
if ( !file ) {
return;
}
for ( int i = 0; i < file->bodies.Num(); i++ ) {
m_comboBody1List.AddString( file->bodies[i]->name );
m_comboBody2List.AddString( file->bodies[i]->name );
}
// the second body may also be the world
m_comboBody2List.AddString( "world" ); // FIXME: we currently assume this is the last body in the list
}
/*
================
DialogAFConstraint::InitNewRenameDeleteButtons
================
*/
void DialogAFConstraint::InitNewRenameDeleteButtons( void ) {
if ( file && file->bodies.Num() >= 1 ) {
GetDlgItem( IDC_BUTTON_NEWCONSTRAINT )->EnableWindow( true );
}
else {
GetDlgItem( IDC_BUTTON_NEWCONSTRAINT )->EnableWindow( false );
}
if ( file && m_comboConstraintList.GetCount() >= 1 ) {
GetDlgItem( IDC_BUTTON_RENAMECONSTRAINT )->EnableWindow( true );
GetDlgItem( IDC_BUTTON_DELETECONSTRAINT )->EnableWindow( true );
}
else {
GetDlgItem( IDC_BUTTON_RENAMECONSTRAINT )->EnableWindow( false );
GetDlgItem( IDC_BUTTON_DELETECONSTRAINT )->EnableWindow( false );
}
}
/*
================
DialogAFConstraint::LoadFile
================
*/
void DialogAFConstraint::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
ballAndSocketDlg->LoadFile( af );
universalDlg->LoadFile( af );
hingeDlg->LoadFile( af );
sliderDlg->LoadFile( af );
springDlg->LoadFile( af );
InitBodyLists();
InitConstraintList();
InitNewRenameDeleteButtons();
}
/*
================
DialogAFConstraint::SaveFile
================
*/
void DialogAFConstraint::SaveFile( void ) {
SaveConstraint();
}
/*
================
DialogAFConstraint::LoadConstraint
================
*/
void DialogAFConstraint::LoadConstraint( const char *name ) {
int i, s1, s2;
if ( !file ) {
return;
}
for ( i = 0; i < file->constraints.Num(); i++ ) {
if ( file->constraints[i]->name.Icmp( name ) == 0 ) {
break;
}
}
if ( i >= file->constraints.Num() ) {
return;
}
constraint = file->constraints[i];
// load the constraint type from the current idDeclAF_Constraint
SetSafeComboBoxSelection( &m_comboConstraintType, ConstraintTypeToString( constraint->type ), -1 );
// load constrained bodies from the current idDeclAF_Constraint
s1 = SetSafeComboBoxSelection( &m_comboBody1List, constraint->body1.c_str(), -1 );
s2 = SetSafeComboBoxSelection( &m_comboBody2List, constraint->body2.c_str(), s1 );
// load friction from the current idDeclAF_Constraint
m_friction = constraint->friction;
// update displayed values
UpdateData( FALSE );
InitConstraintTypeDlg();
if ( GetStyle() & WS_VISIBLE ) {
// highlight the current constraint ingame
cvarSystem->SetCVarString( "af_highlightConstraint", name );
}
}
/*
================
DialogAFConstraint::SaveConstraint
================
*/
void DialogAFConstraint::SaveConstraint( void ) {
int s1, s2;
CString str;
if ( !file || !constraint ) {
return;
}
UpdateData( TRUE );
// save constraint type to the current idDeclAF_Constraint
GetSafeComboBoxSelection( &m_comboConstraintType, str, -1 );
constraint->type = StringToConstraintType( str );
// save constrained bodies to the current idDeclAF_Constraint
s1 = GetSafeComboBoxSelection( &m_comboBody1List, str, -1 );
constraint->body1 = str;
s2 = GetSafeComboBoxSelection( &m_comboBody2List, str, s1 );
constraint->body2 = str;
// save friction to the current idDeclAF_Constraint
constraint->friction = m_friction;
AFDialogSetFileModified();
}
/*
================
DialogAFConstraint::UpdateFile
================
*/
void DialogAFConstraint::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraint::OnInitDialog
================
*/
BOOL DialogAFConstraint::OnInitDialog() {
CDialog::OnInitDialog();
// initialize the constraint types
m_comboConstraintType.ResetContent();
for ( int i = 0; constraintTypes[i].name; i++ ) {
m_comboConstraintType.AddString( constraintTypes[i].name );
}
fixedDlg = new DialogAFConstraintFixed( this );
fixedDlg->ShowWindow( SW_HIDE );
ballAndSocketDlg = new DialogAFConstraintBallAndSocket( this );
ballAndSocketDlg->ShowWindow( SW_HIDE );
universalDlg = new DialogAFConstraintUniversal( this );
universalDlg->ShowWindow( SW_HIDE );
hingeDlg = new DialogAFConstraintHinge( this );
hingeDlg->ShowWindow( SW_HIDE );
sliderDlg = new DialogAFConstraintSlider( this );
sliderDlg->ShowWindow( SW_HIDE );
springDlg = new DialogAFConstraintSpring( this );
springDlg->ShowWindow( SW_HIDE );
constraintDlg = NULL;
InitNewRenameDeleteButtons();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/*
================
DialogAFConstraint::OnToolHitTest
================
*/
int DialogAFConstraint::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraint, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_WM_SHOWWINDOW()
ON_CBN_SELCHANGE(IDC_COMBO_CONSTRAINTS, OnCbnSelchangeComboConstraints)
ON_CBN_SELCHANGE(IDC_COMBO_CONSTRAINT_TYPE, OnCbnSelchangeComboConstraintType)
ON_CBN_SELCHANGE(IDC_COMBO_CONSTRAINT_BODY1, OnCbnSelchangeComboConstraintBody1)
ON_CBN_SELCHANGE(IDC_COMBO_CONSTRAINT_BODY2, OnCbnSelchangeComboConstraintBody2)
ON_EN_CHANGE(IDC_EDIT_CONSTRAINT_FRICTION, OnEnChangeEditConstraintFriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_CONSTRAINT_FRICTION, OnDeltaposSpinConstraintFriction)
ON_BN_CLICKED(IDC_BUTTON_NEWCONSTRAINT, OnBnClickedButtonNewconstraint)
ON_BN_CLICKED(IDC_BUTTON_RENAMECONSTRAINT, OnBnClickedButtonRenameconstraint)
ON_BN_CLICKED(IDC_BUTTON_DELETECONSTRAINT, OnBnClickedButtonDeleteconstraint)
END_MESSAGE_MAP()
// DialogAFConstraint message handlers
BOOL DialogAFConstraint::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraint::OnShowWindow( BOOL bShow, UINT nStatus ) {
if ( bShow && constraint ) {
cvarSystem->SetCVarString( "af_highlightConstraint", constraint->name.c_str() );
} else {
cvarSystem->SetCVarString( "af_highlightConstraint", "" );
}
CDialog::OnShowWindow( bShow, nStatus );
}
void DialogAFConstraint::OnCbnSelchangeComboConstraints() {
CString str;
GetSafeComboBoxSelection( &m_comboConstraintList, str, -1 );
LoadConstraint( str );
}
void DialogAFConstraint::OnBnClickedButtonNewconstraint() {
DialogAFName nameDlg;
CString str;
nameDlg.SetComboBox( &m_comboConstraintList );
if ( nameDlg.DoModal() == IDOK ) {
nameDlg.GetName( str );
// create new constraint
file->NewConstraint( str );
m_comboConstraintList.SetCurSel( m_comboConstraintList.AddString( str ) );
LoadConstraint( str );
gameEdit->AF_UpdateEntities( file->GetName() );
AFDialogSetFileModified();
}
InitNewRenameDeleteButtons();
}
void DialogAFConstraint::OnBnClickedButtonRenameconstraint() {
int i;
CString name, newName;
DialogAFName nameDlg;
if ( !file || !constraint ) {
return;
}
i = m_comboConstraintList.GetCurSel();
if ( i != CB_ERR ) {
m_comboConstraintList.GetLBText( i, name );
nameDlg.SetName( name );
nameDlg.SetComboBox( &m_comboConstraintList );
if ( nameDlg.DoModal() == IDOK ) {
nameDlg.GetName( newName );
// rename constraint;
file->RenameConstraint( name, newName );
m_comboConstraintList.DeleteString( i );
m_comboConstraintList.SetCurSel( m_comboConstraintList.AddString( newName ) );
LoadConstraint( newName );
gameEdit->AF_UpdateEntities( file->GetName() );
AFDialogSetFileModified();
}
}
}
void DialogAFConstraint::OnBnClickedButtonDeleteconstraint() {
int i;
CString str;
if ( !file || !constraint ) {
return;
}
i = m_comboConstraintList.GetCurSel();
if ( i != CB_ERR ) {
if ( MessageBox( "Are you sure you want to delete this constraint ?", "Delete Constraint", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
m_comboConstraintList.GetLBText( i, str );
// delete current constraint
file->DeleteConstraint( str );
constraint = NULL;
m_comboConstraintList.DeleteString( i );
OnCbnSelchangeComboConstraints();
gameEdit->AF_UpdateEntities( file->GetName() );
AFDialogSetFileModified();
}
}
InitNewRenameDeleteButtons();
}
void DialogAFConstraint::OnCbnSelchangeComboConstraintType() {
InitConstraintTypeDlg();
UpdateFile();
}
void DialogAFConstraint::OnCbnSelchangeComboConstraintBody1() {
CString str;
GetSafeComboBoxSelection( &m_comboBody1List, str, -1 );
UnsetSafeComboBoxSelection( &m_comboBody2List, str );
UpdateFile();
}
void DialogAFConstraint::OnCbnSelchangeComboConstraintBody2() {
CString str;
GetSafeComboBoxSelection( &m_comboBody2List, str, -1 );
UnsetSafeComboBoxSelection( &m_comboBody1List, str );
UpdateFile();
}
void DialogAFConstraint::OnEnChangeEditConstraintFriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINT_FRICTION ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINT_FRICTION ), false );
}
}
void DialogAFConstraint::OnDeltaposSpinConstraintFriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_friction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_CONSTRAINT_FRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,98 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
class DialogAFConstraintFixed;
class DialogAFConstraintBallAndSocket;
class DialogAFConstraintUniversal;
class DialogAFConstraintHinge;
class DialogAFConstraintSlider;
class DialogAFConstraintSpring;
// DialogAFConstraint dialog
class DialogAFConstraint : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraint)
public:
DialogAFConstraint( CWnd* pParent = NULL ); // standard constructor
virtual ~DialogAFConstraint();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( const char *name );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT };
protected:
virtual BOOL OnInitDialog();
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnShowWindow( BOOL bShow, UINT nStatus );
afx_msg void OnCbnSelchangeComboConstraints();
afx_msg void OnBnClickedButtonNewconstraint();
afx_msg void OnBnClickedButtonRenameconstraint();
afx_msg void OnBnClickedButtonDeleteconstraint();
afx_msg void OnCbnSelchangeComboConstraintType();
afx_msg void OnCbnSelchangeComboConstraintBody1();
afx_msg void OnCbnSelchangeComboConstraintBody2();
afx_msg void OnEnChangeEditConstraintFriction();
afx_msg void OnDeltaposSpinConstraintFriction(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
CDialog * constraintDlg;
DialogAFConstraintFixed *fixedDlg;
DialogAFConstraintBallAndSocket *ballAndSocketDlg;
DialogAFConstraintUniversal *universalDlg;
DialogAFConstraintHinge *hingeDlg;
DialogAFConstraintSlider *sliderDlg;
DialogAFConstraintSpring *springDlg;
//{{AFX_DATA(DialogAFConstraint)
CComboBox m_comboConstraintList; // list with constraints
CComboBox m_comboConstraintType;
CComboBox m_comboBody1List;
CComboBox m_comboBody2List;
float m_friction;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitConstraintList( void );
void InitConstraintTypeDlg( void );
void InitBodyLists( void );
void InitNewRenameDeleteButtons( void );
};

View File

@@ -0,0 +1,735 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintBallAndSocket.h"
// DialogAFConstraintBallAndSocket dialog
toolTip_t DialogAFConstraintBallAndSocket::toolTips[] = {
{ IDC_RADIO_ANCHOR_JOINT, "use the position of a joint for the anchor" },
{ IDC_COMBO_ANCHOR_JOINT, "anchor joint name" },
{ IDC_RADIO_ANCHOR_COORDINATES, "use absolute coordinates for the anchor" },
{ IDC_EDIT_ANCHOR_X, "anchor x-coordinate" },
{ IDC_EDIT_ANCHOR_Y, "anchor y-coordinate" },
{ IDC_EDIT_ANCHOR_Z, "anchor z-coordinate" },
{ IDC_RADIO_BAS_LIMIT_NONE, "no joint limit" },
{ IDC_RADIO_BAS_LIMIT_CONE, "cone shaped joint limit" },
{ IDC_RADIO_BAS_LIMIT_PYRAMID, "pyramid shaped joint limit" },
{ IDC_EDIT_BAS_LIMIT_CONE_ANGLE, "cone angle" },
{ IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1, "first pyramid angle" },
{ IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2, "second pyramid angle" },
{ IDC_EDIT_BAS_LIMIT_ROLL, "roll angle" },
{ IDC_RADIO_BAS_LIMIT_BONE, "use a bone for the orientation of the limit" },
{ IDC_RADIO_BAS_LIMIT_ANGLES, "use angles to set the orientation of the limit" },
{ IDC_COMBO_BAS_LIMIT_JOINT1, "bone start joint" },
{ IDC_COMBO_BAS_LIMIT_JOINT2, "bone end joint" },
{ IDC_EDIT_BAS_LIMIT_PITCH, "pitch angle" },
{ IDC_EDIT_BAS_LIMIT_YAW, "yaw angle" },
{ IDC_RADIO_BAS_LIMIT_AXIS_BONE, "use a bone for the limit axis" },
{ IDC_RADIO_BAS_LIMIT_AXIS_ANGLES, "use angles to set the orientation of the limit axis" },
{ IDC_COMBO_BAS_LIMIT_AXIS_JOINT1, "bone start joint" },
{ IDC_COMBO_BAS_LIMIT_AXIS_JOINT2, "bone end joint" },
{ IDC_EDIT_BAS_LIMIT_AXIS_PITCH, "pitch angle" },
{ IDC_EDIT_BAS_LIMIT_AXIS_YAW, "yaw angle" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintBallAndSocket, CDialog)
/*
================
DialogAFConstraintBallAndSocket::DialogAFConstraintBallAndSocket
================
*/
DialogAFConstraintBallAndSocket::DialogAFConstraintBallAndSocket(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintBallAndSocket::IDD, pParent)
, m_anchor_x(0)
, m_anchor_y(0)
, m_anchor_z(0)
, m_coneAngle(30.0f)
, m_pyramidAngle1(30.0f)
, m_pyramidAngle2(30.0f)
, m_limitPitch(0)
, m_limitYaw(0)
, m_limitRoll(0)
, m_limitAxisPitch(0)
, m_limitAxisYaw(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_BALLANDSOCKET, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintBallAndSocket::~DialogAFConstraintBallAndSocket
================
*/
DialogAFConstraintBallAndSocket::~DialogAFConstraintBallAndSocket() {
}
/*
================
DialogAFConstraintBallAndSocket::DoDataExchange
================
*/
void DialogAFConstraintBallAndSocket::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintBallAndSocket)
DDX_Control(pDX, IDC_COMBO_ANCHOR_JOINT, m_comboAnchorJoint);
DDX_Text(pDX, IDC_EDIT_ANCHOR_X, m_anchor_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Y, m_anchor_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Z, m_anchor_z);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_CONE_ANGLE, m_coneAngle);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1, m_pyramidAngle1);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2, m_pyramidAngle2);
DDX_Control(pDX, IDC_COMBO_BAS_LIMIT_JOINT1, m_comboLimitJoint1);
DDX_Control(pDX, IDC_COMBO_BAS_LIMIT_JOINT2, m_comboLimitJoint2);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_PITCH, m_limitPitch);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_YAW, m_limitYaw);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_ROLL, m_limitRoll);
DDX_Control(pDX, IDC_COMBO_BAS_LIMIT_AXIS_JOINT1, m_comboLimitAxisJoint1);
DDX_Control(pDX, IDC_COMBO_BAS_LIMIT_AXIS_JOINT2, m_comboLimitAxisJoint2);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_AXIS_PITCH, m_limitAxisPitch);
DDX_Text(pDX, IDC_EDIT_BAS_LIMIT_AXIS_YAW, m_limitAxisYaw);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintBallAndSocket::InitJointLists
================
*/
void DialogAFConstraintBallAndSocket::InitJointLists( void ) {
m_comboAnchorJoint.ResetContent();
m_comboLimitJoint1.ResetContent();
m_comboLimitJoint2.ResetContent();
m_comboLimitAxisJoint1.ResetContent();
m_comboLimitAxisJoint2.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAnchorJoint.AddString( jointName );
m_comboLimitJoint1.AddString( jointName );
m_comboLimitJoint2.AddString( jointName );
m_comboLimitAxisJoint1.AddString( jointName );
m_comboLimitAxisJoint2.AddString( jointName );
}
}
/*
================
DialogAFConstraintBallAndSocket::LoadFile
================
*/
void DialogAFConstraintBallAndSocket::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintBallAndSocket::SaveFile
================
*/
void DialogAFConstraintBallAndSocket::SaveFile( void ) {
SaveConstraint();
}
/*
================
DialogAFConstraintBallAndSocket::LoadConstraint
================
*/
void DialogAFConstraintBallAndSocket::LoadConstraint( idDeclAF_Constraint *c ) {
int i, s1, s2;
idAngles angles;
constraint = c;
// anchor
SetSafeComboBoxSelection( &m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1 );
m_anchor_x = constraint->anchor.ToVec3().x;
m_anchor_y = constraint->anchor.ToVec3().y;
m_anchor_z = constraint->anchor.ToVec3().z;
if ( constraint->anchor.type == idAFVector::VEC_JOINT ) {
i = IDC_RADIO_ANCHOR_JOINT;
}
else {
i = IDC_RADIO_ANCHOR_COORDINATES;
}
CheckRadioButton( IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i );
// limit
if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
i = IDC_RADIO_BAS_LIMIT_CONE;
}
else if ( constraint->limit == idDeclAF_Constraint::LIMIT_PYRAMID ) {
i = IDC_RADIO_BAS_LIMIT_PYRAMID;
}
else {
i = IDC_RADIO_BAS_LIMIT_NONE;
}
CheckRadioButton( IDC_RADIO_BAS_LIMIT_NONE, IDC_RADIO_BAS_LIMIT_PYRAMID, i );
m_coneAngle = constraint->limitAngles[0];
m_pyramidAngle1 = constraint->limitAngles[0];
m_pyramidAngle2 = constraint->limitAngles[1];
m_limitRoll = constraint->limitAngles[2];
angles = constraint->limitAxis.ToVec3().ToAngles();
m_limitPitch = angles.pitch;
m_limitYaw = angles.yaw;
if ( constraint->limitAxis.type == idAFVector::VEC_BONEDIR ) {
i = IDC_RADIO_BAS_LIMIT_BONE;
}
else {
i = IDC_RADIO_BAS_LIMIT_ANGLES;
}
CheckRadioButton( IDC_RADIO_BAS_LIMIT_BONE, IDC_RADIO_BAS_LIMIT_ANGLES, i );
s1 = SetSafeComboBoxSelection( &m_comboLimitJoint1, constraint->limitAxis.joint1.c_str(), -1 );
s2 = SetSafeComboBoxSelection( &m_comboLimitJoint2, constraint->limitAxis.joint2.c_str(), s1 );
// limit axis
s1 = SetSafeComboBoxSelection( &m_comboLimitAxisJoint1, constraint->shaft[0].joint1.c_str(), -1 );
s2 = SetSafeComboBoxSelection( &m_comboLimitAxisJoint2, constraint->shaft[0].joint2.c_str(), s1 );
angles = constraint->shaft[0].ToVec3().ToAngles();
m_limitAxisPitch = angles.pitch;
m_limitAxisYaw = angles.yaw;
if ( constraint->shaft[0].type == idAFVector::VEC_BONEDIR ) {
i = IDC_RADIO_BAS_LIMIT_AXIS_BONE;
}
else {
i = IDC_RADIO_BAS_LIMIT_AXIS_ANGLES;
constraint->shaft[0].type = idAFVector::VEC_COORDS;
}
CheckRadioButton( IDC_RADIO_BAS_LIMIT_AXIS_BONE, IDC_RADIO_BAS_LIMIT_AXIS_ANGLES, i );
// update displayed values
UpdateData( FALSE );
}
/*
================
DialogAFConstraintBallAndSocket::SaveConstraint
================
*/
void DialogAFConstraintBallAndSocket::SaveConstraint( void ) {
int s1, s2;
CString str;
idAngles angles;
if ( !file || !constraint ) {
return;
}
UpdateData( TRUE );
// anchor
GetSafeComboBoxSelection( &m_comboAnchorJoint, str, -1 );
constraint->anchor.joint1 = str;
constraint->anchor.ToVec3().x = m_anchor_x;
constraint->anchor.ToVec3().y = m_anchor_y;
constraint->anchor.ToVec3().z = m_anchor_z;
// limit
if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
constraint->limitAngles[0] = m_coneAngle;
}
else {
constraint->limitAngles[0] = m_pyramidAngle1;
}
constraint->limitAngles[1] = m_pyramidAngle2;
constraint->limitAngles[2] = m_limitRoll;
angles.pitch = m_limitPitch;
angles.yaw = m_limitYaw;
angles.roll = 0.0f;
constraint->limitAxis.ToVec3() = angles.ToForward();
s1 = GetSafeComboBoxSelection( &m_comboLimitJoint1, str, -1 );
constraint->limitAxis.joint1 = str;
s2 = GetSafeComboBoxSelection( &m_comboLimitJoint2, str, s1 );
constraint->limitAxis.joint2 = str;
// limit axis
if ( constraint->shaft[0].type == idAFVector::VEC_BONEDIR ) {
s1 = GetSafeComboBoxSelection( &m_comboLimitAxisJoint1, str, -1 );
constraint->shaft[0].joint1 = str;
s2 = GetSafeComboBoxSelection( &m_comboLimitAxisJoint2, str, s1 );
constraint->shaft[0].joint2 = str;
}
else {
constraint->shaft[0].ToVec3() = idAngles( m_limitAxisPitch, m_limitAxisYaw, 0.0f ).ToForward();
}
AFDialogSetFileModified();
}
/*
================
DialogAFConstraintBallAndSocket::UpdateFile
================
*/
void DialogAFConstraintBallAndSocket::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintBallAndSocket::OnToolHitTest
================
*/
int DialogAFConstraintBallAndSocket::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintBallAndSocket, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_JOINT, OnBnClickedRadioAnchorJoint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_COORDINATES, OnBnClickedRadioAnchorCoordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR_JOINT, OnCbnSelchangeComboAnchorJoint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_X, OnEnChangeEditAnchorX)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Y, OnEnChangeEditAnchorY)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Z, OnEnChangeEditAnchorZ)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_X, OnDeltaposSpinAnchorX)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Y, OnDeltaposSpinAnchorY)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Z, OnDeltaposSpinAnchorZ)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_NONE, OnBnClickedRadioBasLimitNone)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_CONE, OnBnClickedRadioBasLimitCone)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_PYRAMID, OnBnClickedRadioBasLimitPyramid)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_CONE_ANGLE, OnEnChangeEditBasLimitConeAngle)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_CONE_ANGLE, OnDeltaposSpinBasLimitConeAngle)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1, OnEnChangeEditBasLimitPyramidAngle1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_PYRAMID_ANGLE1, OnDeltaposSpinBasLimitPyramidAngle1)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2, OnEnChangeEditBasLimitPyramidAngle2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_PYRAMID_ANGLE2, OnDeltaposSpinBasLimitPyramidAngle2)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_ROLL, OnEnChangeEditBasLimitRoll)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_ROLL, OnDeltaposSpinBasLimitRoll)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_BONE, OnBnClickedRadioBasLimitBone)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_ANGLES, OnBnClickedRadioBasLimitAngles)
ON_CBN_SELCHANGE(IDC_COMBO_BAS_LIMIT_JOINT1, OnCbnSelchangeComboBasLimitJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_BAS_LIMIT_JOINT2, OnCbnSelchangeComboBasLimitJoint2)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_PITCH, OnEnChangeEditBasLimitPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_PITCH, OnDeltaposSpinBasLimitPitch)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_YAW, OnEnChangeEditBasLimitYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_YAW, OnDeltaposSpinBasLimitYaw)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_AXIS_BONE, OnBnClickedRadioBasLimitAxisBone)
ON_BN_CLICKED(IDC_RADIO_BAS_LIMIT_AXIS_ANGLES, OnBnClickedRadioBasLimitAxisAngles)
ON_CBN_SELCHANGE(IDC_COMBO_BAS_LIMIT_AXIS_JOINT1, OnCbnSelchangeComboBasLimitAxisJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_BAS_LIMIT_AXIS_JOINT2, OnCbnSelchangeComboBasLimitAxisJoint2)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_AXIS_PITCH, OnEnChangeEditBasLimitAxisPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_AXIS_PITCH, OnDeltaposSpinBasLimitAxisPitch)
ON_EN_CHANGE(IDC_EDIT_BAS_LIMIT_AXIS_YAW, OnEnChangeEditBasLimitAxisYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BAS_LIMIT_AXIS_YAW, OnDeltaposSpinBasLimitAxisYaw)
END_MESSAGE_MAP()
// DialogAFConstraintBallAndSocket message handlers
BOOL DialogAFConstraintBallAndSocket::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioAnchorJoint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_JOINT ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioAnchorCoordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboAnchorJoint() {
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditAnchorX() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) ) ) {
UpdateFile();
}
else {
m_anchor_x = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) );
}
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditAnchorY() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) ) ) {
UpdateFile();
}
else {
m_anchor_y = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) );
}
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditAnchorZ() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) ) ) {
UpdateFile();
}
else {
m_anchor_z = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_x += 1.0f;
}
else {
m_anchor_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_y += 1.0f;
}
else {
m_anchor_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_z += 1.0f;
}
else {
m_anchor_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitNone() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_NONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitCone() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_CONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_CONE;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitPyramid() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_PYRAMID ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_PYRAMID;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitConeAngle() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_CONE_ANGLE ) ) ) {
UpdateFile();
}
else {
m_coneAngle = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_CONE_ANGLE ), false );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitConeAngle(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_coneAngle += 1.0f;
}
else if ( m_coneAngle > 0.0f ) {
m_coneAngle -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitPyramidAngle1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1 ) ) ) {
UpdateFile();
}
else {
m_pyramidAngle1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE1 ), false );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitPyramidAngle1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pyramidAngle1 += 1.0f;
}
else if ( m_pyramidAngle1 > 0.0f ) {
m_pyramidAngle1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitPyramidAngle2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2 ) ) ) {
UpdateFile();
}
else {
m_pyramidAngle2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PYRAMID_ANGLE2 ), false );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitPyramidAngle2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pyramidAngle2 += 1.0f;
}
else if ( m_pyramidAngle2 > 0.0f ) {
m_pyramidAngle2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitRoll() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_ROLL ) ) ) {
UpdateFile();
}
else {
m_limitRoll = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_ROLL ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitRoll(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitRoll += 1.0f;
}
else {
m_limitRoll -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitBone() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_BONE ) ) {
if ( constraint ) {
constraint->limitAxis.type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_ANGLES ) ) {
if ( constraint ) {
constraint->limitAxis.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboBasLimitJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitJoint2, str );
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboBasLimitJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitJoint1, str );
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PITCH ) ) ) {
UpdateFile();
}
else {
m_limitPitch = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_PITCH ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitPitch += 1.0f;
}
else {
m_limitPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_YAW ) ) ) {
UpdateFile();
}
else {
m_limitYaw = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_YAW ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitYaw += 1.0f;
}
else {
m_limitYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitAxisBone() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_AXIS_BONE ) ) {
if ( constraint ) {
constraint->shaft[0].type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnBnClickedRadioBasLimitAxisAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_BAS_LIMIT_AXIS_ANGLES ) ) {
if ( constraint ) {
constraint->shaft[0].type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboBasLimitAxisJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitAxisJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitAxisJoint2, str );
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnCbnSelchangeComboBasLimitAxisJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitAxisJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitAxisJoint1, str );
UpdateFile();
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitAxisPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_AXIS_PITCH ) ) ) {
UpdateFile();
}
else {
m_limitAxisPitch = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_AXIS_PITCH ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitAxisPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAxisPitch += 1.0f;
}
else {
m_limitAxisPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintBallAndSocket::OnEnChangeEditBasLimitAxisYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_AXIS_YAW ) ) ) {
UpdateFile();
}
else {
m_limitAxisYaw = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_BAS_LIMIT_AXIS_YAW ) );
}
}
void DialogAFConstraintBallAndSocket::OnDeltaposSpinBasLimitAxisYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAxisYaw += 1.0f;
}
else {
m_limitAxisYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,117 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintBallAndSocket dialog
class DialogAFConstraintBallAndSocket : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintBallAndSocket)
public:
DialogAFConstraintBallAndSocket(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintBallAndSocket();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_BALLANDSOCKET };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioAnchorJoint();
afx_msg void OnBnClickedRadioAnchorCoordinates();
afx_msg void OnCbnSelchangeComboAnchorJoint();
afx_msg void OnEnChangeEditAnchorX();
afx_msg void OnEnChangeEditAnchorY();
afx_msg void OnEnChangeEditAnchorZ();
afx_msg void OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioBasLimitNone();
afx_msg void OnBnClickedRadioBasLimitCone();
afx_msg void OnBnClickedRadioBasLimitPyramid();
afx_msg void OnEnChangeEditBasLimitConeAngle();
afx_msg void OnDeltaposSpinBasLimitConeAngle(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitPyramidAngle1();
afx_msg void OnDeltaposSpinBasLimitPyramidAngle1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitPyramidAngle2();
afx_msg void OnDeltaposSpinBasLimitPyramidAngle2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitRoll();
afx_msg void OnDeltaposSpinBasLimitRoll(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioBasLimitBone();
afx_msg void OnBnClickedRadioBasLimitAngles();
afx_msg void OnCbnSelchangeComboBasLimitJoint1();
afx_msg void OnCbnSelchangeComboBasLimitJoint2();
afx_msg void OnEnChangeEditBasLimitPitch();
afx_msg void OnDeltaposSpinBasLimitPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitYaw();
afx_msg void OnDeltaposSpinBasLimitYaw(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioBasLimitAxisBone();
afx_msg void OnBnClickedRadioBasLimitAxisAngles();
afx_msg void OnCbnSelchangeComboBasLimitAxisJoint1();
afx_msg void OnCbnSelchangeComboBasLimitAxisJoint2();
afx_msg void OnEnChangeEditBasLimitAxisPitch();
afx_msg void OnDeltaposSpinBasLimitAxisPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditBasLimitAxisYaw();
afx_msg void OnDeltaposSpinBasLimitAxisYaw(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintBallAndSocket)
CComboBox m_comboAnchorJoint;
float m_anchor_x;
float m_anchor_y;
float m_anchor_z;
float m_coneAngle;
float m_pyramidAngle1;
float m_pyramidAngle2;
CComboBox m_comboLimitJoint1;
CComboBox m_comboLimitJoint2;
float m_limitPitch;
float m_limitYaw;
float m_limitRoll;
CComboBox m_comboLimitAxisJoint1;
CComboBox m_comboLimitAxisJoint2;
float m_limitAxisPitch;
float m_limitAxisYaw;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,169 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintFixed.h"
// DialogAFConstraintFixed dialog
toolTip_t DialogAFConstraintFixed::toolTips[] = {
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintFixed, CDialog)
/*
================
DialogAFConstraintFixed::DialogAFConstraintFixed
================
*/
DialogAFConstraintFixed::DialogAFConstraintFixed(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintFixed::IDD, pParent)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_FIXED, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintFixed::~DialogAFConstraintFixed
================
*/
DialogAFConstraintFixed::~DialogAFConstraintFixed() {
}
/*
================
DialogAFConstraintFixed::DoDataExchange
================
*/
void DialogAFConstraintFixed::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintHinge)
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintFixed::InitJointLists
================
*/
void DialogAFConstraintFixed::InitJointLists( void ) {
}
/*
================
DialogAFConstraintFixed::LoadFile
================
*/
void DialogAFConstraintFixed::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintFixed::SaveFile
================
*/
void DialogAFConstraintFixed::SaveFile( void ) {
SaveConstraint();
}
/*
================
DialogAFConstraintFixed::LoadConstraint
================
*/
void DialogAFConstraintFixed::LoadConstraint( idDeclAF_Constraint *c ) {
constraint = c;
// update displayed values
UpdateData( FALSE );
}
/*
================
DialogAFConstraintFixed::SaveConstraint
================
*/
void DialogAFConstraintFixed::SaveConstraint( void ) {
if ( !file || !constraint ) {
return;
}
UpdateData( TRUE );
AFDialogSetFileModified();
}
/*
================
DialogAFConstraintFixed::UpdateFile
================
*/
void DialogAFConstraintFixed::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintFixed::OnToolHitTest
================
*/
int DialogAFConstraintFixed::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintFixed, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
END_MESSAGE_MAP()
// DialogAFConstraintFixed message handlers
BOOL DialogAFConstraintFixed::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}

View File

@@ -0,0 +1,65 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintFixed dialog
class DialogAFConstraintFixed : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintFixed)
public:
DialogAFConstraintFixed(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintFixed();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_FIXED };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintHinge)
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,565 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintHinge.h"
// DialogAFConstraintHinge dialog
toolTip_t DialogAFConstraintHinge::toolTips[] = {
{ IDC_RADIO_ANCHOR_JOINT, "use the position of a joint for the anchor" },
{ IDC_COMBO_ANCHOR_JOINT, "anchor joint name" },
{ IDC_RADIO_ANCHOR_COORDINATES, "use absolute coordinates for the anchor" },
{ IDC_EDIT_ANCHOR_X, "anchor x-coordinate" },
{ IDC_EDIT_ANCHOR_Y, "anchor y-coordinate" },
{ IDC_EDIT_ANCHOR_Z, "anchor z-coordinate" },
{ IDC_RADIO_HINGE_AXIS_BONE, "use a bone for the hinge axis" },
{ IDC_RADIO_HINGE_AXIS_ANGLES, "use angles to set the orientation of the hinge axis" },
{ IDC_COMBO_HINGE_AXIS_JOINT1, "bone start joint" },
{ IDC_COMBO_HINGE_AXIS_JOINT2, "bone end joint" },
{ IDC_EDIT_HINGE_AXIS_PITCH, "pitch angle" },
{ IDC_EDIT_HINGE_AXIS_YAW, "yaw angle" },
{ IDC_RADIO_HINGE_LIMIT_NONE, "no limit" },
{ IDC_RADIO_HINGE_LIMIT_ANGLES, "angle limit" },
{ IDC_EDIT_HINGE_LIMIT_ANGLE1, "limit orientation" },
{ IDC_EDIT_HINGE_LIMIT_ANGLE2, "limit width" },
{ IDC_EDIT_HINGE_LIMIT_ANGLE3, "limit angle" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintHinge, CDialog)
/*
================
DialogAFConstraintHinge::DialogAFConstraintHinge
================
*/
DialogAFConstraintHinge::DialogAFConstraintHinge(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintHinge::IDD, pParent)
, m_anchor_x(0)
, m_anchor_y(0)
, m_anchor_z(0)
, m_axisPitch(0)
, m_axisYaw(0)
, m_limitAngle1(0)
, m_limitAngle2(30.0f)
, m_limitAngle3(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_HINGE, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintHinge::~DialogAFConstraintHinge
================
*/
DialogAFConstraintHinge::~DialogAFConstraintHinge() {
}
/*
================
DialogAFConstraintHinge::DoDataExchange
================
*/
void DialogAFConstraintHinge::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintHinge)
DDX_Control(pDX, IDC_COMBO_ANCHOR_JOINT, m_comboAnchorJoint);
DDX_Text(pDX, IDC_EDIT_ANCHOR_X, m_anchor_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Y, m_anchor_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Z, m_anchor_z);
DDX_Control(pDX, IDC_COMBO_HINGE_AXIS_JOINT1, m_comboAxisJoint1);
DDX_Control(pDX, IDC_COMBO_HINGE_AXIS_JOINT2, m_comboAxisJoint2);
DDX_Text(pDX, IDC_EDIT_HINGE_AXIS_PITCH, m_axisPitch);
DDX_Text(pDX, IDC_EDIT_HINGE_AXIS_YAW, m_axisYaw);
DDX_Text(pDX, IDC_EDIT_HINGE_LIMIT_ANGLE1, m_limitAngle1);
DDX_Text(pDX, IDC_EDIT_HINGE_LIMIT_ANGLE2, m_limitAngle2);
DDX_Text(pDX, IDC_EDIT_HINGE_LIMIT_ANGLE3, m_limitAngle3);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintHinge::InitJointLists
================
*/
void DialogAFConstraintHinge::InitJointLists( void ) {
m_comboAnchorJoint.ResetContent();
m_comboAxisJoint1.ResetContent();
m_comboAxisJoint2.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAnchorJoint.AddString( jointName );
m_comboAxisJoint1.AddString( jointName );
m_comboAxisJoint2.AddString( jointName );
}
}
/*
================
DialogAFConstraintHinge::LoadFile
================
*/
void DialogAFConstraintHinge::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintHinge::SaveFile
================
*/
void DialogAFConstraintHinge::SaveFile( void ) {
SaveConstraint();
}
/*
================
DialogAFConstraintHinge::LoadConstraint
================
*/
void DialogAFConstraintHinge::LoadConstraint( idDeclAF_Constraint *c ) {
int i, s1, s2;
idAngles angles;
constraint = c;
// load anchor from the current idDeclAF_Constraint
SetSafeComboBoxSelection( &m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1 );
m_anchor_x = constraint->anchor.ToVec3().x;
m_anchor_y = constraint->anchor.ToVec3().y;
m_anchor_z = constraint->anchor.ToVec3().z;
if ( constraint->anchor.type == idAFVector::VEC_JOINT ) {
i = IDC_RADIO_ANCHOR_JOINT;
}
else {
i = IDC_RADIO_ANCHOR_COORDINATES;
}
CheckRadioButton( IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i );
// hinge axis
s1 = SetSafeComboBoxSelection( &m_comboAxisJoint1, constraint->axis.joint1.c_str(), -1 );
s2 = SetSafeComboBoxSelection( &m_comboAxisJoint2, constraint->axis.joint2.c_str(), s1 );
angles = constraint->axis.ToVec3().ToAngles();
m_axisPitch = angles.pitch;
m_axisYaw = angles.yaw;
if ( constraint->axis.type == idAFVector::VEC_BONEDIR ) {
i = IDC_RADIO_HINGE_AXIS_BONE;
}
else {
i = IDC_RADIO_HINGE_AXIS_ANGLES;
constraint->axis.type = idAFVector::VEC_COORDS;
}
CheckRadioButton( IDC_RADIO_HINGE_AXIS_BONE, IDC_RADIO_HINGE_AXIS_ANGLES, i );
// hinge limit
if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
i = IDC_RADIO_HINGE_LIMIT_ANGLES;
}
else {
i = IDC_RADIO_HINGE_LIMIT_NONE;
}
CheckRadioButton( IDC_RADIO_HINGE_LIMIT_NONE, IDC_RADIO_HINGE_LIMIT_ANGLES, i );
m_limitAngle1 = constraint->limitAngles[0];
m_limitAngle2 = constraint->limitAngles[1];
m_limitAngle3 = constraint->limitAngles[2];
// update displayed values
UpdateData( FALSE );
}
/*
================
DialogAFConstraintHinge::SaveConstraint
================
*/
void DialogAFConstraintHinge::SaveConstraint( void ) {
int s1, s2;
CString str;
if ( !file || !constraint ) {
return;
}
UpdateData( TRUE );
// save anchor to the current idDeclAF_Constraint
GetSafeComboBoxSelection( &m_comboAnchorJoint, str, -1 );
constraint->anchor.joint1 = str;
constraint->anchor.ToVec3().x = m_anchor_x;
constraint->anchor.ToVec3().y = m_anchor_y;
constraint->anchor.ToVec3().z = m_anchor_z;
// hinge axis
if ( constraint->axis.type == idAFVector::VEC_BONEDIR ) {
s1 = GetSafeComboBoxSelection( &m_comboAxisJoint1, str, -1 );
constraint->axis.joint1 = str;
s2 = GetSafeComboBoxSelection( &m_comboAxisJoint2, str, s1 );
constraint->axis.joint2 = str;
}
else {
constraint->axis.ToVec3() = idAngles( m_axisPitch, m_axisYaw, 0.0f ).ToForward();
}
// hinge limit
constraint->limitAngles[0] = m_limitAngle1;
constraint->limitAngles[1] = m_limitAngle2;
constraint->limitAngles[2] = m_limitAngle3;
AFDialogSetFileModified();
}
/*
================
DialogAFConstraintHinge::UpdateFile
================
*/
void DialogAFConstraintHinge::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintHinge::OnToolHitTest
================
*/
int DialogAFConstraintHinge::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintHinge, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_JOINT, OnBnClickedRadioAnchorJoint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_COORDINATES, OnBnClickedRadioAnchorCoordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR_JOINT, OnCbnSelchangeComboAnchorJoint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_X, OnEnChangeEditAnchorX)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Y, OnEnChangeEditAnchorY)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Z, OnEnChangeEditAnchorZ)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_X, OnDeltaposSpinAnchorX)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Y, OnDeltaposSpinAnchorY)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Z, OnDeltaposSpinAnchorZ)
ON_BN_CLICKED(IDC_RADIO_HINGE_AXIS_BONE, OnBnClickedRadioHingeAxisBone)
ON_BN_CLICKED(IDC_RADIO_HINGE_AXIS_ANGLES, OnBnClickedRadioHingeAxisAngles)
ON_CBN_SELCHANGE(IDC_COMBO_HINGE_AXIS_JOINT1, OnCbnSelchangeComboHingeAxisJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_HINGE_AXIS_JOINT2, OnCbnSelchangeComboHingeAxisJoint2)
ON_EN_CHANGE(IDC_EDIT_HINGE_AXIS_PITCH, OnEnChangeEditHingeAxisPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_AXIS_PITCH, OnDeltaposSpinHingeAxisPitch)
ON_EN_CHANGE(IDC_EDIT_HINGE_AXIS_YAW, OnEnChangeEditHingeAxisYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_AXIS_YAW, OnDeltaposSpinHingeAxisYaw)
ON_BN_CLICKED(IDC_RADIO_HINGE_LIMIT_NONE, OnBnClickedRadioHingeLimitNone)
ON_BN_CLICKED(IDC_RADIO_HINGE_LIMIT_ANGLES, OnBnClickedRadioHingeLimitAngles)
ON_EN_CHANGE(IDC_EDIT_HINGE_LIMIT_ANGLE1, OnEnChangeEditHingeLimitAngle1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_LIMIT_ANGLE1, OnDeltaposSpinHingeLimitAngle1)
ON_EN_CHANGE(IDC_EDIT_HINGE_LIMIT_ANGLE2, OnEnChangeEditHingeLimitAngle2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_LIMIT_ANGLE2, OnDeltaposSpinHingeLimitAngle2)
ON_EN_CHANGE(IDC_EDIT_HINGE_LIMIT_ANGLE3, OnEnChangeEditHingeLimitAngle3)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HINGE_LIMIT_ANGLE3, OnDeltaposSpinHingeLimitAngle3)
END_MESSAGE_MAP()
// DialogAFConstraintHinge message handlers
BOOL DialogAFConstraintHinge::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintHinge::OnBnClickedRadioAnchorJoint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_JOINT ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnBnClickedRadioAnchorCoordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnCbnSelchangeComboAnchorJoint() {
UpdateFile();
}
void DialogAFConstraintHinge::OnEnChangeEditAnchorX() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) ) ) {
UpdateFile();
}
else {
m_anchor_x = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) );
}
}
void DialogAFConstraintHinge::OnEnChangeEditAnchorY() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) ) ) {
UpdateFile();
}
else {
m_anchor_y = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) );
}
}
void DialogAFConstraintHinge::OnEnChangeEditAnchorZ() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) ) ) {
UpdateFile();
}
else {
m_anchor_z = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_x += 1.0f;
}
else {
m_anchor_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_y += 1.0f;
}
else {
m_anchor_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_z += 1.0f;
}
else {
m_anchor_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnBnClickedRadioHingeAxisBone() {
if ( IsDlgButtonChecked( IDC_RADIO_HINGE_AXIS_BONE ) ) {
if ( constraint ) {
constraint->axis.type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnBnClickedRadioHingeAxisAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_HINGE_AXIS_ANGLES ) ) {
if ( constraint ) {
constraint->axis.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnCbnSelchangeComboHingeAxisJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboAxisJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboAxisJoint2, str );
UpdateFile();
}
void DialogAFConstraintHinge::OnCbnSelchangeComboHingeAxisJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboAxisJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboAxisJoint1, str );
UpdateFile();
}
void DialogAFConstraintHinge::OnEnChangeEditHingeAxisPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_AXIS_PITCH ) ) ) {
UpdateFile();
}
else {
m_axisPitch = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_AXIS_PITCH ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeAxisPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_axisPitch += 1.0f;
}
else {
m_axisPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnEnChangeEditHingeAxisYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_AXIS_YAW ) ) ) {
UpdateFile();
}
else {
m_axisYaw = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_AXIS_YAW ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeAxisYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_axisYaw += 1.0f;
}
else {
m_axisYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnBnClickedRadioHingeLimitNone() {
if ( IsDlgButtonChecked( IDC_RADIO_HINGE_LIMIT_NONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnBnClickedRadioHingeLimitAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_HINGE_LIMIT_ANGLES ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_CONE;
UpdateFile();
}
}
}
void DialogAFConstraintHinge::OnEnChangeEditHingeLimitAngle1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE1 ) ) ) {
UpdateFile();
}
else {
m_limitAngle1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE1 ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeLimitAngle1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAngle1 += 1.0f;
}
else {
m_limitAngle1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnEnChangeEditHingeLimitAngle2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE2 ) ) ) {
UpdateFile();
}
else {
m_limitAngle2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE2 ), false );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeLimitAngle2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAngle2 += 1.0f;
}
else if ( m_limitAngle2 > 0.0f ) {
m_limitAngle2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintHinge::OnEnChangeEditHingeLimitAngle3() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE3 ) ) ) {
UpdateFile();
}
else {
m_limitAngle3 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_HINGE_LIMIT_ANGLE3 ) );
}
}
void DialogAFConstraintHinge::OnDeltaposSpinHingeLimitAngle3(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitAngle3 += 1.0f;
}
else {
m_limitAngle3 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,101 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintHinge dialog
class DialogAFConstraintHinge : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintHinge)
public:
DialogAFConstraintHinge(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintHinge();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_HINGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioAnchorJoint();
afx_msg void OnBnClickedRadioAnchorCoordinates();
afx_msg void OnCbnSelchangeComboAnchorJoint();
afx_msg void OnEnChangeEditAnchorX();
afx_msg void OnEnChangeEditAnchorY();
afx_msg void OnEnChangeEditAnchorZ();
afx_msg void OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioHingeAxisBone();
afx_msg void OnBnClickedRadioHingeAxisAngles();
afx_msg void OnCbnSelchangeComboHingeAxisJoint1();
afx_msg void OnCbnSelchangeComboHingeAxisJoint2();
afx_msg void OnEnChangeEditHingeAxisPitch();
afx_msg void OnDeltaposSpinHingeAxisPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditHingeAxisYaw();
afx_msg void OnDeltaposSpinHingeAxisYaw(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioHingeLimitNone();
afx_msg void OnBnClickedRadioHingeLimitAngles();
afx_msg void OnEnChangeEditHingeLimitAngle1();
afx_msg void OnDeltaposSpinHingeLimitAngle1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditHingeLimitAngle2();
afx_msg void OnDeltaposSpinHingeLimitAngle2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditHingeLimitAngle3();
afx_msg void OnDeltaposSpinHingeLimitAngle3(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintHinge)
CComboBox m_comboAnchorJoint;
float m_anchor_x;
float m_anchor_y;
float m_anchor_z;
CComboBox m_comboAxisJoint1;
CComboBox m_comboAxisJoint2;
float m_axisPitch;
float m_axisYaw;
float m_limitAngle1;
float m_limitAngle2;
float m_limitAngle3;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,313 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintSlider.h"
// DialogAFConstraintSlider dialog
toolTip_t DialogAFConstraintSlider::toolTips[] = {
{ IDC_RADIO_SLIDER_AXIS_BONE, "use a bone for the slider axis" },
{ IDC_RADIO_SLIDER_AXIS_ANGLES, "use angles to set the orientation of the slider axis" },
{ IDC_COMBO_SLIDER_AXIS_JOINT1, "bone start joint" },
{ IDC_COMBO_SLIDER_AXIS_JOINT2, "bone end joint" },
{ IDC_EDIT_SLIDER_AXIS_PITCH, "pitch angle" },
{ IDC_EDIT_SLIDER_AXIS_YAW, "yaw angle" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintSlider, CDialog)
/*
================
DialogAFConstraintSlider::DialogAFConstraintSlider
================
*/
DialogAFConstraintSlider::DialogAFConstraintSlider(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintSlider::IDD, pParent)
, m_axisPitch(0)
, m_axisYaw(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_SLIDER, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintSlider::~DialogAFConstraintSlider
================
*/
DialogAFConstraintSlider::~DialogAFConstraintSlider() {
}
/*
================
DialogAFConstraintSlider::DoDataExchange
================
*/
void DialogAFConstraintSlider::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintSlider)
DDX_Control(pDX, IDC_COMBO_SLIDER_AXIS_JOINT1, m_comboAxisJoint1);
DDX_Control(pDX, IDC_COMBO_SLIDER_AXIS_JOINT2, m_comboAxisJoint2);
DDX_Text(pDX, IDC_EDIT_SLIDER_AXIS_PITCH, m_axisPitch);
DDX_Text(pDX, IDC_EDIT_SLIDER_AXIS_YAW, m_axisYaw);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintSlider::InitJointLists
================
*/
void DialogAFConstraintSlider::InitJointLists( void ) {
m_comboAxisJoint1.ResetContent();
m_comboAxisJoint2.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAxisJoint1.AddString( jointName );
m_comboAxisJoint2.AddString( jointName );
}
}
/*
================
DialogAFConstraintSlider::LoadFile
================
*/
void DialogAFConstraintSlider::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintSlider::SaveFile
================
*/
void DialogAFConstraintSlider::SaveFile( void ) {
SaveConstraint();
}
/*
================
DialogAFConstraintSlider::LoadConstraint
================
*/
void DialogAFConstraintSlider::LoadConstraint( idDeclAF_Constraint *c ) {
int i, s1, s2;
idAngles angles;
constraint = c;
// slider axis
s1 = SetSafeComboBoxSelection( &m_comboAxisJoint1, constraint->axis.joint1.c_str(), -1 );
s2 = SetSafeComboBoxSelection( &m_comboAxisJoint2, constraint->axis.joint2.c_str(), s1 );
angles = constraint->axis.ToVec3().ToAngles();
m_axisPitch = angles.pitch;
m_axisYaw = angles.yaw;
if ( constraint->axis.type == idAFVector::VEC_BONEDIR ) {
i = IDC_RADIO_SLIDER_AXIS_BONE;
}
else {
i = IDC_RADIO_SLIDER_AXIS_ANGLES;
constraint->axis.type = idAFVector::VEC_COORDS;
}
CheckRadioButton( IDC_RADIO_SLIDER_AXIS_BONE, IDC_RADIO_SLIDER_AXIS_ANGLES, i );
// update displayed values
UpdateData( FALSE );
}
/*
================
DialogAFConstraintSlider::SaveConstraint
================
*/
void DialogAFConstraintSlider::SaveConstraint( void ) {
int s1, s2;
CString str;
if ( !file || !constraint ) {
return;
}
UpdateData( TRUE );
// slider axis
if ( constraint->axis.type == idAFVector::VEC_BONEDIR ) {
s1 = GetSafeComboBoxSelection( &m_comboAxisJoint1, str, -1 );
constraint->axis.joint1 = str;
s2 = GetSafeComboBoxSelection( &m_comboAxisJoint2, str, s1 );
constraint->axis.joint2 = str;
}
else {
constraint->axis.ToVec3() = idAngles( m_axisPitch, m_axisYaw, 0.0f ).ToForward();
}
AFDialogSetFileModified();
}
/*
================
DialogAFConstraintSlider::UpdateFile
================
*/
void DialogAFConstraintSlider::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintSlider::OnToolHitTest
================
*/
int DialogAFConstraintSlider::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintSlider, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_SLIDER_AXIS_BONE, OnBnClickedRadioSliderAxisBone)
ON_BN_CLICKED(IDC_RADIO_SLIDER_AXIS_ANGLES, OnBnClickedRadioSliderAxisAngles)
ON_CBN_SELCHANGE(IDC_COMBO_SLIDER_AXIS_JOINT1, OnCbnSelchangeComboSliderAxisJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_SLIDER_AXIS_JOINT2, OnCbnSelchangeComboSliderAxisJoint2)
ON_EN_CHANGE(IDC_EDIT_SLIDER_AXIS_PITCH, OnEnChangeEditSliderAxisPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SLIDER_AXIS_PITCH, OnDeltaposSpinSliderAxisPitch)
ON_EN_CHANGE(IDC_EDIT_SLIDER_AXIS_YAW, OnEnChangeEditSliderAxisYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SLIDER_AXIS_YAW, OnDeltaposSpinSliderAxisYaw)
END_MESSAGE_MAP()
// DialogAFConstraintSlider message handlers
BOOL DialogAFConstraintSlider::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintSlider::OnBnClickedRadioSliderAxisBone() {
if ( IsDlgButtonChecked( IDC_RADIO_SLIDER_AXIS_BONE ) ) {
if ( constraint ) {
constraint->axis.type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintSlider::OnBnClickedRadioSliderAxisAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_SLIDER_AXIS_ANGLES ) ) {
if ( constraint ) {
constraint->axis.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintSlider::OnCbnSelchangeComboSliderAxisJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboAxisJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboAxisJoint2, str );
UpdateFile();
}
void DialogAFConstraintSlider::OnCbnSelchangeComboSliderAxisJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboAxisJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboAxisJoint1, str );
UpdateFile();
}
void DialogAFConstraintSlider::OnEnChangeEditSliderAxisPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_PITCH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_PITCH ) );
}
}
void DialogAFConstraintSlider::OnDeltaposSpinSliderAxisPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_axisPitch += 1.0f;
}
else {
m_axisPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSlider::OnEnChangeEditSliderAxisYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_YAW ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SLIDER_AXIS_YAW ) );
}
}
void DialogAFConstraintSlider::OnDeltaposSpinSliderAxisYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_axisYaw += 1.0f;
}
else {
m_axisYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,77 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintSlider dialog
class DialogAFConstraintSlider : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintSlider)
public:
DialogAFConstraintSlider(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintSlider();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_HINGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioSliderAxisBone();
afx_msg void OnBnClickedRadioSliderAxisAngles();
afx_msg void OnCbnSelchangeComboSliderAxisJoint1();
afx_msg void OnCbnSelchangeComboSliderAxisJoint2();
afx_msg void OnEnChangeEditSliderAxisPitch();
afx_msg void OnDeltaposSpinSliderAxisPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSliderAxisYaw();
afx_msg void OnDeltaposSpinSliderAxisYaw(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintSlider)
CComboBox m_comboAxisJoint1;
CComboBox m_comboAxisJoint2;
float m_axisPitch;
float m_axisYaw;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,662 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintSpring.h"
// DialogAFConstraintSpring dialog
toolTip_t DialogAFConstraintSpring::toolTips[] = {
{ IDC_RADIO_ANCHOR_JOINT, "use the position of a joint for the first anchor" },
{ IDC_COMBO_ANCHOR_JOINT, "first anchor joint name" },
{ IDC_RADIO_ANCHOR_COORDINATES, "use absolute coordinates for the first anchor" },
{ IDC_EDIT_ANCHOR_X, "first anchor x-coordinate" },
{ IDC_EDIT_ANCHOR_Y, "first anchor y-coordinate" },
{ IDC_EDIT_ANCHOR_Z, "first anchor z-coordinate" },
{ IDC_RADIO_ANCHOR2_JOINT, "use the position of a joint for the second anchor" },
{ IDC_COMBO_ANCHOR2_JOINT, "second anchor joint name" },
{ IDC_RADIO_ANCHOR2_COORDINATES, "use absolute coordinates for the second anchor" },
{ IDC_EDIT_ANCHOR2_X, "second anchor x-coordinate" },
{ IDC_EDIT_ANCHOR2_Y, "second anchor y-coordinate" },
{ IDC_EDIT_ANCHOR2_Z, "second anchor z-coordinate" },
{ IDC_EDIT_SPRING_STRETCH, "spring constant when stretched" },
{ IDC_EDIT_SPRING_COMPRESS, "spring constant when compressed" },
{ IDC_EDIT_SPRING_DAMPING, "spring damping" },
{ IDC_EDIT_SPRING_REST_LENGTH, "rest length" },
{ IDC_RADIO_SPRING_NO_MIN_LENGTH, "no minimum length" },
{ IDC_RADIO_SPRING_MIN_LENGTH, "minimum length" },
{ IDC_EDIT_SPRING_MIN_LENGTH, "minimum length" },
{ IDC_RADIO_SPRING_NO_MAX_LENGTH, "no maximum length" },
{ IDC_RADIO_SPRING_MAX_LENGTH, "maximum length" },
{ IDC_EDIT_SPRING_MAX_LENGTH, "maximum length" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintSpring, CDialog)
/*
================
DialogAFConstraintSpring::DialogAFConstraintSpring
================
*/
DialogAFConstraintSpring::DialogAFConstraintSpring(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintSpring::IDD, pParent)
, m_anchor_x(0)
, m_anchor_y(0)
, m_anchor_z(0)
, m_anchor2_x(0)
, m_anchor2_y(0)
, m_anchor2_z(0)
, m_stretch(0)
, m_compress(0)
, m_damping(0)
, m_restLength(0)
, m_minLength(0)
, m_maxLength(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_SPRING, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintSpring::~DialogAFConstraintSpring
================
*/
DialogAFConstraintSpring::~DialogAFConstraintSpring() {
}
/*
================
DialogAFConstraintSpring::DoDataExchange
================
*/
void DialogAFConstraintSpring::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintSpring)
DDX_Control(pDX, IDC_COMBO_ANCHOR_JOINT, m_comboAnchorJoint);
DDX_Control(pDX, IDC_COMBO_ANCHOR2_JOINT, m_comboAnchor2Joint);
DDX_Text(pDX, IDC_EDIT_ANCHOR_X, m_anchor_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Y, m_anchor_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Z, m_anchor_z);
DDX_Text(pDX, IDC_EDIT_ANCHOR2_X, m_anchor2_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR2_Y, m_anchor2_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR2_Z, m_anchor2_z);
DDX_Text(pDX, IDC_EDIT_SPRING_STRETCH, m_stretch);
DDX_Text(pDX, IDC_EDIT_SPRING_COMPRESS, m_compress);
DDX_Text(pDX, IDC_EDIT_SPRING_DAMPING, m_damping);
DDX_Text(pDX, IDC_EDIT_SPRING_REST_LENGTH, m_restLength);
DDX_Text(pDX, IDC_EDIT_SPRING_MIN_LENGTH, m_minLength);
DDX_Text(pDX, IDC_EDIT_SPRING_MAX_LENGTH, m_maxLength);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintSpring::InitJointLists
================
*/
void DialogAFConstraintSpring::InitJointLists( void ) {
m_comboAnchorJoint.ResetContent();
m_comboAnchor2Joint.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAnchorJoint.AddString( jointName );
m_comboAnchor2Joint.AddString( jointName );
}
}
/*
================
DialogAFConstraintSpring::LoadFile
================
*/
void DialogAFConstraintSpring::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintSpring::SaveFile
================
*/
void DialogAFConstraintSpring::SaveFile( void ) {
SaveConstraint();
}
/*
================
DialogAFConstraintSpring::LoadConstraint
================
*/
void DialogAFConstraintSpring::LoadConstraint( idDeclAF_Constraint *c ) {
int i;
constraint = c;
// load first anchor from the current idDeclAF_Constraint
SetSafeComboBoxSelection( &m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1 );
m_anchor_x = constraint->anchor.ToVec3().x;
m_anchor_y = constraint->anchor.ToVec3().y;
m_anchor_z = constraint->anchor.ToVec3().z;
if ( constraint->anchor.type == idAFVector::VEC_JOINT ) {
i = IDC_RADIO_ANCHOR_JOINT;
}
else {
i = IDC_RADIO_ANCHOR_COORDINATES;
}
CheckRadioButton( IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i );
// load second anchor from the current idDeclAF_Constraint
SetSafeComboBoxSelection( &m_comboAnchor2Joint, constraint->anchor2.joint1.c_str(), -1 );
m_anchor2_x = constraint->anchor2.ToVec3().x;
m_anchor2_y = constraint->anchor2.ToVec3().y;
m_anchor2_z = constraint->anchor2.ToVec3().z;
if ( constraint->anchor2.type == idAFVector::VEC_JOINT ) {
i = IDC_RADIO_ANCHOR2_JOINT;
}
else {
i = IDC_RADIO_ANCHOR2_COORDINATES;
}
CheckRadioButton( IDC_RADIO_ANCHOR2_JOINT, IDC_RADIO_ANCHOR2_COORDINATES, i );
// spring settings
m_stretch = constraint->stretch;
m_compress = constraint->compress;
m_damping = constraint->damping;
m_restLength = constraint->restLength;
// spring limits
if ( constraint->minLength > 0.0f ) {
i = IDC_RADIO_SPRING_MIN_LENGTH;
}
else {
i = IDC_RADIO_SPRING_NO_MIN_LENGTH;
}
CheckRadioButton( IDC_RADIO_SPRING_NO_MIN_LENGTH, IDC_RADIO_SPRING_MIN_LENGTH, i );
m_minLength = constraint->minLength;
if ( constraint->maxLength > 0.0f ) {
i = IDC_RADIO_SPRING_MAX_LENGTH;
}
else {
i = IDC_RADIO_SPRING_NO_MAX_LENGTH;
}
CheckRadioButton( IDC_RADIO_SPRING_NO_MAX_LENGTH, IDC_RADIO_SPRING_MAX_LENGTH, i );
m_maxLength = constraint->maxLength;
// update displayed values
UpdateData( FALSE );
}
/*
================
DialogAFConstraintSpring::SaveConstraint
================
*/
void DialogAFConstraintSpring::SaveConstraint( void ) {
CString str;
if ( !file || !constraint ) {
return;
}
UpdateData( TRUE );
// save first anchor to the current idDeclAF_Constraint
GetSafeComboBoxSelection( &m_comboAnchorJoint, str, -1 );
constraint->anchor.joint1 = str;
constraint->anchor.ToVec3().x = m_anchor_x;
constraint->anchor.ToVec3().y = m_anchor_y;
constraint->anchor.ToVec3().z = m_anchor_z;
// save second anchor to the current idDeclAF_Constraint
GetSafeComboBoxSelection( &m_comboAnchor2Joint, str, -1 );
constraint->anchor2.joint1 = str;
constraint->anchor2.ToVec3().x = m_anchor2_x;
constraint->anchor2.ToVec3().y = m_anchor2_y;
constraint->anchor2.ToVec3().z = m_anchor2_z;
// spring settings
constraint->stretch = m_stretch;
constraint->compress = m_compress;
constraint->damping = m_damping;
constraint->restLength = m_restLength;
// spring limits
constraint->minLength = m_minLength;
constraint->maxLength = m_maxLength;
AFDialogSetFileModified();
}
/*
================
DialogAFConstraintSpring::UpdateFile
================
*/
void DialogAFConstraintSpring::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintSpring::OnToolHitTest
================
*/
int DialogAFConstraintSpring::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintSpring, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_JOINT, OnBnClickedRadioAnchorJoint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_COORDINATES, OnBnClickedRadioAnchorCoordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR_JOINT, OnCbnSelchangeComboAnchorJoint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_X, OnEnChangeEditAnchorX)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Y, OnEnChangeEditAnchorY)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Z, OnEnChangeEditAnchorZ)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_X, OnDeltaposSpinAnchorX)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Y, OnDeltaposSpinAnchorY)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Z, OnDeltaposSpinAnchorZ)
ON_BN_CLICKED(IDC_RADIO_ANCHOR2_JOINT, OnBnClickedRadioAnchor2Joint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR2_COORDINATES, OnBnClickedRadioAnchor2Coordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR2_JOINT, OnCbnSelchangeComboAnchor2Joint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR2_X, OnEnChangeEditAnchor2X)
ON_EN_CHANGE(IDC_EDIT_ANCHOR2_Y, OnEnChangeEditAnchor2Y)
ON_EN_CHANGE(IDC_EDIT_ANCHOR2_Z, OnEnChangeEditAnchor2Z)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR2_X, OnDeltaposSpinAnchor2X)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR2_Y, OnDeltaposSpinAnchor2Y)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR2_Z, OnDeltaposSpinAnchor2Z)
ON_EN_CHANGE(IDC_EDIT_SPRING_STRETCH, OnEnChangeEditSpringStretch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_STRETCH, OnDeltaposSpinSpringStretch)
ON_EN_CHANGE(IDC_EDIT_SPRING_COMPRESS, OnEnChangeEditSpringCompress)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_COMPRESS, OnDeltaposSpinSpringCompress)
ON_EN_CHANGE(IDC_EDIT_SPRING_DAMPING, OnEnChangeEditSpringDamping)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_DAMPING, OnDeltaposSpinSpringDamping)
ON_EN_CHANGE(IDC_EDIT_SPRING_REST_LENGTH, OnEnChangeEditSpringRestLength)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_REST_LENGTH, OnDeltaposSpinSpringRestLength)
ON_BN_CLICKED(IDC_RADIO_SPRING_NO_MIN_LENGTH, OnBnClickedRadioLimitNoMinLength)
ON_BN_CLICKED(IDC_RADIO_SPRING_MIN_LENGTH, OnBnClickedRadioLimitMinLength)
ON_EN_CHANGE(IDC_EDIT_SPRING_MIN_LENGTH, OnEnChangeEditLimitMinLength)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_MIN_LENGTH, OnDeltaposSpinLimitMinLength)
ON_BN_CLICKED(IDC_RADIO_SPRING_NO_MAX_LENGTH, OnBnClickedRadioLimitNoMaxLength)
ON_BN_CLICKED(IDC_RADIO_SPRING_MAX_LENGTH, OnBnClickedRadioLimitMaxLength)
ON_EN_CHANGE(IDC_EDIT_SPRING_MAX_LENGTH, OnEnChangeEditLimitMaxLength)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_SPRING_MAX_LENGTH, OnDeltaposSpinLimitMaxLength)
END_MESSAGE_MAP()
// DialogAFConstraintSpring message handlers
BOOL DialogAFConstraintSpring::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintSpring::OnBnClickedRadioAnchorJoint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_JOINT ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnBnClickedRadioAnchorCoordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnCbnSelchangeComboAnchorJoint() {
UpdateFile();
}
void DialogAFConstraintSpring::OnEnChangeEditAnchorX() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) );
}
}
void DialogAFConstraintSpring::OnEnChangeEditAnchorY() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) );
}
}
void DialogAFConstraintSpring::OnEnChangeEditAnchorZ() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_x += 1.0f;
}
else {
m_anchor_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_y += 1.0f;
}
else {
m_anchor_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_z += 1.0f;
}
else {
m_anchor_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnBnClickedRadioAnchor2Joint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR2_JOINT ) ) {
if ( constraint ) {
constraint->anchor2.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnBnClickedRadioAnchor2Coordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR2_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor2.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnCbnSelchangeComboAnchor2Joint() {
UpdateFile();
}
void DialogAFConstraintSpring::OnEnChangeEditAnchor2X() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_X ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_X ) );
}
}
void DialogAFConstraintSpring::OnEnChangeEditAnchor2Y() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_Y ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_Y ) );
}
}
void DialogAFConstraintSpring::OnEnChangeEditAnchor2Z() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_Z ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR2_Z ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchor2X(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor2_x += 1.0f;
}
else {
m_anchor2_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchor2Y(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor2_y += 1.0f;
}
else {
m_anchor2_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnDeltaposSpinAnchor2Z(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor2_z += 1.0f;
}
else {
m_anchor2_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnEnChangeEditSpringStretch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_STRETCH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_STRETCH ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinSpringStretch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_stretch = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_SPRING_STRETCH ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnEnChangeEditSpringCompress() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_COMPRESS ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_COMPRESS ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinSpringCompress(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_compress = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_SPRING_COMPRESS ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnEnChangeEditSpringDamping() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_DAMPING ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_DAMPING ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinSpringDamping(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_damping = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_SPRING_DAMPING ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnEnChangeEditSpringRestLength() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_REST_LENGTH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_REST_LENGTH ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinSpringRestLength(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_restLength += 1.0f;
}
else {
m_restLength -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnBnClickedRadioLimitNoMinLength() {
if ( IsDlgButtonChecked( IDC_RADIO_SPRING_NO_MIN_LENGTH ) ) {
if ( constraint ) {
constraint->minLength = 0.0f;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnBnClickedRadioLimitMinLength() {
// do nothing
}
void DialogAFConstraintSpring::OnEnChangeEditLimitMinLength() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_MIN_LENGTH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_MIN_LENGTH ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinLimitMinLength(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_minLength += 1.0f;
}
else {
m_minLength -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintSpring::OnBnClickedRadioLimitNoMaxLength() {
if ( IsDlgButtonChecked( IDC_RADIO_SPRING_NO_MAX_LENGTH ) ) {
if ( constraint ) {
constraint->maxLength = 0.0f;
UpdateFile();
}
}
}
void DialogAFConstraintSpring::OnBnClickedRadioLimitMaxLength() {
// do nothing
}
void DialogAFConstraintSpring::OnEnChangeEditLimitMaxLength() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_MAX_LENGTH ) ) ) {
UpdateFile();
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_SPRING_MAX_LENGTH ) );
}
}
void DialogAFConstraintSpring::OnDeltaposSpinLimitMaxLength(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_maxLength += 1.0f;
}
else {
m_maxLength -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,113 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintSpring dialog
class DialogAFConstraintSpring : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintSpring)
public:
DialogAFConstraintSpring(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintSpring();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_HINGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioAnchorJoint();
afx_msg void OnBnClickedRadioAnchorCoordinates();
afx_msg void OnCbnSelchangeComboAnchorJoint();
afx_msg void OnEnChangeEditAnchorX();
afx_msg void OnEnChangeEditAnchorY();
afx_msg void OnEnChangeEditAnchorZ();
afx_msg void OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioAnchor2Joint();
afx_msg void OnBnClickedRadioAnchor2Coordinates();
afx_msg void OnCbnSelchangeComboAnchor2Joint();
afx_msg void OnEnChangeEditAnchor2X();
afx_msg void OnEnChangeEditAnchor2Y();
afx_msg void OnEnChangeEditAnchor2Z();
afx_msg void OnDeltaposSpinAnchor2X(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchor2Y(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchor2Z(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSpringStretch();
afx_msg void OnDeltaposSpinSpringStretch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSpringCompress();
afx_msg void OnDeltaposSpinSpringCompress(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSpringDamping();
afx_msg void OnDeltaposSpinSpringDamping(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditSpringRestLength();
afx_msg void OnDeltaposSpinSpringRestLength(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioLimitNoMinLength();
afx_msg void OnBnClickedRadioLimitMinLength();
afx_msg void OnEnChangeEditLimitMinLength();
afx_msg void OnDeltaposSpinLimitMinLength(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioLimitNoMaxLength();
afx_msg void OnBnClickedRadioLimitMaxLength();
afx_msg void OnEnChangeEditLimitMaxLength();
afx_msg void OnDeltaposSpinLimitMaxLength(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintSpring)
CComboBox m_comboAnchorJoint;
float m_anchor_x;
float m_anchor_y;
float m_anchor_z;
CComboBox m_comboAnchor2Joint;
float m_anchor2_x;
float m_anchor2_y;
float m_anchor2_z;
float m_stretch;
float m_compress;
float m_damping;
float m_restLength;
float m_minLength;
float m_maxLength;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,863 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFConstraint.h"
#include "DialogAFConstraintUniversal.h"
// DialogAFConstraintUniversal dialog
toolTip_t DialogAFConstraintUniversal::toolTips[] = {
{ IDC_RADIO_ANCHOR_JOINT, "use the position of a joint for the anchor" },
{ IDC_COMBO_ANCHOR_JOINT, "anchor joint name" },
{ IDC_RADIO_ANCHOR_COORDINATES, "use absolute coordinates for the anchor" },
{ IDC_EDIT_ANCHOR_X, "anchor x-coordinate" },
{ IDC_EDIT_ANCHOR_Y, "anchor y-coordinate" },
{ IDC_EDIT_ANCHOR_Z, "anchor z-coordinate" },
{ IDC_RADIO_UNIVERSAL_BONE_SHAFT1, "use a bone for the first shaft" },
{ IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1, "use angles to set the orientation of the first shaft" },
{ IDC_COMBO_UNIVERSAL_JOINT1_SHAFT1, "bone start joint" },
{ IDC_COMBO_UNIVERSAL_JOINT2_SHAFT1, "bone end joint" },
{ IDC_EDIT_UNIVERSAL_PITCH_SHAFT1, "pitch angle" },
{ IDC_EDIT_UNIVERSAL_YAW_SHAFT1, "yaw angle" },
{ IDC_RADIO_UNIVERSAL_BONE_SHAFT2, "use a bone for the second shaft" },
{ IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2, "use angles to set the orientation of the second shaft" },
{ IDC_COMBO_UNIVERSAL_JOINT1_SHAFT2, "bone start joint" },
{ IDC_COMBO_UNIVERSAL_JOINT2_SHAFT2, "bone end joint" },
{ IDC_EDIT_UNIVERSAL_PITCH_SHAFT2, "pitch angle" },
{ IDC_EDIT_UNIVERSAL_YAW_SHAFT2, "yaw angle" },
{ IDC_RADIO_UNIVERSAL_LIMIT_NONE, "no joint limit" },
{ IDC_RADIO_UNIVERSAL_LIMIT_CONE, "cone shaped joint limit" },
{ IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID, "pyramid shaped joint limit" },
{ IDC_RADIO_UNIVERSAL_LIMIT_BONE, "use a bone for the limit orientation" },
{ IDC_RADIO_UNIVERSAL_LIMIT_ANGLES, "use angles for the limit orientation" },
{ IDC_COMBO_UNIVERSAL_LIMIT_JOINT1, "bone start joint" },
{ IDC_COMBO_UNIVERSAL_LIMIT_JOINT2, "bone end joint" },
{ IDC_EDIT_UNIVERSAL_LIMIT_PITCH, "pitch angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_YAW, "yaw angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_ROLL, "roll angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE, "cone angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1, "first pyramid angle" },
{ IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2, "second pyramid angle" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFConstraintUniversal, CDialog)
/*
================
DialogAFConstraintUniversal::DialogAFConstraintUniversal
================
*/
DialogAFConstraintUniversal::DialogAFConstraintUniversal(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFConstraintUniversal::IDD, pParent)
, m_anchor_x(0)
, m_anchor_y(0)
, m_anchor_z(0)
, m_pitchShaft1(0)
, m_yawShaft1(0)
, m_pitchShaft2(0)
, m_yawShaft2(0)
, m_coneAngle(30.0f)
, m_pyramidAngle1(30.0f)
, m_pyramidAngle2(30.0f)
, m_limitPitch(0)
, m_limitYaw(0)
, m_limitRoll(0)
, constraint(NULL)
, file(NULL)
{
Create( IDD_DIALOG_AF_CONSTRAINT_UNIVERSAL, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFConstraintUniversal::~DialogAFConstraintUniversal
================
*/
DialogAFConstraintUniversal::~DialogAFConstraintUniversal() {
}
/*
================
DialogAFConstraintUniversal::DoDataExchange
================
*/
void DialogAFConstraintUniversal::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFConstraintUniversal)
DDX_Control(pDX, IDC_COMBO_ANCHOR_JOINT, m_comboAnchorJoint);
DDX_Text(pDX, IDC_EDIT_ANCHOR_X, m_anchor_x);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Y, m_anchor_y);
DDX_Text(pDX, IDC_EDIT_ANCHOR_Z, m_anchor_z);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_JOINT1_SHAFT1, m_comboJoint1Shaft1);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_JOINT2_SHAFT1, m_comboJoint2Shaft1);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_PITCH_SHAFT1, m_pitchShaft1);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_YAW_SHAFT1, m_yawShaft1);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_JOINT1_SHAFT2, m_comboJoint1Shaft2);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_JOINT2_SHAFT2, m_comboJoint2Shaft2);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_PITCH_SHAFT2, m_pitchShaft2);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_YAW_SHAFT2, m_yawShaft2);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE, m_coneAngle);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1, m_pyramidAngle1);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2, m_pyramidAngle2);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_LIMIT_JOINT1, m_comboLimitJoint1);
DDX_Control(pDX, IDC_COMBO_UNIVERSAL_LIMIT_JOINT2, m_comboLimitJoint2);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_PITCH, m_limitPitch);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_YAW, m_limitYaw);
DDX_Text(pDX, IDC_EDIT_UNIVERSAL_LIMIT_ROLL, m_limitRoll);
//}}AFX_DATA_MAP
}
/*
================
DialogAFConstraintUniversal::InitJointLists
================
*/
void DialogAFConstraintUniversal::InitJointLists( void ) {
m_comboAnchorJoint.ResetContent();
m_comboJoint1Shaft1.ResetContent();
m_comboJoint2Shaft1.ResetContent();
m_comboJoint1Shaft2.ResetContent();
m_comboJoint2Shaft2.ResetContent();
m_comboLimitJoint1.ResetContent();
m_comboLimitJoint2.ResetContent();
if ( !file ) {
return;
}
const idRenderModel *model = gameEdit->ANIM_GetModelFromName( file->model );
if ( !model ) {
return;
}
int numJoints = model->NumJoints();
for ( int i = 0; i < numJoints; i++ ) {
const char *jointName = model->GetJointName( (jointHandle_t) i );
m_comboAnchorJoint.AddString( jointName );
m_comboJoint1Shaft1.AddString( jointName );
m_comboJoint2Shaft1.AddString( jointName );
m_comboJoint1Shaft2.AddString( jointName );
m_comboJoint2Shaft2.AddString( jointName );
m_comboLimitJoint1.AddString( jointName );
m_comboLimitJoint2.AddString( jointName );
}
}
/*
================
DialogAFConstraintUniversal::LoadFile
================
*/
void DialogAFConstraintUniversal::LoadFile( idDeclAF *af ) {
file = af;
constraint = NULL;
InitJointLists();
}
/*
================
DialogAFConstraintUniversal::SaveFile
================
*/
void DialogAFConstraintUniversal::SaveFile( void ) {
SaveConstraint();
}
/*
================
DialogAFConstraintUniversal::LoadConstraint
================
*/
void DialogAFConstraintUniversal::LoadConstraint( idDeclAF_Constraint *c ) {
int i, s1, s2;
idAngles angles;
idMat3 mat;
constraint = c;
// anchor
SetSafeComboBoxSelection( &m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1 );
m_anchor_x = constraint->anchor.ToVec3().x;
m_anchor_y = constraint->anchor.ToVec3().y;
m_anchor_z = constraint->anchor.ToVec3().z;
if ( constraint->anchor.type == idAFVector::VEC_JOINT ) {
i = IDC_RADIO_ANCHOR_JOINT;
}
else {
i = IDC_RADIO_ANCHOR_COORDINATES;
}
CheckRadioButton( IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i );
// shaft 1
s1 = SetSafeComboBoxSelection( &m_comboJoint1Shaft1, constraint->shaft[0].joint1.c_str(), -1 );
s2 = SetSafeComboBoxSelection( &m_comboJoint2Shaft1, constraint->shaft[0].joint2.c_str(), s1 );
angles = constraint->shaft[0].ToVec3().ToAngles();
m_pitchShaft1 = angles.pitch;
m_yawShaft1 = angles.yaw;
if ( constraint->shaft[0].type == idAFVector::VEC_BONEDIR ) {
i = IDC_RADIO_UNIVERSAL_BONE_SHAFT1;
}
else {
i = IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1;
constraint->shaft[0].type = idAFVector::VEC_COORDS;
}
CheckRadioButton( IDC_RADIO_UNIVERSAL_BONE_SHAFT1, IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1, i );
// shaft 2
s1 = SetSafeComboBoxSelection( &m_comboJoint1Shaft2, constraint->shaft[1].joint1.c_str(), -1 );
s2 = SetSafeComboBoxSelection( &m_comboJoint2Shaft2, constraint->shaft[1].joint2.c_str(), s1 );
angles = constraint->shaft[1].ToVec3().ToAngles();
m_pitchShaft2 = angles.pitch;
m_yawShaft2 = angles.yaw;
if ( constraint->shaft[1].type == idAFVector::VEC_BONEDIR ) {
i = IDC_RADIO_UNIVERSAL_BONE_SHAFT2;
}
else {
i = IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2;
constraint->shaft[1].type = idAFVector::VEC_COORDS;
}
CheckRadioButton( IDC_RADIO_UNIVERSAL_BONE_SHAFT2, IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2, i );
// limit
if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
i = IDC_RADIO_UNIVERSAL_LIMIT_CONE;
}
else if ( constraint->limit == idDeclAF_Constraint::LIMIT_PYRAMID ) {
i = IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID;
}
else {
i = IDC_RADIO_UNIVERSAL_LIMIT_NONE;
}
CheckRadioButton( IDC_RADIO_UNIVERSAL_LIMIT_NONE, IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID, i );
m_coneAngle = constraint->limitAngles[0];
m_pyramidAngle1 = constraint->limitAngles[0];
m_pyramidAngle2 = constraint->limitAngles[1];
m_limitRoll = constraint->limitAngles[2];
angles = constraint->limitAxis.ToVec3().ToAngles();
m_limitPitch = angles.pitch;
m_limitYaw = angles.yaw;
if ( constraint->limitAxis.type == idAFVector::VEC_BONEDIR ) {
i = IDC_RADIO_UNIVERSAL_LIMIT_BONE;
}
else {
i = IDC_RADIO_UNIVERSAL_LIMIT_ANGLES;
}
CheckRadioButton( IDC_RADIO_UNIVERSAL_LIMIT_BONE, IDC_RADIO_UNIVERSAL_LIMIT_ANGLES, i );
s1 = SetSafeComboBoxSelection( &m_comboLimitJoint1, constraint->limitAxis.joint1.c_str(), -1 );
s2 = SetSafeComboBoxSelection( &m_comboLimitJoint2, constraint->limitAxis.joint2.c_str(), s1 );
// update displayed values
UpdateData( FALSE );
}
/*
================
DialogAFConstraintUniversal::SaveConstraint
================
*/
void DialogAFConstraintUniversal::SaveConstraint( void ) {
int s1, s2;
CString str;
idAngles angles;
idMat3 mat;
if ( !file || !constraint ) {
return;
}
UpdateData( TRUE );
// anchor
GetSafeComboBoxSelection( &m_comboAnchorJoint, str, -1 );
constraint->anchor.joint1 = str;
constraint->anchor.ToVec3().x = m_anchor_x;
constraint->anchor.ToVec3().y = m_anchor_y;
constraint->anchor.ToVec3().z = m_anchor_z;
// shaft 1
if ( constraint->shaft[0].type == idAFVector::VEC_BONEDIR ) {
s1 = GetSafeComboBoxSelection( &m_comboJoint1Shaft1, str, -1 );
constraint->shaft[0].joint1 = str;
s2 = GetSafeComboBoxSelection( &m_comboJoint2Shaft1, str, s1 );
constraint->shaft[0].joint2 = str;
}
else {
constraint->shaft[0].ToVec3() = idAngles( m_pitchShaft1, m_yawShaft1, 0.0f ).ToForward();
}
// shaft 2
if ( constraint->shaft[1].type == idAFVector::VEC_BONEDIR ) {
s1 = GetSafeComboBoxSelection( &m_comboJoint1Shaft2, str, -1 );
constraint->shaft[1].joint1 = str;
s2 = GetSafeComboBoxSelection( &m_comboJoint2Shaft2, str, s1 );
constraint->shaft[1].joint2 = str;
}
else {
constraint->shaft[1].ToVec3() = idAngles( m_pitchShaft2, m_yawShaft2, 0.0f ).ToForward();
}
// limit
if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
constraint->limitAngles[0] = m_coneAngle;
}
else {
constraint->limitAngles[0] = m_pyramidAngle1;
}
constraint->limitAngles[1] = m_pyramidAngle2;
constraint->limitAngles[2] = m_limitRoll;
angles.pitch = m_limitPitch;
angles.yaw = m_limitYaw;
angles.roll = 0.0f;
constraint->limitAxis.ToVec3() = angles.ToForward();
s1 = GetSafeComboBoxSelection( &m_comboLimitJoint1, str, -1 );
constraint->limitAxis.joint1 = str;
s2 = GetSafeComboBoxSelection( &m_comboLimitJoint2, str, s1 );
constraint->limitAxis.joint2 = str;
AFDialogSetFileModified();
}
/*
================
DialogAFConstraintUniversal::UpdateFile
================
*/
void DialogAFConstraintUniversal::UpdateFile( void ) {
SaveConstraint();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFConstraintUniversal::OnToolHitTest
================
*/
int DialogAFConstraintUniversal::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFConstraintUniversal, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_JOINT, OnBnClickedRadioAnchorJoint)
ON_BN_CLICKED(IDC_RADIO_ANCHOR_COORDINATES, OnBnClickedRadioAnchorCoordinates)
ON_CBN_SELCHANGE(IDC_COMBO_ANCHOR_JOINT, OnCbnSelchangeComboAnchorJoint)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_X, OnEnChangeEditAnchorX)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Y, OnEnChangeEditAnchorY)
ON_EN_CHANGE(IDC_EDIT_ANCHOR_Z, OnEnChangeEditAnchorZ)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_X, OnDeltaposSpinAnchorX)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Y, OnDeltaposSpinAnchorY)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANCHOR_Z, OnDeltaposSpinAnchorZ)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_BONE_SHAFT1, OnBnClickedRadioUniversalBoneShaft1)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1, OnBnClickedRadioUniversalAnglesShaft1)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_JOINT1_SHAFT1, OnCbnSelchangeComboUniversalJoint1Shaft1)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_JOINT2_SHAFT1, OnCbnSelchangeComboUniversalJoint2Shaft1)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_PITCH_SHAFT1, OnEnChangeEditUniversalPitchShaft1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_PITCH_SHAFT1, OnDeltaposSpinUniversalPitchShaft1)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_YAW_SHAFT1, OnEnChangeEditUniversalYawShaft1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_YAW_SHAFT1, OnDeltaposSpinUniversalYawShaft1)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_BONE_SHAFT2, OnBnClickedRadioUniversalBoneShaft2)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2, OnBnClickedRadioUniversalAnglesShaft2)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_JOINT1_SHAFT2, OnCbnSelchangeComboUniversalJoint1Shaft2)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_JOINT2_SHAFT2, OnCbnSelchangeComboUniversalJoint2Shaft2)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_PITCH_SHAFT2, OnEnChangeEditUniversalPitchShaft2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_PITCH_SHAFT2, OnDeltaposSpinUniversalPitchShaft2)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_YAW_SHAFT2, OnEnChangeEditUniversalYawShaft2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_YAW_SHAFT2, OnDeltaposSpinUniversalYawShaft2)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_NONE, OnBnClickedRadioUniversalLimitNone)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_CONE, OnBnClickedRadioUniversalLimitCone)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID, OnBnClickedRadioUniversalLimitPyramid)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE, OnEnChangeEditUniversalLimitConeAngle)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_CONE_ANGLE, OnDeltaposSpinUniversalLimitConeAngle)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1, OnEnChangeEditUniversalLimitPyramidAngle1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_PYRAMID_ANGLE1, OnDeltaposSpinUniversalLimitPyramidAngle1)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2, OnEnChangeEditUniversalLimitPyramidAngle2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_PYRAMID_ANGLE2, OnDeltaposSpinUniversalLimitPyramidAngle2)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_ROLL, OnEnChangeEditUniversalLimitRoll)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_ROLL, OnDeltaposSpinUniversalLimitRoll)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_BONE, OnBnClickedRadioUniversalLimitBone)
ON_BN_CLICKED(IDC_RADIO_UNIVERSAL_LIMIT_ANGLES, OnBnClickedRadioUniversalLimitAngles)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_LIMIT_JOINT1, OnCbnSelchangeComboUniversalLimitJoint1)
ON_CBN_SELCHANGE(IDC_COMBO_UNIVERSAL_LIMIT_JOINT2, OnCbnSelchangeComboUniversalLimitJoint2)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_PITCH, OnEnChangeEditUniversalLimitPitch)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_PITCH, OnDeltaposSpinUniversalLimitPitch)
ON_EN_CHANGE(IDC_EDIT_UNIVERSAL_LIMIT_YAW, OnEnChangeEditUniversalLimitYaw)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_UNIVERSAL_LIMIT_YAW, OnDeltaposSpinUniversalLimitYaw)
END_MESSAGE_MAP()
// DialogAFConstraintUniversal message handlers
BOOL DialogAFConstraintUniversal::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFConstraintUniversal::OnBnClickedRadioAnchorJoint() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_JOINT ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_JOINT;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioAnchorCoordinates() {
if ( IsDlgButtonChecked( IDC_RADIO_ANCHOR_COORDINATES ) ) {
if ( constraint ) {
constraint->anchor.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboAnchorJoint() {
UpdateFile();
}
void DialogAFConstraintUniversal::OnEnChangeEditAnchorX() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) ) ) {
UpdateFile();
}
else {
m_anchor_x = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_X ) );
}
}
void DialogAFConstraintUniversal::OnEnChangeEditAnchorY() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) ) ) {
UpdateFile();
}
else {
m_anchor_y = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Y ) );
}
}
void DialogAFConstraintUniversal::OnEnChangeEditAnchorZ() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) ) ) {
UpdateFile();
}
else {
m_anchor_z = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANCHOR_Z ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_x += 1.0f;
}
else {
m_anchor_x -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_y += 1.0f;
}
else {
m_anchor_y -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_anchor_z += 1.0f;
}
else {
m_anchor_z -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalBoneShaft1() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_BONE_SHAFT1 ) ) {
if ( constraint ) {
constraint->shaft[0].type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalAnglesShaft1() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1 ) ) {
if ( constraint ) {
constraint->shaft[0].type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalJoint1Shaft1() {
CString str;
GetSafeComboBoxSelection( &m_comboJoint1Shaft1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboJoint2Shaft1, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalJoint2Shaft1() {
CString str;
GetSafeComboBoxSelection( &m_comboJoint2Shaft1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboJoint1Shaft1, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalPitchShaft1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_PITCH_SHAFT1 ) ) ) {
UpdateFile();
}
else {
m_pitchShaft1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_PITCH_SHAFT1 ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalPitchShaft1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pitchShaft1 += 1.0f;
}
else {
m_pitchShaft1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalYawShaft1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_YAW_SHAFT1 ) ) ) {
UpdateFile();
}
else {
m_yawShaft1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_YAW_SHAFT1 ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalYawShaft1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_yawShaft1 += 1.0f;
}
else {
m_yawShaft1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalBoneShaft2() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_BONE_SHAFT2 ) ) {
if ( constraint ) {
constraint->shaft[1].type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalAnglesShaft2() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2 ) ) {
if ( constraint ) {
constraint->shaft[1].type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalJoint1Shaft2() {
CString str;
GetSafeComboBoxSelection( &m_comboJoint1Shaft2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboJoint2Shaft2, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalJoint2Shaft2() {
CString str;
GetSafeComboBoxSelection( &m_comboJoint2Shaft2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboJoint1Shaft2, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalPitchShaft2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_PITCH_SHAFT2 ) ) ) {
UpdateFile();
}
else {
m_pitchShaft2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_PITCH_SHAFT2 ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalPitchShaft2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pitchShaft2 += 1.0f;
}
else {
m_pitchShaft2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalYawShaft2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_YAW_SHAFT2 ) ) ) {
UpdateFile();
}
else {
m_yawShaft2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_YAW_SHAFT2 ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalYawShaft2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_yawShaft2 += 1.0f;
}
else {
m_yawShaft2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitNone() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_NONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitCone() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_CONE ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_CONE;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitPyramid() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID ) ) {
if ( constraint ) {
constraint->limit = idDeclAF_Constraint::LIMIT_PYRAMID;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitConeAngle() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE ) ) ) {
UpdateFile();
}
else {
m_coneAngle = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_CONE_ANGLE ), false );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitConeAngle(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_coneAngle += 1.0f;
}
else if ( m_coneAngle > 0.0f ) {
m_coneAngle -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitPyramidAngle1() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1 ) ) ) {
UpdateFile();
}
else {
m_pyramidAngle1 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE1 ), false );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitPyramidAngle1(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pyramidAngle1 += 1.0f;
}
else if ( m_pyramidAngle1 > 0.0f ) {
m_pyramidAngle1 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitPyramidAngle2() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2 ) ) ) {
UpdateFile();
}
else {
m_pyramidAngle2 = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PYRAMID_ANGLE2 ), false );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitPyramidAngle2(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_pyramidAngle2 += 1.0f;
}
else if ( m_pyramidAngle2 > 0.0f ) {
m_pyramidAngle2 -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitRoll() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_ROLL ) ) ) {
UpdateFile();
}
else {
m_limitRoll = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_ROLL ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitRoll(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitRoll += 1.0f;
}
else {
m_limitRoll -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitBone() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_BONE ) ) {
if ( constraint ) {
constraint->limitAxis.type = idAFVector::VEC_BONEDIR;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnBnClickedRadioUniversalLimitAngles() {
if ( IsDlgButtonChecked( IDC_RADIO_UNIVERSAL_LIMIT_ANGLES ) ) {
if ( constraint ) {
constraint->limitAxis.type = idAFVector::VEC_COORDS;
UpdateFile();
}
}
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalLimitJoint1() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitJoint1, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitJoint2, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnCbnSelchangeComboUniversalLimitJoint2() {
CString str;
GetSafeComboBoxSelection( &m_comboLimitJoint2, str, -1 );
UnsetSafeComboBoxSelection( &m_comboLimitJoint1, str );
UpdateFile();
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitPitch() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PITCH ) ) ) {
UpdateFile();
}
else {
m_limitPitch = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_PITCH ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitPitch(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitPitch += 1.0f;
}
else {
m_limitPitch -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}
void DialogAFConstraintUniversal::OnEnChangeEditUniversalLimitYaw() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_YAW ) ) ) {
UpdateFile();
}
else {
m_limitYaw = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_UNIVERSAL_LIMIT_YAW ) );
}
}
void DialogAFConstraintUniversal::OnDeltaposSpinUniversalLimitYaw(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if ( pNMUpDown->iDelta < 0 ) {
m_limitYaw += 1.0f;
}
else {
m_limitYaw -= 1.0f;
}
UpdateData( FALSE );
UpdateFile();
*pResult = 0;
}

View File

@@ -0,0 +1,129 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFConstraintUniversal dialog
class DialogAFConstraintUniversal : public CDialog {
DECLARE_DYNAMIC(DialogAFConstraintUniversal)
public:
DialogAFConstraintUniversal(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFConstraintUniversal();
void LoadFile( idDeclAF *af );
void SaveFile( void );
void LoadConstraint( idDeclAF_Constraint *c );
void SaveConstraint( void );
void UpdateFile( void );
enum { IDD = IDD_DIALOG_AF_CONSTRAINT_UNIVERSAL };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedRadioAnchorJoint();
afx_msg void OnBnClickedRadioAnchorCoordinates();
afx_msg void OnCbnSelchangeComboAnchorJoint();
afx_msg void OnEnChangeEditAnchorX();
afx_msg void OnEnChangeEditAnchorY();
afx_msg void OnEnChangeEditAnchorZ();
afx_msg void OnDeltaposSpinAnchorX(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorY(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDeltaposSpinAnchorZ(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioUniversalBoneShaft1();
afx_msg void OnBnClickedRadioUniversalAnglesShaft1();
afx_msg void OnCbnSelchangeComboUniversalJoint1Shaft1();
afx_msg void OnCbnSelchangeComboUniversalJoint2Shaft1();
afx_msg void OnEnChangeEditUniversalPitchShaft1();
afx_msg void OnDeltaposSpinUniversalPitchShaft1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalYawShaft1();
afx_msg void OnDeltaposSpinUniversalYawShaft1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioUniversalBoneShaft2();
afx_msg void OnBnClickedRadioUniversalAnglesShaft2();
afx_msg void OnCbnSelchangeComboUniversalJoint1Shaft2();
afx_msg void OnCbnSelchangeComboUniversalJoint2Shaft2();
afx_msg void OnEnChangeEditUniversalPitchShaft2();
afx_msg void OnDeltaposSpinUniversalPitchShaft2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalYawShaft2();
afx_msg void OnDeltaposSpinUniversalYawShaft2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioUniversalLimitNone();
afx_msg void OnBnClickedRadioUniversalLimitCone();
afx_msg void OnBnClickedRadioUniversalLimitPyramid();
afx_msg void OnEnChangeEditUniversalLimitConeAngle();
afx_msg void OnDeltaposSpinUniversalLimitConeAngle(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalLimitPyramidAngle1();
afx_msg void OnDeltaposSpinUniversalLimitPyramidAngle1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalLimitPyramidAngle2();
afx_msg void OnDeltaposSpinUniversalLimitPyramidAngle2(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalLimitRoll();
afx_msg void OnDeltaposSpinUniversalLimitRoll(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedRadioUniversalLimitBone();
afx_msg void OnBnClickedRadioUniversalLimitAngles();
afx_msg void OnCbnSelchangeComboUniversalLimitJoint1();
afx_msg void OnCbnSelchangeComboUniversalLimitJoint2();
afx_msg void OnEnChangeEditUniversalLimitPitch();
afx_msg void OnDeltaposSpinUniversalLimitPitch(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditUniversalLimitYaw();
afx_msg void OnDeltaposSpinUniversalLimitYaw(NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
idDeclAF_Constraint*constraint;
//{{AFX_DATA(DialogAFConstraintUniversal)
CComboBox m_comboAnchorJoint;
float m_anchor_x;
float m_anchor_y;
float m_anchor_z;
CComboBox m_comboJoint1Shaft1;
CComboBox m_comboJoint2Shaft1;
float m_pitchShaft1;
float m_yawShaft1;
CComboBox m_comboJoint1Shaft2;
CComboBox m_comboJoint2Shaft2;
float m_pitchShaft2;
float m_yawShaft2;
float m_coneAngle;
float m_pyramidAngle1;
float m_pyramidAngle2;
CComboBox m_comboLimitJoint1;
CComboBox m_comboLimitJoint2;
float m_limitPitch;
float m_limitYaw;
float m_limitRoll;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void InitJointLists( void );
};

View File

@@ -0,0 +1,168 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFName.h"
// DialogAFName dialog
IMPLEMENT_DYNAMIC(DialogAFName, CDialog)
/*
================
DialogAFName::DialogAFName
================
*/
DialogAFName::DialogAFName(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFName::IDD, pParent)
, m_combo(NULL)
{
}
/*
================
DialogAFName::~DialogAFName
================
*/
DialogAFName::~DialogAFName() {
}
/*
================
DialogAFName::DoDataExchange
================
*/
void DialogAFName::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_AF_NAME, m_editName);
}
/*
================
DialogAFName::SetName
================
*/
void DialogAFName::SetName( CString &str ) {
m_editName = str;
}
/*
================
DialogAFName::GetName
================
*/
void DialogAFName::GetName( CString &str ) {
str = m_editName;
}
/*
================
DialogAFName::SetComboBox
================
*/
void DialogAFName::SetComboBox( CComboBox *combo ) {
m_combo = combo;
}
/*
================
DialogAFName::OnInitDialog
================
*/
BOOL DialogAFName::OnInitDialog() {
CEdit *edit;
CString str;
CDialog::OnInitDialog();
edit = (CEdit *)GetDlgItem( IDC_EDIT_AF_NAME );
edit->SetFocus();
edit->GetWindowText( str );
edit->SetSel( 0, str.GetLength() );
return FALSE;
}
/*
================
EditVerifyName
================
*/
void EditVerifyName( CEdit *edit ) {
CString strIn, strOut;
int start, end;
static bool entered = false;
if ( entered ) {
return;
}
entered = true;
edit->GetSel( start, end );
edit->GetWindowText( strIn );
for ( int i = 0; i < strIn.GetLength(); i++ ) {
if ( ( strIn[i] >= 'a' && strIn[i] <= 'z' ) ||
( strIn[i] >= 'A' && strIn[i] <= 'Z' ) ||
( strIn[i] == '_' ) || ( strIn[i] >= '0' && strIn[i] <= '9' ) ) {
strOut.AppendChar( strIn[i] );
}
}
edit->SetWindowText( strOut );
edit->SetSel( start, end );
entered = false;
}
BEGIN_MESSAGE_MAP(DialogAFName, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_EN_CHANGE(IDC_EDIT_AF_NAME, OnEnChangeEditAfName)
END_MESSAGE_MAP()
// DialogAFName message handlers
void DialogAFName::OnBnClickedOk() {
UpdateData( TRUE );
if ( m_combo && m_combo->FindStringExact( -1, m_editName ) != -1 ) {
MessageBox( va( "The name %s is already used.", m_editName.GetBuffer() ), "Name", MB_OK );
}
else {
OnOK();
}
}
void DialogAFName::OnEnChangeEditAfName() {
EditVerifyName( (CEdit *) GetDlgItem( IDC_EDIT_AF_NAME ) );
}

View File

@@ -0,0 +1,56 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFName dialog
class DialogAFName : public CDialog {
DECLARE_DYNAMIC(DialogAFName)
public:
DialogAFName(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFName();
void SetName( CString &str );
void GetName( CString &str );
void SetComboBox( CComboBox *combo );
enum { IDD = IDD_DIALOG_AF_NAME };
protected:
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
afx_msg void OnBnClickedOk();
afx_msg void OnEnChangeEditAfName();
DECLARE_MESSAGE_MAP()
private:
CString m_editName;
CComboBox * m_combo;
};

View File

@@ -0,0 +1,512 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFProperties.h"
#include "DialogAFBody.h"
#include "DialogAFConstraint.h"
// DialogAFProperties dialog
toolTip_t DialogAFProperties::toolTips[] = {
{ IDC_EDIT_MODEL, "model def" },
{ IDC_BUTTON_BROWSE_MODEL, "browse model def" },
{ IDC_EDIT_SKIN, "skin" },
{ IDC_BUTTON_BROWSE_SKIN, "browse skin" },
{ IDC_EDIT_LINEARFRICTION, "translational friction" },
{ IDC_EDIT_ANGULARFRICTION, "rotational friction" },
{ IDC_EDIT_CONTACTFRICTION, "friction with contact surfaces" },
{ IDC_EDIT_CONSTRAINTFRICTION, "constraint friction" },
{ IDC_CHECK_SELFCOLLISION, "allow bodies to collide with other bodies of this articulated figure" },
{ IDC_EDIT_CONTENTS, "content of bodies" },
{ IDC_EDIT_CLIPMASK, "collide with these content types" },
{ IDC_EDIT_TOTALMASS, "scale the mass of each body to get this total mass" },
{ IDC_EDIT_LINEARVELOCITY, "do not suspend simulation if the linear velocity is higher than this value" },
{ IDC_EDIT_ANGULARVELOCITY, "do not suspend simulation if the angular velocity is higher than this value" },
{ IDC_EDIT_LINEARACCELERATION, "do not suspend simulation if the linear acceleration is higher than this value" },
{ IDC_EDIT_ANGULARACCELERATION, "do not suspend simulation if the angular acceleration is higher than this value" },
{ IDC_EDIT_NO_MOVE_TIME, "suspend simulation if hardly any movement for this many seconds" },
{ IDC_EDIT_MAXIMUM_MOVE_TIME, "always suspend simulation after running for this many seconds" },
{ IDC_EDIT_LINEAR_TOLERANCE, "maximum translation considered no movement" },
{ IDC_EDIT_ANGULAR_TOLERANCE, "maximum rotation considered no movement" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFProperties, CDialog)
/*
================
DialogAFProperties::DialogAFProperties
================
*/
DialogAFProperties::DialogAFProperties(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFProperties::IDD, pParent)
, m_selfCollision(false)
, m_linearFriction(0)
, m_angularFriction(0)
, m_contactFriction(0)
, m_constraintFriction(0)
, m_totalMass(0)
, m_suspendLinearVelocity(0)
, m_suspendAngularVelocity(0)
, m_suspendLinearAcceleration(0)
, m_suspendAngularAcceleration(0)
, m_noMoveTime(0)
, m_minMoveTime(0)
, m_maxMoveTime(0)
, m_linearTolerance(0)
, m_angularTolerance(0)
, file(NULL)
{
Create( IDD_DIALOG_AF_PROPERTIES, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFProperties::~DialogAFProperties
================
*/
DialogAFProperties::~DialogAFProperties() {
}
/*
================
DialogAFProperties::DoDataExchange
================
*/
void DialogAFProperties::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFProperties)
DDX_Control(pDX, IDC_EDIT_MODEL, m_editModel);
DDX_Control(pDX, IDC_EDIT_SKIN, m_editSkin);
DDX_Check(pDX, IDC_CHECK_SELFCOLLISION, m_selfCollision);
DDX_Control(pDX, IDC_EDIT_CONTENTS, m_editContents);
DDX_Control(pDX, IDC_EDIT_CLIPMASK, m_editClipMask);
DDX_Text(pDX, IDC_EDIT_LINEARFRICTION, m_linearFriction);
DDX_Text(pDX, IDC_EDIT_ANGULARFRICTION, m_angularFriction);
DDX_Text(pDX, IDC_EDIT_CONTACTFRICTION, m_contactFriction);
DDX_Text(pDX, IDC_EDIT_CONSTRAINTFRICTION, m_constraintFriction);
DDX_Text(pDX, IDC_EDIT_TOTALMASS, m_totalMass);
DDX_Text(pDX, IDC_EDIT_LINEARVELOCITY, m_suspendLinearVelocity);
DDX_Text(pDX, IDC_EDIT_ANGULARVELOCITY, m_suspendAngularVelocity);
DDX_Text(pDX, IDC_EDIT_LINEARACCELERATION, m_suspendLinearAcceleration);
DDX_Text(pDX, IDC_EDIT_ANGULARACCELERATION, m_suspendAngularAcceleration);
DDX_Text(pDX, IDC_EDIT_NO_MOVE_TIME, m_noMoveTime);
DDX_Text(pDX, IDC_EDIT_MINIMUM_MOVE_TIME, m_minMoveTime);
DDX_Text(pDX, IDC_EDIT_MAXIMUM_MOVE_TIME, m_maxMoveTime);
DDX_Text(pDX, IDC_EDIT_LINEAR_TOLERANCE, m_linearTolerance);
DDX_Text(pDX, IDC_EDIT_ANGULAR_TOLERANCE, m_angularTolerance);
//}}AFX_DATA_MAP
}
/*
================
DialogAFProperties::LoadFile
================
*/
void DialogAFProperties::LoadFile( idDeclAF *af ) {
idStr str;
file = af;
if ( !file ) {
ClearFile();
return;
}
m_editModel.SetWindowText( file->model.c_str() );
m_editSkin.SetWindowText( file->skin.c_str() );
m_selfCollision = file->selfCollision;
idDeclAF::ContentsToString( file->contents, str );
m_editContents.SetWindowText( str );
idDeclAF::ContentsToString( file->clipMask, str );
m_editClipMask.SetWindowText( str );
m_linearFriction = file->defaultLinearFriction;
m_angularFriction = file->defaultAngularFriction;
m_contactFriction = file->defaultContactFriction;
m_constraintFriction = file->defaultConstraintFriction;
m_totalMass = file->totalMass;
m_suspendLinearVelocity = file->suspendVelocity[0];
m_suspendAngularVelocity = file->suspendVelocity[1];
m_suspendLinearAcceleration = file->suspendAcceleration[0];
m_suspendAngularAcceleration = file->suspendAcceleration[1];
m_noMoveTime = file->noMoveTime;
m_minMoveTime = file->minMoveTime;
m_maxMoveTime = file->maxMoveTime;
m_linearTolerance = file->noMoveTranslation;
m_angularTolerance = file->noMoveRotation;
UpdateData( FALSE );
}
/*
================
DialogAFProperties::SetFile
================
*/
void DialogAFProperties::SaveFile( void ) {
CString str;
if ( !file ) {
return;
}
UpdateData( TRUE );
m_editModel.GetWindowText( str );
file->model = str;
m_editSkin.GetWindowText( str );
file->skin = str;
file->selfCollision = ( m_selfCollision != FALSE );
m_editContents.GetWindowText( str );
file->contents = idDeclAF::ContentsFromString( str );
m_editClipMask.GetWindowText( str );
file->clipMask = idDeclAF::ContentsFromString( str );
file->defaultLinearFriction = m_linearFriction;
file->defaultAngularFriction = m_angularFriction;
file->defaultContactFriction = m_contactFriction;
file->defaultConstraintFriction = m_constraintFriction;
file->totalMass = m_totalMass;
file->suspendVelocity[0] = m_suspendLinearVelocity;
file->suspendVelocity[1] = m_suspendAngularVelocity;
file->suspendAcceleration[0] = m_suspendLinearAcceleration;
file->suspendAcceleration[1] = m_suspendAngularAcceleration;
file->noMoveTime = m_noMoveTime;
file->minMoveTime = m_minMoveTime;
file->maxMoveTime = m_maxMoveTime;
file->noMoveTranslation = m_linearTolerance;
file->noMoveRotation = m_angularTolerance;
AFDialogSetFileModified();
}
/*
================
DialogAFProperties::UpdateFile
================
*/
void DialogAFProperties::UpdateFile( void ) {
SaveFile();
if ( file ) {
gameEdit->AF_UpdateEntities( file->GetName() );
}
}
/*
================
DialogAFProperties::ClearFile
================
*/
void DialogAFProperties::ClearFile( void ) {
m_editModel.SetWindowText( "" );
m_editSkin.SetWindowText( "" );
m_selfCollision = false;
m_editContents.SetWindowText( "" );
m_editClipMask.SetWindowText( "" );
m_linearFriction = 0.0f;
m_angularFriction = 0.0f;
m_contactFriction = 0.0f;
m_constraintFriction = 0.0f;
m_totalMass = -1.0f;
m_suspendLinearVelocity = 0.0f;
m_suspendAngularVelocity = 0.0f;
m_suspendLinearAcceleration = 0.0f;
m_suspendAngularAcceleration = 0.0f;
m_noMoveTime = 0.0f;
m_minMoveTime = 0.0f;
m_maxMoveTime = 0.0f;
m_linearTolerance = 0.0f;
m_angularTolerance = 0.0f;
UpdateData( FALSE );
}
/*
================
DialogAFProperties::OnToolHitTest
================
*/
int DialogAFProperties::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFProperties, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_EN_CHANGE(IDC_EDIT_MODEL, OnEnChangeEditModel)
ON_BN_CLICKED(IDC_BUTTON_BROWSE_MODEL, OnBnClickedButtonBrowseModel)
ON_EN_CHANGE(IDC_EDIT_SKIN, OnEnChangeEditSkin)
ON_BN_CLICKED(IDC_BUTTON_BROWSE_SKIN, OnBnClickedButtonBrowseSkin)
ON_EN_CHANGE(IDC_EDIT_LINEARFRICTION, OnEnChangeEditLinearfriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_LINEARFRICTION, OnDeltaposSpinLinearfriction)
ON_EN_CHANGE(IDC_EDIT_ANGULARFRICTION, OnEnChangeEditAngularfriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ANGULARFRICTION, OnDeltaposSpinAngularfriction)
ON_EN_CHANGE(IDC_EDIT_CONTACTFRICTION, OnEnChangeEditContactfriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_CONTACTFRICTION, OnDeltaposSpinContactfriction)
ON_EN_CHANGE(IDC_EDIT_CONSTRAINTFRICTION, OnEnChangeEditConstraintfriction)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_CONSTRAINTFRICTION, OnDeltaposSpinConstraintfriction)
ON_BN_CLICKED(IDC_CHECK_SELFCOLLISION, OnBnClickedCheckSelfcollision)
ON_EN_CHANGE(IDC_EDIT_CONTENTS, OnEnChangeEditContents)
ON_EN_CHANGE(IDC_EDIT_CLIPMASK, OnEnChangeEditClipmask)
ON_EN_CHANGE(IDC_EDIT_TOTALMASS, OnEnChangeEditTotalmass)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_TOTALMASS, OnDeltaposSpinTotalmass)
ON_EN_CHANGE(IDC_EDIT_LINEARVELOCITY, OnEnChangeEditLinearvelocity)
ON_EN_CHANGE(IDC_EDIT_ANGULARVELOCITY, OnEnChangeEditAngularvelocity)
ON_EN_CHANGE(IDC_EDIT_LINEARACCELERATION, OnEnChangeEditLinearacceleration)
ON_EN_CHANGE(IDC_EDIT_ANGULARACCELERATION, OnEnChangeEditAngularacceleration)
ON_EN_CHANGE(IDC_EDIT_NO_MOVE_TIME, OnEnChangeEditNomovetime)
ON_EN_CHANGE(IDC_EDIT_MINIMUM_MOVE_TIME, OnEnChangeEditMinimummovetime)
ON_EN_CHANGE(IDC_EDIT_MAXIMUM_MOVE_TIME, OnEnChangeEditMaximummovetime)
ON_EN_CHANGE(IDC_EDIT_LINEAR_TOLERANCE, OnEnChangeEditLineartolerance)
ON_EN_CHANGE(IDC_EDIT_ANGULAR_TOLERANCE, OnEnChangeEditAngulartolerance)
END_MESSAGE_MAP()
// DialogAFProperties message handlers
BOOL DialogAFProperties::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFProperties::OnEnChangeEditModel() {
if ( EditControlEnterHit( &m_editModel ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditSkin() {
if ( EditControlEnterHit( &m_editSkin ) ) {
UpdateFile();
// reload the .af file
AFDialogReloadFile();
}
}
void DialogAFProperties::OnBnClickedCheckSelfcollision() {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Self Collision", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->selfCollision = file->selfCollision;
}
bodyDlg->LoadFile( file );
}
}
void DialogAFProperties::OnEnChangeEditContents() {
if ( EditControlEnterHit( &m_editContents ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Contents", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->contents = file->contents;
}
bodyDlg->LoadFile( file );
}
}
}
void DialogAFProperties::OnEnChangeEditClipmask() {
if ( EditControlEnterHit( &m_editClipMask ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Clip Mask", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->clipMask = file->clipMask;
}
bodyDlg->LoadFile( file );
}
}
}
void DialogAFProperties::OnEnChangeEditLinearfriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEARFRICTION ) ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Linear Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->linearFriction = file->defaultLinearFriction;
}
bodyDlg->LoadFile( file );
}
}
else {
m_linearFriction = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_LINEARFRICTION ), false );
}
}
void DialogAFProperties::OnDeltaposSpinLinearfriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_linearFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_LINEARFRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditAngularfriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARFRICTION ) ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Angular Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->angularFriction = file->defaultAngularFriction;
}
bodyDlg->LoadFile( file );
}
}
else {
m_angularFriction = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARFRICTION ), false );
}
}
void DialogAFProperties::OnDeltaposSpinAngularfriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_angularFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_ANGULARFRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditContactfriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_CONTACTFRICTION ) ) ) {
UpdateFile();
if ( file && file->bodies.Num() && MessageBox( "Apply to all bodies ?", "Contact Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->bodies.Num(); i++ ) {
file->bodies[i]->contactFriction = file->defaultContactFriction;
}
bodyDlg->LoadFile( file );
}
}
else {
m_contactFriction = EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_CONTACTFRICTION ), false );
}
}
void DialogAFProperties::OnDeltaposSpinContactfriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_contactFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_CONTACTFRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditConstraintfriction() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINTFRICTION ) ) ) {
UpdateFile();
if ( file && file->constraints.Num() && MessageBox( "Apply to all constraints ?", "Constraint Friction", MB_YESNO | MB_ICONQUESTION ) == IDYES ) {
for ( int i = 0; i < file->constraints.Num(); i++ ) {
file->constraints[i]->friction = file->defaultConstraintFriction;
}
constraintDlg->LoadFile( file );
}
}
else {
EditVerifyFloat( (CEdit *) GetDlgItem( IDC_EDIT_CONSTRAINTFRICTION ), false );
}
}
void DialogAFProperties::OnDeltaposSpinConstraintfriction(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_constraintFriction = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_CONSTRAINTFRICTION ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditTotalmass() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_TOTALMASS ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnDeltaposSpinTotalmass(NMHDR *pNMHDR, LRESULT *pResult) {
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
m_totalMass = EditSpinFloat( (CEdit *)GetDlgItem( IDC_EDIT_TOTALMASS ), pNMUpDown->iDelta < 0 );
UpdateFile();
*pResult = 0;
}
void DialogAFProperties::OnEnChangeEditLinearvelocity() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEARVELOCITY ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditAngularvelocity() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARVELOCITY ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditLinearacceleration() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEARACCELERATION ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditAngularacceleration() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULARACCELERATION ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditNomovetime() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_NO_MOVE_TIME ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditMinimummovetime() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_MINIMUM_MOVE_TIME ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditMaximummovetime() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_MAXIMUM_MOVE_TIME ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditLineartolerance() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_LINEAR_TOLERANCE ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnEnChangeEditAngulartolerance() {
if ( EditControlEnterHit( (CEdit *) GetDlgItem( IDC_EDIT_ANGULAR_TOLERANCE ) ) ) {
UpdateFile();
}
}
void DialogAFProperties::OnBnClickedButtonBrowseModel() {
// m_editModel.SetWindowText( str );
// UpdateFile();
}
void DialogAFProperties::OnBnClickedButtonBrowseSkin() {
// m_editSkin.SetWindowText( str );
// UpdateFile();
// reload the .af file
// AFDialogReloadFile();
}

View File

@@ -0,0 +1,110 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFProperties dialog
class DialogAFProperties : public CDialog {
DECLARE_DYNAMIC(DialogAFProperties)
public:
DialogAFProperties( CWnd* pParent = NULL ); // standard constructor
virtual ~DialogAFProperties();
void LoadFile( idDeclAF *af );
void SaveFile( void );
DialogAFBody * bodyDlg;
DialogAFConstraint *constraintDlg;
enum { IDD = IDD_DIALOG_AF_PROPERTIES };
protected:
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnEnChangeEditModel();
afx_msg void OnEnChangeEditSkin();
afx_msg void OnBnClickedButtonBrowseModel();
afx_msg void OnBnClickedButtonBrowseSkin();
afx_msg void OnBnClickedCheckSelfcollision();
afx_msg void OnEnChangeEditContents();
afx_msg void OnEnChangeEditClipmask();
afx_msg void OnEnChangeEditLinearfriction();
afx_msg void OnDeltaposSpinLinearfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditAngularfriction();
afx_msg void OnDeltaposSpinAngularfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditContactfriction();
afx_msg void OnDeltaposSpinContactfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditConstraintfriction();
afx_msg void OnDeltaposSpinConstraintfriction(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditTotalmass();
afx_msg void OnDeltaposSpinTotalmass(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEnChangeEditLinearvelocity();
afx_msg void OnEnChangeEditAngularvelocity();
afx_msg void OnEnChangeEditLinearacceleration();
afx_msg void OnEnChangeEditAngularacceleration();
afx_msg void OnEnChangeEditNomovetime();
afx_msg void OnEnChangeEditMinimummovetime();
afx_msg void OnEnChangeEditMaximummovetime();
afx_msg void OnEnChangeEditLineartolerance();
afx_msg void OnEnChangeEditAngulartolerance();
DECLARE_MESSAGE_MAP()
private:
idDeclAF * file;
//{{AFX_DATA(DialogAFProperties)
CEdit m_editModel;
CEdit m_editSkin;
BOOL m_selfCollision;
CEdit m_editContents;
CEdit m_editClipMask;
float m_linearFriction;
float m_angularFriction;
float m_contactFriction;
float m_constraintFriction;
float m_totalMass;
float m_suspendLinearVelocity;
float m_suspendAngularVelocity;
float m_suspendLinearAcceleration;
float m_suspendAngularAcceleration;
float m_noMoveTime;
float m_minMoveTime;
float m_maxMoveTime;
float m_linearTolerance;
float m_angularTolerance;
//}}AFX_DATA
static toolTip_t toolTips[];
private:
void UpdateFile( void );
void ClearFile( void );
};

View File

@@ -0,0 +1,324 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/AFEditor_resource.h"
#include "DialogAF.h"
#include "DialogAFView.h"
// DialogAFView dialog
toolTip_t DialogAFView::toolTips[] = {
{ IDC_CHECK_VIEW_BODIES, "show bodies" },
{ IDC_CHECK_VIEW_BODYNAMES, "show body names" },
{ IDC_CHECK_VIEW_BODYMASS, "show body mass" },
{ IDC_CHECK_VIEW_TOTALMASS, "show total mass" },
{ IDC_CHECK_VIEW_INERTIATENSOR, "show body inertia tensor" },
{ IDC_CHECK_VIEW_VELOCITY, "show body velocity" },
{ IDC_CHECK_VIEW_CONSTRAINTNAMES, "show constraint names" },
{ IDC_CHECK_VIEW_CONSTRAINTS, "show constraints" },
{ IDC_CHECK_VIEW_PRIMARYONLY, "show only primary constraints" },
{ IDC_CHECK_VIEW_LIMITS, "show constraint limits" },
{ IDC_CHECK_VIEW_CONSTRAINEDBODIES, "show bodies constrained by current constraint (body1 = cyan, body2 = blue)" },
{ IDC_CHECK_VIEW_TREES, "show tree structures" },
{ IDC_CHECK_MD5_SKELETON, "show md5 with skeleton" },
{ IDC_CHECK_MD5_SKELETONONLY, "show only the md5 skeleton" },
{ IDC_CHECK_LINES_DEPTHTEST, "zbuffer lines" },
{ IDC_CHECK_LINES_USEARROWS, "use arrows" },
{ IDC_CHECK_PHYSICS_NOFRICTION, "disable all friction" },
{ IDC_CHECK_PHYSICS_NOLIMITS, "disable all joint limits" },
{ IDC_CHECK_PHYSICS_NOGRAVITY, "disable gravity" },
{ IDC_CHECK_PHYSICS_NOSELFCOLLISION, "disable self collision detection" },
{ IDC_CHECK_PHYSICS_TIMING, "show performance timings" },
{ IDC_CHECK_PHYSICS_DRAG_ENTITIES, "drag entities" },
{ IDC_CHECK_PHYSICS_SHOW_DRAG_SELECTION, "show selection box around the entity selected for dragging" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogAFView, CDialog)
/*
================
DialogAFView::DialogAFView
================
*/
DialogAFView::DialogAFView(CWnd* pParent /*=NULL*/)
: CDialog(DialogAFView::IDD, pParent)
{
m_showBodies = cvarSystem->GetCVarBool( "af_showBodies" );
m_showBodyNames = cvarSystem->GetCVarBool( "af_showBodyNames" );
m_showMass = cvarSystem->GetCVarBool( "af_showMass" );
m_showTotalMass = cvarSystem->GetCVarBool( "af_showTotalMass" );
m_showInertia = cvarSystem->GetCVarBool( "af_showInertia" );
m_showVelocity = cvarSystem->GetCVarBool( "af_showVelocity" );
m_showConstraints = cvarSystem->GetCVarBool( "af_showConstraints" );
m_showConstraintNames = cvarSystem->GetCVarBool( "af_showConstraintNames" );
m_showPrimaryOnly = cvarSystem->GetCVarBool( "af_showPrimaryOnly" );
m_showLimits = cvarSystem->GetCVarBool( "af_showLimits" );
m_showConstrainedBodies = cvarSystem->GetCVarBool( "af_showConstrainedBodies" );
m_showTrees = cvarSystem->GetCVarBool( "af_showTrees" );
m_showSkeleton = cvarSystem->GetCVarInteger( "af_showSkel" ) == 1;
m_showSkeletonOnly = cvarSystem->GetCVarInteger( "af_showSkel" ) == 2;
m_debugLineDepthTest = cvarSystem->GetCVarBool( "r_debugLineDepthTest" );
m_debugLineUseArrows = cvarSystem->GetCVarInteger( "r_debugArrowStep" ) != 0;
m_noFriction = cvarSystem->GetCVarBool( "af_skipFriction" );
m_noLimits = cvarSystem->GetCVarBool( "af_skipLimits" );
m_gravity = cvarSystem->GetCVarFloat( "g_gravity" );
m_noGravity = ( m_gravity == 0.0f );
m_noSelfCollision = cvarSystem->GetCVarBool( "af_skipSelfCollision" );
m_showTimings = cvarSystem->GetCVarBool( "af_showTimings" );
m_dragEntity = cvarSystem->GetCVarBool( "g_dragEntity" );
m_dragShowSelection = cvarSystem->GetCVarBool( "g_dragShowSelection" );
Create( IDD_DIALOG_AF_VIEW, pParent );
EnableToolTips( TRUE );
}
/*
================
DialogAFView::~DialogAFView
================
*/
DialogAFView::~DialogAFView() {
}
/*
================
DialogAFView::DoDataExchange
================
*/
void DialogAFView::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogAFView)
DDX_Check(pDX, IDC_CHECK_VIEW_BODIES, m_showBodies);
DDX_Check(pDX, IDC_CHECK_VIEW_BODYNAMES, m_showBodyNames);
DDX_Check(pDX, IDC_CHECK_VIEW_BODYMASS, m_showMass);
DDX_Check(pDX, IDC_CHECK_VIEW_TOTALMASS, m_showTotalMass);
DDX_Check(pDX, IDC_CHECK_VIEW_INERTIATENSOR, m_showInertia);
DDX_Check(pDX, IDC_CHECK_VIEW_VELOCITY, m_showVelocity);
DDX_Check(pDX, IDC_CHECK_VIEW_CONSTRAINTS, m_showConstraints);
DDX_Check(pDX, IDC_CHECK_VIEW_CONSTRAINTNAMES, m_showConstraintNames);
DDX_Check(pDX, IDC_CHECK_VIEW_PRIMARYONLY, m_showPrimaryOnly);
DDX_Check(pDX, IDC_CHECK_VIEW_LIMITS, m_showLimits);
DDX_Check(pDX, IDC_CHECK_VIEW_CONSTRAINEDBODIES, m_showConstrainedBodies);
DDX_Check(pDX, IDC_CHECK_VIEW_TREES, m_showTrees);
DDX_Check(pDX, IDC_CHECK_MD5_SKELETON, m_showSkeleton);
DDX_Check(pDX, IDC_CHECK_MD5_SKELETONONLY, m_showSkeletonOnly);
DDX_Check(pDX, IDC_CHECK_LINES_DEPTHTEST, m_debugLineDepthTest);
DDX_Check(pDX, IDC_CHECK_LINES_USEARROWS, m_debugLineUseArrows);
DDX_Check(pDX, IDC_CHECK_PHYSICS_NOFRICTION, m_noFriction);
DDX_Check(pDX, IDC_CHECK_PHYSICS_NOLIMITS, m_noLimits);
DDX_Check(pDX, IDC_CHECK_PHYSICS_NOGRAVITY, m_noGravity);
DDX_Check(pDX, IDC_CHECK_PHYSICS_NOSELFCOLLISION, m_noSelfCollision);
DDX_Check(pDX, IDC_CHECK_PHYSICS_TIMING, m_showTimings);
DDX_Check(pDX, IDC_CHECK_PHYSICS_DRAG_ENTITIES, m_dragEntity);
DDX_Check(pDX, IDC_CHECK_PHYSICS_SHOW_DRAG_SELECTION, m_dragShowSelection);
//}}AFX_DATA_MAP
}
/*
================
DialogAFView::OnToolHitTest
================
*/
int DialogAFView::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const {
CDialog::OnToolHitTest( point, pTI );
return DefaultOnToolHitTest( toolTips, this, point, pTI );
}
BEGIN_MESSAGE_MAP(DialogAFView, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_BN_CLICKED(IDC_CHECK_VIEW_BODIES, OnBnClickedCheckViewBodies)
ON_BN_CLICKED(IDC_CHECK_VIEW_BODYNAMES, OnBnClickedCheckViewBodynames)
ON_BN_CLICKED(IDC_CHECK_VIEW_BODYMASS, OnBnClickedCheckViewBodyMass)
ON_BN_CLICKED(IDC_CHECK_VIEW_TOTALMASS, OnBnClickedCheckViewTotalMass)
ON_BN_CLICKED(IDC_CHECK_VIEW_INERTIATENSOR, OnBnClickedCheckViewInertiatensor)
ON_BN_CLICKED(IDC_CHECK_VIEW_VELOCITY, OnBnClickedCheckViewVelocity)
ON_BN_CLICKED(IDC_CHECK_VIEW_CONSTRAINTS, OnBnClickedCheckViewConstraints)
ON_BN_CLICKED(IDC_CHECK_VIEW_CONSTRAINTNAMES, OnBnClickedCheckViewConstraintnames)
ON_BN_CLICKED(IDC_CHECK_VIEW_PRIMARYONLY, OnBnClickedCheckViewPrimaryonly)
ON_BN_CLICKED(IDC_CHECK_VIEW_LIMITS, OnBnClickedCheckViewLimits)
ON_BN_CLICKED(IDC_CHECK_VIEW_CONSTRAINEDBODIES, OnBnClickedCheckViewConstrainedBodies)
ON_BN_CLICKED(IDC_CHECK_VIEW_TREES, OnBnClickedCheckViewTrees)
ON_BN_CLICKED(IDC_CHECK_MD5_SKELETON, OnBnClickedCheckMd5Skeleton)
ON_BN_CLICKED(IDC_CHECK_MD5_SKELETONONLY, OnBnClickedCheckMd5Skeletononly)
ON_BN_CLICKED(IDC_CHECK_LINES_DEPTHTEST, OnBnClickedCheckLinesDepthtest)
ON_BN_CLICKED(IDC_CHECK_LINES_USEARROWS, OnBnClickedCheckLinesUsearrows)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_NOFRICTION, OnBnClickedCheckPhysicsNofriction)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_NOLIMITS, OnBnClickedCheckPhysicsNolimits)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_NOGRAVITY, OnBnClickedCheckPhysicsNogravity)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_NOSELFCOLLISION, OnBnClickedCheckPhysicsNoselfcollision)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_TIMING, OnBnClickedCheckPhysicsTiming)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_DRAG_ENTITIES, OnBnClickedCheckPhysicsDragEntities)
ON_BN_CLICKED(IDC_CHECK_PHYSICS_SHOW_DRAG_SELECTION, OnBnClickedCheckPhysicsShowDragSelection)
END_MESSAGE_MAP()
// DialogAFView message handlers
BOOL DialogAFView::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
void DialogAFView::OnBnClickedCheckViewBodies() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showBodies", m_showBodies != FALSE );
}
void DialogAFView::OnBnClickedCheckViewBodynames() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showBodyNames", m_showBodyNames != FALSE );
}
void DialogAFView::OnBnClickedCheckViewBodyMass() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showMass", m_showMass != FALSE );
}
void DialogAFView::OnBnClickedCheckViewTotalMass() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showTotalMass", m_showTotalMass != FALSE );
}
void DialogAFView::OnBnClickedCheckViewInertiatensor() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showInertia", m_showInertia != FALSE );
}
void DialogAFView::OnBnClickedCheckViewVelocity() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showVelocity", m_showVelocity != FALSE );
}
void DialogAFView::OnBnClickedCheckViewConstraints() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showConstraints", m_showConstraints != FALSE );
}
void DialogAFView::OnBnClickedCheckViewConstraintnames() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showConstraintNames", m_showConstraintNames != FALSE );
}
void DialogAFView::OnBnClickedCheckViewPrimaryonly() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showPrimaryOnly", m_showPrimaryOnly != FALSE );
}
void DialogAFView::OnBnClickedCheckViewLimits() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showLimits", m_showLimits != FALSE );
}
void DialogAFView::OnBnClickedCheckViewConstrainedBodies() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showConstrainedBodies", m_showConstrainedBodies != FALSE );
}
void DialogAFView::OnBnClickedCheckViewTrees() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showTrees", m_showTrees != FALSE );
}
void DialogAFView::OnBnClickedCheckMd5Skeleton() {
UpdateData(TRUE);
if ( !m_showSkeletonOnly ) {
if ( m_showSkeleton ) {
cvarSystem->SetCVarInteger( "r_showSkel", 1 );
} else {
cvarSystem->SetCVarInteger( "r_showSkel", 0 );
}
}
}
void DialogAFView::OnBnClickedCheckMd5Skeletononly() {
UpdateData(TRUE);
if ( m_showSkeletonOnly ) {
cvarSystem->SetCVarInteger( "r_showSkel", 2 );
} else {
if ( m_showSkeleton ) {
cvarSystem->SetCVarInteger( "r_showSkel", 1 );
} else {
cvarSystem->SetCVarInteger( "r_showSkel", 0 );
}
}
}
void DialogAFView::OnBnClickedCheckLinesDepthtest() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "r_debugLineDepthTest", m_debugLineDepthTest != FALSE );
}
void DialogAFView::OnBnClickedCheckLinesUsearrows() {
UpdateData(TRUE);
if ( m_debugLineUseArrows ) {
cvarSystem->SetCVarInteger( "r_debugArrowStep", 120 );
} else {
cvarSystem->SetCVarInteger( "r_debugArrowStep", 0 );
}
}
void DialogAFView::OnBnClickedCheckPhysicsNofriction() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_skipFriction", m_noFriction != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsNolimits() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_skipLimits", m_noLimits != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsNogravity() {
UpdateData(TRUE);
cvarSystem->SetCVarFloat( "g_gravity", m_noGravity ? 0.0f : m_gravity );
}
void DialogAFView::OnBnClickedCheckPhysicsNoselfcollision() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_skipSelfCollision", m_noSelfCollision != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsTiming() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "af_showTimings", m_showTimings != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsDragEntities() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "g_dragEntity", m_dragEntity != FALSE );
}
void DialogAFView::OnBnClickedCheckPhysicsShowDragSelection() {
UpdateData(TRUE);
cvarSystem->SetCVarBool( "g_dragShowSelection", m_dragShowSelection != FALSE );
}

102
neo/tools/af/DialogAFView.h Normal file
View File

@@ -0,0 +1,102 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
// DialogAFView dialog
class DialogAFView : public CDialog {
DECLARE_DYNAMIC(DialogAFView)
public:
DialogAFView(CWnd* pParent = NULL); // standard constructor
virtual ~DialogAFView();
enum { IDD = IDD_DIALOG_AF_VIEW };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnBnClickedCheckViewBodies();
afx_msg void OnBnClickedCheckViewBodynames();
afx_msg void OnBnClickedCheckViewBodyMass();
afx_msg void OnBnClickedCheckViewTotalMass();
afx_msg void OnBnClickedCheckViewInertiatensor();
afx_msg void OnBnClickedCheckViewVelocity();
afx_msg void OnBnClickedCheckViewConstraints();
afx_msg void OnBnClickedCheckViewConstraintnames();
afx_msg void OnBnClickedCheckViewPrimaryonly();
afx_msg void OnBnClickedCheckViewLimits();
afx_msg void OnBnClickedCheckViewConstrainedBodies();
afx_msg void OnBnClickedCheckViewTrees();
afx_msg void OnBnClickedCheckMd5Skeleton();
afx_msg void OnBnClickedCheckMd5Skeletononly();
afx_msg void OnBnClickedCheckLinesDepthtest();
afx_msg void OnBnClickedCheckLinesUsearrows();
afx_msg void OnBnClickedCheckPhysicsNofriction();
afx_msg void OnBnClickedCheckPhysicsNolimits();
afx_msg void OnBnClickedCheckPhysicsNogravity();
afx_msg void OnBnClickedCheckPhysicsNoselfcollision();
afx_msg void OnBnClickedCheckPhysicsTiming();
afx_msg void OnBnClickedCheckPhysicsDragEntities();
afx_msg void OnBnClickedCheckPhysicsShowDragSelection();
DECLARE_MESSAGE_MAP()
private:
//{{AFX_DATA(DialogAFView)
BOOL m_showBodies;
BOOL m_showBodyNames;
BOOL m_showMass;
BOOL m_showTotalMass;
BOOL m_showInertia;
BOOL m_showVelocity;
BOOL m_showConstraints;
BOOL m_showConstraintNames;
BOOL m_showPrimaryOnly;
BOOL m_showLimits;
BOOL m_showConstrainedBodies;
BOOL m_showTrees;
BOOL m_showSkeleton;
BOOL m_showSkeletonOnly;
BOOL m_debugLineDepthTest;
BOOL m_debugLineUseArrows;
BOOL m_noFriction;
BOOL m_noLimits;
BOOL m_noGravity;
BOOL m_noSelfCollision;
BOOL m_showTimings;
BOOL m_dragEntity;
BOOL m_dragShowSelection;
//}}AFX_DATA
float m_gravity;
static toolTip_t toolTips[];
};

1022
neo/tools/comafx/CDIB.cpp Normal file

File diff suppressed because it is too large Load Diff

121
neo/tools/comafx/CDIB.h Normal file
View File

@@ -0,0 +1,121 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __CDIB__
#define __CDIB__
// Original ColorPicker/DIB source by Rajiv Ramachandran <rrajivram@hotmail.com>
// included with permission from the author
class CDIB {
public:
enum BitmapType {
BMP,
GIF,
TIFF
};
CDIB( HANDLE hDib = NULL,int nBits = 8 );
virtual ~CDIB();
CDIB & operator=( CDIB& dib );
BOOL IsValid() { return ( m_pVoid && Width() && Height() ); }
void UseGamma( float fg, BOOL bUse = TRUE );
BOOL CreateFromHandle( HANDLE hDib, int nBits );
BOOL Create( int width, int height, int bits = 24 );
BOOL Create( BITMAPINFOHEADER& bmInfo );
BOOL CopyDIB( CDIB& dib );
BOOL OpenDIB( CString &fileName );
BOOL SaveDIB( CString &fileName, BitmapType type );
void ReplaceColor(unsigned char oldColor,unsigned char newColor);
HANDLE GetDIBits(int nStartX=-1,int nStartY=-1,int nCx=-1,int nCy=-1);
CBitmap * GetBitmap(CDC& dc);
CBitmap * GetTempBitmap(CDC& dc);
DWORD GetDIBSize();
int GetPaletteSize(BITMAPINFOHEADER& bmInfo);
int GetPaletteSize();
int CountColors();
int EnumColors(BYTE *colors);
void InitDIB(COLORREF color);
void CopyLine(int source,int dest);
void DestroyDIB();
void SetPalette(unsigned char *palette);
void SetPalette(RGBQUAD *pRGB);
COLORREF PaletteColor(int index);
void SetPixel(int x,int y,COLORREF color);
void SetPixel8(int x,int y,unsigned char color);
COLORREF GetPixel(int x,int y);
void GetPixel(UINT x,UINT y,int& pixel);
void BitBlt(HDC hDest,int nXDest,int nYDest,int nWidth,int nHeight,int xSrc,int ySrc);
void BitBlt(int nXDest,int nYDest,int nWidth,int nHeight,CDIB& dibSrc,int nSrcX,int nSrcY,BYTE *colors=NULL);
void StretchBlt(HDC hDest,int nXDest,int nYDest,int nDWidth,int nDHeight,int xSrc,int ySrc,int nSWidth,int nSHeight);
void StretchBlt(int nXDest,int nYDest,int nDWidth,int nDHeight,CDIB& dibSrc,int xSrc,int ySrc,int nSWidth,int nSHeight);
void ExpandBlt(int nXDest,int nYDest,int xRatio,int yRatio,CDIB& dibSrc,int xSrc,int ySrc,int nSWidth,int nSHeight);
void SetFlags(int flag) { m_nFlags = flag; }
int Height() { return height ; }
int Width() { return width ; }
unsigned char *GetLinePtr(int line);
inline int GetBitCount() { return m_pInfo->bmiHeader.biBitCount; }
BOOL Make8Bit( CDIB &dib );
BOOL SwitchFromOne( CDIB &dib );
BOOL SwitchFromFour( CDIB &dib );
BOOL SwitchFrom24( CDIB &dib );
BOOL SwitchPalette( CDIB &dib );
int ClosestColor(RGBQUAD *pRgb );
LPBITMAPINFO GetBitmapInfo() { return m_pInfo; }
static unsigned int Distance( RGBQUAD& rgb1, RGBQUAD& rgb2 );
protected:
HANDLE DIBHandle();
BOOL OpenBMP( CString &csFileName );
BOOL OpenGIF( CString &csFileName );
BOOL OpenTIFF( CString &csFileName );
BOOL SaveBMP( CString &csFileName );
BOOL SaveGIF( CString &csFileName );
BOOL SaveTIFF( CString &csFileName );
void CreateGammaCurve();
void Expand( int nXDest, int nYDest, int xRatio, int yRatio, CDIB &dibSrc, int xSrc, int ySrc, int nSWidth, int nSHeight );
unsigned char * m_pBits;
PBITMAPINFO m_pInfo;
RGBQUAD * m_pRGB;
void * m_pVoid;
BYTE ** m_pLinePtr;
int height;
int bytes;
int width;
int m_nBits;
int m_nFlags;
BOOL m_bUseGamma;
float m_fGamma;
float m_fOldGamma;
unsigned char Gamma[256];
RGBQUAD CacheQuad[256];
char CachePtr[256];
};
#endif /* !__CDIB__ */

View File

@@ -0,0 +1,305 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "CPathTreeCtrl.h"
/*
================
CPathTreeCtrl::CPathTreeCtrl
================
*/
CPathTreeCtrl::CPathTreeCtrl() {
}
/*
================
CPathTreeCtrl::~CPathTreeCtrl
================
*/
CPathTreeCtrl::~CPathTreeCtrl() {
}
/*
================
CPathTreeCtrl::PreSubclassWindow
================
*/
void CPathTreeCtrl::PreSubclassWindow() {
CTreeCtrl::PreSubclassWindow();
EnableToolTips( TRUE );
}
/*
================
CPathTreeCtrl::FindItem
Find the given path in the tree.
================
*/
HTREEITEM CPathTreeCtrl::FindItem( const idStr &pathName ) {
int lastSlash;
idStr path, tmpPath, itemName;
HTREEITEM item, parentItem;
parentItem = NULL;
item = GetRootItem();
lastSlash = pathName.Last( '/' );
while( item && lastSlash > path.Length() ) {
itemName = GetItemText( item );
tmpPath = path + itemName;
if ( pathName.Icmpn( tmpPath, tmpPath.Length() ) == 0 ) {
parentItem = item;
item = GetChildItem( item );
path = tmpPath + "/";
} else {
item = GetNextSiblingItem( item );
}
}
for ( item = GetChildItem( parentItem ); item; item = GetNextSiblingItem( item ) ) {
itemName = GetItemText( item );
if ( pathName.Icmp( path + itemName ) == 0 ) {
return item;
}
}
return NULL;
}
/*
================
CPathTreeCtrl::InsertPathIntoTree
Inserts a new item going from the root down the tree only creating paths where necessary.
This is slow and should only be used to insert single items.
================
*/
HTREEITEM CPathTreeCtrl::InsertPathIntoTree( const idStr &pathName, const int id ) {
int lastSlash;
idStr path, tmpPath, itemName;
HTREEITEM item, parentItem;
parentItem = NULL;
item = GetRootItem();
lastSlash = pathName.Last( '/' );
while( item && lastSlash > path.Length() ) {
itemName = GetItemText( item );
tmpPath = path + itemName;
if ( pathName.Icmpn( tmpPath, tmpPath.Length() ) == 0 ) {
parentItem = item;
item = GetChildItem( item );
path = tmpPath + "/";
} else {
item = GetNextSiblingItem( item );
}
}
while( lastSlash > path.Length() ) {
pathName.Mid( path.Length(), pathName.Length(), tmpPath );
tmpPath.Left( tmpPath.Find( '/' ), itemName );
parentItem = InsertItem( itemName, parentItem );
path += itemName + "/";
}
pathName.Mid( path.Length(), pathName.Length(), itemName );
item = InsertItem( itemName, parentItem, TVI_SORT );
SetItemData( item, id );
return item;
}
/*
================
CPathTreeCtrl::AddPathToTree
Adds a new item to the tree.
Assumes new paths after the current stack path do not yet exist.
================
*/
HTREEITEM CPathTreeCtrl::AddPathToTree( const idStr &pathName, const int id, idPathTreeStack &stack ) {
int lastSlash;
idStr itemName, tmpPath;
HTREEITEM item;
lastSlash = pathName.Last( '/' );
while( stack.Num() > 1 ) {
if ( pathName.Icmpn( stack.TopName(), stack.TopNameLength() ) == 0 ) {
break;
}
stack.Pop();
}
while( lastSlash > stack.TopNameLength() ) {
pathName.Mid( stack.TopNameLength(), pathName.Length(), tmpPath );
tmpPath.Left( tmpPath.Find( '/' ), itemName );
item = InsertItem( itemName, stack.TopItem() );
stack.Push( item, itemName );
}
pathName.Mid( stack.TopNameLength(), pathName.Length(), itemName );
item = InsertItem( itemName, stack.TopItem() );
SetItemData( item, id );
return item;
}
/*
================
CPathTreeCtrl::SearchTree
Search the three using the search string.
Adds the matched tree items to the result tree.
Returns the number of items added to the result tree.
================
*/
int CPathTreeCtrl::SearchTree( treeItemCompare_t compare, void *data, CPathTreeCtrl &result ) {
idPathTreeStack stack, searchStack;
HTREEITEM item, child;
idStr name;
int id, numItems;
numItems = 0;
result.DeleteAllItems();
stack.PushRoot( NULL );
item = GetRootItem();
searchStack.PushRoot( item );
id = 0;
while( searchStack.Num() > 0 ) {
for ( child = GetChildItem( item ); child; child = GetChildItem( child ) ) {
searchStack.Push( item, GetItemText( item ) );
item = child;
}
name = searchStack.TopName();
name += GetItemText( item );
id = GetItemData( item );
if ( compare( data, item, name ) ) {
result.AddPathToTree( name, id, stack );
numItems++;
}
for ( item = GetNextSiblingItem( item ); item == NULL; ) {
item = GetNextSiblingItem( searchStack.TopItem() );
searchStack.Pop();
if ( searchStack.Num() <= 0 ) {
return numItems;
}
}
}
return numItems;
}
BEGIN_MESSAGE_MAP(CPathTreeCtrl,CTreeCtrl)
//{{AFX_MSG_MAP(CPathTreeCtrl)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*
================
CPathTreeCtrl::OnToolHitTest
================
*/
int CPathTreeCtrl::OnToolHitTest( CPoint point, TOOLINFO * pTI ) const {
RECT rect;
UINT nFlags;
HTREEITEM hitem = HitTest( point, &nFlags );
if( nFlags & TVHT_ONITEM ) {
GetItemRect( hitem, &rect, TRUE );
pTI->hwnd = m_hWnd;
pTI->uId = (UINT)hitem;
pTI->lpszText = LPSTR_TEXTCALLBACK;
pTI->rect = rect;
return pTI->uId;
}
return -1;
}
/*
================
CPathTreeCtrl::OnToolTipText
================
*/
BOOL CPathTreeCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) {
// need to handle both ANSI and UNICODE versions of the message
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
UINT nID = pNMHDR->idFrom;
*pResult = 0;
// Do not process the message from built in tooltip
if( nID == (UINT)m_hWnd &&
(( pNMHDR->code == TTN_NEEDTEXTA && pTTTA->uFlags & TTF_IDISHWND ) ||
( pNMHDR->code == TTN_NEEDTEXTW && pTTTW->uFlags & TTF_IDISHWND ) ) ) {
return FALSE;
}
CString toolTip = "?";
// Get the mouse position
const MSG* pMessage;
CPoint pt;
pMessage = GetCurrentMessage();
ASSERT ( pMessage );
pt = pMessage->pt;
ScreenToClient( &pt );
// get the tree item
UINT nFlags;
HTREEITEM hitem = HitTest( pt, &nFlags );
if( nFlags & TVHT_ONITEM ) {
// relay message to parent
pTTTA->hdr.hwndFrom = GetSafeHwnd();
pTTTA->hdr.idFrom = (UINT) hitem;
if ( GetParent()->SendMessage( WM_NOTIFY, ( TTN_NEEDTEXT << 16 ) | GetDlgCtrlID(), (LPARAM)pTTTA ) == FALSE ) {
return FALSE;
}
}
return TRUE; // message was handled
}

View File

@@ -0,0 +1,93 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __CPATHTREECTR_H__
#define __CPATHTREECTR_H__
/*
===============================================================================
Tree Control for path names.
===============================================================================
*/
class idPathTreeStack {
public:
idPathTreeStack( void ) { size = 0; }
void PushRoot( HTREEITEM root );
void Push( HTREEITEM item, const char *name );
void Pop( void ) { size--; }
HTREEITEM TopItem( void ) const { return stackItem[size-1]; }
const char * TopName( void ) const { return stackName[size-1]; }
int TopNameLength( void ) const { return stackName[size-1].Length(); }
int Num( void ) const { return size; }
private:
int size;
HTREEITEM stackItem[128];
idStr stackName[128];
};
ID_INLINE void idPathTreeStack::PushRoot( HTREEITEM root ) {
assert( size == 0 );
stackItem[size] = root;
stackName[size] = "";
size++;
}
ID_INLINE void idPathTreeStack::Push( HTREEITEM item, const char *name ) {
assert( size < 127 );
stackItem[size] = item;
stackName[size] = stackName[size-1] + name + "/";
size++;
}
typedef bool (*treeItemCompare_t)( void *data, HTREEITEM item, const char *name );
class CPathTreeCtrl : public CTreeCtrl {
public:
CPathTreeCtrl();
~CPathTreeCtrl();
HTREEITEM FindItem( const idStr &pathName );
HTREEITEM InsertPathIntoTree( const idStr &pathName, const int id );
HTREEITEM AddPathToTree( const idStr &pathName, const int id, idPathTreeStack &stack );
int SearchTree( treeItemCompare_t compare, void *data, CPathTreeCtrl &result );
protected:
virtual void PreSubclassWindow();
virtual int OnToolHitTest( CPoint point, TOOLINFO * pTI ) const;
afx_msg BOOL OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
DECLARE_MESSAGE_MAP()
};
#endif /* !__CPATHTREECTR_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,236 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __CSYNTAXRICHEDITCTR_H__
#define __CSYNTAXRICHEDITCTR_H__
/*
===============================================================================
Rich Edit Control with:
- syntax highlighting
- braced section highlighting
- braced section auto-indentation
- multi-line tabs
- keyword auto-completion
- object member auto-completion
- keyword tool tip
- function parameter tool tip
===============================================================================
*/
// use #import on Vista to generate .tlh header to copy from intermediate compile directory to local directory for subsequent builds
// rename: avoids warning C4278: 'FindText': identifier in type library 'riched20.dll' is already a macro; use the 'rename' qualifier
// no_auto_exclude: avoids warnings
// no_namespace: no longer using this option, which avoids variable redifinition compile errors on Vista
//#define GENERATE_TLH
#ifdef GENERATE_TLH
# import "riched20.dll" raw_interfaces_only, raw_native_types, named_guids, no_auto_exclude, no_implementation, rename( "FindText", "FindShit" )
#else
# include "riched20.tlh"
#endif
static const char * FONT_NAME = "Courier";
static const int FONT_HEIGHT = 10;
static const int FONT_WIDTH = 8;
static const int TAB_SIZE = 4;
static const COLORREF SRE_COLOR_BLACK = RGB( 0, 0, 0 );
static const COLORREF SRE_COLOR_WHITE = RGB( 255, 255, 255 );
static const COLORREF SRE_COLOR_RED = RGB( 255, 0, 0 );
static const COLORREF SRE_COLOR_GREEN = RGB( 0, 255, 0 );
static const COLORREF SRE_COLOR_BLUE = RGB( 0, 0, 255 );
static const COLORREF SRE_COLOR_YELLOW = RGB( 255, 255, 0 );
static const COLORREF SRE_COLOR_MAGENTA = RGB( 255, 0, 255 );
static const COLORREF SRE_COLOR_CYAN = RGB( 0, 255, 255 );
static const COLORREF SRE_COLOR_ORANGE = RGB( 255, 128, 0 );
static const COLORREF SRE_COLOR_PURPLE = RGB( 150, 0, 150 );
static const COLORREF SRE_COLOR_PINK = RGB( 186, 102, 123 );
static const COLORREF SRE_COLOR_GREY = RGB( 85, 85, 85 );
static const COLORREF SRE_COLOR_BROWN = RGB( 100, 90, 20 );
static const COLORREF SRE_COLOR_LIGHT_GREY = RGB( 170, 170, 170 );
static const COLORREF SRE_COLOR_LIGHT_BROWN = RGB( 170, 150, 20 );
static const COLORREF SRE_COLOR_DARK_GREEN = RGB( 0, 128, 0 );
static const COLORREF SRE_COLOR_DARK_CYAN = RGB( 0, 150, 150 );
static const COLORREF SRE_COLOR_DARK_YELLOW = RGB( 220, 200, 20 );
typedef struct {
const char * keyWord;
COLORREF color;
const char * description;
} keyWord_t;
typedef bool (*objectMemberCallback_t)( const char *objectName, CListBox &listBox );
typedef bool (*toolTipCallback_t)( const char *name, CString &string );
class CSyntaxRichEditCtrl : public CRichEditCtrl {
public:
CSyntaxRichEditCtrl( void );
~CSyntaxRichEditCtrl( void );
void Init( void );
void SetCaseSensitive( bool caseSensitive );
void AllowPathNames( bool allow );
void EnableKeyWordAutoCompletion( bool enable );
void SetKeyWords( const keyWord_t kws[] );
bool LoadKeyWordsFromFile( const char *fileName );
void SetObjectMemberCallback( objectMemberCallback_t callback );
void SetFunctionParmCallback( toolTipCallback_t callback );
void SetToolTipCallback( toolTipCallback_t callback );
void SetDefaultColor( const COLORREF color );
void SetCommentColor( const COLORREF color );
void SetStringColor( const COLORREF color, const COLORREF altColor = -1 );
void SetLiteralColor( const COLORREF color );
COLORREF GetForeColor( int charIndex ) const;
COLORREF GetBackColor( int charIndex ) const;
void GetCursorPos( int &line, int &column, int &character ) const;
CHARRANGE GetVisibleRange( void ) const;
void GetText( idStr &text ) const;
void GetText( idStr &text, int startCharIndex, int endCharIndex ) const;
void SetText( const char *text );
void GoToLine( int line );
bool FindNext( const char *find, bool matchCase, bool matchWholeWords, bool searchForward );
int ReplaceAll( const char *find, const char *replace, bool matchCase, bool matchWholeWords );
void ReplaceText( int startCharIndex, int endCharIndex, const char *replace );
protected:
virtual int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
afx_msg BOOL OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult );
afx_msg UINT OnGetDlgCode();
afx_msg void OnChar( UINT nChar, UINT nRepCnt, UINT nFlags );
afx_msg void OnKeyDown( UINT nKey, UINT nRepCnt, UINT nFlags );
afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
afx_msg BOOL OnMouseWheel( UINT nFlags, short zDelta, CPoint pt );
afx_msg void OnMouseMove( UINT nFlags, CPoint point );
afx_msg void OnVScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar );
afx_msg void OnSize( UINT nType, int cx, int cy );
afx_msg void OnProtected( NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnChange();
afx_msg void OnAutoCompleteListBoxChange();
afx_msg void OnAutoCompleteListBoxDblClk();
DECLARE_MESSAGE_MAP()
// settings
CHARFORMAT2 defaultCharFormat;
COLORREF defaultColor;
COLORREF singleLineCommentColor;
COLORREF multiLineCommentColor;
COLORREF stringColor[2];
COLORREF literalColor;
COLORREF braceHighlightColor;
typedef enum {
CT_WHITESPACE,
CT_COMMENT,
CT_STRING,
CT_LITERAL,
CT_NUMBER,
CT_NAME,
CT_PUNCTUATION
} charType_t;
int charType[256];
idList<keyWord_t> keyWordsFromFile;
const keyWord_t * keyWords;
int * keyWordLengths;
COLORREF * keyWordColors;
idHashIndex keyWordHash;
bool caseSensitive;
bool allowPathNames;
bool keyWordAutoCompletion;
objectMemberCallback_t GetObjectMembers;
toolTipCallback_t GetFunctionParms;
toolTipCallback_t GetToolTip;
// run-time variables
tom::ITextDocument * m_TextDoc;
tom::ITextFont * m_DefaultFont;
CHARRANGE updateRange;
bool updateSyntaxHighlighting;
int stringColorIndex;
int stringColorLine;
int autoCompleteStart;
CListBox autoCompleteListBox;
int funcParmToolTipStart;
CEdit funcParmToolTip;
int bracedSection[2];
CPoint mousePoint;
CToolTipCtrl * keyWordToolTip;
TCHAR * m_pchTip;
WCHAR * m_pwchTip;
protected:
void InitFont( void );
void InitSyntaxHighlighting( void );
void SetCharType( int first, int last, int type );
void SetDefaultFont( int startCharIndex, int endCharIndex );
void SetColor( int startCharIndex, int endCharIndex, COLORREF foreColor, COLORREF backColor, bool bold );
void FreeKeyWordsFromFile( void );
int FindKeyWord( const char *keyWord, int length ) const;
void HighlightSyntax( int startCharIndex, int endCharIndex );
void UpdateVisibleRange( void );
bool GetNameBeforeCurrentSelection( CString &name, int &charIndex ) const;
bool GetNameForMousePosition( idStr &name ) const;
void AutoCompleteInsertText( void );
void AutoCompleteUpdate( void );
void AutoCompleteShow( int charIndex );
void AutoCompleteHide( void );
void ToolTipShow( int charIndex, const char *string );
void ToolTipHide( void );
bool BracedSectionStart( char braceStartChar, char braceEndChar );
bool BracedSectionEnd( char braceStartChar, char braceEndChar );
void BracedSectionAdjustEndTabs( void );
void BracedSectionShow( void );
void BracedSectionHide( void );
};
#endif /* !__CSYNTAXRICHEDITCTR_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,193 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __DIALOGCOLORPICKER__
#define __DIALOGCOLORPICKER__
// Original ColorPicker/DIB source by Rajiv Ramachandran <rrajivram@hotmail.com>
// included with permission from the author
#include "CDib.h"
#define RADIUS 100
#define PI 3.14159265358
#define RECT_WIDTH 5
#define TOSCALE(x) (((x)*RADIUS)/255.0)
#define SCALETOMAX(x) (((x)*255.0)/RADIUS)
#define RED 0
#define GREEN 1
#define BLUE 2
#define BAD_SLOPE 1000000.0
struct HSVType;
struct RGBType {
COLORREF color() { return RGB( r, g, b ); }
HSVType toHSV();
int r, g, b;
};
struct HSVType {
RGBType toRGB();
int h, s, v;
};
struct LineDesc {
double x, y;
double slope;
double c;
};
class CDialogColorPicker : public CDialog
{
// Construction
public:
CDialogColorPicker(COLORREF c,CWnd* pParent = NULL); // standard constructor
~CDialogColorPicker();
COLORREF GetColor() { return color.color();};
float GetOverBright() { return overBright; };
// Dialog Data
//{{AFX_DATA(CDialogColorPicker)
enum { IDD = IDD_DIALOG_COLORS };
float m_overBright;
//}}AFX_DATA
void (*UpdateParent)( float r, float g, float b, float a );
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDialogColorPicker)
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDialogColorPicker)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnSysColorChange();
afx_msg void OnPaint();
virtual BOOL OnInitDialog();
afx_msg void OnChangeEditBlue();
afx_msg void OnChangeEditGreen();
afx_msg void OnChangeEditHue();
afx_msg void OnChangeEditRed();
afx_msg void OnChangeEditSat();
afx_msg void OnChangeEditVal();
afx_msg void OnChangeEditOverbright();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnBtnColor();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
void DrawFilledColor(CDC *pDC,CRect cr,COLORREF c);
void DrawLines(CDC *pDC);
void DrawXorRect(CDC *pDC,CRect& cr);
void CalcSlopes();
void CalcCuboid();
void CreateBrightDIB();
void SetDIBPalette();
void DrawMarkers(CDC *pDC);
void TrackPoint(CPoint pt);
void CalcRects();
BOOL InCircle(CPoint pt);
BOOL InBright(CPoint pt);
BOOL InOverBright(CPoint pt);
void SetSpinVals();
void SetEditVals();
void DrawAll();
void DrawRGB(CDC *pDC);
void DrawHSB(CDC *pDC);
void LoadMappedBitmap(CBitmap& bitmap,UINT nIdResource,CSize& size);
CBitmap m_RgbBitmap,m_HsbBitmap;
CDC memDC;
CPoint m_Centre;
CDIB m_BrightDIB;
int rgbWidth;
int rgbHeight;
int hsbWidth;
int hsbHeight;
int m_nMouseIn;
CRect m_CurrentRect,brightMark;
CRect brightRect;
CRect overBrightRect;
HSVType hsvColor;
RGBType color;
RGBType m_OldColor;
CPoint Vertex;
CPoint Top;
CPoint Left;
CPoint Right;
CRect rects[3];
CPoint m_Cuboid[8];
BOOL m_bInMouse;
int nIndex;
int RedLen;
int GreenLen;
int BlueLen;
LineDesc lines[3];
CRect rgbRect;
CRect hsbRect;
CRect OldColorRect;
CRect NewColorRect;
BOOL m_bInitOver;
BOOL m_bInDrawAll;
float overBright;
};
bool DoNewColor( int* i1, int* i2, int* i3, float *overBright, void (*Update)( float, float, float, float ) = NULL );
#endif /* !__DIALOGCOLORPICKER__ */

View File

@@ -0,0 +1,134 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/Common_resource.h"
#include "DialogGoToLine.h"
#ifdef ID_DEBUG_MEMORY
#undef new
#undef DEBUG_NEW
#define DEBUG_NEW new
#endif
IMPLEMENT_DYNAMIC(DialogGoToLine, CDialog)
/*
================
DialogGoToLine::DialogGoToLine
================
*/
DialogGoToLine::DialogGoToLine( CWnd* pParent /*=NULL*/ )
: CDialog(DialogGoToLine::IDD, pParent)
, firstLine(0)
, lastLine(0)
, line(0)
{
}
/*
================
DialogGoToLine::~DialogGoToLine
================
*/
DialogGoToLine::~DialogGoToLine() {
}
/*
================
DialogGoToLine::DoDataExchange
================
*/
void DialogGoToLine::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogGoToLine)
DDX_Control( pDX, IDC_GOTOLINE_EDIT, numberEdit);
//}}AFX_DATA_MAP
}
/*
================
DialogGoToLine::SetRange
================
*/
void DialogGoToLine::SetRange( int firstLine, int lastLine ) {
this->firstLine = firstLine;
this->lastLine = lastLine;
}
/*
================
DialogGoToLine::GetLine
================
*/
int DialogGoToLine::GetLine( void ) const {
return line;
}
/*
================
DialogGoToLine::OnInitDialog
================
*/
BOOL DialogGoToLine::OnInitDialog() {
CDialog::OnInitDialog();
GetDlgItem( IDC_GOTOLINE_STATIC )->SetWindowText( va( "&Line number (%d - %d):", firstLine, lastLine ) );
numberEdit.SetWindowText( va( "%d", firstLine ) );
numberEdit.SetSel( 0, -1 );
numberEdit.SetFocus();
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(DialogGoToLine, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()
// DialogGoToLine message handlers
/*
================
DialogGoToLine::OnBnClickedOk
================
*/
void DialogGoToLine::OnBnClickedOk() {
CString text;
numberEdit.GetWindowText( text );
line = idMath::ClampInt( firstLine, lastLine, atoi( text ) );
OnOK();
}

View File

@@ -0,0 +1,63 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __DIALOGGOTOLINE_H__
#define __DIALOGGOTOLINE_H__
// DialogGoToLine dialog
class DialogGoToLine : public CDialog {
DECLARE_DYNAMIC(DialogGoToLine)
public:
DialogGoToLine( CWnd* pParent = NULL ); // standard constructor
virtual ~DialogGoToLine();
enum { IDD = IDD_DIALOG_GOTOLINE };
void SetRange( int firstLine, int lastLine );
int GetLine( void ) const;
protected:
virtual BOOL OnInitDialog();
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
afx_msg void OnBnClickedOk();
DECLARE_MESSAGE_MAP()
private:
CEdit numberEdit;
int firstLine;
int lastLine;
int line;
};
#endif /* !__DIALOGGOTOLINE_H__ */

View File

@@ -0,0 +1,78 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/common_resource.h"
#include "DialogName.h"
/////////////////////////////////////////////////////////////////////////////
// DialogName dialog
DialogName::DialogName(const char *pName, CWnd* pParent /*=NULL*/)
: CDialog(DialogName::IDD, pParent)
{
//{{AFX_DATA_INIT(DialogName)
m_strName = _T("");
//}}AFX_DATA_INIT
m_strCaption = pName;
}
void DialogName::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogName)
DDX_Text(pDX, IDC_TOOLS_EDITNAME, m_strName);
//}}AFX_DATA_MAP
}
BOOL DialogName::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText(m_strCaption);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(DialogName, CDialog)
//{{AFX_MSG_MAP(DialogName)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DialogName message handlers
void DialogName::OnOK()
{
CDialog::OnOK();
}

View File

@@ -0,0 +1,76 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __DIALOGNAME_H__
#define __DIALOGNAME_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// NameDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// DialogName dialog
class DialogName : public CDialog
{
CString m_strCaption;
// Construction
public:
DialogName(const char *pName, CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(DialogName)
enum { IDD = IDD_NEWNAME };
CString m_strName;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(DialogName)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(DialogName)
virtual BOOL OnInitDialog();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif /* !__DIALOGNAME_H__ */

382
neo/tools/comafx/StdAfx.cpp Normal file
View File

@@ -0,0 +1,382 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/win_local.h"
// source file that includes just the standard includes
// Radiant.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
/*
===============================================================================
Afx initialization.
===============================================================================
*/
bool afxInitialized = false;
/*
================
InitAfx
================
*/
void InitAfx( void ) {
if ( !afxInitialized ) {
AfxWinInit( win32.hInstance, NULL, "", SW_SHOW );
AfxInitRichEdit();
afxInitialized = true;
}
}
/*
===============================================================================
Tool Tips.
===============================================================================
*/
/*
================
DefaultOnToolHitTest
================
*/
int DefaultOnToolHitTest( const toolTip_t *toolTips, const CDialog *dialog, CPoint point, TOOLINFO* pTI ) {
CWnd *wnd;
RECT clientRect, rect;
dialog->GetWindowRect( &clientRect );
point.x += clientRect.left;
point.y += clientRect.top;
for ( int i = 0; toolTips[i].tip; i++ ) {
wnd = dialog->GetDlgItem( toolTips[i].id );
if ( !( wnd->GetStyle() & WS_VISIBLE ) ) {
continue;
}
wnd->GetWindowRect( &rect );
if ( point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom ) {
pTI->hwnd = dialog->GetSafeHwnd();
pTI->uFlags |= TTF_IDISHWND;
pTI->uFlags &= ~TTF_CENTERTIP;
pTI->uId = (UINT_PTR) wnd->GetSafeHwnd();
return pTI->uId;
}
}
return -1;
}
/*
================
DefaultOnToolTipNotify
================
*/
BOOL DefaultOnToolTipNotify( const toolTip_t *toolTips, UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
// need to handle both ANSI and UNICODE versions of the message
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
*pResult = 0;
UINT nID = pNMHDR->idFrom;
if ( pTTTA->uFlags & TTF_IDISHWND ) {
// idFrom is actually the HWND of the tool
nID = ::GetDlgCtrlID((HWND)nID);
}
int i;
for ( i = 0; toolTips[i].tip; i++ ) {
if ( toolTips[i].id == nID ) {
break;
}
}
if ( !toolTips[i].tip ) {
return FALSE;
}
if ( pNMHDR->code == TTN_NEEDTEXTA ) {
lstrcpyn( pTTTA->szText, toolTips[i].tip, sizeof(pTTTA->szText) );
} else {
_mbstowcsz( pTTTW->szText, toolTips[i].tip, sizeof(pTTTW->szText) );
}
return TRUE;
}
/*
===============================================================================
Common control tools.
===============================================================================
*/
/*
================
EditControlEnterHit
returns true if [Enter] was hit in the edit box
all 'return' characters in the text are removed and a single line is maintained
the edit control must be multi-line with auto-vscroll
================
*/
bool EditControlEnterHit( CEdit *edit ) {
CString strIn, strOut;
if ( edit->GetLineCount() > 1 ) {
edit->GetWindowText( strIn );
for ( int i = 0; i < strIn.GetLength(); i++ ) {
if ( strIn[i] >= ' ' ) {
strOut.AppendChar( strIn[i] );
}
}
edit->SetWindowText( strOut );
edit->SetSel( 0, strOut.GetLength() );
return true;
}
return false;
}
/*
================
EditVerifyFloat
================
*/
float EditVerifyFloat( CEdit *edit, bool allowNegative ) {
CString strIn, strOut;
bool dot = false;
int start, end;
edit->GetSel( start, end );
edit->GetWindowText( strIn );
for ( int i = 0; i < strIn.GetLength(); i++ ) {
// first character may be a minus sign
if ( allowNegative && strOut.GetLength() == 0 && strIn[i] == '-' ) {
strOut.AppendChar( '-' );
}
// the string may contain one dot
else if ( !dot && strIn[i] == '.' ) {
strOut.AppendChar( strIn[i] );
dot = true;
}
else if ( strIn[i] >= '0' && strIn[i] <= '9' ) {
strOut.AppendChar( strIn[i] );
}
}
edit->SetWindowText( strOut );
edit->SetSel( start, end );
return atof(strOut.GetBuffer(0));
}
/*
================
SpinFloatString
================
*/
void SpinFloatString( CString &str, bool up ) {
int i, dotIndex = -1, digitIndex = -1;
for ( i = 0; str[i]; i++ ) {
if ( str[i] == '.' ) {
if ( dotIndex == -1 ) {
dotIndex = i;
}
}
else if ( str[i] != '0' ) {
if ( digitIndex == -1 ) {
digitIndex = i;
}
}
}
if ( digitIndex == -1 ) {
str.SetString( "1" );
return;
}
if ( dotIndex != -1 ) {
str.Delete( dotIndex, 1 );
if ( digitIndex > dotIndex ) {
digitIndex--;
}
}
else {
dotIndex = i;
}
if ( up ) {
if ( str[digitIndex] == '9' ) {
str.SetAt( digitIndex, '0' );
if ( digitIndex == 0 ) {
str.Insert( 0, '1' );
dotIndex++;
}
else {
str.SetAt( digitIndex-1, '1' );
}
}
else {
str.SetAt( digitIndex, str[digitIndex] + 1 );
}
}
else {
if ( str[digitIndex] == '1' ) {
if ( str[digitIndex+1] == '\0' ) {
str.SetAt( digitIndex, '0' );
str.AppendChar( '9' );
}
else if ( str[digitIndex+1] == '0' ) {
str.SetAt( digitIndex, '0' );
str.SetAt( digitIndex+1, '9' );
}
else {
str.SetAt( digitIndex+1, str[digitIndex+1] - 1 );
}
}
else {
str.SetAt( digitIndex, str[digitIndex] - 1 );
}
}
if ( dotIndex < str.GetLength() ) {
str.Insert( dotIndex, '.' );
// remove trailing zeros
for ( i = str.GetLength()-1; i >= 0; i-- ) {
if ( str[i] != '0' && str[i] != '.' ) {
break;
}
}
if ( i < str.GetLength() - 1 ) {
str.Delete( i+1, str.GetLength() - i );
}
}
for ( i = 0; str[i]; i++ ) {
if ( str[i] == '.' ) {
if ( i > 1 ) {
str.Delete( 0, i-1 );
}
break;
}
if ( str[i] != '0' ) {
if ( i > 0 ) {
str.Delete( 0, i );
}
break;
}
}
}
/*
================
EditSpinFloat
================
*/
float EditSpinFloat( CEdit *edit, bool up ) {
CString str;
edit->GetWindowText( str );
SpinFloatString( str, up );
edit->SetWindowText( str );
return atof( str );
}
/*
================
SetSafeComboBoxSelection
================
*/
int SetSafeComboBoxSelection( CComboBox *combo, const char *string, int skip ) {
int index;
index = combo->FindString( -1, string );
if ( index == -1 ) {
index = 0;
}
if ( combo->GetCount() != 0 ) {
if ( index == skip ) {
index = ( skip + 1 ) % combo->GetCount();
}
combo->SetCurSel( index );
}
return index;
}
/*
================
GetComboBoxSelection
================
*/
int GetSafeComboBoxSelection( CComboBox *combo, CString &string, int skip ) {
int index;
index = combo->GetCurSel();
if ( index == CB_ERR ) {
index = 0;
}
if ( combo->GetCount() != 0 ) {
if ( index == skip ) {
index = ( skip + 1 ) % combo->GetCount();
}
combo->GetLBText( index, string );
}
else {
string = "";
}
return index;
}
/*
================
UnsetSafeComboBoxSelection
================
*/
int UnsetSafeComboBoxSelection( CComboBox *combo, CString &string ) {
int skip, index;
skip = combo->FindString( -1, string );
index = combo->GetCurSel();
if ( index == CB_ERR ) {
index = 0;
}
if ( combo->GetCount() != 0 ) {
if ( index == skip ) {
index = ( skip + 1 ) % combo->GetCount();
}
combo->SetCurSel( index );
}
return index;
}

66
neo/tools/comafx/StdAfx.h Normal file
View File

@@ -0,0 +1,66 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __AFX_STDAFX_H__
#define __AFX_STDAFX_H__
// include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC OLE automation classes
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
void InitAfx( void );
// tool tips
typedef struct toolTip_s {
int id;
char *tip;
} toolTip_t;
int DefaultOnToolHitTest( const toolTip_t *toolTips, const CDialog *dialog, CPoint point, TOOLINFO* pTI );
BOOL DefaultOnToolTipNotify( const toolTip_t *toolTips, UINT id, NMHDR *pNMHDR, LRESULT *pResult );
// edit control
bool EditControlEnterHit( CEdit *edit );
float EditVerifyFloat( CEdit *edit, bool allowNegative = true );
float EditSpinFloat( CEdit *edit, bool up );
// combo box
int SetSafeComboBoxSelection( CComboBox *combo, const char *string, int skip );
int GetSafeComboBoxSelection( CComboBox *combo, CString &string, int skip );
int UnsetSafeComboBoxSelection( CComboBox *combo, CString &string );
#endif /* !__AFX_STDAFX_H__ */

View File

@@ -0,0 +1,424 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "VectorCtl.h"
#include <math.h>
BEGIN_MESSAGE_MAP(CVectorCtl, CButton)
//{{AFX_MSG_MAP(idGLWidget)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CVectorCtl::CVectorCtl () :
m_bBmpCreated (FALSE),
m_bImageChange (TRUE),
m_bBackgroundBitmapUsed (FALSE),
m_clrDiffuse (DEFAULT_DIFFUSE),
m_clrAmbient (DEFAULT_AMBIENT),
m_clrLight (DEFAULT_LIGHT),
m_clrBackgroundStart (DEFAULT_START_BACKGROUND_COLOR),
m_clrBackgroundEnd (DEFAULT_END_BACKGROUND_COLOR),
m_dSpecularExponent (DEFAULT_SPEC_EXP),
m_bHasFocus (FALSE),
m_bSelected (FALSE),
m_bFrontVector (FALSE),
m_dSensitivity (20.0),
m_procVectorChanging (NULL),
m_procVectorChanged (NULL)
{
double DefaultVec[3] = DEFAULT_VEC;
for (int i=0; i<3; i++) {
m_dVec[i] = DefaultVec[i];
pCtl[i] = NULL;
}
rotationQuat.Set( 0.0f, 0.0f, 0.0f, 1.0f );
lastPress.Zero();
radius = 0.6f;
}
CVectorCtl::~CVectorCtl ()
{
if (m_bBmpCreated)
m_dcMem.SelectObject (m_pOldBitmap);
ClearBackgroundBitmap ();
}
// Owner-drawn control service function:
void CVectorCtl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
CDC *pDC = CDC::FromHandle (lpDrawItemStruct->hDC); // Get CDC to draw
if (!m_bSelected && lpDrawItemStruct->itemState & ODS_SELECTED) {
// Just got re-selected (user starts a new mouse dragging session)
} else if (m_bSelected && // Last state was selected
!(lpDrawItemStruct->itemState & ODS_SELECTED) && // New state is NOT selected
(lpDrawItemStruct->itemState & ODS_FOCUS) && // New state is still in focus
m_procVectorChanged) // User asked for a callback
// User has left the track-ball and asked for a callback.
m_procVectorChanged ( rotationQuat );
m_bHasFocus = lpDrawItemStruct->itemState & ODS_FOCUS; // Update focus status
m_bSelected = lpDrawItemStruct->itemState & ODS_SELECTED; // Update selection status
if (!m_bBmpCreated) // 1st time
InitBitmap (lpDrawItemStruct, pDC);
if (m_bImageChange) { // Image has changes - recalc it!
if (m_procVectorChanging) // User has specified a callback
m_procVectorChanging ( rotationQuat ); // Call it!
BuildImage (lpDrawItemStruct);
m_bImageChange = FALSE;
}
pDC->BitBlt (0,0,m_iWidth, m_iHeight, &m_dcMem, 0, 0, SRCCOPY); // Update screen
}
// Mouse was dragged
void CVectorCtl::OnMouseDrag (int ixMove, int iyMove)
{
RotateByXandY (double(-iyMove) / m_dSensitivity,
double(ixMove) / m_dSensitivity);
}
// Recalc ball image
void CVectorCtl::BuildImage (LPDRAWITEMSTRUCT lpDrawItemStruct)
{
int xf, yf;
for (int x=0; x<m_iWidth; x++) // Scan all columns
for (int y=0; y<m_iHeight; y++) { // Scan all rows
xf = x-m_iXCenter; // Find distance from center
yf = y-m_iYCenter;
if (xf*xf + yf*yf <= m_iSqrRadius) { // Point on ball surface
double vx = double(xf) / double(m_iRadius),
vy = double(yf) / double(m_iRadius),
vz = sqrt (1.0 - vx*vx - vy*vy); // Find ball's normal
m_dcMem.SetPixelV (x,y, CalcLight (vx,vy,vz));
}
}
}
// Normalize a vector to unit size
BOOL CVectorCtl::Normalize ()
{
double Norm = m_dVec[0] * m_dVec[0] + m_dVec[1] * m_dVec[1] + m_dVec[2] * m_dVec[2];
if (Norm > EPS) {
Norm = sqrt (Norm);
m_dVec[0] /= Norm;
m_dVec[1] /= Norm;
m_dVec[2] /= Norm;
return TRUE;
} else { // Reset to defualt vector
double DefaultVec[3] = DEFAULT_VEC;
for (int i=0; i<3; i++)
m_dVec[i] = DefaultVec[i];
return FALSE;
}
}
// Calculate lightning effect for specific pixel on ball's surface
COLORREF CVectorCtl::CalcLight (double dx, double dy, double dz)
{
double NL = dx * m_dVec[0] + dy * m_dVec[1] + dz * m_dVec[2],
RV = 2.0 * NL,
rx = m_dVec[0] - (dx * RV),
ry = m_dVec[1] - (dy * RV),
rz = m_dVec[2] - (dz * RV);
if (NL < 0.0) // Diffuse coefficient
NL = 0.0;
RV = max (0.0, -rz);
RV = double(pow (RV, m_dSpecularExponent));
int r = int ( double(GetRValue(m_clrDiffuse)) * NL + // Diffuse
double(GetRValue(m_clrLight)) * RV + // Specular
double(GetRValue(m_clrAmbient))), // Ambient
g = int ( double(GetGValue(m_clrDiffuse)) * NL + // Diffuse
double(GetGValue(m_clrLight)) * RV + // Specular
double(GetGValue(m_clrAmbient))), // Ambient
b = int ( double(GetBValue(m_clrDiffuse)) * NL + // Diffuse
double(GetBValue(m_clrLight)) * RV + // Specular
double(GetBValue(m_clrAmbient))); // Ambient
r = min (255, r); // Cutoff highlight
g = min (255, g);
b = min (255, b);
return RGB(BYTE(r),BYTE(g),BYTE(b));
}
// Start memory buffer bitmap and measure it
void CVectorCtl::InitBitmap (LPDRAWITEMSTRUCT lpDrawItemStruct, CDC *pDC)
{
m_iWidth = lpDrawItemStruct->rcItem.right - lpDrawItemStruct->rcItem.left;
m_iHeight = lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top;
m_bmpBuffer.CreateCompatibleBitmap (pDC, m_iWidth, m_iHeight);
m_bBmpCreated = TRUE;
m_dcMem.CreateCompatibleDC (pDC);
m_pOldBitmap = m_dcMem.SelectObject (&m_bmpBuffer);
SetRadius (max (min (m_iWidth, m_iHeight) - 2, 0) / 2);
SetCenter (m_iWidth / 2, m_iHeight / 2);
CreateBackground ();
}
// Set new specular intensity
BOOL CVectorCtl::SetSpecularExponent (double dExp)
{
if (dExp < 1.0 || dExp > 200.0)
return FALSE;
m_dSpecularExponent = dExp;
Redraw ();
return TRUE;
}
// Rotate our vector around the X and Y axis
void CVectorCtl::RotateByXandY (double XRot, double YRot)
{ // Angles are in radians
if (XRot == 0.0 && YRot == 0.0) {
return;
}
double cx = cos(XRot),
sx = sin(XRot),
cy = cos(YRot),
sy = sin(YRot),
dx = m_dVec[0] * cy + m_dVec[1] * sx * sy + m_dVec[2] * cx * sy,
dy = m_dVec[1] * cx - m_dVec[2] * sx,
dz = -m_dVec[0] * sy + m_dVec[1] * sx * cy + m_dVec[2] * cx * cy;
if (!m_bFrontVector || dz >= 0.0) { // Vector is bounds free
m_dVec[0] = dx;
m_dVec[1] = dy;
m_dVec[2] = dz;
} else { // Otherwise, do not allow Z to be negative (light shines from behind)
m_dVec[2] = 0.0;
m_dVec[0] = dx;
m_dVec[1] = dy;
Normalize ();
}
Redraw ();
}
void CVectorCtl::UpdateAxisControls ()
{
CString cs;
for (int i=0; i<3; i++)
if (pCtl[i]) {
cs.Format ("%+1.5f",m_dVec[i]);
pCtl[i]->SetWindowText (cs);
}
}
void CVectorCtl::SetAxisControl (int nXCtl, int nYCtl, int nZCtl)
{
pCtl[0] = GetParent()->GetDlgItem(nXCtl);
pCtl[1] = GetParent()->GetDlgItem(nYCtl);
pCtl[2] = GetParent()->GetDlgItem(nZCtl);
}
void CVectorCtl::SetRadius (UINT uRadius)
{
m_iRadius = uRadius;
m_iSqrRadius = m_iRadius * m_iRadius;
CreateBackground ();
Redraw (TRUE);
}
void CVectorCtl::SetCenter (UINT uHorizPos, UINT uVertPos)
{
m_iXCenter = uHorizPos;
m_iYCenter = uVertPos;
CreateBackground ();
Redraw (TRUE);
}
void CVectorCtl::SetAxis (double d, int nAxis)
{
if (fabs(d)>=1.0) {
m_dVec[nAxis]=d > 1.0 ? 1.0 : -1.0;
m_dVec[(nAxis+1) %3]=m_dVec[(nAxis+2) %3]=0.0;
Redraw ();
return;
}
m_dVec[nAxis] = d;
Normalize ();
Redraw ();
}
void CVectorCtl::SetVector (double dx, double dy, double dz)
{
m_dVec[0] = dx;
m_dVec[1] = dy;
m_dVec[2] = dz;
Normalize ();
Redraw ();
}
void CVectorCtl::SetBackgroundColor (COLORREF clrStart, COLORREF clrEnd)
{
ClearBackgroundBitmap ();
m_clrBackgroundStart = clrStart;
m_clrBackgroundEnd = clrEnd;
CreateBackground ();
}
BOOL CVectorCtl::SetBackgroundImage (UINT uBackgroundBitmapID)
{
if (m_bBackgroundBitmapUsed) {
ClearBackgroundBitmap ();
CreateBackground ();
}
if (!m_bmpBack.LoadBitmap (uBackgroundBitmapID))
return FALSE;
m_bBackgroundBitmapUsed = TRUE;
CreateBackground ();
return TRUE;
}
void CVectorCtl::CreateBackground ()
{
if (!m_bBmpCreated)
return; // No image yet
if (!m_bBackgroundBitmapUsed) { // No background used - fill with gradient color
double r = GetRValue (m_clrBackgroundStart),
g = GetGValue (m_clrBackgroundStart),
b = GetBValue (m_clrBackgroundStart),
rd = double (GetRValue (m_clrBackgroundEnd) - r) / double (m_iHeight),
gd = double (GetGValue (m_clrBackgroundEnd) - g) / double (m_iHeight),
bd = double (GetBValue (m_clrBackgroundEnd) - b) / double (m_iHeight);
for (int j=0; j<m_iHeight; j++) {
for (int i=0; i<m_iWidth; i++)
m_dcMem.SetPixelV (i,j, RGB (BYTE(r),BYTE(g),BYTE(b)));
r+=rd; g+=gd; b+=bd;
}
Redraw (TRUE);
return;
}
// Bitmap used : tile it in back
CDC DCtmp;
BITMAP tmpBitmap;
m_bmpBack.GetBitmap (&tmpBitmap);
int iTmpWidth = tmpBitmap.bmWidth,
iTmpHeight = tmpBitmap.bmHeight;
DCtmp.CreateCompatibleDC (&m_dcMem);
m_pOldBitmap = DCtmp.SelectObject (&m_bmpBack);
for (int i=0; i<m_iWidth; i++)
for (int j=0; j<m_iHeight; j++)
m_dcMem.SetPixelV (i,j, DCtmp.GetPixel (i % iTmpWidth, j % iTmpHeight));
DCtmp.SelectObject (m_pOldBitmap);
Redraw (TRUE);
}
void CVectorCtl::ClearBackgroundBitmap ()
{
if (!m_bBackgroundBitmapUsed)
return;
m_bmpBack.DeleteObject ();
m_bBackgroundBitmapUsed = FALSE;
}
BOOL CVectorCtl::SetSensitivity (UINT uSens)
{
if (uSens == 0)
return FALSE;
m_dSensitivity = double(uSens);
return TRUE;
}
void CVectorCtl::Redraw (BOOL bErase) {
m_bImageChange = TRUE;
UpdateAxisControls();
Invalidate (bErase);
}
void CVectorCtl::OnMouseMove(UINT nFlags, CPoint point) {
if ( CWnd::GetCapture() != this ) {
return;
}
float curX = ( float )( 2 * point.x - 64 ) / 64;
float curY = ( float )( 2 * point.y - 64 ) / 64;
idVec3 to( -curX, -curY, 0.0f );
to.ProjectSelfOntoSphere( radius );
lastPress.ProjectSelfOntoSphere( radius );
idVec3 axis;
axis.Cross( to, lastPress );
float len = ( lastPress - to ).Length() / ( 2.0f * radius );
len = idMath::ClampFloat( -1.0f, 1.0f, len );
float phi = 2.0f * asin ( len ) ;
axis.Normalize();
axis *= sin( phi / 2.0f );
idQuat rot( axis.z, axis.y, axis.x, cos( phi / 2.0f ) );
rot.Normalize();
rotationQuat *= rot;
rotationQuat.Normalize();
lastPress = to;
lastPress.z = 0.0f;
m_dVec = rotationQuat.ToMat3()[2];
m_dVec.Normalize();
Redraw();
}
void CVectorCtl::OnLButtonDown(UINT nFlags, CPoint point) {
float curX = ( float )( 2 * point.x - 64 ) / 64;
float curY = ( float )( 2 * point.y - 64 ) / 64;
lastPress.Set( -curX, -curY, 0.0f );
SetCapture();
}
void CVectorCtl::OnLButtonUp(UINT nFlags, CPoint point) {
ReleaseCapture();
}

View File

@@ -0,0 +1,225 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
/*****************************************************************************
* *
* Vector control *
* ---------------- *
* *
* A 3D vector MFC control derived from CButton. *
* Features: *
* - Real-time light rendering on a 3D ball. *
* - Variable ball radius and position. *
* - Supports bitmap background (tiled). *
* - Supports vertical gradient color background (from color to color). *
* - Variable ball color (diffuse), light color and ambient color. *
* - Variable specular intensity. *
* - Supports attached controls (for automatic update). *
* - Variable mouse sensitivity. *
* - Supports front clipping (vector will not have negative Z values). *
* - Supports callback functions for the following events: *
* 1. The trackball has moved (vector is changing). *
* 2. The user dropped the trackball (released left mouse button) *
* i.e., the vector was changed. *
* *
* *
*****************************************************************************/
#ifndef _VECTOR_CTL_H
#define _VECTOR_CTL_H
// Callback pointer prototype:
typedef void (*VectorCtlCallbackProc)( idQuat rotation );
// The callback should look like:
// void CALLBACK MyCallBack (double dVecX, double dVecY, double dVecZ);
// or
// static void CALLBACK MyClass::MyCallBack (double dVecX, double dVecY, double dVecZ);
class CVectorCtl : public CButton
{
#define EPS 1.0e-6 // Epsilon
#define DEFAULT_VEC {0.00, 0.00, 1.00} // Default start vector
#define DEFAULT_DIFFUSE RGB( 30, 0, 200) // Default diffuse color
#define DEFAULT_AMBIENT RGB( 20, 20, 20) // Default ambient color
#define DEFAULT_LIGHT RGB(200, 200, 200) // Default light color
#define DEFAULT_START_BACKGROUND_COLOR RGB( 0, 0, 0) // Default gradient background start color
#define DEFAULT_END_BACKGROUND_COLOR RGB(140, 0, 120) // Default gradient background end color
#define DEFAULT_SPEC_EXP 25.0 // Default specular intensity
#define VAL_NOT_IN_USE -50000 // Internal use
public:
CVectorCtl ();
virtual ~CVectorCtl ();
// Owner-drawn control support function
virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct );
// Sets / Gets diffuse (ball) color.
void SetDiffuseColor (COLORREF clr) { m_clrDiffuse = clr; Redraw (); }
COLORREF GetDiffuseColor () { return m_clrDiffuse; }
// Sets / Gets ambient (background) color.
void SetAmbientColor (COLORREF clr) { m_clrAmbient = clr; Redraw (); }
COLORREF GetAmbientColor () { return m_clrAmbient; }
// Sets / Gets light color.
void SetLightColor (COLORREF clr) { m_clrLight = clr; Redraw (); }
COLORREF GetLightColor () { return m_clrLight; }
// Sets background gradient color (from start to finish vertically)
void SetBackgroundColor (COLORREF clrStart, COLORREF clrEnd);
// Sets a background bitmap (resource ID)
BOOL SetBackgroundImage (UINT uBackgroundBitmapID);
// Sets / Gets specular intensity
BOOL SetSpecularExponent (double dExp);
double GetSpecularExponent () { return m_dSpecularExponent; }
// Enables auto-update of axis controls.
// Place the control's ID and the SetWindowText function will be called
// for each vector component to display the value in the control.
void SetAxisControl (int nXCtl, int nYCtl, int nZCtl);
// Sets / Gets ball radius (in pixels)
void SetRadius (UINT uRadius);
UINT GetRadius () { return UINT(m_iRadius); }
// Sets / Gets ball position (in pixels)
void SetCenter (UINT uHorizPos, UINT uVertPos);
UINT GetHorizCenter () { return UINT(m_iXCenter); }
UINT GetVertCenter () { return UINT(m_iYCenter); }
// Sets / Gets vector components
void SetX (double dx) { SetAxis (dx, 0); }
double GetX() { return m_dVec[0]; }
void SetY (double dy) { SetAxis (dy, 1); }
double GetY() { return m_dVec[1]; }
void SetZ (double dz) { SetAxis (dz, 2); }
double GetZ() { return m_dVec[2]; }
void SetVector (double dx, double dy, double dz);
void SetidAxis( const idMat3 &mat ) {
rotationMatrix = mat;
rotationQuat = mat.ToQuat();
m_dVec = mat[2];
}
// Sets / Gets mouse sensitivity
BOOL SetSensitivity (UINT uSens);
UINT GetSensitivity () { return UINT(m_dSensitivity); }
// Bounds / Unbounds vector to front (positive Z) only
void ClipToFront (BOOL bEnable) { m_bFrontVector = bEnable; }
// Set user-defined callback function to call whenever the vector has changed.
// Set to NULL to disable callback.
void SetVectorChangingCallback (VectorCtlCallbackProc proc)
{ m_procVectorChanging = proc; }
// Set user-defined callback function to call whenever the vector has finished
// changing (user dropped track-ball).
// Set to NULL to disable callback.
void SetVectorChangedCallback (VectorCtlCallbackProc proc)
{ m_procVectorChanged = proc; }
private:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
// Mouse is being dragged
void OnMouseDrag (int , int);
// Create and measure off-screen buffer
void InitBitmap (LPDRAWITEMSTRUCT lpDrawItemStruct, CDC *pDC);
// Build image to BitBlt
void BuildImage (LPDRAWITEMSTRUCT lpDrawItemStruct);
// Free resources of background (non-ball) bitmap
void ClearBackgroundBitmap ();
// Normalize vector
BOOL Normalize ();
// Calculate lightning effect for a pixel on the ball
COLORREF CalcLight (double dx, double dy, double dz);
// Rotate our vector by X and Y angles
void RotateByXandY (double XRot, double YRot);
// Create background image resource
void CreateBackground ();
// Force redraw of entire image
void Redraw (BOOL bErase = FALSE);
// Update user-defined vector components controls
void UpdateAxisControls ();
// Sets a specific vector component to a specific value
void SetAxis (double d, int nAxis);
CBitmap m_bmpBuffer, // Buffer bitmap for BitBlt
m_bmpBack; // Background image bitmap
CDC m_dcMem; // Memory DC
BOOL m_bBmpCreated, // Was the bitmap created ?
m_bBackgroundBitmapUsed,// Are we using a background bitmap ?
m_bImageChange, // Has the image changed ?
m_bFrontVector, // Is the vector constrained to be facing front (positive Z) ?
m_bHasFocus, // Does the control have the focus ?
m_bSelected; // Is the control selected ?
int m_iWidth, // Region width
m_iHeight, // Region height
m_iRadius, // Ball radius
m_iSqrRadius, // Ball radius to the power of two
m_iXCenter, // X center point
m_iYCenter; // Y center point
CBitmap *m_pOldBitmap; // Previously selected bitmap
COLORREF m_clrDiffuse, // Ball diffusion color (self color)
m_clrAmbient, // Ambient (background) color
m_clrLight, // Color of light
m_clrBackgroundStart, // Background color gradient start
m_clrBackgroundEnd; // Background color gradient end
CWnd *pCtl[3]; // Pointers to axis display controls
double m_dSpecularExponent, // Specularity effect intensity
m_dSensitivity; // The bigger the number the less sensitive the mouse gets
// Valid ranges are 1..MAX_UINT
idVec3 m_dVec; // Vector components
idMat3 rotationMatrix; //
idQuat rotationQuat;
idQuat previousQuat;
idVec3 lastPress;
float radius;
VectorCtlCallbackProc m_procVectorChanging,
m_procVectorChanged;
protected:
DECLARE_MESSAGE_MAP()
};
#endif

View File

@@ -0,0 +1,865 @@
// Created by Microsoft (R) C/C++ Compiler Version 14.00.50727.762 (d29fdb1b).
//
// c:\alienbrainwork\rage\build\win32\debug\intermediate\tools\riched20.tlh
//
// C++ source equivalent of Win32 type library riched20.dll
// compiler-generated file created 06/14/07 at 10:58:45 - DO NOT EDIT!
#pragma once
#pragma pack(push, 8)
#include <comdef.h>
namespace tom {
//
// Forward references and typedefs
//
struct __declspec(uuid("8cc497c9-a1df-11ce-8098-00aa0047be5d"))
/* LIBID */ __tom;
enum __MIDL___MIDL_itf_tom_0000_0001;
struct __declspec(uuid("8cc497c0-a1df-11ce-8098-00aa0047be5d"))
/* dual interface */ ITextDocument;
struct __declspec(uuid("8cc497c1-a1df-11ce-8098-00aa0047be5d"))
/* dual interface */ ITextSelection;
struct __declspec(uuid("8cc497c2-a1df-11ce-8098-00aa0047be5d"))
/* dual interface */ ITextRange;
struct __declspec(uuid("8cc497c3-a1df-11ce-8098-00aa0047be5d"))
/* dual interface */ ITextFont;
struct __declspec(uuid("8cc497c4-a1df-11ce-8098-00aa0047be5d"))
/* dual interface */ ITextPara;
struct __declspec(uuid("8cc497c5-a1df-11ce-8098-00aa0047be5d"))
/* dual interface */ ITextStoryRanges;
struct __declspec(uuid("01c25500-4268-11d1-883a-3c8b00c10000"))
/* dual interface */ ITextDocument2;
struct __declspec(uuid("a3787420-4267-11d1-883a-3c8b00c10000"))
/* interface */ ITextMsgFilter;
struct _RemotableHandle;
union __MIDL_IWinTypes_0009;
typedef enum __MIDL___MIDL_itf_tom_0000_0001 tomConstants;
typedef struct _RemotableHandle * wireHWND;
typedef unsigned long UINT_PTR;
typedef long LONG_PTR;
//
// Smart pointer typedef declarations
//
_COM_SMARTPTR_TYPEDEF(ITextFont, __uuidof(ITextFont));
_COM_SMARTPTR_TYPEDEF(ITextPara, __uuidof(ITextPara));
_COM_SMARTPTR_TYPEDEF(ITextRange, __uuidof(ITextRange));
_COM_SMARTPTR_TYPEDEF(ITextSelection, __uuidof(ITextSelection));
_COM_SMARTPTR_TYPEDEF(ITextStoryRanges, __uuidof(ITextStoryRanges));
_COM_SMARTPTR_TYPEDEF(ITextDocument, __uuidof(ITextDocument));
_COM_SMARTPTR_TYPEDEF(ITextDocument2, __uuidof(ITextDocument2));
_COM_SMARTPTR_TYPEDEF(ITextMsgFilter, __uuidof(ITextMsgFilter));
//
// Type library items
//
enum __MIDL___MIDL_itf_tom_0000_0001
{
tomFalse = 0,
tomTrue = -1,
tomUndefined = -9999999,
tomToggle = -9999998,
tomAutoColor = -9999997,
tomDefault = -9999996,
tomSuspend = -9999995,
tomResume = -9999994,
tomApplyNow = 0,
tomApplyLater = 1,
tomTrackParms = 2,
tomCacheParms = 3,
tomBackward = -1073741823,
tomForward = 1073741823,
tomMove = 0,
tomExtend = 1,
tomNoSelection = 0,
tomSelectionIP = 1,
tomSelectionNormal = 2,
tomSelectionFrame = 3,
tomSelectionColumn = 4,
tomSelectionRow = 5,
tomSelectionBlock = 6,
tomSelectionInlineShape = 7,
tomSelectionShape = 8,
tomSelStartActive = 1,
tomSelAtEOL = 2,
tomSelOvertype = 4,
tomSelActive = 8,
tomSelReplace = 16,
tomEnd = 0,
tomStart = 32,
tomCollapseEnd = 0,
tomCollapseStart = 1,
tomClientCoord = 256,
tomNone = 0,
tomSingle = 1,
tomWords = 2,
tomDouble = 3,
tomDotted = 4,
tomDash = 5,
tomDashDot = 6,
tomDashDotDot = 7,
tomWave = 8,
tomThick = 9,
tomHair = 10,
tomLineSpaceSingle = 0,
tomLineSpace1pt5 = 1,
tomLineSpaceDouble = 2,
tomLineSpaceAtLeast = 3,
tomLineSpaceExactly = 4,
tomLineSpaceMultiple = 5,
tomAlignLeft = 0,
tomAlignCenter = 1,
tomAlignRight = 2,
tomAlignJustify = 3,
tomAlignDecimal = 3,
tomAlignBar = 4,
tomAlignInterWord = 3,
tomAlignInterLetter = 4,
tomAlignScaled = 5,
tomAlignGlyphs = 6,
tomAlignSnapGrid = 7,
tomSpaces = 0,
tomDots = 1,
tomDashes = 2,
tomLines = 3,
tomThickLines = 4,
tomEquals = 5,
tomTabBack = -3,
tomTabNext = -2,
tomTabHere = -1,
tomListNone = 0,
tomListBullet = 1,
tomListNumberAsArabic = 2,
tomListNumberAsLCLetter = 3,
tomListNumberAsUCLetter = 4,
tomListNumberAsLCRoman = 5,
tomListNumberAsUCRoman = 6,
tomListNumberAsSequence = 7,
tomListParentheses = 65536,
tomListPeriod = 131072,
tomListPlain = 196608,
tomCharacter = 1,
tomWord = 2,
tomSentence = 3,
tomParagraph = 4,
tomLine = 5,
tomStory = 6,
tomScreen = 7,
tomSection = 8,
tomColumn = 9,
tomRow = 10,
tomWindow = 11,
tomCell = 12,
tomCharFormat = 13,
tomParaFormat = 14,
tomTable = 15,
tomObject = 16,
tomMatchWord = 2,
tomMatchCase = 4,
tomMatchPattern = 8,
tomUnknownStory = 0,
tomMainTextStory = 1,
tomFootnotesStory = 2,
tomEndnotesStory = 3,
tomCommentsStory = 4,
tomTextFrameStory = 5,
tomEvenPagesHeaderStory = 6,
tomPrimaryHeaderStory = 7,
tomEvenPagesFooterStory = 8,
tomPrimaryFooterStory = 9,
tomFirstPageHeaderStory = 10,
tomFirstPageFooterStory = 11,
tomNoAnimation = 0,
tomLasVegasLights = 1,
tomBlinkingBackground = 2,
tomSparkleText = 3,
tomMarchingBlackAnts = 4,
tomMarchingRedAnts = 5,
tomShimmer = 6,
tomWipeDown = 7,
tomWipeRight = 8,
tomAnimationMax = 8,
tomLowerCase = 0,
tomUpperCase = 1,
tomTitleCase = 2,
tomSentenceCase = 4,
tomToggleCase = 5,
tomReadOnly = 256,
tomShareDenyRead = 512,
tomShareDenyWrite = 1024,
tomPasteFile = 4096,
tomCreateNew = 16,
tomCreateAlways = 32,
tomOpenExisting = 48,
tomOpenAlways = 64,
tomTruncateExisting = 80,
tomRTF = 1,
tomText = 2,
tomHTML = 3,
tomWordDocument = 4,
tomBold = -2147483647,
tomItalic = -2147483646,
tomUnderline = -2147483644,
tomStrikeout = -2147483640,
tomProtected = -2147483632,
tomLink = -2147483616,
tomSmallCaps = -2147483584,
tomAllCaps = -2147483520,
tomHidden = -2147483392,
tomOutline = -2147483136,
tomShadow = -2147482624,
tomEmboss = -2147481600,
tomImprint = -2147479552,
tomDisabled = -2147475456,
tomRevised = -2147467264,
tomNormalCaret = 0,
tomKoreanBlockCaret = 1,
tomIncludeInset = 1,
tomIgnoreCurrentFont = 0,
tomMatchFontCharset = 1,
tomMatchFontSignature = 2,
tomCharset = 0x80000000,
tomRE10Mode = 1,
tomNoIME = 524288,
tomSelfIME = 262144
};
struct __declspec(uuid("8cc497c3-a1df-11ce-8098-00aa0047be5d"))
ITextFont : IDispatch
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall get_Duplicate (
/*[out,retval]*/ struct ITextFont * * ppFont ) = 0;
virtual HRESULT __stdcall put_Duplicate (
/*[in]*/ struct ITextFont * ppFont ) = 0;
virtual HRESULT __stdcall CanChange (
/*[out,retval]*/ long * pB ) = 0;
virtual HRESULT __stdcall IsEqual (
/*[in]*/ struct ITextFont * pFont,
/*[out,retval]*/ long * pB ) = 0;
virtual HRESULT __stdcall Reset (
/*[in]*/ long Value ) = 0;
virtual HRESULT __stdcall get_Style (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Style (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_AllCaps (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_AllCaps (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Animation (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Animation (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_BackColor (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_BackColor (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Bold (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Bold (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Emboss (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Emboss (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_ForeColor (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_ForeColor (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Hidden (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Hidden (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Engrave (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Engrave (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Italic (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Italic (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Kerning (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall put_Kerning (
/*[in]*/ float pValue ) = 0;
virtual HRESULT __stdcall get_LanguageID (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_LanguageID (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Name (
/*[out,retval]*/ BSTR * pbstr ) = 0;
virtual HRESULT __stdcall put_Name (
/*[in]*/ BSTR pbstr ) = 0;
virtual HRESULT __stdcall get_Outline (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Outline (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Position (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall put_Position (
/*[in]*/ float pValue ) = 0;
virtual HRESULT __stdcall get_Protected (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Protected (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Shadow (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Shadow (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Size (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall put_Size (
/*[in]*/ float pValue ) = 0;
virtual HRESULT __stdcall get_SmallCaps (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_SmallCaps (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Spacing (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall put_Spacing (
/*[in]*/ float pValue ) = 0;
virtual HRESULT __stdcall get_StrikeThrough (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_StrikeThrough (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Subscript (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Subscript (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Superscript (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Superscript (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Underline (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Underline (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Weight (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Weight (
/*[in]*/ long pValue ) = 0;
};
struct __declspec(uuid("8cc497c4-a1df-11ce-8098-00aa0047be5d"))
ITextPara : IDispatch
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall get_Duplicate (
/*[out,retval]*/ struct ITextPara * * ppPara ) = 0;
virtual HRESULT __stdcall put_Duplicate (
/*[in]*/ struct ITextPara * ppPara ) = 0;
virtual HRESULT __stdcall CanChange (
/*[out,retval]*/ long * pB ) = 0;
virtual HRESULT __stdcall IsEqual (
/*[in]*/ struct ITextPara * pPara,
/*[out,retval]*/ long * pB ) = 0;
virtual HRESULT __stdcall Reset (
/*[in]*/ long Value ) = 0;
virtual HRESULT __stdcall get_Style (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Style (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Alignment (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Alignment (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_Hyphenation (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Hyphenation (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_FirstLineIndent (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall get_KeepTogether (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_KeepTogether (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_KeepWithNext (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_KeepWithNext (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_LeftIndent (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall get_LineSpacing (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall get_LineSpacingRule (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall get_ListAlignment (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_ListAlignment (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_ListLevelIndex (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_ListLevelIndex (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_ListStart (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_ListStart (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_ListTab (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall put_ListTab (
/*[in]*/ float pValue ) = 0;
virtual HRESULT __stdcall get_ListType (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_ListType (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_NoLineNumber (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_NoLineNumber (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_PageBreakBefore (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_PageBreakBefore (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_RightIndent (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall put_RightIndent (
/*[in]*/ float pValue ) = 0;
virtual HRESULT __stdcall SetIndents (
/*[in]*/ float StartIndent,
/*[in]*/ float LeftIndent,
/*[in]*/ float RightIndent ) = 0;
virtual HRESULT __stdcall SetLineSpacing (
/*[in]*/ long LineSpacingRule,
/*[in]*/ float LineSpacing ) = 0;
virtual HRESULT __stdcall get_SpaceAfter (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall put_SpaceAfter (
/*[in]*/ float pValue ) = 0;
virtual HRESULT __stdcall get_SpaceBefore (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall put_SpaceBefore (
/*[in]*/ float pValue ) = 0;
virtual HRESULT __stdcall get_WidowControl (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_WidowControl (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_TabCount (
/*[out,retval]*/ long * pCount ) = 0;
virtual HRESULT __stdcall AddTab (
/*[in]*/ float tbPos,
/*[in]*/ long tbAlign,
/*[in]*/ long tbLeader ) = 0;
virtual HRESULT __stdcall ClearAllTabs ( ) = 0;
virtual HRESULT __stdcall DeleteTab (
/*[in]*/ float tbPos ) = 0;
virtual HRESULT __stdcall GetTab (
/*[in]*/ long iTab,
/*[out]*/ float * ptbPos,
/*[out]*/ long * ptbAlign,
/*[out]*/ long * ptbLeader ) = 0;
};
struct __declspec(uuid("8cc497c2-a1df-11ce-8098-00aa0047be5d"))
ITextRange : IDispatch
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall get_Text (
/*[out,retval]*/ BSTR * pbstr ) = 0;
virtual HRESULT __stdcall put_Text (
/*[in]*/ BSTR pbstr ) = 0;
virtual HRESULT __stdcall get_Char (
/*[out,retval]*/ long * pch ) = 0;
virtual HRESULT __stdcall put_Char (
/*[in]*/ long pch ) = 0;
virtual HRESULT __stdcall get_Duplicate (
/*[out,retval]*/ struct ITextRange * * ppRange ) = 0;
virtual HRESULT __stdcall get_FormattedText (
/*[out,retval]*/ struct ITextRange * * ppRange ) = 0;
virtual HRESULT __stdcall put_FormattedText (
/*[in]*/ struct ITextRange * ppRange ) = 0;
virtual HRESULT __stdcall get_Start (
/*[out,retval]*/ long * pcpFirst ) = 0;
virtual HRESULT __stdcall put_Start (
/*[in]*/ long pcpFirst ) = 0;
virtual HRESULT __stdcall get_End (
/*[out,retval]*/ long * pcpLim ) = 0;
virtual HRESULT __stdcall put_End (
/*[in]*/ long pcpLim ) = 0;
virtual HRESULT __stdcall get_Font (
/*[out,retval]*/ struct ITextFont * * pFont ) = 0;
virtual HRESULT __stdcall put_Font (
/*[in]*/ struct ITextFont * pFont ) = 0;
virtual HRESULT __stdcall get_Para (
/*[out,retval]*/ struct ITextPara * * pPara ) = 0;
virtual HRESULT __stdcall put_Para (
/*[in]*/ struct ITextPara * pPara ) = 0;
virtual HRESULT __stdcall get_StoryLength (
/*[out,retval]*/ long * pcch ) = 0;
virtual HRESULT __stdcall get_StoryType (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall Collapse (
/*[in]*/ long bStart ) = 0;
virtual HRESULT __stdcall Expand (
/*[in]*/ long Unit,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall GetIndex (
/*[in]*/ long Unit,
/*[out,retval]*/ long * pIndex ) = 0;
virtual HRESULT __stdcall SetIndex (
/*[in]*/ long Unit,
/*[in]*/ long Index,
/*[in]*/ long Extend ) = 0;
virtual HRESULT __stdcall SetRange (
/*[in]*/ long cpActive,
/*[in]*/ long cpOther ) = 0;
virtual HRESULT __stdcall InRange (
/*[in]*/ struct ITextRange * pRange,
/*[out,retval]*/ long * pB ) = 0;
virtual HRESULT __stdcall InStory (
/*[in]*/ struct ITextRange * pRange,
/*[out,retval]*/ long * pB ) = 0;
virtual HRESULT __stdcall IsEqual (
/*[in]*/ struct ITextRange * pRange,
/*[out,retval]*/ long * pB ) = 0;
virtual HRESULT __stdcall Select ( ) = 0;
virtual HRESULT __stdcall StartOf (
/*[in]*/ long Unit,
/*[in]*/ long Extend,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall EndOf (
/*[in]*/ long Unit,
/*[in]*/ long Extend,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall Move (
/*[in]*/ long Unit,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveStart (
/*[in]*/ long Unit,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveEnd (
/*[in]*/ long Unit,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveWhile (
/*[in]*/ VARIANT * Cset,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveStartWhile (
/*[in]*/ VARIANT * Cset,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveEndWhile (
/*[in]*/ VARIANT * Cset,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveUntil (
/*[in]*/ VARIANT * Cset,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveStartUntil (
/*[in]*/ VARIANT * Cset,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveEndUntil (
/*[in]*/ VARIANT * Cset,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall FindShit (
/*[in]*/ BSTR bstr,
/*[in]*/ long cch,
/*[in]*/ long Flags,
/*[out,retval]*/ long * pLength ) = 0;
virtual HRESULT __stdcall FindTextStart (
/*[in]*/ BSTR bstr,
/*[in]*/ long cch,
/*[in]*/ long Flags,
/*[out,retval]*/ long * pLength ) = 0;
virtual HRESULT __stdcall FindTextEnd (
/*[in]*/ BSTR bstr,
/*[in]*/ long cch,
/*[in]*/ long Flags,
/*[out,retval]*/ long * pLength ) = 0;
virtual HRESULT __stdcall Delete (
/*[in]*/ long Unit,
/*[in]*/ long Count,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall Cut (
/*[out]*/ VARIANT * pVar ) = 0;
virtual HRESULT __stdcall Copy (
/*[out]*/ VARIANT * pVar ) = 0;
virtual HRESULT __stdcall Paste (
/*[in]*/ VARIANT * pVar,
/*[in]*/ long Format ) = 0;
virtual HRESULT __stdcall CanPaste (
/*[in]*/ VARIANT * pVar,
/*[in]*/ long Format,
/*[out,retval]*/ long * pB ) = 0;
virtual HRESULT __stdcall CanEdit (
/*[out,retval]*/ long * pbCanEdit ) = 0;
virtual HRESULT __stdcall ChangeCase (
/*[in]*/ long Type ) = 0;
virtual HRESULT __stdcall GetPoint (
/*[in]*/ long Type,
/*[out]*/ long * px,
/*[out]*/ long * py ) = 0;
virtual HRESULT __stdcall SetPoint (
/*[in]*/ long x,
/*[in]*/ long y,
/*[in]*/ long Type,
/*[in]*/ long Extend ) = 0;
virtual HRESULT __stdcall ScrollIntoView (
/*[in]*/ long Value ) = 0;
virtual HRESULT __stdcall GetEmbeddedObject (
/*[out,retval]*/ IUnknown * * ppv ) = 0;
};
struct __declspec(uuid("8cc497c1-a1df-11ce-8098-00aa0047be5d"))
ITextSelection : ITextRange
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall get_Flags (
/*[out,retval]*/ long * pFlags ) = 0;
virtual HRESULT __stdcall put_Flags (
/*[in]*/ long pFlags ) = 0;
virtual HRESULT __stdcall get_Type (
/*[out,retval]*/ long * pType ) = 0;
virtual HRESULT __stdcall MoveLeft (
/*[in]*/ long Unit,
/*[in]*/ long Count,
/*[in]*/ long Extend,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveRight (
/*[in]*/ long Unit,
/*[in]*/ long Count,
/*[in]*/ long Extend,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveUp (
/*[in]*/ long Unit,
/*[in]*/ long Count,
/*[in]*/ long Extend,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall MoveDown (
/*[in]*/ long Unit,
/*[in]*/ long Count,
/*[in]*/ long Extend,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall HomeKey (
/*[in]*/ long Unit,
/*[in]*/ long Extend,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall EndKey (
/*[in]*/ long Unit,
/*[in]*/ long Extend,
/*[out,retval]*/ long * pDelta ) = 0;
virtual HRESULT __stdcall TypeText (
/*[in]*/ BSTR bstr ) = 0;
};
struct __declspec(uuid("8cc497c5-a1df-11ce-8098-00aa0047be5d"))
ITextStoryRanges : IDispatch
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall _NewEnum (
/*[out,retval]*/ IUnknown * * ppunkEnum ) = 0;
virtual HRESULT __stdcall Item (
/*[in]*/ long Index,
/*[out,retval]*/ struct ITextRange * * ppRange ) = 0;
virtual HRESULT __stdcall get_Count (
/*[out,retval]*/ long * pCount ) = 0;
};
struct __declspec(uuid("8cc497c0-a1df-11ce-8098-00aa0047be5d"))
ITextDocument : IDispatch
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall get_Name (
/*[out,retval]*/ BSTR * pName ) = 0;
virtual HRESULT __stdcall get_Selection (
/*[out,retval]*/ struct ITextSelection * * ppSel ) = 0;
virtual HRESULT __stdcall get_StoryCount (
/*[out,retval]*/ long * pCount ) = 0;
virtual HRESULT __stdcall get_StoryRanges (
/*[out,retval]*/ struct ITextStoryRanges * * ppStories ) = 0;
virtual HRESULT __stdcall get_Saved (
/*[out,retval]*/ long * pValue ) = 0;
virtual HRESULT __stdcall put_Saved (
/*[in]*/ long pValue ) = 0;
virtual HRESULT __stdcall get_DefaultTabStop (
/*[out,retval]*/ float * pValue ) = 0;
virtual HRESULT __stdcall put_DefaultTabStop (
/*[in]*/ float pValue ) = 0;
virtual HRESULT __stdcall New ( ) = 0;
virtual HRESULT __stdcall Open (
/*[in]*/ VARIANT * pVar,
/*[in]*/ long Flags,
/*[in]*/ long CodePage ) = 0;
virtual HRESULT __stdcall Save (
/*[in]*/ VARIANT * pVar,
/*[in]*/ long Flags,
/*[in]*/ long CodePage ) = 0;
virtual HRESULT __stdcall Freeze (
/*[out,retval]*/ long * pCount ) = 0;
virtual HRESULT __stdcall Unfreeze (
/*[out,retval]*/ long * pCount ) = 0;
virtual HRESULT __stdcall BeginEditCollection ( ) = 0;
virtual HRESULT __stdcall EndEditCollection ( ) = 0;
virtual HRESULT __stdcall Undo (
/*[in]*/ long Count,
/*[out,retval]*/ long * prop ) = 0;
virtual HRESULT __stdcall Redo (
/*[in]*/ long Count,
/*[out,retval]*/ long * prop ) = 0;
virtual HRESULT __stdcall Range (
/*[in]*/ long cp1,
/*[in]*/ long cp2,
/*[out,retval]*/ struct ITextRange * * ppRange ) = 0;
virtual HRESULT __stdcall RangeFromPoint (
/*[in]*/ long x,
/*[in]*/ long y,
/*[out,retval]*/ struct ITextRange * * ppRange ) = 0;
};
struct __declspec(uuid("01c25500-4268-11d1-883a-3c8b00c10000"))
ITextDocument2 : ITextDocument
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall AttachMsgFilter (
/*[in]*/ IUnknown * pFilter ) = 0;
virtual HRESULT __stdcall SetEffectColor (
/*[in]*/ long Index,
/*[in]*/ unsigned long cr ) = 0;
virtual HRESULT __stdcall GetEffectColor (
/*[in]*/ long Index,
/*[out]*/ unsigned long * pcr ) = 0;
virtual HRESULT __stdcall get_CaretType (
/*[out,retval]*/ long * pCaretType ) = 0;
virtual HRESULT __stdcall put_CaretType (
/*[in]*/ long pCaretType ) = 0;
virtual HRESULT __stdcall GetImmContext (
/*[out,retval]*/ long * pContext ) = 0;
virtual HRESULT __stdcall ReleaseImmContext (
/*[in]*/ long Context ) = 0;
virtual HRESULT __stdcall GetPreferredFont (
/*[in]*/ long cp,
/*[in]*/ long CodePage,
/*[in]*/ long Option,
/*[in]*/ long curCodepage,
/*[in]*/ long curFontSize,
/*[out]*/ BSTR * pbstr,
/*[out]*/ long * pPitchAndFamily,
/*[out]*/ long * pNewFontSize ) = 0;
virtual HRESULT __stdcall get_NotificationMode (
/*[out,retval]*/ long * pMode ) = 0;
virtual HRESULT __stdcall put_NotificationMode (
/*[in]*/ long pMode ) = 0;
virtual HRESULT __stdcall GetClientRect (
/*[in]*/ long Type,
/*[out]*/ long * pLeft,
/*[out]*/ long * pTop,
/*[out]*/ long * pRight,
/*[out]*/ long * pBottom ) = 0;
virtual HRESULT __stdcall get_SelectionEx (
/*[out,retval]*/ struct ITextSelection * * ppSel ) = 0;
virtual HRESULT __stdcall GetWindow (
/*[out]*/ long * phWnd ) = 0;
virtual HRESULT __stdcall GetFEFlags (
/*[out]*/ long * pFlags ) = 0;
virtual HRESULT __stdcall UpdateWindow ( ) = 0;
virtual HRESULT __stdcall CheckTextLimit (
long cch,
long * pcch ) = 0;
virtual HRESULT __stdcall IMEInProgress (
long Mode ) = 0;
virtual HRESULT __stdcall SysBeep ( ) = 0;
virtual HRESULT __stdcall Update (
/*[in]*/ long Mode ) = 0;
virtual HRESULT __stdcall Notify (
/*[in]*/ long Notify ) = 0;
};
#pragma pack(push, 4)
union __MIDL_IWinTypes_0009
{
long hInproc;
long hRemote;
};
#pragma pack(pop)
#pragma pack(push, 4)
struct _RemotableHandle
{
long fContext;
union __MIDL_IWinTypes_0009 u;
};
#pragma pack(pop)
struct __declspec(uuid("a3787420-4267-11d1-883a-3c8b00c10000"))
ITextMsgFilter : IUnknown
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall AttachDocument (
/*[in]*/ wireHWND hwnd,
/*[in]*/ struct ITextDocument2 * pTextDoc ) = 0;
virtual HRESULT __stdcall HandleMessage (
/*[in,out]*/ unsigned int * pmsg,
/*[in,out]*/ UINT_PTR * pwparam,
/*[in,out]*/ LONG_PTR * plparam,
/*[out]*/ LONG_PTR * plres ) = 0;
virtual HRESULT __stdcall AttachMsgFilter (
/*[in]*/ struct ITextMsgFilter * pMsgFilter ) = 0;
};
//
// Named GUID constants initializations
//
extern "C" const GUID __declspec(selectany) LIBID_tom =
{0x8cc497c9,0xa1df,0x11ce,{0x80,0x98,0x00,0xaa,0x00,0x47,0xbe,0x5d}};
extern "C" const GUID __declspec(selectany) IID_ITextFont =
{0x8cc497c3,0xa1df,0x11ce,{0x80,0x98,0x00,0xaa,0x00,0x47,0xbe,0x5d}};
extern "C" const GUID __declspec(selectany) IID_ITextPara =
{0x8cc497c4,0xa1df,0x11ce,{0x80,0x98,0x00,0xaa,0x00,0x47,0xbe,0x5d}};
extern "C" const GUID __declspec(selectany) IID_ITextRange =
{0x8cc497c2,0xa1df,0x11ce,{0x80,0x98,0x00,0xaa,0x00,0x47,0xbe,0x5d}};
extern "C" const GUID __declspec(selectany) IID_ITextSelection =
{0x8cc497c1,0xa1df,0x11ce,{0x80,0x98,0x00,0xaa,0x00,0x47,0xbe,0x5d}};
extern "C" const GUID __declspec(selectany) IID_ITextStoryRanges =
{0x8cc497c5,0xa1df,0x11ce,{0x80,0x98,0x00,0xaa,0x00,0x47,0xbe,0x5d}};
extern "C" const GUID __declspec(selectany) IID_ITextDocument =
{0x8cc497c0,0xa1df,0x11ce,{0x80,0x98,0x00,0xaa,0x00,0x47,0xbe,0x5d}};
extern "C" const GUID __declspec(selectany) IID_ITextDocument2 =
{0x01c25500,0x4268,0x11d1,{0x88,0x3a,0x3c,0x8b,0x00,0xc1,0x00,0x00}};
extern "C" const GUID __declspec(selectany) IID_ITextMsgFilter =
{0xa3787420,0x4267,0x11d1,{0x88,0x3a,0x3c,0x8b,0x00,0xc1,0x00,0x00}};
} // namespace tom
#pragma pack(pop)

View File

@@ -0,0 +1,342 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/win_local.h"
#include "ColorButton.h"
#include "MaskEdit.h"
#include "../../sys/win32/rc/guied_resource.h"
static HHOOK gAlphaHook = NULL;
static HWND gAlphaDlg = NULL;
/*
================
AlphaSlider_DrawArrow
Draws the arrow under alpha slider
================
*/
static void AlphaSlider_DrawArrow ( HDC hDC, RECT* pRect, COLORREF color )
{
POINT ptsArrow[3];
ptsArrow[0].x = pRect->left;
ptsArrow[0].y = pRect->bottom;
ptsArrow[1].x = (pRect->left + pRect->right)/2;
ptsArrow[1].y = pRect->top;
ptsArrow[2].x = pRect->right;
ptsArrow[2].y = pRect->bottom;
HBRUSH arrowBrush = CreateSolidBrush ( color );
HPEN arrowPen = CreatePen ( PS_SOLID, 1, color );
HGDIOBJ oldBrush = SelectObject ( hDC, arrowBrush );
HGDIOBJ oldPen = SelectObject ( hDC, arrowPen );
SetPolyFillMode(hDC, WINDING);
Polygon(hDC, ptsArrow, 3);
SelectObject ( hDC, oldBrush );
SelectObject ( hDC, oldPen );
DeleteObject ( arrowBrush );
DeleteObject ( arrowPen );
}
/*
================
AlphaSlider_WndProc
Window procedure for the alpha slider control
================
*/
LRESULT CALLBACK AlphaSlider_WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch ( msg )
{
case WM_LBUTTONDOWN:
{
RECT rClient;
float v;
GetClientRect ( hwnd, &rClient );
v = (float)((short)LOWORD(lParam)-5) / (float)(rClient.right - rClient.left - 10);
if ( v < 0 ) v = 0;
if ( v > 1.0f ) v = 1.0f;
SetWindowLong ( hwnd, GWL_USERDATA, MAKELONG(0x8000,(unsigned short)(255.0f * v)) );
InvalidateRect ( hwnd, NULL, FALSE );
SetCapture ( hwnd );
break;
}
case WM_MOUSEMOVE:
if ( LOWORD(GetWindowLong ( hwnd, GWL_USERDATA ) ) & 0x8000 )
{
RECT rClient;
float v;
GetClientRect ( hwnd, &rClient );
v = (float)((short)LOWORD(lParam)-5) / (float)(rClient.right - rClient.left - 10);
if ( v < 0 ) v = 0;
if ( v > 1.0f ) v = 1.0f;
SetWindowLong ( hwnd, GWL_USERDATA, MAKELONG(0x8000,(unsigned short)(255.0f * v)) );
InvalidateRect ( hwnd, NULL, FALSE );
}
break;
case WM_LBUTTONUP:
if ( LOWORD(GetWindowLong ( hwnd, GWL_USERDATA ) ) & 0x8000 )
{
RECT rClient;
float v;
GetClientRect ( hwnd, &rClient );
v = (float)((short)LOWORD(lParam)-5) / (float)(rClient.right - rClient.left - 10);
if ( v < 0 ) v = 0;
if ( v > 1.0f ) v = 1.0f;
SetWindowLong ( hwnd, GWL_USERDATA, MAKELONG(0x8000,(unsigned short)(255.0f * v)) );
InvalidateRect ( hwnd, NULL, FALSE );
ReleaseCapture ( );
SendMessage ( GetParent ( hwnd ), WM_COMMAND, MAKELONG(GetWindowLong (hwnd,GWL_ID),0), 0 );
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hDC = BeginPaint ( hwnd, &ps );
RECT rDraw;
RECT rClient;
GetClientRect ( hwnd, &rClient );
// Setup the gradient rect
CopyRect ( &rDraw, &rClient );
rDraw.left += 5;
rDraw.right -= 5;
rDraw.bottom -= 6;
// Draw the gradient
int parts = 20;
RECT rColor;
float step = (float)(rDraw.right-rDraw.left) / (float)parts;
CopyRect ( &rColor, &rDraw );
for ( int i = 0; i < parts; i ++ )
{
float color = ((float)i / (float)parts) * 255.0f;
rColor.left = rDraw.left + i * step;
rColor.right = rColor.left + step + 1;
HBRUSH brush = CreateSolidBrush ( RGB((int)color,(int)color,(int)color) );
FillRect ( hDC, &rColor, brush );
DeleteObject ( brush );
}
// Draw a frame around the gradient
FrameRect (hDC, &rDraw, (HBRUSH)GetStockObject ( BLACK_BRUSH ) );
// Make sure the area below the graident is filled in
rClient.top = rDraw.bottom;
FillRect ( hDC, &rClient, GetSysColorBrush ( COLOR_3DFACE ) );
// Draw the thumb
RECT rThumb;
short s = HIWORD(GetWindowLong ( hwnd, GWL_USERDATA ));
float thumb = (float)(short)s;
thumb /= 255.0f;
thumb *= (float)(rDraw.right-rDraw.left);
rThumb.left = rDraw.left - 5 + thumb;
rThumb.right = rThumb.left + 10;
rThumb.top = rDraw.bottom + 1;
rThumb.bottom = rThumb.top + 5;
AlphaSlider_DrawArrow ( hDC, &rThumb, RGB(0,0,0) );
EndPaint ( hwnd, &ps );
return 0;
}
}
return DefWindowProc ( hwnd, msg, wParam, lParam );
}
/*
================
AlphaSelectDlg_GetMsgProc
Ensures normal dialog functions work in the alpha select dialog
================
*/
LRESULT FAR PASCAL AlphaSelectDlg_GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
LPMSG lpMsg = (LPMSG) lParam;
if ( nCode >= 0 && PM_REMOVE == wParam )
{
// Don't translate non-input events.
if ( (lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST) )
{
if ( IsDialogMessage( gAlphaDlg, lpMsg) )
{
// The value returned from this hookproc is ignored,
// and it cannot be used to tell Windows the message has been handled.
// To avoid further processing, convert the message to WM_NULL
// before returning.
lpMsg->message = WM_NULL;
lpMsg->lParam = 0;
lpMsg->wParam = 0;
}
}
}
return CallNextHookEx(gAlphaHook, nCode, wParam, lParam);
}
/*
================
AlphaSelectDlg_WndProc
Window procedure for the alpha select dialog
================
*/
INT_PTR CALLBACK AlphaSelectDlg_WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch ( msg )
{
case WM_INITDIALOG:
{
int color;
gAlphaDlg = hwnd;
gAlphaHook = SetWindowsHookEx( WH_GETMESSAGE, AlphaSelectDlg_GetMsgProc, NULL, GetCurrentThreadId() );
color = GetRValue(ColorButton_GetColor ((HWND)lParam));
// The lParam for the alpha select dialog is the window handle of the button pressed
SetWindowLong ( hwnd, GWL_USERDATA, lParam );
// Subclass the alpha
SetWindowLong ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA, MAKELONG(0,color) );
// Numbers only on the edit box and start it with the current alpha value.
NumberEdit_Attach ( GetDlgItem ( hwnd, IDC_GUIED_ALPHA ) );
SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_ALPHA ), va("%.3f", ((float)color / 255.0f) ) );
break;
}
case WM_DESTROY:
UnhookWindowsHookEx( gAlphaHook );
ReleaseCapture ( );
gAlphaDlg = NULL;
break;
case WM_ACTIVATE:
if ( !LOWORD(wParam) )
{
EndDialog ( hwnd, 0 );
}
break;
case WM_COMMAND:
switch ( LOWORD(wParam) )
{
case IDC_GUIED_ALPHA:
{
char temp[64];
float value;
// Get the current text in the window and convert it to a float
GetDlgItemText ( hwnd, IDC_GUIED_ALPHA, temp, 64 );
value = atof ( temp );
if ( value < 0.0f )
{
value = 0.0f;
}
else if ( value > 1.0f )
{
value = 1.0f;
}
// Set the current alpha value in the slider
SetWindowLong ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA, MAKELONG(0,(255.0f * value)) );
break;
}
case IDC_GUIED_ALPHASLIDER:
case IDOK:
{
int color = (short)HIWORD(GetWindowLong ( GetDlgItem ( hwnd, IDC_GUIED_ALPHASLIDER ), GWL_USERDATA ));
ColorButton_SetColor ( (HWND)GetWindowLong ( hwnd, GWL_USERDATA ), RGB(color,color,color) );
EndDialog ( hwnd, 0 );
break;
}
case IDCANCEL:
EndDialog ( hwnd, 0 );
break;
}
break;
}
return FALSE;
}
/*
================
AlphaButton_OpenPopup
Opens the popup window under the alpha button
================
*/
void AlphaButton_OpenPopup ( HWND button )
{
RECT rWindow;
WNDCLASSEX wndClass;
HWND dlg;
// Make sure the alpha slider window class is registered
memset ( &wndClass, 0, sizeof(wndClass) );
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.lpszClassName = "GUIED_ALPHASLIDER";
wndClass.lpfnWndProc = AlphaSlider_WndProc;
wndClass.hInstance = win32.hInstance;
RegisterClassEx ( &wndClass );
GetWindowRect ( button, &rWindow );
dlg = CreateDialogParam ( win32.hInstance, MAKEINTRESOURCE(IDD_GUIED_ALPHA), GetParent(button), AlphaSelectDlg_WndProc, (LPARAM)button );
SetWindowPos ( dlg, NULL, rWindow.left, rWindow.bottom + 1, 0, 0, SWP_NOSIZE|SWP_NOZORDER );
ShowWindow ( dlg, SW_SHOW );
UpdateWindow ( dlg );
SetFocus ( dlg );
}

View File

@@ -0,0 +1,206 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "ColorButton.h"
static const int ARROW_SIZE_CX = 4 ;
static const int ARROW_SIZE_CY = 2 ;
/*
================
ColorButton_SetColor
Sets the current color button color
================
*/
void ColorButton_SetColor ( HWND hWnd, COLORREF color )
{
if ( NULL == hWnd )
{
return;
}
SetWindowLong ( hWnd, GWL_USERDATA, color );
InvalidateRect ( hWnd, NULL, FALSE );
}
void ColorButton_SetColor ( HWND hWnd, const char* color )
{
float red;
float green;
float blue;
float alpha;
if ( NULL == hWnd )
{
return;
}
sscanf ( color, "%f,%f,%f,%f", &red, &green, &blue, &alpha );
ColorButton_SetColor ( hWnd, RGB(red*255.0f, green*255.0f, blue*255.0f) );
}
void AlphaButton_SetColor ( HWND hWnd, const char* color )
{
float red;
float green;
float blue;
float alpha;
if ( NULL == hWnd )
{
return;
}
sscanf ( color, "%f,%f,%f,%f", &red, &green, &blue, &alpha );
ColorButton_SetColor ( hWnd, RGB(alpha*255.0f, alpha*255.0f, alpha*255.0f) );
}
/*
================
ColorButton_GetColor
Retrieves the current color button color
================
*/
COLORREF ColorButton_GetColor ( HWND hWnd )
{
return (COLORREF) GetWindowLong ( hWnd, GWL_USERDATA );
}
/*
================
ColorButton_DrawArrow
Draws the arrow on the color button
================
*/
static void ColorButton_DrawArrow ( HDC hDC, RECT* pRect, COLORREF color )
{
POINT ptsArrow[3];
ptsArrow[0].x = pRect->left;
ptsArrow[0].y = pRect->top;
ptsArrow[1].x = pRect->right;
ptsArrow[1].y = pRect->top;
ptsArrow[2].x = (pRect->left + pRect->right)/2;
ptsArrow[2].y = pRect->bottom;
HBRUSH arrowBrush = CreateSolidBrush ( color );
HPEN arrowPen = CreatePen ( PS_SOLID, 1, color );
HGDIOBJ oldBrush = SelectObject ( hDC, arrowBrush );
HGDIOBJ oldPen = SelectObject ( hDC, arrowPen );
SetPolyFillMode(hDC, WINDING);
Polygon(hDC, ptsArrow, 3);
SelectObject ( hDC, oldBrush );
SelectObject ( hDC, oldPen );
DeleteObject ( arrowBrush );
DeleteObject ( arrowPen );
}
/*
================
ColorButton_DrawItem
Draws the actual color button as as reponse to a WM_DRAWITEM message
================
*/
void ColorButton_DrawItem ( HWND hWnd, LPDRAWITEMSTRUCT dis )
{
assert ( dis );
HDC hDC = dis->hDC;
UINT state = dis->itemState;
RECT rDraw = dis->rcItem;
RECT rArrow;
// Draw outter edge
UINT uFrameState = DFCS_BUTTONPUSH|DFCS_ADJUSTRECT;
if (state & ODS_SELECTED)
{
uFrameState |= DFCS_PUSHED;
}
if (state & ODS_DISABLED)
{
uFrameState |= DFCS_INACTIVE;
}
DrawFrameControl ( hDC, &rDraw, DFC_BUTTON, uFrameState );
// Draw Focus
if (state & ODS_SELECTED)
{
OffsetRect(&rDraw, 1,1);
}
if (state & ODS_FOCUS)
{
RECT rFocus = {rDraw.left,
rDraw.top,
rDraw.right - 1,
rDraw.bottom};
DrawFocusRect ( hDC, &rFocus );
}
InflateRect ( &rDraw, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE) );
// Draw the arrow
rArrow.left = rDraw.right - ARROW_SIZE_CX - GetSystemMetrics(SM_CXEDGE) /2;
rArrow.right = rArrow.left + ARROW_SIZE_CX;
rArrow.top = (rDraw.bottom + rDraw.top)/2 - ARROW_SIZE_CY / 2;
rArrow.bottom = (rDraw.bottom + rDraw.top)/2 + ARROW_SIZE_CY / 2;
ColorButton_DrawArrow ( hDC, &rArrow, (state & ODS_DISABLED) ? ::GetSysColor(COLOR_GRAYTEXT) : RGB(0,0,0) );
rDraw.right = rArrow.left - GetSystemMetrics(SM_CXEDGE)/2;
// Draw separator
DrawEdge ( hDC, &rDraw, EDGE_ETCHED, BF_RIGHT);
rDraw.right -= (GetSystemMetrics(SM_CXEDGE) * 2) + 1 ;
// Draw Color
if ((state & ODS_DISABLED) == 0)
{
HBRUSH color = CreateSolidBrush ( (COLORREF)GetWindowLong ( hWnd, GWL_USERDATA ) );
FillRect ( hDC, &rDraw, color );
FrameRect ( hDC, &rDraw, (HBRUSH)::GetStockObject(BLACK_BRUSH));
DeleteObject( color );
}
}

View File

@@ -0,0 +1,40 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef COLORBUTTON_H_
#define COLORBUTTON_H_
void ColorButton_DrawItem ( HWND hWnd, LPDRAWITEMSTRUCT dis );
void ColorButton_SetColor ( HWND hWnd, COLORREF color );
void ColorButton_SetColor ( HWND hWnd, const char* color );
COLORREF ColorButton_GetColor ( HWND hWnd );
void AlphaButton_SetColor ( HWND hWnd, const char* color );
void AlphaButton_OpenPopup ( HWND button );
#endif // COLORBUTTON_H_

View File

@@ -0,0 +1,128 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef DIALOGHELPERS_H_
#define DIALOGHELPERS_H_
class rvDialogItem
{
public:
HWND mWindow;
int mID;
rvDialogItem ( int id ) { mID = id; }
void Cache ( HWND parent )
{
mWindow = GetDlgItem ( parent, mID );
}
void Check ( bool checked )
{
SendMessage ( mWindow, BM_SETCHECK, checked ? BST_CHECKED : BST_UNCHECKED, 0 );
}
void Enable ( bool enable )
{
EnableWindow ( mWindow, enable );
}
bool IsChecked ( void )
{
return SendMessage ( mWindow, BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
}
void SetText ( const char* text )
{
SetWindowText ( mWindow, text );
}
void GetText ( idStr& out )
{
char text[4096];
GetWindowText ( mWindow, text, 4095 );
out = text;
}
float GetFloat ( void )
{
idStr text;
GetText ( text );
return atof( text );
}
void SetFloat ( float f )
{
SetText ( va("%g", f ) );
}
operator HWND( void ) const { return mWindow; }
};
class rvDialogItemContainer
{
protected:
void Cache ( HWND parent, int count )
{
int i;
unsigned char* ptr;
ptr = (unsigned char*)this;
for ( i = 0; i < count; i ++, ptr += sizeof(rvDialogItem) )
{
((rvDialogItem*)ptr)->Cache ( parent );
}
}
};
#define DIALOGITEM_BEGIN(name) \
class name : public rvDialogItemContainer \
{ \
public: \
name ( void ) { } \
name ( HWND hwnd ) { Cache ( hwnd ); } \
void Cache ( HWND parent ) \
{ \
rvDialogItemContainer::Cache ( parent, sizeof(*this)/sizeof(rvDialogItem) ); \
}
#define DIALOGITEM(id,name) \
class c##name : public rvDialogItem \
{ \
public: \
c##name(int localid=id) : rvDialogItem ( localid ) { } \
} name;
#define DIALOGITEM_END() \
};
#endif // DIALOGHELPERS_H_

View File

@@ -0,0 +1,97 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#define MASKEDIT_MAXINVALID 1024
typedef struct
{
WNDPROC mProc;
char mInvalid[MASKEDIT_MAXINVALID];
} rvGEMaskEdit;
/*
================
MaskEdit_WndProc
Prevents the invalid characters from being entered
================
*/
LRESULT CALLBACK MaskEdit_WndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
rvGEMaskEdit* edit = (rvGEMaskEdit*)GetWindowLong ( hWnd, GWL_USERDATA );
WNDPROC wndproc = edit->mProc;
switch ( msg )
{
case WM_CHAR:
if ( strchr ( edit->mInvalid, wParam ) )
{
return 0;
}
break;
case WM_DESTROY:
delete edit;
SetWindowLong ( hWnd, GWL_WNDPROC, (LONG)wndproc );
break;
}
return CallWindowProc ( wndproc, hWnd, msg, wParam, lParam );
}
/*
================
MaskEdit_Attach
Attaches the mask edit control to a normal edit control
================
*/
void MaskEdit_Attach ( HWND hWnd, const char* invalid )
{
rvGEMaskEdit* edit = new rvGEMaskEdit;
edit->mProc = (WNDPROC)GetWindowLong ( hWnd, GWL_WNDPROC );
strcpy ( edit->mInvalid, invalid );
SetWindowLong ( hWnd, GWL_USERDATA, (LONG)edit );
SetWindowLong ( hWnd, GWL_WNDPROC, (LONG)MaskEdit_WndProc );
}
/*
================
NumberEdit_Attach
Allows editing of floating point numbers
================
*/
void NumberEdit_Attach ( HWND hWnd )
{
static const char invalid[] = "`~!@#$%^&*()_+|=\\qwertyuiop[]asdfghjkl;'zxcvbnm,/QWERTYUIOP{}ASDFGHJKL:ZXCVBNM<>";
MaskEdit_Attach ( hWnd, invalid );
}

View File

@@ -0,0 +1,34 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef MASKEDIT_H_
#define MASKEDIT_H_
void MaskEdit_Attach ( HWND hWnd, const char* invalid );
void NumberEdit_Attach ( HWND hWnd );
#endif // MASKEDIT_H_

View File

@@ -0,0 +1,504 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/win_local.h"
#include "../../sys/win32/rc/common_resource.h"
#include "OpenFileDialog.h"
char rvOpenFileDialog::mLookin[ MAX_OSPATH ];
/*
================
rvOpenFileDialog::rvOpenFileDialog
constructor
================
*/
rvOpenFileDialog::rvOpenFileDialog( void )
{
mWnd = NULL;
mInstance = NULL;
mBackBitmap = NULL;
mImageList = NULL;
mFlags = 0;
}
/*
================
rvOpenFileDialog::~rvOpenFileDialog
destructor
================
*/
rvOpenFileDialog::~rvOpenFileDialog ( void )
{
if ( mImageList )
{
ImageList_Destroy ( mImageList );
}
if ( mBackBitmap )
{
DeleteObject ( mBackBitmap );
}
}
/*
================
rvOpenFileDialog::DoModal
Opens the dialog and returns true if a filename was found
================
*/
bool rvOpenFileDialog::DoModal ( HWND parent )
{
mInstance = win32.hInstance;
INITCOMMONCONTROLSEX ex;
ex.dwICC = ICC_USEREX_CLASSES | ICC_LISTVIEW_CLASSES;
ex.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCommonControlsEx ( &ex );
return DialogBoxParam ( mInstance, MAKEINTRESOURCE(IDD_TOOLS_OPEN), parent, DlgProc, (LPARAM)this ) ? true : false;
}
/*
================
rvOpenFileDialog::UpdateLookIn
Updates the lookin combo box with the current lookin state
================
*/
void rvOpenFileDialog::UpdateLookIn ( void )
{
COMBOBOXEXITEM item;
idStr file;
idStr path;
// Reset the combo box
SendMessage ( mWndLookin, CB_RESETCONTENT, 0, 0 );
// Setup the common item structure components
ZeroMemory ( &item, sizeof(item) );
item.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
// Add the top left folder
item.pszText = (LPSTR)"base";
SendMessage ( mWndLookin, CBEM_INSERTITEM, 0, (LPARAM)&item );
// Break the lookin path up into its individual components and add them
// to the combo box
path = mLookin;
while ( path.Length ( ) )
{
int slash = path.Find ( "/" );
// Parse out the next subfolder
if ( slash != -1 )
{
file = path.Left ( slash );
path = path.Right ( path.Length ( ) - slash - 1 );
}
else
{
file = path;
path.Empty ( );
}
// Add the sub folder
item.pszText = (LPSTR)file.c_str();
item.iIndent++;
item.iItem = item.iIndent;
SendMessage ( mWndLookin, CBEM_INSERTITEM, 0, (LPARAM)&item );
}
// Set the selection to the last one since thats the deepest folder
SendMessage ( mWndLookin, CB_SETCURSEL, item.iIndent, 0 );
}
/*
================
rvOpenFileDialog::UpdateFileList
Updates the file list with the files that match the filter in the current
look in directory
================
*/
void rvOpenFileDialog::UpdateFileList ( void )
{
const char *basepath = mLookin;
idFileList *files;
HWND list = GetDlgItem ( mWnd, IDC_TOOLS_FILELIST );
int i;
int filter;
ListView_DeleteAllItems ( list );
// Add all the folders first
files = fileSystem->ListFiles ( basepath, "/", true );
for ( i = 0; i < files->GetNumFiles(); i ++ )
{
if ( files->GetFile( i )[0] == '.' )
{
continue;
}
LVITEM item;
item.mask = LVIF_TEXT;
item.iItem = ListView_GetItemCount ( list );
item.pszText = (LPSTR)files->GetFile( i );
item.iSubItem = 0;
ListView_InsertItem ( list, &item );
}
fileSystem->FreeFileList( files );
// Add all the files in the current lookin directory that match the
// current filters.
for ( filter = 0; filter < mFilters.Num(); filter ++ )
{
files = fileSystem->ListFiles( basepath, mFilters[filter], true );
for ( i = 0; i < files->GetNumFiles(); i ++ )
{
if ( files->GetFile( i )[0] == '.' )
{
continue;
}
LVITEM item;
item.mask = LVIF_TEXT|LVIF_IMAGE;
item.iImage = 2;
item.iItem = ListView_GetItemCount( list );
item.pszText = (LPSTR)files->GetFile( i );
item.iSubItem = 0;
ListView_InsertItem ( list, &item );
}
fileSystem->FreeFileList( files );
}
}
/*
================
rvOpenFileDialog::HandleCommandOK
Handles the pressing of the OK button but either opening a selected folder
or closing the dialog with the resulting filename
================
*/
void rvOpenFileDialog::HandleCommandOK ( void )
{
char temp[256];
LVITEM item;
// If nothing is selected then there is nothing to open
int sel = ListView_GetNextItem ( mWndFileList, -1, LVNI_SELECTED );
if ( sel == -1 )
{
GetWindowText ( GetDlgItem ( mWnd, IDC_TOOLS_FILENAME ), temp, sizeof(temp)-1 );
if ( !temp[0] )
{
return;
}
item.iImage = 2;
}
else
{
// Get the currently selected item
item.mask = LVIF_IMAGE|LVIF_TEXT;
item.iImage = sel;
item.iSubItem = 0;
item.pszText = temp;
item.cchTextMax = 256;
item.iItem = sel;
ListView_GetItem ( mWndFileList, &item );
}
// If the item is a folder then just open that folder
if ( item.iImage == 0 )
{
if ( strlen( mLookin ) )
{
idStr::snPrintf( mLookin, sizeof( mLookin ), "%s/%s", mLookin, temp );
} else {
idStr::Copynz( mLookin, temp, sizeof( mLookin ) );
}
UpdateLookIn ( );
UpdateFileList ( );
}
// If the item is a file then build the filename and end the dialog
else if ( item.iImage == 2 )
{
mFilename = mLookin;
if ( mFilename.Length ( ) )
{
mFilename.Append ( "/" );
}
mFilename.Append ( temp );
// Make sure the file exists
if ( mFlags & OFD_MUSTEXIST )
{
idFile* file;
file = fileSystem->OpenFileRead ( mFilename );
if ( !file )
{
MessageBox ( mWnd, va("%s\nFile not found.\nPlease verify the correct file name was given", mFilename.c_str() ), "Open", MB_ICONERROR|MB_OK );
return;
}
fileSystem->CloseFile ( file );
}
EndDialog ( mWnd, 1 );
}
return;
}
/*
================
rvOpenFileDialog::HandleInitDialog
Handles the init dialog message
================
*/
void rvOpenFileDialog::HandleInitDialog ( void )
{
// Cache the more used window handles
mWndFileList = GetDlgItem ( mWnd, IDC_TOOLS_FILELIST );
mWndLookin = GetDlgItem ( mWnd, IDC_TOOLS_LOOKIN );
// Load the custom resources used by the controls
mImageList = ImageList_LoadBitmap ( mInstance, MAKEINTRESOURCE(IDB_TOOLS_OPEN),16,1,RGB(255,255,255) );
mBackBitmap = (HBITMAP)LoadImage ( mInstance, MAKEINTRESOURCE(IDB_TOOLS_BACK), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR|LR_LOADMAP3DCOLORS );
// Attach the image list to the file list and lookin controls
ListView_SetImageList ( mWndFileList, mImageList, LVSIL_SMALL );
SendMessage( mWndLookin,CBEM_SETIMAGELIST,0,(LPARAM) mImageList );
// Back button is a bitmap button
SendMessage( GetDlgItem ( mWnd, IDC_TOOLS_BACK ), BM_SETIMAGE, IMAGE_BITMAP, (LONG) mBackBitmap );
// Allow custom titles
SetWindowText ( mWnd, mTitle );
// Custom ok button title
if ( mOKTitle.Length ( ) )
{
SetWindowText ( GetDlgItem ( mWnd, IDOK ), mOKTitle );
}
// See if there is a filename in the lookin
idStr temp;
idStr filename = mLookin;
filename.ExtractFileExtension ( temp );
if ( temp.Length ( ) )
{
filename.ExtractFileName ( temp );
SetWindowText ( GetDlgItem ( mWnd, IDC_TOOLS_FILENAME ), temp );
filename.StripFilename ( );
idStr::snPrintf( mLookin, sizeof( mLookin ), "%s", filename.c_str() );
}
// Update our controls
UpdateLookIn ( );
UpdateFileList ( );
}
/*
================
rvOpenFileDialog::HandleLookInChange
Handles a selection change within the lookin control
================
*/
void rvOpenFileDialog::HandleLookInChange ( void )
{
char temp[256];
int sel;
int i;
idStr lookin;
temp[0] = 0;
sel = SendMessage ( mWndLookin, CB_GETCURSEL, 0, 0 );
// If something other than base is selected then walk up the list
// and build the new lookin path
if ( sel >= 1 )
{
SendMessage ( mWndLookin, CB_GETLBTEXT, 1, (LPARAM)temp );
idStr::snPrintf( mLookin, sizeof( mLookin ), "%s", temp );
for ( i = 2; i <= sel; i ++ )
{
SendMessage ( mWndLookin, CB_GETLBTEXT, i, (LPARAM)temp );
idStr::snPrintf( mLookin, sizeof( mLookin ), "%s/%s", mLookin, temp );
}
}
else
{
mLookin[0] = 0;
}
// Update the controls with the new lookin path
UpdateLookIn ( );
UpdateFileList ( );
}
/*
================
rvOpenFileDialog::SetFilter
Set the extensions available in the dialog
================
*/
void rvOpenFileDialog::SetFilter ( const char* s )
{
idStr filters = s;
idStr filter;
while ( filters.Length ( ) )
{
int semi = filters.Find ( ';' );
if ( semi != -1 )
{
filter = filters.Left ( semi );
filters = filters.Right ( filters.Length ( ) - semi );
}
else
{
filter = filters;
filters.Empty ( );
}
mFilters.Append ( filter.c_str() + (filter[0] == '*' ? 1 : 0) );
}
}
/*
================
rvOpenFileDialog::DlgProc
Dialog Procedure for the open file dialog
================
*/
INT_PTR rvOpenFileDialog::DlgProc ( HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
rvOpenFileDialog* dlg = (rvOpenFileDialog*) GetWindowLong ( wnd, GWL_USERDATA );
switch ( msg )
{
case WM_INITDIALOG:
dlg = (rvOpenFileDialog*) lparam;
SetWindowLong ( wnd, GWL_USERDATA, lparam );
dlg->mWnd = wnd;
dlg->HandleInitDialog ( );
return TRUE;
case WM_NOTIFY:
{
NMHDR* nm = (NMHDR*) lparam;
switch ( nm->idFrom )
{
case IDC_TOOLS_FILELIST:
switch ( nm->code )
{
case LVN_ITEMCHANGED:
{
NMLISTVIEW* nmlv = (NMLISTVIEW*)nm;
if ( nmlv->uNewState & LVIS_SELECTED )
{
// Get the currently selected item
LVITEM item;
char temp[256];
item.mask = LVIF_IMAGE|LVIF_TEXT;
item.iSubItem = 0;
item.pszText = temp;
item.cchTextMax = sizeof(temp)-1;
item.iItem = nmlv->iItem;
ListView_GetItem ( dlg->mWndFileList, &item );
if ( item.iImage == 2 )
{
SetWindowText ( GetDlgItem ( wnd, IDC_TOOLS_FILENAME ), temp );
}
}
break;
}
case NM_DBLCLK:
dlg->HandleCommandOK ( );
break;
}
break;
}
break;
}
case WM_COMMAND:
switch ( LOWORD ( wparam ) )
{
case IDOK:
{
dlg->HandleCommandOK ( );
break;
}
case IDCANCEL:
EndDialog ( wnd, 0 );
break;
case IDC_TOOLS_BACK:
{
int sel = SendMessage ( GetDlgItem ( wnd, IDC_TOOLS_LOOKIN ), CB_GETCURSEL, 0, 0 );
if ( sel > 0 )
{
sel--;
SendMessage ( GetDlgItem ( wnd, IDC_TOOLS_LOOKIN ), CB_SETCURSEL, sel, 0 );
dlg->HandleLookInChange ( );
}
break;
}
case IDC_TOOLS_LOOKIN:
if ( HIWORD ( wparam ) == CBN_SELCHANGE )
{
dlg->HandleLookInChange ( );
}
break;
}
break;
}
return FALSE;
}

View File

@@ -0,0 +1,117 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef OPENFILEDIALOG_H_
#define OPENFILEDIALOG_H_
#define OFD_MUSTEXIST 0x00000001
class rvOpenFileDialog
{
public:
rvOpenFileDialog ( void );
~rvOpenFileDialog ( void );
bool DoModal ( HWND parent );
const char* GetFilename ( void );
void SetFilter ( const char* filter );
void SetTitle ( const char* title );
void SetOKTitle ( const char* title );
void SetInitialPath ( const char* path );
void SetFlags ( int flags );
const char* GetInitialPath ( void );
protected:
void UpdateFileList ( void );
void UpdateLookIn ( void );
HWND mWnd;
HWND mWndFileList;
HWND mWndLookin;
HINSTANCE mInstance;
HIMAGELIST mImageList;
HBITMAP mBackBitmap;
static char mLookin[ MAX_OSPATH ];
idStr mFilename;
idStr mTitle;
idStr mOKTitle;
idStrList mFilters;
int mFlags;
private:
void HandleCommandOK ( void );
void HandleLookInChange ( void );
void HandleInitDialog ( void );
static INT_PTR CALLBACK DlgProc ( HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam );
};
ID_INLINE const char* rvOpenFileDialog::GetFilename ( void )
{
return mFilename.c_str ( );
}
ID_INLINE void rvOpenFileDialog::SetTitle ( const char* title )
{
mTitle = title;
}
ID_INLINE void rvOpenFileDialog::SetOKTitle ( const char* title )
{
mOKTitle = title;
}
ID_INLINE void rvOpenFileDialog::SetInitialPath ( const char* path )
{
if ( !idStr::Cmpn( mLookin, path, strlen( path ) ) )
{
return;
}
idStr::Copynz( mLookin, path, sizeof( mLookin ) );
}
ID_INLINE void rvOpenFileDialog::SetFlags ( int flags )
{
mFlags = flags;
}
ID_INLINE const char* rvOpenFileDialog::GetInitialPath ( void )
{
return mLookin;
}
#endif // OPENFILEDIALOG_H_

View File

@@ -0,0 +1,923 @@
// PropTree.cpp : implementation file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "PropTree.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define PROPTREEITEM_EXPANDCOLUMN 16 // width of the expand column
#define PROPTREEITEM_COLRNG 5 // width of splitter
//static AFX_EXTENSION_MODULE PropTreeDLL = {NULL, NULL};
static const CString strOfficeFontName = _T("Tahoma");
static const CString strDefaultFontName = _T("MS Sans Serif");
HINSTANCE ghInst;
/*extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("PROPTREE.DLL Initializing!\n");
if (!AfxInitExtensionModule(PropTreeDLL, hInstance))
return 0;
new CDynLinkLibrary(PropTreeDLL);
ghInst = hInstance;
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("PROPTREE.DLL Terminating!\n");
AfxTermExtensionModule(PropTreeDLL);
}
return 1;
}*/
void InitPropTree(HINSTANCE hInstance) {
ghInst = hInstance;
}
static int CALLBACK FontFamilyProcFonts(const LOGFONT FAR* lplf, const TEXTMETRIC FAR*, ULONG, LPARAM)
{
ASSERT(lplf != NULL);
CString strFont = lplf->lfFaceName;
return strFont.CollateNoCase (strOfficeFontName) == 0 ? 0 : 1;
}
/////////////////////////////////////////////////////////////////////////////
// CPropTree
UINT CPropTree::s_nInstanceCount;
CFont* CPropTree::s_pNormalFont;
CFont* CPropTree::s_pBoldFont;
CPropTreeItem* CPropTree::s_pFound;
CPropTree::CPropTree() :
m_bShowInfo(TRUE),
m_nInfoHeight(50),
m_pVisbleList(NULL),
m_Origin(100,0),
m_nLastUID(1),
m_pFocus(NULL),
m_bDisableInput(FALSE)
{
m_Root.Expand();
// init global resources only once
if (!s_nInstanceCount)
InitGlobalResources();
s_nInstanceCount++;
}
CPropTree::~CPropTree()
{
DeleteAllItems();
s_nInstanceCount--;
// free global resource when ALL CPropTrees are destroyed
if (!s_nInstanceCount)
FreeGlobalResources();
}
BEGIN_MESSAGE_MAP(CPropTree, CWnd)
//{{AFX_MSG_MAP(CPropTree)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_ENABLE()
ON_WM_SYSCOLORCHANGE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropTree message handlers
const POINT& CPropTree::GetOrigin()
{
return m_Origin;
}
BOOL CPropTree::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
CWnd* pWnd = this;
LPCTSTR pszCreateClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW, ::LoadCursor(NULL, IDC_ARROW));
return pWnd->Create(pszCreateClass, _T(""), dwStyle, rect, pParentWnd, nID);
}
int CPropTree::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
DWORD dwStyle;
CRect rc;
GetClientRect(rc);
// create CPropTreeList
//
dwStyle = WS_VISIBLE|WS_CHILD|WS_VSCROLL;
if (!m_List.Create(dwStyle, rc, this, 100))
{
TRACE0("Failed to create CPropTreeList\n");
return -1;
}
m_List.SetPropOwner(this);
// create CPropTreeInfo
//
dwStyle &= ~WS_VSCROLL;
if (!m_Info.Create(_T(""), dwStyle, rc, this))
{
TRACE0("Failed to create CPropTreeInfo\n");
return -1;
}
m_Info.SetPropOwner(this);
return 0;
}
CWnd* CPropTree::GetCtrlParent()
{
return &m_List;
}
void CPropTree::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
ResizeChildWindows(cx, cy);
}
void CPropTree::ResizeChildWindows(int cx, int cy)
{
if (m_bShowInfo)
{
if (IsWindow(m_List.m_hWnd))
m_List.MoveWindow(0, 0, cx, cy - m_nInfoHeight);
if (IsWindow(m_Info.m_hWnd))
m_Info.MoveWindow(0, cy - m_nInfoHeight, cx, m_nInfoHeight);
}
else
{
if (IsWindow(m_List.m_hWnd))
m_List.MoveWindow(0, 0, cx, cy);
}
}
void CPropTree::InitGlobalResources()
{
NONCLIENTMETRICS info;
info.cbSize = sizeof(info);
::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0);
LOGFONT lf;
memset(&lf, 0, sizeof (LOGFONT));
CWindowDC dc(NULL);
lf.lfCharSet = (BYTE)GetTextCharsetInfo(dc.GetSafeHdc(), NULL, 0);
lf.lfHeight = info.lfMenuFont.lfHeight;
lf.lfWeight = info.lfMenuFont.lfWeight;
lf.lfItalic = info.lfMenuFont.lfItalic;
// check if we should use system font
_tcscpy(lf.lfFaceName, info.lfMenuFont.lfFaceName);
BOOL fUseSystemFont = (info.lfMenuFont.lfCharSet > SYMBOL_CHARSET);
if (!fUseSystemFont)
{
// check for "Tahoma" font existance:
if (::EnumFontFamilies(dc.GetSafeHdc(), NULL, FontFamilyProcFonts, 0)==0)
{
// Found! Use MS Office font!
_tcscpy(lf.lfFaceName, strOfficeFontName);
}
else
{
// Not found. Use default font:
_tcscpy(lf.lfFaceName, strDefaultFontName);
}
}
s_pNormalFont = new CFont;
s_pNormalFont->CreateFontIndirect(&lf);
lf.lfWeight = FW_BOLD;
s_pBoldFont = new CFont;
s_pBoldFont->CreateFontIndirect(&lf);
}
void CPropTree::FreeGlobalResources()
{
if (s_pNormalFont)
{
delete s_pNormalFont;
s_pNormalFont = NULL;
}
if (s_pBoldFont)
{
delete s_pBoldFont;
s_pBoldFont = NULL;
}
}
CFont* CPropTree::GetNormalFont()
{
return s_pNormalFont;
}
CFont* CPropTree::GetBoldFont()
{
return s_pBoldFont;
}
CPropTreeItem* CPropTree::GetFocusedItem()
{
return m_pFocus;
}
CPropTreeItem* CPropTree::GetRootItem()
{
return &m_Root;
}
void CPropTree::ClearVisibleList()
{
m_pVisbleList = NULL;
}
CPropTreeItem* CPropTree::GetVisibleList()
{
return m_pVisbleList;
}
void CPropTree::AddToVisibleList(CPropTreeItem* pItem)
{
if (!pItem)
return;
// check for an empty visible list
if (!m_pVisbleList)
m_pVisbleList = pItem;
else
{
// Add the new item to the end of the list
CPropTreeItem* pNext;
pNext = m_pVisbleList;
while (pNext->GetNextVisible())
pNext = pNext->GetNextVisible();
pNext->SetNextVisible(pItem);
}
pItem->SetNextVisible(NULL);
}
BOOL CPropTree::EnumItems(CPropTreeItem* pItem, ENUMPROPITEMPROC proc, LPARAM lParam)
{
if (!pItem || !proc)
return FALSE;
CPropTreeItem* pNext;
// don't count the root item in any enumerations
if (pItem!=&m_Root && !proc(this, pItem, lParam))
return FALSE;
// recurse thru all child items
pNext = pItem->GetChild();
while (pNext)
{
if (!EnumItems(pNext, proc, lParam))
return FALSE;
pNext = pNext->GetSibling();
}
return TRUE;
}
void CPropTree::SetOriginOffset(LONG nOffset)
{
m_Origin.y = nOffset;
}
void CPropTree::UpdatedItems()
{
if (!IsWindow(m_hWnd))
return;
Invalidate();
m_List.UpdateResize();
m_List.Invalidate();
}
void CPropTree::DeleteAllItems()
{
Delete(NULL);
UpdatedItems();
m_nLastUID = 1; // reset uid counter
}
void CPropTree::DeleteItem(CPropTreeItem* pItem)
{
Delete(pItem);
UpdatedItems();
}
LONG CPropTree::GetColumn()
{
return m_Origin.x;
}
void CPropTree::SetColumn(LONG nColumn)
{
CRect rc;
GetClientRect(rc);
if (rc.IsRectEmpty())
nColumn = __max(PROPTREEITEM_EXPANDCOLUMN, nColumn);
else
nColumn = __min(__max(PROPTREEITEM_EXPANDCOLUMN, nColumn), rc.Width() - PROPTREEITEM_EXPANDCOLUMN);
m_Origin.x = nColumn;
Invalidate();
}
void CPropTree::Delete(CPropTreeItem* pItem)
{
if (pItem && pItem!=&m_Root && SendNotify(PTN_DELETEITEM, pItem))
return;
// passing in a NULL item is the same as calling DeleteAllItems
if (!pItem)
pItem = &m_Root;
// Clear the visible list before anything gets deleted
ClearVisibleList();
// delete children
CPropTreeItem* pIter;
CPropTreeItem* pNext;
pIter = pItem->GetChild();
while (pIter)
{
pNext = pIter->GetSibling();
DeleteItem(pIter);
pIter = pNext;
}
// unlink from tree
if (pItem->GetParent())
{
if (pItem->GetParent()->GetChild()==pItem)
pItem->GetParent()->SetChild(pItem->GetSibling());
else
{
pIter = pItem->GetParent()->GetChild();
while (pIter->GetSibling() && pIter->GetSibling()!=pItem)
pIter = pIter->GetSibling();
if (pIter->GetSibling())
pIter->SetSibling(pItem->GetSibling());
}
}
if (pItem!=&m_Root)
{
if (pItem==GetFocusedItem())
SetFocusedItem(NULL);
delete pItem;
}
}
void CPropTree::SetFocusedItem(CPropTreeItem* pItem)
{
m_pFocus = pItem;
EnsureVisible(m_pFocus);
if (!IsWindow(m_hWnd))
return;
Invalidate();
}
void CPropTree::ShowInfoText(BOOL bShow)
{
m_bShowInfo = bShow;
CRect rc;
GetClientRect(rc);
ResizeChildWindows(rc.Width(), rc.Height());
}
BOOL CPropTree::IsItemVisible(CPropTreeItem* pItem)
{
if (!pItem)
return FALSE;
for (CPropTreeItem* pNext = m_pVisbleList; pNext; pNext = pNext->GetNextVisible())
{
if (pNext==pItem)
return TRUE;
}
return FALSE;
}
void CPropTree::EnsureVisible(CPropTreeItem* pItem)
{
if (!pItem)
return;
// item is not scroll visible (expand all parents)
if (!IsItemVisible(pItem))
{
CPropTreeItem* pParent;
pParent = pItem->GetParent();
while (pParent)
{
pParent->Expand();
pParent = pParent->GetParent();
}
UpdatedItems();
UpdateWindow();
}
ASSERT(IsItemVisible(pItem));
CRect rc;
m_List.GetClientRect(rc);
rc.OffsetRect(0, m_Origin.y);
rc.bottom -= pItem->GetHeight();
CPoint pt;
pt = pItem->GetLocation();
if (!rc.PtInRect(pt))
{
LONG oy;
if (pt.y < rc.top)
oy = pt.y;
else
oy = pt.y - rc.Height() + pItem->GetHeight();
m_List.OnVScroll(SB_THUMBTRACK, oy, NULL);
}
}
CPropTreeItem* CPropTree::InsertItem(CPropTreeItem* pItem, CPropTreeItem* pParent)
{
if (!pItem)
return NULL;
if (!pParent)
pParent = &m_Root;
if (!pParent->GetChild())
pParent->SetChild(pItem);
else
{
// add to end of the sibling list
CPropTreeItem* pNext;
pNext = pParent->GetChild();
while (pNext->GetSibling())
pNext = pNext->GetSibling();
pNext->SetSibling(pItem);
}
pItem->SetParent(pParent);
pItem->SetPropOwner(this);
// auto generate a default ID
pItem->SetCtrlID(m_nLastUID++);
SendNotify(PTN_INSERTITEM, pItem);
UpdatedItems();
return pItem;
}
LONG CPropTree::HitTest(const POINT& pt)
{
POINT p = pt;
CPropTreeItem* pItem;
// convert screen to tree coordinates
p.y += m_Origin.y;
if ((pItem = FindItem(pt))!=NULL)
{
if (!pItem->IsRootLevel() && pt.x >= m_Origin.x - PROPTREEITEM_COLRNG && pt.x <= m_Origin.x + PROPTREEITEM_COLRNG)
return HTCOLUMN;
if (pItem->HitButton(p)) {
return HTBUTTON;
}
if (pt.x > m_Origin.x + PROPTREEITEM_COLRNG)
return HTATTRIBUTE;
if (pItem->HitExpand(p))
return HTEXPAND;
if (pItem->HitCheckBox(p))
return HTCHECKBOX;
return HTLABEL;
}
return HTCLIENT;
}
CPropTreeItem* CPropTree::FindItem(const POINT& pt)
{
CPropTreeItem* pItem;
CPoint p = pt;
// convert screen to tree coordinates
p.y += m_Origin.y;
// search the visible list for the item
for (pItem = m_pVisbleList; pItem; pItem = pItem->GetNextVisible())
{
CPoint ipt = pItem->GetLocation();
if (p.y>=ipt.y && p.y<ipt.y + pItem->GetHeight())
return pItem;
}
return NULL;
}
CPropTreeItem* CPropTree::FindItem(UINT nCtrlID)
{
s_pFound = NULL;
EnumItems(&m_Root, EnumFindItem, nCtrlID);
return s_pFound;
}
BOOL CALLBACK CPropTree::EnumFindItem(CPropTree*, CPropTreeItem* pItem, LPARAM lParam)
{
ASSERT(pItem!=NULL);
if (pItem->GetCtrlID()==(UINT)lParam)
{
s_pFound = pItem;
return FALSE;
}
return TRUE;
}
BOOL CPropTree::IsDisableInput()
{
return m_bDisableInput;
}
void CPropTree::DisableInput(BOOL bDisable)
{
m_bDisableInput = bDisable;
CWnd* pWnd;
if ((pWnd = GetParent())!=NULL)
pWnd->EnableWindow(!bDisable);
}
void CPropTree::SelectItems(CPropTreeItem* pItem, BOOL bSelect)
{
if (!pItem)
pItem = &m_Root;
EnumItems(pItem, EnumSelectAll, (LPARAM)bSelect);
}
CPropTreeItem* CPropTree::FocusFirst()
{
CPropTreeItem *pold;
pold = m_pFocus;
SetFocusedItem(m_pVisbleList);
if (m_pFocus)
{
SelectItems(NULL, FALSE);
m_pFocus->Select();
}
if (pold!=m_pFocus)
SendNotify(PTN_SELCHANGE, m_pFocus);
return m_pFocus;
}
CPropTreeItem* CPropTree::FocusLast()
{
CPropTreeItem* pNext;
CPropTreeItem* pChange;
pChange = m_pFocus;
pNext = m_pVisbleList;
if (pNext)
{
while (pNext->GetNextVisible())
pNext = pNext->GetNextVisible();
SetFocusedItem(pNext);
if (m_pFocus)
{
SelectItems(NULL, FALSE);
m_pFocus->Select();
}
}
if (pChange!=m_pFocus)
SendNotify(PTN_SELCHANGE, m_pFocus);
return pNext;
}
CPropTreeItem* CPropTree::FocusPrev()
{
CPropTreeItem* pNext;
CPropTreeItem* pChange;
pChange = m_pFocus;
if (m_pFocus==NULL)
{
// get the last visible item
pNext = m_pVisbleList;
while (pNext && pNext->GetNextVisible())
pNext = pNext->GetNextVisible();
}
else
{
pNext = m_pVisbleList;
while (pNext && pNext->GetNextVisible()!=m_pFocus)
pNext = pNext->GetNextVisible();
}
if (pNext)
SetFocusedItem(pNext);
if (m_pFocus)
{
SelectItems(NULL, FALSE);
m_pFocus->Select();
}
if (pChange!=m_pFocus)
SendNotify(PTN_SELCHANGE, m_pFocus);
return pNext;
}
CPropTreeItem* CPropTree::FocusNext()
{
CPropTreeItem* pNext;
CPropTreeItem* pChange;
pChange = m_pFocus;
if (m_pFocus==NULL)
pNext = m_pVisbleList;
else
if (m_pFocus->GetNextVisible())
pNext = m_pFocus->GetNextVisible();
else
pNext = NULL;
if (pNext)
SetFocusedItem(pNext);
if (m_pFocus)
{
SelectItems(NULL, FALSE);
m_pFocus->Select();
}
if (pChange!=m_pFocus)
SendNotify(PTN_SELCHANGE, m_pFocus);
return pNext;
}
void CPropTree::UpdateMoveAllItems()
{
EnumItems(&m_Root, EnumMoveAll);
}
void CPropTree::RefreshItems(CPropTreeItem* pItem)
{
if (!pItem)
pItem = &m_Root;
EnumItems(pItem, EnumRefreshAll);
UpdatedItems();
}
BOOL CALLBACK CPropTree::EnumSelectAll(CPropTree*, CPropTreeItem* pItem, LPARAM lParam)
{
if (!pItem)
return FALSE;
pItem->Select((BOOL)lParam);
return TRUE;
}
BOOL CALLBACK CPropTree::EnumRefreshAll(CPropTree*, CPropTreeItem* pItem, LPARAM)
{
if (!pItem)
return FALSE;
pItem->OnRefresh();
return TRUE;
}
BOOL CALLBACK CPropTree::EnumMoveAll(CPropTree*, CPropTreeItem* pItem, LPARAM)
{
if (!pItem)
return FALSE;
pItem->OnMove();
return TRUE;
}
LRESULT CPropTree::SendNotify(UINT nNotifyCode, CPropTreeItem* pItem)
{
if (!IsWindow(m_hWnd))
return 0L;
if (!(GetStyle() & PTS_NOTIFY))
return 0L;
NMPROPTREE nmmp;
LPNMHDR lpnm;
lpnm = NULL;
switch (nNotifyCode)
{
case PTN_INSERTITEM:
case PTN_DELETEITEM:
case PTN_DELETEALLITEMS:
case PTN_ITEMCHANGED:
case PTN_ITEMBUTTONCLICK:
case PTN_SELCHANGE:
case PTN_ITEMEXPANDING:
case PTN_COLUMNCLICK:
case PTN_PROPCLICK:
case PTN_CHECKCLICK:
lpnm = (LPNMHDR)&nmmp;
nmmp.pItem = pItem;
break;
}
if (lpnm)
{
UINT id = (UINT)::GetMenu(m_hWnd);
lpnm->code = nNotifyCode;
lpnm->hwndFrom = m_hWnd;
lpnm->idFrom = id;
return GetParent()->SendMessage(WM_NOTIFY, (WPARAM)id, (LPARAM)lpnm);
}
return 0L;
}
void CPropTree::OnEnable(BOOL bEnable)
{
CWnd::OnEnable(bEnable);
Invalidate();
}
void CPropTree::OnSysColorChange()
{
CWnd::OnSysColorChange();
Invalidate();
}
BOOL CPropTree::IsSingleSelection()
{
// right now only support single selection
return TRUE;
}

View File

@@ -0,0 +1,290 @@
// PropTree.h : header file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#if !defined(AFX_PROPT_H__386AA426_6FB7_4B4B_9563_C4CC045BB0C9__INCLUDED_)
#define AFX_PROPT_H__386AA426_6FB7_4B4B_9563_C4CC045BB0C9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/*#ifdef _PROPTREE_EXPORT
#define PROPTREE_API __declspec(dllexport)
#else
#define PROPTREE_API __declspec(dllimport)
#endif
#ifndef _PROPTREE_DLL
#ifdef _UNICODE
#ifdef _DEBUG
#pragma comment(lib, "PropTreeDU")
#pragma message("Automatically linking with PropTreeDU.dll (Debug Unicode)")
#else
#pragma comment(lib, "PropTreeU")
#pragma message("Automatically linking with PropTreeU.dll (Release Unicode)")
#endif
#else
#ifdef _DEBUG
#pragma comment(lib, "PropTreeD")
#pragma message("Automatically linking with PropTreeD.dll (Debug)")
#else
#pragma comment(lib, "PropTree")
#pragma message("Automatically linking with PropTree.dll (Release)")
#endif
#endif // _UNICODE
#endif // _PROPTREE_DLL
*/
#define PROPTREE_API
#include "PropTreeList.h"
#include "PropTreeInfo.h"
#include "PropTreeItem.h"
#include "PropTreeItemStatic.h"
#include "PropTreeItemEdit.h"
#include "PropTreeItemCombo.h"
#include "PropTreeItemColor.h"
#include "PropTreeItemCheck.h"
#include "PropTreeItemButton.h"
#include "PropTreeItemEditButton.h"
#include "PropTreeItemFileEdit.h"
class CPropTree;
typedef BOOL (CALLBACK* ENUMPROPITEMPROC)(CPropTree*, CPropTreeItem*, LPARAM);
void InitPropTree(HINSTANCE hInstance);
// CPropTree window styles
#define PTS_NOTIFY 0x00000001
// CPropTree HitTest return codes
#define HTPROPFIRST 50
#define HTLABEL (HTPROPFIRST + 0)
#define HTCOLUMN (HTPROPFIRST + 1)
#define HTEXPAND (HTPROPFIRST + 2)
#define HTATTRIBUTE (HTPROPFIRST + 3)
#define HTCHECKBOX (HTPROPFIRST + 4)
#define HTBUTTON (HTPROPFIRST + 5)
// CPropTree WM_NOTIFY notification structure
typedef struct _NMPROPTREE
{
NMHDR hdr;
CPropTreeItem* pItem;
} NMPROPTREE, *PNMPROPTREE, FAR *LPNMPROPTREE;
// CPropTree specific Notification Codes
#define PTN_FIRST (0U-1100U)
#define PTN_INSERTITEM (PTN_FIRST-1)
#define PTN_DELETEITEM (PTN_FIRST-2)
#define PTN_DELETEALLITEMS (PTN_FIRST-3)
#define PTN_ITEMCHANGED (PTN_FIRST-5)
#define PTN_ITEMBUTTONCLICK (PTN_FIRST-6)
#define PTN_SELCHANGE (PTN_FIRST-7)
#define PTN_ITEMEXPANDING (PTN_FIRST-8)
#define PTN_COLUMNCLICK (PTN_FIRST-9)
#define PTN_PROPCLICK (PTN_FIRST-10)
#define PTN_CHECKCLICK (PTN_FIRST-12)
/////////////////////////////////////////////////////////////////////////////
// CPropTree window
class PROPTREE_API CPropTree : public CWnd
{
// Construction
public:
CPropTree();
virtual ~CPropTree();
BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
// Attributes/Operations
public:
static CFont* GetNormalFont();
static CFont* GetBoldFont();
// Returns the root item of the tree
CPropTreeItem* GetRootItem();
// Returns the focused item or NULL for none
CPropTreeItem* GetFocusedItem();
// Enumerates an item and all its child items
BOOL EnumItems(CPropTreeItem* pItem, ENUMPROPITEMPROC proc, LPARAM lParam = 0L);
// Insert a created CPropTreeItem into the control
CPropTreeItem* InsertItem(CPropTreeItem* pItem, CPropTreeItem* pParent = NULL);
// Delete an item and ALL its children
void DeleteItem(CPropTreeItem* pItem);
// Delete all items from the tree
void DeleteAllItems();
// Return the splitter position
LONG GetColumn();
// Set the splitter position
void SetColumn(LONG nColumn);
// Sets the focused item
void SetFocusedItem(CPropTreeItem* pItem);
// Show or hide the info text
void ShowInfoText(BOOL bShow = TRUE);
// Returns TRUE if the item is visible (its parent is expanded)
BOOL IsItemVisible(CPropTreeItem* pItem);
// Ensures that an item is visible
void EnsureVisible(CPropTreeItem* pItem);
// do a hit test on the control (returns a HTxxxx code)
LONG HitTest(const POINT& pt);
// find an item by a location
CPropTreeItem* FindItem(const POINT& pt);
// find an item by item id
CPropTreeItem* FindItem(UINT nCtrlID);
protected:
// Actual tree control
CPropTreeList m_List;
// Descriptive control
CPropTreeInfo m_Info;
// TRUE to show info control
BOOL m_bShowInfo;
// Height of the info control
LONG m_nInfoHeight;
// Root level tree item
CPropTreeItem m_Root;
// Linked list of visible items
CPropTreeItem* m_pVisbleList;
// Pointer to the focused item (selected)
CPropTreeItem* m_pFocus;
// PropTree scroll position. x = splitter position, y = vscroll position
CPoint m_Origin;
// auto generated last created ID
UINT m_nLastUID;
// Number of CPropTree controls in the current application
static UINT s_nInstanceCount;
static CFont* s_pNormalFont;
static CFont* s_pBoldFont;
BOOL m_bDisableInput;
// Used for enumeration
static CPropTreeItem* s_pFound;
public:
//
// functions used by CPropTreeItem (you normally dont need to call these directly)
//
void AddToVisibleList(CPropTreeItem* pItem);
void ClearVisibleList();
void SetOriginOffset(LONG nOffset);
void UpdatedItems();
void UpdateMoveAllItems();
void RefreshItems(CPropTreeItem* pItem = NULL);
// enable or disable tree input
void DisableInput(BOOL bDisable = TRUE);
BOOL IsDisableInput();
BOOL IsSingleSelection();
CPropTreeItem* GetVisibleList();
CWnd* GetCtrlParent();
const POINT& GetOrigin();
void SelectItems(CPropTreeItem* pItem, BOOL bSelect = TRUE);
// Focus on the first visible item
CPropTreeItem *FocusFirst();
// Focus on the last visible item
CPropTreeItem *FocusLast();
// Focus on the previous item
CPropTreeItem *FocusPrev();
// Focus on the next item
CPropTreeItem *FocusNext();
LRESULT SendNotify(UINT nNotifyCode, CPropTreeItem* pItem = NULL);
protected:
// Resize the child windows to fit the exact dimensions the CPropTree control
void ResizeChildWindows(int cx, int cy);
// Initialize global resources, brushes, fonts, etc.
void InitGlobalResources();
// Free global resources, brushes, fonts, etc.
void FreeGlobalResources();
// Recursive version of DeleteItem
void Delete(CPropTreeItem* pItem);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropTree)
//}}AFX_VIRTUAL
// Implementation
private:
static BOOL CALLBACK EnumFindItem(CPropTree* pProp, CPropTreeItem* pItem, LPARAM lParam);
static BOOL CALLBACK EnumSelectAll(CPropTree*, CPropTreeItem* pItem, LPARAM lParam);
static BOOL CALLBACK EnumMoveAll(CPropTree*, CPropTreeItem* pItem, LPARAM);
static BOOL CALLBACK EnumRefreshAll(CPropTree*, CPropTreeItem* pItem, LPARAM);
// Generated message map functions
protected:
//{{AFX_MSG(CPropTree)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnEnable(BOOL bEnable);
afx_msg void OnSysColorChange();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROPT_H__386AA426_6FB7_4B4B_9563_C4CC045BB0C9__INCLUDED_)

View File

@@ -0,0 +1,110 @@
// PropTreeInfo.cpp : implementation file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "PropTree.h"
#include "../../../sys/win32/rc/proptree_Resource.h"
#include "PropTreeInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPropTreeInfo
CPropTreeInfo::CPropTreeInfo() :
m_pProp(NULL)
{
}
CPropTreeInfo::~CPropTreeInfo()
{
}
BEGIN_MESSAGE_MAP(CPropTreeInfo, CStatic)
//{{AFX_MSG_MAP(CPropTreeInfo)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropTreeInfo message handlers
void CPropTreeInfo::SetPropOwner(CPropTree* pProp)
{
m_pProp = pProp;
}
void CPropTreeInfo::OnPaint()
{
CPaintDC dc(this);
CRect rc;
GetClientRect(rc);
dc.SelectObject(GetSysColorBrush(COLOR_BTNFACE));
dc.PatBlt(rc.left, rc.top, rc.Width(), rc.Height(), PATCOPY);
dc.DrawEdge(&rc, BDR_SUNKENOUTER, BF_RECT);
rc.DeflateRect(4, 4);
ASSERT(m_pProp!=NULL);
CPropTreeItem* pItem = m_pProp->GetFocusedItem();
if (!m_pProp->IsWindowEnabled())
dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT));
else
dc.SetTextColor(GetSysColor(COLOR_BTNTEXT));
dc.SetBkMode(TRANSPARENT);
dc.SelectObject(m_pProp->GetBoldFont());
CString txt;
if (!pItem)
txt.LoadString(IDS_NOITEMSEL);
else
txt = pItem->GetLabelText();
CRect ir;
ir = rc;
// draw label
dc.DrawText(txt, &ir, DT_SINGLELINE|DT_CALCRECT);
dc.DrawText(txt, &ir, DT_SINGLELINE);
ir.top = ir.bottom;
ir.bottom = rc.bottom;
ir.right = rc.right;
if (pItem)
txt = pItem->GetInfoText();
else
txt.LoadString(IDS_SELFORINFO);
dc.SelectObject(m_pProp->GetNormalFont());
dc.DrawText(txt, &ir, DT_WORDBREAK);
}

View File

@@ -0,0 +1,71 @@
#if !defined(AFX_PROPTREEINFO_H__22BD9C18_A68C_4BB8_B7FC_C4A7DA0E1EBF__INCLUDED_)
#define AFX_PROPTREEINFO_H__22BD9C18_A68C_4BB8_B7FC_C4A7DA0E1EBF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PropTreeInfo.h : header file
//
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
class CPropTree;
/////////////////////////////////////////////////////////////////////////////
// CPropTreeInfo window
class PROPTREE_API CPropTreeInfo : public CStatic
{
// Construction
public:
CPropTreeInfo();
// Attributes
public:
// CPropTree class that this class belongs
void SetPropOwner(CPropTree* pProp);
protected:
CPropTree* m_pProp;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropTreeInfo)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CPropTreeInfo();
// Generated message map functions
protected:
//{{AFX_MSG(CPropTreeInfo)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROPTREEINFO_H__22BD9C18_A68C_4BB8_B7FC_C4A7DA0E1EBF__INCLUDED_)

View File

@@ -0,0 +1,590 @@
// PropTreeItem.cpp
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "PropTree.h"
#include "PropTreeItem.h"
#define PROPTREEITEM_DEFHEIGHT 21 // default heigt of an item
#define PROPTREEITEM_SPACE 5 // default horz spacing
#define PROPTREEITEM_EXPANDBOX 9 // size of the expand box
#define PROPTREEITEM_CHECKBOX 14 // size of the check box
#define PROPTREEITEM_EXPANDCOLUMN 16 // width of the expand column
#define PNINDENT 16 // child level indent
#define PROPTREEITEM_EXPANDBOXHALF (PROPTREEITEM_EXPANDBOX/2)
/////////////////////////////////////////////////////////////////////////////
// drawing helper functions
//
// draw a dotted horizontal line
static void _DotHLine(HDC hdc, LONG x, LONG y, LONG w)
{
for (; w>0; w-=2, x+=2)
SetPixel(hdc, x, y, GetSysColor(COLOR_BTNSHADOW));
}
// draw the plus/minus button
static void _DrawExpand(HDC hdc, LONG x, LONG y, BOOL bExpand, BOOL bFill)
{
HPEN hPen;
HPEN oPen;
HBRUSH oBrush;
hPen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNSHADOW));
oPen = (HPEN)SelectObject(hdc, hPen);
oBrush = (HBRUSH)SelectObject(hdc, GetStockObject(bFill ? WHITE_BRUSH : NULL_BRUSH));
Rectangle(hdc, x, y, x + PROPTREEITEM_EXPANDBOX, y + PROPTREEITEM_EXPANDBOX);
SelectObject(hdc, GetStockObject(BLACK_PEN));
if (!bExpand)
{
MoveToEx(hdc, x + PROPTREEITEM_EXPANDBOXHALF, y + 2, NULL);
LineTo(hdc, x + PROPTREEITEM_EXPANDBOXHALF, y + PROPTREEITEM_EXPANDBOX - 2);
}
MoveToEx(hdc, x + 2, y + PROPTREEITEM_EXPANDBOXHALF, NULL);
LineTo(hdc, x + PROPTREEITEM_EXPANDBOX - 2, y + PROPTREEITEM_EXPANDBOXHALF);
SelectObject(hdc, oPen);
SelectObject(hdc, oBrush);
DeleteObject(hPen);
}
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItem
//
CPropTreeItem::CPropTreeItem() :
m_pProp(NULL),
m_sLabel(_T("")),
m_sInfo(_T("")),
m_loc(0,0),
m_rc(0,0,0,0),
m_lParam(0),
m_nCtrlID(0),
m_dwState(0),
m_bActivated(FALSE),
m_bCommitOnce(FALSE),
m_rcExpand(0,0,0,0),
m_rcCheckbox(0,0,0,0),
m_rcButton(0,0,0,0),
m_pParent(NULL),
m_pSibling(NULL),
m_pChild(NULL),
m_pVis(NULL)
{
}
CPropTreeItem::~CPropTreeItem()
{
}
BOOL CPropTreeItem::IsExpanded()
{
return (m_dwState & TreeItemExpanded) ? TRUE : FALSE;
}
BOOL CPropTreeItem::IsSelected()
{
return (m_dwState & TreeItemSelected) ? TRUE : FALSE;
}
BOOL CPropTreeItem::IsChecked()
{
return (m_dwState & TreeItemChecked) ? TRUE : FALSE;
}
BOOL CPropTreeItem::IsReadOnly()
{
return (m_dwState & TreeItemReadOnly) ? TRUE : FALSE;
}
BOOL CPropTreeItem::IsActivated()
{
return (m_dwState & TreeItemActivated) ? TRUE : FALSE;
}
void CPropTreeItem::Select(BOOL bSelect)
{
if (bSelect)
m_dwState |= TreeItemSelected;
else
m_dwState &= ~TreeItemSelected;
}
void CPropTreeItem::Expand(BOOL bExpand)
{
if (bExpand)
m_dwState |= TreeItemExpanded;
else
m_dwState &= ~TreeItemExpanded;
}
void CPropTreeItem::Check(BOOL bCheck)
{
if (bCheck)
m_dwState |= TreeItemChecked;
else
m_dwState &= ~TreeItemChecked;
}
void CPropTreeItem::ReadOnly(BOOL bReadOnly)
{
if (bReadOnly)
m_dwState |= TreeItemReadOnly;
else
m_dwState &= ~TreeItemReadOnly;
}
BOOL CPropTreeItem::IsCheckBox()
{
return (m_dwState & TreeItemCheckbox) ? TRUE : FALSE;
}
void CPropTreeItem::HasCheckBox(BOOL bCheckbox)
{
if (bCheckbox)
m_dwState |= TreeItemCheckbox;
else
m_dwState &= ~TreeItemCheckbox;
}
BOOL CPropTreeItem::HitExpand(const POINT& pt)
{
return m_rcExpand.PtInRect(pt);
}
BOOL CPropTreeItem::HitCheckBox(const POINT& pt)
{
return m_rcCheckbox.PtInRect(pt);
}
BOOL CPropTreeItem::IsRootLevel()
{
ASSERT(m_pProp!=NULL);
return GetParent() == m_pProp->GetRootItem();
}
LONG CPropTreeItem::GetTotalHeight()
{
CPropTreeItem* pItem;
LONG nHeight;
nHeight = GetHeight();
if (IsExpanded())
{
for (pItem = GetChild(); pItem; pItem = pItem->GetSibling())
nHeight += pItem->GetTotalHeight();
}
return nHeight;
}
void CPropTreeItem::SetLabelText(LPCTSTR sLabel)
{
m_sLabel = sLabel;
}
LPCTSTR CPropTreeItem::GetLabelText()
{
return m_sLabel;
}
void CPropTreeItem::SetInfoText(LPCTSTR sInfo)
{
m_sInfo = sInfo;
}
LPCTSTR CPropTreeItem::GetInfoText()
{
return m_sInfo;
}
void CPropTreeItem::SetCtrlID(UINT nCtrlID)
{
m_nCtrlID = nCtrlID;
}
UINT CPropTreeItem::GetCtrlID()
{
return m_nCtrlID;
}
LONG CPropTreeItem::GetHeight()
{
return PROPTREEITEM_DEFHEIGHT;
}
LPARAM CPropTreeItem::GetItemValue()
{
// no items are assocatied with this type
return 0L;
}
void CPropTreeItem::SetItemValue(LPARAM)
{
// no items are assocatied with this type
}
void CPropTreeItem::OnMove()
{
// no attributes, do nothing
}
void CPropTreeItem::OnRefresh()
{
// no attributes, do nothing
}
void CPropTreeItem::OnCommit()
{
// no attributes, do nothing
}
void CPropTreeItem::Activate(int activateType, CPoint point)
{
m_bActivated = TRUE;
m_bCommitOnce = FALSE;
OnActivate(activateType, point);
}
void CPropTreeItem::CommitChanges()
{
m_bActivated = FALSE;
if (m_bCommitOnce)
return;
m_bCommitOnce = TRUE;
ASSERT(m_pProp!=NULL);
OnCommit();
m_pProp->SendNotify(PTN_ITEMCHANGED, this);
m_pProp->RefreshItems(this);
}
void CPropTreeItem::OnActivate(int activateType, CPoint point)
{
// no attributes, do nothing
}
void CPropTreeItem::SetPropOwner(CPropTree* pProp)
{
m_pProp = pProp;
}
const POINT& CPropTreeItem::GetLocation()
{
return m_loc;
}
CPropTreeItem* CPropTreeItem::GetParent()
{
return m_pParent;
}
CPropTreeItem* CPropTreeItem::GetSibling()
{
return m_pSibling;
}
CPropTreeItem* CPropTreeItem::GetChild()
{
return m_pChild;
}
CPropTreeItem* CPropTreeItem::GetNextVisible()
{
return m_pVis;
}
void CPropTreeItem::SetParent(CPropTreeItem* pParent)
{
m_pParent = pParent;
}
void CPropTreeItem::SetSibling(CPropTreeItem* pSibling)
{
m_pSibling = pSibling;
}
void CPropTreeItem::SetChild(CPropTreeItem* pChild)
{
m_pChild = pChild;
}
void CPropTreeItem::SetNextVisible(CPropTreeItem* pVis)
{
m_pVis = pVis;
}
LONG CPropTreeItem::DrawItem(CDC* pDC, const RECT& rc, LONG x, LONG y)
{
CPoint pt;
LONG nTotal, nCol, ey;
CRect drc, ir;
ASSERT(m_pProp!=NULL);
// Add TreeItem the list of visble items
m_pProp->AddToVisibleList(this);
// store the item's location
m_loc = CPoint(x, y);
// store the items rectangle position
m_rc.SetRect(m_pProp->GetOrigin().x + PROPTREEITEM_SPACE, m_loc.y, rc.right, m_loc.y + GetHeight()-1);
m_rc.OffsetRect(0, -m_pProp->GetOrigin().y);
// init temp drawing variables
nTotal = GetHeight();
ey = (nTotal >> 1) - (PROPTREEITEM_EXPANDBOX >> 1) - 2;
bool bCheck = false;
// convert item coordinates to screen coordinates
pt = m_loc;
pt.y -= m_pProp->GetOrigin().y;
nCol = m_pProp->GetOrigin().x;
if (IsRootLevel())
drc.SetRect(pt.x + PROPTREEITEM_EXPANDCOLUMN, pt.y, rc.right, pt.y + nTotal);
else
drc.SetRect(pt.x + PROPTREEITEM_EXPANDCOLUMN, pt.y, nCol, pt.y + nTotal);
// root level items are shaded
if (IsRootLevel())
{
HGDIOBJ hOld = pDC->SelectObject(GetSysColorBrush(COLOR_BTNFACE));
pDC->PatBlt(rc.left, drc.top, rc.right - rc.left + 1, drc.Height(), PATCOPY);
pDC->SelectObject(hOld);
}
// calc/draw expand box position
if (GetChild())
{
m_rcExpand.left = PROPTREEITEM_EXPANDCOLUMN/2 - PROPTREEITEM_EXPANDBOXHALF;
m_rcExpand.top = m_loc.y + ey;
m_rcExpand.right = m_rcExpand.left + PROPTREEITEM_EXPANDBOX - 1;
m_rcExpand.bottom = m_rcExpand.top + PROPTREEITEM_EXPANDBOX - 1;
ir = m_rcExpand;
ir.OffsetRect(0, -m_pProp->GetOrigin().y);
_DrawExpand(pDC->m_hDC, ir.left, ir.top, IsExpanded(), !IsRootLevel());
}
else
m_rcExpand.SetRectEmpty();
// calc/draw check box position
if (IsCheckBox())
{
bCheck = true;
ir.left = drc.left + PROPTREEITEM_SPACE;
ir.top = m_loc.y + ey;
ir.right = ir.left + PROPTREEITEM_CHECKBOX;
ir.bottom = ir.top + PROPTREEITEM_CHECKBOX;
m_rcCheckbox = ir;
}
else
m_rcCheckbox.SetRectEmpty();
HRGN hRgn = NULL;
// create a clipping region for the label
if (!IsRootLevel())
{
hRgn = CreateRectRgn(drc.left, drc.top, drc.right, drc.bottom);
SelectClipRgn(pDC->m_hDC, hRgn);
}
// calc label position
ir = drc;
ir.left += PROPTREEITEM_SPACE;
// offset the label text if item has a check box
if (bCheck)
OffsetRect(&ir, PROPTREEITEM_CHECKBOX + PROPTREEITEM_SPACE * 2, 0);
// draw label
if (!m_sLabel.IsEmpty())
{
if (IsRootLevel())
pDC->SelectObject(CPropTree::GetBoldFont());
else
pDC->SelectObject(CPropTree::GetNormalFont());
pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));
pDC->SetBkMode(TRANSPARENT);
pDC->DrawText(m_sLabel, &ir, DT_SINGLELINE|DT_VCENTER|DT_CALCRECT);
// draw the text highlighted if selected
if (IsSelected())
{
HGDIOBJ oPen = pDC->SelectObject(GetStockObject(NULL_PEN));
HGDIOBJ oBrush = pDC->SelectObject(GetSysColorBrush(COLOR_HIGHLIGHT));
CRect dr;
dr = drc;
dr.left = PROPTREEITEM_EXPANDCOLUMN;
pDC->Rectangle(&dr);
pDC->SelectObject(oPen);
pDC->SelectObject(oBrush);
pDC->SetTextColor(GetSysColor(COLOR_BTNHIGHLIGHT));
}
// check if we need to draw the text as disabled
if (!m_pProp->IsWindowEnabled())
pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
pDC->DrawText(m_sLabel, &ir, DT_SINGLELINE|DT_VCENTER);
}
// draw check box frame
if (IsCheckBox())
{
ir = m_rcCheckbox;
ir.OffsetRect(0, -m_pProp->GetOrigin().y);
pDC->DrawFrameControl(&ir, DFC_BUTTON, DFCS_BUTTONCHECK | (IsChecked() ? DFCS_CHECKED : 0));
}
// remove clip region
if (hRgn)
{
SelectClipRgn(pDC->m_hDC, NULL);
DeleteObject(hRgn);
}
// draw horzontal sep
_DotHLine(pDC->m_hDC, PROPTREEITEM_EXPANDCOLUMN, pt.y + nTotal - 1, rc.right - PROPTREEITEM_EXPANDCOLUMN + 1);
// draw separators
if (!IsRootLevel())
{
// column sep
CPen pn1(PS_SOLID, 1, GetSysColor(COLOR_BTNSHADOW));
CPen* pOld;
pOld = pDC->SelectObject(&pn1);
pDC->MoveTo(nCol, drc.top);
pDC->LineTo(nCol, drc.bottom);
CPen pn2(PS_SOLID, 1, GetSysColor(COLOR_BTNHIGHLIGHT));
pDC->SelectObject(&pn2);
pDC->MoveTo(nCol + 1, drc.top);
pDC->LineTo(nCol + 1, drc.bottom);
pDC->SelectObject(pOld);
}
// draw attribute
if (!IsRootLevel())
{
// create clip region
hRgn = CreateRectRgn(m_rc.left, m_rc.top, m_rc.right, m_rc.bottom);
SelectClipRgn(pDC->m_hDC, hRgn);
DrawAttribute(pDC, m_rc);
SelectClipRgn(pDC->m_hDC, NULL);
DeleteObject(hRgn);
}
// draw children
if (GetChild() && IsExpanded())
{
y += nTotal;
CPropTreeItem* pNext;
for (pNext = GetChild(); pNext; pNext = pNext->GetSibling())
{
LONG nHeight = pNext->DrawItem(pDC, rc, x + (IsRootLevel() ? 0 : PNINDENT), y);
nTotal += nHeight;
y += nHeight;
}
}
return nTotal;
}
void CPropTreeItem::DrawAttribute(CDC*, const RECT&)
{
// no attributes are assocatied with this type
}

View File

@@ -0,0 +1,203 @@
// PropTreeItem.h
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#ifndef _PROPTREEITEM_H
#define _PROPTREEITEM_H
class CPropTree;
class PROPTREE_API CPropTreeItem
{
// Construction
public:
CPropTreeItem();
virtual ~CPropTreeItem();
// Attributes/Operations
public:
// TreeItem states
BOOL IsExpanded();
BOOL IsSelected();
BOOL IsChecked();
BOOL IsReadOnly();
BOOL IsActivated();
void Select(BOOL bSelect = TRUE);
void Expand(BOOL bExpand = TRUE);
void Check(BOOL bCheck = TRUE);
void ReadOnly(BOOL bReadOnly = TRUE);
// Returns true if the item has a checkbox
BOOL IsCheckBox();
// Pass in true, for the item to have a checkbox
void HasCheckBox(BOOL bCheckbox = TRUE);
// Returns TRUE if the point is on the expand button
BOOL HitExpand(const POINT& pt);
// Returns TRUE if the point is on the check box
BOOL HitCheckBox(const POINT& pt);
// Overrideable - Returns TRUE if the point is on the button
virtual BOOL HitButton(const POINT& pt) { return false;}
// Returns TRUE if the item is on the root level. Root level items don't have attribute areas
BOOL IsRootLevel();
// Returns the total height of the item and all its children
LONG GetTotalHeight();
// Set the items label text
void SetLabelText(LPCTSTR sLabel);
// Return the items label text
LPCTSTR GetLabelText();
// Set the items info (description) text
void SetInfoText(LPCTSTR sInfo);
// Get the items info (description) text
LPCTSTR GetInfoText();
// Set the item's ID
void SetCtrlID(UINT nCtrlID);
// Return the item's ID
UINT GetCtrlID();
// Overrideable - draw the item's non attribute area
virtual LONG DrawItem(CDC* pDC, const RECT& rc, LONG x, LONG y);
// call to mark attribute changes
void CommitChanges();
// call to activate item attribute
enum {
ACTIVATE_TYPE_KEYBOARD,
ACTIVATE_TYPE_MOUSE
};
void Activate(int activateType, CPoint point);
//
// Overrideables
//
// The attribute area needs drawing
virtual void DrawAttribute(CDC* pDC, const RECT& rc);
// Return the height of the item
virtual LONG GetHeight();
// Retrieve the item's attribute value
virtual LPARAM GetItemValue();
// Set the item's attribute value
virtual void SetItemValue(LPARAM lParam);
// Called when attribute area has changed size
virtual void OnMove();
// Called when the item needs to refresh its data
virtual void OnRefresh();
// Called when the item needs to commit its changes
virtual void OnCommit();
// Called to activate the item
virtual void OnActivate(int activateType, CPoint point);
//
// Usually only CPropTree should calls these
//
void SetPropOwner(CPropTree* pProp);
// Return the location of the PropItem
const POINT& GetLocation();
// TreeItem link pointer access
CPropTreeItem* GetParent();
CPropTreeItem* GetSibling();
CPropTreeItem* GetChild();
CPropTreeItem* GetNextVisible();
void SetParent(CPropTreeItem* pParent);
void SetSibling(CPropTreeItem* pSibling);
void SetChild(CPropTreeItem* pChild);
void SetNextVisible(CPropTreeItem* pVis);
protected:
// CPropTree class that this class belongs
CPropTree* m_pProp;
// TreeItem label name
CString m_sLabel;
// Descriptive info text
CString m_sInfo;
// TreeItem location
CPoint m_loc;
// TreeItem attribute size
CRect m_rc;
// user defined LPARAM value
LPARAM m_lParam;
// ID of control item (should be unique)
UINT m_nCtrlID;
protected:
enum TreeItemStates
{
TreeItemSelected = 0x00000001,
TreeItemExpanded = 0x00000002,
TreeItemCheckbox = 0x00000004,
TreeItemChecked = 0x00000008,
TreeItemActivated = 0x00000010,
TreeItemReadOnly = 0x00000020,
};
// TreeItem state
DWORD m_dwState;
// TRUE if item is activated
BOOL m_bActivated;
// TRUE if item has been commited once (activation)
BOOL m_bCommitOnce;
// Rectangle position of the expand button (if contains one)
CRect m_rcExpand;
// Rectangle position of the check box (if contains one)
CRect m_rcCheckbox;
// Rectangle position of the button (if contains one)
CRect m_rcButton;
// link pointers
CPropTreeItem* m_pParent;
CPropTreeItem* m_pSibling;
CPropTreeItem* m_pChild;
CPropTreeItem* m_pVis;
};
#endif // _PROPTREEITEM_H

View File

@@ -0,0 +1,103 @@
// PropTreeItemButton.cpp : implementation file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "proptree.h"
#include "PropTreeItemButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define BUTTON_SIZE 17
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemButton
CPropTreeItemButton::CPropTreeItemButton() {
mouseDown = false;
}
CPropTreeItemButton::~CPropTreeItemButton() {
}
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemButton message handlers
LONG CPropTreeItemButton::DrawItem( CDC* pDC, const RECT& rc, LONG x, LONG y )
{
CSize textSize;
CRect textRect;
LONG nTotal = 0;
nTotal = CPropTreeItem::DrawItem( pDC, rc, x, y );
textSize = pDC->GetOutputTextExtent( buttonText );
buttonRect.left = m_rc.right - ( textSize.cx + 12 + 4);
buttonRect.top = m_rc.top + ((m_rc.bottom - m_rc.top)/2)-BUTTON_SIZE/2;
buttonRect.right = buttonRect.left + textSize.cx + 12;
buttonRect.bottom = buttonRect.top + BUTTON_SIZE;
UINT buttonStyle;
if ( (m_dwState & TreeItemChecked) ) {
buttonStyle = DFCS_BUTTONPUSH | DFCS_PUSHED;
} else {
buttonStyle = DFCS_BUTTONPUSH;
}
pDC->DrawFrameControl(&buttonRect, DFC_BUTTON, buttonStyle );
textRect = buttonRect;
textRect.left += 4;
textRect.right -= 8;
pDC->DrawText( buttonText, textRect, DT_SINGLELINE|DT_VCENTER );
//Adjust hit test rect to acount for window scrolling
hitTestRect = buttonRect;
hitTestRect.OffsetRect(0, m_pProp->GetOrigin().y);
return nTotal;
}
void CPropTreeItemButton::DrawAttribute(CDC* pDC, const RECT& rc) {
}
LPARAM CPropTreeItemButton::GetItemValue() {
return (LPARAM)0;
}
void CPropTreeItemButton::SetItemValue(LPARAM lParam) {
}
BOOL CPropTreeItemButton::HitButton( const POINT& pt ) {
return hitTestRect.PtInRect( pt );
}
void CPropTreeItemButton::SetButtonText( LPCSTR text ) {
buttonText = text;
}

View File

@@ -0,0 +1,63 @@
#pragma once
// PropTreeItemButton.h : header file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#include "PropTreeItem.h"
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemButton window
class PROPTREE_API CPropTreeItemButton : public CPropTreeItem
{
// Construction
public:
CPropTreeItemButton();
virtual ~CPropTreeItemButton();
// Attributes
public:
// The non-attribute area needs drawing
virtual LONG DrawItem(CDC* pDC, const RECT& rc, LONG x, LONG y);
// The attribute area needs drawing
virtual void DrawAttribute(CDC* pDC, const RECT& rc);
// Retrieve the item's attribute value
virtual LPARAM GetItemValue();
// Set the item's attribute value
virtual void SetItemValue(LPARAM lParam);
// Overrideable - Returns TRUE if the point is on the button
virtual BOOL HitButton(const POINT& pt);
void SetButtonText( LPCSTR text );
protected:
CString buttonText;
CRect buttonRect;
CRect hitTestRect;
bool mouseDown;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

View File

@@ -0,0 +1,161 @@
// PropTreeItemCheck.cpp : implementation file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "proptree.h"
#include "PropTreeItemCheck.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define CHECK_BOX_SIZE 14
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemCheck
CPropTreeItemCheck::CPropTreeItemCheck()
{
checkState = 0;
}
CPropTreeItemCheck::~CPropTreeItemCheck()
{
}
BEGIN_MESSAGE_MAP(CPropTreeItemCheck, CButton)
//{{AFX_MSG_MAP(CPropTreeItemCheck)
//}}AFX_MSG_MAP
ON_CONTROL_REFLECT(BN_KILLFOCUS, OnBnKillfocus)
ON_CONTROL_REFLECT(BN_CLICKED, OnBnClicked)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemCheck message handlers
void CPropTreeItemCheck::DrawAttribute(CDC* pDC, const RECT& rc)
{
ASSERT(m_pProp!=NULL);
// verify the window has been created
if (!IsWindow(m_hWnd))
{
TRACE0("CPropTreeItemCombo::DrawAttribute() - The window has not been created\n");
return;
}
checkRect.left = m_rc.left;
checkRect.top = m_rc.top + ((m_rc.bottom - m_rc.top)/2)-CHECK_BOX_SIZE/2;
checkRect.right = checkRect.left + CHECK_BOX_SIZE;
checkRect.bottom = checkRect.top + CHECK_BOX_SIZE;
if(!m_bActivated)
pDC->DrawFrameControl(&checkRect, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_FLAT |(checkState ? DFCS_CHECKED : 0));
}
void CPropTreeItemCheck::SetCheckState(BOOL state)
{
checkState = state;
SetCheck(checkState ? BST_CHECKED : BST_UNCHECKED);
}
LPARAM CPropTreeItemCheck::GetItemValue()
{
return (LPARAM)GetCheckState();
}
void CPropTreeItemCheck::SetItemValue(LPARAM lParam)
{
SetCheckState((BOOL)lParam);
}
void CPropTreeItemCheck::OnMove()
{
if (IsWindow(m_hWnd))
SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width(), m_rc.Height(), SWP_NOZORDER|SWP_NOACTIVATE);
}
void CPropTreeItemCheck::OnRefresh()
{
}
void CPropTreeItemCheck::OnCommit()
{
ShowWindow(SW_HIDE);
}
void CPropTreeItemCheck::OnActivate(int activateType, CPoint point)
{
if(activateType == CPropTreeItem::ACTIVATE_TYPE_MOUSE) {
//Check where the user clicked
if(point.x < m_rc.left + CHECK_BOX_SIZE) {
SetCheckState(!GetCheckState());
CommitChanges();
} else {
SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width(), m_rc.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
SetFocus();
}
} else {
SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width(), m_rc.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
SetFocus();
}
}
bool CPropTreeItemCheck::CreateCheckBox() {
ASSERT(m_pProp!=NULL);
if (IsWindow(m_hWnd))
DestroyWindow();
DWORD dwStyle = (WS_CHILD|BS_CHECKBOX|BS_NOTIFY|BS_FLAT );
if (!Create(NULL, dwStyle, CRect(0,0,0,0), m_pProp->GetCtrlParent(), GetCtrlID()))
{
TRACE0("CPropTreeItemCombo::CreateComboBox() - failed to create combo box\n");
return FALSE;
}
return TRUE;
}
void CPropTreeItemCheck::OnBnKillfocus()
{
CommitChanges();
}
void CPropTreeItemCheck::OnBnClicked()
{
int state = GetCheck();
SetCheckState(GetCheck() == BST_CHECKED ? FALSE : TRUE);
CommitChanges();
}

View File

@@ -0,0 +1,95 @@
#pragma once
// PropTreeItemCheck.h : header file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#include "PropTreeItem.h"
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemCheck window
class PROPTREE_API CPropTreeItemCheck : public CButton, public CPropTreeItem
{
// Construction
public:
CPropTreeItemCheck();
virtual ~CPropTreeItemCheck();
// Attributes
public:
// The attribute area needs drawing
virtual void DrawAttribute(CDC* pDC, const RECT& rc);
// Retrieve the item's attribute value
virtual LPARAM GetItemValue();
// Set the item's attribute value
virtual void SetItemValue(LPARAM lParam);
// Called when attribute area has changed size
virtual void OnMove();
// Called when the item needs to refresh its data
virtual void OnRefresh();
// Called when the item needs to commit its changes
virtual void OnCommit();
// Called to activate the item
virtual void OnActivate(int activateType, CPoint point);
bool HitCheckBoxTest(const POINT& pt);
bool CreateCheckBox();
BOOL GetCheckState() { return checkState; };
void SetCheckState(BOOL state);
protected:
BOOL checkState;
CRect checkRect;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropTreeItemCheck)
//}}AFX_VIRTUAL
// Implementation
public:
// Generated message map functions
protected:
//{{AFX_MSG(CPropTreeItemCheck)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnKillfocus();
afx_msg void OnBnClicked();
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

View File

@@ -0,0 +1,369 @@
// PropTreeItemColor.cpp : implementation file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "PropTree.h"
#include "../../../sys/win32/rc/proptree_Resource.h"
#include "PropTreeItemColor.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern HINSTANCE ghInst;
typedef struct _ColorTableEntry
{
COLORREF color;
RECT rcSpot;
} ColorTableEntry;
static ColorTableEntry _crColors[] =
{
{RGB(0x00, 0x00, 0x00)},
{RGB(0xA5, 0x2A, 0x00)},
{RGB(0x00, 0x40, 0x40)},
{RGB(0x00, 0x55, 0x00)},
{RGB(0x00, 0x00, 0x5E)},
{RGB(0x00, 0x00, 0x8B)},
{RGB(0x4B, 0x00, 0x82)},
{RGB(0x28, 0x28, 0x28)},
{RGB(0x8B, 0x00, 0x00)},
{RGB(0xFF, 0x68, 0x20)},
{RGB(0x8B, 0x8B, 0x00)},
{RGB(0x00, 0x93, 0x00)},
{RGB(0x38, 0x8E, 0x8E)},
{RGB(0x00, 0x00, 0xFF)},
{RGB(0x7B, 0x7B, 0xC0)},
{RGB(0x66, 0x66, 0x66)},
{RGB(0xFF, 0x00, 0x00)},
{RGB(0xFF, 0xAD, 0x5B)},
{RGB(0x32, 0xCD, 0x32)},
{RGB(0x3C, 0xB3, 0x71)},
{RGB(0x7F, 0xFF, 0xD4)},
{RGB(0x7D, 0x9E, 0xC0)},
{RGB(0x80, 0x00, 0x80)},
{RGB(0x7F, 0x7F, 0x7F)},
{RGB(0xFF, 0xC0, 0xCB)},
{RGB(0xFF, 0xD7, 0x00)},
{RGB(0xFF, 0xFF, 0x00)},
{RGB(0x00, 0xFF, 0x00)},
{RGB(0x40, 0xE0, 0xD0)},
{RGB(0xC0, 0xFF, 0xFF)},
{RGB(0x48, 0x00, 0x48)},
{RGB(0xC0, 0xC0, 0xC0)},
{RGB(0xFF, 0xE4, 0xE1)},
{RGB(0xD2, 0xB4, 0x8C)},
{RGB(0xFF, 0xFF, 0xE0)},
{RGB(0x98, 0xFB, 0x98)},
{RGB(0xAF, 0xEE, 0xEE)},
{RGB(0x68, 0x83, 0x8B)},
{RGB(0xE6, 0xE6, 0xFA)},
{RGB(0xFF, 0xFF, 0xFF)}
};
static void ColorBox(CDC* pDC, CPoint pt, COLORREF clr, BOOL bHover)
{
CBrush br(clr);
CBrush* obr = pDC->SelectObject(&br);
pDC->PatBlt(pt.x, pt.y, 13, 13, PATCOPY);
pDC->SelectObject(obr);
CRect rc;
rc.SetRect(pt.x - 2, pt.y - 2, pt.x + 15, pt.y + 15);
pDC->DrawEdge(&rc, (bHover) ? BDR_SUNKENOUTER : BDR_RAISEDINNER, BF_RECT);
}
static LONG FindSpot(CPoint point)
{
for (LONG i=0; i<40; i++)
{
if (PtInRect(&_crColors[i].rcSpot, point))
return i;
}
return -1;
}
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemColor
COLORREF* CPropTreeItemColor::s_pColors = NULL;
CPropTreeItemColor::CPropTreeItemColor() :
m_cColor(0),
m_cPrevColor(0),
m_nSpot(-1),
m_bButton(FALSE),
m_bInDialog(FALSE)
{
}
CPropTreeItemColor::~CPropTreeItemColor()
{
}
BEGIN_MESSAGE_MAP(CPropTreeItemColor, CWnd)
//{{AFX_MSG_MAP(CPropTreeItemColor)
ON_WM_KILLFOCUS()
ON_WM_PAINT()
ON_WM_CLOSE()
ON_WM_MOUSEMOVE()
ON_WM_SETCURSOR()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemColor message handlers
void CPropTreeItemColor::SetDefaultColorsList(COLORREF* pColors)
{
s_pColors = pColors;
}
void CPropTreeItemColor::DrawAttribute(CDC* pDC, const RECT& rc)
{
ASSERT(m_pProp!=NULL);
CRect r(rc);
pDC->SelectObject(IsReadOnly() ? m_pProp->GetNormalFont() : m_pProp->GetBoldFont());
if (!m_pProp->IsWindowEnabled())
pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
else
pDC->SetTextColor(RGB(0,0,0));
r.top += 1;
r.right = r.left + r.Height() - 1;
CBrush br(m_cColor);
CBrush* pold = pDC->SelectObject(&br);
pDC->PatBlt(r.left, r.top, r.Width(), r.Height(), PATCOPY);
pDC->SelectObject(pold);
pDC->DrawEdge(&r, EDGE_SUNKEN, BF_RECT);
CString s;
r = rc;
r.left += r.Height();
s.Format(_T("R = %d, G = %d, B = %d"), GetRValue(m_cColor),GetGValue(m_cColor), GetBValue(m_cColor));
pDC->DrawText(s, r, DT_SINGLELINE|DT_VCENTER);
}
LPARAM CPropTreeItemColor::GetItemValue()
{
return m_cColor;
}
void CPropTreeItemColor::SetItemValue(LPARAM lParam)
{
m_cColor = lParam;
}
void CPropTreeItemColor::OnMove()
{
}
void CPropTreeItemColor::OnRefresh()
{
}
void CPropTreeItemColor::OnCommit()
{
ShowWindow(SW_HIDE);
}
void CPropTreeItemColor::OnActivate(int activateType, CPoint point)
{
CRect r;
m_cPrevColor = m_cColor;
r = m_rc;
r.right = r.left + 150;
r.bottom = r.top + 120;
ASSERT(m_pProp!=NULL);
m_pProp->GetCtrlParent()->ClientToScreen(r);
if (!IsWindow(m_hWnd))
{
LPCTSTR pszClassName;
pszClassName = AfxRegisterWndClass(CS_VREDRAW|CS_HREDRAW, LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_BTNFACE + 1));
DWORD dwStyle = WS_POPUP|WS_DLGFRAME;
CreateEx(0, pszClassName, _T(""), dwStyle, r, m_pProp->GetCtrlParent(), 0);
m_rcButton.SetRect(40, 94, 110, 114);
}
SetWindowPos(NULL, r.left, r.top, r.Width() + 1, r.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
SetFocus();
}
void CPropTreeItemColor::OnKillFocus(CWnd* pNewWnd)
{
CWnd::OnKillFocus(pNewWnd);
if (!m_bInDialog)
CommitChanges();
}
void CPropTreeItemColor::OnPaint()
{
CPaintDC dc(this);
CPoint pt;
for (LONG i=0; i<40; i++)
{
pt.x = (i & 7) * 18 + 3;
pt.y = (i >> 3) * 18 + 3;
ColorBox(&dc, pt, _crColors[i].color, m_nSpot==i);
SetRect(&_crColors[i].rcSpot, pt.x, pt.y, pt.x + 13, pt.y + 13);
}
ASSERT(m_pProp!=NULL);
dc.SelectObject(m_pProp->GetNormalFont());
CString s(_T("More Colors"));
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(GetSysColor(COLOR_BTNTEXT));
dc.DrawText(s, &m_rcButton, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
dc.DrawEdge(&m_rcButton, m_bButton ? BDR_SUNKENOUTER : BDR_RAISEDINNER, BF_RECT);
}
void CPropTreeItemColor::OnClose()
{
CommitChanges();
}
void CPropTreeItemColor::OnMouseMove(UINT, CPoint point)
{
BOOL bButton;
LONG nSpot;
nSpot = FindSpot(point);
if (nSpot!=m_nSpot)
{
Invalidate(FALSE);
m_nSpot = nSpot;
}
bButton = m_rcButton.PtInRect(point);
if (bButton!=m_bButton)
{
m_bButton = bButton;
Invalidate(FALSE);
}
}
BOOL CPropTreeItemColor::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (nHitTest==HTCLIENT)
{
CPoint point;
GetCursorPos(&point);
ScreenToClient(&point);
if (FindSpot(point)!=-1 || m_rcButton.PtInRect(point))
{
SetCursor(LoadCursor(ghInst, MAKEINTRESOURCE(IDC_FPOINT)));
return TRUE;
}
}
return CWnd::OnSetCursor(pWnd, nHitTest, message);
}
void CPropTreeItemColor::OnLButtonDown(UINT, CPoint point)
{
if (m_nSpot!=-1)
{
m_cColor = _crColors[m_nSpot].color;
CommitChanges();
}
else
if (m_rcButton.PtInRect(point))
{
CHOOSECOLOR cc;
COLORREF clr[16];
ZeroMemory(&cc, sizeof(CHOOSECOLOR));
cc.Flags = CC_FULLOPEN|CC_ANYCOLOR|CC_RGBINIT;
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = m_hWnd;
cc.rgbResult = m_cColor;
cc.lpCustColors = s_pColors ? s_pColors : clr;
memset(clr, 0xff, sizeof(COLORREF) * 16);
clr[0] = m_cColor;
m_bInDialog = TRUE;
ASSERT(m_pProp!=NULL);
m_pProp->DisableInput();
ShowWindow(SW_HIDE);
if (ChooseColor(&cc))
m_cColor = cc.rgbResult;
m_pProp->DisableInput(FALSE);
CommitChanges();
}
}

View File

@@ -0,0 +1,98 @@
#if !defined(AFX_PROPTREEITEMCOLOR_H__50C09AC0_1F02_4150_AA6A_5151345D87A2__INCLUDED_)
#define AFX_PROPTREEITEMCOLOR_H__50C09AC0_1F02_4150_AA6A_5151345D87A2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PropTreeItemColor.h : header file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#include "PropTreeItem.h"
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemColor window
class PROPTREE_API CPropTreeItemColor : public CWnd, public CPropTreeItem
{
// Construction
public:
CPropTreeItemColor();
virtual ~CPropTreeItemColor();
// Attributes
public:
// The attribute area needs drawing
virtual void DrawAttribute(CDC* pDC, const RECT& rc);
// Retrieve the item's attribute value
virtual LPARAM GetItemValue();
// Set the item's attribute value
virtual void SetItemValue(LPARAM lParam);
// Called when attribute area has changed size
virtual void OnMove();
// Called when the item needs to refresh its data
virtual void OnRefresh();
// Called when the item needs to commit its changes
virtual void OnCommit();
// Called to activate the item
virtual void OnActivate(int activateType, CPoint point);
static void SetDefaultColorsList(COLORREF* pColors);
protected:
COLORREF m_cColor;
COLORREF m_cPrevColor;
CRect m_rcButton;
LONG m_nSpot;
BOOL m_bButton;
BOOL m_bInDialog;
static COLORREF* s_pColors;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropTreeItemColor)
//}}AFX_VIRTUAL
// Implementation
public:
// Generated message map functions
protected:
//{{AFX_MSG(CPropTreeItemColor)
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnPaint();
afx_msg void OnClose();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROPTREEITEMCOLOR_H__50C09AC0_1F02_4150_AA6A_5151345D87A2__INCLUDED_)

View File

@@ -0,0 +1,233 @@
// PropTreeItemCombo.cpp : implementation file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "PropTree.h"
#include "../../../sys/win32/rc/proptree_Resource.h"
#include "PropTreeItemCombo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define DROPDOWN_HEIGHT 100
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemCombo
CPropTreeItemCombo::CPropTreeItemCombo() :
m_lComboData(0),
m_nDropHeight(DROPDOWN_HEIGHT)
{
}
CPropTreeItemCombo::~CPropTreeItemCombo()
{
}
BEGIN_MESSAGE_MAP(CPropTreeItemCombo, CComboBox)
//{{AFX_MSG_MAP(CPropTreeItemCombo)
ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
ON_CONTROL_REFLECT(CBN_KILLFOCUS, OnKillfocus)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemCombo message handlers
void CPropTreeItemCombo::DrawAttribute(CDC* pDC, const RECT& rc)
{
ASSERT(m_pProp!=NULL);
// verify the window has been created
if (!IsWindow(m_hWnd))
{
TRACE0("CPropTreeItemCombo::DrawAttribute() - The window has not been created\n");
return;
}
pDC->SelectObject(IsReadOnly() ? m_pProp->GetNormalFont() : m_pProp->GetBoldFont());
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkMode(TRANSPARENT);
CRect r = rc;
CString s;
LONG idx;
if ((idx = GetCurSel())!=CB_ERR)
GetLBText(idx, s);
else
s = _T("");
pDC->DrawText(s, r, DT_SINGLELINE|DT_VCENTER);
}
LPARAM CPropTreeItemCombo::GetItemValue()
{
return m_lComboData;
}
void CPropTreeItemCombo::SetItemValue(LPARAM lParam)
{
m_lComboData = lParam;
OnRefresh();
}
void CPropTreeItemCombo::OnMove()
{
if (IsWindow(m_hWnd) && IsWindowVisible())
SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width() + 1, m_rc.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
}
void CPropTreeItemCombo::OnRefresh()
{
LONG idx = FindCBData(m_lComboData);
if (idx!=CB_ERR)
SetCurSel(idx);
}
void CPropTreeItemCombo::OnCommit()
{
LONG idx;
// store combo box item data
if ((idx = GetCurSel())==CB_ERR)
m_lComboData = 0;
else
m_lComboData = (LPARAM)GetItemData(idx);
ShowWindow(SW_HIDE);
}
void CPropTreeItemCombo::OnActivate(int activateType, CPoint point)
{
// activate the combo box
SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width() + 1, m_rc.Height() + m_nDropHeight, SWP_NOZORDER|SWP_SHOWWINDOW);
SetFocus();
if (GetCount())
ShowDropDown(TRUE);
}
BOOL CPropTreeItemCombo::CreateComboBox(DWORD dwStyle)
{
ASSERT(m_pProp!=NULL);
if (IsWindow(m_hWnd))
DestroyWindow();
// force as not visible child window
dwStyle = (WS_CHILD|WS_VSCROLL|dwStyle) & ~WS_VISIBLE;
if (!Create(dwStyle, CRect(0,0,0,0), m_pProp->GetCtrlParent(), GetCtrlID()))
{
TRACE0("CPropTreeItemCombo::CreateComboBox() - failed to create combo box\n");
return FALSE;
}
SendMessage(WM_SETFONT, (WPARAM)m_pProp->GetNormalFont()->m_hObject);
return TRUE;
}
BOOL CPropTreeItemCombo::CreateComboBoxBool()
{
ASSERT(m_pProp!=NULL);
if (IsWindow(m_hWnd))
DestroyWindow();
// force as a non-visible child window
DWORD dwStyle = WS_CHILD|WS_VSCROLL|CBS_SORT|CBS_DROPDOWNLIST;
if (!Create(dwStyle, CRect(0,0,0,0), m_pProp->GetCtrlParent(), GetCtrlID()))
{
TRACE0("CPropTreeItemCombo::CreateComboBoxBool() - failed to create combo box\n");
return FALSE;
}
SendMessage(WM_SETFONT, (WPARAM)m_pProp->GetNormalFont()->m_hObject);
// file the combo box
LONG idx;
CString s;
s.LoadString(IDS_TRUE);
idx = AddString(s);
SetItemData(idx, TRUE);
s.LoadString(IDS_FALSE);
idx = AddString(s);
SetItemData(idx, FALSE);
return TRUE;
}
LONG CPropTreeItemCombo::FindCBData(LPARAM lParam)
{
LONG idx;
for (idx = 0; idx < GetCount(); idx++)
{
if (GetItemData(idx)==(DWORD)lParam)
return idx;
}
return CB_ERR;
}
void CPropTreeItemCombo::OnSelchange()
{
CommitChanges();
}
void CPropTreeItemCombo::OnKillfocus()
{
CommitChanges();
}
void CPropTreeItemCombo::SetDropDownHeight(LONG nDropHeight)
{
m_nDropHeight = nDropHeight;
}
LONG CPropTreeItemCombo::GetDropDownHeight()
{
return m_nDropHeight;
}

View File

@@ -0,0 +1,103 @@
#if !defined(AFX_PROPTREEITEMCOMBO_H__9916BC6F_751F_4B15_996F_3C9F6334A259__INCLUDED_)
#define AFX_PROPTREEITEMCOMBO_H__9916BC6F_751F_4B15_996F_3C9F6334A259__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PropTreeItemCombo.h : header file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#include "PropTreeItem.h"
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemCombo window
class PROPTREE_API CPropTreeItemCombo : public CComboBox, public CPropTreeItem
{
// Construction
public:
CPropTreeItemCombo();
virtual ~CPropTreeItemCombo();
// Attributes
public:
// The attribute area needs drawing
virtual void DrawAttribute(CDC* pDC, const RECT& rc);
// Retrieve the item's attribute value
virtual LPARAM GetItemValue();
// Set the item's attribute value
virtual void SetItemValue(LPARAM lParam);
// Called when attribute area has changed size
virtual void OnMove();
// Called when the item needs to refresh its data
virtual void OnRefresh();
// Called when the item needs to commit its changes
virtual void OnCommit();
// Called to activate the item
virtual void OnActivate(int activateType, CPoint point);
// Create your combo box with your specified styles
BOOL CreateComboBox(DWORD dwStyle = WS_CHILD|WS_VSCROLL|CBS_SORT|CBS_DROPDOWNLIST);
// Create combo box with TRUE/FALSE selections
BOOL CreateComboBoxBool();
// Set the height for the dropdown combo box
void SetDropDownHeight(LONG nDropHeight);
// Get the height of the dropdown combo box
LONG GetDropDownHeight();
protected:
LPARAM m_lComboData;
LONG m_nDropHeight;
// Operations
protected:
LONG FindCBData(LPARAM lParam);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropTreeItemCombo)
//}}AFX_VIRTUAL
// Implementation
public:
// Generated message map functions
protected:
//{{AFX_MSG(CPropTreeItemCombo)
afx_msg void OnSelchange();
afx_msg void OnKillfocus();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROPTREEITEMCOMBO_H__9916BC6F_751F_4B15_996F_3C9F6334A259__INCLUDED_)

View File

@@ -0,0 +1,212 @@
// PropTreeItemEdit.cpp : implementation file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "proptree.h"
#include "PropTreeItemEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemEdit
CPropTreeItemEdit::CPropTreeItemEdit() :
m_sEdit(_T("")),
m_nFormat(ValueFormatText),
m_bPassword(FALSE),
m_fValue(0.0f)
{
}
CPropTreeItemEdit::~CPropTreeItemEdit()
{
}
BEGIN_MESSAGE_MAP(CPropTreeItemEdit, CEdit)
//{{AFX_MSG_MAP(CPropTreeItemEdit)
ON_WM_GETDLGCODE()
ON_WM_KEYDOWN()
ON_CONTROL_REFLECT(EN_KILLFOCUS, OnKillfocus)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemEdit message handlers
void CPropTreeItemEdit::DrawAttribute(CDC* pDC, const RECT& rc)
{
ASSERT(m_pProp!=NULL);
pDC->SelectObject(IsReadOnly() ? m_pProp->GetNormalFont() : m_pProp->GetBoldFont());
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkMode(TRANSPARENT);
CRect r = rc;
TCHAR ch;
// can't use GetPasswordChar(), because window may not be created yet
ch = (m_bPassword) ? '*' : '\0';
if (ch)
{
CString s;
s = m_sEdit;
for (LONG i=0; i<s.GetLength();i++)
s.SetAt(i, ch);
pDC->DrawText(s, r, DT_SINGLELINE|DT_VCENTER);
}
else
{
pDC->DrawText(m_sEdit, r, DT_SINGLELINE|DT_VCENTER);
}
}
void CPropTreeItemEdit::SetAsPassword(BOOL bPassword)
{
m_bPassword = bPassword;
}
void CPropTreeItemEdit::SetValueFormat(ValueFormat nFormat)
{
m_nFormat = nFormat;
}
LPARAM CPropTreeItemEdit::GetItemValue()
{
switch (m_nFormat)
{
case ValueFormatNumber:
return _ttoi(m_sEdit);
case ValueFormatFloatPointer:
_stscanf(m_sEdit, _T("%f"), &m_fValue);
return (LPARAM)&m_fValue;
}
return (LPARAM)(LPCTSTR)m_sEdit;
}
void CPropTreeItemEdit::SetItemValue(LPARAM lParam)
{
switch (m_nFormat)
{
case ValueFormatNumber:
m_sEdit.Format(_T("%d"), lParam);
return;
case ValueFormatFloatPointer:
{
TCHAR tmp[MAX_PATH];
m_fValue = *(float*)lParam;
_stprintf(tmp, _T("%f"), m_fValue);
m_sEdit = tmp;
}
return;
}
if (lParam==0L)
{
TRACE0("CPropTreeItemEdit::SetItemValue - Invalid lParam value\n");
return;
}
m_sEdit = (LPCTSTR)lParam;
}
void CPropTreeItemEdit::OnMove()
{
if (IsWindow(m_hWnd))
SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width(), m_rc.Height(), SWP_NOZORDER|SWP_NOACTIVATE);
}
void CPropTreeItemEdit::OnRefresh()
{
if (IsWindow(m_hWnd))
SetWindowText(m_sEdit);
}
void CPropTreeItemEdit::OnCommit()
{
// hide edit control
ShowWindow(SW_HIDE);
// store edit text for GetItemValue
GetWindowText(m_sEdit);
}
void CPropTreeItemEdit::OnActivate(int activateType, CPoint point)
{
// Check if the edit control needs creation
if (!IsWindow(m_hWnd))
{
DWORD dwStyle;
dwStyle = WS_CHILD|ES_AUTOHSCROLL;
Create(dwStyle, m_rc, m_pProp->GetCtrlParent(), GetCtrlID());
}
SendMessage(WM_SETFONT, (WPARAM)m_pProp->GetNormalFont()->m_hObject);
SetPasswordChar((TCHAR)(m_bPassword ? '*' : 0));
SetWindowText(m_sEdit);
SetSel(0, -1);
SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width(), m_rc.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
SetFocus();
}
UINT CPropTreeItemEdit::OnGetDlgCode()
{
return CEdit::OnGetDlgCode()|DLGC_WANTALLKEYS;
}
void CPropTreeItemEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar==VK_RETURN)
CommitChanges();
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CPropTreeItemEdit::OnKillfocus()
{
CommitChanges();
}

View File

@@ -0,0 +1,108 @@
#if !defined(AFX_PROPTREEITEMEDIT_H__642536B1_1162_4F99_B09D_9B1BD2CF88B6__INCLUDED_)
#define AFX_PROPTREEITEMEDIT_H__642536B1_1162_4F99_B09D_9B1BD2CF88B6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PropTreeItemEdit.h : header file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#include "PropTreeItem.h"
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemEdit window
class PROPTREE_API CPropTreeItemEdit : public CEdit, public CPropTreeItem
{
// Construction
public:
CPropTreeItemEdit();
virtual ~CPropTreeItemEdit();
// Attributes
public:
// The attribute area needs drawing
virtual void DrawAttribute(CDC* pDC, const RECT& rc);
// Retrieve the item's attribute value
virtual LPARAM GetItemValue();
// Set the item's attribute value
virtual void SetItemValue(LPARAM lParam);
// Called when attribute area has changed size
virtual void OnMove();
// Called when the item needs to refresh its data
virtual void OnRefresh();
// Called when the item needs to commit its changes
virtual void OnCommit();
// Called to activate the item
virtual void OnActivate(int activateType, CPoint point);
enum ValueFormat
{
ValueFormatText,
ValueFormatNumber,
ValueFormatFloatPointer
};
// Set to specifify format of SetItemValue/GetItemValue
void SetValueFormat(ValueFormat nFormat);
// Set to TRUE for to use a password edit control
void SetAsPassword(BOOL bPassword);
protected:
CString m_sEdit;
float m_fValue;
ValueFormat m_nFormat;
BOOL m_bPassword;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropTreeItemEdit)
//}}AFX_VIRTUAL
// Implementation
public:
// Generated message map functions
protected:
//{{AFX_MSG(CPropTreeItemEdit)
afx_msg UINT OnGetDlgCode();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKillfocus();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROPTREEITEMEDIT_H__642536B1_1162_4F99_B09D_9B1BD2CF88B6__INCLUDED_)

View File

@@ -0,0 +1,259 @@
// PropTreeItemEdit.cpp : implementation file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "proptree.h"
#include "PropTreeItemEditButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define BUTTON_SIZE 17
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemEditButton
CPropTreeItemEditButton::CPropTreeItemEditButton() :
m_sEdit(_T("")),
m_nFormat(ValueFormatText),
m_bPassword(FALSE),
m_fValue(0.0f)
{
mouseDown = false;
}
CPropTreeItemEditButton::~CPropTreeItemEditButton()
{
}
BEGIN_MESSAGE_MAP(CPropTreeItemEditButton, CEdit)
//{{AFX_MSG_MAP(CPropTreeItemEditButton)
ON_WM_GETDLGCODE()
ON_WM_KEYDOWN()
ON_CONTROL_REFLECT(EN_KILLFOCUS, OnKillfocus)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemEditButton message handlers
LONG CPropTreeItemEditButton::DrawItem( CDC* pDC, const RECT& rc, LONG x, LONG y )
{
CSize textSize;
CRect textRect;
LONG nTotal = 0;
nTotal = CPropTreeItemEdit::DrawItem( pDC, rc, x, y );
textSize = pDC->GetOutputTextExtent( buttonText );
buttonRect.left = m_rc.right - ( textSize.cx + 12 + 4);
buttonRect.top = m_rc.top + ((m_rc.bottom - m_rc.top)/2)-BUTTON_SIZE/2;
buttonRect.right = buttonRect.left + textSize.cx + 12;
buttonRect.bottom = buttonRect.top + BUTTON_SIZE;
UINT buttonStyle;
if ( (m_dwState & TreeItemChecked) ) {
buttonStyle = DFCS_BUTTONPUSH | DFCS_PUSHED;
} else {
buttonStyle = DFCS_BUTTONPUSH;
}
pDC->DrawFrameControl(&buttonRect, DFC_BUTTON, buttonStyle );
textRect = buttonRect;
textRect.left += 4;
textRect.right -= 8;
pDC->DrawText( buttonText, textRect, DT_SINGLELINE|DT_VCENTER );
//Adjust hit test rect to acount for window scrolling
hitTestRect = buttonRect;
hitTestRect.OffsetRect(0, m_pProp->GetOrigin().y);
return nTotal;
}
void CPropTreeItemEditButton::DrawAttribute(CDC* pDC, const RECT& rc)
{
ASSERT(m_pProp!=NULL);
pDC->SelectObject(IsReadOnly() ? m_pProp->GetNormalFont() : m_pProp->GetBoldFont());
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkMode(TRANSPARENT);
CRect r = rc;
r.right = buttonRect.left - 5;
TCHAR ch;
// can't use GetPasswordChar(), because window may not be created yet
ch = (m_bPassword) ? '*' : '\0';
if (ch)
{
CString s;
s = m_sEdit;
for (LONG i=0; i<s.GetLength();i++)
s.SetAt(i, ch);
pDC->DrawText(s, r, DT_SINGLELINE|DT_VCENTER);
}
else
{
pDC->DrawText(m_sEdit, r, DT_SINGLELINE|DT_VCENTER);
}
}
void CPropTreeItemEditButton::SetAsPassword(BOOL bPassword)
{
m_bPassword = bPassword;
}
void CPropTreeItemEditButton::SetValueFormat(ValueFormat nFormat)
{
m_nFormat = nFormat;
}
LPARAM CPropTreeItemEditButton::GetItemValue()
{
switch (m_nFormat)
{
case ValueFormatNumber:
return _ttoi(m_sEdit);
case ValueFormatFloatPointer:
_stscanf(m_sEdit, _T("%f"), &m_fValue);
return (LPARAM)&m_fValue;
}
return (LPARAM)(LPCTSTR)m_sEdit;
}
void CPropTreeItemEditButton::SetItemValue(LPARAM lParam)
{
switch (m_nFormat)
{
case ValueFormatNumber:
m_sEdit.Format(_T("%d"), lParam);
return;
case ValueFormatFloatPointer:
{
TCHAR tmp[MAX_PATH];
m_fValue = *(float*)lParam;
_stprintf(tmp, _T("%f"), m_fValue);
m_sEdit = tmp;
}
return;
}
if (lParam==0L)
{
TRACE0("CPropTreeItemEditButton::SetItemValue - Invalid lParam value\n");
return;
}
m_sEdit = (LPCTSTR)lParam;
}
void CPropTreeItemEditButton::OnMove()
{
if (IsWindow(m_hWnd))
SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width(), m_rc.Height(), SWP_NOZORDER|SWP_NOACTIVATE);
}
void CPropTreeItemEditButton::OnRefresh()
{
if (IsWindow(m_hWnd))
SetWindowText(m_sEdit);
}
void CPropTreeItemEditButton::OnCommit()
{
// hide edit control
ShowWindow(SW_HIDE);
// store edit text for GetItemValue
GetWindowText(m_sEdit);
}
void CPropTreeItemEditButton::OnActivate(int activateType, CPoint point)
{
// Check if the edit control needs creation
if (!IsWindow(m_hWnd))
{
DWORD dwStyle;
dwStyle = WS_CHILD|ES_AUTOHSCROLL;
Create(dwStyle, m_rc, m_pProp->GetCtrlParent(), GetCtrlID());
SendMessage(WM_SETFONT, (WPARAM)m_pProp->GetNormalFont()->m_hObject);
}
SetPasswordChar((TCHAR)(m_bPassword ? '*' : 0));
SetWindowText(m_sEdit);
SetSel(0, -1);
SetWindowPos(NULL, m_rc.left, m_rc.top, m_rc.Width() - buttonRect.Width() - 5, m_rc.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
SetFocus();
}
UINT CPropTreeItemEditButton::OnGetDlgCode()
{
return CEdit::OnGetDlgCode()|DLGC_WANTALLKEYS;
}
void CPropTreeItemEditButton::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar==VK_RETURN)
CommitChanges();
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CPropTreeItemEditButton::OnKillfocus()
{
CommitChanges();
}
BOOL CPropTreeItemEditButton::HitButton( const POINT& pt ) {
return hitTestRect.PtInRect( pt );
}
void CPropTreeItemEditButton::SetButtonText( LPCSTR text ) {
buttonText = text;
}

View File

@@ -0,0 +1,125 @@
#ifndef __PROP_TREE_ITEM_EDIT_BUTTON_H__
#define __PROP_TREE_ITEM_EDIT_BUTTON_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PropTreeItemEdit.h : header file
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
#include "PropTreeItem.h"
//#include "PropTreeItemEdit.h"
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemEditButton window
class PROPTREE_API CPropTreeItemEditButton : public CPropTreeItemEdit
{
// Construction
public:
CPropTreeItemEditButton();
virtual ~CPropTreeItemEditButton();
// Attributes
public:
// The non-attribute area needs drawing
virtual LONG DrawItem(CDC* pDC, const RECT& rc, LONG x, LONG y);
// The attribute area needs drawing
virtual void DrawAttribute(CDC* pDC, const RECT& rc);
// Retrieve the item's attribute value
virtual LPARAM GetItemValue();
// Set the item's attribute value
virtual void SetItemValue(LPARAM lParam);
// Called when attribute area has changed size
virtual void OnMove();
// Called when the item needs to refresh its data
virtual void OnRefresh();
// Called when the item needs to commit its changes
virtual void OnCommit();
// Called to activate the item
virtual void OnActivate(int activateType, CPoint point);
enum ValueFormat
{
ValueFormatText,
ValueFormatNumber,
ValueFormatFloatPointer
};
// Set to specifify format of SetItemValue/GetItemValue
void SetValueFormat(ValueFormat nFormat);
// Set to TRUE for to use a password edit control
void SetAsPassword(BOOL bPassword);
// Overrideable - Returns TRUE if the point is on the button
virtual BOOL HitButton(const POINT& pt);
void SetButtonText( LPCSTR text );
protected:
CString m_sEdit;
float m_fValue;
ValueFormat m_nFormat;
BOOL m_bPassword;
CString buttonText;
CRect buttonRect;
CRect hitTestRect;
bool mouseDown;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropTreeItemEditButton)
//}}AFX_VIRTUAL
// Implementation
public:
// Generated message map functions
protected:
//{{AFX_MSG(CPropTreeItemEditButton)
afx_msg UINT OnGetDlgCode();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKillfocus();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // __PROP_TREE_ITEM_EDIT_BUTTON_H__

View File

@@ -0,0 +1,130 @@
// PropTreeItemFileEdit.cpp : implementation file
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "proptree.h"
#include "PropTreeItemFileEdit.h"
#include "../../../sys/win32/rc/proptree_Resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPropTreeItemFileEdit
CPropTreeItemFileEdit::CPropTreeItemFileEdit() {
}
CPropTreeItemFileEdit::~CPropTreeItemFileEdit() {
}
BEGIN_MESSAGE_MAP(CPropTreeItemFileEdit, CPropTreeItemEdit)
//{{AFX_MSG_MAP(CPropTreeItemFileEdit)
//}}AFX_MSG_MAP
ON_WM_CONTEXTMENU()
ON_WM_CREATE()
ON_COMMAND(ID_EDITMENU_INSERTFILE, OnInsertFile)
ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
ON_COMMAND(ID_EDIT_CUT, OnEditCut)
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
ON_COMMAND(ID_EDIT_DELETE, OnEditDelete)
ON_COMMAND(ID_EDIT_SELECTALL, OnEditSelectAll)
END_MESSAGE_MAP()
void CPropTreeItemFileEdit::OnContextMenu(CWnd* pWnd, CPoint point) {
CMenu FloatingMenu;
VERIFY(FloatingMenu.LoadMenu(IDR_ME_EDIT_MENU));
CMenu* pPopupMenu = FloatingMenu.GetSubMenu (0);
if(CanUndo()) {
pPopupMenu->EnableMenuItem(ID_EDIT_UNDO, MF_BYCOMMAND | MF_ENABLED);
} else {
pPopupMenu->EnableMenuItem(ID_EDIT_UNDO, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}
DWORD dwSel = GetSel();
if(HIWORD(dwSel) != LOWORD(dwSel)) {
pPopupMenu->EnableMenuItem(ID_EDIT_CUT, MF_BYCOMMAND | MF_ENABLED);
pPopupMenu->EnableMenuItem(ID_EDIT_COPY, MF_BYCOMMAND | MF_ENABLED);
pPopupMenu->EnableMenuItem(ID_EDIT_DELETE, MF_BYCOMMAND | MF_ENABLED);
} else {
pPopupMenu->EnableMenuItem(ID_EDIT_CUT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
pPopupMenu->EnableMenuItem(ID_EDIT_COPY, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
pPopupMenu->EnableMenuItem(ID_EDIT_DELETE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}
pPopupMenu->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}
int CPropTreeItemFileEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CPropTreeItemEdit::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
return 0;
}
void CPropTreeItemFileEdit::OnInsertFile() {
CFileDialog dlg(TRUE);
dlg.m_ofn.Flags |= OFN_FILEMUSTEXIST;
int startSel, endSel;
GetSel(startSel, endSel);
if( dlg.DoModal()== IDOK) {
idStr currentText = (char*)GetItemValue();
idStr newText = currentText.Left(startSel) + currentText.Right(currentText.Length() - endSel);
idStr filename = fileSystem->OSPathToRelativePath(dlg.m_ofn.lpstrFile);
filename.BackSlashesToSlashes();
newText.Insert(filename, startSel);
SetItemValue((LPARAM)newText.c_str());
m_pProp->RefreshItems(this);
m_pProp->SendNotify(PTN_ITEMCHANGED, this);
}
}
void CPropTreeItemFileEdit::OnEditUndo() {
Undo();
}
void CPropTreeItemFileEdit::OnEditCut() {
Cut();
}
void CPropTreeItemFileEdit::OnEditCopy() {
Copy();
}
void CPropTreeItemFileEdit::OnEditPaste() {
Paste();
}
void CPropTreeItemFileEdit::OnEditDelete() {
Clear();
}
void CPropTreeItemFileEdit::OnEditSelectAll() {
SetSel(0, -1);
}

View File

@@ -0,0 +1,54 @@
#ifndef __PROP_TREE_ITEM_FILE_EDIT_H__
#define __PROP_TREE_ITEM_FILE_EDIT_H__
#if _MSC_VER > 1000
#pragma once
#endif
//#include "PropTreeItem.h"
//#include "PropTreeItemEdit.h"
class PROPTREE_API CPropTreeItemFileEdit : public CPropTreeItemEdit
{
// Construction
public:
CPropTreeItemFileEdit();
virtual ~CPropTreeItemFileEdit();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropTreeItemFileEdit)
//}}AFX_VIRTUAL
// Implementation
public:
// Generated message map functions
protected:
//{{AFX_MSG(CPropTreeItemFileEdit)
//}}AFX_MSG
afx_msg void OnInsertFile();
afx_msg void OnEditUndo();
afx_msg void OnEditCut();
afx_msg void OnEditCopy();
afx_msg void OnEditPaste();
afx_msg void OnEditDelete();
afx_msg void OnEditSelectAll();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
#endif

View File

@@ -0,0 +1,67 @@
// PropTreeItemStatic.cpp
//
// Copyright (C) 1998-2001 Scott Ramsay
// sramsay@gonavi.com
// http://www.gonavi.com
//
// This material is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// Permission to use or copy this software for any purpose is hereby granted
// without fee, provided the above notices are retained on all copies.
// Permission to modify the code and to distribute modified code is granted,
// provided the above notices are retained, and a notice that the code was
// modified is included with the above copyright notice.
//
// If you use this code, drop me an email. I'd like to know if you find the code
// useful.
//#include "stdafx.h"
#include "../../../idlib/precompiled.h"
#pragma hdrstop
#include "PropTree.h"
#include "PropTreeItemStatic.h"
CPropTreeItemStatic::CPropTreeItemStatic() :
m_sAttribute(_T(""))
{
}
CPropTreeItemStatic::~CPropTreeItemStatic()
{
}
void CPropTreeItemStatic::DrawAttribute(CDC* pDC, const RECT& rc)
{
ASSERT(m_pProp!=NULL);
pDC->SelectObject(m_pProp->GetNormalFont());
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkMode(TRANSPARENT);
CRect r = rc;
pDC->DrawText(m_sAttribute, r, DT_SINGLELINE|DT_VCENTER);
}
LPARAM CPropTreeItemStatic::GetItemValue()
{
return (LPARAM)(LPCTSTR)m_sAttribute;
}
void CPropTreeItemStatic::SetItemValue(LPARAM lParam)
{
if (lParam==0L)
{
TRACE0("CPropTreeItemStatic::SetItemValue() - Invalid lParam value\n");
return;
}
m_sAttribute = (LPCTSTR)lParam;
}

Some files were not shown because too many files have changed in this diff Show More