WX_PT_ENTRY_DIALOG: enhancements: fix min size and add reset button.

It is used to enter a point position and a grid origin.
The new button (only in grid origin dialog) allows reset the position.
This commit is contained in:
jean-pierre charras 2025-04-03 13:19:20 +02:00
parent 40058ebe80
commit f8ec23db00
8 changed files with 879 additions and 765 deletions

View File

@ -50,11 +50,13 @@ int WX_UNIT_ENTRY_DIALOG::GetValue()
WX_PT_ENTRY_DIALOG::WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption, WX_PT_ENTRY_DIALOG::WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption,
const wxString& aLabelX, const wxString& aLabelY, const wxString& aLabelX, const wxString& aLabelY,
const VECTOR2I& aDefaultValue ) : const VECTOR2I& aDefaultValue, bool aShowResetButt ) :
WX_PT_ENTRY_DIALOG_BASE( ( wxWindow* ) aParent, wxID_ANY, aCaption ), WX_PT_ENTRY_DIALOG_BASE( ( wxWindow* ) aParent, wxID_ANY, aCaption ),
m_unit_binder_x( aParent, m_labelX, m_textCtrlX, m_unitsX, true ), m_unit_binder_x( aParent, m_labelX, m_textCtrlX, m_unitsX, true ),
m_unit_binder_y( aParent, m_labelY, m_textCtrlY, m_unitsY, true ) m_unit_binder_y( aParent, m_labelY, m_textCtrlY, m_unitsY, true )
{ {
m_ButtonReset->Show( aShowResetButt );
m_labelX->SetLabel( aLabelX ); m_labelX->SetLabel( aLabelX );
m_labelY->SetLabel( aLabelY ); m_labelY->SetLabel( aLabelY );
@ -67,8 +69,7 @@ WX_PT_ENTRY_DIALOG::WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString&
SetInitialFocus( m_textCtrlX ); SetInitialFocus( m_textCtrlX );
SetupStandardButtons(); SetupStandardButtons();
Layout(); finishDialogSettings();
bSizerMain->Fit( this );
} }
@ -76,3 +77,9 @@ VECTOR2I WX_PT_ENTRY_DIALOG::GetValue()
{ {
return VECTOR2I( m_unit_binder_x.GetIntValue(), m_unit_binder_y.GetIntValue() ); return VECTOR2I( m_unit_binder_x.GetIntValue(), m_unit_binder_y.GetIntValue() );
} }
void WX_PT_ENTRY_DIALOG::ResetValues( wxCommandEvent& event )
{
m_unit_binder_x.SetValue( 0 );
m_unit_binder_y.SetValue( 0 );
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -102,8 +102,11 @@ WX_PT_ENTRY_DIALOG_BASE::WX_PT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID i
wxBoxSizer* bSizerButtons; wxBoxSizer* bSizerButtons;
bSizerButtons = new wxBoxSizer( wxHORIZONTAL ); bSizerButtons = new wxBoxSizer( wxHORIZONTAL );
m_ButtonReset = new wxButton( this, wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_ButtonReset, 0, wxALL|wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
bSizerButtons->Add( 100, 0, 1, wxALIGN_CENTER_VERTICAL, 5 );
bSizerButtons->Add( 30, 0, 1, wxALIGN_CENTER_VERTICAL, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK ); m_sdbSizer1OK = new wxButton( this, wxID_OK );
@ -123,8 +126,14 @@ WX_PT_ENTRY_DIALOG_BASE::WX_PT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID i
bSizerMain->Fit( this ); bSizerMain->Fit( this );
this->Centre( wxBOTH ); this->Centre( wxBOTH );
// Connect Events
m_ButtonReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WX_PT_ENTRY_DIALOG_BASE::ResetValues ), NULL, this );
} }
WX_PT_ENTRY_DIALOG_BASE::~WX_PT_ENTRY_DIALOG_BASE() WX_PT_ENTRY_DIALOG_BASE::~WX_PT_ENTRY_DIALOG_BASE()
{ {
// Disconnect Events
m_ButtonReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WX_PT_ENTRY_DIALOG_BASE::ResetValues ), NULL, this );
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -21,10 +21,12 @@
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class WX_UNIT_ENTRY_DIALOG_BASE /// Class WX_UNIT_ENTRY_DIALOG_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -64,10 +66,15 @@ class WX_PT_ENTRY_DIALOG_BASE : public DIALOG_SHIM
wxStaticText* m_labelY; wxStaticText* m_labelY;
wxTextCtrl* m_textCtrlY; wxTextCtrl* m_textCtrlY;
wxStaticText* m_unitsY; wxStaticText* m_unitsY;
wxButton* m_ButtonReset;
wxStdDialogButtonSizer* m_sdbSizer1; wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel; wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, override them in your derived class
virtual void ResetValues( wxCommandEvent& event ) { event.Skip(); }
public: public:
WX_PT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Move Point to Location"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); WX_PT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Move Point to Location"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );

View File

@ -1051,7 +1051,8 @@ TOOL_ACTION ACTIONS::gridOrigin( TOOL_ACTION_ARGS()
.Name( "common.Control.editGridOrigin" ) .Name( "common.Control.editGridOrigin" )
.Scope( AS_GLOBAL ) .Scope( AS_GLOBAL )
.FriendlyName( _( "Grid Origin..." ) ) .FriendlyName( _( "Grid Origin..." ) )
.Tooltip( _( "Set the grid origin point" ) ) ); .Tooltip( _( "Set the grid origin point" ) )
.Icon( BITMAPS::grid_select_axis ) );
TOOL_ACTION ACTIONS::inchesUnits( TOOL_ACTION_ARGS() TOOL_ACTION ACTIONS::inchesUnits( TOOL_ACTION_ARGS()
.Name( "common.Control.imperialUnits" ) .Name( "common.Control.imperialUnits" )

View File

@ -627,7 +627,7 @@ int COMMON_TOOLS::GridProperties( const TOOL_EVENT& aEvent )
int COMMON_TOOLS::GridOrigin( const TOOL_EVENT& aEvent ) int COMMON_TOOLS::GridOrigin( const TOOL_EVENT& aEvent )
{ {
VECTOR2I origin = m_frame->GetGridOrigin(); VECTOR2I origin = m_frame->GetGridOrigin();
WX_PT_ENTRY_DIALOG dlg( m_frame, _( "Grid Origin" ), _( "X:" ), _( "Y:" ), origin ); WX_PT_ENTRY_DIALOG dlg( m_frame, _( "Grid Origin" ), _( "X:" ), _( "Y:" ), origin, true );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
{ {

View File

@ -52,13 +52,15 @@ class WX_PT_ENTRY_DIALOG : public WX_PT_ENTRY_DIALOG_BASE
{ {
public: public:
WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption, const wxString& aLabelX, WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption, const wxString& aLabelX,
const wxString& aLabelY, const VECTOR2I& aDefaultValue ); const wxString& aLabelY, const VECTOR2I& aDefaultValue, bool aShowResetButt );
/** /**
* Return the value in internal units. * Return the value in internal units.
*/ */
VECTOR2I GetValue(); VECTOR2I GetValue();
void ResetValues( wxCommandEvent& event ) override;
private: private:
UNIT_BINDER m_unit_binder_x; UNIT_BINDER m_unit_binder_x;
UNIT_BINDER m_unit_binder_y; UNIT_BINDER m_unit_binder_y;

View File

@ -2457,7 +2457,7 @@ int PCB_POINT_EDITOR::movePoint( const TOOL_EVENT& aEvent )
msg = _( "Move Corner" ); msg = _( "Move Corner" );
} }
WX_PT_ENTRY_DIALOG dlg( editFrame, title, _( "X:" ), _( "Y:" ), pt ); WX_PT_ENTRY_DIALOG dlg( editFrame, title, _( "X:" ), _( "Y:" ), pt, false );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
{ {