1 /**********************************************************************
2 
3   Audacity: A Digital Audio Editor
4 
5   TimerRecordDialog.h
6 
7   Copyright 2006 by Vaughan Johnson
8 
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13 
14 **********************************************************************/
15 
16 #ifndef __AUDACITY_TIMERRECORD_DIALOG__
17 #define __AUDACITY_TIMERRECORD_DIALOG__
18 
19 #include <wx/textctrl.h> // to inherit
20 #include <wx/timer.h> // member variable
21 #include "export/Export.h"
22 
23 class wxCheckBox;
24 class wxChoice;
25 class wxDateEvent;
26 class wxDatePickerCtrl;
27 class wxTimerEvent;
28 
29 class NumericTextCtrl;
30 class ShuttleGui;
31 class wxTextCtrlWrapper;
32 
33 enum TimerRecordCompletedActions {
34    TR_ACTION_NOTHING = 0x00000000,
35    TR_ACTION_SAVED = 0x00000001,
36    TR_ACTION_EXPORTED = 0x00000002
37 };
38 
39 enum {
40    POST_TIMER_RECORD_STOPPED = -3,
41    POST_TIMER_RECORD_CANCEL_WAIT,
42    POST_TIMER_RECORD_CANCEL,
43 
44    POST_TIMER_RECORD_NOTHING = 0,
45    POST_TIMER_RECORD_CLOSE,
46 
47 #ifdef __WINDOWS__
48    POST_TIMER_RECORD_RESTART,
49    POST_TIMER_RECORD_SHUTDOWN
50 #endif
51 };
52 
53 class AudacityProject;
54 
55 class TimerRecordDialog final : public wxDialogWrapper
56 {
57 public:
58    using ProgressResult = BasicUI::ProgressResult;
59 
60    TimerRecordDialog(
61       wxWindow* parent, AudacityProject &project, bool bAlreadySaved);
62    ~TimerRecordDialog();
63 
64    void OnTimer(wxTimerEvent& event);
65    ///Runs the wait for start dialog.  Returns false if the user clicks stop.
66    int RunWaitDialog();
67 
68 private:
69    void OnDatePicker_Start(wxDateEvent& event);
70    void OnTimeText_Start(wxCommandEvent& event);
71 
72    void OnDatePicker_End(wxDateEvent& event);
73    void OnTimeText_End(wxCommandEvent& event);
74 
75    void OnTimeText_Duration(wxCommandEvent & event);
76 
77    void OnOK(wxCommandEvent& event);
78    void OnHelpButtonClick(wxCommandEvent& event);
79 
80    TranslatableString GetDisplayDate(wxDateTime & dt);
81    void PopulateOrExchange(ShuttleGui& S);
82 
83    bool TransferDataFromWindow() override;
84    // no TransferDataFromWindow() because ??
85 
86    void UpdateDuration(); // Update m_TimeSpan_Duration and ctrl based on m_DateTime_Start and m_DateTime_End.
87    void UpdateEnd(); // Update m_DateTime_End and ctrls based on m_DateTime_Start and m_TimeSpan_Duration.
88    ProgressResult WaitForStart();
89 
90    // Timer Recording Automation Control Events
91    void OnAutoSavePathButton_Click(wxCommandEvent& event);
92    void OnAutoExportPathButton_Click(wxCommandEvent& event);
93    void OnAutoSaveCheckBox_Change(wxCommandEvent& event);
94    void OnAutoExportCheckBox_Change(wxCommandEvent& event);
95    // Timer Recording Automation Routines
96    void EnableDisableAutoControls(bool bEnable, int iControlGoup);
97    void UpdateTextBoxControls();
98 
99    // Add Path Controls to Form
100    wxTextCtrlWrapper *NewPathControl(
101       wxWindow *wParent, const int iID,
102       const TranslatableString &sCaption, const TranslatableString &sValue);
103 
104    int ExecutePostRecordActions(bool bWasStopped);
105    ProgressResult PreActionDelay(int iActionIndex, TimerRecordCompletedActions eCompletedActions);
106 
107 private:
108    AudacityProject &mProject;
109 
110    wxDateTime m_DateTime_Start;
111    wxDateTime m_DateTime_End;
112    wxTimeSpan m_TimeSpan_Duration;
113 
114    // controls
115    wxDatePickerCtrl* m_pDatePickerCtrl_Start;
116    NumericTextCtrl* m_pTimeTextCtrl_Start;
117 
118    wxDatePickerCtrl* m_pDatePickerCtrl_End;
119    NumericTextCtrl* m_pTimeTextCtrl_End;
120 
121    NumericTextCtrl* m_pTimeTextCtrl_Duration;
122 
123    wxTimer m_timer;
124 
125    // Controls for Auto Save/Export
126    wxCheckBox *m_pTimerAutoSaveCheckBoxCtrl;
127    wxTextCtrlWrapper *m_pTimerSavePathTextCtrl;
128    wxButton *m_pTimerSavePathButtonCtrl;
129    wxCheckBox *m_pTimerAutoExportCheckBoxCtrl;
130    wxTextCtrlWrapper *m_pTimerExportPathTextCtrl;
131    wxButton *m_pTimerExportPathButtonCtrl;
132 
133    // After Timer Record Options Choice
134    wxChoice *m_pTimerAfterCompleteChoiceCtrl;
135 
136    // After Timer Record do we need to clean up?
137    bool m_bProjectCleanupRequired;
138 
139    // Variables for the Auto Save/Export
140    bool m_bAutoSaveEnabled;
141    wxFileName m_fnAutoSaveFile;
142    bool m_bAutoExportEnabled;
143    wxFileName m_fnAutoExportFile;
144    int m_iAutoExportFormat;
145    int m_iAutoExportSubFormat;
146    int m_iAutoExportFilterIndex;
147    bool m_bProjectAlreadySaved;
148 
149    DECLARE_EVENT_TABLE()
150 };
151 
152 #endif
153