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_staticTextDefProp
 
WX_GRIDm_grid
 
wxStaticText * m_staticTextDefPropDim
 
wxPanel * m_panel1
 
wxStaticText * m_lblDimensionUnits
 
wxChoice * m_dimensionUnits
 
wxStaticText * m_lblTextPositionMode
 
wxChoice * m_dimensionTextPositionMode
 
wxStaticText * m_lblDimensionUnitsFormat
 
wxChoice * m_dimensionUnitsFormat
 
wxCheckBox * m_dimensionTextKeepAligned
 
wxStaticText * m_lblDimensionPrecision
 
wxChoice * m_dimensionPrecision
 
wxStaticText * m_lblArrowLength
 
wxTextCtrl * m_dimensionArrowLength
 
wxStaticText * m_arrowLengthUnits
 
wxCheckBox * m_dimensionSuppressZeroes
 
wxStaticText * m_lblExtensionOffset
 
wxTextCtrl * m_dimensionExtensionOffset
 
wxStaticText * m_dimensionExtensionOffsetUnits
 

Private Member Functions

void onUnitsChanged (wxCommandEvent &aEvent)
 

Private Attributes

PCB_EDIT_FRAMEm_Frame
 
BOARD_DESIGN_SETTINGSm_BrdSettings
 
UNIT_BINDER m_arrowLength
 
UNIT_BINDER m_extensionOffset
 

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::PANEL_SETUP_TEXT_AND_GRAPHICS ( PAGED_DIALOG aParent,
PCB_EDIT_FRAME aFrame 
)

Definition at line 57 of file panel_setup_text_and_graphics.cpp.

58 :
63{
64 m_Frame = aFrame;
66
72 m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
73
74 // Work around a bug in wxWidgets where it fails to recalculate the grid height
75 // after changing the default row size
76 m_grid->AppendRows( 1 );
77 m_grid->DeleteRows( m_grid->GetNumberRows() - 1, 1 );
78
79 // Gives a suitable size to m_grid columns
80 // The default wxWidget col size is not very good
81 // Calculate a min best size to handle longest usual numeric values:
82 int min_best_width = m_grid->GetTextExtent( wxT( "555,555555 mils" ) ).x;
83
84 for( int i = 0; i < m_grid->GetNumberCols(); ++i )
85 {
86 // We calculate the column min size only from texts sizes, not using the initial col width
87 // as this initial width is sometimes strange depending on the language (wxGrid bug?)
88 int min_width = m_grid->GetVisibleWidth( i );
89
90 m_grid->SetColMinimalWidth( i, min_width );
91
92 // We use a "best size" >= min_best_width
93 m_grid->SetColSize( i, std::max( min_width, min_best_width ) );
94 }
95
96 m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
97
98 m_Frame->Bind( UNITS_CHANGED, &PANEL_SETUP_TEXT_AND_GRAPHICS::onUnitsChanged, this );
99}
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:628
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
wxTreebook * GetTreebook()
Definition: paged_dialog.h:37
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, const wxString &name=wxEmptyString)
void onUnitsChanged(wxCommandEvent &aEvent)
BOARD * GetBoard() const
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculates the specified column based on the actual size of the text on screen.
Definition: wx_grid.cpp:377
void SetAutoEvalCols(const std::vector< int > &aCols)
Definition: wx_grid.h:90
void SetUnitsProvider(UNITS_PROVIDER *aProvider, int aCol=0)
Set a UNITS_PROVIDER to enable use of unit- and eval-based Getters.
Definition: wx_grid.cpp:329

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_THICKNESS, COL_TEXT_WIDTH, PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), WX_GRID::GetVisibleWidth(), m_BrdSettings, m_Frame, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, onUnitsChanged(), WX_GRID::SetAutoEvalCols(), and WX_GRID::SetUnitsProvider().

◆ ~PANEL_SETUP_TEXT_AND_GRAPHICS()

PANEL_SETUP_TEXT_AND_GRAPHICS::~PANEL_SETUP_TEXT_AND_GRAPHICS ( )
override

Definition at line 102 of file panel_setup_text_and_graphics.cpp.

103{
104 // destroy GRID_TRICKS before m_grid.
105 m_grid->PopEventHandler( true );
106
107 m_Frame->Unbind( UNITS_CHANGED, &PANEL_SETUP_TEXT_AND_GRAPHICS::onUnitsChanged, this );
108}

References m_Frame, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, and onUnitsChanged().

Member Function Documentation

◆ ImportSettingsFrom()

void PANEL_SETUP_TEXT_AND_GRAPHICS::ImportSettingsFrom ( BOARD aBoard)

Definition at line 241 of file panel_setup_text_and_graphics.cpp.

242{
244 return;
245
246 BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
247
248 m_BrdSettings = &aBoard->GetDesignSettings();
250
251 m_BrdSettings = savedSettings;
252}
Container for design settings for a BOARD object.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:280

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

Referenced by DIALOG_BOARD_SETUP::onAuxiliaryAction().

◆ onUnitsChanged()

void PANEL_SETUP_TEXT_AND_GRAPHICS::onUnitsChanged ( wxCommandEvent &  aEvent)
private

Definition at line 111 of file panel_setup_text_and_graphics.cpp.

112{
113 BOARD_DESIGN_SETTINGS tempBDS( nullptr, "dummy" );
115
116 m_BrdSettings = &tempBDS; // No, address of stack var does not escape function
117
120
121 m_BrdSettings = saveBDS;
122
123 aEvent.Skip();
124}

References m_BrdSettings, TransferDataFromWindow(), and TransferDataToWindow().

Referenced by PANEL_SETUP_TEXT_AND_GRAPHICS(), and ~PANEL_SETUP_TEXT_AND_GRAPHICS().

◆ TransferDataFromWindow()

bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow ( )
override

Definition at line 202 of file panel_setup_text_and_graphics.cpp.

203{
205 return false;
206
207 for( int i = 0; i < ROW_COUNT; ++i )
208 {
210
211 if( i == ROW_EDGES || i == ROW_COURTYARD )
212 continue;
213
218 wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_ITALIC ) );
220 wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_UPRIGHT ) );
221 }
222
223 // These are all stored in project file, not board, so no need for OnModify()
224
225 int mode = m_dimensionUnits->GetSelection();
226 m_BrdSettings->m_DimensionUnitsMode = static_cast<DIM_UNITS_MODE>( mode );
227 int format = m_dimensionUnitsFormat->GetSelection();
228 m_BrdSettings->m_DimensionUnitsFormat = static_cast<DIM_UNITS_FORMAT>( format );
231 int position = m_dimensionTextPositionMode->GetSelection();
232 m_BrdSettings->m_DimensionTextPosition = static_cast<DIM_TEXT_POSITION>( position );
236
237 return true;
238}
DIM_UNITS_FORMAT m_DimensionUnitsFormat
bool m_TextUpright[LAYER_CLASS_COUNT]
int m_DimensionPrecision
Number of digits after the decimal.
int m_TextThickness[LAYER_CLASS_COUNT]
int m_LineThickness[LAYER_CLASS_COUNT]
wxSize m_TextSize[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
DIM_TEXT_POSITION m_DimensionTextPosition
DIM_UNITS_MODE m_DimensionUnitsMode
virtual long long int GetValue()
Return the current value in Internal Units.
int GetUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
Definition: wx_grid.cpp:338
DIM_TEXT_POSITION
Where to place the text on a dimension.
Definition: pcb_dimension.h:48
DIM_UNITS_FORMAT
How to display the units in a dimension's text.
Definition: pcb_dimension.h:40
DIM_UNITS_MODE
Used for storing the units selection in the file because EDA_UNITS alone doesn't cut it.
Definition: pcb_dimension.h:58

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_ITALIC, COL_TEXT_THICKNESS, COL_TEXT_UPRIGHT, COL_TEXT_WIDTH, WX_GRID::CommitPendingChanges(), WX_GRID::GetUnitValue(), UNIT_BINDER::GetValue(), m_arrowLength, m_BrdSettings, BOARD_DESIGN_SETTINGS::m_DimensionArrowLength, BOARD_DESIGN_SETTINGS::m_DimensionExtensionOffset, BOARD_DESIGN_SETTINGS::m_DimensionKeepTextAligned, BOARD_DESIGN_SETTINGS::m_DimensionPrecision, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionPrecision, BOARD_DESIGN_SETTINGS::m_DimensionSuppressZeroes, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionSuppressZeroes, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionTextKeepAligned, BOARD_DESIGN_SETTINGS::m_DimensionTextPosition, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionTextPositionMode, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnits, BOARD_DESIGN_SETTINGS::m_DimensionUnitsFormat, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnitsFormat, BOARD_DESIGN_SETTINGS::m_DimensionUnitsMode, m_extensionOffset, 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, and ROW_EDGES.

Referenced by onUnitsChanged().

◆ TransferDataToWindow()

bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow ( )
override

Definition at line 127 of file panel_setup_text_and_graphics.cpp.

128{
129 wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND );
130
131#define SET_MILS_CELL( row, col, val ) \
132 m_grid->SetCellValue( row, col, m_Frame->StringFromValue( val, true ) )
133
134#define DISABLE_CELL( row, col ) \
135 m_grid->SetReadOnly( row, col ); m_grid->SetCellBackgroundColour( row, col, disabledColour );
136
137 for( int i = 0; i < ROW_COUNT; ++i )
138 {
140
141 if( i == ROW_EDGES || i == ROW_COURTYARD )
142 {
148 }
149 else
150 {
154 m_grid->SetCellValue( i, COL_TEXT_ITALIC, m_BrdSettings->m_TextItalic[ i ] ? wxT( "1" ) : wxT( "" ) );
155 m_grid->SetCellValue( i, COL_TEXT_UPRIGHT, m_BrdSettings->m_TextUpright[ i ] ? wxT( "1" ) : wxT( "" ) );
156
157 auto attr = new wxGridCellAttr;
158 attr->SetRenderer( new wxGridCellBoolRenderer() );
159 attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
160 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
161 m_grid->SetAttr( i, COL_TEXT_ITALIC, attr );
162
163 attr = new wxGridCellAttr;
164 attr->SetRenderer( new wxGridCellBoolRenderer() );
165 attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
166 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
167 m_grid->SetAttr( i, COL_TEXT_UPRIGHT, attr );
168 }
169 }
170
171 // Work around an issue where wxWidgets doesn't calculate the row width on its own
172 for( int col = 0; col < m_grid->GetNumberCols(); col++ )
173 m_grid->SetColMinimalWidth( col, m_grid->GetVisibleWidth( col ) );
174
175 m_grid->SetRowLabelSize( m_grid->GetVisibleWidth( -1, true, true, true ) );
176
177 Layout();
178
179 wxASSERT_MSG( m_BrdSettings->m_DimensionPrecision <= 4,
180 wxT( "Unhandled dimension precision!" ) );
181
182 int mode = static_cast<int>( m_BrdSettings->m_DimensionUnitsMode );
183 m_dimensionUnits->SetSelection( mode );
184
185 int format = static_cast<int>( m_BrdSettings->m_DimensionUnitsFormat );
186 m_dimensionUnitsFormat->SetSelection( format );
187
190
191 int position = static_cast<int>( m_BrdSettings->m_DimensionTextPosition );
192 m_dimensionTextPositionMode->SetSelection( position );
193
197
198 return true;
199}
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
#define SET_MILS_CELL(row, col, val)
#define DISABLE_CELL(row, col)

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_ITALIC, COL_TEXT_THICKNESS, COL_TEXT_UPRIGHT, COL_TEXT_WIDTH, DISABLE_CELL, WX_GRID::GetVisibleWidth(), m_arrowLength, m_BrdSettings, BOARD_DESIGN_SETTINGS::m_DimensionArrowLength, BOARD_DESIGN_SETTINGS::m_DimensionExtensionOffset, BOARD_DESIGN_SETTINGS::m_DimensionKeepTextAligned, BOARD_DESIGN_SETTINGS::m_DimensionPrecision, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionPrecision, BOARD_DESIGN_SETTINGS::m_DimensionSuppressZeroes, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionSuppressZeroes, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionTextKeepAligned, BOARD_DESIGN_SETTINGS::m_DimensionTextPosition, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionTextPositionMode, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnits, BOARD_DESIGN_SETTINGS::m_DimensionUnitsFormat, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnitsFormat, BOARD_DESIGN_SETTINGS::m_DimensionUnitsMode, m_extensionOffset, 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, SET_MILS_CELL, and UNIT_BINDER::SetValue().

Referenced by ImportSettingsFrom(), and onUnitsChanged().

Member Data Documentation

◆ m_arrowLength

UNIT_BINDER PANEL_SETUP_TEXT_AND_GRAPHICS::m_arrowLength
private

Definition at line 55 of file panel_setup_text_and_graphics.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

◆ m_arrowLengthUnits

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_arrowLengthUnits
protectedinherited

◆ m_BrdSettings

BOARD_DESIGN_SETTINGS* PANEL_SETUP_TEXT_AND_GRAPHICS::m_BrdSettings
private

◆ m_dimensionArrowLength

wxTextCtrl* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionArrowLength
protectedinherited

◆ m_dimensionExtensionOffset

wxTextCtrl* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionExtensionOffset
protectedinherited

◆ m_dimensionExtensionOffsetUnits

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionExtensionOffsetUnits
protectedinherited

◆ m_dimensionPrecision

wxChoice* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionPrecision
protectedinherited

◆ m_dimensionSuppressZeroes

wxCheckBox* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionSuppressZeroes
protectedinherited

◆ m_dimensionTextKeepAligned

wxCheckBox* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionTextKeepAligned
protectedinherited

◆ m_dimensionTextPositionMode

wxChoice* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionTextPositionMode
protectedinherited

◆ m_dimensionUnits

wxChoice* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnits
protectedinherited

◆ m_dimensionUnitsFormat

wxChoice* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnitsFormat
protectedinherited

◆ m_extensionOffset

UNIT_BINDER PANEL_SETUP_TEXT_AND_GRAPHICS::m_extensionOffset
private

Definition at line 56 of file panel_setup_text_and_graphics.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

◆ m_Frame

PCB_EDIT_FRAME* PANEL_SETUP_TEXT_AND_GRAPHICS::m_Frame
private

◆ m_grid

◆ m_gridSizer

wxBoxSizer* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_gridSizer
protectedinherited

◆ m_lblArrowLength

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_lblArrowLength
protectedinherited

◆ m_lblDimensionPrecision

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_lblDimensionPrecision
protectedinherited

◆ m_lblDimensionUnits

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_lblDimensionUnits
protectedinherited

◆ m_lblDimensionUnitsFormat

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_lblDimensionUnitsFormat
protectedinherited

◆ m_lblExtensionOffset

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_lblExtensionOffset
protectedinherited

◆ m_lblTextPositionMode

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_lblTextPositionMode
protectedinherited

◆ m_panel1

wxPanel* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_panel1
protectedinherited

◆ m_staticTextDefProp

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_staticTextDefProp
protectedinherited

◆ m_staticTextDefPropDim

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_staticTextDefPropDim
protectedinherited

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