2017-02-19 02:39:55 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
* Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
|
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <widgets/footprint_preview_panel.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <kiway.h>
|
|
|
|
|
|
|
|
|
2017-02-19 12:53:02 +00:00
|
|
|
FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::InstallOnPanel(
|
|
|
|
KIWAY& aKiway, wxPanel* aPanel, bool aStatus )
|
2017-02-19 02:39:55 +00:00
|
|
|
{
|
|
|
|
FOOTPRINT_PREVIEW_PANEL* fpp = NULL;
|
|
|
|
|
|
|
|
try {
|
2017-02-27 09:29:43 +00:00
|
|
|
KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB );
|
|
|
|
|
|
|
|
if( !kiface )
|
|
|
|
return NULL;
|
|
|
|
|
2017-02-19 02:39:55 +00:00
|
|
|
fpp = static_cast<FOOTPRINT_PREVIEW_PANEL*>(
|
|
|
|
kiface->CreateWindow( aPanel, FRAME_PCB_FOOTPRINT_PREVIEW, &aKiway ) );
|
|
|
|
} catch( ... )
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-02-19 19:54:36 +00:00
|
|
|
aPanel->SetBackgroundColour( *wxBLACK );
|
|
|
|
aPanel->SetForegroundColour( *wxWHITE );
|
|
|
|
|
2017-02-19 02:39:55 +00:00
|
|
|
auto sizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
sizer->Add( fpp, 1, wxALL | wxEXPAND, 0 );
|
|
|
|
|
2017-02-19 12:53:02 +00:00
|
|
|
if( aStatus )
|
2017-02-19 02:39:55 +00:00
|
|
|
{
|
|
|
|
auto label = new wxStaticText( aPanel, -1, wxEmptyString );
|
|
|
|
auto sizer2 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
sizer2->Add( 0, 0, 1 );
|
|
|
|
sizer2->Add( label, 0, wxALL | wxALIGN_CENTER, 0 );
|
|
|
|
sizer2->Add( 0, 0, 1 );
|
|
|
|
sizer->Add( sizer2, 1, wxALL | wxALIGN_CENTER, 0 );
|
|
|
|
sizer2->ShowItems( false );
|
|
|
|
fpp->LinkErrorLabel( label );
|
|
|
|
fpp->SetHideSizer( sizer2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
aPanel->SetSizer( sizer );
|
|
|
|
|
|
|
|
return fpp;
|
|
|
|
}
|