/******************************************************************************* Function Name : vSetColumnInfo Inputs : nRow - Row Index nColumn - Column Index sInfo - List info structure Output : - Description : This function will be called to set the list item type. This will call lGetMapID to derive a unique number from row-column index. This will update the CMap with the type information. Member of : CListCtrlEx Author(s) : Raja N Date Created : 22.07.2004 Modifications : *******************************************************************************/ void CListCtrlEx::vSetColumnInfo(int nRow, int nColunm, SLISTINFO sInfo) { // Get the unique map index int nIndex = lGetMapID(nRow, nColunm ); // Update the map with the type information m_omListItemType[ nIndex ] = sInfo; }
/******************************************************************************* Function Name : vSetUserProgInfo Inputs : nRow - Row Index nColumn - Column Index sInfo - User Program info structure Output : - Description : This function will be called to set the list item user program information. This will set the value in the user prog CMap Member of : CFlexListCtrl Author(s) : Raja N Date Created : 22.07.2004 Modifications : *******************************************************************************/ void CFlexListCtrl::vSetUserProgInfo( int nRow, int nColunm, const SUSERPROGINFO& sUSerProgInfo) { // Get the Unique Index int nIndex = lGetMapID(nRow, nColunm); // Update the map data m_omUserProg[ nIndex ] = sUSerProgInfo; }
/******************************************************************************* Function Name : vSetNumericInfo Inputs : nRow - Row Index nColumn - Column Index sInfo - Numeric info structure Output : - Description : This function will be called to set the list item numeric information. This will set the value in the numeric CMap Member of : CFlexListCtrl Author(s) : Raja N Date Created : 22.07.2004 Modifications : *******************************************************************************/ void CFlexListCtrl::vSetNumericInfo( int nRow, int nColunm, const SNUMERICINFO& sInfo) { // Get the Unique Index int nIndex = lGetMapID(nRow, nColunm); // Update the map data m_omNumDetails[ nIndex ] = sInfo; }
/******************************************************************************* Function Name : OnClick Description : Event Handler. This handler will show the controls to edit the selected data from the list control only if signle click activate property is set. This will make list control editable with a single click. Member of : CLinFlexListCtrl Author(s) : Raja N Date Created : 22.07.2004 Modifications : Raja N on 01.08.2004, Modified the function name ShowControl as vShowControl. *******************************************************************************/ void CLinFlexListCtrl::OnClick(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; if(pNMListView != NULL) { // Call Handler Function with required parameters m_nRow = pNMListView->iItem; m_nColumn = pNMListView->iSubItem; sUserProgInfo ouUserProg; //TODO::Lot of If Statements has to reduced; if( m_omUserProg.Lookup(lGetMapID(m_nRow, m_nColumn) , ouUserProg) == TRUE ) { if ( ouUserProg.m_bIcon == true ) { CRect omRect; GetSubItemRect(m_nRow, m_nColumn, LVIR_ICON, omRect); if ( true == omRect.PtInRect( pNMListView->ptAction ) ) { if ( ouUserProg.m_pfHandler != NULL ) { ouUserProg.m_pfHandler(this, m_nRow, m_nColumn, ouUserProg.m_pUserParam); return; } } } } if( m_bSingleClickActivate == TRUE ) { // Set the focus to the list control if( GetFocus() != this) { SetFocus(); } //m_nCurrentCell = pNMListView->iItem * GetHeaderCtrl()->GetItemCount() + pNMListView->iSubItem ; // lGetMapID(pNMListView->iItem, pNMListView->iSubItem); vShowControl(pNMListView->iItem, pNMListView->iSubItem); } } *pResult = 0; }
/******************************************************************************* Function Name : vShowControl Inputs : nRow - Index of the Row nColumn - Index of the Column Output : - Description : This function will show the UI control to change the list item text. This will get the type information from the Cmap and will call approp. function to create and show that control. Member of : CFlexListCtrl Author(s) : Raja N Date Created : 22.07.2004 Modifications : Raja N on 30.07.2004, Code review comments implemented *******************************************************************************/ void CFlexListCtrl::vShowControl(int nItem, int nSubItem) { // Proceed only for a valid entry if( nItem >= 0 && nSubItem >= 0) { SLISTINFO sInfo; SNUMERICINFO sNumInfo; SUSERPROGINFO sProgInfo; CString omStr = STR_EMPTY; // Got the entry type from the CMap if( m_omListItemType.Lookup( lGetMapID(nItem, nSubItem) , sInfo) == TRUE ) { // Begining of Controls creation m_bCreating = TRUE; switch( sInfo.m_eType) { // Numeric Edit box with or with out Spin Control case eNumber: case eBuddy: // Get the numeric control parameters if( m_omNumDetails.Lookup( lGetMapID(nItem, nSubItem), sNumInfo ) == TRUE ) { pomNumItem(nItem, nSubItem, sNumInfo); } else { // Numeric info is not set ASSERT( FALSE ); // Call with default value pomNumItem(nItem, nSubItem, sNumInfo); } break; // General Edit control case eText: pomEditItem(nItem, nSubItem); break; // Editalble Combo Box case eComboList: pomComboList(nItem, nSubItem, sInfo.m_omEntries); break; // Non - Editable combo box case eComboItem: pomComboItem(nItem, nSubItem, sInfo.m_omEntries); break; // User function will be executed case eUser: // Get the user program pointer and parameter details if( m_omUserProg.Lookup( lGetMapID(nItem, nSubItem), sProgInfo ) == TRUE ) { sProgInfo.m_pfHandler( this, nItem, nSubItem, sProgInfo.m_pUserParam); } else { // User program information is not set ASSERT( FALSE ); } break; // Toggling type control case eBool: // Get the current text omStr = GetItemText(nItem, nSubItem); // Compare with the first item if( sInfo.m_omEntries.GetAt(0).Compare(omStr) == 0 ) { // Toggle the first with the second item text. omStr = sInfo.m_omEntries.GetAt(1); } // Compare with the Second item else if( sInfo.m_omEntries.GetAt(1).Compare(omStr) == 0 ) { // Replace with the first item omStr = sInfo.m_omEntries.GetAt(0); } // If it is not matching with these two items nothing will // happen. This could be used to disable the control // For boolean type this is the end of Controls creation m_bCreating = FALSE; // For boolean send the EndLAbleEdit message here itself LV_DISPINFO lvDispInfo; lvDispInfo.hdr.hwndFrom = m_hWnd; lvDispInfo.hdr.idFrom = GetDlgCtrlID(); lvDispInfo.hdr.code = LVN_ENDLABELEDIT; lvDispInfo.item.mask = LVIF_TEXT; lvDispInfo.item.iItem = nItem; lvDispInfo.item.iSubItem = nSubItem; lvDispInfo.item.pszText = LPTSTR((LPCTSTR)omStr); lvDispInfo.item.cchTextMax = omStr.GetLength(); SendMessage( WM_NOTIFY, GetDlgCtrlID(),(LPARAM)&lvDispInfo); break; default: // Unknown control type ASSERT( FALSE ); } // End of Controls m_bCreating = FALSE; } } }
/******************************************************************************* Function Name : sGetColumnInfo Inputs : nRow - Index of the intrested Row nColumn - Index of the intrested Column Output : SLISTINFO - Column Type info Description : This function will be called to get the list item type. This will call lGetMapID to derive a unique number from row-column index. This will return the value stored in the CMap Member of : CFlexListCtrl Author(s) : Raja N Date Created : 22.07.2004 Modifications : *******************************************************************************/ SLISTINFO CFlexListCtrl::sGetColumnInfo(int nRow, int nColunm) { return m_omListItemType [ lGetMapID(nRow, nColunm) ]; }
CAlphaCharEdit* CFlexListCtrl::pomAlphaNumericChar( int nItem, int nSubItem) { CRect omRect; // Set the item to be visible if(!EnsureVisible(nItem, TRUE)) { return nullptr; } // Get the item rect GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, omRect); sUserProgInfo ouUserProg; bool bIsIconAvail = false; if( m_omUserProg.Lookup(lGetMapID(nItem, nSubItem) , ouUserProg) == TRUE ) { bIsIconAvail = ouUserProg.m_bIcon; } if ( true == bIsIconAvail ) { CRect omRect2; GetSubItemRect(nItem, nSubItem, LVIR_ICON , omRect2); omRect.left = omRect2.right; //omRect.right = omRect2.right; } else { omRect.right = omRect.left + GetColumnWidth(nSubItem); } // Now scroll if we need to expose the column CRect omClientRect; GetClientRect(omClientRect); if( omRect.left < 0 || omRect.left > omClientRect.right ) { CSize size( omRect.left, 0 ); Scroll( size ); omRect.left -= size.cx; } if(omRect.right > omClientRect.right) { omRect.right = omClientRect.right; } // Get Column alignment LV_COLUMN lvcol; lvcol.mask = LVCF_FMT; GetColumn(nSubItem, &lvcol); DWORD dwStyle; if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT) { dwStyle = ES_LEFT; } else if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT) { dwStyle = ES_RIGHT; } else { dwStyle = ES_CENTER; } // Set the standard windows style dwStyle |=WS_BORDER|WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; // Get the selected item text CString omStrText = GetItemText(nItem, nSubItem); // Create the control CAlphaCharEdit* pomEdit2 = nullptr; SNUMERICINFO info; info.m_uMaxVal.m_n64Value = 5; info.m_uMaxVal.m_n64Value = 0; omStrText = ""; CAlphaCharEdit* pomEdit = new CAlphaCharEdit(nItem, nSubItem, omStrText); if( pomEdit != nullptr ) { pomEdit->Create(WS_BORDER|WS_CHILD | WS_VISIBLE, omRect, this, IDC_CONTROL); pomEdit->SetLimitText(1); pomEdit->SetFocus(); } else { CString omStrErr; omStrErr.Format( _(defFLC_CREATE_FAILED), defNUM_ITEM ); AfxMessageBox( omStrErr ); } // Return the window pointer return pomEdit2; }
void CFlexListCtrl::selectNext (int nIncrement) { int nCurrentCell = m_nCurrentCell; if ( nIncrement < 0 ) { nCurrentCell += nIncrement; while( nCurrentCell > 0 ) { SLISTINFO sInfo; int r = nCurrentCell / GetHeaderCtrl()->GetItemCount(); int c = nCurrentCell % GetHeaderCtrl()->GetItemCount(); if( m_omListItemType.Lookup(lGetMapID(r,c), sInfo) == TRUE ) { m_nCurrentCell = nCurrentCell; vShowControl(r, c); break; } nCurrentCell--; } } else { int nTotalItems = GetItemCount() * GetHeaderCtrl()->GetItemCount(); nCurrentCell += nIncrement; while( nCurrentCell < nTotalItems ) { SLISTINFO sInfo; int r = nCurrentCell / GetHeaderCtrl()->GetItemCount(); int c = nCurrentCell % GetHeaderCtrl()->GetItemCount(); if( m_omListItemType.Lookup(lGetMapID(r,c), sInfo) == TRUE ) { m_nCurrentCell = nCurrentCell; vShowControl(r, c); break; } nCurrentCell++; } } // int cItems = GetItemCount (); // int iItem = -1; // // iItem = GetNextItem (iItem, LVIS_SELECTED); // int iEditItem = 0; // SetFocus (); //int nNextCell = ( m_nCurrentCell + 1 ) % m_nTotalCell; // int nItem = nNextCell / cItems; // int nSubItems = nNextCell % GetHeaderCtrl()->GetItemCount(); // if (Forward) // { // // if (iItem + 1 >= cItems) // iEditItem = 0; // else // iEditItem = iItem + 1; // } // else // { // if (iItem - 1 < 0) // iEditItem = cItems - 1; // else // iEditItem = iItem - 1; // } //m_nCurrentCell = nItem*GetItemCount() + nSubItems; // vShowControl(nItem, nSubItems); } // selectNext