KiCad PCB EDA Suite
PANEL_SETUP_TEXT_AND_GRAPHICS Class Reference

#include <panel_setup_text_and_graphics.h>

Inheritance diagram for PANEL_SETUP_TEXT_AND_GRAPHICS:
PANEL_SETUP_TEXT_AND_GRAPHICS_BASE

Public Member Functions

 PANEL_SETUP_TEXT_AND_GRAPHICS (PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame)
 
 ~PANEL_SETUP_TEXT_AND_GRAPHICS () override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
void ImportSettingsFrom (BOARD *aBoard)
 

Protected Attributes

wxBoxSizer * m_gridSizer
 
wxStaticText * m_staticText1
 
WX_GRIDm_grid
 

Private Member Functions

bool validateData ()
 
int getGridValue (int aRow, int aCol)
 

Private Attributes

PAGED_DIALOGm_Parent
 
PCB_EDIT_FRAMEm_Frame
 
BOARD_DESIGN_SETTINGSm_BrdSettings
 

Detailed Description

Definition at line 38 of file panel_setup_text_and_graphics.h.

Constructor & Destructor Documentation

PANEL_SETUP_TEXT_AND_GRAPHICS::PANEL_SETUP_TEXT_AND_GRAPHICS ( PAGED_DIALOG aParent,
PCB_EDIT_FRAME aFrame 
)

Definition at line 58 of file panel_setup_text_and_graphics.cpp.

References PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), m_BrdSettings, m_Frame, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, and m_Parent.

59  :
61 {
62  m_Parent = aParent;
63  m_Frame = aFrame;
65 
66  m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
67 
68  // Work around a bug in wxWidgets where it fails to recalculate the grid height
69  // after changing the default row size
70  m_grid->AppendRows( 1 );
71  m_grid->DeleteRows( m_grid->GetNumberRows() - 1, 1 );
72 
73  m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
74 }
Class GRID_TRICKS is used to add cut, copy, and paste to an otherwise unmodied wxGrid instance...
Definition: grid_tricks.h:51
BOARD * GetBoard() const
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
PANEL_SETUP_TEXT_AND_GRAPHICS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL)
PANEL_SETUP_TEXT_AND_GRAPHICS::~PANEL_SETUP_TEXT_AND_GRAPHICS ( )
override

Definition at line 77 of file panel_setup_text_and_graphics.cpp.

References PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid.

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

Member Function Documentation

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

Definition at line 132 of file panel_setup_text_and_graphics.cpp.

References EDA_DRAW_FRAME::GetUserUnits(), m_Frame, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, and ValueFromString().

Referenced by TransferDataFromWindow(), and validateData().

133 {
134  return ValueFromString( m_Frame->GetUserUnits(), m_grid->GetCellValue( aRow, aCol ), true );
135 }
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
void PANEL_SETUP_TEXT_AND_GRAPHICS::ImportSettingsFrom ( BOARD aBoard)

Definition at line 187 of file panel_setup_text_and_graphics.cpp.

References WX_GRID::CommitPendingChanges(), BOARD::GetDesignSettings(), m_BrdSettings, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, and TransferDataToWindow().

Referenced by DIALOG_BOARD_SETUP::OnAuxiliaryAction().

188 {
189  if( !m_grid->CommitPendingChanges() )
190  return;
191 
192  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
193 
194  m_BrdSettings = &aBoard->GetDesignSettings();
196 
197  m_BrdSettings = savedSettings;
198 }
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:156
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow ( )
override

Definition at line 162 of file panel_setup_text_and_graphics.cpp.

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_ITALIC, COL_TEXT_THICKNESS, COL_TEXT_UPRIGHT, COL_TEXT_WIDTH, getGridValue(), i, m_BrdSettings, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, BOARD_DESIGN_SETTINGS::m_LineThickness, BOARD_DESIGN_SETTINGS::m_TextItalic, BOARD_DESIGN_SETTINGS::m_TextSize, BOARD_DESIGN_SETTINGS::m_TextThickness, BOARD_DESIGN_SETTINGS::m_TextUpright, ROW_COUNT, ROW_COURTYARD, ROW_EDGES, and validateData().

163 {
164  if( !validateData() )
165  return false;
166 
167  for( int i = 0; i < ROW_COUNT; ++i )
168  {
170 
171  if( i == ROW_EDGES || i == ROW_COURTYARD )
172  continue;
173 
178  wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_ITALIC ) );
180  wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_UPRIGHT ) );
181  }
182 
183  return true;
184 }
wxSize m_TextSize[LAYER_CLASS_COUNT]
int m_TextThickness[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
int m_LineThickness[LAYER_CLASS_COUNT]
size_t i
Definition: json11.cpp:597
bool m_TextUpright[LAYER_CLASS_COUNT]
bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow ( )
override

Definition at line 84 of file panel_setup_text_and_graphics.cpp.

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_ITALIC, COL_TEXT_THICKNESS, COL_TEXT_UPRIGHT, COL_TEXT_WIDTH, DISABLE_CELL, i, m_BrdSettings, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, BOARD_DESIGN_SETTINGS::m_LineThickness, BOARD_DESIGN_SETTINGS::m_TextItalic, BOARD_DESIGN_SETTINGS::m_TextSize, BOARD_DESIGN_SETTINGS::m_TextThickness, BOARD_DESIGN_SETTINGS::m_TextUpright, ROW_COUNT, ROW_COURTYARD, ROW_EDGES, and SET_MILS_CELL.

Referenced by ImportSettingsFrom().

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  {
105  }
106  else
107  {
111  m_grid->SetCellValue( i, COL_TEXT_ITALIC, m_BrdSettings->m_TextItalic[ i ] ? "1" : "" );
112  m_grid->SetCellValue( i, COL_TEXT_UPRIGHT, m_BrdSettings->m_TextUpright[ i ] ? "1" : "" );
113 
114  auto attr = new wxGridCellAttr;
115  attr->SetRenderer( new wxGridCellBoolRenderer() );
116  attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
117  attr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
118  m_grid->SetAttr( i, COL_TEXT_ITALIC, attr );
119 
120  attr = new wxGridCellAttr;
121  attr->SetRenderer( new wxGridCellBoolRenderer() );
122  attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
123  attr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
124  m_grid->SetAttr( i, COL_TEXT_UPRIGHT, attr );
125  }
126  }
127 
128  return true;
129 }
wxSize m_TextSize[LAYER_CLASS_COUNT]
int m_TextThickness[LAYER_CLASS_COUNT]
#define DISABLE_CELL(row, col)
bool m_TextItalic[LAYER_CLASS_COUNT]
int m_LineThickness[LAYER_CLASS_COUNT]
size_t i
Definition: json11.cpp:597
#define SET_MILS_CELL(row, col, val)
bool m_TextUpright[LAYER_CLASS_COUNT]
bool PANEL_SETUP_TEXT_AND_GRAPHICS::validateData ( )
private

Definition at line 138 of file panel_setup_text_and_graphics.cpp.

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

Referenced by TransferDataFromWindow().

139 {
140  if( !m_grid->CommitPendingChanges() )
141  return false;
142 
143  // Test text parameters.
144  for( int row : { ROW_SILK, ROW_COPPER, ROW_OTHERS } )
145  {
146  int textSize = std::min( getGridValue( row, COL_TEXT_WIDTH ),
147  getGridValue( row, COL_TEXT_HEIGHT ) );
148 
149  if( getGridValue( row, COL_TEXT_THICKNESS ) > textSize / 4 )
150  {
151  wxString msg = _( "Text will not be readable with a thickness greater than\n"
152  "1/4 its width or height." );
153  m_Parent->SetError( msg, this, m_grid, row, COL_TEXT_THICKNESS );
154  return false;
155  }
156  }
157 
158  return true;
159 }
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_SETUP_TEXT_AND_GRAPHICS::m_BrdSettings
private
PCB_EDIT_FRAME* PANEL_SETUP_TEXT_AND_GRAPHICS::m_Frame
private

Definition at line 42 of file panel_setup_text_and_graphics.h.

Referenced by getGridValue(), and PANEL_SETUP_TEXT_AND_GRAPHICS().

wxBoxSizer* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_gridSizer
protectedinherited
PAGED_DIALOG* PANEL_SETUP_TEXT_AND_GRAPHICS::m_Parent
private

Definition at line 41 of file panel_setup_text_and_graphics.h.

Referenced by PANEL_SETUP_TEXT_AND_GRAPHICS(), and validateData().

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_staticText1
protectedinherited

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