📄 pagequery1.cpp
字号:
{
// Retrieve selections at this level
if (hLast == NULL)
{
hItem = m_ctrlTree.GetChildItem(hItem);
} else
{
hItem = m_ctrlTree.GetNextSiblingItem(hItem);
};
ASSERT(hItem != NULL);
s = m_ctrlTree.GetItemText(hItem);
bCheck = m_ctrlTree.GetCheck(hItem);
pElement->SetSelected(bCheck);
// If a feature type then move one level down and exit
if (pElement->GetDataType() == BDFTYPE)
{
RetrieveSelections((CQuery*)pElement, hItem);
break;
}
// If a link type then add links to tree
if (pElement->GetDataType() == BDLINK ||
pElement->GetDataType() == BDFEATURE ||
pElement->GetDataType() == BDBOOLEAN)
{
RetrieveLinkSel((CQueryLink*)pElement, hItem);
}
hLast = hItem;
// Get next query and skip statistics
pElement = pElement->GetNextQuery();
while (pElement != NULL &&
pElement->GetDataType() == BDQUERYSTATS)
{
pElement = pElement->GetNextQuery();
}
};
};
}
///////////////////////////////////////////////////////////////////////////////
void CPageQuery1::RetrieveLinkSel(CQueryLink* pLink, HTREEITEM hParent)
{
HTREEITEM hItem = m_ctrlTree.GetChildItem(hParent);
for (int i = 0; i < pLink->m_aFeatures.GetSize(); i++)
{
ASSERT(hItem != NULL);
BOOL bCheck = m_ctrlTree.GetCheck(hItem);
pLink->m_aFeatures[i].SetSelected(bCheck);
hItem = m_ctrlTree.GetNextSiblingItem(hItem);
}
}
///////////////////////////////////////////////////////////////////////////////
void CPageQuery1::OnSelchangedElements(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
CQueryElement* pElement = NULL;
*pResult = 0;
}
///////////////////////////////////////////////////////////////////////////////
//
// Retrieves the element corresponding to the hItem
//
CQueryElement* CPageQuery1::GetElement(CQuery* pQuery, HTREEITEM hItemSel, HTREEITEM hItem)
{
CQueryElement* pElement = pQuery;
HTREEITEM hLast = NULL;
if (hItem == TVI_ROOT) hItem = m_ctrlTree.GetChildItem(hItem);
pElement = pElement->GetNextQuery();
while (pElement != NULL)
{
// Retrieve selections at this level
if (hLast == NULL)
{
hItem = m_ctrlTree.GetChildItem(hItem);
} else
{
hItem = m_ctrlTree.GetNextSiblingItem(hItem);
};
ASSERT(hItem != NULL);
// Required item found
if (hItem == hItemSel)
{
return pElement;
}
// If a feature type then move one level down and exit
if (pElement->GetDataType() == BDFTYPE)
{
return GetElement((CQuery*)pElement, hItemSel, hItem);
}
hLast = hItem;
pElement = pElement->GetNextQuery();
while (pElement != NULL &&
pElement->GetDataType() == BDQUERYSTATS)
{
pElement = pElement->GetNextQuery();
}
};
return NULL;
}
///////////////////////////////////////////////////////////////////////////////
void CPageQuery1::OnDictionary()
{
m_cbFType.OnClickDictionary();
}
///////////////////////////////////////////////////////////////////////////////
BOOL CPageQuery1::OnSetActive()
{
#ifdef BDQUERYWIZARD
CWnd* pParent = GetParent();
CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, pParent);
pSheet->SetWizardButtons(PSWIZB_NEXT);
#endif
return CPropertyPage::OnSetActive();
}
///////////////////////////////////////////////////////////////////////////////
BOOL CPageQuery1::OnKillActive()
{
if (m_cbFType.GetCurSel() == CB_ERR) return TRUE;
// Retrieve selections
RetrieveSelections(m_pQuery);
m_cbFType.SaveFTypes();
// Validate that one map attribute is selected
int nMapLines = 0, nCoord = 0;
int nImages = 0;
int nDate = 0;
m_nNumber = 0;
CQueryElement* pElement = m_pQuery;
while (pElement != NULL)
{
if (pElement->GetSelected())
{
if (pElement->GetDataType() == BDMAPLINES) nMapLines++;
if (pElement->GetDataType() == BDCOORD) nCoord++;
if (pElement->GetDataType() == BDIMAGE) nImages++;
if (pElement->GetDataType() == BDNUMBER) m_nNumber++;
};
if (pElement->GetDataType() == BDDATE && m_nType == CSheetQuery::TSGraph)
{
pElement->SetSelected(TRUE);
}
pElement = pElement->GetNextQuery();
}
if (m_nType == CSheetQuery::Map && nMapLines + nCoord + nImages != 1)
{
AfxMessageBox(BDString(IDS_SELMAPOBJ));
return 0;
}
// Include the number of numeric attributes
BOOL bStats = FALSE;
pElement = m_pQuery;
while (pElement != NULL)
{
if (pElement->GetDataType() == BDQUERYSTATS || pElement->GetGroupStat() != CQueryElement::none)
{
bStats = TRUE;
break;
}
pElement = pElement->GetNextQuery();
}
// Check that one numeric attribute is selected
if ((m_nType == CSheetQuery::HistGraph || m_nType == CSheetQuery::TSGraph || m_nType == CSheetQuery::PieChart) &&
m_nNumber == 0 && !bStats)
{
if (AfxMessageBox(BDString(IDS_NONUMSEL), MB_OKCANCEL) == IDOK)
{
return FALSE;
};
}
return CPropertyPage::OnKillActive();
}
///////////////////////////////////////////////////////////////////////////////
void CPageQuery1::OnOK()
{
// Okay, can exit
*m_pQueryPrev = *m_pQuery;
CPropertyPage::OnOK();
}
///////////////////////////////////////////////////////////////////////////////
void CPageQuery1::OnMouseMove(UINT nFlags, CPoint point)
{
int nMapLines = 0, nCoord = 0;
int nNum = 0, nText = 0, nDate = 0;
//Set up the tooltip
if (!m_pTooltip)
{
int rt;
m_pTooltip = new CToolTipCtrl;
rt = m_pTooltip->Create(this);
ASSERT(rt!=0);
BDToolTip() = m_pTooltip;
rt = m_pTooltip->AddTool(&m_ctrlTree,BDString(IDS_ATTRIBUTESTIP));
ASSERT(rt!=0);
m_pTooltip->Activate(TRUE);
}
// Update the tooltip message according to what is selected
if (m_pTooltip)
{
RetrieveSelections(m_pQuery);
CQueryElement* pElement = m_pQuery;
while (pElement != NULL)
{
if (pElement->GetSelected())
{
if (pElement->GetDataType() == BDMAPLINES) nMapLines++;
else if (pElement->GetDataType() == BDCOORD) nCoord++;
else if (pElement->GetDataType() == BDNUMBER) nNum++;
else if (pElement->GetDataType() == BDDATE) nDate++;
else nText++;
};
pElement = pElement->GetNextQuery();
}
// Display tooltips for maps
if (m_nType == CSheetQuery::Map)
{
if (nMapLines > 1 || nCoord > 1 || (nMapLines > 0 && nCoord > 0))
{
m_pTooltip->UpdateTipText(BDString(IDS_SELMAPOBJ),&m_ctrlTree);
}
else if (nCoord == 1 && nNum == 0 && nText == 0)
{
m_pTooltip->UpdateTipText(BDString(IDS_SELNUMTEXT), &m_ctrlTree);
}
else if (nMapLines == 1 && nNum == 0)
{
m_pTooltip->UpdateTipText(BDString(IDS_SELNUMTEXT), &m_ctrlTree);
}
else if (nMapLines == 0 && nCoord == 0)
{
m_pTooltip->UpdateTipText(BDString(IDS_SELMAPOBJ), &m_ctrlTree);
} else
{
m_pTooltip->UpdateTipText("",&m_ctrlTree);
}
// Display tooltips for time-series graphs
} else if (m_nType == CSheetQuery::TSGraph)
{
if (nNum == 0)
{
m_pTooltip->UpdateTipText(BDString(IDS_NONUMSEL), &m_ctrlTree);
} else
{
m_pTooltip->UpdateTipText("", &m_ctrlTree);
}
}
// Display tool tips for histogram graphs
else if (m_nType == CSheetQuery::HistGraph)
{
if (nNum == 0)
{
m_pTooltip->UpdateTipText(BDString(IDS_NONUMSEL), &m_ctrlTree);
} else if (nText == 0)
{
m_pTooltip->UpdateTipText(BDString(IDS_SELTEXT), &m_ctrlTree);
} else
{
m_pTooltip->UpdateTipText("", &m_ctrlTree);
}
}
}
CPropertyPage::OnMouseMove(nFlags, point);
}
///////////////////////////////////////////////////////////////////////////////
//
// void CPageQuery1::PostNcDestroy()
//
void CPageQuery1::PostNcDestroy()
{
BDHwndDialog() = NULL;
BDToolTip() = NULL;
CPropertyPage::PostNcDestroy();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -