void CMLineIndexTable::AdjustToText() { const JFontManager* fontMgr = GetFontManager(); JFont font = itsText->GetCurrentFont(); const JSize lineCount = itsText->IsEmpty() ? 0 : itsText->GetLineCount(); const JString lineCountStr = GetLongestLineText(lineCount); const JSize lineHeight = font.GetLineHeight(); const JSize lineNumberWidth = font.GetStringWidth(lineCountStr); SetColWidth(kBreakpointColumn, lineHeight); SetColWidth(kExecPointColumn, lineHeight); SetColWidth(kLineNumberColumn, lineNumberWidth + 2*kMarginWidth); SetAllRowHeights(lineHeight); const JSize origRowCount = GetRowCount(); if (origRowCount < lineCount) { AppendRows(lineCount - origRowCount, lineHeight); } else if (origRowCount > lineCount) { RemovePrevRows(origRowCount, origRowCount - lineCount); } const JCoordinate tableWidth = GetBoundsWidth(); const JCoordinate apWidth = GetApertureWidth(); if (tableWidth != apWidth) { AdjustSize(tableWidth-apWidth, 0); itsText->Place(GetFrameWidth(), 0); itsText->AdjustSize(apWidth-tableWidth, 0); } ScrollTo(0, itsVScrollbar->GetValue()); UpdateBreakpoints(); }
void GMFilterNameTable::GMFilterNameTableX() { AppendCols(1, kDefColWidth); AdjustColWidths(); const JFontManager* fm = GetFontManager(); itsRowHeight = fm->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()) + kRowHeightAdjust; const JSize count = itsFilters->GetElementCount(); AppendRows(count, itsRowHeight); AdjustButtons(); WantInput(kJFalse); ListenTo(itsNewButton); ListenTo(itsRemoveButton); const Atom dndName = GetDNDManager()->GetDNDSelectionName(); GetDisplay()->RegisterXAtom(kDragFilterXAtomName); }
JXTextMenuTable::JXTextMenuTable ( JXMenu* menu, JXTextMenuData* data, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXMenuTable(menu, data, enclosure, hSizing,vSizing, x,y, w,h), itsTextMenuData(data), itsHilightRow(0) { AppendCols(4); // checkbox/radio, image, text, submenu/shortcut AppendRows(itsTextMenuData->GetElementCount()); const_cast<JXTextMenuData*>(itsTextMenuData)->ConfigureTable(this); ListenTo(itsTextMenuData); }
//--------------------------------------------------------- bool CVIEW_Table_Control::_Set_Records(bool bSelection_To_Top) { BeginBatch(); //----------------------------------------------------- if( m_bSelOnly && m_pTable->Get_Selection_Count() <= 0 ) { m_bSelOnly = false; } int Difference, nRecords = m_bSelOnly ? m_pTable->Get_Selection_Count() : m_pTable->Get_Count(); if( (Difference = nRecords - GetNumberRows()) > 0 ) { AppendRows(Difference); } else if( Difference < 0 && (Difference = -Difference < GetNumberRows() ? -Difference : GetNumberRows()) > 0 ) { DeleteRows(0, Difference); } m_pRecords = (CSG_Table_Record **)SG_Realloc(m_pRecords, nRecords * sizeof(CSG_Table_Record *)); ClearSelection(); //----------------------------------------------------- if( m_bSelOnly ) { // #pragma omp parallel for for(int iRecord=0; iRecord<nRecords; iRecord++) { _Set_Record(iRecord, m_pTable->Get_Selection(iRecord)); } } else if( !bSelection_To_Top ) { // #pragma omp parallel for for(int iRecord=0; iRecord<nRecords; iRecord++) { _Set_Record(iRecord, m_pTable->Get_Record_byIndex(iRecord)); } } else // if( bSelection_To_Top && m_pTable->Get_Selection_Count() > 0 ) { for(int iRecord=0, iSel=0, iNoSel=m_pTable->Get_Selection_Count(); iRecord<nRecords && PROGRESSBAR_Set_Position(iRecord, nRecords); iRecord++) { CSG_Table_Record *pRecord = m_pTable->Get_Record_byIndex(iRecord); if( pRecord->is_Selected() ) { _Set_Record(iSel ++, pRecord); } else { _Set_Record(iNoSel++, pRecord); } } PROCESS_Set_Okay(); } //----------------------------------------------------- EndBatch(); _Update_Views(); return( true ); }
void CatheterCmdGrid::appendCommandRow() { cmd_count++; if (cmd_count >= GetNumberRows()) AppendRows(1); setRowReadOnly(cmd_count - 1, false); }
JXFSBindingTable::JXFSBindingTable ( JFSBindingList* list, JXTextButton* addButton, JXTextButton* removeButton, JXTextButton* duplicateButton, JXScrollbarSet* scrollbarSet, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXEditTable(1,1, scrollbarSet, enclosure, hSizing, vSizing, x, y, w, h), itsBindingList(list), itsAddButton(addButton), itsRemoveButton(removeButton), itsDuplicateButton(duplicateButton), itsTextInput(NULL) { // row height const JSize rowHeight = 2*kVMarginWidth + JMax( (GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()), (GetFontManager())->GetLineHeight(JGetMonospaceFontName(), kJDefaultMonoFontSize, JFontStyle())); SetDefaultRowHeight(rowHeight); // buttons ListenTo(itsAddButton); ListenTo(itsRemoveButton); ListenTo(itsDuplicateButton); // type menu itsTypeMenu = new JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10); assert( itsTypeMenu != NULL ); itsTypeMenu->Hide(); itsTypeMenu->SetToHiddenPopupMenu(kJTrue); itsTypeMenu->SetMenuItems(kTypeMenuStr); itsTypeMenu->SetUpdateAction(JXMenu::kDisableNone); ListenTo(itsTypeMenu); // regex for testing itsTestRegex = new JRegex; assert( itsTestRegex != NULL ); // data for (JIndex i=1; i<=kColCount; i++) { AppendCols(1, kInitColWidth[i-1]); } UpdateColWidths(); const JSize rowCount = itsBindingList->GetElementCount(); AppendRows(rowCount); UpdateButtons(); ListenTo(&(GetTableSelection())); }
//--------------------------------------------------------- bool CActive_Attributes_Control::Update_Table(void) { if( GetBatchCount() > 0 ) { return( false ); } BeginBatch(); //----------------------------------------------------- int Difference = (m_pTable->Get_Field_Count() - m_Field_Offset) - GetNumberCols(); if( Difference > 0 ) { AppendCols(Difference); } else if( (Difference = -Difference < GetNumberCols() ? -Difference : GetNumberCols()) > 0 ) { // here is (or was!?) a memory leak - solution: use own wxGridTableBase derived grid table class DeleteCols(0, Difference); } //----------------------------------------------------- for(int iCol=0, iField=m_Field_Offset; iField<m_pTable->Get_Field_Count(); iCol++, iField++) { SetColLabelValue(iCol, m_pTable->Get_Field_Name(iField)); switch( m_pTable->Get_Field_Type(iField) ) { default: case SG_DATATYPE_Byte: case SG_DATATYPE_Char: case SG_DATATYPE_String: case SG_DATATYPE_Date: case SG_DATATYPE_Binary: SetColFormatCustom(iCol, wxGRID_VALUE_STRING); break; case SG_DATATYPE_Bit: case SG_DATATYPE_Word: case SG_DATATYPE_Short: case SG_DATATYPE_DWord: case SG_DATATYPE_Int: case SG_DATATYPE_ULong: case SG_DATATYPE_Long: case SG_DATATYPE_Color: SetColFormatNumber(iCol); break; case SG_DATATYPE_Float: case SG_DATATYPE_Double: SetColFormatFloat(iCol); break; } } //----------------------------------------------------- if( (Difference = m_pTable->Get_Count() - GetNumberRows()) > 0 ) { AppendRows(Difference); } else if( Difference < 0 && (Difference = -Difference < GetNumberRows() ? -Difference : GetNumberRows()) > 0 ) { DeleteRows(0, Difference); } //------------------------------------------------- for(int iRecord=0; iRecord<m_pTable->Get_Count(); iRecord++) { _Set_Record(iRecord); } //----------------------------------------------------- if( GetNumberCols() > 0 && GetNumberRows() > 0 ) { SetRowLabelSize(wxGRID_AUTOSIZE); if( m_Field_Offset ) // feature attributes { if( GetClientSize().x > GetRowLabelSize() ) { SetColSize(0, GetClientSize().x - GetRowLabelSize()); } } else // grid cell values { AutoSizeColumns(); } } Enable(GetNumberRows() > 0); m_pTable->Set_Modified(false); //----------------------------------------------------- EndBatch(); return( true ); }
bool BigGridTable::writeEvent( VscpRXObj *pRecord, bool bUpdate ) { // Validate pointer //if ( NULL == pRecord ) return false; // File should be open //if ( !m_temFile.IsOpened() ) return false; // Go to end //m_temFile.SeekEnd( 0 ); // Write record //if ( sizeof(VscpRecord) != m_temFile.Write( &pRecord->m_event, sizeof(VscpRecord) ) ) { // return false; //} m_rxList.Append( pRecord ); if ( bUpdate ) { // Add one row to the grid AppendRows( 1 ); //wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1); //GetView()->ProcessTableMessage(msg); //if ( GetView() ) //{ // wxGridTableMessage msg( this, // wxGRIDTABLE_NOTIFY_ROWS_APPENDED, // 1 ); // GetView()->ProcessTableMessage( msg ); //} // If selected mow the added row into seight if ( g_Config.m_bAutoscollRcv ) { GetView()->MakeCellVisible( m_rxList.GetCount()-1, 0 ); } /* if ( VSCP_EVENT_DIRECTION_RX == pRecord->m_nDir ) { for ( int i=0; i<10; i++ ) { GetView()->SetCellTextColour( m_rxList.GetCount()-1, i, g_Config.m_VscpRcvFrameRxTextColour ); GetView()->SetCellBackgroundColour( m_rxList.GetCount()-1, i, g_Config.m_VscpRcvFrameRxBgColour ); } } else { for ( int i=0; i<10; i++ ) { GetView()->SetCellTextColour( m_rxList.GetCount()-1, i, g_Config.m_VscpRcvFrameTxTextColour ); GetView()->SetCellBackgroundColour( m_rxList.GetCount()-1, i, g_Config.m_VscpRcvFrameTxBgColour ); } } // RX/TX GetView()->SetCellAlignment( m_rxList.GetCount()-1, 0, wxALIGN_CENTRE, wxALIGN_CENTRE ); // Class GetView()->SetCellAlignment( m_rxList.GetCount()-1, 3, wxALIGN_CENTRE, wxALIGN_CENTRE ); // Type GetView()->SetCellAlignment( m_rxList.GetCount()-1, 4, wxALIGN_CENTRE, wxALIGN_CENTRE ); // Head GetView()->SetCellAlignment( m_rxList.GetCount()-1, 5, wxALIGN_CENTRE, wxALIGN_CENTRE ); // Count GetView()->SetCellAlignment( m_rxList.GetCount()-1, 6, wxALIGN_CENTRE, wxALIGN_CENTRE ); */ GetView()->ForceRefresh(); } return true; }
WContainerWidget * WSVFlexTable::AppendRowsContent(int nRow, int nColumn, int nColumnCount, string strLabel, string strDes, string strError,bool noBlank) { //取出指定栏目的Table WTable * pRowTable = NULL; WContainerWidget * pParentCell = NULL; // if(nRow > m_pListRowTable.size()) { for (unsigned i = nRow; i > m_pListRowTable.size() ; --i) { AppendRows(""); //此情况应该无效或不会出现, 暂时先这样处理 } } else { // } //(nColumn * 2) //nColumnCount == 2 则为 50% pRowTable = m_pListRowTable[nRow]; pRowTable->setStyleClass("table_data_input_rows"); //标题 WText if(noBlank) strLabel += "<font color=red>*</font>"; new WText(strLabel, pRowTable->elementAt(nRow, (nColumn * 2))); strcpy(pRowTable->elementAt(nRow, (nColumn * 2))->contextmenu_,"nowrap"); pRowTable->elementAt(nRow, (nColumn * 2))->setStyleClass("table_data_input_text"); //输入控件 pParentCell = pRowTable->elementAt(nRow, (nColumn * 2) + 1); //pRowTable->elementAt(nRow, (nColumn * 2) + 1)->setStyleClass("table_data_input_text"); strcpy(pRowTable->elementAt(nRow, (nColumn * 2) + 1)->contextmenu_,"nowrap"); //帮助 WText if(strDes != "") { m_pListHelpText.push_back(new WText(strDes, pRowTable->elementAt(nRow + 1, (nColumn * 2) + 1))); if(nColumnCount == 2) pRowTable->elementAt(nRow + 1, (nColumn * 2) + 1)->resize(WLength(50,WLength::Percentage), WLength()); //strcpy(pRowTable->elementAt(nRow + 1, (nColumn * 2) + 1)->contextmenu_,"nowrap"); pRowTable->elementAt(nRow + 1, (nColumn * 2) + 1)->setStyleClass("table_data_input_des"); } //错误信息 WText if(strError != "") { m_pListErrorText.push_back(new WText(strError, pRowTable->elementAt(nRow + 2, (nColumn * 2) + 1))); if(nColumnCount == 2) pRowTable->elementAt(nRow + 2, (nColumn * 2) + 1)->resize(WLength(50,WLength::Percentage), WLength()); //strcpy(pRowTable->elementAt(nRow + 2, (nColumn * 2) + 1)->contextmenu_,"nowrap"); pRowTable->elementAt(nRow + 2, (nColumn * 2) + 1)->setStyleClass("table_data_input_error"); } return pParentCell; }
//添加栏目内容-->标题、输入控件、帮助、错误信息 (多项怎么办?输入控件怎么定位?帮助、错误信息必须放到统一的数组中?)--->由此函数解决 WContainerWidget * WSVFlexTable::AppendRowsContent(int nRow, string strLabel, string strDes, string strError, bool noBlank) { //取出指定栏目的Table WTable * pRowTable = NULL; WContainerWidget * pParentCell = NULL; // if(nRow > m_pListRowTable.size()) { for (unsigned i = nRow; i > m_pListRowTable.size() ; --i) { AppendRows(""); //此情况应该无效或不会出现, 暂时先这样处理 } } else { // } pRowTable = m_pListRowTable[nRow]; int iLast = pRowTable->numRows(); //标题 WText iLast++; if (noBlank) { strLabel += "<font color=red>*</font>"; } new WText(strLabel, pRowTable->elementAt(iLast, 0)); strcpy(pRowTable->elementAt(iLast, 0)->contextmenu_,"nowrap"); pRowTable->elementAt(iLast, 0)->setStyleClass("width120"); //输入控件 pParentCell = pRowTable->elementAt(iLast, 1); strcpy(pRowTable->elementAt(iLast, 1)->contextmenu_,"nowrap"); //pRowTable->elementAt(iLast, 1)->setStyleClass("table_gruop_item"); //帮助 WText if(strDes != "") { iLast++; m_pListHelpText.push_back(new WText(strDes, pRowTable->elementAt(iLast, 1))); //strcpy(pRowTable->elementAt(iLast, 1)->contextmenu_,"nowrap"); pRowTable->elementAt(iLast, 1)->setStyleClass("table_data_input_des"); } //错误信息 WText if(strError != "") { iLast++; m_pListErrorText.push_back(new WText(strError, pRowTable->elementAt(iLast, 1))); strcpy(pRowTable->elementAt(iLast, 1)->contextmenu_,"nowrap"); pRowTable->elementAt(iLast, 1)->setStyleClass("table_data_input_error"); } return pParentCell; }
CBCommandTable::CBCommandTable ( const CBCommandManager::CmdList& cmdList, JXTextButton* addCmdButton, JXTextButton* removeCmdButton, JXTextButton* duplicateCmdButton, JXScrollbarSet* scrollbarSet, JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXEditTable(1,1, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h) { itsTextInput = NULL; itsDNDRowIndex = 0; itsCommandXAtom = (GetDisplay())->RegisterXAtom(CBCommandSelection::GetCommandXAtomName()); // font (CBGetPrefsManager())->GetDefaultFont(&itsFontName, &itsFontSize); const JSize rowHeight = 2*kVMarginWidth + JMax( (GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()), (GetFontManager())->GetLineHeight(itsFontName, itsFontSize, JFontStyle())); SetDefaultRowHeight(rowHeight); // buttons itsAddCmdButton = addCmdButton; itsRemoveCmdButton = removeCmdButton; itsDuplicateCmdButton = duplicateCmdButton; ListenTo(itsAddCmdButton); ListenTo(itsRemoveCmdButton); ListenTo(itsDuplicateCmdButton); // type menu itsOptionsMenu = new JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10); assert( itsOptionsMenu != NULL ); itsOptionsMenu->SetToHiddenPopupMenu(); itsOptionsMenu->SetMenuItems(kOptionsMenuStr); itsOptionsMenu->SetUpdateAction(JXMenu::kDisableNone); ListenTo(itsOptionsMenu); // base path CBProjectDocument* doc = NULL; if ((CBGetDocumentManager())->GetActiveProjectDocument(&doc)) { itsBasePath = doc->GetFilePath(); } // data itsCmdList = new CBCommandManager::CmdList(cmdList); assert( itsCmdList != NULL ); FinishCmdListCopy(itsCmdList); for (JIndex i=1; i<=kColCount; i++) { AppendCols(1, kInitColWidth[i-1]); } AppendRows(itsCmdList->GetElementCount()); UpdateButtons(); ListenTo(&(GetTableSelection())); }
void CBSymbolTable::RebuildTable() { (JXGetApplication())->DisplayBusyCursor(); const JPoint scrollPt = (GetAperture()).topLeft(); ClearSelection(); itsKeyBuffer.Clear(); itsMaxStringWidth = 0; if (itsVisibleListLockedFlag) { const JSize count = itsVisibleList->GetElementCount(); for (JIndex i=1; i<=count; i++) { const JIndex j = itsVisibleList->GetElement(i); const JString* signature; itsSymbolList->GetSignature(j, &signature); CBLanguage lang; CBSymbolList::Type type; CalcColWidths(itsSymbolList->GetSymbol(j, &lang, &type), signature); } } else if (itsNameFilter != NULL || itsNameLiteral != NULL) { itsVisibleList->RemoveAll(); const JSize symbolCount = itsSymbolList->GetElementCount(); for (JIndex i=1; i<=symbolCount; i++) { CBLanguage lang; CBSymbolList::Type type; const JString& symbolName = itsSymbolList->GetSymbol(i, &lang, &type); const JString* signature; itsSymbolList->GetSignature(i, &signature); if (/* (CBGetSymbolTypeList())->IsVisible(type) && */ ((itsNameFilter != NULL && itsNameFilter->Match(symbolName)) || (itsNameLiteral != NULL && symbolName.Contains(*itsNameLiteral))) ) { itsVisibleList->AppendElement(i); CalcColWidths(symbolName, signature); } } } else // optimize because scanning 1e5 symbols takes a while! { const JSize symbolCount = itsSymbolList->GetElementCount(); if (itsVisibleList->GetElementCount() > symbolCount) { itsVisibleList->RemoveNextElements( symbolCount+1, itsVisibleList->GetElementCount() - symbolCount); } while (itsVisibleList->GetElementCount() < symbolCount) { itsVisibleList->AppendElement(itsVisibleList->GetElementCount()+1); } } const JSize rowCount = itsVisibleList->GetElementCount(); if (GetRowCount() < rowCount) { AppendRows(rowCount - GetRowCount()); } else if (GetRowCount() > rowCount) { RemoveNextRows(rowCount+1, GetRowCount() - rowCount); } AdjustColWidths(); ScrollTo(scrollPt); Refresh(); }
void ctlVarWindow::addVar( wxString name, wxString value, wxString type, bool readOnly ) { // If this is a 'hidden' variable, just ignore it if( m_hiddenNames.find( name ) != m_hiddenNames.end()) return; if( m_hiddenTypes.find( type ) != m_hiddenTypes.end()) return; if( m_cells == NULL ) { // This is the first variable we're adding to this grid, // layout the grid and set the column headers. m_cells = new wsCellHash; } // Try to find an existing grid cell for this variable... wxString key( name ); wsCellHash::iterator cell = m_cells->find( key ); if( cell == m_cells->end()) { // Can't find this variable in the grid, go ahead and add it gridCell newCell; newCell.m_row = m_cells->size(); newCell.m_type = type; newCell.m_value = value; AppendRows( 1 ); SetRowLabelValue( newCell.m_row, key ); SetCellValue( newCell.m_row, COL_NAME, key ); SetCellValue( newCell.m_row, COL_TYPE, type ); SetCellValue( newCell.m_row, COL_VALUE, value ); SetCellFont( newCell.m_row, COL_NAME, m_nameFont ); SetReadOnly( newCell.m_row, COL_NAME, true ); SetReadOnly( newCell.m_row, COL_TYPE, true ); SetReadOnly( newCell.m_row, COL_VALUE, readOnly ); (*m_cells)[key] = newCell; } else { // This variable is already in the grid, update the value // and hilite it so the user knows that it has changed. cell->second.m_value = value; if( GetCellValue( cell->second.m_row, COL_VALUE ).IsSameAs( value )) SetCellTextColour( cell->second.m_row, COL_VALUE, *wxBLACK ); else SetCellTextColour( cell->second.m_row, COL_VALUE, *wxRED ); SetCellValue( cell->second.m_row, COL_VALUE, value ); // FIXME: why is this part conditional? // FIXME: why do we need this code? can the type ever change? if( GetCellValue( cell->second.m_row, COL_TYPE) == wxT( "" )) { SetCellValue( cell->second.m_row, COL_TYPE, type ); } } // AutoSizeColumns( false ); }
void CatheterGrid::addGridRow(bool readOnly) { AppendRows(1); formatDefaultRow(GetNumberRows() - 1); setRowReadOnly(GetNumberRows() - 1, readOnly); }