25#include <wx/aui/auibook.h>
29#include <wx/checkbox.h>
37#include <wx/dcclient.h>
46#include <wx/filename.h>
75 int jobBmpColId =
m_jobList->AppendColumn( wxT(
"" ) );
76 int jobNoColId =
m_jobList->AppendColumn(
_(
"No." ) );
77 int jobDescColId =
m_jobList->AppendColumn(
_(
"Job Description" ) );
78 int jobSourceColId =
m_jobList->AppendColumn(
_(
"Source" ) );
79 m_jobList->SetColumnWidth( jobBmpColId, 26 );
80 m_jobList->SetColumnWidth( jobNoColId, GetTextExtent( wxT(
"XXXX" ) ).GetWidth() );
81 m_jobList->SetColumnWidth( jobSourceColId, GetTextExtent( wxT(
"XXXXXX" ) ).GetWidth() );
83 wxImageList* imageList =
new wxImageList( 16, 16,
true, 3 );
86 m_jobList->SetImageList( imageList, wxIMAGE_LIST_SMALL );
104 m_jobList->SetItem( itemIndex, jobNoColId, wxString::Format(
"%d", num++ ) );
105 m_jobList->SetItem( itemIndex, jobDescColId, job.GetDescription() );
108 wxString source = wxEmptyString;
113 source = wxT(
"PCB" );
115 source = wxT(
"SCH" );
118 m_jobList->SetItem( itemIndex, jobSourceColId, source );
146 int itemIndex =
event.GetIndex();
154 if(
static_cast<size_t>( itemIndex ) < jobs.size() )
156 wxString jobId = jobs[itemIndex].m_id;
191 long style = GetWindowStyleFlag();
192 style &= ~wxBORDER_MASK;
193 style |= wxBORDER_SIMPLE;
194 SetWindowStyleFlag( style );
219 wxCHECK( destination, );
229 wxCHECK( destination, );
256 wxClientDC dc(
this );
257 int width = GetSize().GetWidth();
259 m_pathInfo->SetLabel( wxControl::Ellipsize( aMsg, dc, wxELLIPSIZE_MIDDLE, width ) );
273 wxFileName fn =
project.GetProjectFullName();
274 wxSetWorkingDirectory( fn.GetPath() );
295 wxCHECK( destination, );
297 wxString resolvedPath;
308 if( resolvedPath.StartsWith(
"~" ) )
309 resolvedPath.Replace(
"~", wxGetHomeDir(),
false );
312 if( resolvedPath.IsEmpty() )
315 wxString fullPath = wxFileName( resolvedPath ).GetFullPath();
318 DisplayError(
this, wxString::Format(
_(
"Failed to open '%s'." ), fullPath ) );
324 wxCHECK( destination, );
333 wxCHECK( destination, );
336 menu.Append( wxID_EDIT,
_(
"Edit Destination Options..." ) );
337 menu.Append( wxID_DELETE,
_(
"Delete Destination" ) );
339 menu.AppendSeparator();
340 menu.Append( wxID_VIEW_DETAILS,
_(
"View Last Run Log..." ) );
341 menu.Append( wxID_OPEN,
_(
"Open Output" ) );
343 menu.Enable( wxID_VIEW_DETAILS, destination->
m_lastRunSuccess.has_value() );
352 wxCHECK( destination, );
366 virtual void OnDelete( wxCommandEvent& aEvent )
override
385 switch( aEvent.GetId() )
389 wxCommandEvent
dummy;
396 wxCommandEvent
dummy;
401 case wxID_VIEW_DETAILS:
410 wxCommandEvent
dummy;
415 default: wxFAIL_MSG( wxT(
"Unknown ID in context menu event" ) );
445 menu.AppendSeparator();
446 menu.Append(
GRIDTRICKS_ID_COPY,
_(
"Copy" ) +
"\tCtrl+C",
_(
"Copy selected cells to clipboard" ) );
454 m_grid->PopupMenu( &menu );
464 if( selectedRows.size() > 0 )
466 m_grid->SetGridCursor( selectedRows[0], 2 );
467 m_grid->EnableCellEditControl();
472 if( selectedRows.size() > 0 )
473 m_parent->OpenJobOptionsForListItem( selectedRows[0] );
477 wxCommandEvent
dummy;
489 m_grid->CancelShowEditorOnMouseUp();
491 int curr_col = aEvent.GetCol();
492 int curr_row = aEvent.GetRow();
495 && curr_row >= 0 && curr_row < (
int)
m_parent->GetJobsFile()->GetJobs().size() )
498 m_grid->CancelPendingChanges();
505 m_grid->CancelPendingChanges();
509 if( row >= 0 && row < (
int)
m_parent->GetJobsFile()->GetJobs().size() )
510 m_parent->OpenJobOptionsForListItem( row );
521 std::unique_ptr<JOBSET> aJobsFile ) :
530 m_jobsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
586 wxString source = wxEmptyString;
591 source = wxT(
"PCB" );
593 source = wxT(
"SCH" );
605 panel->UpdateStatus();
614 tabName = wxS(
"*" ) + tabName;
629 m_outputListSizer->Add( destinationPanel, 0, wxEXPAND, 5 );
640 std::vector<PANEL_DESTINATION*> panels;
645 panels.push_back( panel );
667 bool success =
false;
708 "support the '%s' job type." ),
728 int row = aEvent.GetRow();
729 int col = aEvent.GetCol();
741 m_jobsFile->SaveToFile( wxEmptyString,
true );
751 wxArrayString headers;
752 std::vector<wxArrayString> items;
754 headers.Add(
_(
"Job Types" ) );
758 for(
const std::pair<const wxString, JOB_REGISTRY_ENTRY>& entry : jobMap )
760 if( entry.second.deprecated )
764 item.Add( wxGetTranslation( entry.second.title ) );
765 items.emplace_back( item );
777 if( !selectedString.IsEmpty() )
779 for(
const std::pair<const wxString, JOB_REGISTRY_ENTRY>& entry : jobMap )
781 if( entry.second.deprecated )
784 if( wxGetTranslation( entry.second.title ) == selectedString )
786 jobKey = entry.first;
792 if( !jobKey.IsEmpty() )
830 wxArrayString headers;
831 std::vector<wxArrayString> items;
833 headers.Add(
_(
"Destination Types" ) );
838 item.Add( wxGetTranslation( destinationTypeInfo.name ) );
839 items.emplace_back( item );
852 if( wxGetTranslation( destinationTypeInfo.name ) == selectedString )
879 wxFileName fileName =
m_jobsFile->GetFullFilename();
880 wxString msg =
_(
"Save changes to '%s' before closing?" );
885 return m_jobsFile->SaveToFile( wxEmptyString, true );
910 wxFileName boardfn =
project.GetProjectFullName();
911 boardfn.SetExt( FILEEXT::PcbFileExtension );
914 wxEventBlocker blocker(
this );
916 frame->
OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
918 if( !frame->IsVisible() )
933 wxFileName schFn =
project.GetProjectFullName();
936 wxEventBlocker blocker(
this );
940 if( !frame->IsVisible() )
984 if( item < m_jobsGrid->GetNumberRows() - 1 )
1013 panel->ClearStatus();
1023 wxFileName fn =
project.GetProjectFullName();
1024 wxSetWorkingDirectory( fn.GetPath() );
1034 panel->UpdateStatus();
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
wxStaticText * m_staticTextOutputName
DIALOG_JOBSET_RUN_LOG_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Jobset Run Log"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxTextCtrl * m_textCtrlOutput
void OnJobListItemSelected(wxListEvent &event) override
DIALOG_JOBSET_RUN_LOG(wxWindow *aParent, JOBSET *aJobsFile, JOBSET_DESTINATION *aDestination)
JOBSET_DESTINATION * m_destination
virtual void OnUpdateUI(wxUpdateUIEvent &event) override
void OptOut(wxWindow *aWindow)
Opt out of control state saving.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void SetListLabel(const wxString &aLabel)
bool m_multiCellEditEnabled
GRID_TRICKS(WX_GRID *aGrid)
bool m_enableSingleClickEdit
virtual void doPopupSelection(wxCommandEvent &event)
WX_GRID * m_grid
I don't own the grid, but he owns me.
std::vector< JOBSET_JOB > GetJobsForDestination(JOBSET_DESTINATION *aDestination)
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
void doPopupSelection(wxCommandEvent &event) override
bool handleDoubleClick(wxGridEvent &aEvent) override
wxArrayInt m_selectedRows
JOBS_GRID_TRICKS(PANEL_JOBSET *aParent, WX_GRID *aGrid)
bool RunJobsAllDestinations(bool aBail=false)
bool RunJobsForDestination(JOBSET_DESTINATION *aDestination, bool aBail=false)
static const REGISTRY_MAP_T & GetRegistry()
std::unordered_map< wxString, JOB_REGISTRY_ENTRY > REGISTRY_MAP_T
static T * CreateInstance(const wxString &aName)
static KIWAY::FACE_T GetKifaceType(const wxString &aName)
An simple container class that lets us dispatch output jobs to kifaces.
const std::string & GetType() const
The main KiCad project manager frame.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
FACE_T
Known KIFACE implementations.
static REPORTER & GetInstance()
wxStaticBitmap * m_statusBitmap
wxButton * m_buttonGenerate
PANEL_DESTINATION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxBORDER_SUNKEN|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxStaticText * m_pathInfo
STD_BITMAP_BUTTON * m_buttonProperties
STD_BITMAP_BUTTON * m_buttonDelete
wxStaticBitmap * m_bitmapOutputType
STD_BITMAP_BUTTON * m_buttonOpenOutput
wxStaticText * m_textOutputType
void onMenu(wxCommandEvent &aEvent)
JOBSET_DESTINATION * GetDestination()
void OnLastStatusClick(wxMouseEvent &aEvent) override
void UpdatePathInfo(const wxString &aMsg)
PANEL_DESTINATION(wxWindow *aParent, PANEL_JOBSET *aPanelParent, KICAD_MANAGER_FRAME *aFrame, JOBSET *aFile, JOBSET_DESTINATION *aDestination)
void OnOpenOutput(wxCommandEvent &aEvent) override
virtual void OnDelete(wxCommandEvent &aEvent) override
virtual void OnGenerate(wxCommandEvent &event) override
void OnRightDown(wxMouseEvent &aEvent) override
KICAD_MANAGER_FRAME * m_frame
void OnProperties(wxCommandEvent &aEvent) override
PANEL_JOBSET * m_panelParent
STD_BITMAP_BUTTON * m_buttonAddDestination
STD_BITMAP_BUTTON * m_buttonDown
PANEL_JOBSET_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxScrolledWindow * m_destinationList
wxBoxSizer * m_destinationListSizer
STD_BITMAP_BUTTON * m_buttonAddJob
STD_BITMAP_BUTTON * m_buttonDelete
STD_BITMAP_BUTTON * m_buttonUp
wxString GetFilePath() const
virtual void OnSaveButtonClick(wxCommandEvent &aEvent) override
void OnJobButtonDelete(wxCommandEvent &aEvent) override
virtual void OnJobButtonDown(wxCommandEvent &aEvent) override
void EnsurePcbSchFramesOpen()
bool GetCanClose() override
wxAuiNotebook * m_parentBook
void addDestinationPanel(JOBSET_DESTINATION *aDestination)
virtual void OnGenerateAllDestinationsClick(wxCommandEvent &event) override
bool OpenJobOptionsForListItem(size_t aItemIndex)
std::vector< PANEL_DESTINATION * > GetDestinationPanels()
void buildDestinationList()
KICAD_MANAGER_FRAME * m_frame
PANEL_JOBSET(wxAuiNotebook *aParent, KICAD_MANAGER_FRAME *aFrame, std::unique_ptr< JOBSET > aJobsFile)
virtual void OnAddDestinationClick(wxCommandEvent &aEvent) override
virtual void OnAddJobClick(wxCommandEvent &aEvent) override
std::unique_ptr< JOBSET > m_jobsFile
virtual void OnGridCellChange(wxGridEvent &aEvent) override
void RemoveDestination(PANEL_DESTINATION *aPanel)
virtual void OnJobButtonUp(wxCommandEvent &aEvent) override
virtual void OnSizeGrid(wxSizeEvent &aEvent) override
Container for project specific data.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, RESOLUTION_CONTEXT aContext)
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
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.
static const std::string KiCadSchematicFileExtension
Some functions to handle hotkeys in KiCad.
KICOMMON_API std::map< JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO > JobsetDestinationTypeInfos
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
KICOMMON_API std::map< JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO > JobsetDestinationTypeInfos
std::vector< FAB_LAYER_COLOR > dummy
JOBSET_DESTINATION_T m_type
wxString GetPathInfo() const
wxString GetDescription() const
std::optional< wxString > m_lastResolvedOutputPath
std::optional< bool > m_lastRunSuccess
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
std::shared_ptr< JOB > m_job
Definition of file extensions used in Kicad.