SearchSignDlg.cpp1
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:9k
- // SearchSignDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "GpsSC.h"
- #include "SearchSignDlg.h"
- #include "GpsSignObject.h"
- #include "GpsAreaLibStruct.h"
- #include "GpsFatStruct.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSearchSignDlg dialog
- // const BYTE AreaLibLevelTotal = 4;
- CSearchSignDlg::CSearchSignDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CSearchSignDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSearchSignDlg)
- m_sAdvertiseInfo = _T("没有信息");
- //}}AFX_DATA_INIT
- }
- CSearchSignDlg::CSearchSignDlg(CObList *SignList,CObList *AreaList,CWnd* pParent /*=NULL*/)
- : CDialog(CSearchSignDlg::IDD, pParent)
- {
- lSignList = SignList;
- lAreaList = AreaList;
- }
- void CSearchSignDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSearchSignDlg)
- DDX_Control(pDX, IDC_AREA_TREE, m_ctlAreaTree);
- DDX_Control(pDX, IDC_OTHER_AREA, m_ctlOtherArea);
- DDX_Control(pDX, IDC_ADVERTISE_INFO, m_ctlAdvertiseInfo);
- DDX_Control(pDX, IDC_CAPTION, m_ctlCaption);
- DDX_Control(pDX, IDC_SIGN_TYPE, m_ctlSignType);
- DDX_Control(pDX, IDC_SIGN_LIST, m_ctlSignList);
- DDX_Control(pDX, IDC_SEARCH, m_btnSearch);
- DDX_Control(pDX, IDC_CURR_AREA, m_ctlCurrArea);
- DDX_Text(pDX, IDC_ADVERTISE_INFO, m_sAdvertiseInfo);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSearchSignDlg, CDialog)
- //{{AFX_MSG_MAP(CSearchSignDlg)
- ON_BN_CLICKED(IDC_SEARCH, OnSearch)
- ON_BN_CLICKED(IDC_CURR_AREA, OnCurrArea)
- ON_CBN_SELCHANGE(IDC_SIGN_TYPE, OnSelchangeSignType)
- ON_BN_CLICKED(IDC_OTHER_AREA, OnOtherArea)
- ON_NOTIFY(NM_DBLCLK, IDC_AREA_TREE, OnDblclkAreaTree)
- ON_NOTIFY(TVN_SELCHANGED, IDC_AREA_TREE, OnSelchangedAreaTree)
- ON_WM_DESTROY()
- ON_LBN_DBLCLK(IDC_SIGN_LIST, OnDblclkSignList)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSearchSignDlg message handlers
- BOOL CSearchSignDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- m_sAdvertiseInfo.Empty();
- m_ctlSignType.SetCurSel(0);
- m_ctlCurrArea.SetCheck(1);
- m_ctlAreaTree.ShowWindow(FALSE);
- OnSelchangeSignType();
- ListTypeAreaLib(lAreaList);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CSearchSignDlg::OnSearch()
- {
- // TODO: Add your control notification handler code here
-
- }
- void CSearchSignDlg::OnCurrArea()
- {
- // TODO: Add your control notification handler code here
- if(m_ctlCurrArea.GetCheck()) {
- m_ctlCaption.ShowWindow(TRUE);
- m_ctlCaption.EnableWindow(TRUE);
- m_ctlAdvertiseInfo.EnableWindow(TRUE);
- m_ctlAdvertiseInfo.ShowWindow(TRUE);
- m_ctlAreaTree.ShowWindow(FALSE);
- m_ctlAreaTree.EnableWindow(FALSE);
- ListTypeSignLib(lSignList);
- }
- else {
- m_ctlCaption.ShowWindow(FALSE);
- m_ctlCaption.EnableWindow(FALSE);
- m_ctlAdvertiseInfo.EnableWindow(FALSE);
- m_ctlAdvertiseInfo.ShowWindow(FALSE);
- m_ctlAreaTree.ShowWindow(TRUE);
- m_ctlAreaTree.EnableWindow(TRUE);
- // m_ctlSignList.ShowWindow(FALSE);
- }
- }
- void CSearchSignDlg::OnOtherArea()
- {
- // TODO: Add your control notification handler code here
- if(m_ctlOtherArea.GetCheck()) {
- m_ctlCaption.ShowWindow(FALSE);
- m_ctlCaption.EnableWindow(FALSE);
- m_ctlAdvertiseInfo.EnableWindow(FALSE);
- m_ctlAdvertiseInfo.ShowWindow(FALSE);
- m_ctlAreaTree.ShowWindow(TRUE);
- m_ctlAreaTree.EnableWindow(TRUE);
- ListTypeSignLib(&lOtherSignList);
- // m_ctlSignList.ShowWindow(FALSE);
- }
- else {
- m_ctlCaption.ShowWindow(TRUE);
- m_ctlCaption.EnableWindow(TRUE);
- m_ctlAdvertiseInfo.EnableWindow(TRUE);
- m_ctlAdvertiseInfo.ShowWindow(TRUE);
- m_ctlAreaTree.ShowWindow(FALSE);
- m_ctlAreaTree.EnableWindow(FALSE);
- // m_ctlSignList.ShowWindow(TRUE);
- }
- }
- void CSearchSignDlg::ListTypeSignLib(CObList *SignList)
- {
- CGpsSignObject *pSign;
- POSITION pos;
- CString SignName;
- BYTE SignType;
- UpdateData(TRUE);
- SignType = m_ctlSignType.GetCurSel();
- m_ctlSignList.ResetContent();
- pos = SignList->GetTailPosition();
- while(pos != NULL) {
- pSign = (CGpsSignObject*)SignList->GetPrev(pos);
- SignName = pSign->m_pSignObjectName;
- if(SignName.IsEmpty()) continue;
- if((SignType != 0) && (pSign->m_bySignType != SignType)) continue;
- m_ctlSignList.AddString(pSign->m_pSignObjectName);
- }
- }
- void CSearchSignDlg::ListTypeAreaLib(CObList *AreaList)
- {
- CGpsAreaLibStruct *pArea;
- POSITION pos;
- TVINSERTSTRUCT tvInsert;
- HTREEITEM hParent;
- BYTE i;
- for(i = 1; i <= AreaLibLevelTotal; i++) {
- pos = AreaList->GetTailPosition();
- while(pos != NULL) {
- pArea = (CGpsAreaLibStruct*)AreaList->GetPrev(pos);
- if(pArea->m_byAreaLevel != i) continue;
- if(i == 1) {
- tvInsert.hParent = NULL;
- tvInsert.hInsertAfter = NULL;
- tvInsert.item.mask = TVIF_TEXT;
- tvInsert.item.pszText = _T(pArea->m_arrAreaName);
- hParent = m_ctlAreaTree.InsertItem(&tvInsert);
- CString str;
- str = pArea->m_arrAreaABCD;
- str = str.Left(i * 2);
- AddSubAreaToTree(hParent,AreaList,i,str);
- break;
- }
- }
- }
- }
- void CSearchSignDlg::AddSubAreaToTree(HTREEITEM hParent,CObList *AreaList,BYTE i,CString Level)
- {
- CGpsAreaLibStruct *pArea;
- POSITION pos;
- CString Name;
- HTREEITEM hCurrent;
- pos = AreaList->GetTailPosition();
- while(pos != NULL) {
- pArea = (CGpsAreaLibStruct*)AreaList->GetPrev(pos);
- Name = pArea->m_arrAreaABCD;
- Name = Name.Left(i * 2);
- if(pArea->m_byAreaLevel != i + 1) continue;
- if(Level != Name) continue;
- hCurrent = m_ctlAreaTree.InsertItem(_T(pArea->m_arrAreaName),hParent,NULL);
- if(i < AreaLibLevelTotal - 1) {
- Name = pArea->m_arrAreaABCD;
- Name = Name.Left((i + 1) * 2);
- AddSubAreaToTree(hCurrent,AreaList,i + 1,Name);
- }
- }
- }
- void CSearchSignDlg::OnSelchangeSignType()
- {
- // TODO: Add your control notification handler code here
- if(m_ctlCurrArea.GetCheck()) {
- ListTypeSignLib(lSignList);
- }
- else {
- ListTypeSignLib(&lOtherSignList);
- }
- }
- void CSearchSignDlg::OnSelchangedAreaTree(NMHDR* pNMHDR, LRESULT* pResult)
- {
- NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
- // TODO: Add your control notification handler code here
-
- m_hCurrTree = m_ctlAreaTree.GetSelectedItem();
- *pResult = 0;
- }
- void CSearchSignDlg::OnDblclkAreaTree(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- CGpsAreaLibStruct *pArea = NULL;
- POSITION pos;
- CString Name,SignName;
- SignName = m_ctlAreaTree.GetItemText(m_hCurrTree);
- pos = lAreaList->GetTailPosition();
- while(pos != NULL) {
- pArea = (CGpsAreaLibStruct*)lAreaList->GetPrev(pos);
- if(pArea->m_byAreaLevel != AreaLibLevelTotal) continue;
- Name = pArea->m_arrAreaName;
- if(SignName != Name) continue;
- ClearSignList(&lOtherSignList);
- m_pDrawMap->GetSignLib(pArea->m_arrRelateSignLibName,&lOtherSignList,false);
- ListTypeSignLib(&lOtherSignList);
- }
- *pResult = 0;
- }
- void CSearchSignDlg::GetParent(CGpsDrawMap *pDrawMap)
- {
- m_pDrawMap = pDrawMap;
- }
- void CSearchSignDlg::ClearSignList(CObList *SignList)
- {
- CGpsSignObject *pSign = NULL;
- POSITION pos;
- pos = SignList->GetTailPosition();
- while(pos != NULL) {
- pSign = (CGpsSignObject*)SignList->GetPrev(pos);
- delete pSign;
- }
- SignList->RemoveAll();
- }
- void CSearchSignDlg::OnDestroy()
- {
- CDialog::OnDestroy();
-
- // TODO: Add your message handler code here
- ClearSignList(&lOtherSignList);
- }
- void CSearchSignDlg::OnDblclkSignList()
- {
- // TODO: Add your control notification handler code here
- CGpsSignObject *pSign = NULL;
- POSITION pos;
- CString SignName,Name;
- bool Flag = false;
- m_ctlSignList.GetText(m_ctlSignList.GetCurSel(),SignName);
- if(SignName.IsEmpty()) return;
- if(m_ctlCurrArea.GetCheck()) {
- pos = lSignList->GetTailPosition();
- while(pos != NULL) {
- pSign = (CGpsSignObject*)lSignList->GetPrev(pos);
- Name = pSign->m_pSignObjectName;
- if(Name != SignName) continue;
- Flag = true;
- break;
- }
- }
- if(m_ctlOtherArea.GetCheck()) {
- pos = lOtherSignList.GetTailPosition();
- while(pos != NULL) {
- pSign = (CGpsSignObject*)lOtherSignList.GetPrev(pos);
- Name = pSign->m_pSignObjectName;
- if(Name != SignName) continue;
- Flag = true;
- break;
- }
- }
- if(!Flag) return;
- CDC *pDC = GetDC();
- m_pDrawMap->CheckMapIsChange(pSign->m_dgx,pSign->m_dgy);
- m_pDrawMap->DrawOneSignPoint(pDC,pSign);
- }