// FacetPage.cpp : implementation file // #include "stdafx.h" #include "KBEditors.h" #include "KBEditorsDoc.h" #include "FacetPage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CFacetPage property page IMPLEMENT_DYNCREATE(CFacetPage, CPropertyPage) CFacetPage::CFacetPage() : CPropertyPage(CFacetPage::IDD) { //{{AFX_DATA_INIT(CFacetPage) m_PromptL = _T(""); m_PromptA = _T(""); m_Type = _T(""); m_LatinLegal = _T(""); m_ArabicLegal = _T(""); m_Default = _T(""); m_LL = 0.0f; m_UL = 0.0f; m_ControlID = 0; //}}AFX_DATA_INIT } CFacetPage::~CFacetPage() { } void CFacetPage::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFacetPage) DDX_Control(pDX, IDC_CPTCOMBO2, m_CptList1); DDX_Control(pDX, IDC_SEARCHORDER, m_SearchOrder); DDX_Control(pDX, IDC_VALUESORCES, m_Sources); DDX_Control(pDX, IDC_PROPCOMBO, m_PropList); DDX_Control(pDX, IDC_CPTCOMBO, m_CptList); DDX_Control(pDX, IDC_LEGALVLIST, m_LegalList); DDX_Text(pDX, IDC_PROMPTL, m_PromptL); DDX_Text(pDX, IDC_PROMPTA, m_PromptA); DDX_CBString(pDX, IDC_TYPE, m_Type); DDX_Text(pDX, IDC_LEGALL, m_LatinLegal); DDX_Text(pDX, IDC_LEGALA, m_ArabicLegal); DDX_Text(pDX, IDC_DEFAULT, m_Default); DDX_Text(pDX, IDC_LL, m_LL); DDX_Text(pDX, IDC_UL, m_UL); DDX_Text(pDX, IDC_PROMPTA2, m_ControlID); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CFacetPage, CPropertyPage) //{{AFX_MSG_MAP(CFacetPage) ON_BN_CLICKED(IDC_SAVEFACETS, OnSavefacets) ON_BN_CLICKED(IDC_ADDLEGAL, OnAddlegal) ON_LBN_SELCHANGE(IDC_LEGALVLIST, OnSelchangeLegalvlist) ON_BN_CLICKED(IDC_DELLEGAL, OnDellegal) ON_CBN_SELCHANGE(IDC_CPTCOMBO, OnSelchangeCpt) ON_CBN_SELCHANGE(IDC_PROPCOMBO, OnSelchangePropcombo) ON_BN_CLICKED(IDC_ADDORDER, OnAddorder) ON_BN_CLICKED(IDC_DELORDER, OnDelorder) ON_BN_CLICKED(IDC_RADIOYES, OnRadioyes) ON_BN_CLICKED(IDC_RADIONO, OnRadiono) ON_CBN_SELCHANGE(IDC_TYPE, OnSelchangeType) ON_EN_CHANGE(IDC_LL, OnChangeLL) ON_EN_CHANGE(IDC_UL, OnChangeUL) ON_CBN_SELCHANGE(IDC_CPTCOMBO2, OnSelchangeCptcombo2) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFacetPage message handlers void CFacetPage::SeeDoc(CKBEditorsDoc*Doc) { m_Doc = Doc; } BOOL CFacetPage::OnInitDialog() { CPropertyPage::OnInitDialog(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CFacetPage::OnSavefacets() { UpdateData(); GetCurrentCpt(); GetCurrentProp(); GProp->LL = m_LL; GProp->UL = m_UL; GProp->PromptA = m_PromptA; GProp->ControlID = m_ControlID; GProp->PromptL = m_PromptL; GProp->Default = m_Default; // GProp->SourceOfValue = m_SourceOfValue; GProp->Type = m_Type; m_Doc->OnSaveDocument(m_Doc->AppName); } BOOL CFacetPage::OnSetActive() { GCpt = new CConcept; GProp = new CProperty; m_LegalList.ResetContent(); m_PropList.ResetContent(); m_CptList.ResetContent(); m_Sources.ResetContent(); m_SearchOrder.ResetContent(); m_Sources.AddString("Relation"); m_Sources.AddString("Database"); m_Sources.AddString("User"); m_Sources.AddString("Table"); m_Sources.AddString("Default"); // m_Doc->CurrentCpt = str; CString str ; POSITION pos = m_Doc->m_CptList.GetStartPosition(); while (pos !=NULL) { m_Doc->m_CptList.GetNextAssoc(pos,str,m_Doc->Cpt); if (m_Doc->Cpt->m_PropList.GetCount() > 0) { m_CptList.AddString(m_Doc->Cpt->NameL); m_CptList1.AddString(m_Doc->Cpt->NameL); } } // m_CptList.SelectString(-1,m_Doc->CurrentCpt); m_Doc->m_CptList.Lookup(m_Doc->CurrentCpt,m_Doc->Cpt); POSITION pos1 = m_Doc->Cpt->m_PropList.GetStartPosition(); while (pos1 !=NULL) { CString str1; m_Doc->Cpt->m_PropList.GetNextAssoc(pos1,str1,m_Doc->Prop); m_PropList.AddString(str1); } m_PropList.SelectString(-1,m_Doc->CurrentProp); m_Doc->Cpt->m_PropList.Lookup(m_Doc->CurrentProp,m_Doc->Prop); if(m_Doc->Prop->LL < 0) m_Doc->Prop->LL = 0; if(m_Doc->Prop->UL < 0) m_Doc->Prop->UL = 0; m_LL = m_Doc->Prop->LL; m_UL = m_Doc->Prop->UL; m_PromptA = m_Doc->Prop->PromptA; m_PromptL = m_Doc->Prop->PromptL; m_ControlID = m_Doc->Prop->ControlID; // m_SourceOfValue = Prop->SourceOfValue; m_Type = m_Doc->Prop->Type; POSITION pos11 = m_Doc->Prop->m_LegalValueList.GetStartPosition(); while (pos11 !=NULL) { CString str11; m_Doc->Prop->m_LegalValueList.GetNextAssoc(pos11,str,str11); m_LegalList.AddString(str); } CButton * CBYES = (CButton*) GetDlgItem(IDC_RADIOYES); CButton * CBNO = (CButton*) GetDlgItem(IDC_RADIONO); if(m_Doc->Prop->Necessary == TRUE) { CBYES->SetCheck(TRUE); CBNO->SetCheck(FALSE); } else { CBNO->SetCheck(TRUE); CBYES->SetCheck(FALSE); } UpdateData(FALSE); GetCurrentCpt(); GetCurrentProp(); POSITION pos0 = GProp->m_SearchOrderList.GetHeadPosition(); while(pos0) { CString ss =GProp->m_SearchOrderList.GetAt(pos0); m_SearchOrder.AddString(ss); GProp->m_SearchOrderList.GetNext(pos0); } return CPropertyPage::OnSetActive(); } void CFacetPage::OnAddlegal() { GetCurrentCpt(); GetCurrentProp(); CString LegalL, LegalA; GetDlgItemText(IDC_LEGALL,LegalL ); GetDlgItemText(IDC_LEGALA, LegalA); if( LegalL.IsEmpty()) return; CString str; if(GProp->m_LegalValueList.Lookup(LegalL,str)) return; GProp->m_LegalValueList.SetAt(LegalL,LegalA); m_LegalList.AddString(LegalL); LegalL.Empty(); LegalA.Empty(); SetDlgItemText(IDC_LEGALL, LegalL); SetDlgItemText(IDC_LEGALA, LegalA); } void CFacetPage::OnSelchangeLegalvlist() { GetCurrentCpt(); GetCurrentProp(); int x = m_LegalList.GetCurSel(); if (x < 0 ) return; CString str; CString str1; m_LegalList.GetText(x,str); GProp->m_LegalValueList.Lookup(str,str1); m_LatinLegal = str; m_ArabicLegal = str1; UpdateData(FALSE); } void CFacetPage::OnDellegal() { GetCurrentCpt(); GetCurrentProp(); GProp->m_LegalValueList.RemoveKey(m_LatinLegal); int x = m_LegalList.GetCurSel(); if (x < 0 ) return; m_LegalList.DeleteString(x); m_LatinLegal.Empty(); m_ArabicLegal.Empty(); UpdateData(FALSE); } void CFacetPage::GetCurrentCpt() { int Sel = m_CptList.GetCurSel(); if (Sel < 0 ) return; CString str; m_CptList.GetLBText(Sel,str); m_Doc->m_CptList.Lookup(str,GCpt); } void CFacetPage::GetCurrentProp() { GetCurrentCpt(); int Sel = m_PropList.GetCurSel(); if (Sel < 0 ) return; CString str; m_PropList.GetLBText(Sel,str); GCpt->m_PropList.Lookup(str,GProp); } void CFacetPage::OnSelchangeCpt() { GetCurrentCpt(); m_PropList.ResetContent(); POSITION pos1 = GCpt->m_PropList.GetStartPosition(); while (pos1 !=NULL) { CString str1; GCpt->m_PropList.GetNextAssoc(pos1,str1,m_Doc->Prop); m_PropList.AddString(str1); } m_PropList.SetCurSel(0); m_LegalList.ResetContent(); // m_LL.Empty(); // m_UL.Empty(); m_PromptA.Empty(); m_PromptL.Empty(); UpdateData(FALSE); OnSelchangePropcombo() ; } void CFacetPage::OnSelchangePropcombo() { GetCurrentCpt(); GetCurrentProp(); m_SearchOrder.ResetContent(); POSITION PosS = GProp->m_SearchOrderList.GetHeadPosition(); while(PosS) { CString ss = GProp->m_SearchOrderList.GetAt(PosS); m_SearchOrder.AddString(ss); GProp->m_SearchOrderList.GetNext(PosS); } m_Type.Empty(); // m_LL.Format("%f", GProp->LL); // m_UL.Format("%f", GProp->UL); m_LL = GProp->LL; m_UL = GProp->UL; m_PromptA = GProp->PromptA; m_PromptL = GProp->PromptL; m_ControlID = GProp->ControlID; m_Type = GProp->Type; m_Default= GProp->Default; m_LegalList.ResetContent(); POSITION pos11 = GProp->m_LegalValueList.GetStartPosition(); while (pos11 !=NULL) { CString str11; CString str; GProp->m_LegalValueList.GetNextAssoc(pos11,str,str11); m_LegalList.AddString(str); } CButton * CBYES = (CButton*) GetDlgItem(IDC_RADIOYES); CButton * CBNO = (CButton*) GetDlgItem(IDC_RADIONO); if(GProp->Necessary == TRUE) { CBYES->SetCheck(TRUE); CBNO->SetCheck(FALSE); } else { CBNO->SetCheck(TRUE); CBYES->SetCheck(FALSE); } m_LatinLegal.Empty(); m_ArabicLegal.Empty(); UpdateData(FALSE); } void CFacetPage::OnAddorder() { int Sel = m_Sources.GetCurSel(); if (Sel < 0 ) return; CString str; m_Sources.GetText(Sel,str); if (m_SearchOrder.FindString( -1, str )>=0) return; m_SearchOrder.AddString(str); GetCurrentCpt(); GetCurrentProp(); GProp->m_SearchOrderList.AddTail(str); } void CFacetPage::OnDelorder() { int Sel = m_SearchOrder.GetCurSel(); if (Sel < 0 ) return; GetCurrentCpt(); GetCurrentProp(); CString str; m_SearchOrder.GetText(Sel,str); POSITION pos = GProp->m_SearchOrderList.GetHeadPosition(); while(pos) { CString ss =GProp->m_SearchOrderList.GetAt(pos); if(ss == str){ GProp->m_SearchOrderList.RemoveAt(pos); m_SearchOrder.DeleteString(Sel); return; } GProp->m_SearchOrderList.GetNext(pos); } } void CFacetPage::OnRadioyes() { GetCurrentCpt(); GetCurrentProp(); GProp->Necessary = TRUE; } void CFacetPage::OnRadiono() { GetCurrentCpt(); GetCurrentProp(); GProp->Necessary = FALSE; } void CFacetPage::OnSelchangeType() { CString ssType; GetDlgItemText(IDC_TYPE, ssType); if(ssType.IsEmpty()) return; if(ssType != "real" && ssType != "integer"){ GetDlgItem(IDC_LL)->EnableWindow(FALSE); GetDlgItem(IDC_UL)->EnableWindow(FALSE); GetDlgItem(IDC_STATICLL)->EnableWindow(FALSE); GetDlgItem(IDC_STATICUL)->EnableWindow(FALSE); } else { GetDlgItem(IDC_LL)->EnableWindow(TRUE); GetDlgItem(IDC_UL)->EnableWindow(TRUE); GetDlgItem(IDC_STATICLL)->EnableWindow(TRUE); GetDlgItem(IDC_STATICUL)->EnableWindow(TRUE); } // GetDlgItemInt(IDC_LL); // GetDlgItemInt(IDC_UL); } void CFacetPage::OnChangeLL() { UpdateData(TRUE); /* if(m_LL >= m_UL){ AfxMessageBox("Lower Limit Should Be Lower Than Upper Limit"); if(m_UL == 0) m_LL = 0; else m_LL = m_UL -1; UpdateData(FALSE); } */ } void CFacetPage::OnChangeUL() { UpdateData(TRUE); if(m_UL <= m_LL){ AfxMessageBox("Upper Limit Should Be Lower Than Lower Limit"); m_UL = m_LL + 1; UpdateData(FALSE); } // send this notification unless you override the CPropertyPage::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here } void CFacetPage::OnSelchangeCptcombo2() { int Sel = m_CptList1.GetCurSel(); if (Sel < 0 ) return; CString str; CConcept *Cpt; m_CptList1.GetLBText(Sel,str); m_Doc->m_CptList.Lookup(str,Cpt); SetDlgItemText(IDC_LEGALL, Cpt->NameL); SetDlgItemText(IDC_LEGALA, Cpt->NameA); }