Font and color for FIELDS_GRID_TABLE.

Fixes https://gitlab.com/kicad/code/kicad/issues/11459
This commit is contained in:
Jeff Young 2022-05-04 01:08:11 +01:00
parent e80c5a4e4e
commit 9c5aa5c3c1
12 changed files with 118 additions and 39 deletions

View File

@ -60,7 +60,7 @@ DIALOG_LABEL_PROPERTIES_BASE::DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wx
m_grid = new WX_GRID( sbFields->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_grid->CreateGrid( 4, 11 );
m_grid->CreateGrid( 4, 13 );
m_grid->EnableEditing( true );
m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false );
@ -78,6 +78,8 @@ DIALOG_LABEL_PROPERTIES_BASE::DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wx
m_grid->SetColSize( 8, 48 );
m_grid->SetColSize( 9, 84 );
m_grid->SetColSize( 10, 84 );
m_grid->SetColSize( 11, 140 );
m_grid->SetColSize( 12, 48 );
m_grid->EnableDragColMove( false );
m_grid->EnableDragColSize( true );
m_grid->SetColLabelSize( 22 );
@ -92,6 +94,8 @@ DIALOG_LABEL_PROPERTIES_BASE::DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wx
m_grid->SetColLabelValue( 8, _("Orientation") );
m_grid->SetColLabelValue( 9, _("X Position") );
m_grid->SetColLabelValue( 10, _("Y Position") );
m_grid->SetColLabelValue( 11, _("Font") );
m_grid->SetColLabelValue( 12, _("Color") );
m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows

View File

@ -444,10 +444,10 @@
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">22</property>
<property name="col_label_values">&quot;Name&quot; &quot;Value&quot; &quot;Show&quot; &quot;H Align&quot; &quot;V Align&quot; &quot;Italic&quot; &quot;Bold&quot; &quot;Text Size&quot; &quot;Orientation&quot; &quot;X Position&quot; &quot;Y Position&quot;</property>
<property name="col_label_values">&quot;Name&quot; &quot;Value&quot; &quot;Show&quot; &quot;H Align&quot; &quot;V Align&quot; &quot;Italic&quot; &quot;Bold&quot; &quot;Text Size&quot; &quot;Orientation&quot; &quot;X Position&quot; &quot;Y Position&quot; &quot;Font&quot; &quot;Color&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">11</property>
<property name="column_sizes">72,84,48,72,72,48,48,84,48,84,84</property>
<property name="cols">13</property>
<property name="column_sizes">72,84,48,72,72,48,48,84,48,84,84,140,48</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>

View File

@ -32,7 +32,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow*
m_grid = new WX_GRID( sbSizer4->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_grid->CreateGrid( 4, 11 );
m_grid->CreateGrid( 4, 13 );
m_grid->EnableEditing( true );
m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false );
@ -50,6 +50,8 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow*
m_grid->SetColSize( 8, 84 );
m_grid->SetColSize( 9, 84 );
m_grid->SetColSize( 10, 84 );
m_grid->SetColSize( 11, 140 );
m_grid->SetColSize( 12, 48 );
m_grid->EnableDragColMove( false );
m_grid->EnableDragColSize( true );
m_grid->SetColLabelSize( 22 );
@ -64,6 +66,8 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow*
m_grid->SetColLabelValue( 8, _("Orientation") );
m_grid->SetColLabelValue( 9, _("X Position") );
m_grid->SetColLabelValue( 10, _("Y Position") );
m_grid->SetColLabelValue( 11, _("Font") );
m_grid->SetColLabelValue( 12, _("Color") );
m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows

View File

@ -225,10 +225,10 @@
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">22</property>
<property name="col_label_values">&quot;Name&quot; &quot;Value&quot; &quot;Show&quot; &quot;H Align&quot; &quot;V Align&quot; &quot;Italic&quot; &quot;Bold&quot; &quot;Text Size&quot; &quot;Orientation&quot; &quot;X Position&quot; &quot;Y Position&quot;</property>
<property name="col_label_values">&quot;Name&quot; &quot;Value&quot; &quot;Show&quot; &quot;H Align&quot; &quot;V Align&quot; &quot;Italic&quot; &quot;Bold&quot; &quot;Text Size&quot; &quot;Orientation&quot; &quot;X Position&quot; &quot;Y Position&quot; &quot;Font&quot; &quot;Color&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">11</property>
<property name="column_sizes">72,120,48,72,72,48,48,84,84,84,84</property>
<property name="cols">13</property>
<property name="column_sizes">72,120,48,72,72,48,48,84,84,84,84,140,48</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>

View File

@ -34,7 +34,7 @@ DIALOG_SHEET_PROPERTIES_BASE::DIALOG_SHEET_PROPERTIES_BASE( wxWindow* parent, wx
m_grid = new WX_GRID( sbFields->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_grid->CreateGrid( 4, 11 );
m_grid->CreateGrid( 4, 13 );
m_grid->EnableEditing( true );
m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false );
@ -52,6 +52,8 @@ DIALOG_SHEET_PROPERTIES_BASE::DIALOG_SHEET_PROPERTIES_BASE( wxWindow* parent, wx
m_grid->SetColSize( 8, 84 );
m_grid->SetColSize( 9, 84 );
m_grid->SetColSize( 10, 84 );
m_grid->SetColSize( 11, 140 );
m_grid->SetColSize( 12, 48 );
m_grid->EnableDragColMove( false );
m_grid->EnableDragColSize( true );
m_grid->SetColLabelSize( 22 );
@ -66,6 +68,8 @@ DIALOG_SHEET_PROPERTIES_BASE::DIALOG_SHEET_PROPERTIES_BASE( wxWindow* parent, wx
m_grid->SetColLabelValue( 8, _("Orientation") );
m_grid->SetColLabelValue( 9, _("X Position") );
m_grid->SetColLabelValue( 10, _("Y Position") );
m_grid->SetColLabelValue( 11, _("Font") );
m_grid->SetColLabelValue( 12, _("Color") );
m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows

View File

@ -169,10 +169,10 @@
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">22</property>
<property name="col_label_values">&quot;Name&quot; &quot;Value&quot; &quot;Show&quot; &quot;H Align&quot; &quot;V Align&quot; &quot;Italic&quot; &quot;Bold&quot; &quot;Text Size&quot; &quot;Orientation&quot; &quot;X Position&quot; &quot;Y Position&quot;</property>
<property name="col_label_values">&quot;Name&quot; &quot;Value&quot; &quot;Show&quot; &quot;H Align&quot; &quot;V Align&quot; &quot;Italic&quot; &quot;Bold&quot; &quot;Text Size&quot; &quot;Orientation&quot; &quot;X Position&quot; &quot;Y Position&quot; &quot;Font&quot; &quot;Color&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">11</property>
<property name="column_sizes">72,120,48,72,72,48,48,84,84,84,84</property>
<property name="cols">13</property>
<property name="column_sizes">72,120,48,72,72,48,48,84,84,84,84,140,48</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>

View File

@ -1006,9 +1006,11 @@ void DIALOG_SYMBOL_PROPERTIES::OnPinTableCellEdited( wxGridEvent& aEvent )
{
int row = aEvent.GetRow();
if( m_pinGrid->GetCellValue( row, COL_ALT_NAME ) ==
m_dataModel->GetValue( row, COL_BASE_NAME ) )
if( m_pinGrid->GetCellValue( row, COL_ALT_NAME )
== m_dataModel->GetValue( row, COL_BASE_NAME ) )
{
m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString );
}
// These are just to get the cells refreshed
m_dataModel->SetValue( row, COL_TYPE, m_dataModel->GetValue( row, COL_TYPE ) );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -29,7 +29,7 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent,
m_fieldsGrid = new WX_GRID( sbFields->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_fieldsGrid->CreateGrid( 4, 11 );
m_fieldsGrid->CreateGrid( 4, 13 );
m_fieldsGrid->EnableEditing( true );
m_fieldsGrid->EnableGridLines( true );
m_fieldsGrid->EnableDragGridSize( false );
@ -47,8 +47,11 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent,
m_fieldsGrid->SetColSize( 8, 84 );
m_fieldsGrid->SetColSize( 9, 84 );
m_fieldsGrid->SetColSize( 10, 84 );
m_fieldsGrid->SetColSize( 11, 140 );
m_fieldsGrid->SetColSize( 12, 48 );
m_fieldsGrid->EnableDragColMove( false );
m_fieldsGrid->EnableDragColSize( true );
m_fieldsGrid->SetColLabelSize( 22 );
m_fieldsGrid->SetColLabelValue( 0, _("Name") );
m_fieldsGrid->SetColLabelValue( 1, _("Value") );
m_fieldsGrid->SetColLabelValue( 2, _("Show") );
@ -60,7 +63,8 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent,
m_fieldsGrid->SetColLabelValue( 8, _("Orientation") );
m_fieldsGrid->SetColLabelValue( 9, _("X Position") );
m_fieldsGrid->SetColLabelValue( 10, _("Y Position") );
m_fieldsGrid->SetColLabelSize( 22 );
m_fieldsGrid->SetColLabelValue( 11, _("Font") );
m_fieldsGrid->SetColLabelValue( 12, _("Color") );
m_fieldsGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows
@ -265,12 +269,12 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent,
m_pinGrid->SetColSize( 4, 140 );
m_pinGrid->EnableDragColMove( false );
m_pinGrid->EnableDragColSize( true );
m_pinGrid->SetColLabelSize( 24 );
m_pinGrid->SetColLabelValue( 0, _("Pin Number") );
m_pinGrid->SetColLabelValue( 1, _("Base Pin Name") );
m_pinGrid->SetColLabelValue( 2, _("Alternate Assignment") );
m_pinGrid->SetColLabelValue( 3, _("Electrical Type") );
m_pinGrid->SetColLabelValue( 4, _("Graphic Style") );
m_pinGrid->SetColLabelSize( 24 );
m_pinGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="16" />
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration">; </property>
<property name="code_generation">C++</property>
@ -14,7 +14,6 @@
<property name="file">dialog_symbol_properties_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_edit_component_in_schematic_base</property>
@ -26,7 +25,6 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -52,7 +50,6 @@
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Symbol Properties</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
@ -220,10 +217,10 @@
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">22</property>
<property name="col_label_values">&quot;Name&quot; &quot;Value&quot; &quot;Show&quot; &quot;H Align&quot; &quot;V Align&quot; &quot;Italic&quot; &quot;Bold&quot; &quot;Text Size&quot; &quot;Orientation&quot; &quot;X Position&quot; &quot;Y Position&quot;</property>
<property name="col_label_values">&quot;Name&quot; &quot;Value&quot; &quot;Show&quot; &quot;H Align&quot; &quot;V Align&quot; &quot;Italic&quot; &quot;Bold&quot; &quot;Text Size&quot; &quot;Orientation&quot; &quot;X Position&quot; &quot;Y Position&quot; &quot;Font&quot; &quot;Color&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">11</property>
<property name="column_sizes">72,120,48,72,72,48,48,84,84,84,84</property>
<property name="cols">13</property>
<property name="column_sizes">72,120,48,72,72,48,48,84,84,84,84,140,48</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
@ -305,7 +302,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -379,7 +375,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -453,7 +448,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -537,7 +531,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -1504,7 +1497,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -1578,7 +1570,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -1652,7 +1643,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -1736,7 +1726,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -2138,7 +2127,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -78,7 +78,7 @@ class DIALOG_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM
wxButton* m_stdDialogButtonSizerOK;
wxButton* m_stdDialogButtonSizerCancel;
// Virtual event handlers, override them in your derived class
// Virtual event handlers, overide them in your derived class
virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnGridEditorHidden( wxGridEvent& event ) { event.Skip(); }
@ -103,7 +103,6 @@ class DIALOG_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM
public:
DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Symbol Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU );
~DIALOG_SYMBOL_PROPERTIES_BASE();
};

View File

@ -40,10 +40,14 @@
#include <project/project_file.h>
#include <project/net_settings.h>
#include "eda_doc.h"
#include "widgets/grid_color_swatch_helpers.h"
#include "font/fontconfig.h"
#include "font/kicad_font_name.h"
#include <wx/settings.h>
#include <string_utils.h>
#include <widgets/grid_combobox.h>
enum
{
MYID_SELECT_FOOTPRINT = GRIDTRICKS_FIRST_CLIENT_ID,
@ -51,6 +55,9 @@ enum
};
#define DEFAULT_FONT_NAME _( "Default Font" )
template <class T>
FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame,
WX_GRID* aGrid, LIB_SYMBOL* aSymbol ) :
@ -212,6 +219,24 @@ void FIELDS_GRID_TABLE<T>::initGrid( WX_GRID* aGrid )
m_netclassAttr = new wxGridCellAttr;
m_netclassAttr->SetEditor( new GRID_CELL_COMBOBOX( existingNetclasses ) );
wxArrayString fonts;
std::vector<std::string> fontNames;
Fontconfig()->ListFonts( fontNames );
for( const std::string& name : fontNames )
fonts.Add( wxString( name ) );
fonts.Sort();
fonts.Insert( KICAD_FONT_NAME, 0 );
fonts.Insert( DEFAULT_FONT_NAME, 0 );
m_fontAttr = new wxGridCellAttr;
m_fontAttr->SetEditor( new GRID_CELL_COMBOBOX( fonts ) );
m_colorAttr = new wxGridCellAttr;
m_colorAttr->SetRenderer( new GRID_CELL_COLOR_RENDERER( m_dialog ) );
m_colorAttr->SetEditor( new GRID_CELL_COLOR_SELECTOR( m_dialog, aGrid ) );
m_frame->Bind( UNITS_CHANGED, &FIELDS_GRID_TABLE<T>::onUnitsChanged, this );
}
@ -232,6 +257,8 @@ FIELDS_GRID_TABLE<T>::~FIELDS_GRID_TABLE()
m_hAlignAttr->DecRef();
m_orientationAttr->DecRef();
m_netclassAttr->DecRef();
m_fontAttr->DecRef();
m_colorAttr->DecRef();
m_frame->Unbind( UNITS_CHANGED, &FIELDS_GRID_TABLE<T>::onUnitsChanged, this );
}
@ -263,6 +290,8 @@ wxString FIELDS_GRID_TABLE<T>::GetColLabelValue( int aCol )
case FDC_ORIENTATION: return _( "Orientation" );
case FDC_POSX: return _( "X Position" );
case FDC_POSY: return _( "Y Position" );
case FDC_FONT: return _( "Font" );
case FDC_COLOR: return _( "Color" );
default: wxFAIL; return wxEmptyString;
}
}
@ -281,6 +310,8 @@ bool FIELDS_GRID_TABLE<T>::CanGetValueAs( int aRow, int aCol, const wxString& aT
case FDC_ORIENTATION:
case FDC_POSX:
case FDC_POSY:
case FDC_FONT:
case FDC_COLOR:
return aTypeName == wxGRID_VALUE_STRING;
case FDC_SHOWN:
@ -415,6 +446,14 @@ wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAtt
m_boolAttr->IncRef();
return m_boolAttr;
case FDC_FONT:
m_fontAttr->IncRef();
return m_fontAttr;
case FDC_COLOR:
m_colorAttr->IncRef();
return m_colorAttr;
default:
wxFAIL;
return nullptr;
@ -504,6 +543,15 @@ wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
case FDC_POSY:
return StringFromValue( m_frame->GetUserUnits(), field.GetTextPos().y, true );
case FDC_FONT:
if( field.GetFont() )
return field.GetFont()->GetName();
else
return DEFAULT_FONT_NAME;
case FDC_COLOR:
return field.GetTextColor().ToWxString( wxC2S_CSS_SYNTAX );
default:
// we can't assert here because wxWidgets sometimes calls this without checking
// the column type when trying to see if there's an overflow
@ -567,8 +615,8 @@ void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue
}
field.SetText( value );
}
break;
}
case FDC_SHOWN:
field.SetVisible( BoolFromString( aValue ) );
@ -583,6 +631,7 @@ void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
else
wxFAIL_MSG( wxT( "unknown horizontal alignment: " ) + aValue );
break;
case FDC_V_ALIGN:
@ -594,6 +643,7 @@ void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue
field.SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
else
wxFAIL_MSG( wxT( "unknown vertical alignment: " ) + aValue);
break;
case FDC_ITALIC:
@ -616,18 +666,35 @@ void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue
field.SetTextAngle( ANGLE_VERTICAL );
else
wxFAIL_MSG( wxT( "unknown orientation: " ) + aValue );
break;
case FDC_POSX:
case FDC_POSY:
pos = field.GetTextPos();
if( aCol == FDC_POSX )
pos.x = ValueFromString( m_frame->GetUserUnits(), aValue );
else
pos.y = ValueFromString( m_frame->GetUserUnits(), aValue );
field.SetTextPos( pos );
break;
case FDC_FONT:
if( aValue == DEFAULT_FONT_NAME )
field.SetFont( nullptr );
else if( aValue == KICAD_FONT_NAME )
field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(), field.IsItalic() ) );
else
field.SetFont( KIFONT::FONT::GetFont( aValue, field.IsBold(), field.IsItalic() ) );
break;
case FDC_COLOR:
field.SetTextColor( wxColor( aValue ) );
break;
default:
wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
break;
@ -650,12 +717,15 @@ void FIELDS_GRID_TABLE<T>::SetValueAsBool( int aRow, int aCol, bool aValue )
case FDC_SHOWN:
field.SetVisible( aValue );
break;
case FDC_ITALIC:
field.SetItalic( aValue );
break;
case FDC_BOLD:
field.SetBold( aValue );
break;
default:
wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
break;

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -64,6 +64,8 @@ enum FIELDS_DATA_COL_ORDER
FDC_ORIENTATION,
FDC_POSX,
FDC_POSY,
FDC_FONT,
FDC_COLOR,
FDC_COUNT // keep as last
};
@ -139,6 +141,8 @@ private:
wxGridCellAttr* m_hAlignAttr;
wxGridCellAttr* m_orientationAttr;
wxGridCellAttr* m_netclassAttr;
wxGridCellAttr* m_fontAttr;
wxGridCellAttr* m_colorAttr;
};