00001
00002
00004
00005
#include "pch.h"
00006
00007
#include "Edge.h"
00008
#include "debug.h"
00009
#include "persctl.h"
00010
00012
00014
00015 CEdge::CEdge()
00016 : m_Guide( new
CGuide() ), m_Attatched(
NULL)
00017 {
00018
SetGuide(
m_Guide);
00019 }
00020
00021 CEdge::~CEdge()
00022 {
00023
00024 }
00025
00026 CEdge::CEdge(
int Position,
int Axis,
BOOL Flexible,
int Offset)
00027 : m_Guide( new
CGuide(Position, Axis, Flexible) ), m_Attatched(
NULL)
00028 {
00029 SetOffsetFromGuide(
Offset);
00030
SetGuide(
m_Guide);
00031 }
00032
00033 CEdge::CEdge(
CGuide * pGuide,
int Offset)
00034 : m_Guide(pGuide), m_Attatched(
NULL)
00035 {
00036 SetOffsetFromGuide(
Offset);
00037
SetGuide(
m_Guide);
00038 }
00039
00040
00041
00042
00043
00044 void CEdge::SetGuide(
CGuide * pGuide)
00045 {
00046
00047
00048
00049
00050
if( pGuide !=
m_Guide )
00051 {
00052
TRACE(
L"Changing the guide - need to re-attatch?\n");
00053
m_Guide->
DeAttatch(
this);
00054 }
00055
00056
m_Guide=pGuide;
00057 pGuide->
Attatch(
this );
00058 }
00059
00060 void CEdge::Attatch(
CResizeControl * pC)
00061 {
00062
if(
m_Attatched==
NULL)
00063
m_Attatched=
new CControlList();
00064
m_Attatched->
Append(pC);
00065 }
00066
00067 int CEdge::Attatchment()
00068 {
00069
CResizeControl * pControl;
00070
int iRet=0;
00071
int iNumControls=
GetControlCount();
00072
while( --iNumControls >= 0)
00073 {
00074 pControl =
GetControl(iNumControls);
00075 iRet |= pControl->
Attatchment(
GetGuide() );
00076 }
00077
return iRet;
00078 }
00079
00081
00082
00083
00085 CEdgeCache::CEdgeCache()
00086 {
00087
m_NumVert=0;
00088
m_NumHoriz=0;
00089 }
00090
00091 CEdgeCache::~CEdgeCache()
00092 {
00093
00094 }
00095
00096 CEdge *
CEdgeCache::Create(
int Position,
int Axis,
int Flexible,
int Offset)
00097 {
00098
CEdge * pEdge=
new CEdge(Position, Axis, Flexible,
Offset);
00099
AddEdge(pEdge);
00100
return pEdge;
00101 }
00102
00103 CEdge *
CEdgeCache::Create(
CGuide * pGuide,
int Offset )
00104 {
00105
CEdge * pEdge=
new CEdge(pGuide,
Offset);
00106
AddEdge(pEdge);
00107
return pEdge;
00108 }
00109
00110 BOOL CEdgeCache::AddEdge(
CEdge *pEdge)
00111 {
00112
if( pEdge->
IsHorizontal() )
00113 SetNumHoriz( GetNumHoriz() + 1 );
00114
else
00115 SetNumVert( GetNumVert() + 1 );
00116
return Append( pEdge );
00117 }
00118
00120
00121
00122
00125
00127
00128 CGuide::CGuide()
00129 : m_Axis(0), m_Position(0), m_Flexible(
FALSE)
00130 {
00131
m_Attatched=
NULL;
00132 }
00133
00134 CGuide::~CGuide()
00135 {
00136
if(
m_Attatched)
00137
delete m_Attatched;
00138 }
00139
00140 CGuide::CGuide(
int Position,
int Axis, BOOL Flexible)
00141 {
00142
m_Attatched=
NULL;
00143 SetPosition(Position);
00144 SetAxis(Axis);
00145 SetFlexible(Flexible);
00146 }
00147
00148
00149
00150
00151 void CGuide::Attatch(
CEdge * pEdge)
00152 {
00153
if(
m_Attatched==
NULL)
00154
m_Attatched=
new CEdgeList();
00155
m_Attatched->
Append(pEdge);
00156 }
00157
00158 BOOL CGuide::IsEqual(
CGuide *pGuide)
00159 {
00160
return pGuide ==
this;
00161 }
00162
00163 void CGuide::Adjust(
int adjust)
00164 {
00165 SetPosition( GetPosition() + adjust );
00166 }
00167
00168 int CGuide::NumAttatchments()
00169 {
00170
if(
m_Attatched==
NULL)
00171
return 0;
00172
00173
int iRet=0;
00174
int iCount=0;
00175
int iNumEdges=
m_Attatched->
GetEdgeCount();
00176
while( --iNumEdges>=0 )
00177 {
00178
CEdge * pEdge=
GetEdge(iNumEdges);
00179 iRet += pEdge->
GetControlCount();
00180 }
00181
return iRet;
00182 }
00183
00184
00185
00186
00187 int CGuide::Attatchment()
00188 {
00189
if(
m_Attatched==
NULL)
00190
return 0;
00191
00192
int iRet=0;
00193
int iCount=0;
00194
int iNumEdges=
m_Attatched->
GetEdgeCount();
00195
while( --iNumEdges>=0 )
00196 {
00197
CEdge * pEdge=
GetEdge(iNumEdges);
00198 iRet |= pEdge->
Attatchment();
00199 }
00200
return iRet;
00201 }
00202
00203 CEdge *
CGuide::GetEdge(
int i)
00204 {
00205
if(
m_Attatched==
NULL)
00206
return NULL;
00207
return m_Attatched->
GetEdge(i);
00208 }
00209
00210 void CGuide::DeAttatch(
CEdge * pEdge )
00211 {
00212
00213
00214
00215
int iCount=
m_Attatched->
GetEdgeCount();
00216
while (--iCount>=0)
00217 {
00218
CEdge * p=
GetEdge(iCount);
00219
if(p==pEdge)
00220
m_Attatched->
Remove(iCount);
00221 }
00222 }
00223
00225
00226
00227
00229
00230
00232
00233
00235
00237
00238 CConstraint::CConstraint()
00239 {
00240
00241 }
00242
00243 CConstraint::~CConstraint()
00244 {
00245
00246 }
00247
00249
00250
00251
00253
00254
00256
00258
00260
00261 CControlList::CControlList()
00262 {
00263
00264 }
00265
00266 CControlList::~CControlList()
00267 {
00268
00269 }