Audacity 3.2.0
SplashDialog.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 SplashDialog.cpp
6
7 James Crook
8
9********************************************************************//********************************************************************/
21
22
23
24#include "SplashDialog.h"
25
26
27
28#include <wx/frame.h>
29#include <wx/html/htmlwin.h>
30#include <wx/statbmp.h>
31
32#include "FileNames.h"
33#include "Project.h"
34#include "ProjectWindows.h"
35#include "ShuttleGui.h"
36#include "AudacityMessageBox.h"
37#include "HelpSystem.h"
38
39#include "AllThemeResources.h"
40#include "Prefs.h"
41#include "HelpText.h"
42
43#include "../images/AudacityLogoWithName.xpm"
44
45#ifdef HAS_WHATS_NEW
46
47#include "MemoryX.h"
48#include <wx/fs_mem.h>
49
50namespace
51{
52# include "../images/WhatsNewBtn.jpeg.h"
53
54struct FSHelper final
55{
56 FSHelper()
57 : mMemoryFSHandler(std::make_unique<wxMemoryFSHandler>())
58 {
59 wxFileSystem::AddHandler(mMemoryFSHandler.get());
60
61 wxMemoryFSHandler::AddFile(
62 "whats_new_btn.jpeg", bin2c_whats_new_btn_jpeg,
63 sizeof(bin2c_whats_new_btn_jpeg));
64 }
65
66 ~FSHelper()
67 {
68 wxMemoryFSHandler::RemoveFile("whats_new_btn.jpeg");
69 wxFileSystem::RemoveHandler(mMemoryFSHandler.get());
70 }
71
72private:
73 std::unique_ptr<wxMemoryFSHandler> mMemoryFSHandler;
74};
75
76} // namespace
77
78constexpr int HTMLWindowHeight = 425;
79#else
80constexpr int HTMLWindowHeight = 280;
81#endif
82
84
85enum
86{
88};
89
90BEGIN_EVENT_TABLE(SplashDialog, wxDialogWrapper)
94
96
97void SplashDialog::DoHelpWelcome( AudacityProject &project )
98{
99 Show2( &GetProjectFrame( project ) );
100}
101
103 : wxDialogWrapper(parent, -1, XO("Welcome to Audacity!"),
104 wxPoint( -1, 60 ), // default x position, y position 60 pixels from top of screen.
105 wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
106{
107 SetName();
108 m_pLogo = NULL; //v
109 ShuttleGui S( this, eIsCreating );
110 Populate( S );
111 Fit();
112 this->Centre();
113 int x,y;
114 GetPosition( &x, &y );
115 Move( x, 60 );
116}
117
118void SplashDialog::OnChar(wxMouseEvent &event)
119{
120 if ( event.ShiftDown() && event.ControlDown() )
121 wxLaunchDefaultBrowser("https://www.audacityteam.org");
122}
123
125{
126 bool bShow;
127 gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &bShow, true );
128 S.StartVerticalLay(1);
129
130 //v For now, change to AudacityLogoWithName via old-fashioned ways, not Theme.
131 m_pLogo = std::make_unique<wxBitmap>((const char **) AudacityLogoWithName_xpm); //v
132
133
134 // JKC: Resize to 50% of size. Later we may use a smaller xpm as
135 // our source, but this allows us to tweak the size - if we want to.
136 // It also makes it easier to revert to full size if we decide to.
137 const float fScale=0.5f;// smaller size.
138 wxImage RescaledImage( m_pLogo->ConvertToImage() );
139 wxColour MainColour(
140 RescaledImage.GetRed(1,1),
141 RescaledImage.GetGreen(1,1),
142 RescaledImage.GetBlue(1,1));
143 this->SetBackgroundColour(MainColour);
144
145 // wxIMAGE_QUALITY_HIGH not supported by wxWidgets 2.6.1, or we would use it here.
146 RescaledImage.Rescale( (int)(LOGOWITHNAME_WIDTH * fScale), (int)(LOGOWITHNAME_HEIGHT *fScale) );
147 wxBitmap RescaledBitmap( RescaledImage );
148 wxStaticBitmap *const icon =
149 safenew wxStaticBitmap(S.GetParent(), -1,
150 //*m_pLogo, //v theTheme.Bitmap(bmpAudacityLogoWithName),
151 RescaledBitmap,
152 wxDefaultPosition,
153 wxSize((int)(LOGOWITHNAME_WIDTH*fScale), (int)(LOGOWITHNAME_HEIGHT*fScale)));
154
155 S.Prop(0)
156#if (0)
157 .ConnectRoot( wxEVT_LEFT_DOWN, &SplashDialog::OnChar)
158#endif
159 .AddWindow( icon );
160
161 mpHtml = safenew LinkingHtmlWindow(S.GetParent(), -1,
162 wxDefaultPosition, wxSize(506, HTMLWindowHeight),
163 wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
164 mpHtml->SetPage(HelpText( wxT("welcome") ));
165 S.Prop(1)
166 .Position( wxEXPAND )
167 .AddWindow( mpHtml );
168 S.Prop(0).StartMultiColumn(2, wxEXPAND);
169 S.SetStretchyCol( 1 );// Column 1 is stretchy...
170 {
171 S.SetBorder( 5 );
172 S.Id( DontShowID).AddCheckBox( XXO("Don't show this again at start up"), !bShow );
173 S.SetBorder( 5 );
174
175 S.Id(wxID_OK)
176 .Prop(0)
177 .AddButton(XXO("OK"), wxALIGN_RIGHT| wxALL, true);
178 }
179 S.EndVerticalLay();
180}
181
183{
184}
185
186void SplashDialog::OnDontShow( wxCommandEvent & Evt )
187{
188 bool bShow = !Evt.IsChecked();
189 gPrefs->Write(wxT("/GUI/ShowSplashScreen"), bShow );
190 gPrefs->Flush();
191}
192
193void SplashDialog::OnOK(wxCommandEvent & WXUNUSED(event))
194{
195 Show( false );
196
197}
198
199void SplashDialog::Show2( wxWindow * pParent )
200{
201#ifdef HAS_WHATS_NEW
202 FSHelper helper;
203#endif // HAS_WHATS_NEW
204
205 if( pSelf == NULL )
206 {
207 // pParent owns it
208 wxASSERT(pParent);
209 pSelf = safenew SplashDialog( pParent );
210 }
211 pSelf->mpHtml->SetPage(HelpText( wxT("welcome") ));
212 pSelf->Show( true );
213}
wxImage(22, 22)
wxT("CloseDown"))
#define LOGOWITHNAME_WIDTH
#define LOGOWITHNAME_HEIGHT
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
wxString HelpText(const wxString &Key)
Definition: HelpText.cpp:329
#define safenew
Definition: MemoryX.h:10
FileConfig * gPrefs
Definition: Prefs.cpp:70
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
accessors for certain important windows associated with each project
IMPLEMENT_CLASS(cloud::ShareAudioToolbar, ToolBar)
@ eIsCreating
Definition: ShuttleGui.h:37
constexpr int HTMLWindowHeight
@ DontShowID
#define S(N)
Definition: ToChars.cpp:64
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
An HtmlWindow that handles linked clicked - usually the link will go to our own local copy of the man...
Definition: HelpSystem.h:126
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
The SplashDialog shows help information for Audacity when Audacity starts up.
Definition: SplashDialog.h:21
void Populate(ShuttleGui &S)
SplashDialog(wxWindow *parent)
void OnOK(wxCommandEvent &event)
static void Show2(wxWindow *pParent)
void OnDontShow(wxCommandEvent &Evt)
void OnChar(wxMouseEvent &event)
virtual ~SplashDialog()
static SplashDialog * pSelf
Definition: SplashDialog.h:42
HtmlWindow * mpHtml
Definition: SplashDialog.h:40
std::unique_ptr< wxBitmap > m_pLogo
Definition: SplashDialog.h:41
STL namespace.