2013-07-19 18:27:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-08-13 17:51:22 +00:00
|
|
|
* Copyright (C) 2013 CERN
|
2023-02-08 07:38:31 +00:00
|
|
|
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-08-13 17:51:22 +00:00
|
|
|
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-07-19 18:27:22 +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
|
|
|
|
*/
|
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
#include <project.h>
|
|
|
|
#include <scintilla_tricks.h>
|
2022-02-28 18:02:00 +00:00
|
|
|
#include <widgets/bitmap_button.h>
|
|
|
|
#include <widgets/font_choice.h>
|
2022-03-31 18:43:08 +00:00
|
|
|
#include <widgets/color_swatch.h>
|
2020-10-13 05:04:31 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_draw_item.h>
|
|
|
|
#include <drawing_sheet/ds_data_item.h>
|
|
|
|
#include <drawing_sheet/ds_data_model.h>
|
2020-10-13 05:04:31 +00:00
|
|
|
#include <view/view.h>
|
2022-02-28 18:02:00 +00:00
|
|
|
#include <bitmaps.h>
|
2020-10-13 05:04:31 +00:00
|
|
|
|
|
|
|
#include "properties_frame.h"
|
|
|
|
#include "pl_editor_frame.h"
|
|
|
|
#include "tools/pl_selection_tool.h"
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-09-14 18:26:03 +00:00
|
|
|
#include <dialogs/html_message_box.h>
|
2021-09-12 09:02:17 +00:00
|
|
|
|
|
|
|
|
2023-02-08 13:26:54 +00:00
|
|
|
/**
|
|
|
|
* Minimum drawing sheet text default size in millmeters from #PROPERTIES_FRAME.
|
|
|
|
*
|
|
|
|
* @note 0.0 is allowed for a given text to use the default size.
|
|
|
|
*/
|
|
|
|
#define DLG_MIN_TEXTSIZE 0.01
|
|
|
|
#define DLG_MAX_TEXTSIZE 100.0 ///< Maximum drawing sheet text size in mm from PROPERTIES_FRAME.
|
2023-02-07 11:53:34 +00:00
|
|
|
|
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
PROPERTIES_FRAME::PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent ) :
|
|
|
|
PANEL_PROPERTIES_BASE( aParent ),
|
2020-12-09 02:31:10 +00:00
|
|
|
m_scintillaTricks( nullptr ),
|
2022-02-28 18:02:00 +00:00
|
|
|
m_textSizeX( aParent, m_staticTextTsizeX, m_textCtrlTextSizeX, m_textSizeXUnits ),
|
|
|
|
m_textSizeY( aParent, m_staticTextTsizeY, m_textCtrlTextSizeY, m_textSizeYUnits ),
|
|
|
|
m_constraintX( aParent, m_constraintXLabel, m_constraintXCtrl, m_constraintXUnits ),
|
|
|
|
m_constraintY( aParent, m_constraintYLabel, m_constraintYCtrl, m_constraintYUnits ),
|
|
|
|
m_textPosX( aParent, m_staticTextPosX, m_textCtrlPosX, m_TextPosXUnits ),
|
|
|
|
m_textPosY( aParent, m_staticTextPosY, m_textCtrlPosY, m_TextPosYUnits ),
|
|
|
|
m_textEndX( aParent, m_staticTextEndX, m_textCtrlEndX, m_TextEndXUnits ),
|
|
|
|
m_textEndY( aParent, m_staticTextEndY, m_textCtrlEndY, m_TextEndYUnits ),
|
|
|
|
m_textStepX( aParent, m_staticTextStepX, m_textCtrlStepX, m_TextStepXUnits ),
|
|
|
|
m_textStepY( aParent, m_staticTextStepY, m_textCtrlStepY, m_TextStepYUnits ),
|
2023-02-08 13:26:54 +00:00
|
|
|
m_defaultTextSizeX( aParent, m_staticTextDefTsX, m_textCtrlDefaultTextSizeX,
|
|
|
|
m_defaultTextSizeXUnits ),
|
|
|
|
m_defaultTextSizeY( aParent, m_staticTextDefTsY, m_textCtrlDefaultTextSizeY,
|
|
|
|
m_defaultTextSizeYUnits ),
|
|
|
|
m_defaultLineWidth( aParent, m_defaultLineWidthLabel, m_defaultLineWidthCtrl,
|
|
|
|
m_defaultLineWidthUnits ),
|
|
|
|
m_defaultTextThickness( aParent, m_defaultTextThicknessLabel, m_defaultTextThicknessCtrl,
|
|
|
|
m_defaultTextThicknessUnits ),
|
2022-02-28 18:02:00 +00:00
|
|
|
m_textLeftMargin( aParent, m_leftMarginLabel, m_leftMarginCtrl, m_leftMarginUnits ),
|
|
|
|
m_textRightMargin( aParent, m_rightMarginLabel, m_rightMarginCtrl, m_rightMarginUnits ),
|
|
|
|
m_textTopMargin( aParent, m_topMarginLabel, m_topMarginCtrl, m_topMarginUnits ),
|
|
|
|
m_textBottomMargin( aParent, m_bottomMarginLabel, m_bottomMarginCtrl, m_bottomMarginUnits ),
|
|
|
|
m_lineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
m_parent = aParent;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
m_stcText->SetUseVerticalScrollBar( false );
|
|
|
|
m_stcText->SetUseHorizontalScrollBar( false );
|
2021-11-29 09:26:06 +00:00
|
|
|
m_stcText->SetEOLMode( wxSTC_EOL_LF ); // Always use LF as eol char, regardless the platform
|
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_stcText->SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE);
|
|
|
|
#endif
|
|
|
|
|
2021-06-28 10:19:12 +00:00
|
|
|
m_scintillaTricks = new SCINTILLA_TRICKS( m_stcText, wxT( "{}" ), false );
|
2020-05-30 09:22:19 +00:00
|
|
|
|
2021-09-16 17:29:29 +00:00
|
|
|
m_staticTextSizeInfo->SetFont( KIUI::GetInfoFont( this ).Italic() );
|
2019-05-24 18:29:38 +00:00
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
m_bold->SetIsCheckButton();
|
|
|
|
m_bold->SetBitmap( KiBitmap( BITMAPS::text_bold ) );
|
|
|
|
m_italic->SetIsCheckButton();
|
|
|
|
m_italic->SetBitmap( KiBitmap( BITMAPS::text_italic ) );
|
|
|
|
|
|
|
|
m_separator2->SetIsSeparator();
|
|
|
|
|
2022-06-12 19:09:21 +00:00
|
|
|
m_alignLeft->SetIsRadioButton();
|
2022-02-28 18:02:00 +00:00
|
|
|
m_alignLeft->SetBitmap( KiBitmap( BITMAPS::text_align_left ) );
|
2022-06-12 19:09:21 +00:00
|
|
|
m_alignCenter->SetIsRadioButton();
|
2022-02-28 18:02:00 +00:00
|
|
|
m_alignCenter->SetBitmap( KiBitmap( BITMAPS::text_align_center ) );
|
2022-06-12 19:09:21 +00:00
|
|
|
m_alignRight->SetIsRadioButton();
|
2022-02-28 18:02:00 +00:00
|
|
|
m_alignRight->SetBitmap( KiBitmap( BITMAPS::text_align_right ) );
|
|
|
|
|
|
|
|
m_separator3->SetIsSeparator();
|
|
|
|
|
2022-06-12 19:09:21 +00:00
|
|
|
m_vAlignTop->SetIsRadioButton();
|
2022-02-28 18:02:00 +00:00
|
|
|
m_vAlignTop->SetBitmap( KiBitmap( BITMAPS::text_valign_top ) );
|
2022-06-12 19:09:21 +00:00
|
|
|
m_vAlignMiddle->SetIsRadioButton();
|
2022-02-28 18:02:00 +00:00
|
|
|
m_vAlignMiddle->SetBitmap( KiBitmap( BITMAPS::text_valign_center ) );
|
2022-06-12 19:09:21 +00:00
|
|
|
m_vAlignBottom->SetIsRadioButton();
|
2022-02-28 18:02:00 +00:00
|
|
|
m_vAlignBottom->SetBitmap( KiBitmap( BITMAPS::text_valign_bottom ) );
|
|
|
|
|
|
|
|
m_separator4->SetIsSeparator();
|
2022-03-31 18:43:08 +00:00
|
|
|
|
|
|
|
m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
|
|
|
m_textColorSwatch->SetSwatchBackground( aParent->GetDrawBgColor() );
|
|
|
|
|
2019-05-24 18:29:38 +00:00
|
|
|
m_buttonOK->SetDefault();
|
2020-05-30 09:22:19 +00:00
|
|
|
|
2021-03-08 14:02:05 +00:00
|
|
|
// ensure sizers are up to date
|
|
|
|
// (fix an issue on GTK but should not create issues on other platforms):
|
|
|
|
m_swItemProperties->Fit();
|
|
|
|
m_swGeneralOpts->Fit();
|
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
m_stcText->Bind( wxEVT_STC_CHARADDED, &PROPERTIES_FRAME::onScintillaCharAdded, this );
|
2022-02-28 18:02:00 +00:00
|
|
|
m_alignLeft->Bind( wxEVT_BUTTON, &PROPERTIES_FRAME::onHAlignButton, this );
|
|
|
|
m_alignCenter->Bind( wxEVT_BUTTON, &PROPERTIES_FRAME::onHAlignButton, this );
|
|
|
|
m_alignRight->Bind( wxEVT_BUTTON, &PROPERTIES_FRAME::onHAlignButton, this );
|
|
|
|
m_vAlignTop->Bind( wxEVT_BUTTON, &PROPERTIES_FRAME::onVAlignButton, this );
|
|
|
|
m_vAlignMiddle->Bind( wxEVT_BUTTON, &PROPERTIES_FRAME::onVAlignButton, this );
|
|
|
|
m_vAlignBottom->Bind( wxEVT_BUTTON, &PROPERTIES_FRAME::onVAlignButton, this );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PROPERTIES_FRAME::~PROPERTIES_FRAME()
|
|
|
|
{
|
2020-05-30 09:22:19 +00:00
|
|
|
delete m_scintillaTricks;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-05-24 18:29:38 +00:00
|
|
|
void PROPERTIES_FRAME::OnPageChanged( wxNotebookEvent& event )
|
|
|
|
{
|
|
|
|
if( event.GetSelection() == 0 )
|
|
|
|
m_buttonOK->SetDefault();
|
|
|
|
else
|
|
|
|
m_buttonGeneralOptsOK->SetDefault();
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
wxSize PROPERTIES_FRAME::GetMinSize() const
|
|
|
|
{
|
|
|
|
return wxSize( 150, -1 );
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
void PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel()
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2022-02-28 18:02:00 +00:00
|
|
|
static EDA_UNITS units = EDA_UNITS::MILLIMETRES;
|
|
|
|
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Set default parameters
|
2022-09-16 04:38:10 +00:00
|
|
|
m_defaultLineWidth.SetDoubleValue(
|
|
|
|
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.m_DefaultLineWidth ) );
|
|
|
|
|
|
|
|
m_defaultTextSizeX.SetDoubleValue(
|
|
|
|
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.m_DefaultTextSize.x ) );
|
|
|
|
m_defaultTextSizeY.SetDoubleValue(
|
|
|
|
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.m_DefaultTextSize.y ) );
|
|
|
|
m_defaultTextThickness.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit(
|
|
|
|
drawSheetIUScale,units, model.m_DefaultTextThickness ) );
|
|
|
|
|
|
|
|
m_textLeftMargin.SetDoubleValue(
|
|
|
|
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetLeftMargin() ) );
|
|
|
|
m_textRightMargin.SetDoubleValue(
|
|
|
|
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetRightMargin() ) );
|
|
|
|
m_textTopMargin.SetDoubleValue(
|
|
|
|
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetTopMargin() ) );
|
|
|
|
m_textBottomMargin.SetDoubleValue(
|
|
|
|
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetBottomMargin() ) );
|
2013-07-20 19:36:19 +00:00
|
|
|
}
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
|
2013-07-20 19:36:19 +00:00
|
|
|
bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral()
|
|
|
|
{
|
2022-02-28 18:02:00 +00:00
|
|
|
static EDA_UNITS units = EDA_UNITS::MILLIMETRES;
|
|
|
|
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
// Import default parameters from widgets
|
2023-02-08 07:38:31 +00:00
|
|
|
bool is_valid = m_defaultLineWidth.Validate( 0.0, 10.0, EDA_UNITS::MILLIMETRES );
|
|
|
|
|
|
|
|
if( is_valid )
|
|
|
|
model.m_DefaultLineWidth = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
2023-02-08 13:26:54 +00:00
|
|
|
m_defaultLineWidth.GetValue() );
|
2013-07-20 19:36:19 +00:00
|
|
|
|
2023-02-08 07:38:31 +00:00
|
|
|
is_valid = m_defaultTextSizeX.Validate( DLG_MIN_TEXTSIZE, DLG_MAX_TEXTSIZE,
|
2023-02-08 13:26:54 +00:00
|
|
|
EDA_UNITS::MILLIMETRES );
|
2023-02-07 11:53:34 +00:00
|
|
|
if( is_valid )
|
|
|
|
model.m_DefaultTextSize.x = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
2023-02-08 13:26:54 +00:00
|
|
|
m_defaultTextSizeX.GetValue() );
|
2023-02-07 11:53:34 +00:00
|
|
|
|
2023-02-08 13:26:54 +00:00
|
|
|
is_valid = m_defaultTextSizeY.Validate( DLG_MIN_TEXTSIZE, DLG_MAX_TEXTSIZE,
|
|
|
|
EDA_UNITS::MILLIMETRES );
|
2023-02-07 11:53:34 +00:00
|
|
|
|
|
|
|
if( is_valid )
|
|
|
|
model.m_DefaultTextSize.y = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
2023-02-08 13:26:54 +00:00
|
|
|
m_defaultTextSizeY.GetValue() );
|
2023-02-07 11:53:34 +00:00
|
|
|
|
|
|
|
is_valid = m_defaultTextThickness.Validate( 0.0, 5.0, EDA_UNITS::MILLIMETRES );
|
|
|
|
|
|
|
|
if( is_valid )
|
|
|
|
model.m_DefaultTextThickness = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
2023-02-08 13:26:54 +00:00
|
|
|
m_defaultTextThickness.GetValue() );
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
// Get page margins values
|
2022-09-16 04:38:10 +00:00
|
|
|
model.SetRightMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
|
|
|
m_textRightMargin.GetValue() ) );
|
|
|
|
model.SetBottomMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
|
|
|
m_textBottomMargin.GetValue() ) );
|
|
|
|
model.SetLeftMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
|
|
|
m_textLeftMargin.GetValue() ) );
|
|
|
|
model.SetTopMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
|
|
|
m_textTopMargin.GetValue() ) );
|
2013-07-20 19:36:19 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
|
2013-07-20 19:36:19 +00:00
|
|
|
{
|
2019-05-24 12:24:43 +00:00
|
|
|
if( !aItem )
|
|
|
|
{
|
|
|
|
m_SizerItemProperties->Show( false );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
static EDA_UNITS units = EDA_UNITS::MILLIMETRES;
|
|
|
|
wxString msg;
|
2013-07-20 19:36:19 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
// Set parameters common to all DS_DATA_ITEM types
|
2019-05-20 10:23:32 +00:00
|
|
|
m_staticTextType->SetLabel( aItem->GetClassName() );
|
2013-07-19 18:27:22 +00:00
|
|
|
m_textCtrlComment->SetValue( aItem->m_Info );
|
|
|
|
|
|
|
|
switch( aItem->GetPage1Option() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
default:
|
|
|
|
case ALL_PAGES: m_choicePageOpt->SetSelection( 0 ); break;
|
|
|
|
case FIRST_PAGE_ONLY: m_choicePageOpt->SetSelection( 1 ); break;
|
|
|
|
case SUBSEQUENT_PAGES: m_choicePageOpt->SetSelection( 2 ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Position/ start point
|
2023-02-08 13:26:54 +00:00
|
|
|
m_textPosX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
aItem->m_Pos.m_Pos.x ) );
|
|
|
|
m_textPosY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
aItem->m_Pos.m_Pos.y ) );
|
2013-10-19 10:29:54 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( aItem->m_Pos.m_Anchor )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case RB_CORNER: m_comboBoxCornerPos->SetSelection( 2 ); break;
|
|
|
|
case RT_CORNER: m_comboBoxCornerPos->SetSelection( 0 ); break;
|
|
|
|
case LB_CORNER: m_comboBoxCornerPos->SetSelection( 3 ); break;
|
|
|
|
case LT_CORNER: m_comboBoxCornerPos->SetSelection( 1 ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// End point
|
2023-02-08 13:26:54 +00:00
|
|
|
m_textEndX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
aItem->m_End.m_Pos.x ) );
|
|
|
|
m_textEndY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
aItem->m_End.m_Pos.y ) );
|
2013-10-19 10:29:54 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( aItem->m_End.m_Anchor )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case RB_CORNER: m_comboBoxCornerEnd->SetSelection( 2 ); break;
|
|
|
|
case RT_CORNER: m_comboBoxCornerEnd->SetSelection( 0 ); break;
|
|
|
|
case LB_CORNER: m_comboBoxCornerEnd->SetSelection( 3 ); break;
|
|
|
|
case LT_CORNER: m_comboBoxCornerEnd->SetSelection( 1 ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2023-02-08 13:26:54 +00:00
|
|
|
m_lineWidth.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
aItem->m_LineWidth ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
// Now, set prms more specific to DS_DATA_ITEM types
|
2013-07-19 18:27:22 +00:00
|
|
|
// For a given type, disable widgets which are not relevant,
|
|
|
|
// and be sure widgets which are relevant are enabled
|
2021-02-22 23:47:17 +00:00
|
|
|
if( aItem->GetType() == DS_DATA_ITEM::DS_TEXT )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM_TEXT* item = static_cast<DS_DATA_ITEM_TEXT*>( aItem );
|
2013-08-18 15:49:04 +00:00
|
|
|
item->m_FullText = item->m_TextBase;
|
2021-07-18 14:06:48 +00:00
|
|
|
|
2013-08-18 15:49:04 +00:00
|
|
|
// Replace our '\' 'n' sequence by the EOL char
|
2015-01-17 08:01:16 +00:00
|
|
|
item->ReplaceAntiSlashSequence();
|
2020-05-30 09:22:19 +00:00
|
|
|
m_stcText->SetValue( item->m_FullText );
|
2022-10-14 21:00:54 +00:00
|
|
|
m_stcText->EmptyUndoBuffer();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
msg.Printf( wxT( "%d" ), item->m_IncrementLabel );
|
2013-07-19 18:27:22 +00:00
|
|
|
m_textCtrlTextIncrement->SetValue( msg );
|
|
|
|
|
|
|
|
// Rotation (poly and text)
|
2022-02-28 18:02:00 +00:00
|
|
|
msg.Printf( wxT( "%.3f" ), item->m_Orient );
|
2013-07-19 18:27:22 +00:00
|
|
|
m_textCtrlRotation->SetValue( msg );
|
|
|
|
|
|
|
|
// Constraints:
|
2023-02-08 13:26:54 +00:00
|
|
|
m_constraintX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
item->m_BoundingBoxSize.x ) );
|
|
|
|
m_constraintY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
item->m_BoundingBoxSize.y ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Font Options
|
2022-02-28 18:02:00 +00:00
|
|
|
m_fontCtrl->SetFontSelection( item->m_Font );
|
|
|
|
|
|
|
|
m_bold->Check( item->m_Bold );
|
|
|
|
m_italic->Check( item->m_Italic );
|
|
|
|
|
2022-03-31 18:43:08 +00:00
|
|
|
m_textColorSwatch->SetSwatchColor( item->m_TextColor, false );
|
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
for( BITMAP_BUTTON* btn : { m_alignLeft, m_alignCenter, m_alignRight } )
|
|
|
|
btn->Check( false );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( item->m_Hjustify )
|
|
|
|
{
|
2022-02-28 18:02:00 +00:00
|
|
|
case GR_TEXT_H_ALIGN_LEFT: m_alignLeft->Check(); break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER: m_alignCenter->Check(); break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT: m_alignRight->Check(); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
for( BITMAP_BUTTON* btn : { m_vAlignTop, m_vAlignMiddle, m_vAlignBottom } )
|
|
|
|
btn->Check( false );
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( item->m_Vjustify )
|
|
|
|
{
|
2022-02-28 18:02:00 +00:00
|
|
|
case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check(); break;
|
|
|
|
case GR_TEXT_V_ALIGN_CENTER: m_vAlignMiddle->Check(); break;
|
|
|
|
case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check(); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Text size
|
2023-02-08 13:26:54 +00:00
|
|
|
m_textSizeX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
item->m_TextSize.x ) );
|
|
|
|
m_textSizeY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
item->m_TextSize.y ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM_POLYGONS* item = static_cast<DS_DATA_ITEM_POLYGONS*>( aItem );
|
2021-07-18 14:06:48 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Rotation (poly and text)
|
2022-02-28 18:02:00 +00:00
|
|
|
msg.Printf( wxT( "%.3f" ), item->m_Orient.AsDegrees() );
|
2013-07-19 18:27:22 +00:00
|
|
|
m_textCtrlRotation->SetValue( msg );
|
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
if( aItem->GetType() == DS_DATA_ITEM::DS_BITMAP )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM_BITMAP* item = static_cast<DS_DATA_ITEM_BITMAP*>( aItem );
|
2021-07-18 14:06:48 +00:00
|
|
|
|
2013-10-19 10:29:54 +00:00
|
|
|
// select definition in PPI
|
2022-02-28 18:02:00 +00:00
|
|
|
msg.Printf( wxT( "%d" ), item->GetPPI() );
|
2021-01-13 18:03:36 +00:00
|
|
|
m_textCtrlBitmapDPI->SetValue( msg );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2013-10-19 10:29:54 +00:00
|
|
|
|
2019-05-24 12:24:43 +00:00
|
|
|
m_SizerItemProperties->Show( true );
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
m_SizerTextOptions->Show( aItem->GetType() == DS_DATA_ITEM::DS_TEXT );
|
2021-09-12 09:02:17 +00:00
|
|
|
m_buttonHelp->Show( aItem->GetType() == DS_DATA_ITEM::DS_TEXT );
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
m_sbSizerEndPosition->Show( aItem->GetType() == DS_DATA_ITEM::DS_SEGMENT
|
2021-07-18 14:06:48 +00:00
|
|
|
|| aItem->GetType() == DS_DATA_ITEM::DS_RECT );
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
m_lineWidth.Show( aItem->GetType() != DS_DATA_ITEM::DS_BITMAP );
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
if( aItem->GetType() == DS_DATA_ITEM::DS_TEXT
|
|
|
|
|| aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON )
|
2021-01-13 18:03:36 +00:00
|
|
|
{
|
|
|
|
m_staticTextRot->Show( true );
|
|
|
|
m_textCtrlRotation->Show( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_staticTextRot->Show( false );
|
|
|
|
m_textCtrlRotation->Show( false );
|
|
|
|
}
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
m_staticTextBitmapDPI->Show( aItem->GetType() == DS_DATA_ITEM::DS_BITMAP );
|
|
|
|
m_textCtrlBitmapDPI->Show( aItem->GetType() == DS_DATA_ITEM::DS_BITMAP );
|
2019-05-24 12:24:43 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
m_staticTextInclabel->Show( aItem->GetType() == DS_DATA_ITEM::DS_TEXT );
|
|
|
|
m_textCtrlTextIncrement->Show( aItem->GetType() == DS_DATA_ITEM::DS_TEXT );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Repeat parameters
|
2022-02-28 18:02:00 +00:00
|
|
|
msg.Printf( wxT( "%d" ), aItem->m_RepeatCount );
|
2013-07-19 18:27:22 +00:00
|
|
|
m_textCtrlRepeatCount->SetValue( msg );
|
2020-12-09 02:31:10 +00:00
|
|
|
|
2023-02-08 13:26:54 +00:00
|
|
|
m_textStepX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
aItem->m_IncrementVector.x ) );
|
|
|
|
m_textStepY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
|
|
|
|
aItem->m_IncrementVector.y ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-11-05 17:37:15 +00:00
|
|
|
// The number of widgets was modified, so recalculate sizers
|
2013-07-20 19:36:19 +00:00
|
|
|
m_swItemProperties->Layout();
|
2023-02-08 13:26:54 +00:00
|
|
|
|
2020-11-30 17:50:36 +00:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
// This call is mandatory on wxGTK to initialize the right virtual size and therefore
|
2021-06-09 19:32:58 +00:00
|
|
|
// scrollbars, but for some reason, create issues on Windows (incorrect display
|
2020-11-30 17:50:36 +00:00
|
|
|
// until the frame is resized). Joys of multiplatform dev.
|
2020-11-30 18:13:14 +00:00
|
|
|
m_swItemProperties->Fit();
|
2020-11-30 17:50:36 +00:00
|
|
|
#endif
|
2021-07-18 14:06:48 +00:00
|
|
|
|
2020-11-30 17:50:36 +00:00
|
|
|
// send a size event to be sure scrollbars will be added/removed as needed
|
2020-11-05 17:37:15 +00:00
|
|
|
m_swItemProperties->PostSizeEvent();
|
2013-07-20 19:36:19 +00:00
|
|
|
m_swItemProperties->Refresh();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
void PROPERTIES_FRAME::onHAlignButton( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
for( BITMAP_BUTTON* btn : { m_alignLeft, m_alignCenter, m_alignRight } )
|
|
|
|
{
|
|
|
|
if( btn->IsChecked() && btn != aEvent.GetEventObject() )
|
|
|
|
btn->Check( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PROPERTIES_FRAME::onVAlignButton( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
for( BITMAP_BUTTON* btn : { m_vAlignTop, m_vAlignMiddle, m_vAlignBottom } )
|
|
|
|
{
|
|
|
|
if( btn->IsChecked() && btn != aEvent.GetEventObject() )
|
|
|
|
btn->Check( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PROPERTIES_FRAME::OnAcceptPrms( wxCommandEvent& event )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
PL_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool<PL_SELECTION_TOOL>();
|
2019-06-09 21:57:23 +00:00
|
|
|
PL_SELECTION& selection = selTool->GetSelection();
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-07-26 12:50:29 +00:00
|
|
|
m_parent->SaveCopyInUndoList();
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_BASE* drawItem = (DS_DRAW_ITEM_BASE*) selection.Front();
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
if( drawItem )
|
2013-08-18 15:49:04 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM* dataItem = drawItem->GetPeer();
|
2019-05-20 10:23:32 +00:00
|
|
|
CopyPrmsFromPanelToItem( dataItem );
|
2021-07-18 14:06:48 +00:00
|
|
|
|
2016-09-14 16:53:24 +00:00
|
|
|
// Be sure what is displayed is what is set for item
|
2013-08-18 15:49:04 +00:00
|
|
|
// (mainly, texts can be modified if they contain "\n")
|
2019-05-20 10:23:32 +00:00
|
|
|
CopyPrmsFromItemToPanel( dataItem );
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->GetView()->Update( drawItem );
|
2013-08-18 15:49:04 +00:00
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-07-20 19:36:19 +00:00
|
|
|
CopyPrmsFromPanelToGeneral();
|
|
|
|
|
2016-09-14 16:53:24 +00:00
|
|
|
// Refresh values, exactly as they are converted, to avoid any mistake
|
|
|
|
CopyPrmsFromGeneralToPanel();
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_parent->OnModify();
|
2019-06-03 15:39:04 +00:00
|
|
|
|
|
|
|
// Rebuild the draw list with the new parameters
|
2021-05-30 22:56:24 +00:00
|
|
|
m_parent->GetCanvas()->DisplayDrawingSheet();
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->Refresh();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2013-07-24 15:11:35 +00:00
|
|
|
void PROPERTIES_FRAME::OnSetDefaultValues( wxCommandEvent& event )
|
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
2019-05-25 13:56:52 +00:00
|
|
|
|
2022-01-20 00:17:44 +00:00
|
|
|
model.m_DefaultTextSize = VECTOR2D( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE );
|
2019-05-25 13:56:52 +00:00
|
|
|
model.m_DefaultLineWidth = 0.15;
|
|
|
|
model.m_DefaultTextThickness = 0.15;
|
2013-07-24 15:11:35 +00:00
|
|
|
|
|
|
|
CopyPrmsFromGeneralToPanel();
|
2019-06-03 15:39:04 +00:00
|
|
|
|
|
|
|
// Rebuild the draw list with the new parameters
|
2021-05-30 22:56:24 +00:00
|
|
|
m_parent->GetCanvas()->DisplayDrawingSheet();
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->Refresh();
|
2013-07-24 15:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
if( aItem == nullptr )
|
2013-07-19 18:27:22 +00:00
|
|
|
return false;
|
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
const EDA_UNITS units = EDA_UNITS::MILLIMETRES;
|
|
|
|
wxString msg;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Import common parameters:
|
|
|
|
aItem->m_Info = m_textCtrlComment->GetValue();
|
|
|
|
|
|
|
|
switch( m_choicePageOpt->GetSelection() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
default:
|
|
|
|
case 0: aItem->SetPage1Option( ALL_PAGES ); break;
|
|
|
|
case 1: aItem->SetPage1Option( FIRST_PAGE_ONLY ); break;
|
|
|
|
case 2: aItem->SetPage1Option( SUBSEQUENT_PAGES ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Import thickness
|
2023-02-07 11:53:34 +00:00
|
|
|
bool is_valid = m_lineWidth.Validate( 0.0, 10.0, EDA_UNITS::MILLIMETRES );
|
|
|
|
|
|
|
|
if( is_valid )
|
|
|
|
aItem->m_LineWidth =
|
2022-09-16 04:38:10 +00:00
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_lineWidth.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Import Start point
|
2022-09-16 04:38:10 +00:00
|
|
|
aItem->m_Pos.m_Pos.x =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textPosX.GetValue() );
|
|
|
|
aItem->m_Pos.m_Pos.y =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textPosY.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
switch( m_comboBoxCornerPos->GetSelection() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case 2: aItem->m_Pos.m_Anchor = RB_CORNER; break;
|
|
|
|
case 0: aItem->m_Pos.m_Anchor = RT_CORNER; break;
|
|
|
|
case 3: aItem->m_Pos.m_Anchor = LB_CORNER; break;
|
|
|
|
case 1: aItem->m_Pos.m_Anchor = LT_CORNER; break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Import End point
|
2022-09-16 04:38:10 +00:00
|
|
|
aItem->m_End.m_Pos.x =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textEndX.GetValue() );
|
|
|
|
aItem->m_End.m_Pos.y =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textEndY.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
switch( m_comboBoxCornerEnd->GetSelection() )
|
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
case 2: aItem->m_End.m_Anchor = RB_CORNER; break;
|
|
|
|
case 0: aItem->m_End.m_Anchor = RT_CORNER; break;
|
|
|
|
case 3: aItem->m_End.m_Anchor = LB_CORNER; break;
|
|
|
|
case 1: aItem->m_End.m_Anchor = LT_CORNER; break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Import Repeat prms
|
|
|
|
long itmp;
|
|
|
|
msg = m_textCtrlRepeatCount->GetValue();
|
|
|
|
msg.ToLong( &itmp );
|
2023-02-08 13:26:54 +00:00
|
|
|
|
2023-02-07 11:53:34 +00:00
|
|
|
// Ensure m_RepeatCount is > 0. Otherwise it create issues because a repeat
|
|
|
|
// count < 1 make no sense
|
|
|
|
if( itmp < 1l )
|
|
|
|
{
|
|
|
|
itmp = 1;
|
|
|
|
msg.Printf( wxT( "%ld" ), itmp );
|
|
|
|
m_textCtrlRepeatCount->SetValue( msg );
|
|
|
|
}
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
aItem->m_RepeatCount = itmp;
|
|
|
|
|
2022-09-16 04:38:10 +00:00
|
|
|
aItem->m_IncrementVector.x =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textStepX.GetValue() );
|
|
|
|
aItem->m_IncrementVector.y =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textStepY.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
if( aItem->GetType() == DS_DATA_ITEM::DS_TEXT )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM_TEXT* item = static_cast<DS_DATA_ITEM_TEXT*>( aItem );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
item->m_TextBase = m_stcText->GetValue();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
msg = m_textCtrlTextIncrement->GetValue();
|
|
|
|
msg.ToLong( &itmp );
|
|
|
|
item->m_IncrementLabel = itmp;
|
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
item->m_Bold = m_bold->IsChecked();
|
|
|
|
item->m_Italic = m_italic->IsChecked();
|
2022-03-31 18:43:08 +00:00
|
|
|
item->m_TextColor = m_textColorSwatch->GetSwatchColor();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
if( m_alignLeft->IsChecked() )
|
|
|
|
item->m_Hjustify = GR_TEXT_H_ALIGN_LEFT;
|
|
|
|
else if( m_alignCenter->IsChecked() )
|
|
|
|
item->m_Hjustify = GR_TEXT_H_ALIGN_CENTER;
|
|
|
|
else if( m_alignRight->IsChecked() )
|
|
|
|
item->m_Hjustify = GR_TEXT_H_ALIGN_RIGHT;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2022-02-28 18:02:00 +00:00
|
|
|
if( m_vAlignTop->IsChecked() )
|
|
|
|
item->m_Vjustify = GR_TEXT_V_ALIGN_TOP;
|
|
|
|
else if( m_vAlignMiddle->IsChecked() )
|
|
|
|
item->m_Vjustify = GR_TEXT_V_ALIGN_CENTER;
|
|
|
|
else if( m_vAlignBottom->IsChecked() )
|
|
|
|
item->m_Vjustify = GR_TEXT_V_ALIGN_BOTTOM;
|
|
|
|
|
|
|
|
if( m_fontCtrl->HaveFontSelection() )
|
|
|
|
item->m_Font = m_fontCtrl->GetFontSelection( item->m_Bold, item->m_Italic );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
msg = m_textCtrlRotation->GetValue();
|
2023-02-08 13:26:54 +00:00
|
|
|
item->m_Orient = EDA_UNIT_UTILS::UI::DoubleValueFromString( drawSheetIUScale,
|
|
|
|
EDA_UNITS::UNSCALED, msg );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Import text size
|
2023-02-07 11:53:34 +00:00
|
|
|
is_valid = m_textSizeX.Validate( 0.0, DLG_MAX_TEXTSIZE, EDA_UNITS::MILLIMETRES );
|
|
|
|
|
|
|
|
if( is_valid )
|
|
|
|
item->m_TextSize.x = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
|
|
|
m_textSizeX.GetValue() );
|
|
|
|
is_valid = m_textSizeY.Validate( 0.0, DLG_MAX_TEXTSIZE, EDA_UNITS::MILLIMETRES );
|
|
|
|
|
|
|
|
if( is_valid )
|
|
|
|
item->m_TextSize.y = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
|
|
|
|
m_textSizeY.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Import constraints:
|
2022-09-16 04:38:10 +00:00
|
|
|
item->m_BoundingBoxSize.x =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_constraintX.GetValue() );
|
|
|
|
item->m_BoundingBoxSize.y =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_constraintY.GetValue() );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM_POLYGONS* item = static_cast<DS_DATA_ITEM_POLYGONS*>( aItem );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
msg = m_textCtrlRotation->GetValue();
|
2022-09-16 04:38:10 +00:00
|
|
|
item->m_Orient = EDA_ANGLE(
|
2023-02-08 13:26:54 +00:00
|
|
|
EDA_UNIT_UTILS::UI::DoubleValueFromString( drawSheetIUScale,EDA_UNITS::UNSCALED,
|
|
|
|
msg ), DEGREES_T );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
if( aItem->GetType() == DS_DATA_ITEM::DS_BITMAP )
|
2013-10-19 10:29:54 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM_BITMAP* item = static_cast<DS_DATA_ITEM_BITMAP*>( aItem );
|
2021-01-13 18:03:36 +00:00
|
|
|
long value;
|
|
|
|
|
|
|
|
msg = m_textCtrlBitmapDPI->GetValue();
|
|
|
|
|
2013-10-19 10:29:54 +00:00
|
|
|
if( msg.ToLong( &value ) )
|
|
|
|
item->SetPPI( (int)value );
|
|
|
|
}
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-30 09:22:19 +00:00
|
|
|
|
|
|
|
void PROPERTIES_FRAME::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
|
|
|
{
|
|
|
|
wxArrayString autocompleteTokens;
|
|
|
|
int pos = m_stcText->GetCurrentPos();
|
|
|
|
int start = m_stcText->WordStartPosition( pos, true );
|
|
|
|
wxString partial;
|
|
|
|
|
|
|
|
if( start >= 2
|
|
|
|
&& m_stcText->GetCharAt( start-2 ) == '$'
|
|
|
|
&& m_stcText->GetCharAt( start-1 ) == '{' )
|
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_LIST::GetTextVars( &autocompleteTokens );
|
2020-05-30 09:22:19 +00:00
|
|
|
|
|
|
|
partial = m_stcText->GetTextRange( start, pos );
|
|
|
|
|
|
|
|
for( std::pair<wxString, wxString> entry : m_parent->Prj().GetTextVars() )
|
|
|
|
autocompleteTokens.push_back( entry.first );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens );
|
|
|
|
m_stcText->SetFocus();
|
|
|
|
}
|
2021-09-12 09:02:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PROPERTIES_FRAME::onHelp( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Show the system variables for worksheet text:
|
|
|
|
HTML_MESSAGE_BOX dlg( this, _( "Predefined Keywords" ) );
|
|
|
|
wxString message;
|
|
|
|
|
|
|
|
message << _( "Texts can include keywords." ) << "<br>";
|
|
|
|
message << _( "Keyword notation is ${keyword}" ) << "<br>";
|
2021-09-20 18:57:08 +00:00
|
|
|
message << _( "Each keyword is replaced by its value" ) << "<br><br>";
|
2021-09-12 09:02:17 +00:00
|
|
|
message << _( "These build-in keywords are always available:" ) << "<br><br>";
|
|
|
|
dlg.AddHTML_Text( message );
|
|
|
|
|
|
|
|
message = "KICAD_VERSION\n";
|
|
|
|
message << "# " << _( "(sheet number)" ) << "\n";
|
|
|
|
message << "## " << _( "(sheet count)" ) << "\n";
|
2021-09-14 23:25:16 +00:00
|
|
|
message << "COMMENT1 thru COMMENT9\n";
|
2021-09-12 09:02:17 +00:00
|
|
|
message << "COMPANY\n";
|
|
|
|
message << "FILENAME\n";
|
|
|
|
message << "ISSUE_DATE\n";
|
|
|
|
message << "LAYER\n";
|
|
|
|
message << "PAPER " << _( "(paper size)" ) << "\n";
|
|
|
|
message << "REVISION\n";
|
|
|
|
message << "SHEETNAME\n";
|
2022-04-09 14:38:47 +00:00
|
|
|
message << "SHEETPATH\n";
|
2021-09-12 09:02:17 +00:00
|
|
|
message << "TITLE\n";
|
|
|
|
|
|
|
|
dlg.ListSet( message );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|