Audacity 3.2.0
wxPanelWrapper.h
Go to the documentation of this file.
1//
2// wxPanelWrapper.h
3// Audacity
4//
5// Created by Paul Licameli on 6/25/16.
6//
7//
8
9#ifndef __AUDACITY_WXPANEL_WRAPPER__
10#define __AUDACITY_WXPANEL_WRAPPER__
11
12#include <memory>
13#include <wx/panel.h> // to inherit
14#include <wx/dialog.h> // to inherit
15
16#include "Internat.h"
17
18#include "Identifier.h"
19
20AUDACITY_DLL_API void wxTabTraversalWrapperCharHook(wxKeyEvent &event);
21
22template <typename Base>
23class AUDACITY_DLL_API wxTabTraversalWrapper : public Base
24{
25public:
26 template <typename... Args>
27 wxTabTraversalWrapper(Args&&... args)
28 : Base( std::forward<Args>(args)... )
29 {
30 this->Bind(wxEVT_CHAR_HOOK, wxTabTraversalWrapperCharHook);
31 }
32
37
38};
39
40class AUDACITY_DLL_API wxPanelWrapper : public wxTabTraversalWrapper<wxPanel>
41{
42public:
43 // Constructors
45
47 wxWindow *parent,
48 wxWindowID winid = wxID_ANY,
49 const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize,
51 long style = wxTAB_TRAVERSAL | wxNO_BORDER,
52 // Important: default window name localizes!
53 const TranslatableString& name = XO("Panel"))
54 : wxTabTraversalWrapper<wxPanel> (
55 parent, winid, pos, size, style, name.Translation() )
56 {}
57
58 // Pseudo ctor
59 bool Create(
60 wxWindow *parent,
61 wxWindowID winid = wxID_ANY,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = wxTAB_TRAVERSAL | wxNO_BORDER,
65 // Important: default window name localizes!
66 const TranslatableString& name = XO("Panel"))
67 {
69 parent, winid, pos, size, style, name.Translation()
70 );
71 }
72 // overload and hide the inherited functions that take naked wxString:
73 void SetLabel(const TranslatableString & label);
74 void SetName(const TranslatableString & name);
75 void SetToolTip(const TranslatableString &toolTip);
76 // Set the name to equal the label:
77 void SetName();
78};
79
80class AUDACITY_DLL_API wxDialogWrapper : public wxTabTraversalWrapper<wxDialog>
81{
82public:
83 // Constructors
85
86 // Constructor with no modal flag - the new convention.
88 wxWindow *parent, wxWindowID id,
90 const wxPoint& pos = wxDefaultPosition,
91 const wxSize& size = wxDefaultSize,
92 long style = wxDEFAULT_DIALOG_STYLE,
93 // Important: default window name localizes!
94 const TranslatableString& name = XO("Dialog"))
95 : wxTabTraversalWrapper<wxDialog>(
96 parent, id, title.Translation(), pos, size, style, name.Translation() )
97 {}
98
99 // Pseudo ctor
100 bool Create(
101 wxWindow *parent, wxWindowID id,
103 const wxPoint& pos = wxDefaultPosition,
104 const wxSize& size = wxDefaultSize,
105 long style = wxDEFAULT_DIALOG_STYLE,
106 // Important: default window name localizes!
107 const TranslatableString& name = XO("Dialog"))
108 {
110 parent, id, title.Translation(), pos, size, style, name.Translation()
111 );
112 }
113
114 // overload and hide the inherited functions that take naked wxString:
115 void SetTitle(const TranslatableString & title);
116 void SetLabel(const TranslatableString & title);
117 void SetName(const TranslatableString & title);
118 // Set the name to equal the title:
119 void SetName();
120};
121
122#include <wx/dirdlg.h> // to inherit
123
124class AUDACITY_DLL_API wxDirDialogWrapper
125 : public wxTabTraversalWrapper<wxDirDialog>
126{
127public:
128 // Constructor with no modal flag - the new convention.
130 wxWindow *parent,
131 const TranslatableString& message = XO("Select a directory"),
132 const wxString& defaultPath = {},
133 long style = wxDD_DEFAULT_STYLE,
134 const wxPoint& pos = wxDefaultPosition,
135 const wxSize& size = wxDefaultSize,
136 // Important: default window name localizes!
137 const TranslatableString& name = XO("Directory Dialog"))
139 parent, message.Translation(), defaultPath, style, pos, size,
140 name.Translation() )
141 {}
142
143 // Pseudo ctor
144 void Create(
145 wxWindow *parent,
146 const TranslatableString& message = XO("Select a directory"),
147 const wxString& defaultPath = {},
148 long style = wxDD_DEFAULT_STYLE,
149 const wxPoint& pos = wxDefaultPosition,
150 const wxSize& size = wxDefaultSize,
151 // Important: default window name localizes!
152 const TranslatableString& name = XO("Directory Dialog"))
153 {
155 parent, message.Translation(), defaultPath, style, pos, size,
156 name.Translation() );
157 }
158};
159
161#include "FileNames.h" // for FileTypes
162
163class AUDACITY_DLL_API FileDialogWrapper
164 : public wxTabTraversalWrapper<FileDialog>
165{
166public:
168
169 // Constructor with no modal flag - the new convention.
171 wxWindow *parent,
172 const TranslatableString& message,
173 const FilePath& defaultDir,
174 const FilePath& defaultFile,
175 const FileNames::FileTypes& fileTypes,
176 long style = wxFD_DEFAULT_STYLE,
177 const wxPoint& pos = wxDefaultPosition,
178 const wxSize& sz = wxDefaultSize,
179 // Important: default window name localizes!
180 const TranslatableString& name = XO("File Dialog"))
182 parent, message.Translation(), defaultDir, defaultFile,
183 FileNames::FormatWildcard( fileTypes ),
184 style, pos, sz, name.Translation() )
185 {}
186
187 // Pseudo ctor
188 void Create(
189 wxWindow *parent,
190 const TranslatableString& message,
191 const FilePath& defaultDir,
192 const FilePath& defaultFile,
193 const FileNames::FileTypes& fileTypes,
194 long style = wxFD_DEFAULT_STYLE,
195 const wxPoint& pos = wxDefaultPosition,
196 const wxSize& sz = wxDefaultSize,
197 // Important: default window name localizes!
198 const TranslatableString& name = XO("File Dialog"))
199 {
201 parent, message.Translation(), defaultDir, defaultFile,
202 FileNames::FormatWildcard( fileTypes ),
203 style, pos, sz, name.Translation()
204 );
205 }
206};
207
208#include <wx/msgdlg.h>
209
210/**************************************************************************/
214class AudacityMessageDialog : public wxTabTraversalWrapper< wxMessageDialog >
215{
216public:
218 wxWindow *parent,
219 const TranslatableString &message,
220 const TranslatableString &caption, // don't use = wxMessageBoxCaptionStr,
221 long style = wxOK|wxCENTRE,
222 const wxPoint& pos = wxDefaultPosition)
223 : wxTabTraversalWrapper< wxMessageDialog>
224 ( parent, message.Translation(), caption.Translation(), style, pos )
225 {}
226};
227
228#endif
const TranslatableString name
Definition: Distortion.cpp:82
#define XO(s)
Definition: Internat.h:31
static const auto title
wxString FilePath
Definition: Project.h:20
TranslatableString label
Definition: TagsEditor.cpp:163
int id
Wrap wxMessageDialog so that caption IS translatable.
AudacityMessageDialog(wxWindow *parent, const TranslatableString &message, const TranslatableString &caption, long style=wxOK|wxCENTRE, const wxPoint &pos=wxDefaultPosition)
Dialog used to present platform specific "Save As" dialog with custom controls.
void Create(wxWindow *parent, const TranslatableString &message, const FilePath &defaultDir, const FilePath &defaultFile, const FileNames::FileTypes &fileTypes, long style=wxFD_DEFAULT_STYLE, const wxPoint &pos=wxDefaultPosition, const wxSize &sz=wxDefaultSize, const TranslatableString &name=XO("File Dialog"))
FileDialogWrapper(wxWindow *parent, const TranslatableString &message, const FilePath &defaultDir, const FilePath &defaultFile, const FileNames::FileTypes &fileTypes, long style=wxFD_DEFAULT_STYLE, const wxPoint &pos=wxDefaultPosition, const wxSize &sz=wxDefaultSize, const TranslatableString &name=XO("File Dialog"))
std::vector< FileType > FileTypes
Definition: FileNames.h:76
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
wxDialogWrapper(wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
bool Create(wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
void Create(wxWindow *parent, const TranslatableString &message=XO("Select a directory"), const wxString &defaultPath={}, long style=wxDD_DEFAULT_STYLE, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, const TranslatableString &name=XO("Directory Dialog"))
wxDirDialogWrapper(wxWindow *parent, const TranslatableString &message=XO("Select a directory"), const wxString &defaultPath={}, long style=wxDD_DEFAULT_STYLE, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, const TranslatableString &name=XO("Directory Dialog"))
wxPanelWrapper(wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
bool Create(wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
wxTabTraversalWrapper & operator=(wxTabTraversalWrapper &&)=delete
wxTabTraversalWrapper(wxTabTraversalWrapper &&)=delete
wxTabTraversalWrapper(Args &&... args)
wxTabTraversalWrapper(const wxTabTraversalWrapper &)=delete
wxTabTraversalWrapper & operator=(const wxTabTraversalWrapper &)=delete
FILES_API wxString FormatWildcard(const FileTypes &fileTypes)
STL namespace.
AUDACITY_DLL_API void wxTabTraversalWrapperCharHook(wxKeyEvent &event)