2011-12-08 15:45:01 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-11-18 17:52:18 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
2018-01-28 21:02:31 +00:00
|
|
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-08 15:45:01 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file sch_text.h
|
|
|
|
* @brief Implementation of the label properties dialog.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <wx/valgen.h>
|
2017-03-07 13:32:34 +00:00
|
|
|
#include <wx/valnum.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <general.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <draw_graphic_text.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <sch_text.h>
|
2015-04-03 20:38:24 +00:00
|
|
|
#include <typeinfo>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2012-03-19 20:57:19 +00:00
|
|
|
#include <dialog_edit_label_base.h>
|
|
|
|
|
|
|
|
class SCH_EDIT_FRAME;
|
|
|
|
class SCH_TEXT;
|
|
|
|
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
class DIALOG_LABEL_EDITOR : public DIALOG_LABEL_EDITOR_BASE
|
2012-03-19 20:57:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-09-28 17:47:41 +00:00
|
|
|
DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem );
|
2017-12-28 19:33:15 +00:00
|
|
|
~DIALOG_LABEL_EDITOR();
|
2012-03-19 20:57:19 +00:00
|
|
|
|
2016-09-25 17:06:49 +00:00
|
|
|
void SetTitle( const wxString& aTitle ) override
|
2015-04-03 20:38:24 +00:00
|
|
|
{
|
|
|
|
// This class is shared for numerous tasks: a couple of
|
|
|
|
// single line labels and multi-line text fields.
|
|
|
|
// Often the desired size of the multi-line text field editor
|
|
|
|
// is larger than is needed for the single line label.
|
|
|
|
// Therefore the session retained sizes of these dialogs needs
|
|
|
|
// to be class independent, make them title dependent.
|
|
|
|
switch( m_CurrentText->Type() )
|
|
|
|
{
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
// labels can share retained settings probably.
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
m_hash_key = TO_UTF8( aTitle );
|
|
|
|
m_hash_key += typeid(*this).name();
|
|
|
|
}
|
|
|
|
|
|
|
|
DIALOG_LABEL_EDITOR_BASE::SetTitle( aTitle );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:57:19 +00:00
|
|
|
private:
|
2016-09-24 18:53:15 +00:00
|
|
|
void InitDialog( ) override;
|
|
|
|
virtual void OnEnterKey( wxCommandEvent& aEvent ) override;
|
|
|
|
virtual void OnOkClick( wxCommandEvent& aEvent ) override;
|
|
|
|
virtual void OnCancelClick( wxCommandEvent& aEvent ) override;
|
2017-12-28 19:33:15 +00:00
|
|
|
void OnCharHook( wxKeyEvent& aEvent );
|
2012-03-19 20:57:19 +00:00
|
|
|
void TextPropertiesAccept( wxCommandEvent& aEvent );
|
|
|
|
|
|
|
|
SCH_EDIT_FRAME* m_Parent;
|
|
|
|
SCH_TEXT* m_CurrentText;
|
|
|
|
wxTextCtrl* m_textLabel;
|
|
|
|
};
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-02-10 20:02:51 +00:00
|
|
|
|
2009-12-27 14:01:21 +00:00
|
|
|
/* Edit the properties of the text (Label, Global label, graphic text).. )
|
2010-03-16 18:22:59 +00:00
|
|
|
* pointed by "aTextStruct"
|
2009-12-27 14:01:21 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::EditSchematicText( SCH_TEXT* aTextItem )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
if( aTextItem == NULL )
|
2009-12-27 14:01:21 +00:00
|
|
|
return;
|
2009-02-10 20:02:51 +00:00
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
DIALOG_LABEL_EDITOR dialog( this, aTextItem );
|
2009-02-10 20:02:51 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
dialog.ShowModal();
|
2009-02-10 20:02:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) :
|
|
|
|
DIALOG_LABEL_EDITOR_BASE( aParent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-03-16 18:22:59 +00:00
|
|
|
m_Parent = aParent;
|
|
|
|
m_CurrentText = aTextItem;
|
2009-12-27 14:01:21 +00:00
|
|
|
InitDialog();
|
|
|
|
|
2017-03-14 19:40:21 +00:00
|
|
|
// Conservative limits 0.0 to 10.0 inches
|
|
|
|
const int minSize = 0; // a value like 0.01 is better, but if > 0, creates
|
|
|
|
// annoying issues when trying to enter a value starting by 0 or .0
|
|
|
|
const int maxSize = 10 * 1000 * IU_PER_MILS;
|
2017-03-07 13:32:34 +00:00
|
|
|
|
|
|
|
wxFloatingPointValidator<double> textSizeValidator( NULL, wxNUM_VAL_NO_TRAILING_ZEROES );
|
|
|
|
textSizeValidator.SetPrecision( 4 );
|
|
|
|
textSizeValidator.SetRange( To_User_Unit( g_UserUnit, minSize ),
|
|
|
|
To_User_Unit( g_UserUnit, maxSize ) );
|
|
|
|
|
|
|
|
m_TextSize->SetValidator( textSizeValidator );
|
|
|
|
|
2017-12-28 19:33:15 +00:00
|
|
|
// 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_textLabelMultiLine->Connect( wxEVT_CHAR_HOOK,
|
|
|
|
wxKeyEventHandler( DIALOG_LABEL_EDITOR::OnCharHook ),
|
|
|
|
NULL, this );
|
|
|
|
|
2016-07-16 10:54:55 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2009-02-09 20:27:16 +00:00
|
|
|
|
2017-12-28 19:33:15 +00:00
|
|
|
DIALOG_LABEL_EDITOR::~DIALOG_LABEL_EDITOR()
|
|
|
|
{
|
|
|
|
m_textLabelMultiLine->Disconnect( wxEVT_CHAR_HOOK,
|
|
|
|
wxKeyEventHandler( DIALOG_LABEL_EDITOR::OnCharHook ),
|
|
|
|
NULL, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-04 19:11:12 +00:00
|
|
|
// Sadly we store the orientation of hierarchical and global labels using a different
|
|
|
|
// int encoding than that for local labels:
|
|
|
|
// Global Local
|
|
|
|
// Left justified 0 2
|
|
|
|
// Up 1 3
|
|
|
|
// Right justified 2 0
|
|
|
|
// Down 3 1
|
|
|
|
static int mapOrientation( KICAD_T labelType, int aOrientation )
|
|
|
|
{
|
|
|
|
if( labelType == SCH_LABEL_T )
|
|
|
|
return aOrientation;
|
|
|
|
|
|
|
|
switch( aOrientation )
|
|
|
|
{
|
|
|
|
case 0: return 2;
|
|
|
|
case 2: return 0;
|
|
|
|
default: return aOrientation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
void DIALOG_LABEL_EDITOR::InitDialog()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-02-09 20:27:16 +00:00
|
|
|
wxString msg;
|
2010-03-16 18:22:59 +00:00
|
|
|
bool multiLine = false;
|
2009-11-02 20:36:20 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( m_CurrentText->IsMultilineAllowed() )
|
2009-05-13 10:26:11 +00:00
|
|
|
{
|
2010-03-30 10:10:33 +00:00
|
|
|
m_textLabel = m_textLabelMultiLine;
|
2013-08-13 23:04:41 +00:00
|
|
|
m_textLabelSingleLine->Show( false );
|
2010-03-16 18:22:59 +00:00
|
|
|
multiLine = true;
|
2009-05-13 10:26:11 +00:00
|
|
|
}
|
2010-03-30 10:10:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_textLabel = m_textLabelSingleLine;
|
2013-08-13 23:04:41 +00:00
|
|
|
m_textLabelMultiLine->Show( false );
|
|
|
|
wxTextValidator* validator = (wxTextValidator*) m_textLabel->GetValidator();
|
|
|
|
wxArrayString excludes;
|
|
|
|
|
|
|
|
// Add invalid label characters to this list.
|
|
|
|
excludes.Add( wxT( " " ) );
|
|
|
|
validator->SetExcludes( excludes );
|
2010-03-30 10:10:33 +00:00
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
m_textLabel->SetValue( m_CurrentText->GetText() );
|
2010-03-16 18:22:59 +00:00
|
|
|
m_textLabel->SetFocus();
|
2008-12-19 20:40:08 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
switch( m_CurrentText->Type() )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_GLOBAL_LABEL_T:
|
2009-02-09 20:27:16 +00:00
|
|
|
SetTitle( _( "Global Label Properties" ) );
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
2011-03-25 19:16:05 +00:00
|
|
|
SetTitle( _( "Hierarchical Label Properties" ) );
|
2009-02-09 20:27:16 +00:00
|
|
|
break;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_LABEL_T:
|
2009-02-09 20:27:16 +00:00
|
|
|
SetTitle( _( "Label Properties" ) );
|
|
|
|
break;
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
case SCH_SHEET_PIN_T:
|
2011-03-25 19:16:05 +00:00
|
|
|
SetTitle( _( "Hierarchical Sheet Pin Properties." ) );
|
|
|
|
break;
|
|
|
|
|
2009-02-09 20:27:16 +00:00
|
|
|
default:
|
|
|
|
SetTitle( _( "Text Properties" ) );
|
|
|
|
break;
|
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2013-03-28 06:40:19 +00:00
|
|
|
const int MINTEXTWIDTH = 40; // M's are big characters, a few establish a lot of width
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2010-12-22 14:11:01 +00:00
|
|
|
int max_len = 0;
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2010-12-22 14:11:01 +00:00
|
|
|
if ( !multiLine )
|
2009-02-09 20:27:16 +00:00
|
|
|
{
|
2014-09-13 18:15:45 +00:00
|
|
|
max_len = m_CurrentText->GetText().Length();
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
2009-09-26 17:22:47 +00:00
|
|
|
else
|
|
|
|
{
|
2010-03-16 18:22:59 +00:00
|
|
|
// calculate the length of the biggest line
|
|
|
|
// we cannot use the length of the entire text that has no meaning
|
2010-12-22 14:11:01 +00:00
|
|
|
int curr_len = MINTEXTWIDTH;
|
2013-03-18 19:36:07 +00:00
|
|
|
int imax = m_CurrentText->GetText().Length();
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2009-09-26 17:22:47 +00:00
|
|
|
for( int count = 0; count < imax; count++ )
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
if( m_CurrentText->GetText()[count] == '\n' ||
|
|
|
|
m_CurrentText->GetText()[count] == '\r' ) // new line
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
curr_len = 0;
|
|
|
|
}
|
2009-09-26 17:22:47 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
curr_len++;
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2009-09-26 17:22:47 +00:00
|
|
|
if ( max_len < curr_len )
|
|
|
|
max_len = curr_len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2010-12-22 14:11:01 +00:00
|
|
|
if( max_len < MINTEXTWIDTH )
|
|
|
|
max_len = MINTEXTWIDTH;
|
|
|
|
|
|
|
|
wxString textWidth;
|
|
|
|
textWidth.Append( 'M', MINTEXTWIDTH );
|
|
|
|
EnsureTextCtrlWidth( m_textLabel, &textWidth );
|
2009-02-09 20:27:16 +00:00
|
|
|
|
2017-02-02 15:50:49 +00:00
|
|
|
// Set text options:
|
2018-02-04 19:11:12 +00:00
|
|
|
int orientation = mapOrientation( m_CurrentText->Type(), m_CurrentText->GetLabelSpinStyle() );
|
|
|
|
m_TextOrient->SetSelection( orientation );
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
m_TextShape->SetSelection( m_CurrentText->GetShape() );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
int style = 0;
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( m_CurrentText->IsItalic() )
|
2008-12-19 20:40:08 +00:00
|
|
|
style = 1;
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( m_CurrentText->IsBold() )
|
2008-12-19 20:40:08 +00:00
|
|
|
style += 2;
|
2009-02-09 20:27:16 +00:00
|
|
|
|
|
|
|
m_TextStyle->SetSelection( style );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
wxString units = ReturnUnitSymbol( g_UserUnit, wxT( "(%s)" ) );
|
2013-04-09 17:49:01 +00:00
|
|
|
msg.Printf( _( "H%s x W%s" ), GetChars( units ), GetChars( units ) );
|
2010-03-16 18:22:59 +00:00
|
|
|
m_staticSizeUnits->SetLabel( msg );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
msg = StringFromValue( g_UserUnit, m_CurrentText->GetTextWidth() );
|
2009-02-09 20:27:16 +00:00
|
|
|
m_TextSize->SetValue( msg );
|
2008-12-20 17:28:25 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T
|
|
|
|
&& m_CurrentText->Type() != SCH_HIERARCHICAL_LABEL_T )
|
2009-02-09 20:27:16 +00:00
|
|
|
{
|
|
|
|
m_TextShape->Show( false );
|
|
|
|
}
|
2010-11-18 21:10:52 +00:00
|
|
|
|
|
|
|
m_sdbSizer1OK->SetDefault();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2009-04-28 19:34:42 +00:00
|
|
|
/*!
|
2017-12-28 19:33:15 +00:00
|
|
|
* wxEVT_COMMAND_ENTER event handler for m_textLabel
|
2009-04-28 19:34:42 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
void DIALOG_LABEL_EDITOR::OnEnterKey( wxCommandEvent& aEvent )
|
2009-04-28 19:34:42 +00:00
|
|
|
{
|
2010-03-16 18:22:59 +00:00
|
|
|
TextPropertiesAccept( aEvent );
|
2009-04-28 19:34:42 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2017-12-28 19:33:15 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_CHAR_HOOK event handler for m_textLabel
|
|
|
|
*/
|
|
|
|
|
|
|
|
void DIALOG_LABEL_EDITOR::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() )
|
|
|
|
{
|
|
|
|
wxCommandEvent cmdEvent( wxEVT_COMMAND_ENTER );
|
|
|
|
TextPropertiesAccept( cmdEvent );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
|
|
|
*/
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
void DIALOG_LABEL_EDITOR::OnOkClick( wxCommandEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-03-16 18:22:59 +00:00
|
|
|
TextPropertiesAccept( aEvent );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2009-02-09 20:27:16 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
2007-11-07 04:24:25 +00:00
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
|
2007-05-06 16:03:28 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
void DIALOG_LABEL_EDITOR::OnCancelClick( wxCommandEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_Parent->GetCanvas()->MoveCursorToCrossHair();
|
2009-11-02 20:36:20 +00:00
|
|
|
EndModal( wxID_CANCEL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2009-04-26 17:00:59 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent )
|
2009-12-27 14:01:21 +00:00
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
int value;
|
|
|
|
|
|
|
|
/* save old text in undo list if not already in edit */
|
2013-01-21 20:16:04 +00:00
|
|
|
/* or the label to be edited is part of a block */
|
|
|
|
if( m_CurrentText->GetFlags() == 0 ||
|
|
|
|
m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
2009-12-27 14:01:21 +00:00
|
|
|
m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED );
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );
|
2009-12-27 14:01:21 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
text = m_textLabel->GetValue();
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2009-12-27 14:01:21 +00:00
|
|
|
if( !text.IsEmpty() )
|
2013-03-18 19:36:07 +00:00
|
|
|
m_CurrentText->SetText( text );
|
2011-12-21 13:42:02 +00:00
|
|
|
else if( !m_CurrentText->IsNew() )
|
2012-10-13 18:33:58 +00:00
|
|
|
{
|
2009-12-27 14:01:21 +00:00
|
|
|
DisplayError( this, _( "Empty Text!" ) );
|
2012-10-13 18:33:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-12-27 14:01:21 +00:00
|
|
|
|
2018-02-04 19:11:12 +00:00
|
|
|
int orientation = m_TextOrient->GetSelection();
|
|
|
|
m_CurrentText->SetLabelSpinStyle( mapOrientation( m_CurrentText->Type(), orientation ) );
|
|
|
|
|
2009-12-27 14:01:21 +00:00
|
|
|
text = m_TextSize->GetValue();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
value = ValueFromString( g_UserUnit, text );
|
2017-01-23 20:30:11 +00:00
|
|
|
m_CurrentText->SetTextSize( wxSize( value, value ) );
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2009-12-27 14:01:21 +00:00
|
|
|
if( m_TextShape )
|
2016-02-28 17:33:29 +00:00
|
|
|
/// @todo move cast to widget
|
2016-02-28 18:16:59 +00:00
|
|
|
m_CurrentText->SetShape( static_cast<PINSHEETLABEL_SHAPE>( m_TextShape->GetSelection() ) );
|
2009-12-27 14:01:21 +00:00
|
|
|
|
|
|
|
int style = m_TextStyle->GetSelection();
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
m_CurrentText->SetItalic( ( style & 1 ) );
|
2009-12-27 14:01:21 +00:00
|
|
|
|
|
|
|
if( ( style & 2 ) )
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
m_CurrentText->SetBold( true );
|
2017-01-23 20:30:11 +00:00
|
|
|
m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) );
|
2009-12-27 14:01:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
m_CurrentText->SetBold( false );
|
|
|
|
m_CurrentText->SetThickness( 0 );
|
2009-12-27 14:01:21 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
m_Parent->OnModify();
|
2009-12-27 14:01:21 +00:00
|
|
|
|
2013-11-18 17:52:18 +00:00
|
|
|
// Make the text size the new default size ( if it is a new text ):
|
2011-12-21 13:42:02 +00:00
|
|
|
if( m_CurrentText->IsNew() )
|
2017-01-23 20:30:11 +00:00
|
|
|
SetDefaultTextSize( m_CurrentText->GetTextWidth() );
|
2009-12-27 14:01:21 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );
|
|
|
|
m_Parent->GetCanvas()->MoveCursorToCrossHair();
|
2010-03-16 18:22:59 +00:00
|
|
|
EndModal( wxID_OK );
|
2009-12-27 14:01:21 +00:00
|
|
|
}
|