// Image.cpp : implementation file // #include "stdafx.h" #include "KBEditors.h" #include "KBEditorsDoc.h" #include "Image.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CImage property page IMPLEMENT_DYNCREATE(CImage, CPropertyPage) CImage::CImage() : CPropertyPage(CImage::IDD) { //{{AFX_DATA_INIT(CImage) //}}AFX_DATA_INIT } CImage::~CImage() { } void CImage::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CImage) DDX_Control(pDX, IDC_VAL, m_LegalList); DDX_Control(pDX, IDC_PROP, m_PropList); DDX_Control(pDX, IDC_CPT, m_CptList); DDX_Control(pDX, IDC_ImageLIST, m_ImageList); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CImage, CPropertyPage) //{{AFX_MSG_MAP(CImage) ON_CBN_SELCHANGE(IDC_CPT, OnSelchangeCpt) ON_BN_CLICKED(IDC_SELECTIMAGE, OnSelectImage) ON_CBN_SELCHANGE(IDC_PROP, OnSelchangeProp) ON_LBN_SELCHANGE(IDC_VAL, OnSelchangeVal) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CImage message handlers void CImage::SeeDoc(CKBEditorsDoc*Doc) { m_Doc = Doc; } void CImage::OnSelchangeCpt() { int Sel = m_CptList.GetCurSel(); if (Sel < 0 ) return; CString str; m_CptList.GetLBText(Sel,str); GetImageList(); m_Doc->m_CptList.Lookup(str,m_Doc->Cpt); m_PropList.ResetContent(); POSITION pos = m_Doc->Cpt->m_PropList.GetStartPosition(); while (pos !=NULL) { CString str1; m_Doc->Cpt->m_PropList.GetNextAssoc(pos,str1,m_Doc->Prop); m_PropList.AddString(str1); } m_LegalList.ResetContent(); } BOOL CImage::OnSetActive() { 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); } } return CPropertyPage::OnSetActive(); } void CImage::OnSelectImage() { CFileDialog cfdlg(TRUE,"*.gif","*.gif",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Gif Files (*.gif)"); cfdlg.DoModal(); CString str = cfdlg.GetFileName(); if(m_ImageList.FindString(-1,str)>=0) return; m_Doc->m_ImageListOb.SetAt(ImageKey,ImageOb); m_ImageList.AddString(str); ImageOb->m_ImageList.AddTail(str); // AfxMessageBox(str); } void CImage::OnSelchangeProp() { m_LegalList.ResetContent(); int Sel = m_PropList.GetCurSel(); if (Sel < 0 ) return; CString strProp; m_PropList.GetLBText(Sel,strProp); GetImageList(); if (!m_Doc->Cpt->m_PropList.Lookup(strProp,m_Doc->Prop)) return; POSITION pos11 = m_Doc->Prop->m_LegalValueList.GetStartPosition(); while (pos11 !=NULL) { CString str11; CString str; m_Doc->Prop->m_LegalValueList.GetNextAssoc(pos11,str,str11); m_LegalList.AddString(str); } } void CImage::GetImageList() { int Sel = m_CptList.GetCurSel(); if (Sel < 0 ) return; CString strCpt; CString strProp; CString strLegal; m_CptList.GetLBText(Sel,strCpt); Sel = m_PropList.GetCurSel(); if (Sel >= 0 ) m_PropList.GetLBText(Sel,strProp); Sel = m_LegalList.GetCurSel(); if (Sel >= 0 ) m_LegalList.GetText(Sel,strLegal); m_ImageList.ResetContent(); ImageKey = strCpt+"-"+strProp+"-"+strLegal; if (!m_Doc->m_ImageListOb.Lookup(ImageKey,ImageOb)) ImageOb = new CImageOb; POSITION pos11 = ImageOb->m_ImageList.GetHeadPosition(); while (pos11 !=NULL) { CString str11; CString str; str = ImageOb->m_ImageList.GetAt(pos11); m_ImageList.AddString(str); ImageOb->m_ImageList.GetNext(pos11); } } void CImage::OnSelchangeVal() { GetImageList(); }