KiCad PCB EDA Suite
PANEL_MODEDIT_DEFAULTS Class Reference

#include <panel_modedit_defaults.h>

Inheritance diagram for PANEL_MODEDIT_DEFAULTS:
PANEL_MODEDIT_DEFAULTS_BASE

Public Member Functions

 PANEL_MODEDIT_DEFAULTS (FOOTPRINT_EDIT_FRAME *aFrame, PAGED_DIALOG *aParent)
 
 ~PANEL_MODEDIT_DEFAULTS () override
 

Protected Attributes

wxStaticText * m_staticText13
 
wxStaticText * m_staticTextRef
 
wxTextCtrl * m_textCtrlRefText
 
wxChoice * m_choiceLayerReference
 
wxChoice * m_choiceVisibleReference
 
wxStaticText * m_staticTextValue
 
wxTextCtrl * m_textCtrlValueText
 
wxChoice * m_choiceLayerValue
 
wxChoice * m_choiceVisibleValue
 
wxStaticText * m_staticTextInfo
 
wxStaticText * m_staticText1
 
WX_GRIDm_grid
 

Private Member Functions

int getGridValue (int aRow, int aCol)
 
bool validateData ()
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 

Private Attributes

BOARD_DESIGN_SETTINGS m_brdSettings
 
FOOTPRINT_EDIT_FRAMEm_frame
 
PAGED_DIALOGm_Parent
 

Detailed Description

Definition at line 30 of file panel_modedit_defaults.h.

Constructor & Destructor Documentation

PANEL_MODEDIT_DEFAULTS::PANEL_MODEDIT_DEFAULTS ( FOOTPRINT_EDIT_FRAME aFrame,
PAGED_DIALOG aParent 
)

Definition at line 56 of file panel_modedit_defaults.cpp.

References PANEL_MODEDIT_DEFAULTS_BASE::m_grid, and PANEL_MODEDIT_DEFAULTS_BASE::m_staticTextInfo.

56  :
58  m_brdSettings( aFrame->GetDesignSettings() ),
59  m_frame( aFrame ),
60  m_Parent( aParent )
61 {
62  m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
63 
64  // Work around a bug in wxWidgets where it fails to recalculate the grid height
65  // after changing the default row size
66  m_grid->AppendRows( 1 );
67  m_grid->DeleteRows( m_grid->GetNumberRows() - 1, 1 );
68 
69  m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
70 
71  wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
72  infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
73  m_staticTextInfo->SetFont( infoFont );
74 }
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
BOARD_DESIGN_SETTINGS m_brdSettings
Class GRID_TRICKS is used to add cut, copy, and paste to an otherwise unmodied wxGrid instance...
Definition: grid_tricks.h:51
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
PANEL_MODEDIT_DEFAULTS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL)
FOOTPRINT_EDIT_FRAME * m_frame
PANEL_MODEDIT_DEFAULTS::~PANEL_MODEDIT_DEFAULTS ( )
override

Definition at line 77 of file panel_modedit_defaults.cpp.

References PANEL_MODEDIT_DEFAULTS_BASE::m_grid.

78 {
79  // destroy GRID_TRICKS before m_grid.
80  m_grid->PopEventHandler( true );
81 }

Member Function Documentation

int PANEL_MODEDIT_DEFAULTS::getGridValue ( int  aRow,
int  aCol 
)
private

Definition at line 133 of file panel_modedit_defaults.cpp.

References EDA_DRAW_FRAME::GetUserUnits(), m_frame, PANEL_MODEDIT_DEFAULTS_BASE::m_grid, and ValueFromString().

Referenced by TransferDataFromWindow(), and validateData().

134 {
135  return ValueFromString( m_frame->GetUserUnits(), m_grid->GetCellValue( aRow, aCol ), true );
136 }
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application...
Definition: base_units.cpp:409
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
FOOTPRINT_EDIT_FRAME * m_frame
bool PANEL_MODEDIT_DEFAULTS::TransferDataFromWindow ( )
overrideprivate

Definition at line 163 of file panel_modedit_defaults.cpp.

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_ITALIC, COL_TEXT_THICKNESS, COL_TEXT_WIDTH, getGridValue(), i, m_brdSettings, m_frame, PANEL_MODEDIT_DEFAULTS_BASE::m_grid, BOARD_DESIGN_SETTINGS::m_LineThickness, BOARD_DESIGN_SETTINGS::m_TextItalic, BOARD_DESIGN_SETTINGS::m_TextSize, BOARD_DESIGN_SETTINGS::m_TextThickness, ROW_COUNT, ROW_COURTYARD, ROW_EDGES, FOOTPRINT_EDIT_FRAME::SetDesignSettings(), and validateData().

164 {
165  if( !validateData() )
166  return false;
167 
168  for( int i = 0; i < ROW_COUNT; ++i )
169  {
171 
172  if( i == ROW_EDGES || i == ROW_COURTYARD )
173  continue;
174 
179  wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_ITALIC ) );
180  }
181 
183 
184  return true;
185 }
int getGridValue(int aRow, int aCol)
BOARD_DESIGN_SETTINGS m_brdSettings
wxSize m_TextSize[LAYER_CLASS_COUNT]
int m_TextThickness[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
int m_LineThickness[LAYER_CLASS_COUNT]
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings) override
size_t i
Definition: json11.cpp:597
FOOTPRINT_EDIT_FRAME * m_frame
bool PANEL_MODEDIT_DEFAULTS::TransferDataToWindow ( )
overrideprivate

Definition at line 84 of file panel_modedit_defaults.cpp.

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_ITALIC, COL_TEXT_THICKNESS, COL_TEXT_WIDTH, DISABLE_CELL, F_SilkS, i, m_brdSettings, PANEL_MODEDIT_DEFAULTS_BASE::m_choiceLayerReference, PANEL_MODEDIT_DEFAULTS_BASE::m_choiceLayerValue, PANEL_MODEDIT_DEFAULTS_BASE::m_choiceVisibleReference, PANEL_MODEDIT_DEFAULTS_BASE::m_choiceVisibleValue, PANEL_MODEDIT_DEFAULTS_BASE::m_grid, BOARD_DESIGN_SETTINGS::m_LineThickness, BOARD_DESIGN_SETTINGS::m_RefDefaultlayer, BOARD_DESIGN_SETTINGS::m_RefDefaultText, BOARD_DESIGN_SETTINGS::m_RefDefaultVisibility, PANEL_MODEDIT_DEFAULTS_BASE::m_textCtrlRefText, PANEL_MODEDIT_DEFAULTS_BASE::m_textCtrlValueText, BOARD_DESIGN_SETTINGS::m_TextItalic, BOARD_DESIGN_SETTINGS::m_TextSize, BOARD_DESIGN_SETTINGS::m_TextThickness, BOARD_DESIGN_SETTINGS::m_ValueDefaultlayer, BOARD_DESIGN_SETTINGS::m_ValueDefaultText, BOARD_DESIGN_SETTINGS::m_ValueDefaultVisibility, ROW_COUNT, ROW_COURTYARD, ROW_EDGES, and SET_MILS_CELL.

85 {
86  wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND );
87 
88 #define SET_MILS_CELL( row, col, val ) \
89  m_grid->SetCellValue( row, col, StringFromValue( m_frame->GetUserUnits(), val, true, true ) )
90 
91 #define DISABLE_CELL( row, col ) \
92  m_grid->SetReadOnly( row, col ); m_grid->SetCellBackgroundColour( row, col, disabledColour );
93 
94  for( int i = 0; i < ROW_COUNT; ++i )
95  {
97 
98  if( i == ROW_EDGES || i == ROW_COURTYARD )
99  {
104  }
105  else
106  {
110  m_grid->SetCellValue( i, COL_TEXT_ITALIC, m_brdSettings.m_TextItalic[ i ] ? "1" : "" );
111 
112  auto attr = new wxGridCellAttr;
113  attr->SetRenderer( new wxGridCellBoolRenderer() );
114  attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
115  attr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
116  m_grid->SetAttr( i, COL_TEXT_ITALIC, attr );
117  }
118  }
119 
120  // Footprint defaults
124 
126  m_choiceLayerValue->SetSelection( m_brdSettings.m_ValueDefaultlayer == F_SilkS ? 0 : 1 );
128 
129  return true;
130 }
wxString m_RefDefaultText
Default ref text on fp creation.
bool m_ValueDefaultVisibility
Default value text visibility on fp creation.
BOARD_DESIGN_SETTINGS m_brdSettings
int m_ValueDefaultlayer
Default value text layer on fp creation.
wxSize m_TextSize[LAYER_CLASS_COUNT]
int m_TextThickness[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
wxString m_ValueDefaultText
Default value text on fp creation.
int m_LineThickness[LAYER_CLASS_COUNT]
#define SET_MILS_CELL(row, col, val)
size_t i
Definition: json11.cpp:597
int m_RefDefaultlayer
Default ref text layer on fp creation.
bool m_RefDefaultVisibility
Default ref text visibility on fp creation.
#define DISABLE_CELL(row, col)
bool PANEL_MODEDIT_DEFAULTS::validateData ( )
private

Definition at line 139 of file panel_modedit_defaults.cpp.

References COL_TEXT_HEIGHT, COL_TEXT_THICKNESS, COL_TEXT_WIDTH, WX_GRID::CommitPendingChanges(), getGridValue(), PANEL_MODEDIT_DEFAULTS_BASE::m_grid, m_Parent, min, ROW_COPPER, ROW_OTHERS, ROW_SILK, and PAGED_DIALOG::SetError().

Referenced by TransferDataFromWindow().

140 {
141  if( !m_grid->CommitPendingChanges() )
142  return false;
143 
144  // Test text parameters.
145  for( int row : { ROW_SILK, ROW_COPPER, ROW_OTHERS } )
146  {
147  int textSize = std::min( getGridValue( row, COL_TEXT_WIDTH ),
148  getGridValue( row, COL_TEXT_HEIGHT ) );
149 
150  if( getGridValue( row, COL_TEXT_THICKNESS ) > textSize / 4 )
151  {
152  wxString msg = _( "Text will not be readable with a thickness greater than\n"
153  "1/4 its width or height." );
154  m_Parent->SetError( msg, this, m_grid, row, COL_TEXT_THICKNESS );
155  return false;
156  }
157  }
158 
159  return true;
160 }
int getGridValue(int aRow, int aCol)
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:156
void SetError(const wxString &aMessage, wxWindow *aPage, wxObject *aCtrl, int aRow=-1, int aCol=-1)
#define min(a, b)
Definition: auxiliary.h:85

Member Data Documentation

BOARD_DESIGN_SETTINGS PANEL_MODEDIT_DEFAULTS::m_brdSettings
private

Definition at line 32 of file panel_modedit_defaults.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

wxChoice* PANEL_MODEDIT_DEFAULTS_BASE::m_choiceLayerReference
protectedinherited
wxChoice* PANEL_MODEDIT_DEFAULTS_BASE::m_choiceLayerValue
protectedinherited
wxChoice* PANEL_MODEDIT_DEFAULTS_BASE::m_choiceVisibleReference
protectedinherited
wxChoice* PANEL_MODEDIT_DEFAULTS_BASE::m_choiceVisibleValue
protectedinherited
FOOTPRINT_EDIT_FRAME* PANEL_MODEDIT_DEFAULTS::m_frame
private

Definition at line 33 of file panel_modedit_defaults.h.

Referenced by getGridValue(), and TransferDataFromWindow().

PAGED_DIALOG* PANEL_MODEDIT_DEFAULTS::m_Parent
private

Definition at line 34 of file panel_modedit_defaults.h.

Referenced by validateData().

wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticText1
protectedinherited
wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticText13
protectedinherited
wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticTextInfo
protectedinherited
wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticTextRef
protectedinherited
wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticTextValue
protectedinherited
wxTextCtrl* PANEL_MODEDIT_DEFAULTS_BASE::m_textCtrlRefText
protectedinherited
wxTextCtrl* PANEL_MODEDIT_DEFAULTS_BASE::m_textCtrlValueText
protectedinherited

The documentation for this class was generated from the following files: