From 19c9df06072511d5aeb5c1729a4de16589e1da9f Mon Sep 17 00:00:00 2001
From: Oliver <oliver.henry.walters@gmail.com>
Date: Wed, 8 Mar 2017 00:32:34 +1100
Subject: [PATCH] Improvement for label edit dialog in eeschema:

- Added wxTE_RICH property to label text controls (allows ctrl+backspace in Windows)
- Added numeric validator to text size
---
 eeschema/dialogs/dialog_edit_label.cpp      | 12 ++++++++++++
 eeschema/dialogs/dialog_edit_label_base.cpp |  6 +++---
 eeschema/dialogs/dialog_edit_label_base.fbp |  4 ++--
 eeschema/dialogs/dialog_edit_label_base.h   |  2 +-
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp
index b4328af..dce7b71 100644
--- a/eeschema/dialogs/dialog_edit_label.cpp
+++ b/eeschema/dialogs/dialog_edit_label.cpp
@@ -30,6 +30,7 @@
 
 #include <fctsys.h>
 #include <wx/valgen.h>
+#include <wx/valnum.h>
 #include <schframe.h>
 #include <base_units.h>
 
@@ -110,6 +111,17 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe
     m_CurrentText = aTextItem;
     InitDialog();
 
+    // Conservative limits 0.01 to 10.0 inches
+    int minSize = 10 * IU_PER_MILS;
+    int maxSize = 10 * 1000 * IU_PER_MILS;
+
+    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 );
+
     // Now all widgets have the size fixed, call FinishDialogSettings
     FinishDialogSettings();
 }
diff --git a/eeschema/dialogs/dialog_edit_label_base.cpp b/eeschema/dialogs/dialog_edit_label_base.cpp
index f223491..191e98b 100644
--- a/eeschema/dialogs/dialog_edit_label_base.cpp
+++ b/eeschema/dialogs/dialog_edit_label_base.cpp
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Feb 26 2016)
+// C++ code generated with wxFormBuilder (version Jun 17 2015)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO "NOT" EDIT THIS FILE!
@@ -31,12 +31,12 @@ DIALOG_LABEL_EDITOR_BASE::DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID
 	wxBoxSizer* bSizeText;
 	bSizeText = new wxBoxSizer( wxVERTICAL );
 	
-	m_textLabelSingleLine = new wxTextCtrl( this, wxID_VALUESINGLE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
+	m_textLabelSingleLine = new wxTextCtrl( this, wxID_VALUESINGLE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH );
 	m_textLabelSingleLine->SetValidator( wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, &m_labelText ) );
 	
 	bSizeText->Add( m_textLabelSingleLine, 0, wxEXPAND|wxLEFT, 3 );
 	
-	m_textLabelMultiLine = new wxTextCtrl( this, wxID_VALUEMULTI, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
+	m_textLabelMultiLine = new wxTextCtrl( this, wxID_VALUEMULTI, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_RICH );
 	m_textLabelMultiLine->SetMinSize( wxSize( -1,60 ) );
 	
 	bSizeText->Add( m_textLabelMultiLine, 1, wxEXPAND|wxLEFT, 3 );
diff --git a/eeschema/dialogs/dialog_edit_label_base.fbp b/eeschema/dialogs/dialog_edit_label_base.fbp
index 609c484..80d5c99 100644
--- a/eeschema/dialogs/dialog_edit_label_base.fbp
+++ b/eeschema/dialogs/dialog_edit_label_base.fbp
@@ -251,7 +251,7 @@
                                         <property name="resize">Resizable</property>
                                         <property name="show">1</property>
                                         <property name="size"></property>
-                                        <property name="style">wxTE_PROCESS_ENTER</property>
+                                        <property name="style">wxTE_PROCESS_ENTER|wxTE_RICH</property>
                                         <property name="subclass"></property>
                                         <property name="toolbar_pane">0</property>
                                         <property name="tooltip"></property>
@@ -342,7 +342,7 @@
                                         <property name="resize">Resizable</property>
                                         <property name="show">1</property>
                                         <property name="size"></property>
-                                        <property name="style">wxTE_MULTILINE</property>
+                                        <property name="style">wxTE_MULTILINE|wxTE_RICH</property>
                                         <property name="subclass"></property>
                                         <property name="toolbar_pane">0</property>
                                         <property name="tooltip"></property>
diff --git a/eeschema/dialogs/dialog_edit_label_base.h b/eeschema/dialogs/dialog_edit_label_base.h
index 2d22d1a..8060c12 100644
--- a/eeschema/dialogs/dialog_edit_label_base.h
+++ b/eeschema/dialogs/dialog_edit_label_base.h
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Feb 26 2016)
+// C++ code generated with wxFormBuilder (version Jun 17 2015)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO "NOT" EDIT THIS FILE!
-- 
1.9.5.msysgit.0

