Move pcb file rep of text_boxes to strokes.

This commit is contained in:
Jeff Young 2022-02-01 15:30:15 +00:00
parent 0faf3a8bf5
commit bebfbce9b2
15 changed files with 242 additions and 67 deletions

View File

@ -128,7 +128,10 @@ bool DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow()
m_italic->Check( m_currentText->IsItalic() );
m_borderCheckbox->SetValue( m_currentText->GetWidth() >= 0 );
m_borderWidth.SetValue( m_currentText->GetWidth() );
if( m_currentText->GetWidth() >= 0 )
m_borderWidth.SetValue( m_currentText->GetWidth() );
m_borderColorSwatch->SetSwatchColor( m_currentText->GetStroke().GetColor(), false );
int style = static_cast<int>( m_currentText->GetStroke().GetPlotStyle() );

View File

@ -20,13 +20,13 @@ DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( wxWindow
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
m_textEntrySizer = new wxGridBagSizer( 3, 0 );
m_textEntrySizer = new wxGridBagSizer( 3, 3 );
m_textEntrySizer->SetFlexibleDirection( wxBOTH );
m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textLabel->Wrap( -1 );
m_textEntrySizer->Add( m_textLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxRIGHT, 5 );
m_textEntrySizer->Add( m_textLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), 0, 5 );
m_textCtrl = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString );
m_textCtrl->SetUseTabs( true );
@ -63,7 +63,7 @@ DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( wxWindow
m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 );
m_fontLabel->Wrap( -1 );
m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") };
int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString );
@ -145,14 +145,14 @@ DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( wxWindow
m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textSizeLabel->Wrap( -1 );
m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_textSizeCtrl = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textEntrySizer->Add( m_textSizeCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_textSizeUnits->Wrap( -1 );
m_textEntrySizer->Add( m_textSizeUnits, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_textSizeUnits, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( 0, 15, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );
@ -162,7 +162,7 @@ DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( wxWindow
m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderWidthLabel->Wrap( -1 );
m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
@ -199,7 +199,7 @@ DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( wxWindow
m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderStyleLabel->Wrap( -1 );
m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) );

View File

@ -67,7 +67,7 @@
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">3</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="hgap">3</property>
<property name="minimum_size"></property>
<property name="name">m_textEntrySizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
@ -77,7 +77,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxRIGHT</property>
<property name="flag"></property>
<property name="row">0</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
@ -211,7 +211,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP</property>
<property name="row">1</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
@ -1226,7 +1226,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">2</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
@ -1357,7 +1357,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">2</property>
<property name="flag">wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">2</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
@ -1502,7 +1502,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">5</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
@ -1901,7 +1901,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">6</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">

View File

@ -158,7 +158,10 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
SCH_TEXTBOX* textBox = static_cast<SCH_TEXTBOX*>( m_currentItem );
m_borderCheckbox->SetValue( textBox->GetWidth() >= 0 );
m_borderWidth.SetValue( textBox->GetWidth() );
if( textBox->GetWidth() >= 0 )
m_borderWidth.SetValue( textBox->GetWidth() );
m_borderColorSwatch->SetSwatchColor( textBox->GetStroke().GetColor(), false );
int style = static_cast<int>( textBox->GetStroke().GetPlotStyle() );

View File

@ -20,7 +20,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
m_textEntrySizer = new wxGridBagSizer( 3, 0 );
m_textEntrySizer = new wxGridBagSizer( 3, 3 );
m_textEntrySizer->SetFlexibleDirection( wxBOTH );
m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -63,7 +63,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 );
m_fontLabel->Wrap( -1 );
m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") };
int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString );
@ -145,21 +145,21 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textSizeLabel->Wrap( -1 );
m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_textSizeCtrl = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textEntrySizer->Add( m_textSizeCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_textSizeUnits->Wrap( -1 );
m_textEntrySizer->Add( m_textSizeUnits, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_textSizeUnits, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_borderCheckbox = new wxCheckBox( this, wxID_ANY, _("Border"), wxDefaultPosition, wxDefaultSize, 0 );
m_textEntrySizer->Add( m_borderCheckbox, wxGBPosition( 4, 0 ), wxGBSpan( 1, 2 ), wxRIGHT, 5 );
m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderWidthLabel->Wrap( -1 );
m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
@ -169,7 +169,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
m_borderWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderWidthUnits->Wrap( -1 );
bSizer7->Add( m_borderWidthUnits, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 3 );
bSizer7->Add( m_borderWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 3 );
m_borderColorLabel = new wxStaticText( this, wxID_ANY, _("Color:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderColorLabel->Wrap( -1 );
@ -196,7 +196,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderStyleLabel->Wrap( -1 );
m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) );

View File

@ -67,7 +67,7 @@
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">3</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="hgap">3</property>
<property name="minimum_size"></property>
<property name="name">m_textEntrySizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
@ -211,7 +211,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP</property>
<property name="row">1</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
@ -1226,7 +1226,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">2</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
@ -1357,7 +1357,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">2</property>
<property name="flag">wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">2</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
@ -1489,7 +1489,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">5</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">
@ -1627,7 +1627,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -1888,7 +1888,7 @@
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">0</property>
<property name="flag">wxRIGHT|wxALIGN_CENTER_VERTICAL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">6</property>
<property name="rowspan">1</property>
<object class="wxStaticText" expanded="1">

View File

@ -76,7 +76,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
bMainSizer->Add( m_SingleLineSizer, 0, wxEXPAND|wxALL, 10 );
wxGridBagSizer* gbSizer1;
gbSizer1 = new wxGridBagSizer( 2, 5 );
gbSizer1 = new wxGridBagSizer( 2, 3 );
gbSizer1->SetFlexibleDirection( wxBOTH );
gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
gbSizer1->SetEmptyCellSize( wxSize( 20,-1 ) );

View File

@ -345,7 +345,7 @@
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
<property name="hgap">5</property>
<property name="hgap">3</property>
<property name="minimum_size"></property>
<property name="name">gbSizer1</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>

View File

@ -27,6 +27,7 @@
#include <confirm.h>
#include <widgets/unit_binder.h>
#include <board_commit.h>
#include <board_design_settings.h>
#include <board.h>
#include <footprint.h>
#include <string_utils.h>
@ -51,7 +52,8 @@ DIALOG_TEXTBOX_PROPERTIES::DIALOG_TEXTBOX_PROPERTIES( PCB_BASE_EDIT_FRAME* aPare
m_textWidth( aParent, m_SizeXLabel, m_SizeXCtrl, m_SizeXUnits ),
m_textHeight( aParent, m_SizeYLabel, m_SizeYCtrl, m_SizeYUnits ),
m_thickness( aParent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnits ),
m_orientation( aParent, m_OrientLabel, m_OrientCtrl, nullptr )
m_orientation( aParent, m_OrientLabel, m_OrientCtrl, nullptr ),
m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits )
{
m_MultiLineText->SetEOLMode( wxSTC_EOL_LF );
@ -128,6 +130,9 @@ DIALOG_TEXTBOX_PROPERTIES::DIALOG_TEXTBOX_PROPERTIES( PCB_BASE_EDIT_FRAME* aPare
for( size_t ii = 0; ii < m_OrientCtrl->GetCount() && ii < 4; ++ii )
m_OrientCtrl->SetString( ii, wxString::Format( "%.1f", rot_list[ii] ) );
for( const std::pair<const PLOT_DASH_TYPE, lineTypeStruct>& typeEntry : lineTypeNames )
m_borderStyleCombo->Append( typeEntry.second.name, KiBitmap( typeEntry.second.bitmap ) );
SetupStandardButtons();
// wxTextCtrls fail to generate wxEVT_CHAR events when the wxTE_MULTILINE flag is set,
@ -159,7 +164,7 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow()
{
BOARD* board = m_frame->GetBoard();
wxString converted = board->ConvertKIIDsToCrossReferences(
UnescapeString( m_edaText->GetText() ) );
UnescapeString( m_edaText->GetText() ) );
m_MultiLineText->SetValue( converted );
m_MultiLineText->SetSelection( -1, -1 );
@ -188,6 +193,31 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow()
m_orientation.SetAngleValue( m_edaText->GetTextAngle() );
STROKE_PARAMS stroke;
if( m_fpTextBox )
stroke = m_fpTextBox->GetStroke();
else if( m_pcbTextBox )
stroke = m_pcbTextBox->GetStroke();
m_borderCheckbox->SetValue( stroke.GetWidth() >= 0 );
if( stroke.GetWidth() >= 0 )
m_borderWidth.SetValue( stroke.GetWidth() );
int style = static_cast<int>( stroke.GetPlotStyle() );
if( style == -1 )
m_borderStyleCombo->SetStringSelection( DEFAULT_STYLE );
else if( style < (int) lineTypeNames.size() )
m_borderStyleCombo->SetSelection( style );
else
wxFAIL_MSG( "Line type not found in the type lookup map" );
m_borderWidth.Enable( stroke.GetWidth() >= 0 );
m_borderStyleLabel->Enable( stroke.GetWidth() >= 0 );
m_borderStyleCombo->Enable( stroke.GetWidth() >= 0 );
return DIALOG_TEXTBOX_PROPERTIES_BASE::TransferDataToWindow();
}
@ -244,6 +274,22 @@ void DIALOG_TEXTBOX_PROPERTIES::onThickness( wxCommandEvent& event )
}
void DIALOG_TEXTBOX_PROPERTIES::onBorderChecked( wxCommandEvent& event )
{
bool border = m_borderCheckbox->GetValue();
if( border && m_borderWidth.GetValue() <= 0 )
{
BOARD_DESIGN_SETTINGS& bds = m_item->GetBoard()->GetDesignSettings();
m_borderWidth.SetValue( bds.GetLineThickness( m_item->GetLayer() ) );
}
m_borderWidth.Enable( border );
m_borderStyleLabel->Enable( border );
m_borderStyleCombo->Enable( border );
}
bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow()
{
if( !DIALOG_TEXTBOX_PROPERTIES_BASE::TransferDataFromWindow() )
@ -324,6 +370,36 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow()
m_edaText->SetMirrored( m_mirrored->IsChecked() );
STROKE_PARAMS stroke;
if( m_fpTextBox )
stroke = m_fpTextBox->GetStroke();
else if( m_pcbTextBox )
stroke = m_pcbTextBox->GetStroke();
if( m_borderCheckbox->GetValue() )
{
if( !m_borderWidth.IsIndeterminate() )
stroke.SetWidth( m_borderWidth.GetValue() );
}
else
{
stroke.SetWidth( -1 );
}
auto it = lineTypeNames.begin();
std::advance( it, m_borderStyleCombo->GetSelection() );
if( it == lineTypeNames.end() )
stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT );
else
stroke.SetPlotStyle( it->first );
if( m_fpTextBox )
m_fpTextBox->SetStroke( stroke );
else if( m_pcbTextBox )
m_pcbTextBox->SetStroke( stroke );
if( pushCommit )
commit.Push( _( "Change text box properties" ) );

View File

@ -49,6 +49,7 @@ private:
void onBoldToggle( wxCommandEvent &aEvent ) override;
void onAlignButton( wxCommandEvent &aEvent ) override;
void onThickness( wxCommandEvent &aEvent ) override;
void onBorderChecked( wxCommandEvent& event ) override;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
@ -65,6 +66,7 @@ private:
UNIT_BINDER m_textHeight;
UNIT_BINDER m_thickness;
UNIT_BINDER m_orientation; // rotation in degrees
UNIT_BINDER m_borderWidth;
SCINTILLA_TRICKS* m_scintillaTricks;
};

View File

@ -65,7 +65,7 @@ DIALOG_TEXTBOX_PROPERTIES_BASE::DIALOG_TEXTBOX_PROPERTIES_BASE( wxWindow* parent
bMainSizer->Add( m_MultiLineSizer, 20, wxEXPAND|wxALL, 10 );
wxGridBagSizer* gbSizer1;
gbSizer1 = new wxGridBagSizer( 3, 5 );
gbSizer1 = new wxGridBagSizer( 4, 3 );
gbSizer1->SetFlexibleDirection( wxBOTH );
gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
gbSizer1->SetEmptyCellSize( wxSize( 20,8 ) );
@ -147,6 +147,9 @@ DIALOG_TEXTBOX_PROPERTIES_BASE::DIALOG_TEXTBOX_PROPERTIES_BASE( wxWindow* parent
m_SizeXUnits->Wrap( -1 );
gbSizer1->Add( m_SizeXUnits, wxGBPosition( 4, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_borderCheckbox = new wxCheckBox( this, wxID_ANY, _("Border"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_borderCheckbox, wxGBPosition( 4, 4 ), wxGBSpan( 1, 2 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_SizeYLabel = new wxStaticText( this, wxID_ANY, _("Text Height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeYLabel->Wrap( -1 );
m_SizeYLabel->SetToolTip( _("Text height") );
@ -186,7 +189,7 @@ DIALOG_TEXTBOX_PROPERTIES_BASE::DIALOG_TEXTBOX_PROPERTIES_BASE( wxWindow* parent
m_OrientCtrl->Append( _("180.0") );
gbSizer1->Add( m_OrientCtrl, wxGBPosition( 1, 5 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 5 );
m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Border Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Border width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderWidthLabel->Wrap( -1 );
gbSizer1->Add( m_borderWidthLabel, wxGBPosition( 5, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
@ -197,18 +200,17 @@ DIALOG_TEXTBOX_PROPERTIES_BASE::DIALOG_TEXTBOX_PROPERTIES_BASE( wxWindow* parent
m_borderWidthUnits->Wrap( -1 );
gbSizer1->Add( m_borderWidthUnits, wxGBPosition( 5, 6 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 );
m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Border Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Border style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_borderStyleLabel->Wrap( -1 );
gbSizer1->Add( m_borderStyleLabel, wxGBPosition( 6, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) );
gbSizer1->Add( m_borderStyleCombo, wxGBPosition( 6, 5 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
gbSizer1->Add( m_borderStyleCombo, wxGBPosition( 6, 5 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND, 5 );
gbSizer1->AddGrowableCol( 1 );
gbSizer1->AddGrowableCol( 5 );
gbSizer1->AddGrowableCol( 3 );
bMainSizer->Add( gbSizer1, 0, wxRIGHT|wxLEFT|wxEXPAND, 10 );
@ -249,6 +251,7 @@ DIALOG_TEXTBOX_PROPERTIES_BASE::DIALOG_TEXTBOX_PROPERTIES_BASE( wxWindow* parent
m_alignCenter->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::onAlignButton ), NULL, this );
m_alignRight->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::onAlignButton ), NULL, this );
m_SizeXCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_borderCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::onBorderChecked ), NULL, this );
m_SizeYCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_ThicknessCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::onThickness ), NULL, this );
m_OrientCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::OnOkClick ), NULL, this );
@ -266,6 +269,7 @@ DIALOG_TEXTBOX_PROPERTIES_BASE::~DIALOG_TEXTBOX_PROPERTIES_BASE()
m_alignCenter->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::onAlignButton ), NULL, this );
m_alignRight->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::onAlignButton ), NULL, this );
m_SizeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_borderCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::onBorderChecked ), NULL, this );
m_SizeYCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_ThicknessCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::onThickness ), NULL, this );
m_OrientCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXTBOX_PROPERTIES_BASE::OnOkClick ), NULL, this );

View File

@ -205,14 +205,14 @@
<object class="wxGridBagSizer" expanded="1">
<property name="empty_cell_size">20,8</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1,5</property>
<property name="growablecols">3</property>
<property name="growablerows"></property>
<property name="hgap">5</property>
<property name="hgap">3</property>
<property name="minimum_size"></property>
<property name="name">gbSizer1</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="vgap">3</property>
<property name="vgap">4</property>
<object class="gbsizeritem" expanded="1">
<property name="border">5</property>
<property name="colspan">3</property>
@ -1478,6 +1478,74 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="gbsizeritem" expanded="1">
<property name="border">5</property>
<property name="colspan">2</property>
<property name="column">4</property>
<property name="flag">wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="row">4</property>
<property name="rowspan">1</property>
<object class="wxCheckBox" expanded="1">
<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="checked">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="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">Border</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_borderCheckbox</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="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">onBorderChecked</event>
</object>
</object>
<object class="gbsizeritem" expanded="1">
<property name="border">5</property>
<property name="colspan">1</property>
@ -2038,7 +2106,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Border Width:</property>
<property name="label">Border width:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -2233,7 +2301,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Border Style:</property>
<property name="label">Border style:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -2266,7 +2334,7 @@
<property name="border">5</property>
<property name="colspan">2</property>
<property name="column">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND</property>
<property name="row">6</property>
<property name="rowspan">1</property>
<object class="wxBitmapComboBox" expanded="1">

View File

@ -68,6 +68,7 @@ class DIALOG_TEXTBOX_PROPERTIES_BASE : public DIALOG_SHIM
wxStaticText* m_SizeXLabel;
wxTextCtrl* m_SizeXCtrl;
wxStaticText* m_SizeXUnits;
wxCheckBox* m_borderCheckbox;
wxStaticText* m_SizeYLabel;
wxTextCtrl* m_SizeYCtrl;
wxStaticText* m_SizeYUnits;
@ -93,6 +94,7 @@ class DIALOG_TEXTBOX_PROPERTIES_BASE : public DIALOG_SHIM
virtual void onBoldToggle( wxCommandEvent& event ) { event.Skip(); }
virtual void onAlignButton( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); }
virtual void onThickness( wxCommandEvent& event ) { event.Skip(); }

View File

@ -2892,6 +2892,7 @@ PCB_TEXTBOX* PCB_PARSER::parsePCB_TEXTBOX()
std::unique_ptr<PCB_TEXTBOX> textbox = std::make_unique<PCB_TEXTBOX>( m_board );
STROKE_PARAMS stroke( -1, PLOT_DASH_TYPE::SOLID );
T token = NextTok();
if( token == T_locked )
@ -2954,10 +2955,15 @@ PCB_TEXTBOX* PCB_PARSER::parsePCB_TEXTBOX()
NeedRIGHT();
break;
case T_width:
textbox->SetWidth( parseBoardUnits( "text box border width" ) );
NeedRIGHT();
case T_stroke:
{
STROKE_PARAMS_PARSER strokeParser( reader, IU_PER_MM );
strokeParser.SyncLineReaderWith( *this );
strokeParser.ParseStroke( stroke );
SyncLineReaderWith( strokeParser );
break;
}
case T_layer:
textbox->SetLayer( parseBoardItemLayer() );
@ -2983,6 +2989,8 @@ PCB_TEXTBOX* PCB_PARSER::parsePCB_TEXTBOX()
}
}
textbox->SetStroke( stroke );
return textbox.release();
}
@ -3917,6 +3925,7 @@ FP_TEXTBOX* PCB_PARSER::parseFP_TEXTBOX()
std::unique_ptr<FP_TEXTBOX> textbox = std::make_unique<FP_TEXTBOX>( nullptr );
STROKE_PARAMS stroke( -1, PLOT_DASH_TYPE::SOLID );
T token = NextTok();
if( token == T_locked )
@ -3977,10 +3986,15 @@ FP_TEXTBOX* PCB_PARSER::parseFP_TEXTBOX()
NeedRIGHT();
break;
case T_width:
textbox->SetWidth( parseBoardUnits( "text box border width" ) );
NeedRIGHT();
case T_stroke:
{
STROKE_PARAMS_PARSER strokeParser( reader, IU_PER_MM );
strokeParser.SyncLineReaderWith( *this );
strokeParser.ParseStroke( stroke );
SyncLineReaderWith( strokeParser );
break;
}
case T_layer:
textbox->SetLayer( parseBoardItemLayer() );
@ -4006,6 +4020,8 @@ FP_TEXTBOX* PCB_PARSER::parseFP_TEXTBOX()
}
}
textbox->SetStroke( stroke );
return textbox.release();
}

View File

@ -1759,7 +1759,7 @@ void PCB_PLUGIN::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) const
if( aTextBox->GetShape() == SHAPE_T::RECT )
{
m_out->Print( aNestLevel, "(start %s) (end %s)",
m_out->Print( aNestLevel + 1, "(start %s) (end %s)",
FormatInternalUnits( aTextBox->GetStart() ).c_str(),
FormatInternalUnits( aTextBox->GetEnd() ).c_str() );
}
@ -1768,7 +1768,7 @@ void PCB_PLUGIN::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) const
const SHAPE_POLY_SET& poly = aTextBox->GetPolyShape();
const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
formatPolyPts( outline, aNestLevel, true );
formatPolyPts( outline, aNestLevel + 1, true );
}
else
{
@ -1778,8 +1778,6 @@ void PCB_PLUGIN::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) const
if( !aTextBox->GetTextAngle().IsZero() )
m_out->Print( 0, " (angle %s)", FormatAngle( aTextBox->GetTextAngle() ).c_str() );
m_out->Print( 0, " (width %s)", FormatInternalUnits( aTextBox->GetWidth() ).c_str() );
formatLayer( aTextBox );
m_out->Print( 0, " (tstamp %s)", TO_UTF8( aTextBox->m_Uuid.AsString() ) );
@ -1787,7 +1785,10 @@ void PCB_PLUGIN::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) const
m_out->Print( 0, "\n" );
// PCB_TEXTBOXes are never hidden, so always omit "hide" attribute
aTextBox->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
aTextBox->EDA_TEXT::Format( m_out, aNestLevel + 1, m_ctl | CTL_OMIT_HIDE );
if( aTextBox->GetStroke().GetWidth() > 0 )
aTextBox->GetStroke().Format( m_out, aNestLevel + 1 );
if( aTextBox->GetFont() && aTextBox->GetFont()->IsOutline() )
formatRenderCache( aTextBox, aNestLevel + 1 );
@ -1881,7 +1882,7 @@ void PCB_PLUGIN::format( const FP_TEXT* aText, int aNestLevel ) const
m_out->Print( 0, "\n" );
aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
aText->EDA_TEXT::Format( m_out, aNestLevel + 1, m_ctl | CTL_OMIT_HIDE );
m_out->Print( aNestLevel + 1, "(tstamp %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) );
@ -1902,11 +1903,9 @@ void PCB_PLUGIN::format( const FP_TEXTBOX* aTextBox, int aNestLevel ) const
if( aTextBox->GetShape() == SHAPE_T::RECT )
{
m_out->Print( aNestLevel, "(start %s) (end %s) (angle %s) (width %s)",
m_out->Print( aNestLevel, "(start %s) (end %s)",
FormatInternalUnits( aTextBox->GetStart0() ).c_str(),
FormatInternalUnits( aTextBox->GetEnd0() ).c_str(),
FormatAngle( aTextBox->GetTextAngle() ).c_str(),
FormatInternalUnits( aTextBox->GetWidth() ).c_str() );
FormatInternalUnits( aTextBox->GetEnd0() ).c_str() );
}
else if( aTextBox->GetShape() == SHAPE_T::POLY )
{
@ -1914,16 +1913,15 @@ void PCB_PLUGIN::format( const FP_TEXTBOX* aTextBox, int aNestLevel ) const
const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
formatPolyPts( outline, aNestLevel, true );
m_out->Print( aNestLevel, " (angle %s) (width %s)",
FormatAngle( aTextBox->GetTextAngle() ).c_str(),
FormatInternalUnits( aTextBox->GetWidth() ).c_str() );
}
else
{
UNIMPLEMENTED_FOR( aTextBox->SHAPE_T_asString() );
}
if( !aTextBox->GetTextAngle().IsZero() )
m_out->Print( 0, " (angle %s)", FormatAngle( aTextBox->GetTextAngle() ).c_str() );
formatLayer( aTextBox );
m_out->Print( 0, " (tstamp %s)", TO_UTF8( aTextBox->m_Uuid.AsString() ) );
@ -1931,7 +1929,10 @@ void PCB_PLUGIN::format( const FP_TEXTBOX* aTextBox, int aNestLevel ) const
m_out->Print( 0, "\n" );
// FP_TEXTBOXes are never hidden, so always omit "hide" attribute
aTextBox->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
aTextBox->EDA_TEXT::Format( m_out, aNestLevel + 1, m_ctl | CTL_OMIT_HIDE );
if( aTextBox->GetStroke().GetWidth() > 0 )
aTextBox->GetStroke().Format( m_out, aNestLevel + 1 );
if( aTextBox->GetFont() && aTextBox->GetFont()->IsOutline() )
formatRenderCache( aTextBox, aNestLevel + 1 );