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::PANEL_MODEDIT_DEFAULTS ( FOOTPRINT_EDIT_FRAME aFrame,
PAGED_DIALOG aParent 
)

Definition at line 57 of file panel_modedit_defaults.cpp.

57  :
59  m_brdSettings( aFrame->GetDesignSettings() ),
60  m_frame( aFrame ),
61  m_Parent( aParent )
62 {
63  m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
64 
65  // Work around a bug in wxWidgets where it fails to recalculate the grid height
66  // after changing the default row size
67  m_grid->AppendRows( 1 );
68  m_grid->DeleteRows( m_grid->GetNumberRows() - 1, 1 );
69 
70  m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
71 
72  wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
73  infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
74  m_staticTextInfo->SetFont( infoFont );
75 }
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 mouse and command handling (such as cut, copy, and paste) to a WX_GR...
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

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

◆ ~PANEL_MODEDIT_DEFAULTS()

PANEL_MODEDIT_DEFAULTS::~PANEL_MODEDIT_DEFAULTS ( )
override

Definition at line 78 of file panel_modedit_defaults.cpp.

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

References PANEL_MODEDIT_DEFAULTS_BASE::m_grid.

Member Function Documentation

◆ getGridValue()

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

Definition at line 148 of file panel_modedit_defaults.cpp.

149 {
150  return ValueFromString( m_frame->GetUserUnits(), m_grid->GetCellValue( aRow, aCol ), true );
151 }
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:289
FOOTPRINT_EDIT_FRAME * m_frame

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

Referenced by TransferDataFromWindow(), and validateData().

◆ TransferDataFromWindow()

bool PANEL_MODEDIT_DEFAULTS::TransferDataFromWindow ( )
overrideprivate

Definition at line 178 of file panel_modedit_defaults.cpp.

179 {
180  if( !validateData() )
181  return false;
182 
183  for( int i = 0; i < ROW_COUNT; ++i )
184  {
186 
187  if( i == ROW_EDGES || i == ROW_COURTYARD )
188  continue;
189 
194  wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_ITALIC ) );
195  }
196 
198 
199  return true;
200 }
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

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().

◆ TransferDataToWindow()

bool PANEL_MODEDIT_DEFAULTS::TransferDataToWindow ( )
overrideprivate

Definition at line 85 of file panel_modedit_defaults.cpp.

86 {
87  wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND );
88 
89 #define SET_MILS_CELL( row, col, val ) \
90  m_grid->SetCellValue( row, col, StringFromValue( m_frame->GetUserUnits(), val, true, true ) )
91 
92 #define DISABLE_CELL( row, col ) \
93  m_grid->SetReadOnly( row, col ); m_grid->SetCellBackgroundColour( row, col, disabledColour );
94 
95  for( int i = 0; i < ROW_COUNT; ++i )
96  {
98 
99  if( i == ROW_EDGES || i == ROW_COURTYARD )
100  {
105  }
106  else
107  {
111  m_grid->SetCellValue( i, COL_TEXT_ITALIC, m_brdSettings.m_TextItalic[ i ] ? "1" : "" );
112 
113  auto attr = new wxGridCellAttr;
114  attr->SetRenderer( new wxGridCellBoolRenderer() );
115  attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
116  attr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
117  m_grid->SetAttr( i, COL_TEXT_ITALIC, attr );
118  }
119  }
120 
121  // Footprint defaults
125 
127  m_choiceLayerValue->SetSelection( m_brdSettings.m_ValueDefaultlayer == F_SilkS ? 0 : 1 );
129 
130  for( int col = 0; col < m_grid->GetNumberCols(); col++ )
131  {
132  // Set the minimal width to the column label size.
133  m_grid->SetColMinimalWidth( col, m_grid->GetVisibleWidth( col, true, false, false ) );
134 
135  // Set the width to see the full contents
136  if( m_grid->IsColShown( col ) )
137  m_grid->SetColSize( col, m_grid->GetVisibleWidth( col, true, true, true ) );
138  }
139 
140  m_grid->SetRowLabelSize( m_grid->GetVisibleWidth( -1, true, true, true ) );
141 
142  Layout();
143 
144  return true;
145 }
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.
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=false, bool aKeep=true)
Calculates the specified column based on the actual size of the text on screen.
Definition: wx_grid.cpp:223
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)

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_ITALIC, COL_TEXT_THICKNESS, COL_TEXT_WIDTH, DISABLE_CELL, F_SilkS, WX_GRID::GetVisibleWidth(), 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.

◆ validateData()

bool PANEL_MODEDIT_DEFAULTS::validateData ( )
private

Definition at line 154 of file panel_modedit_defaults.cpp.

155 {
156  if( !m_grid->CommitPendingChanges() )
157  return false;
158 
159  // Test text parameters.
160  for( int row : { ROW_SILK, ROW_COPPER, ROW_OTHERS } )
161  {
162  int textSize = std::min( getGridValue( row, COL_TEXT_WIDTH ),
163  getGridValue( row, COL_TEXT_HEIGHT ) );
164 
165  if( getGridValue( row, COL_TEXT_THICKNESS ) > textSize / 4 )
166  {
167  wxString msg = _( "Text will not be readable with a thickness greater than\n"
168  "1/4 its width or height." );
169  m_Parent->SetError( msg, this, m_grid, row, COL_TEXT_THICKNESS );
170  return false;
171  }
172  }
173 
174  return true;
175 }
int getGridValue(int aRow, int aCol)
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:167
void SetError(const wxString &aMessage, wxWindow *aPage, wxObject *aCtrl, int aRow=-1, int aCol=-1)
#define min(a, b)
Definition: auxiliary.h:85

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().

Member Data Documentation

◆ m_brdSettings

BOARD_DESIGN_SETTINGS PANEL_MODEDIT_DEFAULTS::m_brdSettings
private

Definition at line 32 of file panel_modedit_defaults.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

◆ m_choiceLayerReference

wxChoice* PANEL_MODEDIT_DEFAULTS_BASE::m_choiceLayerReference
protectedinherited

◆ m_choiceLayerValue

wxChoice* PANEL_MODEDIT_DEFAULTS_BASE::m_choiceLayerValue
protectedinherited

◆ m_choiceVisibleReference

wxChoice* PANEL_MODEDIT_DEFAULTS_BASE::m_choiceVisibleReference
protectedinherited

◆ m_choiceVisibleValue

wxChoice* PANEL_MODEDIT_DEFAULTS_BASE::m_choiceVisibleValue
protectedinherited

◆ m_frame

FOOTPRINT_EDIT_FRAME* PANEL_MODEDIT_DEFAULTS::m_frame
private

Definition at line 33 of file panel_modedit_defaults.h.

Referenced by getGridValue(), and TransferDataFromWindow().

◆ m_grid

◆ m_Parent

PAGED_DIALOG* PANEL_MODEDIT_DEFAULTS::m_Parent
private

Definition at line 34 of file panel_modedit_defaults.h.

Referenced by validateData().

◆ m_staticText1

wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticText1
protectedinherited

◆ m_staticText13

wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticText13
protectedinherited

◆ m_staticTextInfo

wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticTextInfo
protectedinherited

◆ m_staticTextRef

wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticTextRef
protectedinherited

◆ m_staticTextValue

wxStaticText* PANEL_MODEDIT_DEFAULTS_BASE::m_staticTextValue
protectedinherited

◆ m_textCtrlRefText

wxTextCtrl* PANEL_MODEDIT_DEFAULTS_BASE::m_textCtrlRefText
protectedinherited

◆ m_textCtrlValueText

wxTextCtrl* PANEL_MODEDIT_DEFAULTS_BASE::m_textCtrlValueText
protectedinherited

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