Implemented 3D search path configuration GUI
This commit is contained in:
parent
7848b2a52e
commit
54940002f9
|
@ -150,20 +150,10 @@ bool S3D_FILENAME_RESOLVER::createPathList( void )
|
|||
lpath.m_description = _( "Current project directory" );
|
||||
m_Paths.push_back( lpath );
|
||||
|
||||
if( wxGetEnv( wxT( "KISYS3DMOD" ), &kmod ) && !kmod.empty() )
|
||||
{
|
||||
wxFileName tmp( kmod );
|
||||
wxString kpath = tmp.GetFullPath();
|
||||
|
||||
if( tmp.Normalize() && lpath.m_pathexp.Cmp( kpath ) )
|
||||
{
|
||||
lpath.m_alias = wxT( "KISYS3DMOD" );
|
||||
lpath.m_pathvar = wxT( "${KISYS3DMOD}" );
|
||||
lpath.m_pathexp = kpath;
|
||||
lpath.m_description = _( "Legacy 3D environment path" );
|
||||
addPath( lpath );
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_ConfigDir.empty() )
|
||||
readPathList();
|
||||
|
@ -499,6 +489,10 @@ bool S3D_FILENAME_RESOLVER::readPathList( void )
|
|||
if( !getHollerith( cfgLine, idx, al.m_alias ) )
|
||||
continue;
|
||||
|
||||
// never add on KISYS3DMOD from a config file
|
||||
if( !al.m_alias.Cmp( wxT( "KISYS3DMOD" ) ) )
|
||||
continue;
|
||||
|
||||
if( !getHollerith( cfgLine, idx, al.m_pathvar ) )
|
||||
continue;
|
||||
|
||||
|
@ -524,16 +518,40 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
|
|||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = _( "3D configuration directory is unknown" );
|
||||
std::cerr << " * " << errmsg.ToUTF8() << "\n";
|
||||
wxMessageBox( errmsg, _T( "Write 3D search path list" ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( m_Paths.empty() || 1 == m_Paths.size() )
|
||||
return false;
|
||||
|
||||
wxFileName cfgpath( m_ConfigDir, S3D_RESOLVER_CONFIG );
|
||||
wxString cfgname = cfgpath.GetFullPath();
|
||||
std::ofstream cfgFile;
|
||||
|
||||
if( m_Paths.empty() || 1 == m_Paths.size() )
|
||||
{
|
||||
wxMessageDialog md( NULL,
|
||||
_T( "3D search path list is empty;\ncontinue to write empty file?" ),
|
||||
_T( "Write 3D search path list" ), wxYES_NO );
|
||||
|
||||
if( md.ShowModal() == wxID_YES )
|
||||
{
|
||||
cfgFile.open( cfgname.ToUTF8(), std::ios_base::trunc );
|
||||
|
||||
if( !cfgFile.is_open() )
|
||||
{
|
||||
wxMessageBox( _T( "Could not open configuration file" ),
|
||||
_T( "Write 3D search path list" ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
cfgFile.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
cfgFile.open( cfgname.ToUTF8(), std::ios_base::trunc );
|
||||
|
||||
if( !cfgFile.is_open() )
|
||||
|
@ -541,6 +559,9 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
|
|||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = _( "could not open configuration file " );
|
||||
std::cerr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'\n";
|
||||
wxMessageBox( _T( "Could not open configuration file" ),
|
||||
_T( "Write 3D search path list" ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -554,6 +575,13 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
|
|||
|
||||
while( sPL != ePL )
|
||||
{
|
||||
// never write the KISYS3DMOD entry
|
||||
if( !sPL->m_alias.Cmp( wxT( "KISYS3DMOD") ) )
|
||||
{
|
||||
++sPL;
|
||||
continue;
|
||||
}
|
||||
|
||||
tstr = sPL->m_alias.ToUTF8();
|
||||
cfgFile << "\"" << tstr.size() << ":" << tstr << "\",";
|
||||
tstr = sPL->m_pathvar.ToUTF8();
|
||||
|
@ -567,7 +595,12 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
|
|||
cfgFile.close();
|
||||
|
||||
if( bad )
|
||||
{
|
||||
wxMessageBox( _T( "Problems writing configuration file" ),
|
||||
_T( "Write 3D search path list" ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,10 @@ DLG_3D_PATH_CONFIG::DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER
|
|||
DLG_3D_PATH_CONFIG_BASE( aParent ), m_resolver( aResolver )
|
||||
{
|
||||
m_Aliases->EnableEditing( true );
|
||||
m_Aliases->SetColMinimalWidth( 0, 80 );
|
||||
m_Aliases->SetColMinimalWidth( 1, 300 );
|
||||
m_Aliases->SetColMinimalWidth( 2, 120 );
|
||||
m_Aliases->SetColMinimalAcceptableWidth( 80 );
|
||||
|
||||
if( m_resolver )
|
||||
{
|
||||
|
@ -42,10 +46,10 @@ DLG_3D_PATH_CONFIG::DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER
|
|||
if( listsize > 0 )
|
||||
m_curdir = rpaths->front().m_pathexp;
|
||||
|
||||
if( listsize < 2 )
|
||||
if( listsize < 3 )
|
||||
return;
|
||||
|
||||
listsize = listsize - 1 - m_Aliases->GetNumberRows();
|
||||
listsize = listsize - 2 - m_Aliases->GetNumberRows();
|
||||
|
||||
// note: if the list allocation fails we have bigger problems
|
||||
// and there is no point in trying to notify the user here
|
||||
|
@ -56,7 +60,9 @@ DLG_3D_PATH_CONFIG::DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER
|
|||
std::list< S3D_ALIAS >::const_iterator eL = rpaths->end();
|
||||
int nitems = 0;
|
||||
|
||||
// skip the first entry which is always the current project dir
|
||||
// skip the first 2 entries which are always the current project dir
|
||||
// and KISYS3DMOD
|
||||
++sL;
|
||||
++sL;
|
||||
wxGridCellTextEditor* pEdAlias;
|
||||
|
||||
|
@ -74,10 +80,9 @@ DLG_3D_PATH_CONFIG::DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER
|
|||
++sL;
|
||||
}
|
||||
|
||||
m_Aliases->AutoSizeColumns();
|
||||
m_Aliases->AutoSize();
|
||||
}
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
SetMinSize( GetSize() );
|
||||
|
||||
|
@ -88,7 +93,12 @@ DLG_3D_PATH_CONFIG::DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER
|
|||
bool DLG_3D_PATH_CONFIG::TransferDataFromWindow()
|
||||
{
|
||||
if( NULL == m_resolver )
|
||||
{
|
||||
wxMessageBox( _T( "[BUG] No valid resolver; data will not be updated" ),
|
||||
_T( "Update 3D search path list" ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<S3D_ALIAS> alist;
|
||||
S3D_ALIAS alias;
|
||||
|
@ -129,6 +139,8 @@ void DLG_3D_PATH_CONFIG::OnAddAlias( wxCommandEvent& event )
|
|||
pEdAlias->SetValidator( m_aliasValidator );
|
||||
pEdAlias->DecRef();
|
||||
m_Aliases->SelectRow( ni, false );
|
||||
m_Aliases->AutoSize();
|
||||
Fit();
|
||||
|
||||
// TODO: set the editors on any newly created rows
|
||||
}
|
||||
|
@ -164,6 +176,8 @@ void DLG_3D_PATH_CONFIG::OnDelAlias( wxCommandEvent& event )
|
|||
ni = m_Aliases->GetNumberRows() - 1;
|
||||
|
||||
m_Aliases->SelectRow( ni, false );
|
||||
m_Aliases->AutoSize();
|
||||
Fit();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -16,6 +16,9 @@ DLG_3D_PATH_CONFIG_BASE::DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID i
|
|||
wxBoxSizer* bSizer1;
|
||||
bSizer1 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bSizer3;
|
||||
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_Aliases = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
// Grid
|
||||
|
@ -26,7 +29,6 @@ DLG_3D_PATH_CONFIG_BASE::DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID i
|
|||
m_Aliases->SetMargins( 0, 0 );
|
||||
|
||||
// Columns
|
||||
m_Aliases->AutoSizeColumns();
|
||||
m_Aliases->EnableDragColMove( false );
|
||||
m_Aliases->EnableDragColSize( true );
|
||||
m_Aliases->SetColLabelSize( 30 );
|
||||
|
@ -36,7 +38,8 @@ DLG_3D_PATH_CONFIG_BASE::DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID i
|
|||
m_Aliases->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
|
||||
// Rows
|
||||
m_Aliases->EnableDragRowSize( true );
|
||||
m_Aliases->AutoSizeRows();
|
||||
m_Aliases->EnableDragRowSize( false );
|
||||
m_Aliases->SetRowLabelSize( 80 );
|
||||
m_Aliases->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
|
||||
|
@ -44,7 +47,10 @@ DLG_3D_PATH_CONFIG_BASE::DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID i
|
|||
|
||||
// Cell Defaults
|
||||
m_Aliases->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
|
||||
bSizer1->Add( m_Aliases, 0, wxALL, 5 );
|
||||
bSizer3->Add( m_Aliases, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( bSizer3, 1, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer2;
|
||||
bSizer2 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
|
|
@ -95,8 +95,17 @@
|
|||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer3</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxGrid" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
|
@ -106,8 +115,8 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="autosize_cols">1</property>
|
||||
<property name="autosize_rows">0</property>
|
||||
<property name="autosize_cols">0</property>
|
||||
<property name="autosize_rows">1</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
|
@ -134,7 +143,7 @@
|
|||
<property name="drag_col_move">0</property>
|
||||
<property name="drag_col_size">1</property>
|
||||
<property name="drag_grid_size">0</property>
|
||||
<property name="drag_row_size">1</property>
|
||||
<property name="drag_row_size">0</property>
|
||||
<property name="editing">1</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
|
@ -236,6 +245,8 @@
|
|||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
|
|
|
@ -20,8 +20,8 @@ class DIALOG_SHIM;
|
|||
#include <wx/font.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/frame.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue