OSDN Git Service

Shell Extension for Windows 11 or later (5)
[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         bool m_ignoreCase;
42         CSuperComboBox m_ctlFile1;
43         CSuperComboBox m_ctlFile2;
44         CSuperComboBox m_ctlResult;
45         String  m_file1;
46         String  m_file2;
47         String  m_fileResult;
48         bool m_ignoreBlanks;
49         bool m_ignoreEOLDifference;
50         int m_whitespaceCompare;
51         bool m_appendFile;
52         bool m_openToEditor;
53         bool m_includeCmdLine;
54         //}}AFX_DATA
55
56         enum output_style m_outputStyle; /**< Patch style (context, unified etc.) */
57         int m_contextLines; /**< How many context lines are added. */
58         enum DiffAlgorithm m_diffAlgorithm;
59         bool m_indentHeuristic;
60
61 // Overrides
62         // ClassWizard generated virtual function overrides
63         //{{AFX_VIRTUAL(CPatchDlg)
64         protected:
65         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
66         //}}AFX_VIRTUAL
67
68 // Implementation
69 protected:
70
71         std::vector<PATCHFILES> m_fileList; /**< Source files to create patch from */
72
73         void UpdateSettings();
74         void LoadSettings();
75         void SaveSettings();
76         void Swap();
77
78         // Generated message map functions
79         //{{AFX_MSG(CPatchDlg)
80         virtual void OnOK() override;
81         virtual BOOL OnInitDialog() override;
82         afx_msg void OnDiffBrowseFile1();
83         afx_msg void OnDiffBrowseFile2();
84         afx_msg void OnDiffBrowseResult();
85         afx_msg void OnSelchangeDiffStyle();
86         afx_msg void OnDiffSwapFiles();
87         afx_msg void OnDefaultSettings();
88         afx_msg void OnSelchangeFile1();
89         afx_msg void OnSelchangeFile2();
90         afx_msg void OnEditchangeFile1();
91         afx_msg void OnEditchangeFile2();
92         //}}AFX_MSG
93         DECLARE_MESSAGE_MAP()
94 };
95
96 /** 
97  * @brief Add patch item to internal list.
98  * @param [in] pf Patch item to add.
99  */
100 inline void CPatchDlg::AddItem(const PATCHFILES& pf)
101 {
102         m_fileList.push_back(pf);
103 }
104
105 /** 
106  * @brief Returns amount of patch items in the internal list.
107  * @return Count of patch items in the list.
108  */
109 inline size_t CPatchDlg::GetItemCount()
110 {
111         return m_fileList.size();
112 }
113
114 /** 
115  * @brief Return item in the internal list at given position
116  * @param [in] position Zero-based index of item to get
117  * @return PATCHFILES from given position.
118  */
119 inline const PATCHFILES& CPatchDlg::GetItemAt(size_t position)
120 {
121         return m_fileList.at(position);
122 }
123
124 /** 
125  * @brief Empties internal item list.
126  */
127 inline void CPatchDlg::ClearItems()
128 {
129         m_fileList.clear();
130 }
131