CXTPReportColumn* CSimpleReport::ColSet(int order, const char* s, int width, int align) { CXTPReportColumn* p = AddColumn(new CXTPReportColumn(order, s, width)); p->SetAlignment(align); p->SetHeaderAlignment(DT_CENTER); return p; }
void CReportCtrl::Initialize(const CReportCtrl::ColInfo cols[], int nColCount, UINT nOpFlag) { m_nOpFlag = nOpFlag; m_cols = cols; m_nColCount = nColCount; AllowEdit(nOpFlag != 0); SetGridStyle(FALSE,xtpReportGridSolid); GetPaintManager()->SetColumnStyle(xtpReportColumnResource); GetPaintManager()->m_strNoItems.Empty(); for (int i=0; i<nColCount; ++i) { const ColInfo &c = cols[i]; if (c.fmt != FmtIdOnly) { CXTPReportColumn *pCol = new CXTPReportColumn(GetColumns()->GetCount(),c.caption,c.width, !c.fixed,XTP_REPORT_NOICON,c.sortable); pCol->AllowRemove(FALSE); pCol->SetAllowDrag(FALSE); AddColumn(pCol); } } if (nOpFlag & OpModify) m_pSubmitOpCol = AddOpCol(IndexModify); if (nOpFlag & OpReset) m_pResetOpCol = AddOpCol(IndexReset); if (nOpFlag & OpDelete) m_pDeleteOpCol = AddOpCol(IndexDelete); }
CXTPReportColumn* CReportCtrl::AddOpCol(int i) { const ColInfo &c = s_EditCols[i]; CXTPReportColumn *pCol = new CXTPReportColumn(GetColumns()->GetCount(),c.caption,c.width,FALSE,XTP_REPORT_NOICON,FALSE); pCol->AllowRemove(FALSE); pCol->SetAllowDrag(FALSE); AddColumn(pCol); return pCol; }
void CXTPReportColumnOrder::DoPropExchange(CXTPPropExchange* pPX) { if (pPX->IsStoring()) { int nCount = GetCount(); PX_Int(pPX, _T("Count"), nCount, 0); for (int i = 0; i < nCount; i++) { CXTPReportColumn* pColumn = GetAt(i); if (pColumn) { int nItemIndex = pColumn->GetItemIndex(); CString strInternalName = pColumn->GetInternalName(); CString strParamName; strParamName.Format(_T("Column%i"), i); PX_Int(pPX, strParamName, nItemIndex, 0); strParamName.Format(_T("InternalName%i"), i); PX_String(pPX, strParamName, strInternalName); } } } else { Clear(); int nCount = 0; PX_Int(pPX, _T("Count"), nCount, 0); for (int i = 0; i < nCount; i++) { int nItemIndex = 0; CString strParamName; strParamName.Format(_T("Column%i"), i); PX_Int(pPX, strParamName, nItemIndex, 0); CXTPReportColumn* pColumn = NULL; if (pPX->GetSchema() > _XTP_SCHEMA_1100) { strParamName.Format(_T("InternalName%i"), i); CString strInternalName; PX_String(pPX, strParamName, strInternalName); if (!strInternalName.IsEmpty()) pColumn = m_pColumns->Find(strInternalName); } if (!pColumn) pColumn = m_pColumns->Find(nItemIndex); if (pColumn) Add(pColumn); } } }
CXTPReportColumn* CXTPReportColumns::Find(const CString& strInternalName) const { for (int nColumn = 0; nColumn < GetCount(); nColumn++) { CXTPReportColumn* pColumn = GetAt(nColumn); if (pColumn->GetInternalName() == strInternalName) return pColumn; } return NULL; }
CXTPReportColumn* CXTPReportColumns::GetFirstVisibleColumn() const { for (int nColumn = 0; nColumn < GetCount(); nColumn++) { CXTPReportColumn* pColumn = GetAt(nColumn); if (pColumn->IsVisible()) return pColumn; } return NULL; }
CXTPReportColumn* CXTPReportColumns::GetLastVisibleColumn() const { for (int nColumn = GetCount() - 1; nColumn >= 0; nColumn--) { CXTPReportColumn* pColumn = GetAt(nColumn); if (pColumn->IsVisible()) return pColumn; } return NULL; }
CXTPReportColumn* CXTPReportColumns::Find(int nItemIndex) const { for (int nColumn = 0; nColumn < GetCount(); nColumn++) { CXTPReportColumn* pColumn = GetAt(nColumn); if (pColumn->GetItemIndex() == nItemIndex) return pColumn; } return NULL; }
int CXTPReportColumns::GetVisibleColumnsCount() const { int nVisibleCount = 0; int nCount = GetCount(); for (int nColumn = 0; nColumn < nCount; nColumn++) { CXTPReportColumn* pColumn = GetAt(nColumn); if (pColumn && pColumn->IsVisible()) nVisibleCount++; } return nVisibleCount; }
HRESULT CXTPReportDataManager::CreateColumns() { HRESULT hr = E_FAIL; try { XTPREPORTADODB::FieldsPtr pFields; if (FAILED(hr = m_pDataSource->get_Fields(&pFields)) || pFields == NULL) return hr; long lFields; if (FAILED(hr = pFields->get_Count(&lFields)) || lFields == 0) return hr; VARIANT vtIdx; vtIdx.vt = VT_I4; for (int i = 0; i < lFields; i++) { vtIdx.lVal = i; XTPREPORTADODB::FieldPtr pField; if (FAILED(hr = pFields->get_Item(vtIdx, &pField)) || pField == NULL) break; /* XTPREPORTADODB::DataTypeEnum dteType; if (FAILED(hr = pField->get_Type(&dteType))) break; if (dteType == XTPREPORTADODB::adLongVarBinary) continue;*/ BSTR bstrName; pField->get_Name(&bstrName); CString strName(bstrName); ::SysFreeString(bstrName); CXTPReportColumn* pColumn = new CXTPReportColumn(i, strName, 100); if (!pColumn) break; long lAttrs; if (SUCCEEDED(hr = pField->get_Attributes(&lAttrs)) && (lAttrs & XTPREPORTADODB::adFldUpdatable)) pColumn->SetEditable(TRUE); m_pReportControl->AddColumn(pColumn); } } catch(_com_error &e) { TRACE_ProviderError(m_pConnection); TRACE_ComError(e); hr = FAILED(hr) ? hr : E_FAIL; } catch(...) { TRACE(_T("Unknown error in CreateColumns()\n")); hr = FAILED(hr) ? hr : E_FAIL; } return FAILED(hr) ? hr : S_OK; }
void CXTPReportColumns::GetVisibleColumns(CXTPReportColumns& arrColumns) const { int nCount = GetCount(); for (int nColumn = 0; nColumn < nCount; nColumn++) { CXTPReportColumn* pColumn = GetAt(nColumn); if (pColumn && pColumn->IsVisible()) { arrColumns.m_arrColumns.Add(pColumn); pColumn->InternalAddRef(); } } }
int CInteractionStructureView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CXTPReportView::OnCreate(lpCreateStruct) == -1) { return -1; } GetReportCtrl().SetPaintManager(new CXTPReportInteractionStructurePaintManager()); CXTPToolTipContext* pToolTipContext = GetReportCtrl().GetToolTipContext(); if (pToolTipContext != NULL) { pToolTipContext->SetStyle(xtpToolTipOffice2007); pToolTipContext->SetMaxTipWidth(200); pToolTipContext->SetMargin(CRect(2, 2, 2, 2)); pToolTipContext->SetDelayTime(TTDT_INITIAL, 1000); } LoadImages(); CXTPReportControl& wndReport = GetReportCtrl(); CXTPReportColumn* pColumn = wndReport.AddColumn(new CXTPReportColumn(0, _T("Name"), 250)); pColumn->SetTreeColumn(TRUE); pColumn->SetAlignment(DT_VCENTER); pColumn->SetEditable(FALSE); pColumn->SetSortable(TRUE); pColumn->SetSortIncreasing(TRUE); pColumn = wndReport.AddColumn(new CXTPReportColumn(ICON_COLUMN_NO /*1*/, _T(""), 30)); pColumn->SetMinWidth(25); pColumn->SetAlignment(DT_RIGHT); pColumn->SetEditable(FALSE); pColumn->EnableResize(FALSE); wndReport.SetGridStyle(false, xtpReportGridNoLines); wndReport.GetReportHeader()->AllowColumnRemove(FALSE); wndReport.GetPaintManager()->SetColumnStyle(xtpReportColumnFlat); wndReport.EditOnClick(FALSE); wndReport.SetMultipleSelection(true); wndReport.SetTreeIndent(7); wndReport.ShowHeader(FALSE); wndReport.ShowRowFocus(FALSE); wndReport.GetReportHeader()->AllowColumnResize(false); wndReport.SetSortRecordChilds(TRUE); wndReport.GetColumns()->SetSortColumn(wndReport.GetColumns()->GetAt(0), TRUE); wndReport.GetPaintManager()->m_bShadeSortColumn = FALSE; ShowScrollBar(SB_HORZ, FALSE); RefreshList(); return 0; }
CXTPReportColumn* CXTPReportColumns::GetVisibleAt(int nIndex) const { for (int nColumn = 0; nColumn < GetCount(); nColumn++) { CXTPReportColumn* pColumn = GetAt(nColumn); if (!pColumn->IsVisible()) continue; if (nIndex == 0) return pColumn; nIndex--; } return NULL; }
void CXTPReportColumn::SetExpanded(BOOL bExpanded) { m_bExpanded = bExpanded; int nCnt = m_pColumns->GetCount(); int iN = GetNextVisualBlock(); int iVs = GetVisibleIndex(); CXTPReportColumn* pCol = NULL; for (int iC = 0; iC < nCnt; iC++) { pCol = m_pColumns->GetAt(nCnt - iC - 1); if (pCol) { if (bExpanded) { int iVc = pCol->GetVisibleIndex(); if (iVc == -1) continue; if (iN > 0 && iVc > iVs && iVc <= iVs + iN) pCol->SetVisible(FALSE); else if (iN < 0 && iVc < iVs && iVc >= iVs + iN) pCol->SetVisible(FALSE); } else { int iVc = pCol->GetOldVisibleIndex(); if (iVc == -1) continue; if (iN > 0 && iVc > iVs && iVc <= iVs + iN) pCol->SetVisible(TRUE); //else if (iN < 0 && iVc <= iVs + 1 && iVc >= iVs + iN) else if (iN < 0 && iVc <= iVs + 2 && iVc >= iVs + iN) pCol->SetVisible(TRUE); } } } }
void CXTPReportColumns::Clear() { // array cleanup for (int nColumn = GetCount() - 1; nColumn >= 0; nColumn--) { CXTPReportColumn* pColumn = m_arrColumns.GetAt(nColumn); if (pColumn) pColumn->InternalRelease(); } m_arrColumns.RemoveAll(); m_pSortOrder->Clear(); m_pGroupsOrder->Clear(); // clear variables which could be references to those values if (m_pControl && (m_pControl->GetColumns() == this)) m_pControl->SetFocusedColumn(NULL); }
int CXTPReportColumn::GetPrintWidth(int nTotalWidth) const { CXTPReportColumns* pColumns = m_pColumns; int nColumnsWidth = 0; CXTPReportColumn* pLastAutoColumn = NULL; for (int nColumn = 0; nColumn < pColumns->GetCount(); nColumn++) { CXTPReportColumn* pColumn = pColumns->GetAt(nColumn); if (!pColumn->IsVisible()) continue; if (pColumn->IsAutoSize()) { pLastAutoColumn = pColumn; nColumnsWidth += pColumn->GetWidth(); } else { nTotalWidth -= pColumn->GetWidth(); } } for (int i = 0; i < pColumns->GetCount(); i++) { CXTPReportColumn* pColumn = pColumns->GetAt(i); if (!pColumn->IsVisible()) continue; int nWidth = pColumn->GetWidth(); if (pColumn->IsAutoSize()) { if (pColumn == pLastAutoColumn) { nWidth = max(nTotalWidth, pColumn->GetMinWidth()); } else { nColumnsWidth = max(1, nColumnsWidth); nWidth = max(int(pColumn->GetWidth() * nTotalWidth / nColumnsWidth), pColumn->GetMinWidth()); nTotalWidth -= nWidth; nColumnsWidth -= pColumn->GetWidth(); } } if (pColumn == this) return nWidth; } return 0; }
void CXTPReportColumns::DoPropExchange(CXTPPropExchange* pPX) { int nItemIndex; CString strInternalName; if (pPX->IsStoring()) { int nCount = GetCount(); CXTPPropExchangeEnumeratorPtr pEnumerator(pPX->GetEnumerator(_T("Column"))); POSITION pos = pEnumerator->GetPosition(nCount, FALSE); for (int nColumn = 0; nColumn < nCount; nColumn++) { CXTPReportColumn* pColumn = GetAt(nColumn); CXTPPropExchangeSection secColumn(pEnumerator->GetNext(pos)); nItemIndex = pColumn->GetItemIndex(); strInternalName = pColumn->GetInternalName(); PX_Int(&secColumn, _T("ItemIndex"), nItemIndex); PX_String(&secColumn, _T("InternalName"), strInternalName); pColumn->DoPropExchange(&secColumn); } } else { CXTPPropExchangeEnumeratorPtr pEnumerator(pPX->GetEnumerator(_T("Column"))); POSITION pos = pEnumerator->GetPosition(0, FALSE); CXTPReportColumn tmpColumn(0, _T(""), 0); int i = 0; while (pos) { CXTPPropExchangeSection secColumn(pEnumerator->GetNext(pos)); CXTPReportColumn* pColumn = NULL; PX_Int(&secColumn, _T("ItemIndex"), nItemIndex, -1); if (pPX->GetSchema() > _XTP_SCHEMA_1100) { PX_String(&secColumn, _T("InternalName"), strInternalName); if (!strInternalName.IsEmpty()) { pColumn = Find(strInternalName); if (!pColumn && pPX->GetSchema() < _XTP_SCHEMA_1500) // before 15.0 release internal name was equal to caption { for (int nColumn = 0; nColumn < GetCount(); nColumn++) { CXTPReportColumn* p = GetAt(nColumn); if (p->GetCaption() == strInternalName) { pColumn = p; break; } } } // column data is exists but column is not in the collection. if (!pColumn) { // just read data to skeep (to be safe for array serialization) tmpColumn.DoPropExchange(&secColumn); continue; } } } if (!pColumn) pColumn = Find(nItemIndex); if (!pColumn) AfxThrowArchiveException(CArchiveException::badIndex); pColumn->DoPropExchange(&secColumn); ChangeColumnOrder(i, IndexOf(pColumn)); i++; } } CXTPPropExchangeSection secGroupsOrder(pPX->GetSection(_T("GroupsOrder"))); m_pGroupsOrder->DoPropExchange(&secGroupsOrder); CXTPPropExchangeSection secSortOrder(pPX->GetSection(_T("SortOrder"))); m_pSortOrder->DoPropExchange(&secSortOrder); }
void CXTPReportHeaderDragWnd::OnTimer(UINT_PTR nIDEvent) { UNREFERENCED_PARAMETER(nIDEvent); if (!m_pHeader || !m_pHeader->GetControl()) { return; } CXTPReportControl* pControl = m_pHeader->GetControl(); ASSERT(pControl->m_bHScrollBarVisible); CRect rcHeaderScreen = m_pHeader->m_rcHeader; pControl->ClientToScreen(&rcHeaderScreen); CRect rcControlScreen(0,0,0,0); CRect rcDragScreen(0,0,0,0); pControl->GetWindowRect(&rcControlScreen); GetWindowRect(&rcDragScreen); CPoint ptMouseScreen(0, 0); if (!GetCursorPos(&ptMouseScreen) || ptMouseScreen.y < rcHeaderScreen.top || ptMouseScreen.y > rcHeaderScreen.bottom) { return; } BOOL bScrolled = FALSE; BOOL bLayoutRTL = pControl->GetExStyle() & WS_EX_LAYOUTRTL; int nDiffRight = bLayoutRTL ? rcControlScreen.left - rcDragScreen.left : rcDragScreen.right - rcControlScreen.right; //----------------------------------------------------------------------- CXTPReportColumn *pPrev = NULL, *pCurr = NULL, *pNext = NULL; int nScrollPos = 0, nScrollMax = 0; int nFreezOffset = 0; BOOL bFullColumnScrolling = pControl->IsFullColumnScrolling(); if (bFullColumnScrolling) nFreezOffset = m_pHeader->GetFulColScrollInfo(pPrev, pCurr, pNext, nScrollPos, nScrollMax); //----------------------------------------------------------------------- if (nDiffRight > 0) { int nStep = max(min(7, nDiffRight/10), CXTPReportHeader::s_nMinAutoScrollStep); UINT uTimer = bFullColumnScrolling ? max(30, 800 - nDiffRight * 10) : max(10, 100 - nDiffRight); SCROLLINFO scrollInfo; BOOL bRes = pControl->GetScrollInfo(SB_HORZ, &scrollInfo); if (bRes) { if (!bFullColumnScrolling && scrollInfo.nPos < scrollInfo.nMax || bFullColumnScrolling && nScrollPos < nScrollMax) { if (bFullColumnScrolling) pControl->SendMessage(WM_HSCROLL, SB_LINERIGHT); else pControl->SetLeftOffset(scrollInfo.nPos + nStep); KillTimer(1); SetTimer(1, uTimer, NULL); bScrolled = TRUE; } } } else { int nLeftBorderX = bLayoutRTL ? rcControlScreen.right : rcControlScreen.left; int nFreezCols = pControl->GetFreezeColumnsCount(); if (nFreezCols && pControl->GetColumns()) { CXTPReportColumn* pLastFCol = pControl->GetColumns()->GetVisibleAt(nFreezCols - 1); if (pLastFCol) { CRect rcLastFCol = pLastFCol->GetRect(); pControl->ClientToScreen(&rcLastFCol); int nLastFCol_middleX = rcLastFCol.left + rcLastFCol.Width() / 2; if (rcDragScreen.left < rcLastFCol.right && ptMouseScreen.x > nLastFCol_middleX ) { nLeftBorderX = rcLastFCol.right; } } } int nDiffLeft = bLayoutRTL ? rcDragScreen.right - nLeftBorderX : nLeftBorderX - rcDragScreen.left; if (nDiffLeft > 0) { int nStep = max(min(7, nDiffLeft/10), CXTPReportHeader::s_nMinAutoScrollStep); UINT uTimer = bFullColumnScrolling ? max(30, 800 - nDiffLeft * 10) : max(10, 100 - nDiffLeft); SCROLLINFO scrollInfo; BOOL bRes = pControl->GetScrollInfo(SB_HORZ, &scrollInfo); if (bRes) { if (scrollInfo.nPos > scrollInfo.nMin) { if (bFullColumnScrolling) pControl->SendMessage(WM_HSCROLL, SB_LINELEFT); else pControl->SetLeftOffset(scrollInfo.nPos - nStep); SetTimer(1, uTimer, NULL); bScrolled = TRUE; } } } } //------------------------------------------------------------------------- if (bScrolled) { CPoint ptMouse = ptMouseScreen; pControl->ScreenToClient(&ptMouse); pControl->RedrawControl(); pControl->UpdateWindow(); m_pHeader->OnMouseMove(0, ptMouse); } }