ADDED: textbox and tablecell margins.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10672

Fixes https://gitlab.com/kicad/code/kicad/-/issues/6806
This commit is contained in:
Jeff Young 2024-01-20 17:05:21 +00:00
parent e445249720
commit 4eefbc7815
31 changed files with 4638 additions and 3150 deletions

View File

@ -194,6 +194,7 @@ line_spacing
links
locked
loss_tangent
margins
max_error
max_length
max_width

View File

@ -67,6 +67,10 @@ DIALOG_TABLECELL_PROPERTIES::DIALOG_TABLECELL_PROPERTIES( SCH_EDIT_FRAME* aFrame
m_borderWidth( aFrame, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits ),
m_separatorsWidth( aFrame, m_separatorsWidthLabel, m_separatorsWidthCtrl, m_separatorsWidthUnits ),
m_textSize( aFrame, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ),
m_marginLeft( aFrame, nullptr, m_marginLeftCtrl, nullptr ),
m_marginTop( aFrame, nullptr, m_marginTopCtrl, m_marginTopUnits ),
m_marginRight( aFrame, nullptr, m_marginRightCtrl, nullptr ),
m_marginBottom( aFrame, nullptr, m_marginBottomCtrl, nullptr ),
m_scintillaTricks( nullptr )
{
m_table = static_cast<SCH_TABLE*>( m_cell->GetParent() );
@ -245,6 +249,11 @@ bool DIALOG_TABLECELL_PROPERTIES::TransferDataToWindow()
else
m_fillColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
m_marginLeft.SetValue( m_cell->GetMarginLeft() );
m_marginTop.SetValue( m_cell->GetMarginTop() );
m_marginRight.SetValue( m_cell->GetMarginRight() );
m_marginBottom.SetValue( m_cell->GetMarginBottom() );
return true;
}
@ -458,6 +467,11 @@ bool DIALOG_TABLECELL_PROPERTIES::TransferDataFromWindow()
m_cell->SetFillColor( fillColor );
}
m_cell->SetMarginLeft( m_marginLeft.GetIntValue() );
m_cell->SetMarginTop( m_marginTop.GetIntValue() );
m_cell->SetMarginRight( m_marginRight.GetIntValue() );
m_cell->SetMarginBottom( m_marginBottom.GetIntValue() );
if( !commit.Empty() )
commit.Push( _( "Edit Table Cell" ), SKIP_CONNECTIVITY );

View File

@ -58,6 +58,10 @@ private:
UNIT_BINDER m_borderWidth;
UNIT_BINDER m_separatorsWidth;
UNIT_BINDER m_textSize;
UNIT_BINDER m_marginLeft;
UNIT_BINDER m_marginTop;
UNIT_BINDER m_marginRight;
UNIT_BINDER m_marginBottom;
SCINTILLA_TRICKS* m_scintillaTricks;
};

View File

@ -269,7 +269,7 @@ DIALOG_TABLECELL_PROPERTIES_BASE::DIALOG_TABLECELL_PROPERTIES_BASE( wxWindow* pa
bSizeCtrlSizer->Add( m_separator4, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMargins->Add( bSizeCtrlSizer, 0, wxBOTTOM, 10 );
bMargins->Add( bSizeCtrlSizer, 0, wxBOTTOM, 5 );
wxGridBagSizer* gbSizer2;
gbSizer2 = new wxGridBagSizer( 4, 5 );
@ -309,6 +309,9 @@ DIALOG_TABLECELL_PROPERTIES_BASE::DIALOG_TABLECELL_PROPERTIES_BASE( wxWindow* pa
bMargins->Add( gbSizer2, 0, wxEXPAND|wxBOTTOM, 5 );
bMargins->Add( 0, 5, 0, wxEXPAND, 5 );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 2, 6, 5 );
fgSizer1->SetFlexibleDirection( wxBOTH );
@ -349,7 +352,62 @@ DIALOG_TABLECELL_PROPERTIES_BASE::DIALOG_TABLECELL_PROPERTIES_BASE( wxWindow* pa
fgSizer1->Add( m_panelFillColor, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMargins->Add( fgSizer1, 1, wxEXPAND|wxTOP, 5 );
bMargins->Add( fgSizer1, 0, wxEXPAND|wxTOP, 5 );
bMargins->Add( 0, 10, 0, wxEXPAND, 5 );
wxGridBagSizer* gbSizer3;
gbSizer3 = new wxGridBagSizer( 1, 0 );
gbSizer3->SetFlexibleDirection( wxBOTH );
gbSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_marginsLable = new wxStaticText( m_cellPage, wxID_ANY, _("Margins:"), wxDefaultPosition, wxDefaultSize, 0 );
m_marginsLable->Wrap( -1 );
gbSizer3->Add( m_marginsLable, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 35 );
wxBoxSizer* marginTopSizer;
marginTopSizer = new wxBoxSizer( wxHORIZONTAL );
m_marginTopCtrl = new wxTextCtrl( m_cellPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
marginTopSizer->Add( m_marginTopCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_marginTopUnits = new wxStaticText( m_cellPage, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_marginTopUnits->Wrap( -1 );
marginTopSizer->Add( m_marginTopUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 3 );
gbSizer3->Add( marginTopSizer, wxGBPosition( 0, 2 ), wxGBSpan( 1, 4 ), wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* marginLeftSizer;
marginLeftSizer = new wxBoxSizer( wxHORIZONTAL );
m_marginLeftCtrl = new wxTextCtrl( m_cellPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
marginLeftSizer->Add( m_marginLeftCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
gbSizer3->Add( marginLeftSizer, wxGBPosition( 1, 0 ), wxGBSpan( 1, 3 ), wxEXPAND|wxRIGHT|wxLEFT, 25 );
wxBoxSizer* marginRightSizer;
marginRightSizer = new wxBoxSizer( wxHORIZONTAL );
m_marginRightCtrl = new wxTextCtrl( m_cellPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
marginRightSizer->Add( m_marginRightCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
gbSizer3->Add( marginRightSizer, wxGBPosition( 1, 3 ), wxGBSpan( 1, 3 ), wxEXPAND, 5 );
wxBoxSizer* bSizer19;
bSizer19 = new wxBoxSizer( wxHORIZONTAL );
m_marginBottomCtrl = new wxTextCtrl( m_cellPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer19->Add( m_marginBottomCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
gbSizer3->Add( bSizer19, wxGBPosition( 2, 2 ), wxGBSpan( 1, 4 ), wxEXPAND, 5 );
bMargins->Add( gbSizer3, 1, wxEXPAND|wxTOP, 5 );
bSizer13->Add( bMargins, 1, wxEXPAND|wxALL, 5 );

View File

@ -1788,7 +1788,7 @@
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">10</property>
<property name="border">5</property>
<property name="flag">wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="true">
@ -3042,10 +3042,20 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="true">
<property name="height">5</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">1</property>
<property name="proportion">0</property>
<object class="wxFlexGridSizer" expanded="true">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
@ -3438,6 +3448,476 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="true">
<property name="height">10</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">1</property>
<object class="wxGridBagSizer" expanded="true">
<property name="empty_cell_size"></property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">gbSizer3</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="vgap">1</property>
<object class="gbsizeritem" expanded="true">
<property name="border">35</property>
<property name="colspan">2</property>
<property name="column">0</property>
<property name="flag">wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="row">0</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Margins:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginsLable</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="gbsizeritem" expanded="true">
<property name="border">5</property>
<property name="colspan">4</property>
<property name="column">2</property>
<property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
<property name="row">0</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">marginTopSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginTopCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">mm</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginTopUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
</object>
</object>
<object class="gbsizeritem" expanded="true">
<property name="border">25</property>
<property name="colspan">3</property>
<property name="column">0</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="row">1</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">marginLeftSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginLeftCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="gbsizeritem" expanded="true">
<property name="border">5</property>
<property name="colspan">3</property>
<property name="column">3</property>
<property name="flag">wxEXPAND</property>
<property name="row">1</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">marginRightSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginRightCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="gbsizeritem" expanded="true">
<property name="border">5</property>
<property name="colspan">4</property>
<property name="column">2</property>
<property name="flag">wxEXPAND</property>
<property name="row">2</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">bSizer19</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginBottomCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>

View File

@ -98,6 +98,12 @@ class DIALOG_TABLECELL_PROPERTIES_BASE : public DIALOG_SHIM
wxStaticText* m_fillColorLabel;
wxPanel* m_panelFillColor;
COLOR_SWATCH* m_fillColorSwatch;
wxStaticText* m_marginsLable;
wxTextCtrl* m_marginTopCtrl;
wxStaticText* m_marginTopUnits;
wxTextCtrl* m_marginLeftCtrl;
wxTextCtrl* m_marginRightCtrl;
wxTextCtrl* m_marginBottomCtrl;
wxButton* m_applyButton;
wxStaticText* m_hotkeyHint;
wxStdDialogButtonSizer* m_sdbSizer1;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -175,7 +175,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
bSizeCtrlSizer->Add( m_separator5, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( bSizeCtrlSizer, wxGBPosition( 3, 3 ), wxGBSpan( 1, 2 ), wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( bSizeCtrlSizer, wxGBPosition( 3, 3 ), wxGBSpan( 1, 3 ), wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textSizeLabel->Wrap( -1 );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!

View File

@ -52,16 +52,27 @@ LIB_TEXTBOX::LIB_TEXTBOX( LIB_SYMBOL* aParent, int aLineWidth, FILL_T aFillType,
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
SetVertJustify( GR_TEXT_V_ALIGN_TOP );
SetMultilineAllowed( true );
int defaultMargin = GetLegacyTextMargin();
m_marginLeft = defaultMargin;
m_marginTop = defaultMargin;
m_marginRight = defaultMargin;
m_marginBottom = defaultMargin;
}
LIB_TEXTBOX::LIB_TEXTBOX( const LIB_TEXTBOX& aText ) :
LIB_SHAPE( aText ),
EDA_TEXT( aText )
{ }
{
m_marginLeft = aText.m_marginLeft;
m_marginTop = aText.m_marginTop;
m_marginRight = aText.m_marginRight;
m_marginBottom = aText.m_marginBottom;
}
int LIB_TEXTBOX::GetTextMargin() const
int LIB_TEXTBOX::GetLegacyTextMargin() const
{
return KiROUND( GetTextSize().y * 0.8 );
}
@ -106,37 +117,36 @@ void LIB_TEXTBOX::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
VECTOR2I LIB_TEXTBOX::GetDrawPos() const
{
int margin = GetTextMargin();
BOX2I bbox( VECTOR2I( std::min( m_start.x, m_end.x ), std::min( -m_start.y, -m_end.y ) ),
VECTOR2I( abs( m_end.x - m_start.x ), abs( m_end.y - m_start.y ) ) );
VECTOR2I pos( bbox.GetLeft() + margin, bbox.GetBottom() - margin );
VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom );
if( GetTextAngle() == ANGLE_VERTICAL )
if( GetTextAngle().IsVertical() )
{
switch( GetHorizJustify() )
{
case GR_TEXT_H_ALIGN_LEFT:
pos.y = bbox.GetBottom() - margin;
pos.y = bbox.GetBottom() - m_marginBottom;
break;
case GR_TEXT_H_ALIGN_CENTER:
pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
break;
case GR_TEXT_H_ALIGN_RIGHT:
pos.y = bbox.GetTop() + margin;
pos.y = bbox.GetTop() + m_marginTop;
break;
}
switch( GetVertJustify() )
{
case GR_TEXT_V_ALIGN_TOP:
pos.x = bbox.GetLeft() + margin;
pos.x = bbox.GetLeft() + m_marginLeft;
break;
case GR_TEXT_V_ALIGN_CENTER:
pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
break;
case GR_TEXT_V_ALIGN_BOTTOM:
pos.x = bbox.GetRight() - margin;
pos.x = bbox.GetRight() - m_marginRight;
break;
}
}
@ -145,26 +155,26 @@ VECTOR2I LIB_TEXTBOX::GetDrawPos() const
switch( GetHorizJustify() )
{
case GR_TEXT_H_ALIGN_LEFT:
pos.x = bbox.GetLeft() + margin;
pos.x = bbox.GetLeft() + m_marginLeft;
break;
case GR_TEXT_H_ALIGN_CENTER:
pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
break;
case GR_TEXT_H_ALIGN_RIGHT:
pos.x = bbox.GetRight() - margin;
pos.x = bbox.GetRight() - m_marginRight;
break;
}
switch( GetVertJustify() )
{
case GR_TEXT_V_ALIGN_TOP:
pos.y = bbox.GetTop() + margin;
pos.y = bbox.GetTop() + m_marginTop;
break;
case GR_TEXT_V_ALIGN_CENTER:
pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
break;
case GR_TEXT_V_ALIGN_BOTTOM:
pos.y = bbox.GetBottom() - margin;
pos.y = bbox.GetBottom() - m_marginBottom;
break;
}
}
@ -207,6 +217,18 @@ int LIB_TEXTBOX::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
if( GetTextAngle().AsTenthsOfADegree() != tmp->GetTextAngle().AsTenthsOfADegree() )
return GetTextAngle().AsTenthsOfADegree() - tmp->GetTextAngle().AsTenthsOfADegree();
if( GetMarginLeft() != tmp->GetMarginLeft() )
return GetMarginLeft() - tmp->GetMarginLeft();
if( GetMarginTop() != tmp->GetMarginTop() )
return GetMarginTop() - tmp->GetMarginTop();
if( GetMarginRight() != tmp->GetMarginRight() )
return GetMarginRight() - tmp->GetMarginRight();
if( GetMarginBottom() != tmp->GetMarginBottom() )
return GetMarginBottom() - tmp->GetMarginBottom();
return EDA_SHAPE::Compare( &static_cast<const LIB_SHAPE&>( aOther ) );
}
@ -333,12 +355,16 @@ wxString LIB_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const
KIFONT::FONT* font = GetFont();
VECTOR2D size = GetEnd() - GetStart();
int colWidth = GetTextAngle() == ANGLE_HORIZONTAL ? size.x : size.y;
int colWidth;
if( GetTextAngle().IsVertical() )
colWidth = abs( size.y ) - ( GetMarginTop() + GetMarginBottom() );
else
colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
if( !font )
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
colWidth = abs( colWidth ) - GetTextMargin() * 2;
font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
return text;
@ -537,3 +563,42 @@ void LIB_TEXTBOX::ViewGetLayers( int aLayers[], int& aCount ) const
aLayers[1] = IsPrivate() ? LAYER_NOTES_BACKGROUND : LAYER_DEVICE_BACKGROUND;
aLayers[2] = LAYER_SELECTION_SHADOWS;
}
static struct LIB_TEXTBOX_DESC
{
LIB_TEXTBOX_DESC()
{
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( LIB_TEXTBOX );
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXTBOX, LIB_SHAPE> );
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXTBOX, EDA_SHAPE> );
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXTBOX, EDA_TEXT> );
propMgr.InheritsAfter( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( LIB_SHAPE ) );
propMgr.InheritsAfter( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ) );
propMgr.InheritsAfter( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ) );
propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) );
propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
propMgr.AddProperty( new PROPERTY<LIB_TEXTBOX, int>( _HKI( "Margin Left" ),
&LIB_TEXTBOX::SetMarginLeft, &LIB_TEXTBOX::GetMarginLeft, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<LIB_TEXTBOX, int>( _HKI( "Margin Top" ),
&LIB_TEXTBOX::SetMarginTop, &LIB_TEXTBOX::GetMarginTop, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<LIB_TEXTBOX, int>( _HKI( "Margin Right" ),
&LIB_TEXTBOX::SetMarginRight, &LIB_TEXTBOX::GetMarginRight, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<LIB_TEXTBOX, int>( _HKI( "Margin Bottom" ),
&LIB_TEXTBOX::SetMarginBottom, &LIB_TEXTBOX::GetMarginBottom, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.AddProperty( new PROPERTY<LIB_TEXTBOX, int>( _HKI( "Text Size" ),
&LIB_TEXTBOX::SetLibTextSize, &LIB_TEXTBOX::GetLibTextSize, PROPERTY_DISPLAY::PT_SIZE ),
_( "Text Properties" ) );
propMgr.Mask( TYPE_HASH( LIB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
}
} _LIB_TEXTBOX_DESC;

View File

@ -51,7 +51,20 @@ public:
return wxT( "LIB_TEXTBOX" );
}
int GetTextMargin() const;
int GetLegacyTextMargin() const;
void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
void SetMarginTop( int aTop ) { m_marginTop = aTop; }
void SetMarginRight( int aRight ) { m_marginRight = aRight; }
void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
int GetMarginLeft() const { return m_marginLeft; }
int GetMarginTop() const { return m_marginTop; }
int GetMarginRight() const { return m_marginRight; }
int GetMarginBottom() const { return m_marginBottom; }
int GetLibTextSize() const { return GetTextWidth(); }
void SetLibTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
VECTOR2I GetDrawPos() const override;
@ -105,6 +118,12 @@ private:
void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
const TRANSFORM& aTransform, bool aDimmed ) override;
private:
int m_marginLeft;
int m_marginTop;
int m_marginRight;
int m_marginBottom;
};

View File

@ -1349,13 +1349,17 @@ void SCH_IO_KICAD_SEXPR::saveTextBox( SCH_TEXTBOX* aTextBox, int aNestLevel )
VECTOR2I pos = aTextBox->GetStart();
VECTOR2I size = aTextBox->GetEnd() - pos;
m_out->Print( aNestLevel + 1, "(exclude_from_sim %s) (at %s %s %s) (size %s %s)",
m_out->Print( aNestLevel + 1, "(exclude_from_sim %s) (at %s %s %s) (size %s %s) (margins %s %s %s %s)",
aTextBox->GetExcludedFromSim() ? "yes" : "no",
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.x ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.y ).c_str(),
EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.x ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.y ).c_str() );
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.y ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aTextBox->GetMarginLeft() ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aTextBox->GetMarginTop() ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aTextBox->GetMarginRight() ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aTextBox->GetMarginBottom() ).c_str() );
if( SCH_TABLECELL* cell = dynamic_cast<SCH_TABLECELL*>( aTextBox ) )
m_out->Print( 0, " (span %d %d)", cell->GetColSpan(), cell->GetRowSpan() );

View File

@ -502,12 +502,16 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveTextBox( LIB_TEXTBOX* aTextBox, OUTPUTFOR
VECTOR2I pos = aTextBox->GetStart();
VECTOR2I size = aTextBox->GetEnd() - pos;
aFormatter.Print( aNestLevel + 1, "(at %s %s %s) (size %s %s)\n",
aFormatter.Print( aNestLevel + 1, "(at %s %s %s) (size %s %s) (margins %s %s %s %s)\n",
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.x ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.y ).c_str(),
EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.x ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.y ).c_str() );
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.y ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aTextBox->GetMarginLeft() ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aTextBox->GetMarginTop() ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aTextBox->GetMarginRight() ).c_str(),
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aTextBox->GetMarginBottom() ).c_str() );
aTextBox->GetStroke().Format( &aFormatter, schIUScale, aNestLevel + 1 );
aFormatter.Print( 0, "\n" );

View File

@ -1816,10 +1816,16 @@ LIB_TEXTBOX* SCH_IO_KICAD_SEXPR_PARSER::parseTextBox()
VECTOR2I pos;
VECTOR2I end;
VECTOR2I size;
bool foundEnd = false;
bool foundSize = false;
int left;
int top;
int right;
int bottom;
STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT );
FILL_PARAMS fill;
bool foundEnd = false;
bool foundSize = false;
bool foundMargins = false;
std::unique_ptr<LIB_TEXTBOX> textBox = std::make_unique<LIB_TEXTBOX>( nullptr );
textBox->SetUnit( m_unit );
@ -1883,6 +1889,16 @@ LIB_TEXTBOX* SCH_IO_KICAD_SEXPR_PARSER::parseTextBox()
textBox->SetFillColor( fill.m_Color );
break;
case T_margins:
parseMargins( left, top, right, bottom );
textBox->SetMarginLeft( left );
textBox->SetMarginTop( top );
textBox->SetMarginRight( right );
textBox->SetMarginBottom( bottom );
foundMargins = true;
NeedRIGHT();
break;
case T_effects:
parseEDA_TEXT( static_cast<EDA_TEXT*>( textBox.get() ), false );
break;
@ -1901,6 +1917,15 @@ LIB_TEXTBOX* SCH_IO_KICAD_SEXPR_PARSER::parseTextBox()
else
Expecting( "size" );
if( !foundMargins )
{
int margin = textBox->GetLegacyTextMargin();
textBox->SetMarginLeft( margin );
textBox->SetMarginTop( margin );
textBox->SetMarginRight( margin );
textBox->SetMarginBottom( margin );
}
return textBox.release();
}
@ -4174,10 +4199,15 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseSchTextBoxContent( SCH_TEXTBOX* aTextBox )
VECTOR2I pos;
VECTOR2I end;
VECTOR2I size;
bool foundEnd = false;
bool foundSize = false;
int left;
int top;
int right;
int bottom;
STROKE_PARAMS stroke( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ), LINE_STYLE::DEFAULT );
FILL_PARAMS fill;
bool foundEnd = false;
bool foundSize = false;
bool foundMargins = false;
NeedSYMBOL();
@ -4245,6 +4275,16 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseSchTextBoxContent( SCH_TEXTBOX* aTextBox )
aTextBox->SetFillColor( fill.m_Color );
break;
case T_margins:
parseMargins( left, top, right, bottom );
aTextBox->SetMarginLeft( left );
aTextBox->SetMarginTop( top );
aTextBox->SetMarginRight( right );
aTextBox->SetMarginBottom( bottom );
foundMargins = true;
NeedRIGHT();
break;
case T_effects:
parseEDA_TEXT( static_cast<EDA_TEXT*>( aTextBox ), false );
break;
@ -4271,6 +4311,15 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseSchTextBoxContent( SCH_TEXTBOX* aTextBox )
aTextBox->SetEnd( pos + size );
else
Expecting( "size" );
if( !foundMargins )
{
int margin = aTextBox->GetLegacyTextMargin();
aTextBox->SetMarginLeft( margin );
aTextBox->SetMarginTop( margin );
aTextBox->SetMarginRight( margin );
aTextBox->SetMarginBottom( margin );
}
}

View File

@ -182,6 +182,14 @@ private:
void parseFill( FILL_PARAMS& aFill );
void parseMargins( int& aLeft, int& aTop, int& aRight, int& aBottom )
{
aLeft = parseInternalUnits( "left margin" );
aTop = parseInternalUnits( "top margin" );
aRight = parseInternalUnits( "right margin" );
aBottom = parseInternalUnits( "bottom margin" );
}
void parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSyntax,
bool aEnforceMinTextSize = true );
void parsePinNames( std::unique_ptr<LIB_SYMBOL>& aSymbol );

View File

@ -602,11 +602,11 @@ static struct SCH_TABLE_DESC
propMgr.AddTypeCast( new TYPE_CAST<SCH_TABLE, SCH_ITEM> );
propMgr.InheritsAfter( TYPE_HASH( SCH_TABLE ), TYPE_HASH( SCH_ITEM ) );
propMgr.AddProperty( new PROPERTY<EDA_SHAPE, int>( _HKI( "Start X" ),
&EDA_SHAPE::SetStartX, &EDA_SHAPE::GetStartX, PROPERTY_DISPLAY::PT_COORD,
propMgr.AddProperty( new PROPERTY<SCH_TABLE, int>( _HKI( "Start X" ),
&SCH_TABLE::SetPositionX, &SCH_TABLE::GetPositionX, PROPERTY_DISPLAY::PT_COORD,
ORIGIN_TRANSFORMS::ABS_X_COORD ) );
propMgr.AddProperty( new PROPERTY<EDA_SHAPE, int>( _HKI( "Start Y" ),
&EDA_SHAPE::SetStartY, &EDA_SHAPE::GetStartY, PROPERTY_DISPLAY::PT_COORD,
propMgr.AddProperty( new PROPERTY<SCH_TABLE, int>( _HKI( "Start Y" ),
&SCH_TABLE::SetPositionY, &SCH_TABLE::GetPositionY, PROPERTY_DISPLAY::PT_COORD,
ORIGIN_TRANSFORMS::ABS_Y_COORD ) );
const wxString tableProps = _( "Table Properties" );

View File

@ -96,6 +96,12 @@ public:
VECTOR2I GetPosition() const override;
VECTOR2I GetEnd() const;
// For property manager:
void SetPositionX( int x ) { SetPosition( VECTOR2I( x, GetPosition().y ) ); }
void SetPositionY( int y ) { SetPosition( VECTOR2I( GetPosition().x, y ) ); }
int GetPositionX() const { return GetPosition().x; }
int GetPositionY() const { return GetPosition().y; }
void SetColCount( int aCount ) { m_colCount = aCount; }
int GetColCount() const { return m_colCount; }

View File

@ -54,6 +54,12 @@ SCH_TEXTBOX::SCH_TEXTBOX( int aLineWidth, FILL_T aFillType, const wxString& text
SetMultilineAllowed( true );
m_excludedFromSim = false;
int defaultMargin = GetLegacyTextMargin();
m_marginLeft = defaultMargin;
m_marginTop = defaultMargin;
m_marginRight = defaultMargin;
m_marginBottom = defaultMargin;
}
@ -62,10 +68,14 @@ SCH_TEXTBOX::SCH_TEXTBOX( const SCH_TEXTBOX& aText ) :
EDA_TEXT( aText )
{
m_excludedFromSim = aText.m_excludedFromSim;
m_marginLeft = aText.m_marginLeft;
m_marginTop = aText.m_marginTop;
m_marginRight = aText.m_marginRight;
m_marginBottom = aText.m_marginBottom;
}
int SCH_TEXTBOX::GetTextMargin() const
int SCH_TEXTBOX::GetLegacyTextMargin() const
{
return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
}
@ -116,38 +126,37 @@ void SCH_TEXTBOX::Rotate90( bool aClockwise )
VECTOR2I SCH_TEXTBOX::GetDrawPos() const
{
int margin = GetTextMargin();
BOX2I bbox( m_start, m_end - m_start );
bbox.Normalize();
VECTOR2I pos( bbox.GetLeft() + margin, bbox.GetBottom() - margin );
VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom );
if( GetTextAngle() == ANGLE_VERTICAL )
if( GetTextAngle().IsVertical() )
{
switch( GetHorizJustify() )
{
case GR_TEXT_H_ALIGN_LEFT:
pos.y = bbox.GetBottom() - margin;
pos.y = bbox.GetBottom() - m_marginBottom;
break;
case GR_TEXT_H_ALIGN_CENTER:
pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
break;
case GR_TEXT_H_ALIGN_RIGHT:
pos.y = bbox.GetTop() + margin;
pos.y = bbox.GetTop() + m_marginTop;
break;
}
switch( GetVertJustify() )
{
case GR_TEXT_V_ALIGN_TOP:
pos.x = bbox.GetLeft() + margin;
pos.x = bbox.GetLeft() + m_marginLeft;
break;
case GR_TEXT_V_ALIGN_CENTER:
pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
break;
case GR_TEXT_V_ALIGN_BOTTOM:
pos.x = bbox.GetRight() - margin;
pos.x = bbox.GetRight() - m_marginRight;
break;
}
}
@ -156,26 +165,26 @@ VECTOR2I SCH_TEXTBOX::GetDrawPos() const
switch( GetHorizJustify() )
{
case GR_TEXT_H_ALIGN_LEFT:
pos.x = bbox.GetLeft() + margin;
pos.x = bbox.GetLeft() + m_marginLeft;
break;
case GR_TEXT_H_ALIGN_CENTER:
pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
break;
case GR_TEXT_H_ALIGN_RIGHT:
pos.x = bbox.GetRight() - margin;
pos.x = bbox.GetRight() - m_marginRight;
break;
}
switch( GetVertJustify() )
{
case GR_TEXT_V_ALIGN_TOP:
pos.y = bbox.GetTop() + margin;
pos.y = bbox.GetTop() + m_marginTop;
break;
case GR_TEXT_V_ALIGN_CENTER:
pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
break;
case GR_TEXT_V_ALIGN_BOTTOM:
pos.y = bbox.GetBottom() - margin;
pos.y = bbox.GetBottom() - m_marginBottom;
break;
}
}
@ -191,6 +200,10 @@ void SCH_TEXTBOX::SwapData( SCH_ITEM* aItem )
SCH_TEXTBOX* item = static_cast<SCH_TEXTBOX*>( aItem );
std::swap( m_layer, item->m_layer );
std::swap( m_marginLeft, item->m_marginLeft );
std::swap( m_marginTop, item->m_marginTop );
std::swap( m_marginRight, item->m_marginRight );
std::swap( m_marginBottom, item->m_marginBottom );
SwapText( *item );
SwapAttributes( *item );
@ -205,7 +218,7 @@ bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const
auto other = static_cast<const SCH_TEXTBOX*>( &aItem );
if( GetLayer() != other->GetLayer() )
return GetLayer() < other->GetLayer();
return GetLayer() < other->GetLayer();
if( GetPosition().x != other->GetPosition().x )
return GetPosition().x < other->GetPosition().x;
@ -213,6 +226,18 @@ bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const
if( GetPosition().y != other->GetPosition().y )
return GetPosition().y < other->GetPosition().y;
if( GetMarginLeft() != other->GetMarginLeft() )
return GetMarginLeft() < other->GetMarginLeft();
if( GetMarginTop() != other->GetMarginTop() )
return GetMarginTop() < other->GetMarginTop();
if( GetMarginRight() != other->GetMarginRight() )
return GetMarginRight() < other->GetMarginRight();
if( GetMarginBottom() != other->GetMarginBottom() )
return GetMarginBottom() < other->GetMarginBottom();
if( GetExcludedFromSim() != other->GetExcludedFromSim() )
return GetExcludedFromSim() - other->GetExcludedFromSim();
@ -319,9 +344,13 @@ wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtr
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
VECTOR2I size = GetEnd() - GetStart();
int colWidth = GetTextAngle() == ANGLE_HORIZONTAL ? size.x : size.y;
int colWidth;
if( GetTextAngle().IsVertical() )
colWidth = abs( size.y ) - ( GetMarginTop() + GetMarginBottom() );
else
colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
colWidth = abs( colWidth ) - GetTextMargin() * 2;
font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
return text;
@ -475,6 +504,18 @@ bool SCH_TEXTBOX::operator==( const SCH_ITEM& aOther ) const
if( m_excludedFromSim != other.m_excludedFromSim )
return false;
if( GetMarginLeft() != other.GetMarginLeft() )
return false;
if( GetMarginTop() != other.GetMarginTop() )
return false;
if( GetMarginRight() != other.GetMarginRight() )
return false;
if( GetMarginBottom() != other.GetMarginBottom() )
return false;
return SCH_SHAPE::operator==( aOther ) && EDA_TEXT::operator==( other );
}
@ -491,6 +532,18 @@ double SCH_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const
if( m_excludedFromSim != other.m_excludedFromSim )
similarity *= 0.9;
if( GetMarginLeft() != other.GetMarginLeft() )
similarity *= 0.9;
if( GetMarginTop() != other.GetMarginTop() )
similarity *= 0.9;
if( GetMarginRight() != other.GetMarginRight() )
similarity *= 0.9;
if( GetMarginBottom() != other.GetMarginBottom() )
similarity *= 0.9;
similarity *= SCH_SHAPE::Similarity( aOther );
similarity *= EDA_TEXT::Similarity( other );
@ -514,12 +567,33 @@ static struct SCH_TEXTBOX_DESC
propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) );
propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
const wxString marginProps = _( "Margins" );
propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Left" ),
&SCH_TEXTBOX::SetMarginLeft, &SCH_TEXTBOX::GetMarginLeft,
PROPERTY_DISPLAY::PT_SIZE ),
marginProps );
propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Top" ),
&SCH_TEXTBOX::SetMarginTop, &SCH_TEXTBOX::GetMarginTop,
PROPERTY_DISPLAY::PT_SIZE ),
marginProps );
propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Right" ),
&SCH_TEXTBOX::SetMarginRight, &SCH_TEXTBOX::GetMarginRight,
PROPERTY_DISPLAY::PT_SIZE ),
marginProps );
propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Bottom" ),
&SCH_TEXTBOX::SetMarginBottom, &SCH_TEXTBOX::GetMarginBottom,
PROPERTY_DISPLAY::PT_SIZE ),
marginProps );
propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Text Size" ),
&SCH_TEXTBOX::SetSchTextSize, &SCH_TEXTBOX::GetSchTextSize, PROPERTY_DISPLAY::PT_SIZE ),
&SCH_TEXTBOX::SetSchTextSize, &SCH_TEXTBOX::GetSchTextSize,
PROPERTY_DISPLAY::PT_SIZE ),
_( "Text Properties" ) );
propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );

View File

@ -52,7 +52,17 @@ public:
return wxT( "SCH_TEXTBOX" );
}
int GetTextMargin() const;
int GetLegacyTextMargin() const;
void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
void SetMarginTop( int aTop ) { m_marginTop = aTop; }
void SetMarginRight( int aRight ) { m_marginRight = aRight; }
void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
int GetMarginLeft() const { return m_marginLeft; }
int GetMarginTop() const { return m_marginTop; }
int GetMarginRight() const { return m_marginRight; }
int GetMarginBottom() const { return m_marginBottom; }
int GetSchTextSize() const { return GetTextWidth(); }
void SetSchTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
@ -141,6 +151,10 @@ protected:
protected:
bool m_excludedFromSim;
int m_marginLeft;
int m_marginTop;
int m_marginRight;
int m_marginBottom;
};

View File

@ -80,6 +80,7 @@ lib_name
lib_symbols
line
line_spacing
margins
members
mid
mirror

View File

@ -2123,7 +2123,10 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
BOX2I bbox = textbox->GetBoundingBox();
bbox.Inflate( -textbox->GetTextMargin() );
bbox.SetOrigin( bbox.GetLeft() + textbox->GetMarginLeft(),
bbox.GetTop() + textbox->GetMarginTop() );
bbox.SetEnd( bbox.GetRight() - textbox->GetMarginRight(),
bbox.GetBottom() - textbox->GetMarginBottom() );
if( convertTo == SCH_LABEL_T
|| convertTo == SCH_HIER_LABEL_T
@ -2277,14 +2280,16 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
new_textbox->SetAttributes( *sourceText, false );
int margin = new_textbox->GetTextMargin();
bbox.Inflate( margin );
bbox.SetOrigin( bbox.GetLeft() - new_textbox->GetMarginLeft(),
bbox.GetTop() - new_textbox->GetMarginTop() );
bbox.SetEnd( bbox.GetRight() + new_textbox->GetMarginRight(),
bbox.GetBottom() + new_textbox->GetMarginBottom() );
VECTOR2I topLeft = bbox.GetPosition();
VECTOR2I botRight = bbox.GetEnd();
// Add 1/20 of the margin at the end to reduce line-breaking changes.
int slop = margin / 20;
int slop = new_textbox->GetLegacyTextMargin() / 20;
if( sourceText->GetTextAngle() == ANGLE_VERTICAL )
{

View File

@ -74,6 +74,10 @@ DIALOG_TABLECELL_PROPERTIES::DIALOG_TABLECELL_PROPERTIES( PCB_BASE_EDIT_FRAME* a
m_textHeight( aFrame, m_SizeYLabel, m_SizeYCtrl, m_SizeYUnits ),
m_textWidth( aFrame, m_SizeXLabel, m_SizeXCtrl, m_SizeXUnits ),
m_textThickness( aFrame, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnits ),
m_marginLeft( aFrame, nullptr, m_marginLeftCtrl, nullptr ),
m_marginTop( aFrame, nullptr, m_marginTopCtrl, m_marginTopUnits ),
m_marginRight( aFrame, nullptr, m_marginRightCtrl, nullptr ),
m_marginBottom( aFrame, nullptr, m_marginBottomCtrl, nullptr ),
m_scintillaTricks( nullptr )
{
m_table = static_cast<PCB_TABLE*>( m_cell->GetParent() );
@ -254,6 +258,11 @@ bool DIALOG_TABLECELL_PROPERTIES::TransferDataToWindow()
case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check(); break;
}
m_marginLeft.SetValue( m_cell->GetMarginLeft() );
m_marginTop.SetValue( m_cell->GetMarginTop() );
m_marginRight.SetValue( m_cell->GetMarginRight() );
m_marginBottom.SetValue( m_cell->GetMarginBottom() );
return true;
}
@ -459,6 +468,11 @@ bool DIALOG_TABLECELL_PROPERTIES::TransferDataFromWindow()
else
m_cell->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
m_cell->SetMarginLeft( m_marginLeft.GetIntValue() );
m_cell->SetMarginTop( m_marginTop.GetIntValue() );
m_cell->SetMarginRight( m_marginRight.GetIntValue() );
m_cell->SetMarginBottom( m_marginBottom.GetIntValue() );
if( !commit.Empty() )
commit.Push( _( "Edit Table Cell" ), SKIP_CONNECTIVITY );

View File

@ -64,6 +64,10 @@ private:
UNIT_BINDER m_textHeight;
UNIT_BINDER m_textWidth;
UNIT_BINDER m_textThickness;
UNIT_BINDER m_marginLeft;
UNIT_BINDER m_marginTop;
UNIT_BINDER m_marginRight;
UNIT_BINDER m_marginBottom;
SCINTILLA_TRICKS* m_scintillaTricks;
};

View File

@ -241,7 +241,7 @@ DIALOG_TABLECELL_PROPERTIES_BASE::DIALOG_TABLECELL_PROPERTIES_BASE( wxWindow* pa
bSizeCtrlSizer->Add( m_separator4, 0, wxALIGN_CENTER_VERTICAL, 5 );
bMargins->Add( bSizeCtrlSizer, 0, wxBOTTOM, 10 );
bMargins->Add( bSizeCtrlSizer, 0, wxBOTTOM, 5 );
wxGridBagSizer* gbSizer2;
gbSizer2 = new wxGridBagSizer( 4, 5 );
@ -262,7 +262,7 @@ DIALOG_TABLECELL_PROPERTIES_BASE::DIALOG_TABLECELL_PROPERTIES_BASE( wxWindow* pa
gbSizer2->AddGrowableCol( 1 );
bMargins->Add( gbSizer2, 0, wxEXPAND|wxBOTTOM, 5 );
bMargins->Add( gbSizer2, 0, wxEXPAND, 5 );
wxGridBagSizer* gbSizer1;
gbSizer1 = new wxGridBagSizer( 3, 5 );
@ -312,6 +312,58 @@ DIALOG_TABLECELL_PROPERTIES_BASE::DIALOG_TABLECELL_PROPERTIES_BASE( wxWindow* pa
bMargins->Add( gbSizer1, 1, wxEXPAND|wxTOP, 5 );
wxGridBagSizer* gbSizer3;
gbSizer3 = new wxGridBagSizer( 1, 0 );
gbSizer3->SetFlexibleDirection( wxBOTH );
gbSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_marginsLable = new wxStaticText( m_cellPage, wxID_ANY, _("Margins:"), wxDefaultPosition, wxDefaultSize, 0 );
m_marginsLable->Wrap( -1 );
gbSizer3->Add( m_marginsLable, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 35 );
wxBoxSizer* marginTopSizer;
marginTopSizer = new wxBoxSizer( wxHORIZONTAL );
m_marginTopCtrl = new wxTextCtrl( m_cellPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
marginTopSizer->Add( m_marginTopCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_marginTopUnits = new wxStaticText( m_cellPage, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_marginTopUnits->Wrap( -1 );
marginTopSizer->Add( m_marginTopUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 3 );
gbSizer3->Add( marginTopSizer, wxGBPosition( 0, 2 ), wxGBSpan( 1, 4 ), wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* marginLeftSizer;
marginLeftSizer = new wxBoxSizer( wxHORIZONTAL );
m_marginLeftCtrl = new wxTextCtrl( m_cellPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
marginLeftSizer->Add( m_marginLeftCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
gbSizer3->Add( marginLeftSizer, wxGBPosition( 1, 0 ), wxGBSpan( 1, 3 ), wxEXPAND|wxRIGHT|wxLEFT, 25 );
wxBoxSizer* marginRightSizer;
marginRightSizer = new wxBoxSizer( wxHORIZONTAL );
m_marginRightCtrl = new wxTextCtrl( m_cellPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
marginRightSizer->Add( m_marginRightCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
gbSizer3->Add( marginRightSizer, wxGBPosition( 1, 3 ), wxGBSpan( 1, 3 ), wxEXPAND, 5 );
wxBoxSizer* bSizer19;
bSizer19 = new wxBoxSizer( wxHORIZONTAL );
m_marginBottomCtrl = new wxTextCtrl( m_cellPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizer19->Add( m_marginBottomCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 );
gbSizer3->Add( bSizer19, wxGBPosition( 2, 2 ), wxGBSpan( 1, 4 ), wxEXPAND, 5 );
bMargins->Add( gbSizer3, 1, wxEXPAND, 5 );
bSizer13->Add( bMargins, 1, wxEXPAND|wxALL, 5 );

View File

@ -1592,7 +1592,7 @@
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">10</property>
<property name="border">5</property>
<property name="flag">wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="true">
@ -2492,7 +2492,7 @@
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxGridBagSizer" expanded="true">
<property name="empty_cell_size">-1,5</property>
@ -3254,6 +3254,466 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxGridBagSizer" expanded="true">
<property name="empty_cell_size"></property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">gbSizer3</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="vgap">1</property>
<object class="gbsizeritem" expanded="true">
<property name="border">35</property>
<property name="colspan">2</property>
<property name="column">0</property>
<property name="flag">wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="row">0</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Margins:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginsLable</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="gbsizeritem" expanded="true">
<property name="border">5</property>
<property name="colspan">4</property>
<property name="column">2</property>
<property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
<property name="row">0</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">marginTopSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginTopCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">mm</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginTopUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
</object>
</object>
<object class="gbsizeritem" expanded="true">
<property name="border">25</property>
<property name="colspan">3</property>
<property name="column">0</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="row">1</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">marginLeftSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginLeftCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="gbsizeritem" expanded="true">
<property name="border">5</property>
<property name="colspan">3</property>
<property name="column">3</property>
<property name="flag">wxEXPAND</property>
<property name="row">1</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">marginRightSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginRightCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="gbsizeritem" expanded="true">
<property name="border">5</property>
<property name="colspan">4</property>
<property name="column">2</property>
<property name="flag">wxEXPAND</property>
<property name="row">2</property>
<property name="rowspan">1</property>
<object class="wxBoxSizer" expanded="true">
<property name="minimum_size"></property>
<property name="name">bSizer19</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_marginBottomCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>

View File

@ -95,6 +95,12 @@ class DIALOG_TABLECELL_PROPERTIES_BASE : public DIALOG_SHIM
wxStaticText* m_ThicknessLabel;
wxTextCtrl* m_ThicknessCtrl;
wxStaticText* m_ThicknessUnits;
wxStaticText* m_marginsLable;
wxTextCtrl* m_marginTopCtrl;
wxStaticText* m_marginTopUnits;
wxTextCtrl* m_marginLeftCtrl;
wxTextCtrl* m_marginRightCtrl;
wxTextCtrl* m_marginBottomCtrl;
wxButton* m_applyButton;
wxStaticText* m_hotkeyHint;
wxStdDialogButtonSizer* m_sdbSizer1;

View File

@ -1919,6 +1919,12 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) c
UNIMPLEMENTED_FOR( aTextBox->SHAPE_T_asString() );
}
m_out->Print( 0, " (margins %s %s %s %s)",
formatInternalUnits( aTextBox->GetMarginLeft() ).c_str(),
formatInternalUnits( aTextBox->GetMarginTop() ).c_str(),
formatInternalUnits( aTextBox->GetMarginRight() ).c_str(),
formatInternalUnits( aTextBox->GetMarginBottom() ).c_str() );
if( const PCB_TABLECELL* cell = dynamic_cast<const PCB_TABLECELL*>( aTextBox ) )
m_out->Print( 0, " (span %d %d)", cell->GetColSpan(), cell->GetRowSpan() );

View File

@ -405,6 +405,15 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseXY( int* aX, int* aY )
}
void PCB_IO_KICAD_SEXPR_PARSER::parseMargins( int& aLeft, int& aTop, int& aRight, int& aBottom )
{
aLeft = parseBoardUnits( "left margin" );
aTop = parseBoardUnits( "top margin" );
aRight = parseBoardUnits( "right margin" );
aBottom = parseBoardUnits( "bottom margin" );
}
std::pair<wxString, wxString> PCB_IO_KICAD_SEXPR_PARSER::parseBoardProperty()
{
wxString pName;
@ -3361,7 +3370,13 @@ PCB_TABLECELL* PCB_IO_KICAD_SEXPR_PARSER::parsePCB_TABLECELL( BOARD_ITEM* aParen
void PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent( PCB_TEXTBOX* aTextBox )
{
int left;
int top;
int right;
int bottom;
STROKE_PARAMS stroke( -1, LINE_STYLE::SOLID );
bool foundMargins = false;
T token = NextTok();
if( token == T_locked )
@ -3441,6 +3456,16 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent( PCB_TEXTBOX* aTextBox )
NeedRIGHT();
break;
case T_margins:
parseMargins( left, top, right, bottom );
aTextBox->SetMarginLeft( left );
aTextBox->SetMarginTop( top );
aTextBox->SetMarginRight( right );
aTextBox->SetMarginBottom( bottom );
foundMargins = true;
NeedRIGHT();
break;
case T_layer:
aTextBox->SetLayer( parseBoardItemLayer() );
NeedRIGHT();
@ -3488,6 +3513,14 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent( PCB_TEXTBOX* aTextBox )
if( m_requiredVersion < 20230825 ) // compat, we move to an explicit flag
aTextBox->SetBorderEnabled( stroke.GetWidth() >= 0 );
if( !foundMargins )
{
int margin = aTextBox->GetLegacyTextMargin();
aTextBox->SetMarginLeft( margin );
aTextBox->SetMarginTop( margin );
aTextBox->SetMarginRight( margin );
aTextBox->SetMarginBottom( margin );
}
if( FOOTPRINT* parentFP = dynamic_cast<FOOTPRINT*>( aTextBox->GetParent() ) )
{

View File

@ -283,6 +283,8 @@ private:
void parseXY( int* aX, int* aY );
void parseMargins( int& aLeft, int& aTop, int& aRight, int& aBottom );
std::pair<wxString, wxString> parseBoardProperty();
/**

View File

@ -46,6 +46,12 @@ PCB_TEXTBOX::PCB_TEXTBOX( BOARD_ITEM* aParent, KICAD_T aType ) :
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
SetVertJustify( GR_TEXT_V_ALIGN_TOP );
SetMultilineAllowed( true );
int defaultMargin = GetLegacyTextMargin();
m_marginLeft = defaultMargin;
m_marginTop = defaultMargin;
m_marginRight = defaultMargin;
m_marginBottom = defaultMargin;
}
@ -66,7 +72,7 @@ void PCB_TEXTBOX::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings )
}
int PCB_TEXTBOX::GetTextMargin() const
int PCB_TEXTBOX::GetLegacyTextMargin() const
{
return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
}
@ -257,15 +263,15 @@ VECTOR2I PCB_TEXTBOX::GetDrawPos() const
{
case GR_TEXT_H_ALIGN_LEFT:
textAnchor = corners[0];
offset = VECTOR2I( GetTextMargin(), GetTextMargin() );
offset = VECTOR2I( GetMarginLeft(), GetMarginTop() );
break;
case GR_TEXT_H_ALIGN_CENTER:
textAnchor = ( corners[0] + corners[1] ) / 2;
offset = VECTOR2I( 0, GetTextMargin() );
offset = VECTOR2I( 0, GetMarginTop() );
break;
case GR_TEXT_H_ALIGN_RIGHT:
textAnchor = corners[1];
offset = VECTOR2I( -GetTextMargin(), GetTextMargin() );
offset = VECTOR2I( -GetMarginRight(), GetMarginTop() );
break;
}
@ -339,7 +345,11 @@ wxString PCB_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const
std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
int colWidth = ( corners[1] - corners[0] ).EuclideanNorm();
colWidth -= GetTextMargin() * 2;
if( GetTextAngle().IsHorizontal() )
colWidth -= ( GetMarginLeft() + GetMarginRight() );
else
colWidth -= ( GetMarginTop() + GetMarginBottom() );
font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
return text;
@ -639,6 +649,18 @@ double PCB_TEXTBOX::Similarity( const BOARD_ITEM& aBoardItem ) const
if( m_borderEnabled != other.m_borderEnabled )
similarity *= 0.9;
if( GetMarginLeft() != other.GetMarginLeft() )
similarity *= 0.9;
if( GetMarginTop() != other.GetMarginTop() )
similarity *= 0.9;
if( GetMarginRight() != other.GetMarginRight() )
similarity *= 0.9;
if( GetMarginBottom() != other.GetMarginBottom() )
similarity *= 0.9;
similarity *= EDA_TEXT::Similarity( other );
return similarity;
@ -684,19 +706,36 @@ static struct PCB_TEXTBOX_DESC
LINE_STYLE ( PCB_TEXTBOX::*lineStyleGetter )() const = &PCB_TEXTBOX::GetLineStyle;
propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, bool>( _HKI( "Border" ),
&PCB_TEXTBOX::SetBorderEnabled,
&PCB_TEXTBOX::IsBorderEnabled ),
borderProps );
&PCB_TEXTBOX::SetBorderEnabled, &PCB_TEXTBOX::IsBorderEnabled ),
borderProps );
propMgr.AddProperty( new PROPERTY_ENUM<PCB_TEXTBOX, LINE_STYLE>( _HKI( "Border Style" ),
lineStyleSetter,
lineStyleGetter ),
borderProps );
lineStyleSetter, lineStyleGetter ),
borderProps );
propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Border Width" ),
&PCB_TEXTBOX::SetBorderWidth,
&PCB_TEXTBOX::GetBorderWidth,
PROPERTY_DISPLAY::PT_SIZE ),
borderProps );
&PCB_TEXTBOX::SetBorderWidth, &PCB_TEXTBOX::GetBorderWidth,
PROPERTY_DISPLAY::PT_SIZE ),
borderProps );
const wxString marginProps = _( "Margins" );
propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Left" ),
&PCB_TEXTBOX::SetMarginLeft, &PCB_TEXTBOX::GetMarginLeft,
PROPERTY_DISPLAY::PT_SIZE ),
marginProps );
propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Top" ),
&PCB_TEXTBOX::SetMarginTop, &PCB_TEXTBOX::GetMarginTop,
PROPERTY_DISPLAY::PT_SIZE ),
marginProps );
propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Right" ),
&PCB_TEXTBOX::SetMarginRight, &PCB_TEXTBOX::GetMarginRight,
PROPERTY_DISPLAY::PT_SIZE ),
marginProps );
propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Bottom" ),
&PCB_TEXTBOX::SetMarginBottom, &PCB_TEXTBOX::GetMarginBottom,
PROPERTY_DISPLAY::PT_SIZE ),
marginProps );
}
} _PCB_TEXTBOX_DESC;

View File

@ -74,7 +74,17 @@ public:
void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) override;
int GetTextMargin() const;
int GetLegacyTextMargin() const;
void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
void SetMarginTop( int aTop ) { m_marginTop = aTop; }
void SetMarginRight( int aRight ) { m_marginRight = aRight; }
void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
int GetMarginLeft() const { return m_marginLeft; }
int GetMarginTop() const { return m_marginTop; }
int GetMarginRight() const { return m_marginRight; }
int GetMarginBottom() const { return m_marginBottom; }
VECTOR2I GetDrawPos() const override;
@ -159,6 +169,12 @@ protected:
virtual void swapData( BOARD_ITEM* aImage ) override;
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
private:
int m_marginLeft;
int m_marginTop;
int m_marginRight;
int m_marginBottom;
};
#endif // #define PCB_TEXTBOX_H