OSDN Git Service

refactor
[winmerge-jp/winmerge-jp.git] / Src / PatchDlg.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /** 
3  * @file  PatchDlg.h
4  *
5  * @brief Declaration file for patch creation dialog
6  */
7 #pragma once
8
9 #include "resource.h"
10 #include "TrDialogs.h"
11 #include "SuperComboBox.h"
12 #include "UnicodeString.h"
13
14 struct PATCHFILES;
15
16 /////////////////////////////////////////////////////////////////////////////
17 // PatchDlg dialog
18
19 /** 
20  * @brief Dialog class for Generate Patch -dialog.
21  * This dialog allows user to select files from which to create a patch,
22  * patch file's filename and several options related to patch.
23  */
24 class CPatchDlg : public CTrDialog
25 {
26 // Construction
27 public:
28         explicit CPatchDlg(CWnd* pParent = nullptr);   // standard constructor
29
30         // Functions to add and get selected files (as PATCHFILEs)
31         void AddItem(const PATCHFILES& pf);
32         size_t GetItemCount();
33         const PATCHFILES& GetItemAt(size_t position);
34         void ClearItems();
35
36 // Dialog Data
37         //{{AFX_DATA(CPatchDlg)
38         enum { IDD = IDD_GENERATE_PATCH };
39         CComboBox m_comboStyle;
40         CSuperComboBox m_comboContext;
41         CSuperComboBox m_ctlFile1;
42         CSuperComboBox m_ctlFile2;
43         CSuperComboBox m_ctlResult;
44         String  m_file1;
45         String  m_file2;
46         String  m_fileResult;
47         bool m_copyToClipboard;
48         bool m_appendFile;
49         bool m_openToEditor;
50         bool m_includeCmdLine;
51         //}}AFX_DATA
52
53         enum output_style m_outputStyle; /**< Patch style (context, unified etc.) */
54         int m_contextLines; /**< How many context lines are added. */
55
56 // Overrides
57         // ClassWizard generated virtual function overrides
58         //{{AFX_VIRTUAL(CPatchDlg)
59         protected:
60         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
61         //}}AFX_VIRTUAL
62
63 // Implementation
64 protected:
65
66         std::vector<PATCHFILES> m_fileList; /**< Source files to create patch from */
67
68         void UpdateSettings();
69         void LoadSettings();
70         void SaveSettings();
71         void Swap();
72
73         // Generated message map functions
74         //{{AFX_MSG(CPatchDlg)
75         virtual void OnOK() override;
76         virtual BOOL OnInitDialog() override;
77         afx_msg void OnDiffBrowseFile1();
78         afx_msg void OnDiffBrowseFile2();
79         afx_msg void OnDiffBrowseResult();
80         afx_msg void OnSelchangeDiffStyle();
81         afx_msg void OnDiffSwapFiles();
82         afx_msg void OnDefaultSettings();
83         afx_msg void OnSelchangeFile1();
84         afx_msg void OnSelchangeFile2();
85         afx_msg void OnEditchangeFile1();
86         afx_msg void OnEditchangeFile2();
87         //}}AFX_MSG
88         DECLARE_MESSAGE_MAP()
89 };
90
91 /** 
92  * @brief Add patch item to internal list.
93  * @param [in] pf Patch item to add.
94  */
95 inline void CPatchDlg::AddItem(const PATCHFILES& pf)
96 {
97         m_fileList.push_back(pf);
98 }
99
100 /** 
101  * @brief Returns amount of patch items in the internal list.
102  * @return Count of patch items in the list.
103  */
104 inline size_t CPatchDlg::GetItemCount()
105 {
106         return m_fileList.size();
107 }
108
109 /** 
110  * @brief Return item in the internal list at given position
111  * @param [in] position Zero-based index of item to get
112  * @return PATCHFILES from given position.
113  */
114 inline const PATCHFILES& CPatchDlg::GetItemAt(size_t position)
115 {
116         return m_fileList.at(position);
117 }
118
119 /** 
120  * @brief Empties internal item list.
121  */
122 inline void CPatchDlg::ClearItems()
123 {
124         m_fileList.clear();
125 }
126