Audacity  3.0.3
TimeDialog.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  TimeDialog.cpp
6 
7  Dominic Mazzoni
8 
9 *******************************************************************//*******************************************************************/
15 
16 
17 #include "TimeDialog.h"
18 
19 #include <wx/defs.h>
20 #include <wx/intl.h>
21 #include <wx/sizer.h>
22 #include <wx/string.h>
23 
24 #include "ShuttleGui.h"
26 
27 BEGIN_EVENT_TABLE(TimeDialog, wxDialogWrapper)
28  EVT_COMMAND(wxID_ANY, EVT_TIMETEXTCTRL_UPDATED, TimeDialog::OnUpdate)
30 
31 TimeDialog::TimeDialog(wxWindow *parent,
32  const TranslatableString &title,
34  double rate,
35  double time,
36  const TranslatableString &prompt)
37 : wxDialogWrapper(parent, wxID_ANY, title),
38  mPrompt(prompt),
39  mFormat(format),
40  mRate(rate),
41  mTime(time),
42  mTimeCtrl(NULL)
43 {
44  SetName();
45  ShuttleGui S(this, eIsCreating);
46  PopulateOrExchange(S);
47 }
48 
50 {
51  S.SetBorder(5);
52  S.StartVerticalLay(true);
53  {
54  S.StartStatic(mPrompt, true);
55  {
58  S.GetParent(), wxID_ANY,
60  mFormat,
61  mTime,
62  mRate,
64  .AutoPos(true));
66  }
67  S.EndStatic();
68  }
69  S.EndVerticalLay();
71 
73 
74  Layout();
75  Fit();
76  SetMinSize(GetSize());
77  Center();
78 }
79 
81 {
85  mTimeCtrl->SetFocus();
86 
87  return true;
88 }
89 
91 {
93 
94  return true;
95 }
96 
98 {
99  return mTime;
100 }
101 
103 {
104  mFormat = formatString;
106 }
107 
108 void TimeDialog::SetSampleRate(double sampleRate)
109 {
110  mRate = sampleRate;
112 }
113 
114 void TimeDialog::SetTimeValue(double newTime)
115 {
116  mTime = newTime;
118 }
119 
120 void TimeDialog::OnUpdate(wxCommandEvent &event)
121 {
122  Layout();
123  Refresh();
124 
125  event.Skip(false);
126 }
TranslatableString
Definition: Types.h:290
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:36
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1177
TimeDialog::SetTimeValue
void SetTimeValue(double newTime)
Definition: TimeDialog.cpp:114
TimeDialog.h
NumericTextCtrl::Options::AutoPos
Options & AutoPos(bool enable)
Definition: NumericTextCtrl.h:187
EVT_COMMAND
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
Definition: LabelDialog.cpp:91
TimeDialog::GetTimeValue
const double GetTimeValue()
Definition: TimeDialog.cpp:97
TimeDialog::OnUpdate
void OnUpdate(wxCommandEvent &event)
Definition: TimeDialog.cpp:120
TimeDialog::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: TimeDialog.cpp:90
NumericTextCtrl::SetFormatString
bool SetFormatString(const FormatStrings &formatString)
Definition: NumericTextCtrl.cpp:1447
TimeDialog::mTime
double mTime
Definition: TimeDialog.h:52
TimeDialog::SetFormatString
void SetFormatString(const NumericFormatSymbol &formatString)
Definition: TimeDialog.cpp:102
NumericTextCtrl
Definition: NumericTextCtrl.h:169
NumericTextCtrl::SetValue
void SetValue(double newValue)
Definition: NumericTextCtrl.cpp:1470
TimeDialog::mTimeCtrl
NumericTextCtrl * mTimeCtrl
Definition: TimeDialog.h:54
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:60
NumericTextCtrl::Options
Definition: NumericTextCtrl.h:175
TimeDialog
Dialog used to request a time value.
Definition: TimeDialog.h:24
NumericTextCtrl::SetSampleRate
void SetSampleRate(double sampleRate)
Definition: NumericTextCtrl.cpp:1461
NumericConverter::GetBuiltinFormat
FormatStrings GetBuiltinFormat(const int index)
Definition: NumericTextCtrl.cpp:1205
TimeDialog::mPrompt
TranslatableString mPrompt
Definition: TimeDialog.h:49
TimeDialog::mFormat
NumericFormatSymbol mFormat
Definition: TimeDialog.h:50
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1196
TimeDialog::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S)
Definition: TimeDialog.cpp:49
NumericConverter::TIME
@ TIME
Definition: NumericTextCtrl.h:51
format
int format
Definition: ExportPCM.cpp:54
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:503
ShuttleGui.h
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
TimeDialog::TransferDataToWindow
bool TransferDataToWindow() override
Definition: TimeDialog.cpp:80
wxDialogWrapper
Definition: wxPanelWrapper.h:81
ShuttleGuiBase::AddWindow
wxWindow * AddWindow(wxWindow *pWindow)
Definition: ShuttleGui.cpp:292
TimeDialog::mRate
double mRate
Definition: TimeDialog.h:51
TimeDialog::SetSampleRate
void SetSampleRate(double sampleRate)
Definition: TimeDialog.cpp:108
NumericTextCtrl.h
ShuttleGui::AddStandardButtons
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
Definition: ShuttleGui.cpp:2406
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
safenew
#define safenew
Definition: MemoryX.h:8
NumericConverter::GetValue
double GetValue()
Definition: NumericTextCtrl.cpp:1170
END_EVENT_TABLE
END_EVENT_TABLE()
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638