Merge PCBnew text edit dialogs.

(cherry picked from commit 63b7738)
This commit is contained in:
Jeff Young 2018-06-06 11:05:56 +01:00
parent 40c1c8285d
commit ae2cb331b1
32 changed files with 2542 additions and 7220 deletions

View File

@ -785,9 +785,7 @@ LSET LSET::BackMask()
LSET LSET::ForbiddenTextLayers() LSET LSET::ForbiddenTextLayers()
{ {
static const LSET saved = AllCuMask().set( Edge_Cuts ).set( Margin ) static const LSET saved( 6, Edge_Cuts, Margin, F_Paste, B_Paste, F_Mask, B_Mask );
.set( F_Paste ).set( B_Paste )
.set( F_Mask ).set( B_Mask );
return saved; return saved;
} }

View File

@ -395,7 +395,7 @@ public:
void ResetModuleTextSizes( const wxString & aFilter, bool aRef, void ResetModuleTextSizes( const wxString & aFilter, bool aRef,
bool aValue, bool aOthers ); bool aValue, bool aOthers );
void InstallPadOptionsFrame( D_PAD* pad ); void InstallPadOptionsFrame( D_PAD* pad );
void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC ); void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC );
void AddPad( MODULE* Module, bool draw ); void AddPad( MODULE* Module, bool draw );

View File

@ -61,17 +61,14 @@ set( PCBNEW_DIALOGS
dialogs/dialog_copper_zones_base.cpp dialogs/dialog_copper_zones_base.cpp
dialogs/dialog_create_array.cpp dialogs/dialog_create_array.cpp
dialogs/dialog_create_array_base.cpp dialogs/dialog_create_array_base.cpp
dialogs/dialog_drc.cpp
dialogs/dialog_design_rules.cpp dialogs/dialog_design_rules.cpp
dialogs/dialog_design_rules_base.cpp dialogs/dialog_design_rules_base.cpp
dialogs/dialog_dimension_editor_base.cpp
dialogs/dialog_drc.cpp
dialogs/dialog_drc_base.cpp dialogs/dialog_drc_base.cpp
dialogs/dialog_edit_footprint_for_BoardEditor.cpp dialogs/dialog_edit_footprint_for_BoardEditor.cpp
dialogs/dialog_edit_footprint_for_BoardEditor_base.cpp dialogs/dialog_edit_footprint_for_BoardEditor_base.cpp
dialogs/dialog_edit_footprint_for_fp_editor.cpp dialogs/dialog_edit_footprint_for_fp_editor.cpp
dialogs/dialog_edit_footprint_for_fp_editor_base.cpp dialogs/dialog_edit_footprint_for_fp_editor_base.cpp
dialogs/dialog_edit_footprint_text.cpp
dialogs/dialog_edit_footprint_text_base.cpp
dialogs/dialog_enum_pads.cpp dialogs/dialog_enum_pads.cpp
dialogs/dialog_enum_pads_base.cpp dialogs/dialog_enum_pads_base.cpp
dialogs/dialog_exchange_footprints.cpp dialogs/dialog_exchange_footprints.cpp
@ -125,8 +122,6 @@ set( PCBNEW_DIALOGS
dialogs/dialog_pad_basicshapes_properties.cpp dialogs/dialog_pad_basicshapes_properties.cpp
dialogs/dialog_pad_properties.cpp dialogs/dialog_pad_properties.cpp
dialogs/dialog_pad_properties_base.cpp dialogs/dialog_pad_properties_base.cpp
dialogs/dialog_pcb_text_properties.cpp
dialogs/dialog_pcb_text_properties_base.cpp
dialogs/dialog_plot.cpp dialogs/dialog_plot.cpp
dialogs/dialog_plot_base.cpp dialogs/dialog_plot_base.cpp
dialogs/dialog_pns_diff_pair_dimensions.cpp dialogs/dialog_pns_diff_pair_dimensions.cpp
@ -148,6 +143,8 @@ set( PCBNEW_DIALOGS
dialogs/dialog_set_grid.cpp dialogs/dialog_set_grid.cpp
dialogs/dialog_set_grid_base.cpp dialogs/dialog_set_grid_base.cpp
dialogs/dialog_target_properties_base.cpp dialogs/dialog_target_properties_base.cpp
dialogs/dialog_text_properties.cpp
dialogs/dialog_text_properties_base.cpp
dialogs/dialog_track_via_properties.cpp dialogs/dialog_track_via_properties.cpp
dialogs/dialog_track_via_properties_base.cpp dialogs/dialog_track_via_properties_base.cpp
dialogs/dialog_track_via_size.cpp dialogs/dialog_track_via_size.cpp

View File

@ -1,135 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 19 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "pcb_layer_box_selector.h"
#include "widgets/text_ctrl_eval.h"
#include "dialog_dimension_editor_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_staticTextDim = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextDim->Wrap( -1 );
bSizerMain->Add( m_staticTextDim, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_Name = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_Name->SetMinSize( wxSize( 400,-1 ) );
bSizerMain->Add( m_Name, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerUpper;
bSizerUpper = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerLeft;
bSizerLeft = new wxBoxSizer( wxVERTICAL );
m_staticTextSizeX = new wxStaticText( this, wxID_ANY, _("Text width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextSizeX->Wrap( -1 );
bSizerLeft->Add( m_staticTextSizeX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TxtSizeXCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_TxtSizeXCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextSizeY = new wxStaticText( this, wxID_ANY, _("Text height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextSizeY->Wrap( -1 );
bSizerLeft->Add( m_staticTextSizeY, 0, wxRIGHT|wxLEFT, 5 );
m_TxtSizeYCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_TxtSizeYCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextWidth = new wxStaticText( this, wxID_ANY, _("Text thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextWidth->Wrap( -1 );
bSizerLeft->Add( m_staticTextWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TxtWidthCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_TxtWidthCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextPosX = new wxStaticText( this, wxID_ANY, _("Text position X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPosX->Wrap( -1 );
bSizerLeft->Add( m_staticTextPosX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCtrlPosX = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_textCtrlPosX, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextPosY = new wxStaticText( this, wxID_ANY, _("Text position Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPosY->Wrap( -1 );
bSizerLeft->Add( m_staticTextPosY, 0, wxRIGHT|wxLEFT, 5 );
m_textCtrlPosY = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerLeft->Add( m_textCtrlPosY, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerUpper->Add( bSizerLeft, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
wxString m_rbMirrorChoices[] = { _("Normal"), _("Mirror") };
int m_rbMirrorNChoices = sizeof( m_rbMirrorChoices ) / sizeof( wxString );
m_rbMirror = new wxRadioBox( this, wxID_ANY, _("Display:"), wxDefaultPosition, wxDefaultSize, m_rbMirrorNChoices, m_rbMirrorChoices, 1, wxRA_SPECIFY_COLS );
m_rbMirror->SetSelection( 0 );
bSizerRight->Add( m_rbMirror, 0, wxALL|wxEXPAND, 5 );
m_staticTextLayer = new wxStaticText( this, wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextLayer->Wrap( -1 );
bSizerRight->Add( m_staticTextLayer, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bSizerRight->Add( m_SelLayerBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerUpper->Add( bSizerRight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
m_sdbSizerBts = new wxStdDialogButtonSizer();
m_sdbSizerBtsOK = new wxButton( this, wxID_OK );
m_sdbSizerBts->AddButton( m_sdbSizerBtsOK );
m_sdbSizerBtsCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizerBts->AddButton( m_sdbSizerBtsCancel );
m_sdbSizerBts->Realize();
bSizerMain->Add( m_sdbSizerBts, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
// Connect Events
m_TxtSizeXCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_TxtSizeYCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_TxtWidthCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_textCtrlPosX->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_textCtrlPosY->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_sdbSizerBtsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
}
DIALOG_DIMENSION_EDITOR_BASE::~DIALOG_DIMENSION_EDITOR_BASE()
{
// Disconnect Events
m_TxtSizeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_TxtSizeYCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_TxtWidthCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_textCtrlPosX->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_textCtrlPosY->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
m_sdbSizerBtsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 19 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_DIMENSION_EDITOR_BASE_H__
#define __DIALOG_DIMENSION_EDITOR_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class PCB_LAYER_BOX_SELECTOR;
class TEXT_CTRL_EVAL;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/radiobox.h>
#include <wx/bmpcbox.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_DIMENSION_EDITOR_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_DIMENSION_EDITOR_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_staticTextDim;
wxTextCtrl* m_Name;
wxStaticText* m_staticTextSizeX;
TEXT_CTRL_EVAL* m_TxtSizeXCtrl;
wxStaticText* m_staticTextSizeY;
TEXT_CTRL_EVAL* m_TxtSizeYCtrl;
wxStaticText* m_staticTextWidth;
TEXT_CTRL_EVAL* m_TxtWidthCtrl;
wxStaticText* m_staticTextPosX;
TEXT_CTRL_EVAL* m_textCtrlPosX;
wxStaticText* m_staticTextPosY;
TEXT_CTRL_EVAL* m_textCtrlPosY;
wxRadioBox* m_rbMirror;
wxStaticText* m_staticTextLayer;
PCB_LAYER_BOX_SELECTOR* m_SelLayerBox;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizerBts;
wxButton* m_sdbSizerBtsOK;
wxButton* m_sdbSizerBtsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Dimension Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_DIMENSION_EDITOR_BASE();
};
#endif //__DIALOG_DIMENSION_EDITOR_BASE_H__

View File

@ -44,7 +44,6 @@
#include <filename_resolver.h> #include <filename_resolver.h>
#include "3d_cache/dialogs/panel_prev_model.h" #include "3d_cache/dialogs/panel_prev_model.h"
#include "3d_cache/dialogs/3d_cache_dialogs.h" #include "3d_cache/dialogs/3d_cache_dialogs.h"
#include <dialog_edit_footprint_text.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <3d_viewer.h> #include <3d_viewer.h>

View File

@ -49,7 +49,6 @@
#include "3d_cache/dialogs/panel_prev_model.h" #include "3d_cache/dialogs/panel_prev_model.h"
#include "3d_cache/dialogs/3d_cache_dialogs.h" #include "3d_cache/dialogs/3d_cache_dialogs.h"
#include <dialog_edit_footprint_text.h>
#include <fp_lib_table.h> #include <fp_lib_table.h>
#define LibFootprintTextShownColumnsKey wxT( "LibFootprintTextShownColumns" ) #define LibFootprintTextShownColumnsKey wxT( "LibFootprintTextShownColumns" )

View File

@ -1,240 +0,0 @@
/**
* @file dialog_edit_module_text.cpp
* @brief dialog editor for texts (fields) in footprints.
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* 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 <fctsys.h>
#include <macros.h>
#include <gr_basic.h>
#include <common.h>
#include <class_drawpanel.h>
#include <pcbnew.h>
#include <draw_graphic_text.h>
#include <confirm.h>
#include <pcb_base_frame.h>
#include <base_units.h>
#include <wx/numformatter.h>
#include <board_commit.h>
#include <widgets/text_ctrl_eval.h>
#include <class_module.h>
#include <class_text_mod.h>
#include <class_board.h>
#include <pcb_layer_box_selector.h>
#include <dialog_edit_footprint_text.h>
extern wxPoint MoveVector; // Move vector for move edge, imported from edtxtmod.cpp
void PCB_BASE_FRAME::InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC )
{
m_canvas->SetIgnoreMouseEvents( true );
DIALOG_EDIT_FPTEXT dialog( this, this, TextMod, DC );
dialog.ShowModal();
m_canvas->SetIgnoreMouseEvents( false );
}
DIALOG_EDIT_FPTEXT::DIALOG_EDIT_FPTEXT( wxWindow* aCaller, PCB_BASE_FRAME* aFrame,
TEXTE_MODULE* aTextMod, wxDC* aDC ) :
DIALOG_EDIT_FPTEXT_BASE( aCaller ),
m_frame( aFrame ), m_dc( aDC ), m_text( aTextMod ),
m_textWidth( aFrame, m_widthLabel, m_widthCtrl, m_widthUnits, true, TEXTS_MIN_SIZE ),
m_textHeight( aFrame, m_heightLabel, m_heightCtrl, m_heightUnits, true, TEXTS_MIN_SIZE ),
m_thickness( aFrame, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true, 0 ),
m_posX( aFrame, m_posXLabel, m_posXCtrl, m_posXUnits ),
m_posY( aFrame, m_posYLabel, m_posYCtrl, m_posYUnits ),
m_OrientValidator( 1, &m_OrientValue )
{
if( m_text )
m_module = (MODULE*) m_text->GetParent();
m_OrientValue = 0;
switch( m_text->GetType() )
{
case TEXTE_MODULE::TEXT_is_REFERENCE: m_TextDataTitle->SetLabel( _( "Reference:" ) ); break;
case TEXTE_MODULE::TEXT_is_VALUE: m_TextDataTitle->SetLabel( _( "Value:" ) ); break;
case TEXTE_MODULE::TEXT_is_DIVERS: m_TextDataTitle->SetLabel( _( "Text:" ) ); break;
}
// 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.
if( !m_frame->GetBoard()->IsLayerEnabled( m_text->GetLayer() ) )
m_LayerSelectionCtrl->ShowNonActivatedLayers( true );
m_LayerSelectionCtrl->SetLayersHotkeys( false );
m_LayerSelectionCtrl->SetNotAllowedLayerSet( LSET::ForbiddenTextLayers() );
m_LayerSelectionCtrl->SetBoardFrame( m_frame );
m_LayerSelectionCtrl->Resync();
m_OrientValidator.SetRange( -180.0, 180.0 );
m_OrientValueCtrl->SetValidator( m_OrientValidator );
m_OrientValidator.SetWindow( m_OrientValueCtrl );
m_sdbSizerOK->SetDefault();
SetInitialFocus( m_Name );
Layout();
FinishDialogSettings();
}
bool DIALOG_EDIT_FPTEXT::TransferDataToWindow()
{
if( !wxDialog::TransferDataToWindow() )
return false;
wxString msg1, msg2;
if( m_module )
{
msg1.Printf( _("Footprint %s (%s),"), m_module->GetReference(), m_module->GetValue() );
msg2.Printf( _("orientation %.1f deg"), m_module->GetOrientation() / 10.0 );
}
m_statusLine1->SetLabel( msg1 );
m_statusLine2->SetLabel( msg2 );
m_Name->SetValue( m_text->GetText() );
m_textWidth.SetValue( m_text->GetTextWidth() );
m_textHeight.SetValue( m_text->GetTextHeight() );
m_thickness.SetValue( m_text->GetThickness() );
m_posX.SetValue( m_text->GetPos0().x );
m_posY.SetValue( m_text->GetPos0().y );
m_Show->SetValue( m_text->IsVisible() );
m_Italic->SetValue( m_text->IsItalic() );
m_OrientValue = m_text->GetTextAngle() / 10.0;
m_Orient0->SetValue( m_OrientValue == 0.0 );
m_Orient90->SetValue( m_OrientValue == 90.0 || m_OrientValue == -270.0 );
m_Orient270->SetValue( m_OrientValue == 270.0 || m_OrientValue == -90.0 );
m_Orient180->SetValue( m_OrientValue == 180.0 || m_OrientValue == -180.0 );
m_OrientOther->SetValue( !m_Orient0->GetValue() && !m_Orient90->GetValue()
&& !m_Orient270->GetValue() && !m_Orient180->GetValue() );
m_OrientValidator.TransferToWindow();
m_unlock->SetValue( m_text->IsUnlocked() );
if( m_LayerSelectionCtrl->SetLayerSelection( m_text->GetLayer() ) < 0 )
{
wxString layerName = m_frame->GetBoard()->GetLayerName( ToLAYER_ID( m_text->GetLayer() ) );
DisplayError( this, wxString::Format( _( "Text not allowed on %s." ), layerName ) );
m_LayerSelectionCtrl->SetLayerSelection( F_SilkS );
}
return true;
}
bool DIALOG_EDIT_FPTEXT::TransferDataFromWindow()
{
BOARD_COMMIT commit( m_frame );
if( !Validate() || !DIALOG_EDIT_FPTEXT_BASE::TransferDataFromWindow() )
return false;
if( !m_textWidth.Validate( true ) || !m_textHeight.Validate( true ) )
return false;
if( m_module )
commit.Modify( m_text );
#ifndef USE_WX_OVERLAY
if( m_dc ) // Erase old text on screen
{
m_text->Draw( m_frame->GetCanvas(), m_dc, GR_XOR,
m_text->IsMoving() ? MoveVector : wxPoint( 0, 0 ) );
}
#endif
m_text->SetText( m_Name->GetValue() );
m_text->SetItalic( m_Italic->GetValue() );
m_text->SetVisible( m_Show->GetValue() );
m_text->SetPos0( wxPoint( m_posX.GetValue(), m_posY.GetValue() ) );
m_text->SetTextSize( wxSize( m_textWidth.GetValue(), m_textHeight.GetValue() ) );
m_text->SetThickness( Clamp_Text_PenSize( m_thickness.GetValue(), m_text->GetTextSize() ) );
m_text->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) );
m_text->SetDrawCoord();
m_text->SetUnlocked( m_unlock->GetValue() );
m_text->SetLayer( ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) );
m_text->SetMirrored( IsBackLayer( m_text->GetLayer() ) );
#ifndef USE_WX_OVERLAY
if( m_dc ) // Display new text
{
m_text->Draw( m_frame->GetCanvas(), m_dc, GR_XOR,
m_text->IsMoving() ? MoveVector : wxPoint( 0, 0 ) );
}
#else
m_frame->Refresh();
#endif
commit.Push( _( "Modify module text" ) );
if( m_module )
m_module->SetLastEditTime();
return true;
}
void DIALOG_EDIT_FPTEXT::ModuleOrientEvent( wxCommandEvent& )
{
if( m_Orient0->GetValue() )
m_OrientValue = 0.0;
else if( m_Orient90->GetValue() )
m_OrientValue = 90.0;
else if( m_Orient270->GetValue() )
m_OrientValue = 270.0;
else if( m_Orient180->GetValue() )
m_OrientValue = 180.0;
m_OrientValidator.TransferToWindow();
}
void DIALOG_EDIT_FPTEXT::OnOtherOrientation( wxKeyEvent& aEvent )
{
m_OrientOther->SetValue( true );
aEvent.Skip();
}

View File

@ -1,65 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* 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
*/
#ifndef DIALOG_EDIT_FOOTPRINT_TEXT_H
#define DIALOG_EDIT_FOOTPRINT_TEXT_H
#include <dialog_edit_footprint_text_base.h>
#include <wx/valnum.h>
#include <widgets/unit_binder.h>
class DIALOG_EDIT_FPTEXT : public DIALOG_EDIT_FPTEXT_BASE
{
private:
PCB_BASE_FRAME* m_frame;
wxDC* m_dc;
MODULE* m_module;
TEXTE_MODULE* m_text;
UNIT_BINDER m_textWidth;
UNIT_BINDER m_textHeight;
UNIT_BINDER m_thickness;
UNIT_BINDER m_posX;
UNIT_BINDER m_posY;
wxFloatingPointValidator<double> m_OrientValidator;
double m_OrientValue;
public:
DIALOG_EDIT_FPTEXT( wxWindow* aCaller, PCB_BASE_FRAME* aFrame,
TEXTE_MODULE* aTextMod, wxDC* aDC );
~DIALOG_EDIT_FPTEXT() {};
protected:
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
private:
void ModuleOrientEvent( wxCommandEvent& event ) override;
void OnOtherOrientation( wxKeyEvent& event ) override;
};
#endif /* DIALOG_EDIT_FOOTPRINT_TEXT_H */

View File

@ -1,240 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "pcb_layer_box_selector.h"
#include "widgets/text_ctrl_eval.h"
#include "dialog_edit_footprint_text_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_EDIT_FPTEXT_BASE::DIALOG_EDIT_FPTEXT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* upperSizer;
upperSizer = new wxBoxSizer( wxHORIZONTAL );
wxFlexGridSizer* leftSizer;
leftSizer = new wxFlexGridSizer( 8, 3, 0, 0 );
leftSizer->AddGrowableCol( 1 );
leftSizer->AddGrowableRow( 6 );
leftSizer->SetFlexibleDirection( wxBOTH );
leftSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );
m_TextDataTitle = new wxStaticText( this, wxID_ANY, _("Reference:"), wxDefaultPosition, wxDefaultSize, 0 );
m_TextDataTitle->Wrap( -1 );
leftSizer->Add( m_TextDataTitle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_Name = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_Name->SetMinSize( wxSize( 160,-1 ) );
leftSizer->Add( m_Name, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 );
leftSizer->Add( 0, 0, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP, 5 );
m_widthLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_widthLabel->Wrap( -1 );
leftSizer->Add( m_widthLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_widthCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
leftSizer->Add( m_widthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxLEFT, 5 );
m_widthUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_widthUnits->Wrap( -1 );
leftSizer->Add( m_widthUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_heightLabel = new wxStaticText( this, wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_heightLabel->Wrap( -1 );
leftSizer->Add( m_heightLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_heightCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
leftSizer->Add( m_heightCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxLEFT, 5 );
m_heightUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_heightUnits->Wrap( -1 );
leftSizer->Add( m_heightUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_thicknessLabel = new wxStaticText( this, wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_thicknessLabel->Wrap( -1 );
leftSizer->Add( m_thicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_thicknessCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
leftSizer->Add( m_thicknessCtrl, 0, wxEXPAND|wxTOP|wxLEFT, 5 );
m_thicknessUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_thicknessUnits->Wrap( -1 );
leftSizer->Add( m_thicknessUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_posXLabel = new wxStaticText( this, wxID_ANY, _("Offset X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_posXLabel->Wrap( -1 );
leftSizer->Add( m_posXLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_posXCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
leftSizer->Add( m_posXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxLEFT, 5 );
m_posXUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_posXUnits->Wrap( -1 );
leftSizer->Add( m_posXUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
m_posYLabel = new wxStaticText( this, wxID_ANY, _("Offset Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_posYLabel->Wrap( -1 );
leftSizer->Add( m_posYLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );
m_posYCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
leftSizer->Add( m_posYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxEXPAND, 5 );
m_posYUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_posYUnits->Wrap( -1 );
leftSizer->Add( m_posYUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 );
leftSizer->Add( 0, 0, 0, wxEXPAND, 5 );
leftSizer->Add( 0, 0, 0, wxEXPAND, 5 );
leftSizer->Add( 0, 0, 0, wxEXPAND, 5 );
m_LayerLabel = new wxStaticText( this, wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 );
m_LayerLabel->Wrap( -1 );
leftSizer->Add( m_LayerLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_LayerSelectionCtrl = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
leftSizer->Add( m_LayerSelectionCtrl, 0, wxEXPAND|wxLEFT, 5 );
upperSizer->Add( leftSizer, 1, wxALL|wxEXPAND, 10 );
upperSizer->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* rightSizer;
rightSizer = new wxBoxSizer( wxVERTICAL );
m_Show = new wxCheckBox( this, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 );
rightSizer->Add( m_Show, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_Italic = new wxCheckBox( this, wxID_ANY, _("Italic"), wxDefaultPosition, wxDefaultSize, 0 );
rightSizer->Add( m_Italic, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
rightSizer->Add( 0, 0, 1, wxEXPAND, 5 );
stOrienationLabel = new wxStaticText( this, wxID_ANY, _("Orientation:"), wxDefaultPosition, wxDefaultSize, 0 );
stOrienationLabel->Wrap( -1 );
rightSizer->Add( stOrienationLabel, 0, wxALL, 5 );
wxGridBagSizer* gbSizer1;
gbSizer1 = new wxGridBagSizer( 2, 0 );
gbSizer1->SetFlexibleDirection( wxBOTH );
gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_Orient0 = new wxRadioButton( this, wxID_ANY, _("0.0 deg"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_Orient0, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), 0, 5 );
m_Orient90 = new wxRadioButton( this, wxID_ANY, _("90.0 deg"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_Orient90, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), 0, 5 );
m_Orient270 = new wxRadioButton( this, wxID_ANY, _("-90.0 deg"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_Orient270, wxGBPosition( 2, 0 ), wxGBSpan( 1, 2 ), 0, 5 );
m_Orient180 = new wxRadioButton( this, wxID_ANY, _("180.0 deg"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_Orient180, wxGBPosition( 3, 0 ), wxGBSpan( 1, 2 ), 0, 5 );
m_OrientOther = new wxRadioButton( this, wxID_ANY, _("Other:"), wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_OrientOther, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
m_OrientValueCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gbSizer1->Add( m_OrientValueCtrl, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
gbSizer1->AddGrowableCol( 1 );
rightSizer->Add( gbSizer1, 0, wxEXPAND|wxLEFT, 20 );
m_unlock = new wxCheckBox( this, wxID_ANY, _("Unconstrained"), wxDefaultPosition, wxDefaultSize, 0 );
m_unlock->SetToolTip( _("If orientation is locked, the text will always face near the bottom or right edge of the board.") );
rightSizer->Add( m_unlock, 0, wxALL, 5 );
upperSizer->Add( rightSizer, 0, wxEXPAND|wxALL, 10 );
bMainSizer->Add( upperSizer, 0, wxEXPAND, 5 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline2, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 );
wxBoxSizer* lowerSizer;
lowerSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxVERTICAL );
m_statusLine1 = new wxStaticText( this, wxID_ANY, _("Status line 1"), wxDefaultPosition, wxDefaultSize, 0 );
m_statusLine1->Wrap( -1 );
m_statusLine1->SetFont( wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
bSizer7->Add( m_statusLine1, 0, wxBOTTOM|wxRIGHT|wxLEFT, 2 );
m_statusLine2 = new wxStaticText( this, wxID_ANY, _("Status line 2"), wxDefaultPosition, wxDefaultSize, 0 );
m_statusLine2->Wrap( -1 );
m_statusLine2->SetFont( wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
bSizer7->Add( m_statusLine2, 0, wxRIGHT|wxLEFT, 2 );
lowerSizer->Add( bSizer7, 0, wxEXPAND|wxTOP|wxLEFT, 8 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
lowerSizer->Add( m_sdbSizer, 1, wxEXPAND|wxALL, 5 );
bMainSizer->Add( lowerSizer, 1, wxEXPAND|wxLEFT, 5 );
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_FPTEXT_BASE::OnInitDlg ) );
m_Orient0->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_Orient90->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_Orient270->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_Orient180->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_OrientOther->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_OrientValueCtrl->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_EDIT_FPTEXT_BASE::OnOtherOrientation ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::OnOkClick ), NULL, this );
}
DIALOG_EDIT_FPTEXT_BASE::~DIALOG_EDIT_FPTEXT_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_FPTEXT_BASE::OnInitDlg ) );
m_Orient0->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_Orient90->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_Orient270->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_Orient180->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_OrientOther->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::ModuleOrientEvent ), NULL, this );
m_OrientValueCtrl->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_EDIT_FPTEXT_BASE::OnOtherOrientation ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_FPTEXT_BASE::OnOkClick ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,94 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_EDIT_FOOTPRINT_TEXT_BASE_H__
#define __DIALOG_EDIT_FOOTPRINT_TEXT_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class PCB_LAYER_BOX_SELECTOR;
class TEXT_CTRL_EVAL;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/bmpcbox.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/radiobut.h>
#include <wx/gbsizer.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_EDIT_FPTEXT_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_EDIT_FPTEXT_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_TextDataTitle;
wxTextCtrl* m_Name;
wxStaticText* m_widthLabel;
TEXT_CTRL_EVAL* m_widthCtrl;
wxStaticText* m_widthUnits;
wxStaticText* m_heightLabel;
TEXT_CTRL_EVAL* m_heightCtrl;
wxStaticText* m_heightUnits;
wxStaticText* m_thicknessLabel;
TEXT_CTRL_EVAL* m_thicknessCtrl;
wxStaticText* m_thicknessUnits;
wxStaticText* m_posXLabel;
TEXT_CTRL_EVAL* m_posXCtrl;
wxStaticText* m_posXUnits;
wxStaticText* m_posYLabel;
TEXT_CTRL_EVAL* m_posYCtrl;
wxStaticText* m_posYUnits;
wxStaticText* m_LayerLabel;
PCB_LAYER_BOX_SELECTOR* m_LayerSelectionCtrl;
wxCheckBox* m_Show;
wxCheckBox* m_Italic;
wxStaticText* stOrienationLabel;
wxRadioButton* m_Orient0;
wxRadioButton* m_Orient90;
wxRadioButton* m_Orient270;
wxRadioButton* m_Orient180;
wxRadioButton* m_OrientOther;
wxTextCtrl* m_OrientValueCtrl;
wxCheckBox* m_unlock;
wxStaticLine* m_staticline2;
wxStaticText* m_statusLine1;
wxStaticText* m_statusLine2;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
virtual void ModuleOrientEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOtherOrientation( wxKeyEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_EDIT_FPTEXT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Footprint Text Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_EDIT_FPTEXT_BASE();
};
#endif //__DIALOG_EDIT_FOOTPRINT_TEXT_BASE_H__

View File

@ -35,7 +35,7 @@
#include <kicad_string.h> #include <kicad_string.h>
#include <macros.h> #include <macros.h>
#include <board_commit.h> #include <board_commit.h>
#include <widgets/unit_binder.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <pcb_edit_frame.h> #include <pcb_edit_frame.h>
@ -44,7 +44,6 @@
#include <class_text_mod.h> #include <class_text_mod.h>
#include <dialog_global_footprints_fields_edition_base.h> #include <dialog_global_footprints_fields_edition_base.h>
// The dialog to set options for global fields edition: // The dialog to set options for global fields edition:
// optionas are: // optionas are:
// - edited fields (ref, value, others // - edited fields (ref, value, others
@ -53,6 +52,11 @@ class DIALOG_GLOBAL_FOOTPRINTS_FIELDS_EDITION : public DIALOG_GLOBAL_FOOTPRINTS_
{ {
PCB_EDIT_FRAME* m_parent; PCB_EDIT_FRAME* m_parent;
BOARD_DESIGN_SETTINGS* m_brdSettings; BOARD_DESIGN_SETTINGS* m_brdSettings;
UNIT_BINDER m_textWidth;
UNIT_BINDER m_textHeight;
UNIT_BINDER m_textThickness;
// Static variable to remember options, withing a session: // Static variable to remember options, withing a session:
static bool m_refSelection; static bool m_refSelection;
static bool m_valueSelection; static bool m_valueSelection;
@ -61,8 +65,11 @@ class DIALOG_GLOBAL_FOOTPRINTS_FIELDS_EDITION : public DIALOG_GLOBAL_FOOTPRINTS_
public: public:
DIALOG_GLOBAL_FOOTPRINTS_FIELDS_EDITION( PCB_EDIT_FRAME* parent ) DIALOG_GLOBAL_FOOTPRINTS_FIELDS_EDITION( PCB_EDIT_FRAME* parent ) :
: DIALOG_GLOBAL_FOOTPRINTS_FIELDS_EDITION_BASE( parent ) DIALOG_GLOBAL_FOOTPRINTS_FIELDS_EDITION_BASE( parent ),
m_textWidth( parent, m_staticText3, m_SizeX_Value, m_SizeXunit, true, 0 ),
m_textHeight( parent, m_staticText6, m_SizeY_Value, m_SizeYunit, true, 0 ),
m_textThickness( parent, m_staticText9, m_ThicknessValue, m_ThicknessUnit, true, 0 )
{ {
m_parent = parent; m_parent = parent;
initDialog(); initDialog();
@ -89,15 +96,9 @@ void DIALOG_GLOBAL_FOOTPRINTS_FIELDS_EDITION::initDialog()
m_ValueOpt->SetValue(m_valueSelection), m_ValueOpt->SetValue(m_valueSelection),
m_OtherFields->SetValue(m_othersSelection); m_OtherFields->SetValue(m_othersSelection);
m_ModuleFilter->SetValue(m_filterString); m_ModuleFilter->SetValue(m_filterString);
m_SizeXunit->SetLabel( GetAbbreviatedUnitsLabel() ); m_textWidth.SetValue( m_brdSettings->m_ModuleTextSize.x );
m_SizeYunit->SetLabel( GetAbbreviatedUnitsLabel() ); m_textHeight.SetValue( m_brdSettings->m_ModuleTextSize.y );
m_ThicknessUnit->SetLabel( GetAbbreviatedUnitsLabel() ); m_textThickness.SetValue( m_brdSettings->m_ModuleTextWidth );
m_SizeX_Value->SetValue(
StringFromValue( g_UserUnit, m_brdSettings->m_ModuleTextSize.x ) );
m_SizeY_Value->SetValue(
StringFromValue( g_UserUnit, m_brdSettings->m_ModuleTextSize.y ) );
m_ThicknessValue->SetValue(
StringFromValue( g_UserUnit, m_brdSettings->m_ModuleTextWidth) );
Layout(); Layout();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
@ -112,9 +113,9 @@ bool DIALOG_GLOBAL_FOOTPRINTS_FIELDS_EDITION::TransferDataFromWindow()
m_othersSelection = m_OtherFields->GetValue(); m_othersSelection = m_OtherFields->GetValue();
m_filterString = m_ModuleFilter->GetValue(); m_filterString = m_ModuleFilter->GetValue();
m_brdSettings->m_ModuleTextSize.x = ValueFromTextCtrl( *m_SizeX_Value ); m_brdSettings->m_ModuleTextSize.x = m_textWidth.GetValue();
m_brdSettings->m_ModuleTextSize.y = ValueFromTextCtrl( *m_SizeY_Value ); m_brdSettings->m_ModuleTextSize.y = m_textHeight.GetValue();
m_brdSettings->m_ModuleTextWidth = ValueFromTextCtrl( *m_ThicknessValue ); m_brdSettings->m_ModuleTextWidth = m_textThickness.GetValue();
// clip m_ModuleTextWidth to the 1/4 of min size, to keep it always readable // clip m_ModuleTextWidth to the 1/4 of min size, to keep it always readable
int max_thickness = std::min( m_brdSettings->m_ModuleTextSize.x, int max_thickness = std::min( m_brdSettings->m_ModuleTextSize.x,

View File

@ -1,354 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 2010-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* 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
*/
/***************************************************************************/
/* Dialog editor for text on copper and technical layers (TEXTE_PCB class) */
/***************************************************************************/
#include <fctsys.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <pcbnew.h>
#include <pcb_edit_frame.h>
#include <draw_graphic_text.h>
#include <confirm.h>
#include <base_units.h>
#include <wx/valnum.h>
#include <widgets/text_ctrl_eval.h>
#include <class_board.h>
#include <class_pcb_text.h>
#include <vector>
#include <wx/wx.h>
#include <dialog_pcb_text_properties_base.h>
#include <pcb_layer_box_selector.h>
#include <board_commit.h>
class PCB_EDIT_FRAME;
class TEXTE_PCB;
class DIALOG_PCB_TEXT_PROPERTIES : public DIALOG_PCB_TEXT_PROPERTIES_BASE
{
public:
DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, TEXTE_PCB* passedTextPCB, wxDC* DC = nullptr );
~DIALOG_PCB_TEXT_PROPERTIES();
private:
PCB_EDIT_FRAME* m_Parent;
wxDC* m_DC;
TEXTE_PCB* m_SelectedPCBText;
wxFloatingPointValidator<double> m_OrientValidator;
double m_OrientValue;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
// Virtual event handler
virtual void OnInitDlg( wxInitDialogEvent& event ) override
{
// Call the default wxDialog handler of a wxInitDialogEvent
TransferDataToWindow();
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
}
void OnCharHook( wxKeyEvent& aEvent );
};
/**
* DIALOG_PCB_TEXT_PROPERTIES, derived from DIALOG_PCB_TEXT_PROPERTIES_BASE
* @see dialog_dialog_pcb_text_properties_base.h and
* dialog_dialog_pcb_text_properties_base.cpp, automatically created by
* wxFormBuilder.
*/
DIALOG_PCB_TEXT_PROPERTIES::DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent,
TEXTE_PCB* passedTextPCB, wxDC* DC ) :
DIALOG_PCB_TEXT_PROPERTIES_BASE( parent ),
m_OrientValidator( 1, &m_OrientValue )
{
m_Parent = parent;
m_DC = DC;
m_SelectedPCBText = passedTextPCB;
m_OrientValue = 0.0;
m_OrientValidator.SetRange( -360.0, 360.0 );
m_OrientCtrl->SetValidator( m_OrientValidator );
m_OrientValidator.SetWindow( m_OrientCtrl );
m_StandardSizerOK->SetDefault();
// 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.
m_TextContentCtrl->Connect( wxEVT_CHAR_HOOK,
wxKeyEventHandler( DIALOG_PCB_TEXT_PROPERTIES::OnCharHook ),
NULL, this );
}
DIALOG_PCB_TEXT_PROPERTIES::~DIALOG_PCB_TEXT_PROPERTIES()
{
m_TextContentCtrl->Disconnect( wxEVT_CHAR_HOOK,
wxKeyEventHandler( DIALOG_PCB_TEXT_PROPERTIES::OnCharHook ),
NULL, this );
}
/**
* Routine for main window class to launch text properties dialog.
*/
void PCB_EDIT_FRAME::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC )
{
m_canvas->SetIgnoreMouseEvents( true );
#ifndef __WXMAC__
DIALOG_PCB_TEXT_PROPERTIES dlg( this, TextPCB, DC );
#else
// Avoid "writes" in the dialog, creates errors with WxOverlay and NSView
// Raising an Exception - Fixes #891347
DIALOG_PCB_TEXT_PROPERTIES dlg( this, TextPCB, NULL );
#endif
dlg.ShowModal();
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false );
}
void DIALOG_PCB_TEXT_PROPERTIES::OnCharHook( wxKeyEvent& aEvent )
{
if( aEvent.GetKeyCode() == WXK_TAB )
{
int flags = 0;
if( !aEvent.ShiftDown() )
flags |= wxNavigationKeyEvent::IsForward;
if( aEvent.ControlDown() )
flags |= wxNavigationKeyEvent::WinChange;
NavigateIn( flags );
}
else if( aEvent.GetKeyCode() == WXK_RETURN && aEvent.ShiftDown() )
{
TransferDataFromWindow();
EndModal( 1 );
}
else
{
aEvent.Skip();
}
}
bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow()
{
// Put units symbols to text labels where appropriate
AddUnitSymbol( *m_SizeXLabel );
AddUnitSymbol( *m_SizeYLabel );
AddUnitSymbol( *m_ThicknessLabel );
AddUnitSymbol( *m_PositionXLabel );
AddUnitSymbol( *m_PositionYLabel );
// Fill fields with current values
*m_TextContentCtrl << m_SelectedPCBText->GetText();
PutValueInLocalUnits( *m_SizeXCtrl, m_SelectedPCBText->GetTextWidth() );
PutValueInLocalUnits( *m_SizeYCtrl, m_SelectedPCBText->GetTextHeight() );
PutValueInLocalUnits( *m_ThicknessCtrl, m_SelectedPCBText->GetThickness() );
PutValueInLocalUnits( *m_PositionXCtrl, m_SelectedPCBText->GetTextPos().x );
PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->GetTextPos().y );
// Configure the layers list selector
m_LayerSelectionCtrl->SetLayersHotkeys( false );
// A text has no sense on edge cut layer
m_LayerSelectionCtrl->SetNotAllowedLayerSet( Edge_Cuts );
m_LayerSelectionCtrl->SetBoardFrame( m_Parent );
m_LayerSelectionCtrl->Resync();
m_LayerSelectionCtrl->SetLayerSelection( m_SelectedPCBText->GetLayer() );
m_OrientValue = m_SelectedPCBText->GetTextAngleDegrees();
if( m_SelectedPCBText->IsMirrored() )
m_DisplayCtrl->SetSelection( 1 );
else
m_DisplayCtrl->SetSelection( 0 );
if( m_SelectedPCBText->IsItalic() )
m_StyleCtrl->SetSelection( 1 );
else
m_StyleCtrl->SetSelection( 0 );
// Set justification
EDA_TEXT_HJUSTIFY_T hJustify = m_SelectedPCBText->GetHorizJustify();
m_justifyChoice->SetSelection( (int) hJustify + 1 );
// Manually set tab order
m_SizeXCtrl->MoveAfterInTabOrder( m_TextContentCtrl );
m_SizeYCtrl->MoveAfterInTabOrder( m_SizeXCtrl );
m_ThicknessCtrl->MoveAfterInTabOrder( m_SizeYCtrl );
m_PositionXCtrl->MoveAfterInTabOrder( m_ThicknessCtrl );
m_PositionYCtrl->MoveAfterInTabOrder( m_PositionXCtrl );
m_OrientCtrl->MoveAfterInTabOrder( m_PositionYCtrl );
m_LayerSelectionCtrl->MoveAfterInTabOrder( m_OrientCtrl );
m_StyleCtrl->MoveAfterInTabOrder( m_LayerSelectionCtrl );
m_DisplayCtrl->MoveAfterInTabOrder( m_StyleCtrl );
m_justifyChoice->MoveAfterInTabOrder( m_DisplayCtrl );
// Set focus on most important control
m_TextContentCtrl->SetFocus();
m_TextContentCtrl->SetSelection( -1, -1 );
return DIALOG_PCB_TEXT_PROPERTIES_BASE::TransferDataToWindow();
}
bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow()
{
if( !DIALOG_PCB_TEXT_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
BOARD_COMMIT commit( m_Parent );
commit.Modify( m_SelectedPCBText );
// Test for acceptable layer.
// Incorrect layer can happen for old boards,
// having texts on edge cut layer for instance
if( m_LayerSelectionCtrl->GetLayerSelection() < 0 )
{
wxMessageBox( _( "No layer selected, Please select the text layer" ) );
return false;
}
wxPoint newPosition;
wxSize newSize;
// If no other command in progress, prepare undo command
// (for a command in progress, will be made later, at the completion of command)
bool pushCommit = ( m_SelectedPCBText->GetFlags() == 0 );
/* set flag in edit to force undo/redo/abort proper operation,
* and avoid new calls to SaveCopyInUndoList for the same text
* this can occurs when a text is moved, and then rotated, edited ..
*/
if( m_SelectedPCBText->GetFlags() != 0 )
m_SelectedPCBText->SetFlags( IN_EDIT );
#ifndef USE_WX_OVERLAY
// Erase old text on screen if context is available
if( m_DC )
{
m_SelectedPCBText->Draw( m_Parent->GetCanvas(), m_DC, GR_XOR );
}
#endif
// Set the new text content
if( !m_TextContentCtrl->GetValue().IsEmpty() )
{
m_SelectedPCBText->SetText( m_TextContentCtrl->GetValue() );
}
// Set PCB Text position
newPosition.x = ValueFromString( g_UserUnit, m_PositionXCtrl->GetValue() );
newPosition.y = ValueFromString( g_UserUnit, m_PositionYCtrl->GetValue() );
m_SelectedPCBText->SetTextPos( newPosition );
// Check constraints and set PCB Text size
newSize.x = ValueFromString( g_UserUnit, m_SizeXCtrl->GetValue() );
newSize.y = ValueFromString( g_UserUnit, m_SizeYCtrl->GetValue() );
if( newSize.x < TEXTS_MIN_SIZE )
newSize.x = TEXTS_MIN_SIZE;
if( newSize.y < TEXTS_MIN_SIZE )
newSize.y = TEXTS_MIN_SIZE;
if( newSize.x > TEXTS_MAX_WIDTH )
newSize.x = TEXTS_MAX_WIDTH;
if( newSize.y > TEXTS_MAX_WIDTH )
newSize.y = TEXTS_MAX_WIDTH;
m_SelectedPCBText->SetTextSize( newSize );
// Set the new thickness
m_SelectedPCBText->SetThickness( ValueFromString( g_UserUnit,
m_ThicknessCtrl->GetValue() ) );
// Test for acceptable values for thickness and size and clamp if fails
int maxthickness = Clamp_Text_PenSize( m_SelectedPCBText->GetThickness(),
m_SelectedPCBText->GetTextSize() );
if( m_SelectedPCBText->GetThickness() > maxthickness )
{
DisplayError( NULL,
_( "The text thickness is too large for the text size. It will be clamped" ) );
m_SelectedPCBText->SetThickness( maxthickness );
}
// Set the layer on which the PCB text is laying
m_SelectedPCBText->SetLayer( ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) );
// Set whether the PCB text is mirrored (faced down from layer face perspective)
m_SelectedPCBText->SetMirrored( m_DisplayCtrl->GetSelection() == 1 );
// Set the text angle
m_SelectedPCBText->SetTextAngle( m_OrientValue * 10.0 );
// Set whether the PCB text is slanted (it is not italics, as italics has additional curves in style)
m_SelectedPCBText->SetItalic( m_StyleCtrl->GetSelection() );
// Set justification
switch( m_justifyChoice->GetSelection() )
{
case 0:
m_SelectedPCBText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break;
case 1:
m_SelectedPCBText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
break;
case 2:
m_SelectedPCBText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
break;
default:
break;
}
#ifndef USE_WX_OVERLAY
// Finally, display new text if there is a context to do so
if( m_DC )
{
m_SelectedPCBText->Draw( m_Parent->GetCanvas(), m_DC, GR_OR );
}
#else
m_Parent->Refresh();
#endif
if( pushCommit )
commit.Push( _( "Change text properties" ) );
return true;
}

View File

@ -1,169 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "pcb_layer_box_selector.h"
#include "widgets/text_ctrl_eval.h"
#include "dialog_pcb_text_properties_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_PCB_TEXT_PROPERTIES_BASE::DIALOG_PCB_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer9;
bSizer9 = new wxBoxSizer( wxVERTICAL );
m_TextLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
m_TextLabel->Wrap( -1 );
bSizer9->Add( m_TextLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TextContentCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_TextContentCtrl->SetToolTip( _("Enter the text placed on selected layer.") );
m_TextContentCtrl->SetMinSize( wxSize( 400,60 ) );
bSizer9->Add( m_TextContentCtrl, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bMainSizer->Add( bSizer9, 1, wxALL|wxEXPAND, 5 );
wxFlexGridSizer* fgSizerSetup;
fgSizerSetup = new wxFlexGridSizer( 0, 4, 0, 0 );
fgSizerSetup->AddGrowableCol( 0 );
fgSizerSetup->AddGrowableCol( 1 );
fgSizerSetup->AddGrowableCol( 2 );
fgSizerSetup->AddGrowableCol( 3 );
fgSizerSetup->SetFlexibleDirection( wxBOTH );
fgSizerSetup->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_SizeXLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeXLabel->Wrap( -1 );
fgSizerSetup->Add( m_SizeXLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
m_PositionXLabel = new wxStaticText( this, wxID_ANY, _("Position X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_PositionXLabel->Wrap( -1 );
fgSizerSetup->Add( m_PositionXLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
m_LayerLabel = new wxStaticText( this, wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 );
m_LayerLabel->Wrap( -1 );
fgSizerSetup->Add( m_LayerLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
m_staticText10 = new wxStaticText( this, wxID_ANY, _("Display:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText10->Wrap( -1 );
fgSizerSetup->Add( m_staticText10, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
m_SizeXCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_SizeXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_PositionXCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_PositionXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_LayerSelectionCtrl = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
fgSizerSetup->Add( m_LayerSelectionCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
wxString m_DisplayCtrlChoices[] = { _("Normal"), _("Mirrored") };
int m_DisplayCtrlNChoices = sizeof( m_DisplayCtrlChoices ) / sizeof( wxString );
m_DisplayCtrl = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_DisplayCtrlNChoices, m_DisplayCtrlChoices, 0 );
m_DisplayCtrl->SetSelection( 0 );
fgSizerSetup->Add( m_DisplayCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_SizeYLabel = new wxStaticText( this, wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeYLabel->Wrap( -1 );
fgSizerSetup->Add( m_SizeYLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
m_PositionYLabel = new wxStaticText( this, wxID_ANY, _("Position Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_PositionYLabel->Wrap( -1 );
fgSizerSetup->Add( m_PositionYLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
m_staticText9 = new wxStaticText( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText9->Wrap( -1 );
fgSizerSetup->Add( m_staticText9, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
m_staticText11 = new wxStaticText( this, wxID_ANY, _("Justification:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText11->Wrap( -1 );
fgSizerSetup->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
m_SizeYCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_SizeYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_PositionYCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_PositionYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
wxString m_StyleCtrlChoices[] = { _("Normal"), _("Italic") };
int m_StyleCtrlNChoices = sizeof( m_StyleCtrlChoices ) / sizeof( wxString );
m_StyleCtrl = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_StyleCtrlNChoices, m_StyleCtrlChoices, 0 );
m_StyleCtrl->SetSelection( 0 );
fgSizerSetup->Add( m_StyleCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
wxString m_justifyChoiceChoices[] = { _("Left"), _("Center"), _("Right") };
int m_justifyChoiceNChoices = sizeof( m_justifyChoiceChoices ) / sizeof( wxString );
m_justifyChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_justifyChoiceNChoices, m_justifyChoiceChoices, 0 );
m_justifyChoice->SetSelection( 0 );
fgSizerSetup->Add( m_justifyChoice, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_ThicknessLabel = new wxStaticText( this, wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_ThicknessLabel->Wrap( -1 );
fgSizerSetup->Add( m_ThicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
m_orientationLabel = new wxStaticText( this, wxID_ANY, _("Orientation (deg):"), wxDefaultPosition, wxDefaultSize, 0 );
m_orientationLabel->Wrap( -1 );
fgSizerSetup->Add( m_orientationLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 3 );
fgSizerSetup->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizerSetup->Add( 0, 0, 1, wxEXPAND, 5 );
m_ThicknessCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_ThicknessCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_OrientCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_OrientCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
fgSizerSetup->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizerSetup->Add( 0, 0, 1, wxEXPAND, 5 );
bMainSizer->Add( fgSizerSetup, 0, wxALL|wxEXPAND, 5 );
m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline, 0, wxEXPAND, 5 );
m_StandardSizer = new wxStdDialogButtonSizer();
m_StandardSizerOK = new wxButton( this, wxID_OK );
m_StandardSizer->AddButton( m_StandardSizerOK );
m_StandardSizerCancel = new wxButton( this, wxID_CANCEL );
m_StandardSizer->AddButton( m_StandardSizerCancel );
m_StandardSizer->Realize();
bMainSizer->Add( m_StandardSizer, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PCB_TEXT_PROPERTIES_BASE::OnInitDlg ) );
}
DIALOG_PCB_TEXT_PROPERTIES_BASE::~DIALOG_PCB_TEXT_PROPERTIES_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PCB_TEXT_PROPERTIES_BASE::OnInitDlg ) );
}

View File

@ -1,82 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_PCB_TEXT_PROPERTIES_BASE_H__
#define __DIALOG_PCB_TEXT_PROPERTIES_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
class PCB_LAYER_BOX_SELECTOR;
class TEXT_CTRL_EVAL;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/bmpcbox.h>
#include <wx/choice.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_PCB_TEXT_PROPERTIES_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_PCB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_TextLabel;
wxTextCtrl* m_TextContentCtrl;
wxStaticText* m_SizeXLabel;
wxStaticText* m_PositionXLabel;
wxStaticText* m_LayerLabel;
wxStaticText* m_staticText10;
TEXT_CTRL_EVAL* m_SizeXCtrl;
TEXT_CTRL_EVAL* m_PositionXCtrl;
PCB_LAYER_BOX_SELECTOR* m_LayerSelectionCtrl;
wxChoice* m_DisplayCtrl;
wxStaticText* m_SizeYLabel;
wxStaticText* m_PositionYLabel;
wxStaticText* m_staticText9;
wxStaticText* m_staticText11;
TEXT_CTRL_EVAL* m_SizeYCtrl;
TEXT_CTRL_EVAL* m_PositionYCtrl;
wxChoice* m_StyleCtrl;
wxChoice* m_justifyChoice;
wxStaticText* m_ThicknessLabel;
wxStaticText* m_orientationLabel;
TEXT_CTRL_EVAL* m_ThicknessCtrl;
TEXT_CTRL_EVAL* m_OrientCtrl;
wxStaticLine* m_staticline;
wxStdDialogButtonSizer* m_StandardSizer;
wxButton* m_StandardSizerOK;
wxButton* m_StandardSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
public:
DIALOG_PCB_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU );
~DIALOG_PCB_TEXT_PROPERTIES_BASE();
};
#endif //__DIALOG_PCB_TEXT_PROPERTIES_BASE_H__

View File

@ -0,0 +1,332 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 2010-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* 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 <fctsys.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <pcbnew.h>
#include <pcb_edit_frame.h>
#include <draw_graphic_text.h>
#include <confirm.h>
#include <wx/valnum.h>
#include <pcb_layer_box_selector.h>
#include <board_commit.h>
#include <widgets/unit_binder.h>
#include <class_board.h>
#include <class_pcb_text.h>
#include <class_text_mod.h>
#include <class_module.h>
#include <class_dimension.h>
#include <dialog_text_properties.h>
/**
* DIALOG_PCB_TEXT_PROPERTIES, derived from DIALOG_PCB_TEXT_PROPERTIES_BASE
* @see dialog_dialog_pcb_text_properties_base.h and
* dialog_dialog_pcb_text_properties_base.cpp, automatically created by
* wxFormBuilder.
*/
DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BOARD_ITEM* aItem,
wxDC* aDC ) :
DIALOG_TEXT_PROPERTIES_BASE( aParent ),
m_Parent( aParent ), m_DC( aDC ), m_item( aItem ),
m_textWidth( aParent, m_SizeXLabel, m_SizeXCtrl, m_SizeXUnits, true, TEXTS_MIN_SIZE ),
m_textHeight( aParent, m_SizeYLabel, m_SizeYCtrl, m_SizeYUnits, true, TEXTS_MIN_SIZE ),
m_thickness( aParent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnits, true, 0 ),
m_posX( aParent, m_PositionXLabel, m_PositionXCtrl, m_PositionXUnits ),
m_posY( aParent, m_PositionYLabel, m_PositionYCtrl, m_PositionYUnits ),
m_OrientValidator( 1, &m_OrientValue )
{
wxString title, label;
bool multiLine = false;
if( m_item->Type() == PCB_DIMENSION_T )
{
title = _( "Dimension Text Properties" );
DIMENSION* dimension = (DIMENSION*) m_item;
m_edaText = &dimension->Text();
m_pcbText = &dimension->Text();
label = _( "Dimension text:" );
m_KeepUpright->Show( false );
}
else if( m_item->Type() == PCB_MODULE_TEXT_T )
{
title = _( "Footprint Text Properties" );
m_modText = (TEXTE_MODULE*) m_item;
m_edaText = static_cast<EDA_TEXT*>( m_modText );
switch( m_modText->GetType() )
{
case TEXTE_MODULE::TEXT_is_REFERENCE: label = _( "Reference:" ); break;
case TEXTE_MODULE::TEXT_is_VALUE: label = _( "Value:" ); break;
case TEXTE_MODULE::TEXT_is_DIVERS: label = _( "Text:" ); break;
}
}
else
{
title = _( "Text Properties" );
m_pcbText = (TEXTE_PCB*) aItem;
m_edaText = static_cast<EDA_TEXT*>( m_pcbText );
multiLine = true;
m_KeepUpright->Show( false );
}
SetTitle( title );
m_hash_key = title;
m_TextLabel->SetLabel( label );
m_SingleLineSizer->Show( !multiLine );
m_MultiLineSizer->Show( multiLine );
SetInitialFocus( multiLine ? m_MultiLineText : m_SingleLineText );
// 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.
if( !m_Parent->GetBoard()->IsLayerEnabled( m_item->GetLayer() ) )
m_LayerSelectionCtrl->ShowNonActivatedLayers( true );
m_LayerSelectionCtrl->SetLayersHotkeys( false );
m_LayerSelectionCtrl->SetNotAllowedLayerSet( LSET::ForbiddenTextLayers() );
m_LayerSelectionCtrl->SetBoardFrame( m_Parent );
m_LayerSelectionCtrl->Resync();
m_OrientValue = 0.0;
m_OrientValidator.SetRange( -360.0, 360.0 );
m_OrientCtrl->SetValidator( m_OrientValidator );
m_OrientValidator.SetWindow( m_OrientCtrl );
m_sdbSizerOK->SetDefault();
// 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.
m_MultiLineText->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_TEXT_PROPERTIES::OnCharHook ), NULL, this );
FinishDialogSettings();
}
DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES()
{
m_MultiLineText->Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_TEXT_PROPERTIES::OnCharHook ), NULL, this );
}
/**
* Routine for main window class to launch text properties dialog.
*/
void PCB_BASE_EDIT_FRAME::InstallTextOptionsFrame( BOARD_ITEM* aText, wxDC* aDC )
{
m_canvas->SetIgnoreMouseEvents( true );
#ifndef __WXMAC__
DIALOG_TEXT_PROPERTIES dlg( this, aText, aDC );
#else
// Avoid "writes" in the dialog, creates errors with WxOverlay and NSView
// Raising an Exception - Fixes #891347
DIALOG_TEXT_PROPERTIES dlg( this, aText, NULL );
#endif
dlg.ShowModal();
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false );
}
void DIALOG_TEXT_PROPERTIES::OnCharHook( wxKeyEvent& aEvent )
{
if( aEvent.GetKeyCode() == WXK_TAB )
{
int flags = 0;
if( !aEvent.ShiftDown() )
flags |= wxNavigationKeyEvent::IsForward;
if( aEvent.ControlDown() )
flags |= wxNavigationKeyEvent::WinChange;
NavigateIn( flags );
}
else if( aEvent.GetKeyCode() == WXK_RETURN && aEvent.ShiftDown() )
{
TransferDataFromWindow();
EndModal( wxID_OK );
}
else
{
aEvent.Skip();
}
}
bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
{
wxString msg1, msg2;
if( m_SingleLineText->IsShown() )
{
m_SingleLineText->SetValue( m_edaText->GetText() );
m_SingleLineText->SetSelection( -1, -1 );
}
else
{
m_MultiLineText->SetValue( m_edaText->GetText() );
m_MultiLineText->SetSelection( -1, -1 );
}
if( m_item->Type() == PCB_MODULE_TEXT_T )
{
MODULE* module = dynamic_cast<MODULE*>( m_modText->GetParent() );
if( module )
{
wxString side = module->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" );
msg1.Printf( _("Footprint %s (%s),"), module->GetReference(), module->GetValue() );
msg2.Printf( _("%s, rotated %.1f deg"), side, module->GetOrientation() / 10.0 );
}
}
m_statusLine1->SetLabel( msg1 );
m_statusLine2->SetLabel( msg2 );
m_LayerSelectionCtrl->SetLayerSelection( m_item->GetLayer() );
m_textWidth.SetValue( m_edaText->GetTextSize().x );
m_textHeight.SetValue( m_edaText->GetTextSize().y );
m_thickness.SetValue( m_edaText->GetThickness() );
m_posX.SetValue( m_edaText->GetTextPos().x );
m_posY.SetValue( m_edaText->GetTextPos().y );
m_Visible->SetValue( m_edaText->IsVisible() );
m_Italic->SetValue( m_edaText->IsItalic() );
EDA_TEXT_HJUSTIFY_T hJustify = m_edaText->GetHorizJustify();
m_JustifyChoice->SetSelection( (int) hJustify + 1 );
m_OrientValue = m_edaText->GetTextAngleDegrees();
m_Mirrored->SetValue( m_edaText->IsMirrored() );
if( m_modText )
m_KeepUpright->SetValue( !m_modText->IsUnlocked() );
return DIALOG_TEXT_PROPERTIES_BASE::TransferDataToWindow();
}
bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
{
if( !DIALOG_TEXT_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
// Test for acceptable layer.
// Incorrect layer can happen for old boards, having texts on edge cut layer for instance
if( m_LayerSelectionCtrl->GetLayerSelection() < 0 )
{
wxMessageBox( _( "No layer selected, Please select the text layer" ) );
return false;
}
if( !m_textWidth.Validate( true ) || !m_textHeight.Validate( true ) )
return false;
if( !m_thickness.Validate( true ) )
return false;
BOARD_COMMIT commit( m_Parent );
commit.Modify( m_item );
// If no other command in progress, prepare undo command
// (for a command in progress, will be made later, at the completion of command)
bool pushCommit = ( m_item->GetFlags() == 0 );
/* set flag in edit to force undo/redo/abort proper operation,
* and avoid new calls to SaveCopyInUndoList for the same text
* this can occurs when a text is moved, and then rotated, edited ..
*/
if( m_item->GetFlags() != 0 )
m_item->SetFlags( IN_EDIT );
#ifndef USE_WX_OVERLAY
// Erase old text on screen if context is available
if( m_DC )
{
m_item->Draw( m_Parent->GetCanvas(), m_DC, GR_XOR );
}
#endif
// Set the new text content
if( m_SingleLineText->IsShown() && !m_SingleLineText->GetValue().IsEmpty() )
m_edaText->SetText( m_SingleLineText->GetValue() );
else if( m_MultiLineText->IsShown() && !m_MultiLineText->GetValue().IsEmpty() )
m_edaText->SetText( m_MultiLineText->GetValue() );
m_item->SetLayer( ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() ) );
m_edaText->SetTextSize( wxSize( m_textWidth.GetValue(), m_textHeight.GetValue() ) );
m_edaText->SetThickness( m_thickness.GetValue() );
m_edaText->SetTextPos( wxPoint( m_posX.GetValue(), m_posY.GetValue() ) );
// Test for acceptable values for thickness and size and clamp if fails
int maxthickness = Clamp_Text_PenSize( m_edaText->GetThickness(), m_edaText->GetTextSize() );
if( m_edaText->GetThickness() > maxthickness )
{
DisplayError( NULL, _( "The text thickness is too large for the text size.\n"
"It will be clamped." ) );
m_edaText->SetThickness( maxthickness );
}
m_edaText->SetVisible( m_Visible->GetValue() );
m_edaText->SetItalic( m_Italic->GetValue() );
m_edaText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) );
m_edaText->SetMirrored( m_Mirrored->GetValue() );
if( m_modText )
m_modText->SetUnlocked( !m_KeepUpright->GetValue() );
switch( m_JustifyChoice->GetSelection() )
{
case 0: m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); break;
case 1: m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); break;
case 2: m_edaText->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); break;
default: break;
}
#ifndef USE_WX_OVERLAY
// Finally, display new text if there is a context to do so
if( m_DC )
{
m_item->Draw( m_Parent->GetCanvas(), m_DC, GR_OR );
}
#else
m_Parent->Refresh();
#endif
if( pushCommit )
commit.Push( _( "Change text properties" ) );
return true;
}

View File

@ -0,0 +1,67 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* 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
*/
#ifndef KICAD_DIALOG_TEXT_PROPERTIES_H
#define KICAD_DIALOG_TEXT_PROPERTIES_H
#include <widgets/unit_binder.h>
#include <wx/valnum.h>
#include <dialog_text_properties_base.h>
class PCB_BASE_EDIT_FRAME;
class BOARD_ITEM;
class DIALOG_TEXT_PROPERTIES : public DIALOG_TEXT_PROPERTIES_BASE
{
public:
DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BOARD_ITEM* aItem, wxDC* aDC = nullptr );
~DIALOG_TEXT_PROPERTIES();
private:
PCB_BASE_EDIT_FRAME* m_Parent;
wxDC* m_DC;
BOARD_ITEM* m_item; // TEXTE_MODULE, TEXTE_PCB, or DIMENSION
EDA_TEXT* m_edaText; // always non-null
TEXTE_MODULE* m_modText; // only non-null for TEXTE_MODULEs
TEXTE_PCB* m_pcbText; // only non-null for TEXTE_PCBs and DIMENSIONs
UNIT_BINDER m_textWidth;
UNIT_BINDER m_textHeight;
UNIT_BINDER m_thickness;
UNIT_BINDER m_posX;
UNIT_BINDER m_posY;
wxFloatingPointValidator<double> m_OrientValidator;
double m_OrientValue;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
void OnCharHook( wxKeyEvent& aEvent );
};
#endif //KICAD_DIALOG_TEXT_PROPERTIES_H

View File

@ -0,0 +1,237 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "pcb_layer_box_selector.h"
#include "dialog_text_properties_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
m_MultiLineSizer = new wxBoxSizer( wxVERTICAL );
wxStaticText* textLabel;
textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 );
textLabel->Wrap( -1 );
m_MultiLineSizer->Add( textLabel, 0, wxRIGHT|wxLEFT, 5 );
m_MultiLineText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_MultiLineText->SetToolTip( _("Enter the text placed on selected layer.") );
m_MultiLineText->SetMinSize( wxSize( 400,60 ) );
m_MultiLineSizer->Add( m_MultiLineText, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bMainSizer->Add( m_MultiLineSizer, 20, wxEXPAND|wxALL, 10 );
m_SingleLineSizer = new wxBoxSizer( wxHORIZONTAL );
m_TextLabel = new wxStaticText( this, wxID_ANY, _("Reference:"), wxDefaultPosition, wxDefaultSize, 0 );
m_TextLabel->Wrap( -1 );
m_SingleLineSizer->Add( m_TextLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_SingleLineText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_SingleLineSizer->Add( m_SingleLineText, 1, wxTOP|wxBOTTOM|wxRIGHT, 5 );
bMainSizer->Add( m_SingleLineSizer, 0, wxEXPAND|wxALL, 10 );
wxFlexGridSizer* fgSizerSetup;
fgSizerSetup = new wxFlexGridSizer( 0, 5, 4, 0 );
fgSizerSetup->AddGrowableCol( 1 );
fgSizerSetup->AddGrowableCol( 4 );
fgSizerSetup->SetFlexibleDirection( wxBOTH );
fgSizerSetup->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_LayerLabel = new wxStaticText( this, wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 );
m_LayerLabel->Wrap( -1 );
fgSizerSetup->Add( m_LayerLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
m_LayerSelectionCtrl = new PCB_LAYER_BOX_SELECTOR( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
fgSizerSetup->Add( m_LayerSelectionCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
fgSizerSetup->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 40 );
m_Visible = new wxCheckBox( this, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_Visible, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
fgSizerSetup->Add( 0, 0, 1, wxEXPAND, 5 );
m_SizeXLabel = new wxStaticText( this, wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeXLabel->Wrap( -1 );
fgSizerSetup->Add( m_SizeXLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_SizeXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_SizeXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_SizeXUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeXUnits->Wrap( -1 );
fgSizerSetup->Add( m_SizeXUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_Italic = new wxCheckBox( this, wxID_ANY, _("Italic"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_Italic, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
fgSizerSetup->Add( 0, 0, 1, wxEXPAND, 5 );
m_SizeYLabel = new wxStaticText( this, wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeYLabel->Wrap( -1 );
fgSizerSetup->Add( m_SizeYLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_SizeYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_SizeYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_SizeYUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_SizeYUnits->Wrap( -1 );
fgSizerSetup->Add( m_SizeYUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_staticText11 = new wxStaticText( this, wxID_ANY, _("Justification:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText11->Wrap( -1 );
fgSizerSetup->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
wxString m_JustifyChoiceChoices[] = { _("Left"), _("Center"), _("Right") };
int m_JustifyChoiceNChoices = sizeof( m_JustifyChoiceChoices ) / sizeof( wxString );
m_JustifyChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_JustifyChoiceNChoices, m_JustifyChoiceChoices, 0 );
m_JustifyChoice->SetSelection( 0 );
fgSizerSetup->Add( m_JustifyChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 3 );
m_ThicknessLabel = new wxStaticText( this, wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_ThicknessLabel->Wrap( -1 );
fgSizerSetup->Add( m_ThicknessLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_ThicknessCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_ThicknessCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM, 2 );
m_ThicknessUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_ThicknessUnits->Wrap( -1 );
fgSizerSetup->Add( m_ThicknessUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_OrientLabel = new wxStaticText( this, wxID_ANY, _("Orientation:"), wxDefaultPosition, wxDefaultSize, 0 );
m_OrientLabel->Wrap( -1 );
fgSizerSetup->Add( m_OrientLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_OrientCtrl = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_OrientCtrl->Append( _("0") );
m_OrientCtrl->Append( _("90") );
m_OrientCtrl->Append( _("-90") );
m_OrientCtrl->Append( _("180") );
fgSizerSetup->Add( m_OrientCtrl, 0, wxEXPAND, 5 );
m_PositionXLabel = new wxStaticText( this, wxID_ANY, _("Position X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_PositionXLabel->Wrap( -1 );
fgSizerSetup->Add( m_PositionXLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_PositionXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_PositionXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_PositionXUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_PositionXUnits->Wrap( -1 );
fgSizerSetup->Add( m_PositionXUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_Mirrored = new wxCheckBox( this, wxID_ANY, _("Mirrored"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_Mirrored, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizerSetup->Add( 0, 0, 1, wxEXPAND, 5 );
m_PositionYLabel = new wxStaticText( this, wxID_ANY, _("Position Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_PositionYLabel->Wrap( -1 );
fgSizerSetup->Add( m_PositionYLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_PositionYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_PositionYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
m_PositionYUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
m_PositionYUnits->Wrap( -1 );
fgSizerSetup->Add( m_PositionYUnits, 0, wxRIGHT|wxLEFT, 5 );
m_KeepUpright = new wxCheckBox( this, wxID_ANY, _("Keep Upright"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizerSetup->Add( m_KeepUpright, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
bMainSizer->Add( fgSizerSetup, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 );
bMainSizer->Add( 0, 0, 1, wxEXPAND|wxTOP, 5 );
m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
wxBoxSizer* lowerSizer;
lowerSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxVERTICAL );
m_statusLine1 = new wxStaticText( this, wxID_ANY, _("Status line 1"), wxDefaultPosition, wxDefaultSize, 0 );
m_statusLine1->Wrap( -1 );
m_statusLine1->SetFont( wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
bSizer7->Add( m_statusLine1, 0, wxBOTTOM|wxRIGHT|wxLEFT, 2 );
m_statusLine2 = new wxStaticText( this, wxID_ANY, _("Status line 2"), wxDefaultPosition, wxDefaultSize, 0 );
m_statusLine2->Wrap( -1 );
m_statusLine2->SetFont( wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
bSizer7->Add( m_statusLine2, 0, wxRIGHT|wxLEFT, 2 );
lowerSizer->Add( bSizer7, 0, wxEXPAND|wxTOP|wxLEFT, 8 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
lowerSizer->Add( m_sdbSizer, 1, wxEXPAND|wxALL, 5 );
bMainSizer->Add( lowerSizer, 0, wxALIGN_BOTTOM|wxEXPAND|wxLEFT, 5 );
this->SetSizer( bMainSizer );
this->Layout();
bMainSizer->Fit( this );
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnInitDlg ) );
m_SingleLineText->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_SizeXCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_SizeYCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_ThicknessCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_OrientCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_PositionXCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_PositionYCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
}
DIALOG_TEXT_PROPERTIES_BASE::~DIALOG_TEXT_PROPERTIES_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnInitDlg ) );
m_SingleLineText->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_SizeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_SizeYCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_ThicknessCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_OrientCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_PositionXCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_PositionYCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
}

View File

@ -0,0 +1,93 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_TEXT_PROPERTIES_BASE_H__
#define __DIALOG_TEXT_PROPERTIES_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class PCB_LAYER_BOX_SELECTOR;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/bmpcbox.h>
#include <wx/checkbox.h>
#include <wx/choice.h>
#include <wx/combobox.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_TEXT_PROPERTIES_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM
{
private:
protected:
wxBoxSizer* m_MultiLineSizer;
wxTextCtrl* m_MultiLineText;
wxBoxSizer* m_SingleLineSizer;
wxStaticText* m_TextLabel;
wxTextCtrl* m_SingleLineText;
wxStaticText* m_LayerLabel;
PCB_LAYER_BOX_SELECTOR* m_LayerSelectionCtrl;
wxCheckBox* m_Visible;
wxStaticText* m_SizeXLabel;
wxTextCtrl* m_SizeXCtrl;
wxStaticText* m_SizeXUnits;
wxCheckBox* m_Italic;
wxStaticText* m_SizeYLabel;
wxTextCtrl* m_SizeYCtrl;
wxStaticText* m_SizeYUnits;
wxStaticText* m_staticText11;
wxChoice* m_JustifyChoice;
wxStaticText* m_ThicknessLabel;
wxTextCtrl* m_ThicknessCtrl;
wxStaticText* m_ThicknessUnits;
wxStaticText* m_OrientLabel;
wxComboBox* m_OrientCtrl;
wxStaticText* m_PositionXLabel;
wxTextCtrl* m_PositionXCtrl;
wxStaticText* m_PositionXUnits;
wxCheckBox* m_Mirrored;
wxStaticText* m_PositionYLabel;
wxTextCtrl* m_PositionYCtrl;
wxStaticText* m_PositionYUnits;
wxCheckBox* m_KeepUpright;
wxStaticLine* m_staticline;
wxStaticText* m_statusLine1;
wxStaticText* m_statusLine2;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU );
~DIALOG_TEXT_PROPERTIES_BASE();
};
#endif //__DIALOG_TEXT_PROPERTIES_BASE_H__

View File

@ -38,15 +38,14 @@
#include <macros.h> #include <macros.h>
#include <base_units.h> #include <base_units.h>
#include <board_commit.h> #include <board_commit.h>
#include <widgets/text_ctrl_eval.h>
#include <class_board.h> #include <class_board.h>
#include <class_pcb_text.h> #include <class_pcb_text.h>
#include <class_dimension.h> #include <class_dimension.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <dialog_dimension_editor_base.h>
#include <pcb_layer_box_selector.h> #include <pcb_layer_box_selector.h>
#include <dialogs/dialog_text_properties.h>
/* Local functions */ /* Local functions */
static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC, static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
@ -73,168 +72,6 @@ static int status_dimension; /* Used in dimension creation:
* *
*/ */
/*********************************/
/* class DIALOG_DIMENSION_EDITOR */
/*********************************/
class DIALOG_DIMENSION_EDITOR : public DIALOG_DIMENSION_EDITOR_BASE
{
private:
PCB_EDIT_FRAME* m_parent;
wxDC* m_DC;
DIMENSION* m_currentDimension;
public:
// Constructor and destructor
DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent, DIMENSION* aDimension, wxDC* aDC );
~DIALOG_DIMENSION_EDITOR()
{
}
private:
virtual void OnOKClick( wxCommandEvent& event ) override;
};
DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
DIMENSION* aDimension, wxDC* aDC ) :
DIALOG_DIMENSION_EDITOR_BASE( aParent )
{
SetFocus();
m_parent = aParent;
m_DC = aDC;
m_currentDimension = aDimension;
if( aDimension->Text().IsMirrored() )
m_rbMirror->SetSelection( 1 );
else
m_rbMirror->SetSelection( 0 );
m_Name->SetValue( aDimension->Text().GetText() );
// Enter size value in dialog
PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->Text().GetTextWidth() );
AddUnitSymbol( *m_staticTextSizeX );
PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->Text().GetTextHeight() );
AddUnitSymbol( *m_staticTextSizeY );
// Enter lines thickness value in dialog
PutValueInLocalUnits( *m_TxtWidthCtrl, aDimension->GetWidth() );
AddUnitSymbol( *m_staticTextWidth );
// Enter position value in dialog
PutValueInLocalUnits( *m_textCtrlPosX, aDimension->Text().GetTextPos().x );
AddUnitSymbol( *m_staticTextPosX );
PutValueInLocalUnits( *m_textCtrlPosY, aDimension->Text().GetTextPos().y );
AddUnitSymbol( *m_staticTextPosY );
// Configure the layers list selector
if( !m_parent->GetBoard()->IsLayerEnabled( aDimension->GetLayer() ) )
// Should not happens, because one cannot select a board item on a
// not activated layer, but ...
m_SelLayerBox->ShowNonActivatedLayers( true );
m_SelLayerBox->SetLayersHotkeys( false );
m_SelLayerBox->SetNotAllowedLayerSet( LSET::AllCuMask().set( Edge_Cuts ) );
m_SelLayerBox->SetBoardFrame( m_parent );
m_SelLayerBox->Resync();
if( m_SelLayerBox->SetLayerSelection( aDimension->GetLayer() ) < 0 )
{
wxMessageBox( _( "This item has an illegal layer id.\n"
"Now, forced on the drawings layer. Please, fix it" ) );
m_SelLayerBox->SetLayerSelection( Dwgs_User );
}
m_sdbSizerBtsOK->SetDefault();
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
}
void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
{
BOARD_COMMIT commit( m_parent );
PCB_LAYER_ID newlayer = ToLAYER_ID( m_SelLayerBox->GetLayerSelection() );
if( !m_parent->GetBoard()->IsLayerEnabled( newlayer ) )
{
wxMessageBox( _( "The layer currently selected is not enabled for this board\n"
"You cannot use it" ) );
return;
}
#ifndef USE_WX_OVERLAY
if( m_DC ) // Delete old text.
{
m_currentDimension->Draw( m_parent->GetCanvas(), m_DC, GR_XOR );
}
#endif
commit.Modify( m_currentDimension );
if( m_Name->GetValue() != wxEmptyString )
{
m_currentDimension->SetText( m_Name->GetValue() );
}
wxString msg;
// Get new size value:
msg = m_TxtSizeXCtrl->GetValue();
m_currentDimension->Text().SetTextWidth( ValueFromString( g_UserUnit, msg ) );
msg = m_TxtSizeYCtrl->GetValue();
m_currentDimension->Text().SetTextHeight( ValueFromString( g_UserUnit, msg ) );
// Get new position value:
// It will be copied later in dimension, because
msg = m_textCtrlPosX->GetValue();
wxPoint pos;
pos.x = ValueFromString( g_UserUnit, msg );
msg = m_textCtrlPosY->GetValue();
pos.y = ValueFromString( g_UserUnit, msg );
m_currentDimension->Text().SetTextPos( pos );
// Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue();
int width = ValueFromString( g_UserUnit, msg );
int maxthickness = Clamp_Text_PenSize( width, m_currentDimension->Text().GetTextSize() );
if( width > maxthickness )
{
DisplayError( NULL,
_( "The text thickness is too large for the text size. "
"It will be clamped" ) );
width = maxthickness;
}
m_currentDimension->SetWidth( width );
m_currentDimension->Text().SetThickness( width );
m_currentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
m_currentDimension->SetLayer( newlayer );
#ifndef USE_WX_OVERLAY
if( m_DC ) // Display new text
{
m_currentDimension->Draw( m_parent->GetCanvas(), m_DC, GR_OR );
}
#else
m_parent->Refresh();
#endif
commit.Push( _( "Modified dimensions properties" ) );
event.Skip(); // ends returning wxID_OK (default behavior)
}
static void AbortBuildDimension( EDA_DRAW_PANEL* Panel, wxDC* aDC ) static void AbortBuildDimension( EDA_DRAW_PANEL* Panel, wxDC* aDC )
{ {
DIMENSION* dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem(); DIMENSION* dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem();
@ -356,7 +193,7 @@ void PCB_EDIT_FRAME::ShowDimensionPropertyDialog( DIMENSION* aDimension, wxDC* a
if( aDimension == NULL ) if( aDimension == NULL )
return; return;
DIALOG_DIMENSION_EDITOR dlg( this, aDimension, aDC ); DIALOG_TEXT_PROPERTIES dlg( this, aDimension, aDC );
dlg.ShowModal(); dlg.ShowModal();
} }

View File

@ -980,8 +980,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_EDIT_TEXTMODULE: case ID_POPUP_PCB_EDIT_TEXTMODULE:
InstallTextModOptionsFrame( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc ); InstallTextOptionsFrame( GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair();
break; break;
case ID_POPUP_PCB_RESET_TEXT_SIZE: case ID_POPUP_PCB_RESET_TEXT_SIZE:
@ -1060,8 +1059,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_EDIT_TEXTEPCB: case ID_POPUP_PCB_EDIT_TEXTEPCB:
InstallTextPCBOptionsFrame( (TEXTE_PCB*) GetCurItem(), &dc ); InstallTextOptionsFrame( GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair();
break; break;
case ID_POPUP_PCB_ROTATE_TEXTEPCB: case ID_POPUP_PCB_ROTATE_TEXTEPCB:

View File

@ -218,7 +218,7 @@ TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText )
textePcb->SetTextPos( GetCrossHairPosition() ); textePcb->SetTextPos( GetCrossHairPosition() );
textePcb->SetThickness( GetBoard()->GetDesignSettings().m_PcbTextWidth ); textePcb->SetThickness( GetBoard()->GetDesignSettings().m_PcbTextWidth );
InstallTextPCBOptionsFrame( textePcb, aDC ); InstallTextOptionsFrame( textePcb, aDC );
if( textePcb->GetText().IsEmpty() ) if( textePcb->GetText().IsEmpty() )
{ {

View File

@ -79,9 +79,7 @@ TEXTE_MODULE* FOOTPRINT_EDIT_FRAME::CreateTextModule( MODULE* aModule, wxDC* aDC
if( LSET::AllTechMask().test( GetActiveLayer() ) ) // i.e. a possible layer for a text if( LSET::AllTechMask().test( GetActiveLayer() ) ) // i.e. a possible layer for a text
text->SetLayer( GetActiveLayer() ); text->SetLayer( GetActiveLayer() );
InstallTextModOptionsFrame( text, NULL ); InstallTextOptionsFrame( text, NULL );
m_canvas->MoveCursorToCrossHair();
if( text->GetText().IsEmpty() ) if( text->GetText().IsEmpty() )
{ {

View File

@ -543,8 +543,7 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem )
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
InstallTextModOptionsFrame( static_cast<TEXTE_MODULE*>( aItem ), aDC ); InstallTextOptionsFrame( aItem, aDC );
m_canvas->MoveCursorToCrossHair();
break; break;
case PCB_MODULE_EDGE_T : case PCB_MODULE_EDGE_T :

View File

@ -675,8 +675,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_EDIT_TEXTMODULE: case ID_POPUP_PCB_EDIT_TEXTMODULE:
InstallTextModOptionsFrame( static_cast<TEXTE_MODULE*>( GetScreen()->GetCurItem() ), &dc ); InstallTextOptionsFrame( GetScreen()->GetCurItem(), &dc );
m_canvas->MoveCursorToCrossHair();
break; break;
case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST: case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST:

View File

@ -585,7 +585,7 @@ void PCB_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem )
break; break;
case PCB_TEXT_T: case PCB_TEXT_T:
InstallTextPCBOptionsFrame( static_cast<TEXTE_PCB*>( aItem ), aDC ); InstallTextOptionsFrame( aItem, aDC );
break; break;
case PCB_PAD_T: case PCB_PAD_T:
@ -605,7 +605,7 @@ void PCB_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem )
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
InstallTextModOptionsFrame( static_cast<TEXTE_MODULE*>( aItem ), aDC ); InstallTextOptionsFrame( aItem, aDC );
break; break;
case PCB_LINE_T: case PCB_LINE_T:

View File

@ -158,6 +158,7 @@ public:
*/ */
void SetRotationAngle( int aRotationAngle ); void SetRotationAngle( int aRotationAngle );
void InstallTextOptionsFrame( BOARD_ITEM* aText, wxDC* aDC );
void InstallGraphicItemPropertiesDialog( BOARD_ITEM* aItem, wxDC* aDC ); void InstallGraphicItemPropertiesDialog( BOARD_ITEM* aItem, wxDC* aDC );
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()

View File

@ -1095,7 +1095,6 @@ public:
void Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ); void Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
void StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aErase = true ); void StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aErase = true );
void Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ); void Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
void InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC );
// Graphic Segments type DRAWSEGMENT // Graphic Segments type DRAWSEGMENT
void Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ); void Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC );

View File

@ -32,7 +32,6 @@
#include <id.h> #include <id.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <confirm.h> #include <confirm.h>
#include <dialog_edit_footprint_text.h>
#include <import_dxf/dialog_dxf_import.h> #include <import_dxf/dialog_dxf_import.h>
#include <view/view_group.h> #include <view/view_group.h>
@ -49,7 +48,7 @@
#include <painter.h> #include <painter.h>
#include <status_popup.h> #include <status_popup.h>
#include "grid_helper.h" #include "grid_helper.h"
#include <dialogs/dialog_text_properties.h>
#include <preview_items/arc_assistant.h> #include <preview_items/arc_assistant.h>
#include <class_board.h> #include <class_board.h>
@ -389,7 +388,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
textMod->SetThickness( dsnSettings.m_ModuleTextWidth ); textMod->SetThickness( dsnSettings.m_ModuleTextWidth );
textMod->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) ); textMod->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
DIALOG_EDIT_FPTEXT textDialog( m_frame, m_frame, textMod, NULL ); DIALOG_TEXT_PROPERTIES textDialog( m_frame, textMod, NULL );
bool placing; bool placing;
RunMainStack([&]() { RunMainStack([&]() {
@ -419,7 +418,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
textPcb->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) ); textPcb->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
RunMainStack([&]() { RunMainStack([&]() {
getEditFrame<PCB_EDIT_FRAME>()->InstallTextPCBOptionsFrame( textPcb, NULL ); m_frame->InstallTextOptionsFrame( textPcb, NULL );
} ); } );
if( textPcb->GetText().IsEmpty() ) if( textPcb->GetText().IsEmpty() )