7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 00:21:36 +00:00

split legacy DIALOG_BOM to have a header

This commit is contained in:
Marek Roszko 2024-09-07 22:24:31 -04:00
parent fd09ad2a75
commit bca77cf54b
2 changed files with 85 additions and 52 deletions

View File

@ -32,7 +32,7 @@
#include <widgets/std_bitmap_button.h>
#include <bom_plugins.h>
#include <confirm.h>
#include <dialog_bom_base.h>
#include <dialog_bom.h>
#include <dialogs/html_message_box.h>
#include <eeschema_settings.h>
#include <gestfich.h>
@ -56,57 +56,6 @@ wxString s_bomHelpInfo =
#include <dialog_bom_help_md.h>
;
// BOM "plugins" are not actually plugins. They are external tools
// (scripts or executables) called by this dialog.
typedef std::vector< std::unique_ptr<BOM_GENERATOR_HANDLER> > BOM_GENERATOR_ARRAY;
// The main dialog frame to run scripts to build bom
class DIALOG_BOM : public DIALOG_BOM_BASE
{
private:
SCH_EDIT_FRAME* m_parent;
BOM_GENERATOR_ARRAY m_generators;
bool m_initialized;
HTML_MESSAGE_BOX* m_helpWindow;
public:
DIALOG_BOM( SCH_EDIT_FRAME* parent );
~DIALOG_BOM();
private:
void OnGeneratorSelected( wxCommandEvent& event ) override;
void OnRunGenerator( wxCommandEvent& event ) override;
void OnHelp( wxCommandEvent& event ) override;
void OnAddGenerator( wxCommandEvent& event ) override;
void OnRemoveGenerator( wxCommandEvent& event ) override;
void OnEditGenerator( wxCommandEvent& event ) override;
void OnCommandLineEdited( wxCommandEvent& event ) override;
void OnNameEdited( wxCommandEvent& event ) override;
void OnShowConsoleChanged( wxCommandEvent& event ) override;
void OnIdle( wxIdleEvent& event ) override;
void pluginInit();
void installGeneratorsList();
BOM_GENERATOR_HANDLER* addGenerator( const wxString& aPath,
const wxString& aName = wxEmptyString );
bool pluginExists( const wxString& aName );
BOM_GENERATOR_HANDLER* selectedGenerator()
{
int idx = m_lbGenerators->GetSelection();
if( idx < 0 || idx >= (int)m_generators.size() )
return nullptr;
return m_generators[idx].get();
}
wxString chooseGenerator();
};
// Create and show DIALOG_BOM.
int InvokeDialogCreateBOM( SCH_EDIT_FRAME* aCaller )
{
@ -530,3 +479,14 @@ void DIALOG_BOM::OnIdle( wxIdleEvent& event )
m_initialized = true;
}
}
BOM_GENERATOR_HANDLER* DIALOG_BOM::selectedGenerator()
{
int idx = m_lbGenerators->GetSelection();
if( idx < 0 || idx >= (int) m_generators.size() )
return nullptr;
return m_generators[idx].get();
}

View File

@ -0,0 +1,73 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma once
#include <dialog_bom_base.h>
#include <vector>
class SCH_EDIT_FRAME;
class BOM_GENERATOR_HANDLER;
class HTML_MESSAGE_BOX;
// BOM "plugins" are not actually plugins. They are external tools
// (scripts or executables) called by this dialog.
typedef std::vector<std::unique_ptr<BOM_GENERATOR_HANDLER>> BOM_GENERATOR_ARRAY;
// The main dialog frame to run scripts to build bom
class DIALOG_BOM : public DIALOG_BOM_BASE
{
private:
SCH_EDIT_FRAME* m_parent;
BOM_GENERATOR_ARRAY m_generators;
bool m_initialized;
HTML_MESSAGE_BOX* m_helpWindow;
public:
DIALOG_BOM( SCH_EDIT_FRAME* parent );
~DIALOG_BOM();
private:
void OnGeneratorSelected( wxCommandEvent& event ) override;
void OnRunGenerator( wxCommandEvent& event ) override;
void OnHelp( wxCommandEvent& event ) override;
void OnAddGenerator( wxCommandEvent& event ) override;
void OnRemoveGenerator( wxCommandEvent& event ) override;
void OnEditGenerator( wxCommandEvent& event ) override;
void OnCommandLineEdited( wxCommandEvent& event ) override;
void OnNameEdited( wxCommandEvent& event ) override;
void OnShowConsoleChanged( wxCommandEvent& event ) override;
void OnIdle( wxIdleEvent& event ) override;
void pluginInit();
void installGeneratorsList();
BOM_GENERATOR_HANDLER* addGenerator( const wxString& aPath,
const wxString& aName = wxEmptyString );
bool pluginExists( const wxString& aName );
BOM_GENERATOR_HANDLER* selectedGenerator();
wxString chooseGenerator();
};