Commit 26b20cad authored by charras's avatar charras

Better label dialog editor. Libedit: now, cannot change the component name to...

Better label dialog editor. Libedit: now, cannot change the component name to an existing alias name (eeschema crashes when happens)
parent 07ddb9cb
......@@ -8,7 +8,7 @@
#include "appl_wxstruct.h"
#define BUILD_VERSION wxT("(20090504-unstable)")
#define BUILD_VERSION wxT("(20090513-unstable)")
wxString g_BuildVersion
......
......@@ -21,9 +21,8 @@
int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText )
{
int ret;
bool multiline = CurrentText->m_MultilineAllowed;
DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText, multiline );
DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText );
// doing any post construction resizing is better done here than in
// OnInitDialog() since it tends to flash/redraw the dialog less.
......@@ -36,17 +35,29 @@ int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * C
DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* CurrentText,bool multiline ) :
DialogLabelEditor_Base( parent,wxID_ANY,multiline )
DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* CurrentText ) :
DialogLabelEditor_Base( parent )
{
m_Parent = parent;
m_CurrentText = CurrentText;
init();
}
void DialogLabelEditor::init()
{
wxString msg;
if( m_CurrentText->m_MultilineAllowed )
{
m_TextLabel = m_textCtrlMultiline;
m_TextLabelSingleline->Show(false);
}
else
{
m_TextLabel = m_TextLabelSingleline;
m_textCtrlMultiline->Show(false);
}
m_TextLabel->SetValue( m_CurrentText->m_Text );
m_TextLabel->SetFocus();
......
......@@ -15,10 +15,11 @@ class DialogLabelEditor : public DialogLabelEditor_Base
private:
WinEDA_SchematicFrame * m_Parent;
SCH_TEXT * m_CurrentText;
wxTextCtrl* m_TextLabel;
protected:
// these are protected so that the static ShowModally() gets used.
DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText, bool multiline);
DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText);
~DialogLabelEditor(){};
......
......@@ -9,26 +9,27 @@
///////////////////////////////////////////////////////////////////////////
DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, bool multiline,const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxHORIZONTAL );
bSizerTextCtrl = new wxBoxSizer( wxVERTICAL );
bMainSizer = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Text"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
bSizerTextCtrl->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TextLabelSingleline = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_TextLabelSingleline->SetToolTip( _("Enter the text to be used within the schematic") );
bMainSizer->Add( m_TextLabelSingleline, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
if (multiline)
m_TextLabel = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER | wxTE_MULTILINE );
else
m_TextLabel = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
m_TextLabel->SetToolTip( _("Enter the text to be used within the schematic") );
m_textCtrlMultiline = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_PROCESS_ENTER );
m_textCtrlMultiline->SetToolTip( _("Enter the text to be used within the schematic") );
m_textCtrlMultiline->SetMinSize( wxSize( -1,60 ) );
bSizerTextCtrl->Add( m_TextLabel, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bMainSizer->Add( m_textCtrlMultiline, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
wxBoxSizer* m_OptionsSizer;
m_OptionsSizer = new wxBoxSizer( wxHORIZONTAL );
......@@ -51,10 +52,6 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id,
m_TextShape->SetSelection( 0 );
m_OptionsSizer->Add( m_TextShape, 1, wxALL, 5 );
bSizerTextCtrl->Add( m_OptionsSizer, 1, wxEXPAND, 5 );
bMainSizer->Add( bSizerTextCtrl, 5, wxEXPAND, 5 );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
......@@ -66,7 +63,7 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id,
bSizer4->Add( m_TextSize, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizer4->Add( 8, 8, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
bSizer4->Add( 8, 8, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_buttonOK, 1, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
......@@ -74,13 +71,15 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id,
m_buttonCANCEL = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_buttonCANCEL, 1, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bMainSizer->Add( bSizer4, 1, 0, 5 );
m_OptionsSizer->Add( bSizer4, 1, 0, 5 );
bMainSizer->Add( m_OptionsSizer, 1, wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
// Connect Events
m_TextLabel->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::onEnterKey ), NULL, this );
m_TextLabelSingleline->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::onEnterKey ), NULL, this );
m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonOKClick ), NULL, this );
m_buttonCANCEL->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonCANCEL_Click ), NULL, this );
}
......@@ -88,7 +87,7 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id,
DialogLabelEditor_Base::~DialogLabelEditor_Base()
{
// Disconnect Events
m_TextLabel->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::onEnterKey ), NULL, this );
m_TextLabelSingleline->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::onEnterKey ), NULL, this );
m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonOKClick ), NULL, this );
m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonCANCEL_Click ), NULL, this );
}
This diff is collapsed.
......@@ -18,8 +18,8 @@
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/radiobox.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
......@@ -38,9 +38,9 @@ class DialogLabelEditor_Base : public wxDialog
wxID_SIZE,
};
wxBoxSizer* bSizerTextCtrl;
wxStaticText* m_staticText1;
wxTextCtrl* m_TextLabel;
wxTextCtrl* m_TextLabelSingleline;
wxTextCtrl* m_textCtrlMultiline;
wxRadioBox* m_TextOrient;
wxRadioBox* m_TextStyle;
wxRadioBox* m_TextShape;
......@@ -57,7 +57,7 @@ class DialogLabelEditor_Base : public wxDialog
public:
DialogLabelEditor_Base( wxWindow* parent, wxWindowID id = wxID_ANY, bool multiline=false, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,216 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DialogLabelEditor_Base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 526,281 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DialogLabelEditor_Base();
};
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment