void CDlgAllCheckOut::AddRow(INT_PTR nIndex, ReturnInfo &rInfo) { CBCGPGridRow* pRow = CreateNewRow(); pRow->SetData(nIndex); if (rInfo.bLocal) { pRow->GetItem(0)->SetValue(rInfo.LocalInfo.GetSerialNum().GetString()); pRow->GetItem(1)->SetValue(rInfo.LocalInfo.GetName().GetString()); pRow->GetItem(2)->SetValue(CNetBarConfig::GetInstance()->GetUserClassName(rInfo.LocalInfo.GetClassId()).GetString()); pRow->GetItem(3)->SetValue(rInfo.LocalInfo.GetTermId().GetString()); CString strTmp; UINT nTmp = CIBAHelpper::RoundMoney(rInfo.LocalInfo.GetReturnAmount(), CNetBarConfig::GetInstance()->GetRoundType()); strTmp.Format(_T("%.2f"), nTmp / 100.0); pRow->GetItem(4)->SetValue(strTmp.GetString()); if ( rInfo.bLocalReturned ) { pRow->GetItem(5)->SetValue(_T("已退款")); } else { CBCGPGridItem* pItem = new CBCGPGridButtonItem(_T("退款"), GirdButtonId); pRow->ReplaceItem(6, pItem); } m_listCtrl.InsertItem(nIndex,_T("")); m_listCtrl.SetItemText(nIndex,0,rInfo.LocalInfo.GetSerialNum().GetString()); m_listCtrl.SetItemText(nIndex,1,rInfo.LocalInfo.GetName().GetString()); m_listCtrl.SetItemText(nIndex,2,CNetBarConfig::GetInstance()->GetUserClassName(rInfo.LocalInfo.GetClassId()).GetString()); m_listCtrl.SetItemText(nIndex,3,rInfo.LocalInfo.GetTermId().GetString()); m_listCtrl.SetItemText(nIndex,4,strTmp.GetString()); if ( rInfo.bLocalReturned ) { m_listCtrl.SetItemText(nIndex,5,_T("已退款")); } else { m_listCtrl.SetItem(nIndex,6,_T("退款"),NS_COMMON::CGxxListCtrl::GLC_Button); } } else { CCheckOutinfo& CheckOutinfo = rInfo.CheckOutInfo; pRow->GetItem(0)->SetValue(CheckOutinfo.GetSerialNum().GetString()); pRow->GetItem(1)->SetValue(CheckOutinfo.GetUserName().GetString()); pRow->GetItem(2)->SetValue(CheckOutinfo.GetClassName().GetString()); pRow->GetItem(3)->SetValue(CheckOutinfo.GetTerminalId().GetString()); CString strTmp; UINT nTmp = CIBAHelpper::RoundMoney(CheckOutinfo.GetBalanceMoney(), CNetBarConfig::GetInstance()->GetRoundType()); strTmp.Format(_T("%.2f"), nTmp / 100.0); pRow->GetItem(4)->SetValue(strTmp.GetString()); if (CheckOutinfo.GetReturnState() == 1) { pRow->GetItem(5)->SetValue(_T("已退款")); } else { CBCGPGridItem* pItem = new CBCGPGridButtonItem(_T("退款"), GirdButtonId); pRow->ReplaceItem(6, pItem); } m_listCtrl.InsertItem(nIndex,_T("")); m_listCtrl.SetItemText(nIndex,0,CheckOutinfo.GetSerialNum().GetString()); m_listCtrl.SetItemText(nIndex,1,CheckOutinfo.GetUserName().GetString()); m_listCtrl.SetItemText(nIndex,2,CheckOutinfo.GetClassName().GetString()); m_listCtrl.SetItemText(nIndex,3,CheckOutinfo.GetTerminalId().GetString()); m_listCtrl.SetItemText(nIndex,4,strTmp.GetString()); if ( CheckOutinfo.GetReturnState() == 1 ) { m_listCtrl.SetItemText(nIndex,5,_T("已退款")); } else { m_listCtrl.SetItem(nIndex,6,_T("退款"),NS_COMMON::CGxxListCtrl::GLC_Button); } } //CBCGPGridCheckItem* pItem = new CBCGPGridCheckItem(CheckOutinfo.GetReturnState() > 0 ? true : false); //pRow->ReplaceItem(7, pItem); m_GridCtrl.AddRow(pRow, FALSE); }
/** * DevEditPanel */ DevEditPanel::DevEditPanel(SocDevRef ref, QWidget *parent) :QWidget(parent), m_ref(ref) { m_name_group = new QGroupBox("Name", this); m_name_edit = new QLineEdit(this); m_name_edit->setText(QString::fromStdString(ref.GetDev().name)); QVBoxLayout *name_group_layout = new QVBoxLayout; name_group_layout->addWidget(m_name_edit); m_name_group->setLayout(name_group_layout); m_long_name_group = new QGroupBox("Long Name", this); m_long_name_edit = new QLineEdit(this); m_long_name_edit->setText(QString::fromStdString(ref.GetDev().long_name)); QVBoxLayout *long_name_group_layout = new QVBoxLayout; long_name_group_layout->addWidget(m_long_name_edit); m_long_name_group->setLayout(long_name_group_layout); m_version_group = new QGroupBox("Version", this); m_version_edit = new QLineEdit(this); m_version_edit->setText(QString::fromStdString(ref.GetDev().version)); QVBoxLayout *version_group_layout = new QVBoxLayout; version_group_layout->addWidget(m_version_edit); m_version_group->setLayout(version_group_layout); QVBoxLayout *name_ver_layout = new QVBoxLayout; name_ver_layout->addWidget(m_name_group); name_ver_layout->addWidget(m_long_name_group); name_ver_layout->addWidget(m_version_group); name_ver_layout->addStretch(); m_instances_table = new QTableWidget(this); m_instances_table->setRowCount(ref.GetDev().addr.size() + 1); m_instances_table->setColumnCount(3); for(size_t row = 0; row < ref.GetDev().addr.size(); row++) FillRow(row, ref.GetDev().addr[row]); CreateNewRow(ref.GetDev().addr.size()); m_instances_table->setHorizontalHeaderItem(0, new QTableWidgetItem("")); m_instances_table->setHorizontalHeaderItem(1, new QTableWidgetItem("Name")); m_instances_table->setHorizontalHeaderItem(2, new QTableWidgetItem("Address")); m_instances_table->verticalHeader()->setVisible(false); m_instances_table->resizeColumnsToContents(); m_instances_table->horizontalHeader()->setStretchLastSection(true); m_instances_table->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_instances_group = new QGroupBox("Instances", this); QHBoxLayout *instances_group_layout = new QHBoxLayout; instances_group_layout->addWidget(m_instances_table); m_instances_group->setLayout(instances_group_layout); QHBoxLayout *top_layout = new QHBoxLayout; top_layout->addWidget(m_instances_group); top_layout->addLayout(name_ver_layout); top_layout->addStretch(); m_desc_group = new QGroupBox("Description", this); QHBoxLayout *group_layout = new QHBoxLayout; m_desc_edit = new MyTextEditor(this); m_desc_edit->SetTextHtml(QString::fromStdString(ref.GetDev().desc)); group_layout->addWidget(m_desc_edit); m_desc_group->setLayout(group_layout); QVBoxLayout *layout = new QVBoxLayout; layout->addLayout(top_layout, 0); layout->addWidget(m_desc_group, 1); setLayout(layout); SocFieldItemDelegate *m_table_delegate = new SocFieldItemDelegate(this); QItemEditorFactory *m_table_edit_factory = new QItemEditorFactory(); SocFieldEditorCreator *m_table_edit_creator = new SocFieldEditorCreator(); m_table_edit_factory->registerEditor(QVariant::UInt, m_table_edit_creator); m_table_delegate->setItemEditorFactory(m_table_edit_factory); m_instances_table->setItemDelegate(m_table_delegate); connect(m_instances_table, SIGNAL(cellActivated(int,int)), this, SLOT(OnInstActivated(int,int))); connect(m_instances_table, SIGNAL(cellChanged(int,int)), this, SLOT(OnInstChanged(int,int))); connect(m_name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnNameEdited(const QString&))); connect(m_long_name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnLongNameEdited(const QString&))); connect(m_version_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnVersionEdited(const QString&))); connect(m_desc_edit, SIGNAL(OnTextChanged()), this, SLOT(OnDescEdited())); }
void CStatisGridCtrl::AddEmptyRow () { AddRow (CreateNewRow (), TRUE); }
/** * FieldEditPanel */ FieldEditPanel::FieldEditPanel(SocFieldRef ref, QWidget *parent) :QWidget(parent), m_ref(ref) { m_name_group = new QGroupBox("Name", this); m_name_edit = new QLineEdit(this); m_name_edit->setText(QString::fromStdString(ref.GetField().name)); QVBoxLayout *name_group_layout = new QVBoxLayout; name_group_layout->addWidget(m_name_edit); m_name_group->setLayout(name_group_layout); m_bitrange_group = new QGroupBox("Bit Range", this); m_bitrange_edit = new QLineEdit(this); const soc_reg_field_t& field = ref.GetField(); QString bits_str; if(field.first_bit == field.last_bit) bits_str.sprintf("%d", field.first_bit); else bits_str.sprintf("%d:%d", field.last_bit, field.first_bit); m_bitrange_edit->setText(bits_str); m_bitrange_edit->setValidator(new SocBitRangeValidator(m_bitrange_edit)); QVBoxLayout *bitrange_group_layout = new QVBoxLayout; bitrange_group_layout->addWidget(m_bitrange_edit); m_bitrange_group->setLayout(bitrange_group_layout); m_desc_group = new QGroupBox("Description", this); QHBoxLayout *group_layout = new QHBoxLayout; m_desc_edit = new MyTextEditor(this); m_desc_edit->SetTextHtml(QString::fromStdString(ref.GetField().desc)); group_layout->addWidget(m_desc_edit); m_desc_group->setLayout(group_layout); m_value_group = new QGroupBox("Values", this); QHBoxLayout *value_layout = new QHBoxLayout; m_value_table = new QTableWidget(this); m_value_table->setRowCount(ref.GetField().value.size() + 1); m_value_table->setColumnCount(FieldValueNrColumns); for(size_t row = 0; row < ref.GetField().value.size(); row++) FillRow(row, ref.GetField().value[row]); CreateNewRow(ref.GetField().value.size()); m_value_table->setHorizontalHeaderItem(FieldValueIconColumn, new QTableWidgetItem("")); m_value_table->setHorizontalHeaderItem(FieldValueNameColumn, new QTableWidgetItem("Name")); m_value_table->setHorizontalHeaderItem(FieldValueValueColumn, new QTableWidgetItem("Value")); m_value_table->setHorizontalHeaderItem(FieldValueDescColumn, new QTableWidgetItem("Description")); m_value_table->verticalHeader()->setVisible(false); m_value_table->horizontalHeader()->setStretchLastSection(true); value_layout->addWidget(m_value_table); m_value_group->setLayout(value_layout); QHBoxLayout *line_layout = new QHBoxLayout; line_layout->addWidget(m_name_group); line_layout->addWidget(m_bitrange_group); line_layout->addStretch(); QVBoxLayout *left_layout = new QVBoxLayout; left_layout->addLayout(line_layout); left_layout->addWidget(m_desc_group); left_layout->addWidget(m_value_group, 1); UpdateDelegates(); connect(m_name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnNameEdited(const QString&))); connect(m_desc_edit, SIGNAL(OnTextChanged()), this, SLOT(OnDescEdited())); connect(m_value_table, SIGNAL(cellActivated(int,int)), this, SLOT(OnValueActivated(int,int))); connect(m_value_table, SIGNAL(cellChanged(int,int)), this, SLOT(OnValueChanged(int,int))); connect(m_bitrange_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnBitRangeEdited(const QString&))); setLayout(left_layout); }
//********************************************************************* BOOL CCxNDArrayDimGrid::Init( CRect& rc, CWnd * pParent ) { if ( IsWindow(m_hWnd) ) return FALSE; Create (WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, rc, pParent, ID_NAE_ARRAY_DIM); EnableColumnAutoSize (FALSE); SetSingleSel (TRUE); EnableGroupByBox (FALSE); SetReadOnly (FALSE); SetWholeRowSel (FALSE); EnableHeader (TRUE, 0); m_nBaseHeight = 20; // Set grid tab order (first): SetWindowPos (&CWnd::wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // SetSelectionBorder(FALSE); //m_bGridItemBorders = TRUE; //m_bHighlightActiveItem = FALSE; //m_bDrawFocusRect = FALSE; //m_bSelectionBorder = FALSE; CBCGPGridColors colors; colors.m_clrBackground = g_crStructTreeClientBg; // Grid background color //colors.m_clrText; // Grid foreground color //colors.m_clrHeader; // H foreground color //colors.m_EvenColors; // Even rows color //colors.m_OddColors; // Odd rows color //colors.m_GroupColors; // Group colors colors.m_GroupSelColors.m_clrBackground = g_crStructTreeSelItemBg; // Selected group colors colors.m_SelColors.m_clrBackground = g_crStructTreeSelItemBg; // Selected rows color colors.m_HeaderColors.m_clrBackground = g_crStructTreeHeaderBg; // Header item color //colors.m_HeaderSelColors; // Selected header item color colors.m_LeftOffsetColors.m_clrBackground = g_crStructTreeClientBg; // Left offset colors //colors.m_clrHorzLine = g_crStructTreeClientBg; // Grid horizontal line text //colors.m_clrVertLine = g_crStructTreeClientBg; // Grid vertical line text //colors.m_clrPreviewText; // Description text color SetColorTheme (colors); //SetSelectionBorderForActiveItem(FALSE); //SetSelectionBorder(FALSE); ////////////////////////////////////////////////////////////////////////// CString str; int nColCnt = 0; int nRowCnt = 0; CCxNDArrayDimItem* pItem = NULL; CCxNDArrayDimRow * pRow = NULL; nColCnt = sizeof( arrDimColCaption ) / sizeof( LPCTSTR ); for (int i=0; i<nColCnt; i++) { InsertColumn (i, arrDimColCaption[i], arrDimColWidth[i]); } if ( m_pArrayData != NULL ) { nRowCnt = m_pArrayData->GetDimCount(); for ( int i=0; i<nRowCnt; i++ ) { //if ( nRowCnt <= 2 ) //{ // break; //} pRow = CreateNewRow (); pRow->AllowSubItems (FALSE); for (int col = 0; col < nColCnt; col++) { switch (col) { case COL_DIM_INDEX: case COL_DIM_TYPE: case COL_DIM_VALUE: pRow->GetItem(col)->AllowEdit(FALSE); break; default: break; } } str.Format("%d", i); pRow->GetItem (COL_DIM_INDEX)->SetValue( (LPCTSTR)str ); CString strSel; switch (i) { case 0: strSel = "Row"; break; case 1: strSel = "Column"; break; //case 2: // strSel = "Column"; break; default: strSel = "Index"; break; } pItem = new CCxNDArrayDimItem ( (LPCTSTR)strSel ); if ( nRowCnt > 0 ) pItem->AddOption ( "Row", 1 ); if ( nRowCnt > 1 ) pItem->AddOption ( "Column", 1 ); if ( nRowCnt > 2 ) pItem->AddOption ( "Index", 1 ); pRow->ReplaceItem (COL_DIM_TYPE, pItem); if ( nRowCnt <= 2 ) { pRow->GetItem( COL_DIM_TYPE )->Enable(FALSE); pRow->GetItem( COL_DIM_TYPE )->AllowEdit(FALSE); } pItem = new CCxNDArrayDimItem ( 0 ); pItem->EnableSpinControl(TRUE, 0, m_pArrayData->GetDataCount( nRowCnt-i-1 ) - 1 ); pRow->ReplaceItem (COL_DIM_VALUE, pItem); switch (i) { case 2: //row col case 1: pRow->GetItem( COL_DIM_VALUE )->Enable( FALSE ); break; default: break; } AddRow (pRow, FALSE); } //if ( nRowCnt == 2 ) //{ // GetRow(0)->GetItem(COL_DIM_TYPE)->Enable(FALSE); // GetRow(0)->GetItem(COL_DIM_VALUE)->Enable(FALSE); //} //if ( nRowCnt == 1 ) //{ // GetRow(0)->GetItem(COL_DIM_TYPE)->Enable(FALSE); // GetRow(0)->GetItem(COL_DIM_VALUE)->Enable(FALSE); // GetRow(1)->GetItem(COL_DIM_TYPE)->Enable(FALSE); // GetRow(1)->GetItem(COL_DIM_VALUE)->Enable(FALSE); // GetRow(2)->GetItem(COL_DIM_TYPE)->Enable(FALSE); // GetRow(2)->GetItem(COL_DIM_VALUE)->Enable(FALSE); //} } m_nButtonWidth = 20; AdjustLayout(); return TRUE; }