00001
00002
00003
00004 #include "stdafx.h"
00005 #include "aspectspectbl.h"
00006 #include "aspectpage.h"
00007
00008
00009
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015
00017
00018
00019
00020
00021 int CAspectPage::m_actHeight = 0;
00022 int CAspectPage::m_actWidth = 0;
00023
00024 CAspectPage::CAspectPage()
00025 : CPropertyPage(IDD_ASPECT_PAGE)
00026 , m_deflateVal(10)
00027 {
00028
00029
00030
00031 }
00032
00033
00034 CAspectPage::~CAspectPage()
00035 {
00036 POSITION pos = entries.GetHeadPosition();
00037 while (pos) {
00038 delete entries.GetNext(pos);
00039 }
00040 entries.RemoveAll();
00041
00042 m_actWidth = m_actHeight = 0;
00043 }
00044
00045 void CAspectPage::DoDataExchange(CDataExchange* pDX)
00046 {
00047 CPropertyPage::DoDataExchange(pDX);
00048
00049
00050
00051 }
00052
00053
00054 BEGIN_MESSAGE_MAP(CAspectPage, CPropertyPage)
00055 ON_WM_SIZE()
00056
00057
00058 END_MESSAGE_MAP()
00059
00061
00062
00063 CString CAspectPage::GetAspectName() {
00064 return aspectName;
00065 }
00066
00067 void CAspectPage::SetAspectName(CString name) {
00068 aspectName = name;
00069 }
00070
00071 BOOL CAspectPage::OnInitDialog()
00072 {
00073 CPropertyPage::OnInitDialog();
00074
00075
00076
00077 CRect loc;
00078 calcPlace( loc);
00079
00080 aspectTable.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT|LVS_SINGLESEL|LVS_NOSORTHEADER, loc, this, 1);
00081 POSITION pos = entries.GetHeadPosition();
00082 while (pos) {
00083 entry *e = entries.GetNext(pos);
00084 aspectTable.AddRow(e->rowID, e->roleName, e->kindAspect, e->isPrimary);
00085 }
00086
00087 return TRUE;
00088
00089 }
00090
00091 void CAspectPage::AddEntry(int rowID, CString roleName, CString kindAspect, CString isPrimary, const void * ptr)
00092 {
00093 entry* newent = new entry;;
00094
00095 newent->rowID = rowID;
00096
00097 newent->roleName = roleName;
00098 newent->kindAspect = kindAspect;
00099 newent->isPrimary = isPrimary;
00100 newent->ptr = ptr;
00101
00102 entries.AddTail(newent);
00103 }
00104
00105
00106 bool CAspectPage::GetEntry(int rowID, CString &roleName, CString& kindAspect, CString& isPrimary, const void * &ptr)
00107 {
00108 bool retval = false;
00109
00110 POSITION pos = entries.GetHeadPosition();
00111 while (pos) {
00112 entry *e = entries.GetNext(pos);
00113 if (e->rowID == rowID) {
00114 roleName = e->roleName;
00115 kindAspect = e->kindAspect;
00116 isPrimary = e->isPrimary;
00117 ptr = e->ptr;
00118 retval = true;
00119 }
00120 }
00121 return retval;
00122 }
00123
00124 void CAspectPage::OnOK()
00125 {
00126
00127 POSITION pos = entries.GetHeadPosition();
00128 while (pos) {
00129 entry *e = entries.GetNext(pos);
00130 aspectTable.GetRow(e->rowID, e->roleName, e->kindAspect, e->isPrimary);
00131 }
00132
00133 CPropertyPage::OnOK();
00134 }
00135
00136 void CAspectPage::OnSize(UINT ntype, int cx, int cy)
00137 {
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 CPropertyPage::OnSize(ntype, cx, cy);
00148
00149 m_actHeight = cy;
00150 m_actWidth = cx;
00151 }
00152
00153 void CAspectPage::calcPlace( CRect &loc)
00154 {
00155
00156 loc.left = loc.top = 0;
00157 loc.bottom = m_actHeight;
00158 loc.right = m_actWidth;
00159
00160 loc.DeflateRect( m_deflateVal, m_deflateVal);
00161 }
00162
00163 void CAspectPage::resizeTableToFitIn()
00164 {
00165 CRect loc;
00166 calcPlace( loc);
00167 aspectTable.SetWindowPos( 0, loc.left, loc.top,
00168 loc.right - loc.left, loc.bottom - loc.top,
00169 SWP_SHOWWINDOW|SWP_NOZORDER|SWP_NOMOVE);
00170 }
00171