BOOL COXMultiComboBox::SetColumnCount(int nCount) { if(nCount == m_nColumnCount) return TRUE; // ... nCount should be more than or equal to Master column and -1 if ((nCount <= m_nMasterColumn) || (nCount < 0)) return FALSE; m_aColumnWidth.SetSize(nCount); // If size grows initailize the new columns width for(int nColIndex = m_nColumnCount; nColIndex < nCount; nColIndex++) m_aColumnWidth[nColIndex] = DEFAULT_COLUMN_WIDTH; // Resizes the number of columns in each rowdata object int nCurCount = GetCount(); for(int nIndex = 0; nIndex < nCurCount; nIndex++) { COXRowData* pRowData = GetRowData(nIndex); if (pRowData != NULL) pRowData->SetColumnCount(nCount); else TRACE0("In COXMultiComboBox::SetColumnCount : GetRowData() returned NULL.\n"); } m_nColumnCount = nCount; AdjustToFitSize(); return TRUE; }
//Private BOOL COXMultiComboBox::ChangeMasterColumn(int /* nCol */) { int nNumItems = GetCount(); CArray<COXRowData*,COXRowData*> aPtrsRowData; aPtrsRowData.SetSize(nNumItems); int nIndex=0; for(nIndex=0; nIndex < nNumItems; nIndex++) { COXRowData* pRowData = GetRowData(nIndex); aPtrsRowData[nIndex] = pRowData; if (pRowData == NULL) TRACE0("In COXMultiComboBox::ChangeMasterColumn : GetRowData() returned NULL.\n"); } // ... To avoid deleting the Rowdata in DeleteItem m_fMasterColumnChanging = TRUE; // ... Delete all the Items ResetContent(); // ... Resets the flag m_fMasterColumnChanging = FALSE; int nRetVal; // Again add all the items. This deletion and addition is to effect // the sorting order based on current master column for(nIndex=0; nIndex < nNumItems; nIndex++) { if((nRetVal = CComboBox::AddString((aPtrsRowData[nIndex])->GetColumnString(m_nMasterColumn))) != CB_ERR) SetRowData(nRetVal,aPtrsRowData[nIndex]); else return FALSE; } return TRUE; }
int COXMultiComboBox::FindStringExact(int nIndexStart, int nColIndex, LPCTSTR lpszFind, BOOL bCaseSensitive/*=FALSE*/) const { if(nColIndex >= m_nColumnCount || nColIndex < 0) return CB_ERR; if(nIndexStart <= -1) nIndexStart = 0; int nItemCount = GetCount(); for(int nIndex = nIndexStart; nIndex < nItemCount; nIndex++) { COXRowData* pRowData = GetRowData(nIndex); if (pRowData != NULL) { if(bCaseSensitive) { if(pRowData->GetColumnString(nColIndex) == lpszFind) return nIndex; } else { if(pRowData->GetColumnString(nColIndex).CompareNoCase(lpszFind) == 0) return nIndex; } } else TRACE0("In COXMultiComboBox::FindStringExact : GetRowData() returned NULL.\n"); } return CB_ERR; }
int COXMultiComboBox::GetLBTextLen(int nIndex,int nColIndex) const { if(nIndex >= GetCount() || nColIndex >= m_nColumnCount || nColIndex < 0 || nIndex < 0) return CB_ERR; COXRowData* pRowData = GetRowData(nIndex); if (pRowData != NULL) return pRowData->GetColumnString(nColIndex).GetLength(); else { TRACE0("In COXMultiComboBox::GetLBTextLen : GetRowData() returned NULL.\n"); return CB_ERR; } }
//This is handle to delete rowdata. void COXMultiComboBox::OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct) { if(!m_fMasterColumnChanging && lpDeleteItemStruct->CtlType == ODT_LISTBOX) { COXRowData* pRowData = GetRowData(lpDeleteItemStruct->itemID); if (pRowData != NULL) { pRowData->SetColumnCount(0); delete pRowData; } else TRACE0("In COXMultiComboBox::OnDeleteItem : GetRowData() returned NULL.\n"); } CComboBox::OnDeleteItem(nIDCtl, lpDeleteItemStruct); }
void COXMultiComboBox::GetLBText(int nIndex, int nColIndex, CString& rString) const { if(nIndex < GetCount() && nColIndex < m_nColumnCount && nIndex >= 0 && nColIndex >=0 ) { COXRowData* pRowData = GetRowData(nIndex); if (pRowData != NULL) { rString = pRowData->GetColumnString(nColIndex); return; } else TRACE0("In COXMultiComboBox::GetLBText : GetRowData() returned NULL.\n"); } rString.Empty(); }
int COXMultiComboBox::GetLBText(int nIndex,int nColIndex, LPTSTR lpszText) const { if(nIndex >= GetCount() || nColIndex >= m_nColumnCount || nColIndex < 0 || nIndex < 0) return CB_ERR; // ... copies the string into buffer COXRowData* pRowData = GetRowData(nIndex); if (pRowData != NULL) { // ... returns the length UTBStr::tcscpy(lpszText, pRowData->GetColumnString(nColIndex).GetLength()+1, pRowData->GetColumnString(nColIndex).GetBuffer(0)); return pRowData->GetColumnString(nColIndex).GetLength(); } else { TRACE0("In COXMultiComboBox::GetLBText : GetRowData() returned NULL.\n"); return CB_ERR; } }
int COXMultiComboBox::FindString(int nStartAfter, int nColIndex, LPCTSTR lpszString, BOOL bCaseSensitive/*=FALSE*/) const { if(nColIndex >= m_nColumnCount || nColIndex < 0) return CB_ERR; if(nStartAfter < -1) nStartAfter = -1; int nItemCount = GetCount(); int nStrLen = (int)_tcslen(lpszString); if(nStrLen==0) { TRACE(_T("COXMultiComboBox::FindString : zero-length string was specified\n")); return CB_ERR; } for(int nIndex = nStartAfter+1; nIndex < nItemCount; nIndex++) { COXRowData* pRowData = GetRowData(nIndex); if (pRowData != NULL) { if(bCaseSensitive) { if(pRowData->GetColumnString(nColIndex).Left(nStrLen) == lpszString) return nIndex; } else { if(pRowData->GetColumnString(nColIndex).Left(nStrLen). CompareNoCase(lpszString) == 0) return nIndex; } } else TRACE0("In COXMultiComboBox::FindString : GetRowData() returned NULL.\n"); } return CB_ERR; }
int COXMultiComboBox::SelectString(int nStartAfter, int nColIndex, LPCTSTR lpszString) { if(nColIndex >= m_nColumnCount || nColIndex < 0) return CB_ERR; int nIndex = FindStringExact(nStartAfter,nColIndex,lpszString); if(nIndex != CB_ERR) { COXRowData* pRowData = GetRowData(nIndex); if (pRowData != NULL) nIndex = CComboBox::SelectString(nStartAfter,pRowData->GetColumnString(m_nMasterColumn)); else { TRACE0("In COXMultiComboBox::SelectString : GetRowData() returned NULL.\n"); nIndex = CB_ERR; } } return nIndex; }
bool DefaultDetail::DeleteRows(size_t pos, size_t numRows) { if ( pos >=0 && pos < GetNumberRows() ) { wxList* row = GetRowData(pos); GetData()->RemoveAt(pos); DeleteRow(row); if ( GetView() ) { wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, pos, 1); GetView()->ProcessTableMessage(msg); } return true; } else { return false; } };
BOOL DiaGridView::StoreStyleRowCol( ROWCOL nRow, ROWCOL nCol, const CGXStyle* pStyle, GXModifyType mt /*= gxOverride*/, int nType /*= 0*/ ) { auto cell = GetRowData(nRow); if( !cell ) return FALSE; switch (nCol) { case 2: { CGXStyle styleY; GetStyleRowCol(nRow, nCol + 1, styleY); CPoint point( pStyle->GetLongValue(), styleY.GetLongValue() ); setEntityCentralPoint( nRow, point ); break; } case 3: { CGXStyle styleX; GetStyleRowCol(nRow, nCol - 1, styleX); CPoint point( styleX.GetLongValue(), pStyle->GetLongValue() ); setEntityCentralPoint(nRow, point); break; } case 4: { int istyle = getIntegerTypeOfStyle(pStyle->GetValue()); setEntityPenStyle(nRow, istyle); break; } } return TRUE; }
BOOL DiaGridView::GetStyleRowCol( ROWCOL nRow, ROWCOL nCol, CGXStyle& style, GXModifyType mt, int nType ) { auto cell = GetRowData(nRow); if( !cell ) return FALSE; CPoint point = cell->getCentralPoint(); switch(nCol) { case 1: style.SetValue(getStringFigureTypeName( cell->type() )); return TRUE; case 2: style.SetValue(point.x); return TRUE; case 3: style.SetValue(point.y); return TRUE; case 4: style .SetControl(GX_IDS_CTRL_COMBOBOX) .SetChoiceList("solid\ndash\ndashdot\ndashdotdot") .SetValue(getStringContourTypeName( cell->getContourStyle() )); return TRUE; case 5: style .SetControl(GX_IDS_CTRL_HOTSPOT) .SetInterior(cell->getContourColor()); return TRUE; } return FALSE; }
Bool_T Postsolver::GetFreeSingletonAction( Int_T &nn, Int_T var ) { if( !Lexer::GetKeyword( "FREE_SINGL" ) ) return False; Lexer::GetNewline( True ); nn--; Real_T b = 0.0, slOpt = 0.0, val = 0.0; //-------------------------------------------------------------------------- // Read the optional optimal slack value. // if( !Lexer::GetSpace() ) { Error( "Premature end of the ACTION FREE_SINGL section." ); return False; } if( Lexer::GetKeyword( "SLACK" ) ) { if( !Lexer::GetSpace() || !Lexer::GetNumeric() ) { Error( "SLACK value expected." ); goto error; } slOpt = Lexer::Number; Lexer::GetNewline( True ); if( !Lexer::GetSpace() ) { Error( "Premature end of the ACTION FREE_SINGL section." ); return False; } } //-------------------------------------------------------------------------- // Read the RHS value. // if( !Lexer::GetKeyword( "RHS" ) || !Lexer::GetSpace() || !Lexer::GetNumeric() ) { Error( "RHS value expected." ); goto error; } b = Lexer::Number; Lexer::GetNewline( True ); //-------------------------------------------------------------------------- // Read the matrix row. // { Int_T len; Array<Real_T> a; Array<Int_T> col; if( !GetRowData( val, len, a, col ) ) return False; FreeSingletonColumnRemoval( var, a, col, len, val, b, slOpt ); } return True; error: SkipToNextSection(); return False; }
Bool_T Postsolver::GetExplicitSlackAction( Int_T &nn, Int_T var ) { if( !Lexer::GetKeyword( "EXPL_SLACK" ) ) return False; Lexer::GetNewline( True ); nn--; Real_T bl = -INFINITY, bu = +INFINITY; Short_T rt = RT_UNDEFINED; Real_T l = -INFINITY, u = +INFINITY; Short_T vt = VTM_UNDEFINED; Real_T sl = 0.0; //-------------------------------------------------------------------------- // Read the row type and the row activity bounds. // if( !Lexer::GetSpace() ) { Error( "Premature end of the ACTION EXPL_SLACK section." ); return False; } if( Lexer::GetKeyword( "GE" ) ) rt = VT_NORM; else if( Lexer::GetKeyword( "LE" ) ) rt = VT_MI; else if( Lexer::GetKeyword( "EQ" ) ) rt = VT_FIXED; else if( Lexer::GetKeyword( "RG" ) ) rt = VT_BOUNDED; else { Error( "Unrecognized row type in presolver action file." ); goto error; } if( !Lexer::GetSpace() || !Lexer::GetNumeric() ) { Error( "Numeric value(s) expected." ); goto error; } switch( rt ) { case VT_NORM: bl = Lexer::Number; break; case VT_MI: bu = Lexer::Number; break; case VT_FIXED: bl = bu = Lexer::Number; break; case VT_BOUNDED: bl = Lexer::Number; break; #ifndef NDEBUG default: abort(); #endif } if( rt == RT_RNG ) { if( !Lexer::GetSpace() || !Lexer::GetNumeric() ) { Error( "Numeric value(s) expected." ); goto error; } bu = Lexer::Number; } Lexer::GetNewline( True ); //-------------------------------------------------------------------------- // Read the variable type and its simple bounds. // if( !Lexer::GetSpace() ) { Error( "Premature end of section." ); return False; } if( Lexer::GetKeyword( "FX" ) ) vt = VT_FIXED; else if( Lexer::GetKeyword( "UP" ) ) vt = VT_BOUNDED; else if( Lexer::GetKeyword( "PL" ) ) vt = VT_NORM; else if( Lexer::GetKeyword( "MI" ) ) vt = VT_MI; else { Error( "Unrecognized variable type in presolver action file." ); goto error; } if( !Lexer::GetSpace() || !Lexer::GetNumeric() ) { Error( "Numeric value(s) expected." ); goto error; } switch( vt ) { case VT_FIXED: l = u = Lexer::Number; break; case VT_BOUNDED: l = Lexer::Number; break; case VT_NORM: l = Lexer::Number; break; case VT_MI: u = Lexer::Number; break; #ifndef NDEBUG default: abort(); #endif } if( vt == VT_BOUNDED ) { if( !Lexer::GetSpace() || !Lexer::GetNumeric() ) { Error( "Numeric value(s) expected." ); goto error; } u = Lexer::Number; } Lexer::GetNewline( True ); //-------------------------------------------------------------------------- // Read the matrix row. // { Int_T len; Array<Real_T> a; Array<Int_T> col; if( !GetRowData( sl, len, a, col ) ) return False; ExplicitSlackRemoval( var, a, col, len, sl, vt, l, u, rt, bl, bu ); } return True; error: SkipToNextSection(); return False; }
bool CCaliData::GenerateTable(CIADataTable &cIADataTable, const CString& caliMethod) { //确定定制表格类型 m_tableType = caliMethod; //创建以峰高显示类型的表格 CStringArray ArrTopics, ArrTitles, ArrColWidth, ArrAlign; ArrTopics.Add(_T("icon_inf")); ArrTitles.Add(_T("i")); ArrColWidth.Add(_T("20")); ArrAlign.Add(_T("center|vcenter")); ArrTopics.Add(_T("NO")); ArrTitles.Add(_T("编号")); ArrColWidth.Add(_T("40")); ArrAlign.Add(_T("center|vcenter")); ArrTopics.Add(_T("ReserveTime")); ArrTitles.Add(_T("保留时间")); ArrColWidth.Add(_T("80")); ArrAlign.Add(_T("right|vcenter")); ArrTopics.Add(_T("ComponentName")); ArrTitles.Add(_T("组份名")); ArrColWidth.Add(_T("80")); ArrAlign.Add(_T("center|vcenter")); ArrTopics.Add(_T("Level")); ArrTitles.Add(_T("样品级别")); ArrColWidth.Add(_T("60")); ArrAlign.Add(_T("center|vcenter")); ArrTopics.Add(_T("Contents")); ArrTitles.Add(_T("含量")); ArrColWidth.Add(_T("100")); ArrAlign.Add(_T("right|vcenter")); if (m_tableType == _T("峰面积")) { ArrTopics.Add(_T("PeakArea")); ArrTitles.Add(_T("峰面积")); ArrColWidth.Add(_T("60")); ArrAlign.Add(_T("right|vcenter")); } else if (m_tableType == _T("峰高")) { ArrTopics.Add(_T("PeakHeight")); ArrTitles.Add(_T("峰高")); ArrColWidth.Add(_T("60")); ArrAlign.Add(_T("right|vcenter")); } else { ::AfxMessageBox(_T("究竟是峰面积还是峰高?")); return false; } ArrTopics.Add(_T("ResFactor")); ArrTitles.Add(_T("响应因子")); ArrColWidth.Add(_T("100")); ArrAlign.Add(_T("right|vcenter")); ArrTopics.Add(_T("IsReference")); ArrTitles.Add(_T("是否参比")); ArrColWidth.Add(_T("80")); ArrAlign.Add(_T("center|vcenter")); ArrTopics.Add(_T("IsInterior")); ArrTitles.Add(_T("是否内标")); ArrColWidth.Add(_T("80")); ArrAlign.Add(_T("center|vcenter")); ArrTopics.Add(_T("InteriorNo")); ArrTitles.Add(_T("内标编号")); ArrColWidth.Add(_T("80")); ArrAlign.Add(_T("center|vcenter")); ArrTopics.Add(_T("icon_del")); ArrTitles.Add(_T("删")); ArrColWidth.Add(_T("20")); ArrAlign.Add(_T("center|vcenter")); //创建列信息 if(!cIADataTable.SetColumns(ArrTopics, &ArrTitles)) { ::AfxMessageBox(_T("创建列信息失败")); return FALSE; } //增加列宽信息 for (int i=0; i<ArrTitles.GetSize(); ++i) { if(!cIADataTable.SetColumnInfo(ArrTopics.GetAt(i), XMLPROP_TAB_COL_WIDTH, ArrColWidth.GetAt(i))) { ::AfxMessageBox(_T("创建列宽失败")); return FALSE; } } //增加对齐信息 for (int i=0; i<ArrAlign.GetSize(); ++i) { if(!cIADataTable.SetColumnInfo(ArrTopics.GetAt(i), XMLPROP_TAB_COL_ALIGN, ArrAlign.GetAt(i))) { ::AfxMessageBox(_T("创建对齐方式失败")); return FALSE; } } // *********清除无用数据 ClearUnnecessaryCell(); //进行数据填充 const int itemNum = m_CaliItems.size(); for (int i=0; i<itemNum; ++i) { CStringArray arrItem; if (!GetRowData(i, arrItem)) { ::AfxMessageBox(_T("未取到对应行数据")); return false; } cIADataTable.AppendRow(arrItem); } //CString szWatch = cIADataTable.GetXMLString(); return true; }