41#define GRID_CELL_MARGIN 4
56 void showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
override;
65 wxString
id =
m_grid->GetCellValue(
m_grid->GetGridCursorRow(),
68 if( std::optional<const PLUGIN_ACTION*> action = mgr.
GetAction(
id ) )
71 _(
"Recreate Plugin Environment" ) );
72 menu.AppendSeparator();
86 wxString
id =
m_grid->GetCellValue(
m_grid->GetGridCursorRow(),
89 if( std::optional<const PLUGIN_ACTION*> action = mgr.
GetAction(
id ) )
107 m_grid->SetUseNativeColLabels();
119 m_grid->PopEventHandler(
true );
132 m_grid->SelectRow( aRow );
138 auto selectedRows =
m_grid->GetSelectedRows();
141 if( selectedRows.size() != 1 )
return;
143 int selectedRow = selectedRows[0];
146 if( selectedRow == 0 )
152 SwapRows( selectedRow, selectedRow - 1 );
160 auto selectedRows =
m_grid->GetSelectedRows();
163 if( selectedRows.size() != 1 )
return;
165 int selectedRow = selectedRows[0];
168 if( selectedRow + 1 ==
m_grid->GetNumberRows() )
174 SwapRows( selectedRow, selectedRow + 1 );
186 for(
int column = 0; column <
m_grid->GetNumberCols(); column++ )
188 tempStr =
m_grid->GetCellValue( aRowA, column );
189 m_grid->SetCellValue( aRowA, column,
m_grid->GetCellValue( aRowB, column ) );
190 m_grid->SetCellValue( aRowB, column, tempStr );
213 wxASSERT( settings );
223 for(
int ii = 0; ii <
m_grid->GetNumberRows(); ii++ )
227 if( mgr.
GetAction(
id ) != std::nullopt )
244 for(
int ii = 0; ii <
m_grid->GetNumberRows(); ii++ )
264 const std::vector<LEGACY_OR_API_PLUGIN>& orderedPlugins =
266 m_grid->AppendRows( orderedPlugins.size() );
269 wxSize iconSize( size, size );
271 for(
size_t row = 0; row < orderedPlugins.size(); row++ )
273 if( std::holds_alternative<ACTION_PLUGIN*>( orderedPlugins[row] ) )
275 auto ap = std::get<ACTION_PLUGIN*>( orderedPlugins[row] );
280 ? wxBitmapBundle( ap->iconBitmap )
291 ap->GetShowToolbarButton() );
301 auto action = std::get<const PLUGIN_ACTION*>( orderedPlugins[row] );
305 : action->icon_light;
318 action->show_button );
328 for(
int col = 0; col <
m_grid->GetNumberCols(); col++ )
330 const wxString& heading =
m_grid->GetColLabelValue( col );
334 m_grid->SetColMinimalWidth( col, headingWidth );
340 m_grid->AutoSizeColumns();
Class PCBNEW_ACTION_PLUGINS.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
static int GetActionsCount()
Responsible for loading plugin definitions for API-based plugins (ones that do not run inside KiCad i...
void RecreatePluginEnvironment(const wxString &aIdentifier)
std::optional< const PLUGIN_ACTION * > GetAction(const wxString &aIdentifier)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
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.
APP_SETTINGS_BASE * KifaceSettings() const
Class PANEL_PCBNEW_ACTION_PLUGINS_BASE.
STD_BITMAP_BUTTON * m_openDirectoryButton
STD_BITMAP_BUTTON * m_moveUpButton
STD_BITMAP_BUTTON * m_moveDownButton
STD_BITMAP_BUTTON * m_showErrorsButton
STD_BITMAP_BUTTON * m_reloadButton
bool TransferDataToWindow() override
void OnShowErrorsButtonClick(wxCommandEvent &event) override
Shows plugin import errors.
friend class PLUGINS_GRID_TRICKS
void OnMoveUpButtonClick(wxCommandEvent &event) override
Moves plugin up in the grid.
void OnGridCellClick(wxGridEvent &event) override
Selects a whole row.
wxBitmapBundle m_genericIcon
bool TransferDataFromWindow() override
void OnMoveDownButtonClick(wxCommandEvent &event) override
Moves plugin down in the grid.
PANEL_PCBNEW_ACTION_PLUGINS(wxWindow *aParent)
@ COLUMN_SETTINGS_IDENTIFIER
void OnOpenDirectoryButtonClick(wxCommandEvent &event) override
Opens user's action plugin directory.
void SwapRows(int aRowA, int aRowB)
~PANEL_PCBNEW_ACTION_PLUGINS() override
void OnReloadButtonClick(wxCommandEvent &event) override
Reloads plugins and updates grid.
ACTION_PLUGIN_SETTINGS_LIST m_VisibleActionPlugins
static std::vector< std::variant< ACTION_PLUGIN *, const PLUGIN_ACTION * > > GetOrderedActionPlugins()
Return ordered list of plugins in sequence in which they should appear on toolbar or in settings.
static bool GetActionPluginButtonVisible(const wxString &aPluginPath, bool aPluginDefault)
Return true if button visibility action plugin setting was set to true or it is unset and plugin defa...
virtual COMMON_SETTINGS * GetCommonSettings() const
PLUGINS_GRID_TRICKS(WX_GRID *aGrid)
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
void doPopupSelection(wxCommandEvent &event) override
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculate the specified column based on the actual size of the text on screen.
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
@ GRIDTRICKS_FIRST_CLIENT_ID
void pcbnewGetWizardsBackTrace(wxString &aTrace)
Return the backtrace of errors (if any) when wizard python scripts are loaded.
PGM_BASE & Pgm()
The global program "get" accessor.
std::vector< std::pair< wxString, bool > > actions
Ordered list of plugin actions mapped to whether or not they are shown in the toolbar.