48#include <wx/filedlg.h>
49#include <wx/filename.h>
52#include <wx/textdlg.h>
55#define COLUMN_MARGIN 4
57#define COLUMN_MARGIN 15
73 VIEW_CONTROLS_GRID_TRICKS(
WX_GRID* aGrid ) :
79 void doPopupSelection( wxCommandEvent& aEvent )
override
82 m_grid->PostSizeEvent();
101 int row =
m_grid->GetGridCursorRow();
102 int col =
m_grid->GetGridCursorCol();
104 wxMenuItem* revertMenu = aMenu.Append( MYID_REVERT_ROW,
_(
"Revert Row" ),
105 _(
"Revert the fields in this row" ) );
106 wxMenuItem* clearMenu = aMenu.Append( MYID_CLEAR_CELL,
_(
"Clear Cell" ),
107 _(
"Clear the cell value" ) );
108 aMenu.AppendSeparator();
110 if( row >= 0 && col >= 0 )
113 clearMenu->Enable(
m_grid->IsEditable() &&
m_dataModel->CanClearCell( row, col ) );
117 revertMenu->Enable(
false );
118 clearMenu->Enable(
false );
127 int row =
m_grid->GetGridCursorRow();
128 int col =
m_grid->GetGridCursorCol();
130 if( aEvent.GetId() == MYID_REVERT_ROW )
132 if(
m_grid->CommitPendingChanges(
false ) )
142 else if( aEvent.GetId() == MYID_CLEAR_CELL )
144 if(
m_grid->CommitPendingChanges(
false ) )
213 wxGridCellAttr* attr =
new wxGridCellAttr;
214 attr->SetReadOnly(
true );
217 attr =
new wxGridCellAttr;
218 attr->SetRenderer(
new wxGridCellBoolRenderer() );
220 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
223 attr =
new wxGridCellAttr;
224 attr->SetRenderer(
new wxGridCellBoolRenderer() );
226 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
232 m_filter->SetDescriptiveText(
_(
"Filter" ) );
234 m_grid->EnableCursorRowColumnHighlight();
300 [&]() -> std::pair<int, int>
311 if( aInputFileName.IsEmpty() )
312 return wxEmptyString;
314 wxFileName fn( aInputFileName );
317 return fn.GetFullPath();
331 aPreset.fieldsOrdered.clear();
338 field.
name = fieldName;
339 field.
show = !fieldName.StartsWith( wxT(
"__" ), &field.
name );
349 aPreset.fieldsOrdered.emplace_back( field );
397 if( modelField.show )
404 if( modelField.groupBy )
414 bool modified =
false;
442 if( aSaveCurrentSettings &&
m_cfgBomSettings.m_BomFmtSettings != fmtSettings )
454 return ConvertDialogToPixels( wxSize( 600, 300 ) );
460 m_grid->Connect( wxEVT_GRID_RANGE_SELECTED,
468 m_grid->Disconnect( wxEVT_GRID_RANGE_SELECTED,
482 std::set<int> selectedRows;
484 wxGridCellCoordsArray topLeft =
m_grid->GetSelectionBlockTopLeft();
485 wxGridCellCoordsArray bottomRight =
m_grid->GetSelectionBlockBottomRight();
487 for(
size_t i = 0; i < topLeft.size(); ++i )
489 for(
int row = topLeft[i].GetRow(); row <= bottomRight[i].GetRow(); ++row )
490 selectedRows.insert( row );
493 wxGridCellCoordsArray selectedCells =
m_grid->GetSelectedCells();
495 for(
size_t i = 0; i < selectedCells.size(); ++i )
496 selectedRows.insert( selectedCells[i].GetRow() );
498 for(
int row :
m_grid->GetSelectedRows() )
499 selectedRows.insert( row );
501 int cursorRow =
m_grid->GetGridCursorRow();
503 if( selectedRows.empty() && cursorRow >= 0 && cursorRow <
getDataModel()->GetNumberRows() )
504 selectedRows.insert( cursorRow );
512 std::set<KIID_PATH> selectedItemKeys;
517 selectedItemKeys.insert( key );
520 return selectedItemKeys;
526 if( aItemKeys.empty() )
531 bool firstSelection =
true;
533 for(
int row = 0; row <
getDataModel()->GetNumberRows(); ++row )
537 if( aItemKeys.count( key ) )
539 m_grid->SelectRow( row,
true );
543 m_grid->SetGridCursor( row,
m_grid->GetGridCursorCol() );
544 firstSelection =
false;
563 [
this, sidebarCollapsed, sashPosition, variantSashPosition]()
565 if( sidebarCollapsed )
588 for(
int i = 0; i <
m_grid->GetNumberCols(); i++ )
590 if(
m_grid->IsColShown( i ) )
592 std::string fieldName(
getDataModel()->GetColFieldName( i ).ToUTF8() );
617 m_grid->EnableEditing( !aReadOnly );
633 wxGridCellAttr* attr =
new wxGridCellAttr;
634 attr->SetReadOnly(
false );
665 attr->SetAlignment( wxALIGN_RIGHT, wxALIGN_CENTER );
666 attr->SetRenderer(
new wxGridCellNumberRenderer() );
671 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
684 attr->SetEditor(
m_grid->GetDefaultEditor() );
695 m_grid->AutoSizeColumns(
false );
697 bool sortAscending =
true;
699 for(
int col = 0; col <
m_grid->GetNumberCols(); ++col )
725 std::string key(
getDataModel()->GetColFieldName( col ).ToUTF8() );
734 int maxWidth = defaultDlgSize.x / 3;
736 m_grid->SetColSize( col, std::clamp( textWidth, 100, maxWidth ) );
746 m_grid->SetSortingColumn( sortCol, sortAscending );
754 if( aIsLeftPanelCollapsed )
788 if(
getDataModel()->IsExpanderColumn( event.GetCol() ) )
793 m_grid->SetGridCursor( event.GetRow(), event.GetCol() );
818#if defined( __WXOSX__ )
819 wxPoint pos = aEvent.GetPosition();
820 wxRect ctrlRect =
m_filter->GetScreenRect();
821 int buttonWidth = ctrlRect.GetHeight();
824 if(
m_filter->IsSearchButtonVisible() && pos.x < buttonWidth )
825 SetCursor( wxCURSOR_ARROW );
826 else if(
m_filter->IsCancelButtonVisible() && pos.x > ctrlRect.GetWidth() - buttonWidth )
827 SetCursor( wxCURSOR_ARROW );
829 SetCursor( wxCURSOR_IBEAM );
840 int remainingWidth =
m_viewControlsGrid->GetSize().GetX() - showColWidth - groupByColWidth;
865 int row = aEvent.GetRow();
867 wxCHECK( row < m_viewControlsGrid->GetNumberRows(), );
869 switch( aEvent.GetCol() )
880 m_grid->SetColLabelValue( dataCol, label );
914 DisplayError(
this,
_(
"The Quantity column cannot be grouped by." ) );
922 if(
getDataModel()->ColIsItemNumber( dataCol ) && value )
924 DisplayError(
this,
_(
"The Item Number column cannot be grouped by." ) );
952 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Add Field" ) );
954 if( dlg.ShowModal() != wxID_OK )
957 wxString fieldName = dlg.GetValue();
959 if( fieldName.IsEmpty() )
969 DisplayError(
this, wxString::Format(
_(
"Field name '%s' already in use." ), fieldName ) );
992 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory." ),
998 return IsOK(
this, wxString::Format(
_(
"Are you sure you want to remove the field '%s'?" ),
1024 if( selectedRows.empty() )
1027 int row = selectedRows[0];
1033 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory and names cannot be changed." ),
1044 wxCHECK_RET( col != -1, wxS(
"Existing field name missing from data model" ) );
1046 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Rename Field" ), fieldName );
1048 if( dlg.ShowModal() != wxID_OK )
1051 wxString newFieldName = dlg.GetValue();
1054 if( newFieldName == fieldName )
1058 if(
getDataModel()->GetFieldNameCol( newFieldName ) != -1 )
1060 wxString confirm_msg = wxString::Format(
_(
"Field name %s already exists." ), newFieldName );
1069 if( labelIsAutogenerated )
1128 int sortCol = aEvent.GetCol();
1140 if(
m_grid->IsSortingBy( sortCol ) )
1143 ascending = !
m_grid->IsSortOrderAscending();
1161 int origPos = aEvent.GetCol();
1169 int newPos =
m_grid->GetColPos( origPos );
1172 if( newPos < origPos )
1195 wxPoint pos = aEvent.GetPosition();
1197 m_grid->CalcUnscrolledPosition( pos.x, pos.y, &ux, &uy );
1198 int row =
m_grid->YToRow( uy );
1199 int col =
m_grid->XToCol( ux );
1201 if( row == wxNOT_FOUND || col == wxNOT_FOUND )
1203 m_grid->GetGridWindow()->UnsetToolTip();
1207 wxString rawValue =
getDataModel()->GetValue( row, col );
1209 if( rawValue.Contains( wxT(
"${" ) ) )
1210 m_grid->GetGridWindow()->SetToolTip( rawValue );
1212 m_grid->GetGridWindow()->UnsetToolTip();
1218 if( aEvent.GetWheelAxis() != wxMOUSE_WHEEL_VERTICAL || aEvent.GetModifiers() != wxMOD_SHIFT )
1233 int scrollLines = aEvent.IsPageScroll() ?
m_grid->GetScrollPageSize( wxHORIZONTAL )
1234 : aEvent.GetLinesPerAction();
1236 wxPoint viewStart =
m_grid->GetViewStart();
1237 m_grid->Scroll( viewStart.x - lines * scrollLines, viewStart.y );
1262 wxFileName fn(
Prj().AbsolutePath(
m_parentFrame->GetCurrentFileName() ) );
1265 wxFileDialog saveDlg(
this,
_(
"Bill of Materials Output File" ),
path, fn.GetFullName(),
1270 if( saveDlg.ShowModal() == wxID_CANCEL )
1273 wxFileName file = wxFileName( saveDlg.GetPath() );
1274 wxString defaultPath = fn.GetPathWithSep();
1276 if(
IsOK(
this, wxString::Format(
_(
"Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
1278 if( !file.MakeRelativeTo( defaultPath ) )
1294 _(
"Changes have not yet been saved. Export unsaved data?" ),
"",
_(
"OK" ),
1305 std::function<bool( wxString* )> textResolver =
1306 [&]( wxString* token ) ->
bool
1311 wxString sourceFileName =
m_parentFrame->GetCurrentFileName();
1314 if(
path.IsEmpty() )
1320 if(
path.IsEmpty() )
1322 DisplayError(
this,
_(
"No output file specified in Export tab." ) );
1332 wxFileName outputFile = wxFileName::FileName(
path );
1337 msg.Printf(
_(
"Could not open/create path '%s'." ), outputFile.GetPath() );
1342 wxFFile out( outputFile.GetFullPath(),
"wb" );
1344 if( !out.IsOpened() )
1346 msg.Printf(
_(
"Could not create BOM output '%s'." ), outputFile.GetFullPath() );
1355 msg.Printf(
_(
"Could not write BOM output '%s'." ), outputFile.GetFullPath() );
1369 msg.Printf(
_(
"Wrote BOM output to '%s'" ), outputFile.GetFullPath() );
1383 if( saveIncludeExcudedFromBOM )
1406 std::vector<BOM_PRESET> ret;
1408 for(
const std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1410 if( !pair.second.readOnly )
1411 ret.emplace_back( pair.second );
1423 for(
const BOM_PRESET& preset : aPresetList )
1441 wxCommandEvent
dummy;
1448 BOM_PRESET preset = aPreset;
1450 if( preset.fieldsOrdered.empty() )
1454 if( builtIn.name == BOM_PRESET::DefaultEditing().name )
1490 for(
int i = 0; i <
getDataModel()->GetColsCount(); i++ )
1492 const wxString& fieldName(
getDataModel()->GetColFieldName( i ) );
1517 wxASSERT_MSG(
true,
"Fields control has a field not found in the data model." );
1521 std::string fieldNameStr( fieldName.ToUTF8() );
1526 m_grid->SetColLabelValue( col, label );
1581 return BOM_PRESET::BuiltInPresets();
1590 int default_idx = 0;
1594 m_cbBomPresets->Append( wxGetTranslation( presetName ), (
void*) &preset );
1596 if( presetName == BOM_PRESET::DefaultEditing().
name )
1620 return aPresetCount - (
m_job ? 1 : 3 );
1626 return m_job ? wxNOT_FOUND : aPresetCount - 2;
1632 return m_job ? wxNOT_FOUND : aPresetCount - 1;
1647 [&](
const std::pair<const wxString, BOM_PRESET>& aPair )
1649 const BOM_PRESET& preset = aPair.second;
1652 if( !( preset.sortAsc == current.sortAsc
1653 && preset.filterString == current.filterString
1654 && preset.filterScope == current.filterScope
1655 && preset.groupSymbols == current.groupSymbols
1656 && preset.excludeDNP == current.excludeDNP
1657 && preset.includeExcludedFromBOM == current.includeExcludedFromBOM ) )
1668 if( preset.sortField != wxGetTranslation( current.sortField ) )
1672 std::vector<BOM_FIELD>
A,
B;
1674 for(
const BOM_FIELD& field : preset.fieldsOrdered )
1676 if( field.show || field.groupBy )
1677 A.emplace_back( field );
1680 for(
const BOM_FIELD& field : current.fieldsOrdered )
1682 if( field.show || field.groupBy )
1683 B.emplace_back( field );
1689 if( it != m_bomPresets.end() )
1693 bool do_translate = it->second.readOnly;
1694 wxString
text = do_translate ? wxGetTranslation( it->first ) : it->first;
1695 m_cbBomPresets->SetStringSelection(
text );
1699 m_cbBomPresets->SetSelection( presetDashDashDashIndex( m_cbBomPresets->GetCount() ) );
1702 m_currentBomPreset =
static_cast<BOM_PRESET*
>( m_cbBomPresets->GetClientData( m_cbBomPresets->GetSelection() ) );
1711 wxString ui_label = aName;
1715 if( presetName == aName )
1717 if( preset.readOnly ==
true )
1718 ui_label = wxGetTranslation( aName );
1743 auto resetSelection =
1766 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
1768 if( dlg.ShowModal() != wxID_OK )
1774 name = dlg.GetValue();
1790 else if( preset->readOnly )
1792 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
1793 _(
"Error" ), wxOK | wxICON_ERROR,
this );
1800 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
1807 preset->name =
name;
1824 wxArrayString headers;
1825 std::vector<wxArrayString> items;
1827 headers.Add(
_(
"Presets" ) );
1831 if( !preset.readOnly )
1835 items.emplace_back( item );
1847 if( idx != wxNOT_FOUND )
1904 std::vector<BOM_FMT_PRESET> ret;
1908 if( !preset.readOnly )
1909 ret.emplace_back( preset );
1939 wxCommandEvent
dummy;
1997 int default_idx = 0;
2030 [&](
const std::pair<const wxString, BOM_FMT_PRESET>& aPair )
2032 return ( aPair.second.fieldDelimiter == current.fieldDelimiter
2033 && aPair.second.stringDelimiter == current.stringDelimiter
2034 && aPair.second.refDelimiter == current.refDelimiter
2035 && aPair.second.refRangeDelimiter == current.refRangeDelimiter
2036 && aPair.second.keepTabs == current.keepTabs
2037 && aPair.second.keepLineBreaks == current.keepLineBreaks
2038 && aPair.second.includeByteOrderMark == current.includeByteOrderMark );
2045 bool do_translate = it->second.readOnly;
2046 wxString
text = do_translate ? wxGetTranslation( it->first ) : it->first;
2065 wxString ui_label = aName;
2069 if( presetName == aName )
2071 if( preset.readOnly )
2072 ui_label = wxGetTranslation( aName );
2097 auto resetSelection =
2120 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
2122 if( dlg.ShowModal() != wxID_OK )
2128 name = dlg.GetValue();
2146 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
2147 _(
"Error" ), wxOK | wxICON_ERROR,
this );
2154 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
2178 wxArrayString headers;
2179 std::vector<wxArrayString> items;
2181 headers.Add(
_(
"Presets" ) );
2183 for( std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
2185 if( !pair.second.readOnly )
2188 item.Add( pair.first );
2189 items.emplace_back( item );
2201 if( idx != wxNOT_FOUND )
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
STD_BITMAP_BUTTON * m_addVariantButton
wxTextCtrl * m_textStringDelimiter
STD_BITMAP_BUTTON * m_renameVariantButton
wxTextCtrl * m_textRefDelimiter
wxTextCtrl * m_outputFileName
wxChoice * m_cbBomFmtPresets
wxCheckBox * m_checkIncludeByteOrderMark
DIALOG_FIELDS_TABLE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Fields Table"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER)
STD_BITMAP_BUTTON * m_removeFieldButton
wxTextCtrl * m_textOutput
STD_BITMAP_BUTTON * m_renameFieldButton
wxTextCtrl * m_textFieldDelimiter
wxSplitterWindow * m_splitterMainWindow
wxCheckBox * m_checkKeepTabs
STD_BITMAP_BUTTON * m_copyVariantButton
wxCheckBox * m_checkKeepLineBreaks
STD_BITMAP_BUTTON * m_bMenu
STD_BITMAP_BUTTON * m_deleteVariantButton
STD_BITMAP_BUTTON * m_sidebarButton
STD_BITMAP_BUTTON * m_browseButton
STD_BITMAP_BUTTON * m_addFieldButton
STD_BITMAP_BUTTON * m_editVariantDescButton
WX_GRID * m_viewControlsGrid
wxListBox * m_variantListBox
STD_BITMAP_BUTTON * m_bRefreshPreview
wxChoice * m_cbBomPresets
wxTextCtrl * m_textRefRangeDelimiter
STD_BITMAP_BUTTON * m_bRefresh
wxCheckBox * m_groupSymbolsBox
wxSplitterWindow * m_splitter_left
std::map< wxString, BOM_PRESET > m_bomPresets
BOM_PRESET * m_lastSelectedBomPreset
void saveJobSettings(JOB_EXPORT_BOM &aJob)
virtual wxGridCellEditor * createReferenceEditor()
void SetUserBomFmtPresets(std::vector< BOM_FMT_PRESET > &aPresetList)
wxSize GetDefaultDialogSize() const
virtual wxGridCellEditor * createDatasheetEditor()=0
virtual bool resolveTextVar(wxString *aToken) const =0
BOM_FMT_PRESET * m_lastSelectedBomFmtPreset
void syncBomFmtPresetSelection()
void OnTableCellClick(wxGridEvent &event) override
void OnColMove(wxGridEvent &aEvent)
void EnableSelectionEvents()
void DisableSelectionEvents()
int presetDashDashDashIndex(int aPresetCount) const
void OnColSort(wxGridEvent &aEvent)
BOM_PRESET * m_currentBomPreset
void OnGridMouseMove(wxMouseEvent &aEvent)
bool savePresets(bool aSaveCurrentSettings)
wxArrayString m_bomFmtPresetMRU
void OnSizeViewControlsGrid(wxSizeEvent &event) override
void OnViewControlsCellChanged(wxGridEvent &aEvent) override
BOM_FMT_PRESET * m_currentBomFmtPreset
int presetDeletePresetIndex(int aPresetCount) const
void OnTableRangeSelectionChanged(wxGridRangeSelectEvent &aEvent)
wxString getSelectedVariant() const
void doApplyBomFmtPreset(const BOM_FMT_PRESET &aPreset)
void OnFilterText(wxCommandEvent &aEvent) override
void doApplyBomPreset(const BOM_PRESET &aPreset)
void OnPageChanged(wxNotebookEvent &aEvent) override
void ShowHideColumn(int aCol, bool aShow)
void OnExport(wxCommandEvent &aEvent) override
virtual void OnTableSelectionChanged(const std::set< int > &aRows)=0
void updateBomPresetSelection(const wxString &aName)
void OnFilterScope(wxCommandEvent &aEvent) override
BOM_FMT_PRESET GetCurrentBomFmtSettings()
Returns a formatting configuration corresponding to the values in the UI controls of the dialog.
void RestorePanelLayout()
void RestoreGridSelection(const std::set< KIID_PATH > &aItemKeys)
Restore a selection previously returned by SaveGridSelection().
std::map< FIELD_T, int > m_mandatoryFieldListIndexes
virtual wxGridCellEditor * createFootprintEditor()
void onBomFmtPresetChanged(wxCommandEvent &aEvent)
int presetSavePresetIndex(int aPresetCount) const
void OnRenameField(wxCommandEvent &aEvent) override
void OnGroupSymbolsToggled(wxCommandEvent &aEvent) override
void OnPreviewRefresh(wxCommandEvent &aEvent) override
virtual std::vector< BOM_PRESET > getBuiltInBomPresets() const
void updateBomFmtPresetSelection(const wxString &aName)
void OnTableColSize(wxGridSizeEvent &event) override
void SetUserBomPresets(std::vector< BOM_PRESET > &aPresetList)
void ApplyBomFmtPreset(const wxString &aPresetName)
DIALOG_FIELDS_TABLE(wxWindow *aParent, FIELDS_TABLE_SETTINGS &aPanelSettings, FIELDS_TABLE_BOM_SETTINGS &aBomSettings, JOB_EXPORT_BOM *aJob)
~DIALOG_FIELDS_TABLE() override
void SetupColumnProperties(int aCol)
FIELDS_TABLE_BOM_SETTINGS & m_cfgBomSettings
void loadDefaultBomPresets()
static void loadJobBomFmtPreset(const JOB_EXPORT_BOM &aJob, BOM_FMT_PRESET &aPreset)
FIELDS_TABLE_SETTINGS & m_cfgDialogSettings
std::map< wxString, BOM_FMT_PRESET > m_bomFmtPresets
static void loadJobBomPreset(const JOB_EXPORT_BOM &aJob, BOM_PRESET &aPreset)
BOM_PRESET getDataModelBomPreset()
virtual wxString resolveVariant() const =0
std::set< int > GetSelectedGridRows() const
Return the explicitly selected grid rows, or the cursor row if the selection is empty.
wxArrayString m_bomPresetMRU
void OnGridMouseWheel(wxMouseEvent &aEvent)
void OnSidebarToggle(wxCommandEvent &event) override
void rebuildBomPresetsWidget()
void OnAddField(wxCommandEvent &aEvent) override
std::vector< BOM_PRESET > GetUserBomPresets() const
void onBomPresetChanged(wxCommandEvent &aEvent)
virtual void onBomSettingsChanged()
void SetReadOnly(bool aReadOnly)
std::set< KIID_PATH > SaveGridSelection()
Save the grid selection by stable item identity so it can survive a row rebuild.
void ApplyBomPreset(const wxString &aPresetName)
void OnFilterMouseMoved(wxMouseEvent &event) override
void OnRegroupSymbols(wxCommandEvent &aEvent) override
void OnOutputFileBrowseClicked(wxCommandEvent &aEvent) override
void OnTableValueChanged(wxGridEvent &event) override
void syncBomPresetSelection()
virtual FIELDS_TABLE_DATA_MODEL_BASE * getDataModel() const =0
VIEW_CONTROLS_GRID_DATA_MODEL * m_viewControlsDataModel
static wxString GetDefaultBomFileName(const wxString &aInputFileName)
Derive the default BOM output file name from the input file name by swapping the extension to CSV.
std::vector< BOM_FMT_PRESET > GetUserBomFmtPresets() const
void rebuildBomFmtPresetsWidget()
void setSideBarButtonLook(bool aIsLeftPanelCollapsed)
void AddField(const wxString &aFieldName, const wxString &aLabelValue, bool aShow, bool aGroupBy, bool aAddedByUser=false)
void loadDefaultBomFmtPresets()
void OnRemoveField(wxCommandEvent &aEvent) override
void SetupAllColumnProperties()
void OptOut(wxWindow *aWindow)
Opt out of control state saving.
EDA_BASE_FRAME * m_parentFrame
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void SetListLabel(const wxString &aLabel)
Contains everything completly generic to fields tables data models, as well as column functionality t...
void SetSorting(int aCol, bool aAscending)
int GetNumberCols() override
void MoveColumn(int aCol, int aNewPos)
void SetShowColumn(int aCol, bool aShow)
void SetIncludeExcludedFromBOM(bool aInclude)
virtual void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser)=0
bool GetGroupColumn(int aCol)
void SetColLabelValue(int aCol, const wxString &aLabel) override
void SetFilterScope(BOM_FILTER_SCOPE aScope)
BOM_PRESET GetBomSettings()
int GetFieldNameCol(const wxString &aFieldName) const
void RemoveColumn(int aCol)
bool GetIncludeExcludedFromBOM()
void SetGroupingEnabled(bool aGroup)
int GetColDataWidth(int aCol)
virtual void ExpandCollapseRow(int aRow)=0
void SetCurrentVariant(const wxString &aVariantName)
Set the current variant name for highlighting purposes.
void RenameColumn(int aCol, const wxString &newName)
void SetGroupColumn(int aCol, bool aGroup)
void SetFilter(const wxString &aFilter)
wxString GetColLabelValue(int aCol) override
bool GetShowColumn(int aCol)
void ApplyBomPreset(const BOM_PRESET &aPreset)
virtual void RebuildRows()=0
DIALOG_FIELDS_TABLE * m_dialog
FIELDS_TABLE_GRID_TRICKS(DIALOG_FIELDS_TABLE *aDialog, WX_GRID *aGrid, FIELDS_TABLE_DATA_MODEL_BASE *aDataModel)
virtual void showFieldsTablePopupMenu(wxMenu &aMenu, wxGridEvent &aEvent)
FIELDS_TABLE_DATA_MODEL_BASE * m_dataModel
void doPopupSelection(wxCommandEvent &aEvent) override
void showPopupMenu(wxMenu &aMenu, wxGridEvent &aEvent) override
virtual void doFieldsTablePopupSelection(wxCommandEvent &aEvent)
A text control validator used for validating the text allowed in fields.
This class works around a bug in wxGrid where the first keystroke doesn't get sent through the valida...
A general-purpose text renderer for WX_GRIDs backed by WX_GRID_TABLE_BASE tables that can handle draw...
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
GRID_TRICKS(WX_GRID *aGrid)
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent)
WX_GRID * m_grid
I don't own the grid, but he owns me.
wxString m_stringDelimiter
wxString m_fieldDelimiter
bool m_includeByteOrderMark
std::vector< wxString > m_fieldsOrdered
wxString m_refRangeDelimiter
std::vector< wxString > m_fieldsLabels
void SetSelectedVariant(const wxString &aVariant)
std::vector< wxString > m_fieldsGroupBy
wxString m_bomFmtPresetName
BOM_FILTER_SCOPE m_filterScope
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static REPORTER & GetInstance()
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
void SetColAttr(wxGridCellAttr *aAttr, int aCol) override
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
wxString GetGeneratedFieldDisplayName(const wxString &aSource)
Returns any variables unexpanded, e.g.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, RESOLUTION_CONTEXT aContext)
wxString NormalizeFilePathForTextVars(const wxString &aPath)
Normalize a file path so its text variables survive ExpandTextVars.
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
bool IsGeneratedField(const wxString &aFieldName)
Returns true if the entire string is generated, e.g is a single text var reference.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
Base window classes and related definitions.
#define DISPLAY_NAME_COLUMN
#define SHOW_FIELD_COLUMN
@ GRIDTRICKS_FIRST_SHOWHIDE
@ GRIDTRICKS_FIRST_CLIENT_ID
static const std::string CsvFileExtension
static wxString CsvFileWildcard()
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
std::vector< FAB_LAYER_COLOR > dummy
wxString GetDefaultVariantName()
bool includeByteOrderMark
static BOM_FMT_PRESET CSV()
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
wxString refRangeDelimiter
Dialog settings for the lib/symbol/footprint table editors across the various editors.
bool FieldNamesAreDuplicates(const wxString &aLhs, const wxString &aRhs, std::initializer_list< FIELD_T > aMandatoryFields)
Test whether two field names should be treated as duplicates for the purposes of field name uniquenes...
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
Functions to provide common constants and other functions to assist in making a consistent UI.
Custom text control validator definitions.
Definition of file extensions used in Kicad.