void CReportCtrl::RemoveEditOptions(CXTPReportRecordItem *pItem,DWORD_PTR dwData) { CXTPReportRecordItemEditOptions *pEditOptions = pItem->GetEditOptions(NULL); ASSERT(pEditOptions != NULL); CXTPReportRecordItemConstraints *pConstraints = pEditOptions->GetConstraints(); ASSERT(pConstraints != NULL); CXTPReportRecordItemConstraint *pConstraint = pEditOptions->FindConstraint(dwData); ASSERT (pConstraint != NULL); CDWordArray dwDatas; CStringArray strConstraints; for (int i=0; i<pConstraints->GetCount(); ++i) { CXTPReportRecordItemConstraint *pConstraint = pConstraints->GetAt(i); if (pConstraint->m_dwData != dwData) { dwDatas.Add(pConstraint->m_dwData); strConstraints.Add(pConstraint->m_strConstraint); } } pConstraints->RemoveAll(); for (int i=0; i<dwDatas.GetCount(); ++i) pEditOptions->AddConstraint(strConstraints[i],dwDatas[i]); }
void CXTPReportInplaceList::OnSelectionChanged(int nLBIndex) { CString strActual, str; CListBox::GetText(nLBIndex,strActual); CXTPReportRecordItemEditOptions* pEditOptions = pItem->GetEditOptions(pColumn); CXTPReportRecordItemConstraints* pConstraints = pEditOptions->GetConstraints(); int nCount = pConstraints->GetCount(); for (int nIndex = 0; nIndex < nCount; nIndex++) { CXTPReportRecordItemConstraint* pConstraint = pConstraints->GetAt(nIndex); str = pConstraint->m_strConstraint; if (strActual.CompareNoCase(str) == 0) { ((CXTPReportControl*) pControl)->OnConstraintSelecting(pRow, pItem, pColumn, pConstraint); break; } } //BOOL bAllowEdit = pEditOptions->m_bAllowEdit; BOOL bConstraintEdit = pEditOptions->m_bConstraintEdit; CXTPReportInplaceButton* pButton = pEditOptions->GetButton(0); if (pButton) { if (bConstraintEdit) pButton->m_bDraw = TRUE; //to eliminate flickering else pButton->m_bDraw = FALSE; } }
void CXTPReportInplaceList::OnSelectionChanged(int nLBIndex) { CString strActual, str; CListBox::GetText(nLBIndex,strActual); CXTPReportRecordItemEditOptions* pEditOptions = pItem->GetEditOptions(pColumn); CXTPReportRecordItemConstraints* pConstraints = pEditOptions->GetConstraints(); int nCount = pConstraints->GetCount(); for (int nIndex = 0; nIndex < nCount; nIndex++) { CXTPReportRecordItemConstraint* pConstraint = pConstraints->GetAt(nIndex); str = pConstraint->m_strConstraint; if (strActual.CompareNoCase(str) == 0) { ((CXTPReportControl*) pControl)->OnConstraintSelecting(pRow, pItem, pColumn, pConstraint); break; } } }
void CXTPReportInplaceEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { CXTPReportControl* _pControl = pControl; if (!_pControl) return; if (nChar == VK_TAB) { _pControl->SetFocus(); _pControl->SendMessage(WM_CHAR, nChar); return; } if (nChar == VK_ESCAPE) { SetWindowText(m_strValue); return; } else if (nChar == VK_F5) { _pControl->Recalc(TRUE); return; } else if (nChar == VK_RETURN) { if ((GetStyle() & ES_WANTRETURN) == 0) return; if (GetKeyState(VK_CONTROL) < 0) // ES_WANTRETURN is set and Ctrl+Enter is pressed { pControl->EditItem(NULL); return; } } else if (nChar == VK_UP || nChar == VK_DOWN || nChar == VK_PRIOR || nChar == VK_NEXT) { if (pItem && pColumn && pItem->GetEditOptions(pColumn)->m_bConstraintEdit) { CXTPReportRecordItemConstraint* pConstraint; CXTPReportRecordItemEditOptions* pEditOptions = pItem->GetEditOptions(pColumn); CXTPReportRecordItemConstraints* pConstraints = pEditOptions->GetConstraints(); int nCount = pConstraints->GetCount(); if (nCount > 1) { CString strActual, str; GetWindowText(strActual); int nIndex = 0; // the first item if (nChar == VK_NEXT) { nIndex = nCount - 1; // the last item } else if (nChar != VK_PRIOR) { // look for the actually selected item for (int i = 0; i < nCount; i++) { pConstraint = pConstraints->GetAt(i); if (strActual.CompareNoCase(pConstraint->m_strConstraint) == 0) { if (nChar == VK_UP) nIndex = max(0, i - 1); else if (nChar == VK_DOWN) nIndex = min(nCount-1, i + 1); break; } } } pConstraint = pConstraints->GetAt(max(0, min(nIndex, nCount-1))); str = pConstraint->m_strConstraint; m_pSelectedConstraint = pConstraint; // set the default font, because user could change the font (for ex. to striked one) SetFont(pControl->GetPaintManager()->GetTextFont()); SetWindowText(str); SetSel(0, -1); if (strActual.CompareNoCase(str) != 0) ((CXTPReportControl*)pControl)->OnConstraintSelecting(pRow, pItem, pColumn, pConstraint); return; } } } CEdit::OnKeyDown(nChar, nRepCnt, nFlags); }
void CXTPReportInplaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { if (!pControl) return; if (nChar == VK_TAB) return; if (nChar == VK_ESCAPE) { pControl->EditItem(NULL); return; } if (nChar == VK_RETURN) { if ((GetStyle() & ES_WANTRETURN) == 0) { pControl->EditItem(NULL); } else { CEdit::OnChar(nChar, nRepCnt, nFlags); } return; } if (pItem && pColumn && pItem->GetEditOptions(pColumn)->m_bConstraintEdit) { CXTPReportRecordItemEditOptions* pEditOptions = pItem->GetEditOptions(pColumn); CXTPReportRecordItemConstraints* pConstraints = pEditOptions->GetConstraints(); int nCount = pConstraints->GetCount(); if (nCount > 0) { CString str, strActual; GetWindowText(str); strActual = str; CXTPReportRecordItemConstraint* pConstraint = (m_pSelectedConstraint == NULL) ? pEditOptions->FindConstraint(str): m_pSelectedConstraint; int nIndexStart, nIndex; nIndexStart = nIndex = (pConstraint == NULL ? nCount - 1 : pConstraint->GetIndex()); CString strSeach ((TCHAR)nChar); do { nIndex = nIndex < nCount - 1 ? nIndex + 1 : 0; pConstraint = pConstraints->GetAt(nIndex); str = pConstraint->m_strConstraint; if (strSeach.CompareNoCase(str.Left(1)) == 0) { m_pSelectedConstraint = pConstraint; SetWindowText(str); SetSel(0, -1); if (strActual.CompareNoCase(str) != 0) ((CXTPReportControl*)pControl)->OnConstraintSelecting(pRow, pItem, pColumn, pConstraint); return; } } while (nIndex != nIndexStart); return; } } if (nChar == 1 && nFlags == 30) //Ctrl+A case { SetSel(0, -1); } CEdit::OnChar(nChar, nRepCnt, nFlags); }