KiCad PCB EDA Suite
dialog_lib_edit_draw_item.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2006-2018 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
28 #include <lib_item.h>
29 #include <class_libentry.h>
31 #include <lib_edit_frame.h>
32 
33 
36  m_frame( aParent ),
37  m_item( aItem ),
38  m_lineWidth( aParent, m_widthLabel, m_widthCtrl, m_widthUnits, true )
39 {
40  SetTitle( aItem->GetTypeName() + wxT( " " ) + GetTitle() );
41 
43 
44  // Required under wxGTK if we want to dismiss the dialog with the ESC key
45  SetFocus();
46  m_sdbSizerOK->SetDefault();
47 
48  // Now all widgets have the size fixed, call FinishDialogSettings
50 }
51 
52 
54 {
55  LIB_PART* symbol = m_item->GetParent();
56 
58  m_checkApplyToAllUnits->SetValue( m_item->GetUnit() == 0 );
59  m_checkApplyToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 );
60  m_checkApplyToAllConversions->SetValue( m_item->GetConvert() == 0 );
61 
62  bool enblConvOptStyle = symbol && symbol->HasConversion();
63  // if a symbol contains no graphic items, symbol->HasConversion() returns false.
64  // but when creating a new symbol, with DeMorgan option set, the ApplyToAllConversions
65  // must be enabled even if symbol->HasConversion() returns false in order to be able
66  // to create graphic items shared by all body styles
67  if( m_frame->GetShowDeMorgan() )
68  enblConvOptStyle = true;
69 
70  m_checkApplyToAllConversions->Enable( enblConvOptStyle );
71 
72  m_fillCtrl->SetSelection( m_item->GetFillMode() );
73  m_fillCtrl->Enable( m_item->IsFillable() );
74 
75  return true;
76 }
77 
78 
80 {
81  return m_lineWidth.GetValue();
82 }
83 
84 
86 {
87  return m_checkApplyToAllConversions->IsChecked();
88 }
89 
90 
92 {
93  return m_checkApplyToAllUnits->IsChecked();
94 }
95 
96 
98 {
99  return std::max( m_fillCtrl->GetSelection(), 0 );
100 }
101 
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
LIB_PART * GetParent() const
Definition: lib_item.h:176
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
FILL_T GetFillMode() const
Definition: lib_item.h:306
Class DIALOG_LIB_EDIT_DRAW_ITEM_BASE.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:115
The base class for drawable items used by schematic library components.
Definition: lib_item.h:60
int GetUnit() const
Definition: lib_item.h:300
int GetUnitCount() const override
For items with units, return the number of units.
bool GetShowDeMorgan() const
Class LIB_PIN definition.
Define a library symbol object.
int GetConvert() const
Definition: lib_item.h:303
DIALOG_LIB_EDIT_DRAW_ITEM(LIB_EDIT_FRAME *parent, LIB_ITEM *aItem)
Constructor.
virtual int GetWidth() const =0
The symbol library editor main window.
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
virtual wxString GetTypeName()=0
Provide a user-consumable name of the object type.
virtual long long int GetValue()
Function GetValue Returns the current value in Internal Units.
bool IsFillable() const
Check if draw object can be filled.
Definition: lib_item.h:295