161 m_providers.push_back( std::make_unique<STARTWIZARD_PROVIDER_SETTINGS>() );
162 m_providers.push_back( std::make_unique<STARTWIZARD_PROVIDER_LIBRARIES>() );
163 m_providers.push_back( std::make_unique<STARTWIZARD_PROVIDER_PRIVACY>() );
169 bool wizardRequired = std::ranges::any_of( std::as_const(
m_providers ),
170 [](
const std::unique_ptr<STARTWIZARD_PROVIDER>& aProvider ) ->
bool
172 return aProvider->NeedsUserInput();
175 if( !wizardRequired )
180 m_wizard =
new wxWizard( aParent, wxID_ANY,
_(
"KiCad Setup" ) );
181 m_wizard->SetWindowStyleFlag( wxRESIZE_BORDER );
184 wxWizardPageSimple* lastPage =
nullptr;
187 for( std::unique_ptr<STARTWIZARD_PROVIDER>& provider :
m_providers )
189 if( !provider->NeedsUserInput() )
192 provider->SetWasShown(
true );
195 wxPanel* panel = provider->GetWizardPanel( page->
GetContentParent(),
this );
198 if( lastPage !=
nullptr )
200 lastPage->Chain( page );
204 firstPage->Chain( page );
211 if( size.x > minPageSize.x )
212 minPageSize.x = size.x;
214 if( size.y > minPageSize.y )
215 minPageSize.y = size.y;
221 static constexpr int WIZARD_CHROME_HEIGHT = 120;
222 static constexpr int WIZARD_MARGIN = 40;
224 wxSize pageSize = minPageSize + wxSize( 10, 10 );
226 int displayIdx = wxDisplay::GetFromWindow( aParent ? aParent : wxTheApp->GetTopWindow() );
228 if( displayIdx == wxNOT_FOUND )
231 wxRect displayArea = wxDisplay( (
unsigned int) displayIdx ).GetClientArea();
232 int maxPageHeight = displayArea.GetHeight() - WIZARD_CHROME_HEIGHT - WIZARD_MARGIN;
234 if( maxPageHeight > 0 && pageSize.y > maxPageHeight )
235 pageSize.y = maxPageHeight;
238 firstPage->
SetWrap( pageSize.x );
240 m_wizard->Bind( wxEVT_WIZARD_CANCEL,
241 [&]( wxWizardEvent& aEvt )
243 if(
IsOK( aParent,
_(
"Are you sure? If you cancel KiCad setup, default settings "
244 "will be chosen for you." ) ) )
246 for( std::unique_ptr<STARTWIZARD_PROVIDER>& provider :
m_providers )
248 provider->ApplyDefaults();
257 if(
m_wizard->RunWizard( firstPage ) )
259 for( std::unique_ptr<STARTWIZARD_PROVIDER>& provider :
m_providers )
261 if( !provider->WasShown() )
STARTWIZARD_PAGE(wxWizard *aParent, const wxString &aPageTitle)
wxScrolledWindow * m_scrolledWindow
void AddContent(wxPanel *aContent)
wxSize GetContentMinSize() const
wxWindow * GetContentParent() const
void SetWrap(int aWidth) const
wxStaticText * m_welcomeText
STARTWIZARD_WELCOME_PAGE(wxWizard *aParent)