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  icon
117 #if ((((AUDACITY_VERSION % 10) ^ 1) >> 1) == 1)
118  ->Bind(wxEVT_LEFT_DOWN
119 
120  ,[this](
121 
122  wxMouseEvent const
123  & tneve
124  )->void{(void)((
125  tneve.ShiftDown (
126  )&& tneve.ControlDown (
127  ))?([this]{
128  decltype(GetName(
129 
130  ))L1{wxT(
131 
132 
133  "\256Ovrairavqb9-Yhvtv\056\
134 ")};for( auto
135 
136  c:L1) c
137  =(( wxChar
138  )c&~ 0x1fu
139  )| ((((
140  wxChar) c&0x1fu
141  )+0xdu)% 0x1AU
142  );static_assert(
143 
144  /**********/
145 
146  !!!!!!
147 
148 0 <3 <3
149 
150 ," !!!!!! "
151 
152  /**********/
153 
154  );AudacityMessageBox(wxT(1)
155  );}(),!0):!1);})
156 #endif
157  ;
158 
160  wxDefaultPosition,
161  wxSize(506, 280),
162  wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
163  mpHtml->SetPage(HelpText( wxT("welcome") ));
164  S.Prop(1).AddWindow( mpHtml, wxEXPAND );
165  S.Prop(0).StartMultiColumn(2, wxEXPAND);
166  S.SetStretchyCol( 1 );// Column 1 is stretchy...
167  {
168  S.SetBorder( 5 );
169  S.Id( DontShowID).AddCheckBox( _("Don't show this again at start up"), bShow ? wxT("false") : wxT("true") );
170  wxButton *ok = safenew wxButton(S.GetParent(), wxID_OK);
171  ok->SetDefault();
172  S.SetBorder( 5 );
173  S.Prop(0).AddWindow( ok, wxALIGN_RIGHT| wxALL );
174  }
175  S.EndVerticalLay();
176 }
177 
179 {
180 }
181 
182 void SplashDialog::OnDontShow( wxCommandEvent & Evt )
183 {
184  bool bShow = !Evt.IsChecked();
185  gPrefs->Write(wxT("/GUI/ShowSplashScreen"), bShow );
186  gPrefs->Flush();
187 }
188 
189 void SplashDialog::OnOK(wxCommandEvent & WXUNUSED(event))
190 {
191  Show( false );
192 
193 }
194 
195 void SplashDialog::Show2( wxWindow * pParent )
196 {
197  if( pSelf == NULL )
198  {
199  // pParent owns it
200  wxASSERT(pParent);
201  pSelf = safenew SplashDialog( pParent );
202  }
203  pSelf->mpHtml->SetPage(HelpText( wxT("welcome") ));
204  pSelf->Show( true );
205 }
void Populate(ShuttleGui &S)
SplashDialog(wxWindow *parent)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
static void Show2(wxWindow *pParent)
wxWindow * AddWindow(wxWindow *pWindow, int Flags=wxALIGN_CENTRE|wxALL)
Definition: ShuttleGui.cpp:257
std::unique_ptr< wxBitmap > m_pLogo
Definition: SplashDialog.h:42
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
static SplashDialog * pSelf
Definition: SplashDialog.h:43
#define safenew
Definition: Audacity.h:223
void EndVerticalLay()
Definition: ShuttleGui.cpp:991
#define LOGOWITHNAME_WIDTH
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
wxCheckBox * AddCheckBox(const wxString &Prompt, const wxString &Selected)
Definition: ShuttleGui.cpp:267
wxWindow * GetParent()
Definition: ShuttleGui.h:259
wxString HelpText(const wxString &Key)
Definition: HelpText.cpp:297
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:998
virtual ~SplashDialog()
ShuttleGui & Id(int id)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
IMPLEMENT_CLASS(ControlToolBar, ToolBar)
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:374
#define LOGOWITHNAME_HEIGHT
END_EVENT_TABLE()
void SetBorder(int Border)
Definition: ShuttleGui.h:251
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:192
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:982