Audacity  3.0.3
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/dialog.h>
29 #include <wx/frame.h>
30 #include <wx/html/htmlwin.h>
31 #include <wx/button.h>
32 #include <wx/sizer.h>
33 #include <wx/statbmp.h>
34 #include <wx/intl.h>
35 #include <wx/image.h>
36 
37 #include "FileNames.h"
38 #include "Project.h"
39 #include "ShuttleGui.h"
41 #include "widgets/HelpSystem.h"
42 
43 #include "AllThemeResources.h"
44 #include "Prefs.h"
45 #include "HelpText.h"
46 
47 // DA: Logo for Splash Dialog (welcome dialog)
48 #ifdef EXPERIMENTAL_DA
49 #include "../images/DarkAudacityLogoWithName.xpm"
50 #else
51 #include "../images/AudacityLogoWithName.xpm"
52 #endif
53 
55 
56 enum
57 {
58  DontShowID=1000,
59 };
60 
61 BEGIN_EVENT_TABLE(SplashDialog, wxDialogWrapper)
63  EVT_CHECKBOX( DontShowID, SplashDialog::OnDontShow )
65 
67 
68 void SplashDialog::DoHelpWelcome( AudacityProject &project )
69 {
70  Show2( &GetProjectFrame( project ) );
71 }
72 
73 SplashDialog::SplashDialog(wxWindow * parent)
74  : wxDialogWrapper(parent, -1, XO("Welcome to Audacity!"),
75  wxPoint( -1, 60 ), // default x position, y position 60 pixels from top of screen.
76  wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
77 {
78  SetName();
79  m_pLogo = NULL; //v
80  ShuttleGui S( this, eIsCreating );
81  Populate( S );
82  Fit();
83  this->Centre();
84  int x,y;
85  GetPosition( &x, &y );
86  Move( x, 60 );
87 }
88 
89 void SplashDialog::OnChar(wxMouseEvent &event)
90 {
91  if ( event.ShiftDown() && event.ControlDown() )
92  wxLaunchDefaultBrowser("https://www.audacityteam.org");
93 }
94 
96 {
97  bool bShow;
98  gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &bShow, true );
99  S.StartVerticalLay(1);
100 
101  //v For now, change to AudacityLogoWithName via old-fashioned ways, not Theme.
102  m_pLogo = std::make_unique<wxBitmap>((const char **) AudacityLogoWithName_xpm); //v
103 
104 
105  // JKC: Resize to 50% of size. Later we may use a smaller xpm as
106  // our source, but this allows us to tweak the size - if we want to.
107  // It also makes it easier to revert to full size if we decide to.
108  const float fScale=0.5f;// smaller size.
109  wxImage RescaledImage( m_pLogo->ConvertToImage() );
110  wxColour MainColour(
111  RescaledImage.GetRed(1,1),
112  RescaledImage.GetGreen(1,1),
113  RescaledImage.GetBlue(1,1));
114  this->SetBackgroundColour(MainColour);
115 
116  // wxIMAGE_QUALITY_HIGH not supported by wxWidgets 2.6.1, or we would use it here.
117  RescaledImage.Rescale( (int)(LOGOWITHNAME_WIDTH * fScale), (int)(LOGOWITHNAME_HEIGHT *fScale) );
118  wxBitmap RescaledBitmap( RescaledImage );
119  wxStaticBitmap *const icon =
120  safenew wxStaticBitmap(S.GetParent(), -1,
121  //*m_pLogo, //v theTheme.Bitmap(bmpAudacityLogoWithName),
122  RescaledBitmap,
123  wxDefaultPosition,
124  wxSize((int)(LOGOWITHNAME_WIDTH*fScale), (int)(LOGOWITHNAME_HEIGHT*fScale)));
125 
126  S.Prop(0)
127 #if (0)
128  .ConnectRoot( wxEVT_LEFT_DOWN, &SplashDialog::OnChar)
129 #endif
130  .AddWindow( icon );
131 
133  wxDefaultPosition,
134  wxSize(506, 280),
135  wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
136  mpHtml->SetPage(HelpText( wxT("welcome") ));
137  S.Prop(1)
138  .Position( wxEXPAND )
139  .AddWindow( mpHtml );
140  S.Prop(0).StartMultiColumn(2, wxEXPAND);
141  S.SetStretchyCol( 1 );// Column 1 is stretchy...
142  {
143  S.SetBorder( 5 );
144  S.Id( DontShowID).AddCheckBox( XXO("Don't show this again at start up"), !bShow );
145  S.SetBorder( 5 );
146 
147  S.Id(wxID_OK)
148  .Prop(0)
149  .AddButton(XXO("OK"), wxALIGN_RIGHT| wxALL, true);
150  }
151  S.EndVerticalLay();
152 }
153 
154 SplashDialog::~SplashDialog()
155 {
156 }
157 
158 void SplashDialog::OnDontShow( wxCommandEvent & Evt )
159 {
160  bool bShow = !Evt.IsChecked();
161  gPrefs->Write(wxT("/GUI/ShowSplashScreen"), bShow );
162  gPrefs->Flush();
163 }
164 
165 void SplashDialog::OnOK(wxCommandEvent & WXUNUSED(event))
166 {
167  Show( false );
168 
169 }
170 
171 void SplashDialog::Show2( wxWindow * pParent )
172 {
173  if( pSelf == NULL )
174  {
175  // pParent owns it
176  wxASSERT(pParent);
177  pSelf = safenew SplashDialog( pParent );
178  }
179  pSelf->mpHtml->SetPage(HelpText( wxT("welcome") ));
180  pSelf->Show( true );
181 }
EVT_BUTTON
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:36
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1177
ShuttleGuiBase::AddCheckBox
wxCheckBox * AddCheckBox(const TranslatableString &Prompt, bool Selected)
Definition: ShuttleGui.cpp:302
SplashDialog::Populate
void Populate(ShuttleGui &S)
Definition: SplashDialog.cpp:95
HelpSystem.h
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:67
AllThemeResources.h
Project.h
SplashDialog::m_pLogo
std::unique_ptr< wxBitmap > m_pLogo
Definition: SplashDialog.h:41
SplashDialog
The SplashDialog shows help information for Audacity when Audacity starts up.
Definition: SplashDialog.h:21
SplashDialog.h
SplashDialog::Show2
static void Show2(wxWindow *pParent)
Definition: SplashDialog.cpp:171
XO
#define XO(s)
Definition: Internat.h:32
LOGOWITHNAME_WIDTH
#define LOGOWITHNAME_WIDTH
Definition: AllThemeResources.h:240
DontShowID
@ DontShowID
Definition: SplashDialog.cpp:58
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2248
HelpText.h
XXO
#define XXO(s)
Definition: Internat.h:45
SplashDialog::OnChar
void OnChar(wxMouseEvent &event)
Definition: SplashDialog.cpp:89
SplashDialog::pSelf
static SplashDialog * pSelf
Definition: SplashDialog.h:42
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1196
GetProjectFrame
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 ...
Definition: Project.cpp:186
LinkingHtmlWindow
An HtmlWindow that handles linked clicked - usually the link will go to our own local copy of the man...
Definition: HelpSystem.h:125
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:503
ShuttleGui.h
ShuttleGui::Prop
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:732
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:353
SplashDialog::OnDontShow
void OnDontShow(wxCommandEvent &Evt)
Definition: SplashDialog.cpp:158
wxDialogWrapper
Definition: wxPanelWrapper.h:81
ShuttleGuiBase::AddWindow
wxWindow * AddWindow(wxWindow *pWindow)
Definition: ShuttleGui.cpp:292
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:151
ShuttleGui::Position
ShuttleGui & Position(int flags)
Definition: ShuttleGui.h:719
ShuttleGui::ConnectRoot
auto ConnectRoot(wxEventTypeTag< Tag > eventType, void(Handler::*func)(Argument &)) -> typename std::enable_if< std::is_base_of< Argument, Tag >::value, ShuttleGui & >::type
Definition: ShuttleGui.h:706
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
SplashDialog::mpHtml
HtmlWindow * mpHtml
Definition: SplashDialog.h:40
FileNames.h
AudacityMessageBox.h
IMPLEMENT_CLASS
IMPLEMENT_CLASS(ControlToolBar, ToolBar)
SplashDialog::SplashDialog
SplashDialog(wxWindow *parent)
Definition: SplashDialog.cpp:73
Prefs.h
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
wxDialogWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:81
SplashDialog::OnOK
void OnOK(wxCommandEvent &event)
Definition: SplashDialog.cpp:165
HelpText
AUDACITY_DLL_API wxString HelpText(const wxString &Key)
safenew
#define safenew
Definition: MemoryX.h:8
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:195
END_EVENT_TABLE
END_EVENT_TABLE()
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638
LOGOWITHNAME_HEIGHT
#define LOGOWITHNAME_HEIGHT
Definition: AllThemeResources.h:243