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 <wx/panel.h> // to inherit
13#include <wx/dialog.h> // to inherit
14
15#include "Internat.h"
16
17#include "Identifier.h"
18
19WX_WRAPPERS_API void wxTabTraversalWrapperCharHook(wxKeyEvent &event);
20
21template <typename Base>
22class WX_WRAPPERS_API wxTabTraversalWrapper : public Base
23{
24public:
25 template <typename... Args>
26 wxTabTraversalWrapper(Args&&... args)
27 : Base( std::forward<Args>(args)... )
28 {
29 this->Bind(wxEVT_CHAR_HOOK, wxTabTraversalWrapperCharHook);
30 }
31
36
37};
38
39class WX_WRAPPERS_API wxPanelWrapper : public wxTabTraversalWrapper<wxPanel>
40{
41public:
42 // Constructors
44
46 wxWindow *parent,
47 wxWindowID winid = wxID_ANY,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 long style = wxTAB_TRAVERSAL | wxNO_BORDER,
51 // Important: default window name localizes!
52 const TranslatableString& name = XO("Panel"))
53 : wxTabTraversalWrapper<wxPanel> (
54 parent, winid, pos, size, style, name.Translation() )
55 {}
56
57 // Pseudo ctor
58 bool Create(
59 wxWindow *parent,
60 wxWindowID winid = wxID_ANY,
61 const wxPoint& pos = wxDefaultPosition,
62 const wxSize& size = wxDefaultSize,
63 long style = wxTAB_TRAVERSAL | wxNO_BORDER,
64 // Important: default window name localizes!
65 const TranslatableString& name = XO("Panel"))
66 {
68 parent, winid, pos, size, style, name.Translation()
69 );
70 }
71 // overload and hide the inherited functions that take naked wxString:
72 void SetLabel(const TranslatableString & label);
73 void SetName(const TranslatableString & name);
74 void SetToolTip(const TranslatableString &toolTip);
75 // Set the name to equal the label:
76 void SetName();
77};
78
79class WX_WRAPPERS_API wxDialogWrapper : public wxTabTraversalWrapper<wxDialog>
80{
81public:
82 // Constructors
84
85 // Constructor with no modal flag - the new convention.
87 wxWindow *parent, wxWindowID id,
89 const wxPoint& pos = wxDefaultPosition,
90 const wxSize& size = wxDefaultSize,
91 long style = wxDEFAULT_DIALOG_STYLE,
92 // Important: default window name localizes!
93 const TranslatableString& name = XO("Dialog"))
94 : wxTabTraversalWrapper<wxDialog>(
95 parent, id, title.Translation(), pos, size, style, name.Translation() )
96 {}
97
98 // Pseudo ctor
99 bool Create(
100 wxWindow *parent, wxWindowID id,
102 const wxPoint& pos = wxDefaultPosition,
103 const wxSize& size = wxDefaultSize,
104 long style = wxDEFAULT_DIALOG_STYLE,
105 // Important: default window name localizes!
106 const TranslatableString& name = XO("Dialog"))
107 {
109 parent, id, title.Translation(), pos, size, style, name.Translation()
110 );
111 }
112
113 // overload and hide the inherited functions that take naked wxString:
114 void SetTitle(const TranslatableString & title);
115 void SetLabel(const TranslatableString & title);
116 void SetName(const TranslatableString & title);
117 // Set the name to equal the title:
118 void SetName();
119};
120
121#include <wx/dirdlg.h> // to inherit
122
123class WX_WRAPPERS_API wxDirDialogWrapper
124 : public wxTabTraversalWrapper<wxDirDialog>
125{
126public:
128
129 // Constructor with no modal flag - the new convention.
131 wxWindow *parent,
132 const TranslatableString& message = DefaultDialogPrompt,
133 const wxString& defaultPath = {},
134 long style = wxDD_DEFAULT_STYLE,
135 const wxPoint& pos = wxDefaultPosition,
136 const wxSize& size = wxDefaultSize,
137 // Important: default window name localizes!
138 const TranslatableString& name = XO("Directory Dialog"))
140 parent, message.Translation(), defaultPath, style, pos, size,
141 name.Translation() )
142 {}
143
144 // Pseudo ctor
145 void Create(
146 wxWindow *parent,
147 const TranslatableString& message = XO("Select a directory"),
148 const wxString& defaultPath = {},
149 long style = wxDD_DEFAULT_STYLE,
150 const wxPoint& pos = wxDefaultPosition,
151 const wxSize& size = wxDefaultSize,
152 // Important: default window name localizes!
153 const TranslatableString& name = XO("Directory Dialog"))
154 {
156 parent, message.Translation(), defaultPath, style, pos, size,
157 name.Translation() );
158 }
159};
160
162#include "FileNames.h" // for FileTypes
163
164class WX_WRAPPERS_API FileDialogWrapper
165 : public wxTabTraversalWrapper<FileDialog>
166{
167public:
169
170 // Constructor with no modal flag - the new convention.
172 wxWindow *parent,
173 const TranslatableString& message,
174 const FilePath& defaultDir,
175 const FilePath& defaultFile,
176 const FileNames::FileTypes& fileTypes,
177 long style = wxFD_DEFAULT_STYLE,
178 const wxPoint& pos = wxDefaultPosition,
179 const wxSize& sz = wxDefaultSize,
180 // Important: default window name localizes!
181 const TranslatableString& name = XO("File Dialog"))
183 parent, message.Translation(), defaultDir, defaultFile,
184 FileNames::FormatWildcard( fileTypes ),
185 style, pos, sz, name.Translation() )
186 {}
187
188 // Pseudo ctor
189 void Create(
190 wxWindow *parent,
191 const TranslatableString& message,
192 const FilePath& defaultDir,
193 const FilePath& defaultFile,
194 const FileNames::FileTypes& fileTypes,
195 long style = wxFD_DEFAULT_STYLE,
196 const wxPoint& pos = wxDefaultPosition,
197 const wxSize& sz = wxDefaultSize,
198 // Important: default window name localizes!
199 const TranslatableString& name = XO("File Dialog"))
200 {
202 parent, message.Translation(), defaultDir, defaultFile,
203 FileNames::FormatWildcard( fileTypes ),
204 style, pos, sz, name.Translation()
205 );
206 }
207};
208
209#include <wx/msgdlg.h>
210
211/**************************************************************************/
215class WX_WRAPPERS_API AudacityMessageDialog
216 : public wxTabTraversalWrapper< wxMessageDialog >
217{
218public:
220 wxWindow *parent,
221 const TranslatableString &message,
222 const TranslatableString &caption, // don't use = wxMessageBoxCaptionStr,
223 long style = wxOK|wxCENTRE,
224 const wxPoint& pos = wxDefaultPosition)
225 : wxTabTraversalWrapper< wxMessageDialog>
226 ( parent, message.Translation(), caption.Translation(), style, pos )
227 {}
229};
230
231#endif
XO("Cut/Copy/Paste")
static const auto title
wxString FilePath
Definition: Project.h:21
wxString name
Definition: TagsEditor.cpp:166
TranslatableString label
Definition: TagsEditor.cpp:165
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:75
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"))
wxDirDialogWrapper(wxWindow *parent, const TranslatableString &message=DefaultDialogPrompt, const wxString &defaultPath={}, long style=wxDD_DEFAULT_STYLE, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, const TranslatableString &name=XO("Directory Dialog"))
static const TranslatableString DefaultDialogPrompt
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"))
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.
WX_WRAPPERS_API void wxTabTraversalWrapperCharHook(wxKeyEvent &event)