2022-01-30 10:52:52 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-03-30 11:49:23 +00:00
|
|
|
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2022-01-30 10:52:52 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <widgets/bitmap_button.h>
|
|
|
|
#include <widgets/font_choice.h>
|
|
|
|
#include <dialog_textbox_properties.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <board_commit.h>
|
2022-02-01 15:30:15 +00:00
|
|
|
#include <board_design_settings.h>
|
2022-01-30 10:52:52 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <footprint.h>
|
|
|
|
#include <pcb_textbox.h>
|
2023-05-24 11:08:52 +00:00
|
|
|
#include <project.h>
|
2022-01-30 10:52:52 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <pcb_layer_box_selector.h>
|
|
|
|
#include <scintilla_tricks.h>
|
|
|
|
|
|
|
|
DIALOG_TEXTBOX_PROPERTIES::DIALOG_TEXTBOX_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXTBOX* aTextBox ) :
|
2022-01-30 10:52:52 +00:00
|
|
|
DIALOG_TEXTBOX_PROPERTIES_BASE( aParent ),
|
|
|
|
m_frame( aParent ),
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox( aTextBox ),
|
2022-01-30 10:52:52 +00:00
|
|
|
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 ),
|
2022-02-01 15:30:15 +00:00
|
|
|
m_orientation( aParent, m_OrientLabel, m_OrientCtrl, nullptr ),
|
|
|
|
m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
|
|
|
m_MultiLineText->SetEOLMode( wxSTC_EOL_LF );
|
|
|
|
|
2023-08-03 16:28:37 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
// Without this setting, on Windows, some esoteric unicode chars create display issue
|
|
|
|
// in a wxStyledTextCtrl.
|
|
|
|
// for SetTechnology() info, see https://www.scintilla.org/ScintillaDoc.html#SCI_SETTECHNOLOGY
|
|
|
|
m_MultiLineText->SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE);
|
|
|
|
#endif
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
m_scintillaTricks = new SCINTILLA_TRICKS( m_MultiLineText, wxT( "{}" ), false,
|
2023-05-24 22:46:48 +00:00
|
|
|
// onAccept handler
|
2023-08-02 19:11:59 +00:00
|
|
|
[this]( wxKeyEvent& aEvent )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
|
|
|
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
|
2023-05-24 22:46:48 +00:00
|
|
|
},
|
|
|
|
// onCharAdded handler
|
|
|
|
[this]( wxStyledTextEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_scintillaTricks->DoTextVarAutocomplete(
|
|
|
|
[this]( const wxString& crossRef, wxArrayString* tokens )
|
|
|
|
{
|
|
|
|
m_frame->GetContextualTextVars( m_textBox, crossRef, tokens );
|
|
|
|
} );
|
2022-01-30 10:52:52 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
// A hack which causes Scintilla to auto-size the text editor canvas
|
|
|
|
// See: https://github.com/jacobslusser/ScintillaNET/issues/216
|
|
|
|
m_MultiLineText->SetScrollWidth( 1 );
|
|
|
|
m_MultiLineText->SetScrollWidthTracking( true );
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( m_textBox->GetParentFootprint() )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
|
|
|
// Do not allow locking items in the footprint editor
|
|
|
|
m_cbLocked->Show( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
SetInitialFocus( m_MultiLineText );
|
|
|
|
|
|
|
|
m_separator0->SetIsSeparator();
|
|
|
|
|
|
|
|
m_bold->SetIsCheckButton();
|
|
|
|
m_bold->SetBitmap( KiBitmap( BITMAPS::text_bold ) );
|
|
|
|
m_italic->SetIsCheckButton();
|
|
|
|
m_italic->SetBitmap( KiBitmap( BITMAPS::text_italic ) );
|
|
|
|
|
|
|
|
m_separator1->SetIsSeparator();
|
|
|
|
|
2022-06-12 19:09:21 +00:00
|
|
|
m_alignLeft->SetIsRadioButton();
|
2022-01-30 10:52:52 +00:00
|
|
|
m_alignLeft->SetBitmap( KiBitmap( BITMAPS::text_align_left ) );
|
2022-06-12 19:09:21 +00:00
|
|
|
m_alignCenter->SetIsRadioButton();
|
2022-01-30 10:52:52 +00:00
|
|
|
m_alignCenter->SetBitmap( KiBitmap( BITMAPS::text_align_center ) );
|
2022-06-12 19:09:21 +00:00
|
|
|
m_alignRight->SetIsRadioButton();
|
2022-01-30 10:52:52 +00:00
|
|
|
m_alignRight->SetBitmap( KiBitmap( BITMAPS::text_align_right ) );
|
|
|
|
|
|
|
|
m_separator2->SetIsSeparator();
|
|
|
|
|
|
|
|
m_mirrored->SetIsCheckButton();
|
|
|
|
m_mirrored->SetBitmap( KiBitmap( BITMAPS::text_mirrored ) );
|
|
|
|
|
|
|
|
m_separator3->SetIsSeparator();
|
|
|
|
|
|
|
|
// Configure the layers list selector. Note that footprints are built outside the current
|
|
|
|
// board and so we may need to show all layers if the text is on an unactivated layer.
|
2023-03-30 11:49:23 +00:00
|
|
|
if( !m_frame->GetBoard()->IsLayerEnabled( m_textBox->GetLayer() ) )
|
2022-01-30 10:52:52 +00:00
|
|
|
m_LayerSelectionCtrl->ShowNonActivatedLayers( true );
|
|
|
|
|
|
|
|
m_LayerSelectionCtrl->SetLayersHotkeys( false );
|
|
|
|
m_LayerSelectionCtrl->SetBoardFrame( m_frame );
|
|
|
|
m_LayerSelectionCtrl->Resync();
|
|
|
|
|
|
|
|
m_orientation.SetUnits( EDA_UNITS::DEGREES );
|
|
|
|
m_orientation.SetPrecision( 3 );
|
|
|
|
|
|
|
|
// Set predefined rotations in combo dropdown, according to the locale floating point
|
|
|
|
// separator notation
|
|
|
|
double rot_list[] = { 0.0, 90.0, -90.0, 180.0 };
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < m_OrientCtrl->GetCount() && ii < 4; ++ii )
|
|
|
|
m_OrientCtrl->SetString( ii, wxString::Format( "%.1f", rot_list[ii] ) );
|
|
|
|
|
2022-02-01 15:30:15 +00:00
|
|
|
for( const std::pair<const PLOT_DASH_TYPE, lineTypeStruct>& typeEntry : lineTypeNames )
|
|
|
|
m_borderStyleCombo->Append( typeEntry.second.name, KiBitmap( typeEntry.second.bitmap ) );
|
|
|
|
|
2022-03-11 23:13:05 +00:00
|
|
|
m_borderStyleCombo->Append( DEFAULT_STYLE );
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
SetupStandardButtons();
|
|
|
|
|
|
|
|
// wxTextCtrls fail to generate wxEVT_CHAR events when the wxTE_MULTILINE flag is set,
|
|
|
|
// so we have to listen to wxEVT_CHAR_HOOK events instead.
|
|
|
|
Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_TEXTBOX_PROPERTIES::OnCharHook ),
|
|
|
|
nullptr, this );
|
|
|
|
|
|
|
|
finishDialogSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_TEXTBOX_PROPERTIES::~DIALOG_TEXTBOX_PROPERTIES()
|
|
|
|
{
|
|
|
|
Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_TEXTBOX_PROPERTIES::OnCharHook ),
|
|
|
|
nullptr, this );
|
|
|
|
|
|
|
|
delete m_scintillaTricks;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
int PCB_BASE_EDIT_FRAME::ShowTextBoxPropertiesDialog( PCB_TEXTBOX* aTextBox )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
DIALOG_TEXTBOX_PROPERTIES dlg( this, aTextBox );
|
2023-05-24 11:08:52 +00:00
|
|
|
|
|
|
|
// QuasiModal required for Scintilla auto-complete
|
2022-01-30 10:52:52 +00:00
|
|
|
return dlg.ShowQuasiModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
wxString converted = board->ConvertKIIDsToCrossReferences(
|
2023-03-30 11:49:23 +00:00
|
|
|
UnescapeString( m_textBox->GetText() ) );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
|
|
|
m_MultiLineText->SetValue( converted );
|
|
|
|
m_MultiLineText->SetSelection( -1, -1 );
|
2022-10-14 21:00:54 +00:00
|
|
|
m_MultiLineText->EmptyUndoBuffer();
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_cbLocked->SetValue( m_textBox->IsLocked() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_LayerSelectionCtrl->SetLayerSelection( m_textBox->GetLayer() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_fontCtrl->SetFontSelection( m_textBox->GetFont() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textWidth.SetValue( m_textBox->GetTextSize().x );
|
|
|
|
m_textHeight.SetValue( m_textBox->GetTextSize().y );
|
|
|
|
m_thickness.SetValue( m_textBox->GetTextThickness() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_bold->Check( m_textBox->IsBold() );
|
|
|
|
m_italic->Check( m_textBox->IsItalic() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
switch ( m_textBox->GetHorizJustify() )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT: m_alignLeft->Check( true ); break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER: m_alignCenter->Check( true ); break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT: m_alignRight->Check( true ); break;
|
|
|
|
}
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_mirrored->Check( m_textBox->IsMirrored() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
EDA_ANGLE orientation = m_textBox->GetTextAngle();
|
2022-04-10 21:43:09 +00:00
|
|
|
m_orientation.SetAngleValue( orientation.Normalize180() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
STROKE_PARAMS stroke = m_textBox->GetStroke();
|
2023-08-25 01:00:19 +00:00
|
|
|
m_borderCheckbox->SetValue( m_textBox->IsBorderEnabled() );
|
2022-02-01 15:30:15 +00:00
|
|
|
|
2023-08-25 01:19:35 +00:00
|
|
|
if( m_textBox->IsBorderEnabled() )
|
2022-02-01 15:30:15 +00:00
|
|
|
m_borderWidth.SetValue( stroke.GetWidth() );
|
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
PLOT_DASH_TYPE style = stroke.GetPlotStyle();
|
2022-02-01 15:30:15 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
if( style == PLOT_DASH_TYPE::DEFAULT )
|
|
|
|
style = PLOT_DASH_TYPE::SOLID;
|
|
|
|
|
|
|
|
if( (int) style < (int) lineTypeNames.size() )
|
|
|
|
m_borderStyleCombo->SetSelection( (int) style );
|
2022-02-01 15:30:15 +00:00
|
|
|
|
2023-08-25 01:19:35 +00:00
|
|
|
m_borderWidth.Enable( m_textBox->IsBorderEnabled() );
|
|
|
|
m_borderStyleLabel->Enable( m_textBox->IsBorderEnabled() );
|
|
|
|
m_borderStyleCombo->Enable( m_textBox->IsBorderEnabled() );
|
2022-02-01 15:30:15 +00:00
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
return DIALOG_TEXTBOX_PROPERTIES_BASE::TransferDataToWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TEXTBOX_PROPERTIES::onFontSelected( wxCommandEvent & aEvent )
|
|
|
|
{
|
|
|
|
if( KIFONT::FONT::IsStroke( aEvent.GetString() ) )
|
|
|
|
{
|
|
|
|
m_thickness.Show( true );
|
|
|
|
|
|
|
|
int textSize = std::min( m_textWidth.GetValue(), m_textHeight.GetValue() );
|
|
|
|
int thickness = m_thickness.GetValue();
|
|
|
|
|
|
|
|
m_bold->Check( abs( thickness - GetPenSizeForBold( textSize ) )
|
|
|
|
< abs( thickness - GetPenSizeForNormal( textSize ) ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_thickness.Show( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TEXTBOX_PROPERTIES::onBoldToggle( wxCommandEvent & aEvent )
|
|
|
|
{
|
|
|
|
int textSize = std::min( m_textWidth.GetValue(), m_textHeight.GetValue() );
|
|
|
|
|
|
|
|
if( aEvent.IsChecked() )
|
|
|
|
m_thickness.ChangeValue( GetPenSizeForBold( textSize ) );
|
|
|
|
else
|
|
|
|
m_thickness.ChangeValue( GetPenSizeForNormal( textSize ) );
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TEXTBOX_PROPERTIES::onAlignButton( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
for( BITMAP_BUTTON* btn : { m_alignLeft, m_alignCenter, m_alignRight } )
|
|
|
|
{
|
|
|
|
if( btn->IsChecked() && btn != aEvent.GetEventObject() )
|
|
|
|
btn->Check( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TEXTBOX_PROPERTIES::onThickness( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int textSize = std::min( m_textWidth.GetValue(), m_textHeight.GetValue() );
|
|
|
|
int thickness = m_thickness.GetValue();
|
|
|
|
|
|
|
|
m_bold->Check( abs( thickness - GetPenSizeForBold( textSize ) )
|
|
|
|
< abs( thickness - GetPenSizeForNormal( textSize ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-01 15:30:15 +00:00
|
|
|
void DIALOG_TEXTBOX_PROPERTIES::onBorderChecked( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
bool border = m_borderCheckbox->GetValue();
|
|
|
|
|
|
|
|
if( border && m_borderWidth.GetValue() <= 0 )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = m_textBox->GetBoard()->GetDesignSettings();
|
|
|
|
m_borderWidth.SetValue( bds.GetLineThickness( m_textBox->GetLayer() ) );
|
2022-02-01 15:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_borderWidth.Enable( border );
|
|
|
|
m_borderStyleLabel->Enable( border );
|
|
|
|
m_borderStyleCombo->Enable( border );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow()
|
|
|
|
{
|
|
|
|
if( !DIALOG_TEXTBOX_PROPERTIES_BASE::TransferDataFromWindow() )
|
|
|
|
return false;
|
|
|
|
|
2023-06-03 15:59:00 +00:00
|
|
|
int minSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
|
|
|
|
int maxSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
|
|
|
|
|
|
|
|
if( !m_textWidth.Validate( minSize, maxSize ) || !m_textHeight.Validate( minSize, maxSize ) )
|
2022-01-30 10:52:52 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
2023-03-30 11:49:23 +00:00
|
|
|
commit.Modify( m_textBox );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
|
|
|
// If no other command in progress, prepare undo command
|
|
|
|
// (for a command in progress, will be made later, at the completion of command)
|
2023-03-30 11:49:23 +00:00
|
|
|
bool pushCommit = ( m_textBox->GetEditFlags() == 0 );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
|
|
|
// Set IN_EDIT flag to force undo/redo/abort proper operation and avoid new calls to
|
|
|
|
// SaveCopyInUndoList for the same text if is moved, and then rotated, edited, etc....
|
|
|
|
if( !pushCommit )
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetFlags( IN_EDIT );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2022-04-05 15:25:03 +00:00
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
wxString txt = board->ConvertCrossReferencesToKIIDs( m_MultiLineText->GetValue() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
2022-04-05 15:25:03 +00:00
|
|
|
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting.
|
|
|
|
// Replace it now.
|
|
|
|
txt.Replace( "\r", "\n" );
|
2022-01-30 10:52:52 +00:00
|
|
|
#elif defined( __WINDOWS__ )
|
2022-04-05 15:25:03 +00:00
|
|
|
// On Windows, a new line is coded as \r\n. We use only \n in kicad files and in
|
|
|
|
// drawing routines so strip the \r char.
|
|
|
|
txt.Replace( "\r", "" );
|
2022-01-30 10:52:52 +00:00
|
|
|
#endif
|
2022-04-05 15:25:03 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetText( EscapeString( txt, CTX_QUOTED_STR ) );
|
|
|
|
m_textBox->SetLocked( m_cbLocked->GetValue() );
|
|
|
|
m_textBox->SetLayer( ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
|
|
|
if( m_fontCtrl->HaveFontSelection() )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetFont( m_fontCtrl->GetFontSelection( m_bold->IsChecked(),
|
2022-01-30 10:52:52 +00:00
|
|
|
m_italic->IsChecked() ) );
|
|
|
|
}
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetTextSize( VECTOR2I( m_textWidth.GetValue(), m_textHeight.GetValue() ) );
|
|
|
|
m_textBox->SetTextThickness( m_thickness.GetValue() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
|
|
|
// Test for acceptable values for thickness and size and clamp if fails
|
2023-03-30 11:49:23 +00:00
|
|
|
int maxPenWidth = Clamp_Text_PenSize( m_textBox->GetTextThickness(), m_textBox->GetTextSize() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
if( m_textBox->GetTextThickness() > maxPenWidth )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "The text thickness is too large for the text size.\n"
|
|
|
|
"It will be clamped." ) );
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetTextThickness( maxPenWidth );
|
2022-01-30 10:52:52 +00:00
|
|
|
}
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetTextAngle( m_orientation.GetAngleValue().Normalize() );
|
|
|
|
m_textBox->SetBold( m_bold->IsChecked() );
|
|
|
|
m_textBox->SetItalic( m_italic->IsChecked() );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
|
|
|
if( m_alignLeft->IsChecked() )
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
2022-01-30 10:52:52 +00:00
|
|
|
else if( m_alignCenter->IsChecked() )
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
2022-01-30 10:52:52 +00:00
|
|
|
else
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->SetMirrored( m_mirrored->IsChecked() );
|
2022-02-01 15:30:15 +00:00
|
|
|
|
2023-08-31 02:33:55 +00:00
|
|
|
m_textBox->SetBorderEnabled( m_borderCheckbox->GetValue() );
|
|
|
|
STROKE_PARAMS stroke = m_textBox->GetStroke();
|
|
|
|
if( !m_borderWidth.IsIndeterminate() )
|
|
|
|
stroke.SetWidth( m_borderWidth.GetValue() );
|
2022-02-01 15:30:15 +00:00
|
|
|
|
2023-08-25 01:00:19 +00:00
|
|
|
|
2023-08-31 02:33:55 +00:00
|
|
|
auto it = lineTypeNames.begin();
|
|
|
|
std::advance( it, m_borderStyleCombo->GetSelection() );
|
2023-08-25 01:00:19 +00:00
|
|
|
|
2023-08-31 02:33:55 +00:00
|
|
|
if( it == lineTypeNames.end() )
|
|
|
|
stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT );
|
2022-02-01 15:30:15 +00:00
|
|
|
else
|
2023-08-31 02:33:55 +00:00
|
|
|
stroke.SetPlotStyle( it->first );
|
|
|
|
|
|
|
|
m_textBox->SetStroke( stroke );
|
2022-02-01 15:30:15 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
m_textBox->ClearBoundingBoxCache();
|
|
|
|
m_textBox->ClearRenderCache();
|
2023-02-13 16:58:35 +00:00
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
if( pushCommit )
|
|
|
|
commit.Push( _( "Change text box properties" ) );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TEXTBOX_PROPERTIES::onMultiLineTCLostFocus( wxFocusEvent& event )
|
|
|
|
{
|
|
|
|
if( m_scintillaTricks )
|
|
|
|
m_scintillaTricks->CancelAutocomplete();
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|