Kicad manager: Allows the selection of templates paths, in template selector dialog.
This commit is contained in:
parent
77249d9b2d
commit
e74eccede3
|
@ -28,28 +28,22 @@
|
|||
#include <wx/settings.h>
|
||||
|
||||
|
||||
TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxWindow* aParent,
|
||||
TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent,
|
||||
const wxString& aPath ) :
|
||||
TEMPLATE_SELECTION_PANEL_BASE( aParent )
|
||||
{
|
||||
parent = aParent;
|
||||
m_parent = aParent;
|
||||
m_templatesPath = aPath;
|
||||
}
|
||||
|
||||
|
||||
TEMPLATE_SELECTION_PANEL::~TEMPLATE_SELECTION_PANEL()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEMPLATE_WIDGET::TEMPLATE_WIDGET( wxWindow* aParent, wxDialog* aDialog ) :
|
||||
TEMPLATE_WIDGET::TEMPLATE_WIDGET( wxWindow* aParent, DIALOG_TEMPLATE_SELECTOR* aDialog ) :
|
||||
TEMPLATE_WIDGET_BASE( aParent )
|
||||
{
|
||||
parent = aParent;
|
||||
dialog = aDialog;
|
||||
m_parent = aParent;
|
||||
m_dialog = aDialog;
|
||||
|
||||
// wxWidgets 2.9.x way of doing the same...
|
||||
// wxWidgets_3.xx way of doing the same...
|
||||
// Bind(wxEVT_LEFT_DOWN, &TEMPLATE_WIDGET::OnMouse, this );
|
||||
|
||||
m_bitmapIcon->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( TEMPLATE_WIDGET::OnMouse ), NULL, this );
|
||||
|
@ -59,21 +53,15 @@ TEMPLATE_WIDGET::TEMPLATE_WIDGET( wxWindow* aParent, wxDialog* aDialog ) :
|
|||
Unselect();
|
||||
|
||||
// Start with template being NULL
|
||||
templ = NULL;
|
||||
m_currTemplate = NULL;
|
||||
}
|
||||
|
||||
|
||||
TEMPLATE_WIDGET::~TEMPLATE_WIDGET()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TEMPLATE_WIDGET::Select()
|
||||
{
|
||||
DIALOG_TEMPLATE_SELECTOR* d = (DIALOG_TEMPLATE_SELECTOR*)dialog;
|
||||
d->SetWidget( this );
|
||||
m_dialog->SetWidget( this );
|
||||
SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ) );
|
||||
selected = true;
|
||||
m_selected = true;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
@ -81,26 +69,14 @@ void TEMPLATE_WIDGET::Select()
|
|||
void TEMPLATE_WIDGET::Unselect()
|
||||
{
|
||||
SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
|
||||
selected = false;
|
||||
m_selected = false;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
bool TEMPLATE_WIDGET::IsSelected()
|
||||
{
|
||||
return selected;
|
||||
}
|
||||
|
||||
|
||||
PROJECT_TEMPLATE* TEMPLATE_WIDGET::GetTemplate()
|
||||
{
|
||||
return templ;
|
||||
}
|
||||
|
||||
|
||||
void TEMPLATE_WIDGET::SetTemplate(PROJECT_TEMPLATE* aTemplate)
|
||||
{
|
||||
templ = aTemplate;
|
||||
m_currTemplate = aTemplate;
|
||||
m_staticTitle->SetLabel( *(aTemplate->GetTitle()) );
|
||||
m_bitmapIcon->SetBitmap( *(aTemplate->GetIcon()) );
|
||||
}
|
||||
|
@ -108,7 +84,7 @@ void TEMPLATE_WIDGET::SetTemplate(PROJECT_TEMPLATE* aTemplate)
|
|||
|
||||
void TEMPLATE_WIDGET::OnMouse( wxMouseEvent& event )
|
||||
{
|
||||
/* Toggle selection here */
|
||||
// Toggle selection here
|
||||
Select();
|
||||
event.Skip();
|
||||
}
|
||||
|
@ -120,9 +96,9 @@ void DIALOG_TEMPLATE_SELECTOR::onNotebookResize(wxSizeEvent& event)
|
|||
{
|
||||
m_panels[i]->SetSize( m_notebook->GetSize().GetWidth() - 6, 140 );
|
||||
m_panels[i]->m_SizerBase->FitInside( m_panels[i] );
|
||||
m_panels[i]->m_scrolledWindow1->SetSize( m_panels[i]->GetSize().GetWidth() - 6,
|
||||
m_panels[i]->m_scrolledWindow->SetSize( m_panels[i]->GetSize().GetWidth() - 6,
|
||||
m_panels[i]->GetSize().GetHeight() - 6 );
|
||||
m_panels[i]->m_SizerChoice->FitInside( m_panels[i]->m_scrolledWindow1 );
|
||||
m_panels[i]->m_SizerChoice->FitInside( m_panels[i]->m_scrolledWindow );
|
||||
}
|
||||
m_notebook->Refresh();
|
||||
|
||||
|
@ -134,7 +110,7 @@ void DIALOG_TEMPLATE_SELECTOR::OnPageChange( wxNotebookEvent& event )
|
|||
int page = m_notebook->GetSelection();
|
||||
|
||||
if( page != wxNOT_FOUND && (unsigned)page < m_panels.size() )
|
||||
m_textCtrlTemplatePath->SetValue( m_panels[page]->GetPath() );
|
||||
m_tcTemplatePath->SetValue( m_panels[page]->GetPath() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,24 +123,6 @@ DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent ) :
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_TEMPLATE_SELECTOR::SetHtml( wxFileName aFilename )
|
||||
{
|
||||
m_htmlWin->LoadPage( aFilename.GetFullPath() );
|
||||
}
|
||||
|
||||
|
||||
DIALOG_TEMPLATE_SELECTOR::~DIALOG_TEMPLATE_SELECTOR()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEMPLATE_WIDGET* DIALOG_TEMPLATE_SELECTOR::GetWidget()
|
||||
{
|
||||
return m_selectedWidget;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_TEMPLATE_SELECTOR::SetWidget( TEMPLATE_WIDGET* aWidget )
|
||||
{
|
||||
if( m_selectedWidget != NULL )
|
||||
|
@ -176,40 +134,51 @@ void DIALOG_TEMPLATE_SELECTOR::SetWidget( TEMPLATE_WIDGET* aWidget )
|
|||
|
||||
void DIALOG_TEMPLATE_SELECTOR::AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate )
|
||||
{
|
||||
TEMPLATE_WIDGET* w = new TEMPLATE_WIDGET( m_panels[aPage]->m_scrolledWindow1, this );
|
||||
TEMPLATE_WIDGET* w = new TEMPLATE_WIDGET( m_panels[aPage]->m_scrolledWindow, this );
|
||||
w->SetTemplate( aTemplate );
|
||||
|
||||
m_panels[aPage]->m_SizerChoice->Add( w );
|
||||
m_panels[aPage]->m_SizerChoice->Layout();
|
||||
m_panels[aPage]->SetSize( m_notebook->GetSize().GetWidth() - 6, 140 );
|
||||
m_panels[aPage]->m_SizerBase->FitInside( m_panels[aPage] );
|
||||
m_panels[aPage]->m_scrolledWindow1->SetSize( m_panels[aPage]->GetSize().GetWidth() - 6,
|
||||
m_panels[aPage]->m_scrolledWindow->SetSize( m_panels[aPage]->GetSize().GetWidth() - 6,
|
||||
m_panels[aPage]->GetSize().GetHeight() - 6 );
|
||||
m_panels[aPage]->m_SizerChoice->FitInside( m_panels[aPage]->m_scrolledWindow1 );
|
||||
m_panels[aPage]->m_SizerChoice->FitInside( m_panels[aPage]->m_scrolledWindow );
|
||||
|
||||
m_notebook->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPath )
|
||||
PROJECT_TEMPLATE* DIALOG_TEMPLATE_SELECTOR::GetSelectedTemplate()
|
||||
{
|
||||
return m_selectedWidget? m_selectedWidget->GetTemplate() : NULL;
|
||||
}
|
||||
|
||||
void DIALOG_TEMPLATE_SELECTOR::AddTemplatesPage( const wxString& aTitle, wxFileName& aPath )
|
||||
{
|
||||
wxNotebookPage* newPage = new wxNotebookPage( m_notebook, wxID_ANY );
|
||||
m_notebook->AddPage( newPage, aTitle );
|
||||
|
||||
aPath.Normalize();
|
||||
wxString path = aPath.GetFullPath(); // caller ensures this ends with file separator.
|
||||
|
||||
TEMPLATE_SELECTION_PANEL* tpanel = new TEMPLATE_SELECTION_PANEL( newPage, path );
|
||||
m_panels.push_back( tpanel );
|
||||
|
||||
m_notebook->AddPage( newPage, aTitle );
|
||||
|
||||
if( m_notebook->GetPageCount() == 1 )
|
||||
m_textCtrlTemplatePath->SetValue( path );
|
||||
m_tcTemplatePath->SetValue( path );
|
||||
|
||||
buildPageContent( path, m_notebook->GetPageCount() - 1 );
|
||||
}
|
||||
|
||||
void DIALOG_TEMPLATE_SELECTOR::buildPageContent( const wxString& aPath, int aPage )
|
||||
{
|
||||
// Get a list of files under the template path to include as choices...
|
||||
wxArrayString files;
|
||||
wxDir dir;
|
||||
|
||||
if( dir.Open( path ) )
|
||||
if( dir.Open( aPath ) )
|
||||
{
|
||||
wxDir sub_dir;
|
||||
wxString sub_name;
|
||||
|
@ -217,16 +186,88 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat
|
|||
bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS );
|
||||
while( cont )
|
||||
{
|
||||
wxString sub_full = path + sub_name;
|
||||
wxString sub_full = aPath + sub_name;
|
||||
if( sub_dir.Open( sub_full ) )
|
||||
{
|
||||
files.Add( sub_name );
|
||||
|
||||
PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( sub_full );
|
||||
AddTemplate( m_notebook->GetPageCount() - 1, pt );
|
||||
AddTemplate( aPage, pt );
|
||||
}
|
||||
|
||||
cont = dir.GetNext( &sub_name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_TEMPLATE_SELECTOR::onDirectoryBrowseClicked( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn;
|
||||
fn.AssignDir( m_tcTemplatePath->GetValue() );
|
||||
fn.Normalize();
|
||||
wxString currPath = fn.GetFullPath();
|
||||
|
||||
wxDirDialog dirDialog( this, _( "Select Templates Directory" ),
|
||||
currPath,
|
||||
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
|
||||
|
||||
if( dirDialog.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
||||
|
||||
m_tcTemplatePath->SetValue( dirName.GetFullPath() );
|
||||
|
||||
if( currPath == m_tcTemplatePath->GetValue() )
|
||||
return; // No change
|
||||
|
||||
// Rebuild the page from the new templates path:
|
||||
replaceCurrentPage();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_TEMPLATE_SELECTOR::onValidatePath( wxCommandEvent& event )
|
||||
{
|
||||
int page = m_notebook->GetSelection();
|
||||
|
||||
if( page < 0 )
|
||||
return; // Should not happen
|
||||
|
||||
wxString currPath = m_tcTemplatePath->GetValue();
|
||||
|
||||
if( currPath == m_panels[page]->GetPath() ) // No change
|
||||
return;
|
||||
|
||||
wxFileName fn;
|
||||
fn.AssignDir( m_tcTemplatePath->GetValue() );
|
||||
fn.Normalize();
|
||||
currPath = fn.GetFullPath();
|
||||
m_tcTemplatePath->SetValue( currPath );
|
||||
|
||||
replaceCurrentPage();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_TEMPLATE_SELECTOR::replaceCurrentPage()
|
||||
{
|
||||
// Rebuild the page from the new templates path:
|
||||
int page = m_notebook->GetSelection();
|
||||
|
||||
if( page < 0 )
|
||||
return; // Should not happen
|
||||
|
||||
wxString title = m_notebook->GetPageText( page );
|
||||
wxString currPath = m_tcTemplatePath->GetValue();
|
||||
|
||||
m_notebook->DeletePage( page );
|
||||
|
||||
wxNotebookPage* newPage = new wxNotebookPage( m_notebook, wxID_ANY );
|
||||
TEMPLATE_SELECTION_PANEL* tpanel = new TEMPLATE_SELECTION_PANEL( newPage, currPath );
|
||||
m_panels[page] = tpanel;
|
||||
m_notebook->InsertPage( page, newPage, title, true );
|
||||
|
||||
buildPageContent( m_tcTemplatePath->GetValue(), page );
|
||||
|
||||
m_selectedWidget = NULL;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<wxFormBuilder_Project>
|
||||
<FileVersion major="1" minor="11" />
|
||||
<FileVersion major="1" minor="13" />
|
||||
<object class="Project" expanded="1">
|
||||
<property name="class_decoration"></property>
|
||||
<property name="code_generation">C++</property>
|
||||
|
@ -20,8 +20,10 @@
|
|||
<property name="path">.</property>
|
||||
<property name="precompiled_header"></property>
|
||||
<property name="relative_path">1</property>
|
||||
<property name="skip_lua_events">1</property>
|
||||
<property name="skip_php_events">1</property>
|
||||
<property name="skip_python_events">1</property>
|
||||
<property name="ui_table">UI</property>
|
||||
<property name="use_enum">0</property>
|
||||
<property name="use_microsoft_bom">0</property>
|
||||
<object class="Dialog" expanded="1">
|
||||
|
@ -261,7 +263,7 @@
|
|||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxRIGHT|wxLEFT</property>
|
||||
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
@ -344,8 +346,17 @@
|
|||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bsizerTemplateSelector</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxTextCtrl" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
|
@ -382,7 +393,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_textCtrlTemplatePath</property>
|
||||
<property name="name">m_tcTemplatePath</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -392,7 +403,7 @@
|
|||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxTE_READONLY</property>
|
||||
<property name="style">wxTE_PROCESS_ENTER</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
|
@ -433,6 +444,265 @@
|
|||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Browse</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_buttonBrowse</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxBU_EXACTFIT</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnButtonClick">onDirectoryBrowseClicked</event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Validate</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_buttonValidate</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxBU_EXACTFIT</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnButtonClick">onValidatePath</event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND | wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticLine" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_staticline</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxLI_HORIZONTAL</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">3</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
|
@ -557,7 +827,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_scrolledWindow1</property>
|
||||
<property name="name">m_scrolledWindow</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
|
|
@ -28,49 +28,53 @@
|
|||
#include <dialogs/dialog_template_selector_base.h>
|
||||
#include "project_template.h"
|
||||
|
||||
class DIALOG_TEMPLATE_SELECTOR;
|
||||
|
||||
class TEMPLATE_WIDGET : public TEMPLATE_WIDGET_BASE
|
||||
{
|
||||
protected:
|
||||
wxDialog* dialog;
|
||||
wxWindow* parent;
|
||||
wxPanel* panel;
|
||||
bool selected;
|
||||
DIALOG_TEMPLATE_SELECTOR* m_dialog;
|
||||
wxWindow* m_parent;
|
||||
wxPanel* m_panel;
|
||||
bool m_selected;
|
||||
|
||||
PROJECT_TEMPLATE* templ;
|
||||
PROJECT_TEMPLATE* m_currTemplate;
|
||||
|
||||
void OnKillFocus( wxFocusEvent& event );
|
||||
void OnMouse( wxMouseEvent& event );
|
||||
|
||||
public:
|
||||
TEMPLATE_WIDGET( wxWindow* aParent, wxDialog* aDialog );
|
||||
~TEMPLATE_WIDGET();
|
||||
TEMPLATE_WIDGET( wxWindow* aParent, DIALOG_TEMPLATE_SELECTOR* aDialog );
|
||||
|
||||
/**
|
||||
* Set the project template for this widget, which will determine the icon and title
|
||||
* associated with this project template widget
|
||||
*/
|
||||
void SetTemplate(PROJECT_TEMPLATE* aTemplate);
|
||||
PROJECT_TEMPLATE* GetTemplate();
|
||||
|
||||
PROJECT_TEMPLATE* GetTemplate() { return m_currTemplate; }
|
||||
|
||||
void Select();
|
||||
void Unselect();
|
||||
bool IsSelected();
|
||||
|
||||
private:
|
||||
bool IsSelected() { return m_selected; }
|
||||
};
|
||||
|
||||
|
||||
class TEMPLATE_SELECTION_PANEL : public TEMPLATE_SELECTION_PANEL_BASE
|
||||
{
|
||||
protected:
|
||||
wxWindow* parent;
|
||||
wxString m_templatesPath;
|
||||
wxNotebookPage* m_parent;
|
||||
wxString m_templatesPath; ///< the path to access to the folder
|
||||
///< containing the templates (which are also folders)
|
||||
|
||||
public:
|
||||
/**
|
||||
* @param aParent The window creating the dialog
|
||||
* @param aPath the path
|
||||
*/
|
||||
TEMPLATE_SELECTION_PANEL( wxWindow* aParent, const wxString& aPath );
|
||||
~TEMPLATE_SELECTION_PANEL();
|
||||
TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, const wxString& aPath );
|
||||
|
||||
const wxString& GetPath() { return m_templatesPath; }
|
||||
};
|
||||
|
@ -80,23 +84,44 @@ class DIALOG_TEMPLATE_SELECTOR : public DIALOG_TEMPLATE_SELECTOR_BASE
|
|||
{
|
||||
protected:
|
||||
std::vector<TEMPLATE_SELECTION_PANEL*> m_panels;
|
||||
void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate );
|
||||
TEMPLATE_WIDGET* m_selectedWidget;
|
||||
|
||||
void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate );
|
||||
|
||||
public:
|
||||
DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent );
|
||||
~DIALOG_TEMPLATE_SELECTOR();
|
||||
|
||||
/**
|
||||
* Add a new page with \a aTitle, populated with templates from \a aPath
|
||||
* - All directories under the path are treated as templates
|
||||
* @param aTitle = the title of the wxNoteBook page
|
||||
* @param aPath = the path of the main folder containing templates
|
||||
*/
|
||||
void AddPage( const wxString& aTitle, wxFileName& aPath );
|
||||
void SetHtml( wxFileName aFilename );
|
||||
TEMPLATE_WIDGET* GetWidget();
|
||||
void AddTemplatesPage( const wxString& aTitle, wxFileName& aPath );
|
||||
|
||||
/**
|
||||
* @return the selected template, or NULL
|
||||
*/
|
||||
PROJECT_TEMPLATE* GetSelectedTemplate();
|
||||
|
||||
private:
|
||||
|
||||
void SetHtml( wxFileName aFilename )
|
||||
{
|
||||
m_htmlWin->LoadPage( aFilename.GetFullPath() );
|
||||
}
|
||||
|
||||
public:
|
||||
void SetWidget( TEMPLATE_WIDGET* aWidget );
|
||||
|
||||
private:
|
||||
void buildPageContent( const wxString& aPath, int aPage );
|
||||
void replaceCurrentPage();
|
||||
|
||||
void onNotebookResize( wxSizeEvent& event );
|
||||
void OnPageChange( wxNotebookEvent& event );
|
||||
void onDirectoryBrowseClicked( wxCommandEvent& event );
|
||||
void onValidatePath( wxCommandEvent& event );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 8 2012)
|
||||
// C++ code generated with wxFormBuilder (version Jun 5 2014)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -25,10 +25,25 @@ DIALOG_TEMPLATE_SELECTOR_BASE::DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent,
|
|||
|
||||
m_staticTextTpath = new wxStaticText( this, wxID_ANY, wxT("Templates path"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextTpath->Wrap( -1 );
|
||||
bmainSizer->Add( m_staticTextTpath, 0, wxRIGHT|wxLEFT, 5 );
|
||||
bmainSizer->Add( m_staticTextTpath, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_textCtrlTemplatePath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
||||
bmainSizer->Add( m_textCtrlTemplatePath, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
wxBoxSizer* bsizerTemplateSelector;
|
||||
bsizerTemplateSelector = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_tcTemplatePath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
||||
bsizerTemplateSelector->Add( m_tcTemplatePath, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_buttonBrowse = new wxButton( this, wxID_ANY, wxT("Browse"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
|
||||
bsizerTemplateSelector->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
|
||||
|
||||
m_buttonValidate = new wxButton( this, wxID_ANY, wxT("Validate"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
|
||||
bsizerTemplateSelector->Add( m_buttonValidate, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
|
||||
|
||||
|
||||
bmainSizer->Add( bsizerTemplateSelector, 0, wxEXPAND, 5 );
|
||||
|
||||
m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
bmainSizer->Add( m_staticline, 0, wxEXPAND | wxALL, 5 );
|
||||
|
||||
m_sdbSizer = new wxStdDialogButtonSizer();
|
||||
m_sdbSizerOK = new wxButton( this, wxID_OK );
|
||||
|
@ -47,12 +62,16 @@ DIALOG_TEMPLATE_SELECTOR_BASE::DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent,
|
|||
|
||||
// Connect Events
|
||||
m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnPageChange ), NULL, this );
|
||||
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onDirectoryBrowseClicked ), NULL, this );
|
||||
m_buttonValidate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onValidatePath ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_TEMPLATE_SELECTOR_BASE::~DIALOG_TEMPLATE_SELECTOR_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnPageChange ), NULL, this );
|
||||
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onDirectoryBrowseClicked ), NULL, this );
|
||||
m_buttonValidate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onValidatePath ), NULL, this );
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,15 +79,15 @@ TEMPLATE_SELECTION_PANEL_BASE::TEMPLATE_SELECTION_PANEL_BASE( wxWindow* parent,
|
|||
{
|
||||
m_SizerBase = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_scrolledWindow1 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL );
|
||||
m_scrolledWindow1->SetScrollRate( 5, 5 );
|
||||
m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL );
|
||||
m_scrolledWindow->SetScrollRate( 5, 5 );
|
||||
m_SizerChoice = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
|
||||
m_scrolledWindow1->SetSizer( m_SizerChoice );
|
||||
m_scrolledWindow1->Layout();
|
||||
m_SizerChoice->Fit( m_scrolledWindow1 );
|
||||
m_SizerBase->Add( m_scrolledWindow1, 0, wxEXPAND | wxALL, 3 );
|
||||
m_scrolledWindow->SetSizer( m_SizerChoice );
|
||||
m_scrolledWindow->Layout();
|
||||
m_SizerChoice->Fit( m_scrolledWindow );
|
||||
m_SizerBase->Add( m_scrolledWindow, 0, wxEXPAND | wxALL, 3 );
|
||||
|
||||
|
||||
this->SetSizer( m_SizerBase );
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Oct 8 2012)
|
||||
// C++ code generated with wxFormBuilder (version Jun 5 2014)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -22,8 +22,9 @@ class DIALOG_SHIM;
|
|||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/scrolwin.h>
|
||||
#include <wx/panel.h>
|
||||
|
@ -46,13 +47,18 @@ class DIALOG_TEMPLATE_SELECTOR_BASE : public DIALOG_SHIM
|
|||
wxNotebook* m_notebook;
|
||||
wxHtmlWindow* m_htmlWin;
|
||||
wxStaticText* m_staticTextTpath;
|
||||
wxTextCtrl* m_textCtrlTemplatePath;
|
||||
wxTextCtrl* m_tcTemplatePath;
|
||||
wxButton* m_buttonBrowse;
|
||||
wxButton* m_buttonValidate;
|
||||
wxStaticLine* m_staticline;
|
||||
wxStdDialogButtonSizer* m_sdbSizer;
|
||||
wxButton* m_sdbSizerOK;
|
||||
wxButton* m_sdbSizerCancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnPageChange( wxNotebookEvent& event ) { event.Skip(); }
|
||||
virtual void onDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onValidatePath( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
@ -73,7 +79,7 @@ class TEMPLATE_SELECTION_PANEL_BASE : public wxPanel
|
|||
|
||||
public:
|
||||
wxBoxSizer* m_SizerBase;
|
||||
wxScrolledWindow* m_scrolledWindow1;
|
||||
wxScrolledWindow* m_scrolledWindow;
|
||||
wxBoxSizer* m_SizerChoice;
|
||||
|
||||
TEMPLATE_SELECTION_PANEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,140 ), long style = wxNO_BORDER|wxTAB_TRAVERSAL );
|
||||
|
|
|
@ -108,13 +108,13 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName,
|
|||
templatePath = GetOSXKicadDataDir() + sep + wxT( "template" );
|
||||
#endif
|
||||
|
||||
ps->AddPage( _( "System Templates" ), templatePath );
|
||||
ps->AddTemplatesPage( _( "System Templates" ), templatePath );
|
||||
|
||||
// Add a new tab for user templates
|
||||
wxFileName userPath = wxStandardPaths::Get().GetDocumentsDir() +
|
||||
sep + wxT( "kicad" ) + sep + wxT( "template" ) + sep;
|
||||
|
||||
ps->AddPage( _( "User Templates" ), userPath );
|
||||
ps->AddTemplatesPage( _( "User Templates" ), userPath );
|
||||
|
||||
// Check to see if a custom template location is available and setup a
|
||||
// new selection tab if there is.
|
||||
|
@ -128,15 +128,15 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName,
|
|||
|
||||
wxFileName envPath = envStr;
|
||||
|
||||
ps->AddPage( _( "Portable Templates" ), envPath );
|
||||
ps->AddTemplatesPage( _( "Portable Templates" ), envPath );
|
||||
}
|
||||
|
||||
// Show the project template selector dialog
|
||||
int result = ps->ShowModal();
|
||||
|
||||
if( (result != wxID_OK) || (ps->GetWidget() == NULL) )
|
||||
if( ( result != wxID_OK ) || ( ps->GetSelectedTemplate() == NULL ) )
|
||||
{
|
||||
if( ps->GetWidget() == NULL )
|
||||
if( ps->GetSelectedTemplate() == NULL )
|
||||
{
|
||||
wxMessageBox( _( "No project template was selected. Cannot generate new "
|
||||
"project." ),
|
||||
|
@ -149,7 +149,7 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName,
|
|||
{
|
||||
// The selected template widget contains the template we're attempting to use to
|
||||
// create a project
|
||||
if( !ps->GetWidget()->GetTemplate()->CreateProject( newProjectName ) )
|
||||
if( !ps->GetSelectedTemplate()->CreateProject( newProjectName ) )
|
||||
{
|
||||
wxMessageBox( _( "Problem whilst creating new project from template!" ),
|
||||
_( "Template Error" ),
|
||||
|
|
Loading…
Reference in New Issue