Pcbnew: minor VRML export dialog improvements.
* Track the last used path for the current session. * Set focus back to OK button after wxFilePickerCtrl button is pressed to change file path and/or file name so next return key press fires OK event. * Use default dialog size to let the sizers set initial dialog size. * Add spacer to improve layout when resizing dialog.
This commit is contained in:
parent
3076a5deda
commit
72e50b496c
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2013 Lorenzo Mercantonio
|
||||
* Copyright (C) 2013 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2015 KiCad Developers, see change_log.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
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
wxConfigBase* m_config;
|
||||
int m_unitsOpt; // Remember last units option
|
||||
bool m_copy3DFilesOpt; // Remember last copy model files option
|
||||
bool m_useRelativePathsOpt; // Remember last use absolut paths option
|
||||
bool m_useRelativePathsOpt; // Remember last use absolute paths option
|
||||
bool m_usePlainPCBOpt; // Remember last Plain Board option
|
||||
int m_RefUnits; // Remember last units for Reference Point
|
||||
double m_XRef; // Remember last X Reference Point
|
||||
|
@ -85,11 +85,7 @@ public:
|
|||
tmpStr = wxT( "" );
|
||||
tmpStr << m_YRef;
|
||||
m_VRML_Yref->SetValue( tmpStr );
|
||||
wxButton* okButton = (wxButton*) FindWindowByLabel( wxT( "OK" ) );
|
||||
|
||||
if( okButton )
|
||||
SetDefaultItem( okButton );
|
||||
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
GetSizer()->SetSizeHints( this );
|
||||
Centre();
|
||||
|
||||
|
@ -165,18 +161,30 @@ public:
|
|||
// Making path relative or absolute has no meaning when VRML files are not copied.
|
||||
event.Enable( m_cbCopyFiles->GetValue() );
|
||||
}
|
||||
|
||||
virtual void OnFileChanged( wxFileDirPickerEvent& event )
|
||||
{
|
||||
// Clicking on file picker button changes the focus to the file picker button which
|
||||
// is not the behavior we want. Set the focus back to the OK button so the next enter
|
||||
// key press dismisses this dialog with the OK action.
|
||||
m_sdbSizer1OK->SetFocus();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
|
||||
{
|
||||
static wxString mruPath;
|
||||
static wxString subDirFor3Dshapes;
|
||||
wxFileName fn;
|
||||
wxString projectPath;
|
||||
|
||||
if( !wxGetEnv( wxT( "KIPRJMOD" ), &projectPath ) )
|
||||
projectPath = wxFileName::GetCwd();
|
||||
|
||||
static wxString subDirFor3Dshapes;
|
||||
if( mruPath.IsEmpty() )
|
||||
mruPath = projectPath;
|
||||
|
||||
if( subDirFor3Dshapes.IsEmpty() )
|
||||
{
|
||||
|
@ -191,6 +199,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
|
|||
// Build default file name
|
||||
fn = GetBoard()->GetFileName();
|
||||
fn.SetExt( wxT( "wrl" ) );
|
||||
fn.SetPath( mruPath );
|
||||
|
||||
DIALOG_EXPORT_3DFILE dlg( this );
|
||||
dlg.FilePicker()->SetPath( fn.GetFullPath() );
|
||||
|
@ -219,6 +228,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
|
|||
|
||||
modelPath.AppendDir( dlg.GetSubdir() );
|
||||
subDirFor3Dshapes = dlg.GetSubdir();
|
||||
mruPath = dlg.FilePicker()->GetPath();
|
||||
|
||||
wxLogDebug( wxT( "Exporting enabled=%d to %s." ),
|
||||
export3DFiles, GetChars( subDirFor3Dshapes ) );
|
||||
|
@ -232,7 +242,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
|
|||
usePlainPCB, modelPath.GetPath(),
|
||||
aXRef, aYRef ) )
|
||||
{
|
||||
wxString msg = _( "Unable to create " ) + fullFilename;
|
||||
wxString msg = _( "Unable to create file " ) + fullFilename;
|
||||
wxMessageBox( msg );
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||
// C++ code generated with wxFormBuilder (version Jun 5 2014)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -128,6 +128,9 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow
|
|||
|
||||
bSizer1->Add( bLowerSizer, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
bSizer1->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
@ -143,8 +146,10 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow
|
|||
|
||||
this->SetSizer( bSizer1 );
|
||||
this->Layout();
|
||||
bSizer1->Fit( this );
|
||||
|
||||
// Connect Events
|
||||
m_filePicker->Connect( wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnFileChanged ), NULL, this );
|
||||
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnCancelClick ), NULL, this );
|
||||
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnOkClick ), NULL, this );
|
||||
}
|
||||
|
@ -152,6 +157,7 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow
|
|||
DIALOG_EXPORT_3DFILE_BASE::~DIALOG_EXPORT_3DFILE_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_filePicker->Disconnect( wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnFileChanged ), NULL, this );
|
||||
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnCancelClick ), NULL, this );
|
||||
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnOkClick ), NULL, this );
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<property name="minimum_size"></property>
|
||||
<property name="name">DIALOG_EXPORT_3DFILE_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">384,370</property>
|
||||
<property name="size">-1,-1</property>
|
||||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title">VRML Export Options</property>
|
||||
|
@ -93,11 +93,11 @@
|
|||
<property name="name">bSizer1</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size">-1,-1</property>
|
||||
<property name="name">bUpperSizer</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
|
@ -251,7 +251,7 @@
|
|||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnFileChanged"></event>
|
||||
<event name="OnFileChanged">OnFileChanged</event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
|
@ -546,7 +546,7 @@
|
|||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer9</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
|
@ -634,11 +634,11 @@
|
|||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxFlexGridSizer" expanded="1">
|
||||
<object class="wxFlexGridSizer" expanded="0">
|
||||
<property name="cols">2</property>
|
||||
<property name="flexible_direction">wxBOTH</property>
|
||||
<property name="growablecols">1</property>
|
||||
|
@ -1554,6 +1554,16 @@
|
|||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="spacer" expanded="0">
|
||||
<property name="height">0</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="width">0</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||
// C++ code generated with wxFormBuilder (version Jun 5 2014)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -68,13 +68,14 @@ class DIALOG_EXPORT_3DFILE_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizer1Cancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnFileChanged( wxFileDirPickerEvent& event ) { event.Skip(); }
|
||||
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("VRML Export Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 384,370 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("VRML Export Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_EXPORT_3DFILE_BASE();
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue