From 416e54f0d57f9845a45b48368b5f1f09b74f9144 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 4 Aug 2025 14:57:10 -0700 Subject: [PATCH] Update template selector to modern webview Allow more attractive templates. Start of building singular template+new project layout Fixes https://gitlab.com/kicad/code/kicad/-/issues/15987 --- CMakeLists.txt | 2 +- common/widgets/webview_panel.cpp | 91 +++--- include/widgets/webview_panel.h | 5 +- kicad/dialogs/dialog_template_selector.cpp | 182 +++++++++++- kicad/dialogs/dialog_template_selector.h | 4 +- .../dialogs/dialog_template_selector_base.cpp | 35 ++- .../dialogs/dialog_template_selector_base.fbp | 279 +++++++++--------- kicad/dialogs/dialog_template_selector_base.h | 10 +- 8 files changed, 402 insertions(+), 206 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97d3097cb9..b594991bf5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1032,7 +1032,7 @@ endif() # See line 49 of cmake/FindwxWidgets.cmake set( wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} --static=no ) -find_package( wxWidgets ${wxWidgets_REQ_VERSION} COMPONENTS gl aui adv html core net base propgrid xml stc richtext REQUIRED ) +find_package( wxWidgets ${wxWidgets_REQ_VERSION} COMPONENTS gl aui adv html core net base propgrid xml stc richtext webview REQUIRED ) # Include wxWidgets macros. include( ${wxWidgets_USE_FILE} ) diff --git a/common/widgets/webview_panel.cpp b/common/widgets/webview_panel.cpp index f743abbe36..946b83f20e 100644 --- a/common/widgets/webview_panel.cpp +++ b/common/widgets/webview_panel.cpp @@ -6,12 +6,19 @@ #include #include -WEBVIEW_PANEL::WEBVIEW_PANEL( wxWindow* parent ) : - wxPanel( parent ), - m_browser( wxWebView::New() ) +WEBVIEW_PANEL::WEBVIEW_PANEL( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos, + const wxSize& aSize, const int aStyle ) + : wxPanel( aParent, aId, aPos, aSize, aStyle ), + m_initialized( false ), + m_browser( wxWebView::New() ) { wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL ); + if( !wxGetEnv( wxT( "WEBKIT_DISABLE_COMPOSITING_MODE" ), nullptr ) ) + { + wxSetEnv( wxT( "WEBKIT_DISABLE_COMPOSITING_MODE" ), wxT( "1" ) ); + } + #ifdef __WXMAC__ m_browser->RegisterHandler( wxSharedPtr( new wxWebViewArchiveHandler( "wxfs" ) ) ); m_browser->RegisterHandler( wxSharedPtr( new wxWebViewFSHandler( "memory" ) ) ); @@ -38,14 +45,32 @@ WEBVIEW_PANEL::~WEBVIEW_PANEL() { } -void WEBVIEW_PANEL::LoadURL( const wxString& url ) +void WEBVIEW_PANEL::LoadURL( const wxString& aURL ) +{ + if( aURL.starts_with( "file:/" ) && !aURL.starts_with( "file:///" ) ) + { + wxString new_url = wxString( "file:///" ) + aURL.AfterFirst( '/' ); + m_browser->LoadURL( new_url ); + return; + } + + if( !aURL.StartsWith( "http://" ) && !aURL.StartsWith( "https://" ) && !aURL.StartsWith( "file://" ) ) + { + wxLogError( "Invalid URL: %s", aURL ); + return; + } + + m_browser->LoadURL( aURL ); +} + +void WEBVIEW_PANEL::SetPage( const wxString& aHtmlContent ) { - m_browser->LoadURL( url ); + m_browser->SetPage( aHtmlContent, "file://" ); } -bool WEBVIEW_PANEL::AddMessageHandler( const wxString& name, MESSAGE_HANDLER handler ) +bool WEBVIEW_PANEL::AddMessageHandler( const wxString& aName, MESSAGE_HANDLER aHandler ) { - m_msgHandlers.emplace( name, std::move(handler) ); + m_msgHandlers.emplace( aName, std::move(aHandler) ); return true; } @@ -54,18 +79,18 @@ void WEBVIEW_PANEL::ClearMessageHandlers() m_msgHandlers.clear(); } -void WEBVIEW_PANEL::OnNavigationRequest( wxWebViewEvent& evt ) +void WEBVIEW_PANEL::OnNavigationRequest( wxWebViewEvent& aEvt ) { // Default behavior: open external links in the system browser - if( !evt.GetURL().StartsWith( "file:" ) && !evt.GetURL().StartsWith( "wxfs:" ) - && !evt.GetURL().StartsWith( "memory:" ) ) + bool isExternal = aEvt.GetURL().StartsWith( "http://" ) || aEvt.GetURL().StartsWith( "https://" ); + if( isExternal ) { - wxLaunchDefaultBrowser( evt.GetURL() ); - evt.Veto(); + wxLaunchDefaultBrowser( aEvt.GetURL() ); + aEvt.Veto(); } } -void WEBVIEW_PANEL::OnWebViewLoaded( wxWebViewEvent& evt ) +void WEBVIEW_PANEL::OnWebViewLoaded( wxWebViewEvent& aEvt ) { if( !m_initialized ) { @@ -116,45 +141,45 @@ void WEBVIEW_PANEL::OnWebViewLoaded( wxWebViewEvent& evt ) } } -void WEBVIEW_PANEL::OnNewWindow( wxWebViewEvent& evt ) +void WEBVIEW_PANEL::OnNewWindow( wxWebViewEvent& aEvt ) { - m_browser->LoadURL( evt.GetURL() ); - evt.Veto(); // Prevent default behavior of opening a new window - wxLogTrace( "webview", "New window requested for URL: %s", evt.GetURL() ); - wxLogTrace( "webview", "Target: %s", evt.GetTarget() ); - wxLogTrace( "webview", "Action flags: %d", static_cast(evt.GetNavigationAction()) ); - wxLogTrace( "webview", "Message handler: %s", evt.GetMessageHandler() ); + m_browser->LoadURL( aEvt.GetURL() ); + aEvt.Veto(); // Prevent default behavior of opening a new window + wxLogTrace( "webview", "New window requested for URL: %s", aEvt.GetURL() ); + wxLogTrace( "webview", "Target: %s", aEvt.GetTarget() ); + wxLogTrace( "webview", "Action flags: %d", static_cast(aEvt.GetNavigationAction()) ); + wxLogTrace( "webview", "Message handler: %s", aEvt.GetMessageHandler() ); } -void WEBVIEW_PANEL::OnScriptMessage( wxWebViewEvent& evt ) +void WEBVIEW_PANEL::OnScriptMessage( wxWebViewEvent& aEvt ) { - wxLogTrace( "webview", "Script message received: %s for handler %s", evt.GetString(), evt.GetMessageHandler() ); + wxLogTrace( "webview", "Script message received: %s for handler %s", aEvt.GetString(), aEvt.GetMessageHandler() ); - if( evt.GetMessageHandler().IsEmpty() ) + if( aEvt.GetMessageHandler().IsEmpty() ) { - wxLogDebug( "No message handler specified for script message: %s", evt.GetString() ); + wxLogDebug( "No message handler specified for script message: %s", aEvt.GetString() ); return; } - auto it = m_msgHandlers.find( evt.GetMessageHandler() ); + auto it = m_msgHandlers.find( aEvt.GetMessageHandler() ); if( it == m_msgHandlers.end() ) { - wxLogDebug( "No handler registered for message: %s", evt.GetMessageHandler() ); + wxLogDebug( "No handler registered for message: %s", aEvt.GetMessageHandler() ); return; } // Call the registered handler with the message - wxLogTrace( "webview", "Calling handler for message: %s", evt.GetMessageHandler() ); - it->second( evt.GetString() ); + wxLogTrace( "webview", "Calling handler for message: %s", aEvt.GetMessageHandler() ); + it->second( aEvt.GetString() ); } -void WEBVIEW_PANEL::OnScriptResult( wxWebViewEvent& evt ) +void WEBVIEW_PANEL::OnScriptResult( wxWebViewEvent& aEvt ) { - if( evt.IsError() ) - wxLogDebug( "Async script execution failed: %s", evt.GetString() ); + if( aEvt.IsError() ) + wxLogDebug( "Async script execution failed: %s", aEvt.GetString() ); } -void WEBVIEW_PANEL::OnError( wxWebViewEvent& evt ) +void WEBVIEW_PANEL::OnError( wxWebViewEvent& aEvt ) { - wxLogDebug( "WebView error: %s", evt.GetString() ); + wxLogDebug( "WebView error: %s", aEvt.GetString() ); } diff --git a/include/widgets/webview_panel.h b/include/widgets/webview_panel.h index c6607a5b77..2b1a053526 100644 --- a/include/widgets/webview_panel.h +++ b/include/widgets/webview_panel.h @@ -11,12 +11,15 @@ class WEBVIEW_PANEL : public wxPanel public: using MESSAGE_HANDLER = std::function; - explicit WEBVIEW_PANEL( wxWindow* parent ); + explicit WEBVIEW_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, const int style = 0 ); ~WEBVIEW_PANEL() override; wxWebView* GetWebView() const { return m_browser; } void LoadURL( const wxString& url ); + void SetPage( const wxString& htmlContent ); + bool AddMessageHandler( const wxString& name, MESSAGE_HANDLER handler ); void ClearMessageHandlers(); diff --git a/kicad/dialogs/dialog_template_selector.cpp b/kicad/dialogs/dialog_template_selector.cpp index df555c3cff..392d28cdac 100644 --- a/kicad/dialogs/dialog_template_selector.cpp +++ b/kicad/dialogs/dialog_template_selector.cpp @@ -31,6 +31,89 @@ #include #include +static const wxString GetWelcomeHtml() +{ + return wxString( + "" + "" + "" + "" + "" + "KiCad Project Template Selector" + "" + "" + "" + "
" + "
" + "
KiCad 📑
" + "
" + _( "Project Template Selector" ) + "
" + "
" + "
" + "

" + _( "Welcome to Template Selection!" ) + "

" + "

" + _( "Choose from a variety of pre-configured project templates to jumpstart your PCB design. Templates provide ready-to-use project structures with common components, libraries, and design rules." ) + "

" + "
" + "
" + "
" + "

→ " + _( "Browse Templates" ) + "

" + "

" + _( "Navigate through the template tabs above to explore different categories of project templates. Each tab contains templates organized by type or complexity." ) + "

" + "
" + "
" + "

→ " + _( "Select a Template" ) + "

" + "

" + _( "Click on any template in the list to " ) + "" + _( "preview its details" ) + ". " + _( "The template information will appear in this panel, showing descriptions, included components, and project structure." ) + "

" + "
" + "
" + "

→ " + _( "Customize Path" ) + "

" + "

" + _( "Use the " ) + "" + _( "folder path field" ) + " " + _( "above to browse custom template directories. Click the folder icon to browse, or the refresh icon to reload templates." ) + "

" + "
" + "
" + "

→ " + _( "Create Project" ) + "

" + "

" + _( "Once you've found the right template, click " ) + "" + _( "OK" ) + " " + _( "to create a new project based on the selected template. Your project will inherit all template settings and files." ) + "

" + "
" + "
" + "
" + "

" + _( "What You Get with Templates" ) + "

" + "
    " + "
  • " + _( "Pre-configured libraries" ) + " " + _( "- Common components and footprints already linked" ) + "
  • " + "
  • " + _( "Design rules" ) + " " + _( "- Appropriate electrical and mechanical constraints" ) + "
  • " + "
  • " + _( "Layer stackups" ) + " " + _( "- Optimized for the intended application" ) + "
  • " + "
  • " + _( "Component placement" ) + " " + _( "- Basic layout and routing guidelines" ) + "
  • " + "
  • " + _( "Documentation" ) + " " + _( "- README files and design notes" ) + "
  • " + "
  • " + _( "Manufacturing files" ) + " " + _( "- Gerber and drill file configurations" ) + "
  • " + "
" + "
" + "
" + "

" + _( "Pro Tips" ) + "

" + "

" + _( "Start Simple:" ) + " " + _( "Begin with basic templates and add more elements as you go." ) + "

" + "

" + _( "Customize Later:" ) + " " + _( "Templates are starting points - you can modify libraries, rules, and layouts after project creation." ) + "

" + "

" + _( "Save Your Own:" ) + " " + _( "Once you develop preferred settings, create a custom template for future projects." ) + "

" + "
" + "
" + "" + "" +); +} TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, const wxString& aPath ) : @@ -107,10 +190,32 @@ void TEMPLATE_WIDGET::OnMouse( wxMouseEvent& event ) void DIALOG_TEMPLATE_SELECTOR::OnPageChange( wxNotebookEvent& event ) { - int page = event.GetSelection(); + int newPage = event.GetSelection(); + int oldPage = event.GetOldSelection(); - if( page != wxNOT_FOUND && (unsigned)page < m_panels.size() ) - m_tcTemplatePath->SetValue( m_panels[page]->GetPath() ); + // Move webview panel from old page to new page + if( oldPage != wxNOT_FOUND && (unsigned)oldPage < m_panels.size() ) + { + // Detach webview from old panel + m_panels[oldPage]->m_SizerBase->Detach( m_webviewPanel ); + m_panels[oldPage]->Layout(); + } + + if( newPage != wxNOT_FOUND && (unsigned)newPage < m_panels.size() ) + { + // Reparent the webview to the new panel + m_webviewPanel->Reparent( m_panels[newPage] ); + + // Attach webview to new panel + m_panels[newPage]->m_SizerBase->Add( m_webviewPanel, 1, wxEXPAND | wxALL, 5 ); + m_panels[newPage]->Layout(); + + // Update template path + m_tcTemplatePath->SetValue( m_panels[newPage]->GetPath() ); + + // Reset to welcome page when switching tabs if no template selected + m_webviewPanel->SetPage( GetWelcomeHtml() ); + } event.Skip(); } @@ -125,7 +230,6 @@ DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent, const wxP m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) ); m_reloadButton->SetBitmap( KiBitmapBundle( BITMAPS::small_refresh ) ); - m_htmlWin->SetPage( _( "

Template Selector

" ) ); m_selectedWidget = nullptr; for( auto& [title, pathFname] : aTitleDirMap ) @@ -144,6 +248,29 @@ DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent, const wxP buildPageContent( path, m_notebook->GetPageCount() - 1 ); } + // Move webview panel from dialog to first template selection panel + if( !m_panels.empty() ) + { + // Find the sizer containing the webview and detach it + wxSizer* parentSizer = m_webviewPanel->GetContainingSizer(); + if( parentSizer ) + { + parentSizer->Detach( m_webviewPanel ); + } + + // Reparent the webview to the first panel + m_webviewPanel->Reparent( m_panels[0] ); + + // Add webview to first panel + m_panels[0]->m_SizerBase->Add( m_webviewPanel, 1, wxEXPAND | wxALL, 5 ); + m_panels[0]->Layout(); + } + + // Set welcome HTML after dialog is fully constructed + CallAfter( [this]() { + m_webviewPanel->SetPage( GetWelcomeHtml() ); + }); + // When all widgets have the size fixed, call finishDialogSettings to update sizers finishDialogSettings(); } @@ -155,7 +282,30 @@ void DIALOG_TEMPLATE_SELECTOR::SetWidget( TEMPLATE_WIDGET* aWidget ) m_selectedWidget->Unselect(); m_selectedWidget = aWidget; - SetHtml( m_selectedWidget->GetTemplate()->GetHtmlFile() ); + wxFileName htmlFile = aWidget->GetTemplate()->GetHtmlFile(); + + if( htmlFile.FileExists() && htmlFile.IsFileReadable() ) + { + m_webviewPanel->LoadURL( wxFileName::FileNameToURL( htmlFile ) ); + } + else + { + // Fallback to a simple template info page if no HTML file exists + wxString templateHtml = wxString::Format( + "" + "" + "
" + "

%s

" + "

Template selected. Click OK to create a new project based on this template.

" + "
", + *aWidget->GetTemplate()->GetTitle() + ); + m_webviewPanel->SetPage( templateHtml ); + } } @@ -267,22 +417,28 @@ void DIALOG_TEMPLATE_SELECTOR::replaceCurrentPage() wxString title = m_notebook->GetPageText( page ); wxString currPath = m_tcTemplatePath->GetValue(); + // Detach webview from current panel before deleting it + if( (unsigned)page < m_panels.size() ) + { + m_panels[page]->m_SizerBase->Detach( m_webviewPanel ); + } + m_notebook->DeletePage( page ); TEMPLATE_SELECTION_PANEL* tpanel = new TEMPLATE_SELECTION_PANEL( m_notebook, currPath ); m_panels[page] = tpanel; m_notebook->InsertPage( page, tpanel, title, true ); + // Reparent and add webview back to the new panel + m_webviewPanel->Reparent( tpanel ); + tpanel->m_SizerBase->Add( m_webviewPanel, 1, wxEXPAND | wxALL, 5 ); + buildPageContent( m_tcTemplatePath->GetValue(), page ); m_selectedWidget = nullptr; - Layout(); -} - + // Reset to welcome page after rebuilding + m_webviewPanel->SetPage( GetWelcomeHtml() ); -void DIALOG_TEMPLATE_SELECTOR::OnHtmlLinkActivated( wxHtmlLinkEvent& event ) -{ - wxString url = event.GetLinkInfo().GetHref(); - wxLaunchDefaultBrowser( url ); -} + Layout(); +} \ No newline at end of file diff --git a/kicad/dialogs/dialog_template_selector.h b/kicad/dialogs/dialog_template_selector.h index 0bd5f61d0c..09950c9b9e 100644 --- a/kicad/dialogs/dialog_template_selector.h +++ b/kicad/dialogs/dialog_template_selector.h @@ -26,6 +26,7 @@ #define PROJECT_TEMPLATE_SELECTOR_H #include +#include #include "project_template.h" #include @@ -104,7 +105,7 @@ protected: private: void SetHtml( const wxFileName& aFilename ) { - m_htmlWin->LoadPage( aFilename.GetFullPath() ); + m_webviewPanel->LoadURL( aFilename.GetFullPath() ); } private: @@ -114,7 +115,6 @@ private: void OnPageChange( wxNotebookEvent& event ) override; void onDirectoryBrowseClicked( wxCommandEvent& event ) override; void onReload( wxCommandEvent& event ) override; - void OnHtmlLinkActivated( wxHtmlLinkEvent& event ) override; protected: std::vector m_panels; diff --git a/kicad/dialogs/dialog_template_selector_base.cpp b/kicad/dialogs/dialog_template_selector_base.cpp index 4fb6421a95..7bf446c290 100644 --- a/kicad/dialogs/dialog_template_selector_base.cpp +++ b/kicad/dialogs/dialog_template_selector_base.cpp @@ -1,11 +1,12 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "widgets/std_bitmap_button.h" +#include "widgets/webview_panel.h" #include "dialog_template_selector_base.h" @@ -37,14 +38,20 @@ DIALOG_TEMPLATE_SELECTOR_BASE::DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, bmainSizer->Add( bsizerTemplateSelector, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); + wxBoxSizer* bSizer6; + bSizer6 = new wxBoxSizer( wxVERTICAL ); + m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bmainSizer->Add( m_notebook, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bSizer6->Add( m_notebook, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + + m_webviewPanel = new WEBVIEW_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_webviewPanel->SetMinSize( wxSize( 700,300 ) ); + + bSizer6->Add( m_webviewPanel, 1, wxEXPAND | wxALL, 5 ); - m_htmlWin = new HTML_WINDOW( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxHW_SCROLLBAR_AUTO ); - m_htmlWin->SetMinSize( wxSize( 700,300 ) ); - bmainSizer->Add( m_htmlWin, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + bmainSizer->Add( bSizer6, 1, wxEXPAND, 5 ); m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); @@ -66,7 +73,6 @@ DIALOG_TEMPLATE_SELECTOR_BASE::DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onDirectoryBrowseClicked ), NULL, this ); m_reloadButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onReload ), NULL, this ); m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnPageChange ), NULL, this ); - m_htmlWin->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnHtmlLinkActivated ), NULL, this ); } DIALOG_TEMPLATE_SELECTOR_BASE::~DIALOG_TEMPLATE_SELECTOR_BASE() @@ -75,7 +81,6 @@ DIALOG_TEMPLATE_SELECTOR_BASE::~DIALOG_TEMPLATE_SELECTOR_BASE() m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onDirectoryBrowseClicked ), NULL, this ); m_reloadButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onReload ), NULL, this ); m_notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnPageChange ), NULL, this ); - m_htmlWin->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnHtmlLinkActivated ), NULL, this ); } @@ -83,19 +88,19 @@ TEMPLATE_SELECTION_PANEL_BASE::TEMPLATE_SELECTION_PANEL_BASE( wxWindow* parent, { this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); - m_SizerBase = new wxBoxSizer( wxVERTICAL ); + m_SizerBase = new wxBoxSizer( wxHORIZONTAL ); - m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxALWAYS_SHOW_SB|wxHSCROLL ); - m_scrolledWindow->SetScrollRate( 25, 0 ); + m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxALWAYS_SHOW_SB|wxVSCROLL ); + m_scrolledWindow->SetScrollRate( 0, 25 ); m_scrolledWindow->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); - m_SizerChoice = new wxBoxSizer( wxHORIZONTAL ); + m_SizerChoice = new wxBoxSizer( wxVERTICAL ); m_scrolledWindow->SetSizer( m_SizerChoice ); m_scrolledWindow->Layout(); m_SizerChoice->Fit( m_scrolledWindow ); - m_SizerBase->Add( m_scrolledWindow, 1, wxEXPAND, 10 ); + m_SizerBase->Add( m_scrolledWindow, 0, wxEXPAND, 10 ); this->SetSizer( m_SizerBase ); @@ -113,17 +118,17 @@ TEMPLATE_WIDGET_BASE::TEMPLATE_WIDGET_BASE( wxWindow* parent, wxWindowID id, con this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); wxBoxSizer* bSizerMain; - bSizerMain = new wxBoxSizer( wxVERTICAL ); + bSizerMain = new wxBoxSizer( wxHORIZONTAL ); m_bitmapIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 64,64 ), 0 ); m_bitmapIcon->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); m_bitmapIcon->SetMinSize( wxSize( 64,64 ) ); - bSizerMain->Add( m_bitmapIcon, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizerMain->Add( m_bitmapIcon, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_staticTitle = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL ); m_staticTitle->Wrap( 100 ); - bSizerMain->Add( m_staticTitle, 1, wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 2 ); + bSizerMain->Add( m_staticTitle, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT|wxRIGHT, 2 ); this->SetSizer( bSizerMain ); diff --git a/kicad/dialogs/dialog_template_selector_base.fbp b/kicad/dialogs/dialog_template_selector_base.fbp index 64b15495a7..2be002eaa1 100644 --- a/kicad/dialogs/dialog_template_selector_base.fbp +++ b/kicad/dialogs/dialog_template_selector_base.fbp @@ -68,16 +68,16 @@ 5 wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP 0 - + bsizerTemplateSelector wxHORIZONTAL none - + 5 wxALIGN_CENTER_VERTICAL|wxRIGHT 0 - + 1 1 1 @@ -135,11 +135,11 @@ -1 - + 2 wxALIGN_CENTER_VERTICAL|wxRIGHT 1 - + 1 1 1 @@ -200,11 +200,11 @@ - + 5 wxTOP|wxBOTTOM|wxRIGHT 0 - + 1 1 1 @@ -275,11 +275,11 @@ onDirectoryBrowseClicked - + 5 wxBOTTOM|wxTOP 0 - + 1 1 1 @@ -354,123 +354,132 @@ 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - -1,-1 - - 0 - -1,-1 - 1 - m_notebook - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - OnPageChange - - - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + wxEXPAND 1 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - 700,300 - 1 - m_htmlWin - 1 - - - public - 1 - - Resizable - 1 - -1,-1 - wxHW_SCROLLBAR_AUTO - HTML_WINDOW; widgets/html_window.h; - 0 - - - - - OnHtmlLinkActivated + + + bSizer6 + wxVERTICAL + none + + 5 + wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + -1,-1 + + 0 + -1,-1 + 1 + m_notebook + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + OnPageChange + + + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 700,300 + 1 + m_webviewPanel + 1 + + + protected + 1 + + Resizable + 1 + + WEBVIEW_PANEL; widgets/webview_panel.h; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + @@ -520,12 +529,12 @@ m_SizerBase - wxVERTICAL + wxHORIZONTAL public 10 wxEXPAND - 1 + 0 1 1 @@ -570,8 +579,8 @@ 1 Resizable - 25 - 0 + 0 + 25 1 ; ; forward_declare @@ -579,11 +588,11 @@ - wxALWAYS_SHOW_SB|wxHSCROLL - + wxALWAYS_SHOW_SB|wxVSCROLL + m_SizerChoice - wxHORIZONTAL + wxVERTICAL public @@ -617,11 +626,11 @@ bSizerMain - wxVERTICAL + wxHORIZONTAL none 5 - wxALL|wxALIGN_CENTER_HORIZONTAL + wxALIGN_CENTER_VERTICAL|wxALL 0 1 @@ -680,7 +689,7 @@ 2 - wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT + wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxLEFT|wxRIGHT 1 1 diff --git a/kicad/dialogs/dialog_template_selector_base.h b/kicad/dialogs/dialog_template_selector_base.h index 6764925035..4f21380ea7 100644 --- a/kicad/dialogs/dialog_template_selector_base.h +++ b/kicad/dialogs/dialog_template_selector_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -11,8 +11,8 @@ #include #include class STD_BITMAP_BUTTON; +class WEBVIEW_PANEL; -#include "widgets/html_window.h" #include "dialog_shim.h" #include #include @@ -28,10 +28,9 @@ class STD_BITMAP_BUTTON; #include #include #include -#include +#include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -49,6 +48,7 @@ class DIALOG_TEMPLATE_SELECTOR_BASE : public DIALOG_SHIM STD_BITMAP_BUTTON* m_browseButton; STD_BITMAP_BUTTON* m_reloadButton; wxNotebook* m_notebook; + WEBVIEW_PANEL* m_webviewPanel; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; @@ -57,11 +57,9 @@ class DIALOG_TEMPLATE_SELECTOR_BASE : public DIALOG_SHIM virtual void onDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } virtual void onReload( wxCommandEvent& event ) { event.Skip(); } virtual void OnPageChange( wxNotebookEvent& event ) { event.Skip(); } - virtual void OnHtmlLinkActivated( wxHtmlLinkEvent& event ) { event.Skip(); } public: - HTML_WINDOW* m_htmlWin; DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Project Template Selector"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );