2012-07-17 15:29:29 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-10-20 10:38:36 +00:00
|
|
|
* Copyright (C) 2006-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-07-17 15:29:29 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file dialog_lib_edit_draw_item.cpp
|
|
|
|
*/
|
|
|
|
|
2019-08-15 07:09:52 +00:00
|
|
|
#include <lib_item.h>
|
2019-05-06 02:32:01 +00:00
|
|
|
#include <class_libentry.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_lib_edit_draw_item.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_edit_frame.h>
|
2010-07-22 20:12:40 +00:00
|
|
|
|
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( SYMBOL_EDIT_FRAME* aParent, LIB_ITEM* aItem ) :
|
2018-06-14 08:26:11 +00:00
|
|
|
DIALOG_LIB_EDIT_DRAW_ITEM_BASE( aParent ),
|
|
|
|
m_frame( aParent ),
|
|
|
|
m_item( aItem ),
|
2018-11-29 18:59:38 +00:00
|
|
|
m_lineWidth( aParent, m_widthLabel, m_widthCtrl, m_widthUnits, true )
|
2010-07-22 20:12:40 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
SetTitle( aItem->GetTypeName() + wxT( " " ) + GetTitle() );
|
|
|
|
|
|
|
|
SetInitialFocus( m_widthCtrl );
|
2010-07-22 20:12:40 +00:00
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
// Required under wxGTK if we want to dismiss the dialog with the ESC key
|
2010-07-22 20:12:40 +00:00
|
|
|
SetFocus();
|
2018-10-20 10:38:36 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
2016-07-16 10:54:55 +00:00
|
|
|
|
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
2010-07-22 20:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
bool DIALOG_LIB_EDIT_DRAW_ITEM::TransferDataToWindow()
|
2010-07-22 20:12:40 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
LIB_PART* symbol = m_item->GetParent();
|
2010-07-22 20:12:40 +00:00
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
m_lineWidth.SetValue( m_item->GetWidth() );
|
|
|
|
m_checkApplyToAllUnits->SetValue( m_item->GetUnit() == 0 );
|
|
|
|
m_checkApplyToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 );
|
2018-10-20 10:38:36 +00:00
|
|
|
m_checkApplyToAllConversions->SetValue( m_item->GetConvert() == 0 );
|
2010-07-22 20:12:40 +00:00
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
bool enblConvOptStyle = symbol && symbol->HasConversion();
|
|
|
|
// if a symbol contains no graphic items, symbol->HasConversion() returns false.
|
|
|
|
// but when creating a new symbol, with DeMorgan option set, the ApplyToAllConversions
|
|
|
|
// must be enabled even if symbol->HasConversion() returns false in order to be able
|
|
|
|
// to create graphic items shared by all body styles
|
|
|
|
if( m_frame->GetShowDeMorgan() )
|
|
|
|
enblConvOptStyle = true;
|
2010-07-22 20:12:40 +00:00
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
m_checkApplyToAllConversions->Enable( enblConvOptStyle );
|
2010-07-22 20:12:40 +00:00
|
|
|
|
2020-10-15 01:45:20 +00:00
|
|
|
m_fillCtrl->SetSelection( static_cast<int>( m_item->GetFillMode() ) );
|
2018-06-14 08:26:11 +00:00
|
|
|
m_fillCtrl->Enable( m_item->IsFillable() );
|
2010-07-22 20:12:40 +00:00
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
return true;
|
2010-07-22 20:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
int DIALOG_LIB_EDIT_DRAW_ITEM::GetWidth()
|
2010-07-22 20:12:40 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
return m_lineWidth.GetValue();
|
2010-07-22 20:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllConversions()
|
2010-07-22 20:12:40 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
return m_checkApplyToAllConversions->IsChecked();
|
2010-07-22 20:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
bool DIALOG_LIB_EDIT_DRAW_ITEM::GetApplyToAllUnits()
|
2010-07-22 20:12:40 +00:00
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
return m_checkApplyToAllUnits->IsChecked();
|
2010-07-22 20:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DIALOG_LIB_EDIT_DRAW_ITEM::GetFillStyle( void )
|
|
|
|
{
|
2018-06-14 08:26:11 +00:00
|
|
|
return std::max( m_fillCtrl->GetSelection(), 0 );
|
2010-07-22 20:12:40 +00:00
|
|
|
}
|
|
|
|
|