Audacity  2.2.2
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 #include "Audacity.h"
24 
25 #include <wx/dialog.h>
26 #include <wx/html/htmlwin.h>
27 #include <wx/button.h>
28 #include <wx/dcclient.h>
29 #include <wx/sizer.h>
30 #include <wx/statbmp.h>
31 #include <wx/intl.h>
32 #include <wx/image.h>
33 
34 #include "SplashDialog.h"
35 #include "FileNames.h"
36 #include "Internat.h"
37 #include "ShuttleGui.h"
38 #include "widgets/ErrorDialog.h"
40 
41 #include "Theme.h"
42 #include "AllThemeResources.h"
43 #include "Prefs.h"
44 #include "HelpText.h"
45 
46 // DA: Logo for Splash Dialog (welcome dialog)
47 #ifdef EXPERIMENTAL_DA
48 #include "../images/DarkAudacityLogoWithName.xpm"
49 #else
50 #include "../images/AudacityLogoWithName.xpm"
51 #endif
52 
54 
55 enum
56 {
57  DontShowID=1000,
58 };
59 
60 BEGIN_EVENT_TABLE(SplashDialog, wxDialogWrapper)
61  EVT_BUTTON(wxID_OK, SplashDialog::OnOK)
62  EVT_CHECKBOX( DontShowID, SplashDialog::OnDontShow )
64 
66 
67 SplashDialog::SplashDialog(wxWindow * parent)
68  : wxDialogWrapper(parent, -1, _("Welcome to Audacity!"),
69  wxPoint( -1, 60 ), // default x position, y position 60 pixels from top of screen.
70  wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
71 {
72  SetName(GetTitle());
73  m_pLogo = NULL; //v
74  ShuttleGui S( this, eIsCreating );
75  Populate( S );
76  Fit();
77  this->Centre();
78  int x,y;
79  GetPosition( &x, &y );
80  Move( x, 60 );
81 }
82 
84 {
85  bool bShow;
86  gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &bShow, true );
87  S.StartVerticalLay(1);
88 
89  //v For now, change to AudacityLogoWithName via old-fashioned ways, not Theme.
90  m_pLogo = std::make_unique<wxBitmap>((const char **) AudacityLogoWithName_xpm); //v
91 
92 
93  // JKC: Resize to 50% of size. Later we may use a smaller xpm as
94  // our source, but this allows us to tweak the size - if we want to.
95  // It also makes it easier to revert to full size if we decide to.
96  const float fScale=0.5f;// smaller size.
97  wxImage RescaledImage( m_pLogo->ConvertToImage() );
98  wxColour MainColour(
99  RescaledImage.GetRed(1,1),
100  RescaledImage.GetGreen(1,1),
101  RescaledImage.GetBlue(1,1));
102  this->SetBackgroundColour(MainColour);
103 
104  // wxIMAGE_QUALITY_HIGH not supported by wxWidgets 2.6.1, or we would use it here.
105  RescaledImage.Rescale( (int)(LOGOWITHNAME_WIDTH * fScale), (int)(LOGOWITHNAME_HEIGHT *fScale) );
106  wxBitmap RescaledBitmap( RescaledImage );
107  wxStaticBitmap *const icon =
108  safenew wxStaticBitmap(S.GetParent(), -1,
109  //*m_pLogo, //v theTheme.Bitmap(bmpAudacityLogoWithName),
110  RescaledBitmap,
111  wxDefaultPosition,
112  wxSize((int)(LOGOWITHNAME_WIDTH*fScale), (int)(LOGOWITHNAME_HEIGHT*fScale)));
113 
114  S.Prop(0).AddWindow( icon );
115 
116 #if (0)
117  icon->Bind(wxEVT_LEFT_DOWN,
118  [this]( wxMouseEvent const & event ) ->void {
119  if ( event.ShiftDown() && event.ControlDown())
120  wxLaunchDefaultBrowser("https://www.audacityteam.org");
121  }
122  );
123 #endif
124 
126  wxDefaultPosition,
127  wxSize(506, 280),
128  wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
129  mpHtml->SetPage(HelpText( wxT("welcome") ));
130  S.Prop(1).AddWindow( mpHtml, wxEXPAND );
131  S.Prop(0).StartMultiColumn(2, wxEXPAND);
132  S.SetStretchyCol( 1 );// Column 1 is stretchy...
133  {
134  S.SetBorder( 5 );
135  S.Id( DontShowID).AddCheckBox( _("Don't show this again at start up"), bShow ? wxT("false") : wxT("true") );
136  wxButton *ok = safenew wxButton(S.GetParent(), wxID_OK);
137  ok->SetDefault();
138  S.SetBorder( 5 );
139  S.Prop(0).AddWindow( ok, wxALIGN_RIGHT| wxALL );
140  }
141  S.EndVerticalLay();
142 }
143 
145 {
146 }
147 
148 void SplashDialog::OnDontShow( wxCommandEvent & Evt )
149 {
150  bool bShow = !Evt.IsChecked();
151  gPrefs->Write(wxT("/GUI/ShowSplashScreen"), bShow );
152  gPrefs->Flush();
153 }
154 
155 void SplashDialog::OnOK(wxCommandEvent & WXUNUSED(event))
156 {
157  Show( false );
158 
159 }
160 
161 void SplashDialog::Show2( wxWindow * pParent )
162 {
163  if( pSelf == NULL )
164  {
165  // pParent owns it
166  wxASSERT(pParent);
167  pSelf = safenew SplashDialog( pParent );
168  }
169  pSelf->mpHtml->SetPage(HelpText( wxT("welcome") ));
170  pSelf->Show( true );
171 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void Populate(ShuttleGui &S)
SplashDialog(wxWindow *parent)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
static void Show2(wxWindow *pParent)
wxWindow * AddWindow(wxWindow *pWindow, int Flags=wxALIGN_CENTRE|wxALL)
Definition: ShuttleGui.cpp:288
std::unique_ptr< wxBitmap > m_pLogo
Definition: SplashDialog.h:42
static SplashDialog * pSelf
Definition: SplashDialog.h:43
#define safenew
Definition: Audacity.h:230
void EndVerticalLay()
#define LOGOWITHNAME_WIDTH
wxCheckBox * AddCheckBox(const wxString &Prompt, const wxString &Selected)
Definition: ShuttleGui.cpp:298
wxWindow * GetParent()
Definition: ShuttleGui.h:294
wxString HelpText(const wxString &Key)
Definition: HelpText.cpp:298
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
virtual ~SplashDialog()
ShuttleGui & Id(int id)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
IMPLEMENT_CLASS(ControlToolBar, ToolBar)
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
HtmlWindow * mpHtml
Definition: SplashDialog.h:41
void OnOK(wxCommandEvent &event)
void OnDontShow(wxCommandEvent &Evt)
The SplashDialog shows help information for Audacity when Audacity starts up.
Definition: SplashDialog.h:26
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:418
#define LOGOWITHNAME_HEIGHT
END_EVENT_TABLE()
void SetBorder(int Border)
Definition: ShuttleGui.h:286
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:203
void StartVerticalLay(int iProp=1)