GME
13
|
00001 // ClosureDlg.cpp : implementation file 00002 // 00003 00004 #include "stdafx.h" 00005 #include "gme.h" 00006 #include "ClosureDlg.h" 00007 #include "ClosureKindSel.h" 00008 #include <afxcmn.h> 00009 00010 #ifdef _DEBUG 00011 #define new DEBUG_NEW 00012 #undef THIS_FILE 00013 static char THIS_FILE[] = __FILE__; 00014 #endif 00015 00017 // CClosureDlg dialog 00018 00019 00020 CClosureDlg::CClosureDlg(CWnd* pParent /*=NULL*/) 00021 //: CPropertyPage(CClosureDlg::IDD) 00022 : CDialog(CClosureDlg::IDD, pParent) 00023 , m_activeFolderContainment( true) 00024 { 00025 //{{AFX_DATA_INIT(CClosureDlg) 00026 m_bConnection = FALSE; 00027 m_bContainment = FALSE; 00028 m_bFolderContainment = FALSE; 00029 m_bRefersTo = FALSE; 00030 m_bSetMember = FALSE; 00031 m_bMemberOfSets = FALSE; 00032 m_bReferredBy = FALSE; 00033 m_bBaseTypes = FALSE; 00034 m_bDerivedTypes = FALSE; 00035 m_bPartOfModels = FALSE; 00036 m_bPartOfFolders = FALSE; 00037 m_strOutputFile = _T(""); 00038 m_outputOption = -1; 00039 m_direction = -1; 00040 m_wrappingOption = -1; 00041 m_libraryHandling = -1; 00042 m_includeAllKindsRadio = -1; 00043 m_bRefPortConnection = FALSE; 00044 m_bMarkObjs = FALSE; 00045 //}}AFX_DATA_INIT 00046 m_iMarkVal = -1; 00047 } 00048 00049 00050 void CClosureDlg::DoDataExchange(CDataExchange* pDX) 00051 { 00052 CDialog::DoDataExchange(pDX); 00053 //{{AFX_DATA_MAP(CClosureDlg) 00054 DDX_Control(pDX, IDC_FILTER, m_ctrlFilter); 00055 DDX_Control(pDX, IDC_CHECKREFPORTCONNECTION, m_ctrlRefPortConnection); 00056 DDX_Control(pDX, IDC_INCLUDEALL, m_ctrlIncludeAll); 00057 DDX_Control(pDX, IDC_INCLUDESOME, m_ctrlIncludeSome); 00058 DDX_Control(pDX, IDC_WRAPMINIPROJ, m_ctrlRadio1); 00059 DDX_Control(pDX, IDC_WRAPAUTO, m_ctrlRadio2); 00060 DDX_Control(pDX, IDC_WRAPASIS, m_ctrlRadio3); 00061 DDX_Control(pDX, IDC_LIBR1, m_ctrlLibRadio1); 00062 DDX_Control(pDX, IDC_LIBR2, m_ctrlLibRadio2); 00063 DDX_Control(pDX, IDC_LIBR3, m_ctrlLibRadio3); 00064 DDX_Control(pDX, IDC_CHECKPARTOFMODEL, m_ctrlPartOfModels); 00065 DDX_Control(pDX, IDC_CHECKPARTOFFOLDERS, m_ctrlPartOfFolders); 00066 DDX_Control(pDX, IDC_CHECKCONTAINMENT, m_ctrlContainment); 00067 DDX_Control(pDX, IDOK, m_ctrlOk); 00068 DDX_Control(pDX, IDC_BROWSE, m_ctrlBrowse); 00069 DDX_Control(pDX, IDC_EDIT1, m_ctrlOutputFile); 00070 DDX_Control(pDX, IDC_CHECKFOLDERCONTAINMENT, m_ctrlFolderContainment); 00071 DDX_Check(pDX, IDC_CHECKCONNECTION, m_bConnection); 00072 DDX_Check(pDX, IDC_CHECKCONTAINMENT, m_bContainment); 00073 DDX_Check(pDX, IDC_CHECKFOLDERCONTAINMENT, m_bFolderContainment); 00074 DDX_Check(pDX, IDC_CHECKREFERSTO, m_bRefersTo); 00075 DDX_Check(pDX, IDC_CHECKSETMEMBER, m_bSetMember); 00076 DDX_Check(pDX, IDC_CHECKMEMBEROF, m_bMemberOfSets); 00077 DDX_Check(pDX, IDC_CHECKREFERREDBY, m_bReferredBy); 00078 DDX_Check(pDX, IDC_CHECKBASETYPES, m_bBaseTypes); 00079 DDX_Check(pDX, IDC_CHECKSUBTYPES, m_bDerivedTypes); 00080 DDX_Check(pDX, IDC_CHECKPARTOFMODEL, m_bPartOfModels); 00081 DDX_Check(pDX, IDC_CHECKPARTOFFOLDERS, m_bPartOfFolders); 00082 DDX_Text(pDX, IDC_EDIT1, m_strOutputFile); 00083 DDX_Radio(pDX, IDC_OUTPUTTOCLIPBOARD, m_outputOption); 00084 DDX_Radio(pDX, IDC_DIRECTIONUP, m_direction); 00085 DDX_Radio(pDX, IDC_WRAPMINIPROJ, m_wrappingOption); 00086 DDX_Radio(pDX, IDC_LIBR1, m_libraryHandling); 00087 DDX_Radio(pDX, IDC_INCLUDEALL, m_includeAllKindsRadio); 00088 DDX_Check(pDX, IDC_CHECKREFPORTCONNECTION, m_bRefPortConnection); 00089 DDX_Check(pDX, IDC_CHECKMARK, m_bMarkObjs); 00090 DDX_Control(pDX, IDC_EDITMARK, m_ctrlMarkVal); 00091 //}}AFX_DATA_MAP 00092 } 00093 00094 00095 BEGIN_MESSAGE_MAP(CClosureDlg, CDialog) 00096 //{{AFX_MSG_MAP(CClosureDlg) 00097 ON_BN_CLICKED(IDC_BROWSE, OnBrowse) 00098 ON_BN_CLICKED(IDC_OUTPUTTOCLIPBOARD, OnOutputtoclipboard) 00099 ON_BN_CLICKED(IDC_OUTPUTTOFILE, OnOutputtofile) 00100 ON_BN_CLICKED(IDC_DIRECTIONUP, OnDirectionup) 00101 ON_BN_CLICKED(IDC_DIRECTIONDN, OnDirectiondn) 00102 ON_BN_CLICKED(IDC_CHECKCONNECTION, OnCheckconnection) 00103 ON_BN_CLICKED(IDC_CHECKFOLDERCONTAINMENT, OnCheckfoldercontainment) 00104 ON_BN_CLICKED(IDC_CHECKCONTAINMENT, OnCheckcontainment) 00105 ON_BN_CLICKED(IDC_FILTER, OnFilter) 00106 ON_BN_CLICKED(IDC_INCLUDESOME, OnIncludeSome) 00107 ON_BN_CLICKED(IDC_INCLUDEALL, OnIncludeAll) 00108 ON_BN_CLICKED(IDC_WRAPMINIPROJ, OnWrapMiniProj) 00109 ON_BN_CLICKED(IDC_WRAPAUTO, OnWrapAuto) 00110 ON_BN_CLICKED(IDC_WRAPASIS, OnWrapAsIs) 00111 ON_BN_CLICKED(IDC_CHECKMARK, OnMarkClicked) 00112 //}}AFX_MSG_MAP 00113 END_MESSAGE_MAP() 00114 00116 // CClosureDlg message handlers 00117 00118 BOOL CClosureDlg::OnInitDialog() 00119 { 00120 CDialog::OnInitDialog(); 00121 00122 m_wrappingOption = 1; // automatic 00123 m_outputOption = 0; // clipboard 00124 m_direction = 1; // downward 00125 m_libraryHandling = 0; // stubs 00126 m_includeAllKindsRadio = 0; // all kind preferred over the "some kinds" only 00127 m_includeFolders = 1; // def values for the kind selector dialog 00128 m_includeModels = 1; 00129 m_includeAtoms = 1; 00130 m_includeSets = 0; 00131 m_includeReferences = 0; 00132 00133 00134 // initially use the value of the activeFolderCntm since the direction is down 00135 m_ctrlFolderContainment.EnableWindow( m_activeFolderContainment); 00136 00137 // direction is down 00138 m_ctrlPartOfFolders.EnableWindow( FALSE); 00139 m_ctrlPartOfModels.EnableWindow( FALSE); 00140 00141 m_strOutputFile = _T("Closure.xme"); 00142 00143 m_ctrlOutputFile.EnableWindow( m_outputOption); 00144 m_ctrlBrowse.EnableWindow( m_outputOption); 00145 00146 m_ctrlIncludeAll.EnableWindow(m_bContainment || m_bFolderContainment); 00147 m_ctrlIncludeSome.EnableWindow(m_bContainment || m_bFolderContainment); 00148 m_ctrlFilter.EnableWindow( m_includeAllKindsRadio == 0?FALSE:TRUE); 00149 00150 m_ctrlRefPortConnection.EnableWindow( m_bConnection); 00151 00152 m_ctrlMarkVal.EnableWindow( m_bMarkObjs); 00153 if( m_iMarkVal != -1) 00154 { 00155 TCHAR buf[12]; 00156 _stprintf_s( buf, _T("%i"), m_iMarkVal); 00157 m_ctrlMarkVal.SetWindowText( buf); 00158 } 00159 00160 //m_bConnection = TRUE; 00161 //m_bContainment = TRUE; 00162 //m_bFolderContainment = m_activeFolderContainment; 00163 00164 //m_bRefersTo = TRUE; 00165 //m_bReferredBy = TRUE; 00166 00167 //m_bSetMember = TRUE; 00168 //m_bMemberOfSets = TRUE; 00169 00170 //m_bPartOfModels = FALSE; 00171 //m_bPartOfFolders = FALSE; 00172 00173 //m_bDigIntoLibraries = TRUE; 00174 00175 //m_bBaseTypes = TRUE; 00176 //m_bDerivedTypes = TRUE; 00177 00178 UpdateData( FALSE); 00179 00180 return TRUE; 00181 } 00182 00183 void CClosureDlg::OnOK() 00184 { 00185 TCHAR buf[12]; 00186 m_ctrlMarkVal.GetWindowText( buf, 11); 00187 00188 if( 1 != _stscanf( buf, _T("%i"), &m_iMarkVal)) 00189 m_iMarkVal = -1; 00190 00191 CDialog::OnOK(); 00192 } 00193 00194 00195 void CClosureDlg::OnBrowse() 00196 { 00197 UpdateData( TRUE); 00198 CWaitCursor wait; 00199 CFileDialog dlg(FALSE, _T("xme"), _T("Closure.xme"), 00200 OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 00201 _T("GME Exported Files (*.xme;*.xml)|*.xme; *.xml|All Files (*.*)|*.*||")); 00202 if( dlg.DoModal() == IDOK) 00203 { 00204 m_strOutputFile = dlg.GetPathName(); 00205 this->UpdateData( FALSE); 00206 } 00207 } 00208 00209 void CClosureDlg::OnOutputtoclipboard() 00210 { 00211 UpdateData( TRUE); 00212 00213 m_ctrlOutputFile.EnableWindow( m_outputOption); 00214 m_ctrlBrowse.EnableWindow( m_outputOption); 00215 } 00216 00217 void CClosureDlg::OnOutputtofile() 00218 { 00219 OnOutputtoclipboard(); 00220 } 00221 00222 void CClosureDlg::OnDirectionup() 00223 { 00224 UpdateData( TRUE); 00225 // if the closure direction is up: the folder containment should be allowed 00226 m_ctrlFolderContainment.EnableWindow( FALSE); 00227 m_ctrlContainment.EnableWindow( FALSE); 00228 m_ctrlPartOfFolders.EnableWindow( TRUE); 00229 m_ctrlPartOfModels.EnableWindow( TRUE); 00230 00231 m_ctrlIncludeAll.EnableWindow( FALSE); 00232 m_ctrlIncludeSome.EnableWindow( FALSE); 00233 m_ctrlFilter.EnableWindow( FALSE); 00234 00235 UpdateData( FALSE); 00236 } 00237 00238 00239 void CClosureDlg::OnDirectiondn() 00240 { 00241 UpdateData( TRUE); 00242 // if the closure direction is down: the folder containment should be set 00243 // according to the variable which indicates if there is any folder involved 00244 m_ctrlFolderContainment.EnableWindow( m_activeFolderContainment); 00245 m_ctrlContainment.EnableWindow( TRUE); 00246 m_ctrlPartOfFolders.EnableWindow( FALSE); 00247 m_ctrlPartOfModels.EnableWindow( FALSE); 00248 00249 m_ctrlIncludeAll.EnableWindow(m_bContainment || m_bFolderContainment); 00250 m_ctrlIncludeSome.EnableWindow(m_bContainment || m_bFolderContainment); 00251 m_ctrlFilter.EnableWindow( m_includeAllKindsRadio == 0?FALSE:TRUE); 00252 } 00253 00254 void CClosureDlg::OnCheckconnection() 00255 { 00256 UpdateData( TRUE); 00257 00258 m_bRefPortConnection = m_bConnection?m_bRefPortConnection:FALSE; 00259 00260 m_ctrlRefPortConnection.EnableWindow( m_bConnection); 00261 00262 UpdateData( FALSE); 00263 } 00264 00265 void CClosureDlg::OnCheckfoldercontainment() 00266 { 00267 OnCheckcontainment(); 00268 } 00269 00270 void CClosureDlg::OnCheckcontainment() 00271 { 00272 UpdateData( TRUE); 00273 00274 m_ctrlIncludeAll.EnableWindow(m_bContainment || m_bFolderContainment); 00275 m_ctrlIncludeSome.EnableWindow(m_bContainment || m_bFolderContainment); 00276 m_ctrlFilter.EnableWindow( m_includeAllKindsRadio == 0?FALSE:TRUE); 00277 } 00278 00279 void CClosureDlg::OnFilter() 00280 { 00281 CClosureKindSel sel( 00282 m_includeFolders 00283 , m_includeModels 00284 , m_includeAtoms 00285 , m_includeSets 00286 , m_includeReferences 00287 , 0); 00288 00289 if( sel.DoModal() == IDOK) 00290 { 00291 m_includeFolders = sel.m_folder == TRUE; 00292 m_includeModels = sel.m_model == TRUE; 00293 m_includeAtoms = sel.m_atom == TRUE; 00294 m_includeSets = sel.m_set == TRUE; 00295 m_includeReferences = sel.m_ref == TRUE; 00296 } 00297 } 00298 00299 void CClosureDlg::OnIncludeAll() 00300 { 00301 m_ctrlFilter.EnableWindow( FALSE); 00302 } 00303 00304 void CClosureDlg::OnIncludeSome() 00305 { 00306 m_ctrlFilter.EnableWindow( TRUE); 00307 } 00308 00309 00310 void CClosureDlg::OnWrapMiniProj() 00311 { 00312 UpdateData( TRUE); 00313 m_ctrlLibRadio1.EnableWindow( m_wrappingOption != 0); 00314 m_ctrlLibRadio2.EnableWindow( m_wrappingOption != 0); 00315 m_ctrlLibRadio3.EnableWindow( TRUE); 00316 if( m_wrappingOption == 0) m_libraryHandling = 2; 00317 UpdateData( FALSE); 00318 } 00319 00320 void CClosureDlg::OnWrapAuto() 00321 { 00322 OnWrapMiniProj(); 00323 } 00324 00325 void CClosureDlg::OnWrapAsIs() 00326 { 00327 OnWrapMiniProj(); 00328 } 00329 00330 long CClosureDlg::calcKindMask() 00331 { 00332 long kind_map = 0;//important to set it to 0 00333 if( m_includeAllKindsRadio == 0) 00334 kind_map = -1;//0xffffffff; 00335 else 00336 kind_map = kind_map 00337 | (m_includeFolders?0x1:0) 00338 | (m_includeModels?0x2:0) 00339 | (m_includeAtoms?0x4:0) 00340 | (m_includeSets?0x8:0) 00341 | (m_includeReferences?0x10:0); 00342 00343 return kind_map; 00344 } 00345 00346 void CClosureDlg::OnMarkClicked() 00347 { 00348 UpdateData( TRUE); 00349 m_ctrlMarkVal.EnableWindow( m_bMarkObjs); 00350 UpdateData( FALSE); 00351 00352 }