Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LangChoiceDialog Class Referencefinal

A dialog used (at start up) to present the user with a choice of languages for Audacity. More...

Inheritance diagram for LangChoiceDialog:
wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 LangChoiceDialog (wxWindow *parent, wxWindowID id, const wxString &title)
 
wxString GetLang ()
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void OnOk (wxCommandEvent &event)
 

Private Attributes

wxChoice * mChoice
 
wxString mLang
 
int mNumLangs
 
wxArrayString mLangCodes
 
wxArrayString mLangNames
 

Detailed Description

A dialog used (at start up) to present the user with a choice of languages for Audacity.

Definition at line 34 of file LangChoice.cpp.

Constructor & Destructor Documentation

LangChoiceDialog::LangChoiceDialog ( wxWindow *  parent,
wxWindowID  id,
const wxString &  title 
)

Definition at line 73 of file LangChoice.cpp.

References _(), ShuttleGuiBase::AddChoice(), ShuttleGui::AddStandardButtons(), eIsCreating, ShuttleGuiBase::EndVerticalLay(), eOkButton, GetLanguages(), GetSystemLanguageCode(), ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartHorizontalLay(), and ShuttleGuiBase::StartVerticalLay().

75  :
76  wxDialogWrapper(parent, id, title)
77 {
78  SetName(GetTitle());
80  int ndx = mLangCodes.Index(GetSystemLanguageCode());
81  wxString lang;
82 
83  if (ndx != wxNOT_FOUND) {
84  lang = mLangNames[ndx];
85  }
86 
87  ShuttleGui S(this, eIsCreating);
88 
89  S.StartVerticalLay(false);
90  {
91  S.StartHorizontalLay();
92  {
93  S.SetBorder(15);
94  mChoice = S.AddChoice(_("Choose Language for Audacity to use:"),
95  lang,
96  &mLangNames);
97  }
98  S.EndVerticalLay();
99 
100  S.SetBorder(0);
101  S.AddStandardButtons(eOkButton);
102  }
103  S.EndVerticalLay();
104 
105  Fit();
106 }
wxArrayString mLangNames
Definition: LangChoice.cpp:50
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
wxArrayString mLangCodes
Definition: LangChoice.cpp:49
_("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
wxString GetSystemLanguageCode()
Definition: Languages.cpp:76
void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
Definition: Languages.cpp:130
wxChoice * mChoice
Definition: LangChoice.cpp:45

Member Function Documentation

wxString LangChoiceDialog::GetLang ( )
inline

Definition at line 40 of file LangChoice.cpp.

References mLang.

Referenced by ChooseLanguage().

40 { return mLang; }
void LangChoiceDialog::OnOk ( wxCommandEvent &  event)
private

Definition at line 108 of file LangChoice.cpp.

References _(), AudacityMessageBox(), GetSystemLanguageCode(), mChoice, mLang, mLangCodes, and mLangNames.

109 {
110  int ndx = mChoice->GetSelection();
111  mLang = mLangCodes[ndx];
112 
113  wxString slang = GetSystemLanguageCode();
114  int sndx = mLangCodes.Index(slang);
115  wxString sname;
116 
117  if (sndx == wxNOT_FOUND) {
118  const wxLanguageInfo *sinfo = wxLocale::FindLanguageInfo(slang);
119  if (sinfo) {
120  sname = sinfo->Description;
121  }
122  }
123  else {
124  sname = mLangNames[sndx];
125  }
126 
127  if (mLang.Left(2) != slang.Left(2)) {
128  wxString msg;
129  /* i18n-hint: The %s's are replaced by translated and untranslated
130  * versions of language names. */
131  msg.Printf(_("The language you have chosen, %s (%s), is not the same as the system language, %s (%s)."),
132  mLangNames[ndx],
133  mLang,
134  sname,
135  slang);
136  if (AudacityMessageBox(msg, _("Confirm"), wxYES_NO) == wxNO) {
137  return;
138  }
139  }
140 
141  EndModal(true);
142 }
wxArrayString mLangNames
Definition: LangChoice.cpp:50
wxArrayString mLangCodes
Definition: LangChoice.cpp:49
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
_("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
wxString GetSystemLanguageCode()
Definition: Languages.cpp:76
wxChoice * mChoice
Definition: LangChoice.cpp:45

Member Data Documentation

wxChoice* LangChoiceDialog::mChoice
private

Definition at line 45 of file LangChoice.cpp.

Referenced by OnOk().

wxString LangChoiceDialog::mLang
private

Definition at line 46 of file LangChoice.cpp.

Referenced by GetLang(), and OnOk().

wxArrayString LangChoiceDialog::mLangCodes
private

Definition at line 49 of file LangChoice.cpp.

Referenced by OnOk().

wxArrayString LangChoiceDialog::mLangNames
private

Definition at line 50 of file LangChoice.cpp.

Referenced by OnOk().

int LangChoiceDialog::mNumLangs
private

Definition at line 48 of file LangChoice.cpp.


The documentation for this class was generated from the following file: