OSDN Git Service

Add WinMergePluginBase.h (2)
[winmerge-jp/winmerge-jp.git] / Src / DirColsDlg.h
1 /** 
2  * @file  DirColsDlg.h
3  *
4  * @brief Declaration file for CDirColsDlg
5  *
6  * @date  Created: 2003-08-19
7  */
8 #pragma once
9
10 #include <vector>
11 #include "TrDialogs.h"
12 #include "UnicodeString.h"
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CDirColsDlg dialog
16
17 /**
18  * @brief A Dialog for choosing visible folder compare columns.
19  * This class implements a dialog for choosing visible columns in folder
20  * compare. Columns can be also re-ordered. There is one listview component
21  * which lists all available columns. Every column name has a checkbox with
22  * it. If the checkbox is checked, the column is visible.
23  *
24  * @note: Due to how columns handling code is implemented, hidden columns
25  * must be always be last in the list with order number -1.
26  * @todo: Allow hidden columns between visible columns.
27  */
28 class CDirColsDlg : public CTrDialog
29 {
30 // Public types
31 public:
32         /** @brief One column's information. */
33         struct column
34         {
35                 String name; /**< Column name */
36                 String desc; /**< Description for column */
37                 int log_col; /**< Logical (shown) order number */
38                 int phy_col; /**< Physical (in memory) order number */
39                 column(const String & colName, const String & dsc, int log, int phy)
40                         : name(colName), desc(dsc), log_col(log), phy_col(phy)
41                 { } 
42         };
43         typedef std::vector<column> ColumnArray;
44
45 // Construction
46 public:
47         explicit CDirColsDlg(CWnd* pParent = nullptr);   // standard constructor
48         void AddColumn(const String & name, const String & desc, int log, int phy=-1)
49                 { column c(name, desc, log, phy); m_cols.push_back(c); }
50         void AddDefColumn(const String & name, int log, int phy=-1)
51                 { column c(name, _T(""), log, phy); m_defCols.push_back(c); }
52         const ColumnArray & GetColumns() const { return m_cols; }
53
54 // Dialog Data
55         //{{AFX_DATA(CDirColsDlg)
56         enum { IDD = IDD_DIRCOLS };
57         CListCtrl m_listColumns;
58         bool m_bReset;
59         //}}AFX_DATA
60
61
62 // Overrides
63         // ClassWizard generated virtual function overrides
64         //{{AFX_VIRTUAL(CDirColsDlg)
65         protected:
66         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
67         //}}AFX_VIRTUAL
68
69 // Implementation methods
70 protected:
71         void InitList();
72         void LoadLists();
73         void SelectItem(int index);
74         void LoadDefLists();
75         void SortArrayToLogicalOrder();
76         void MoveItem(int index, int newIndex);
77         void MoveSelectedItems(bool bUp);
78         void SanitizeOrder();
79
80 // Implementation data
81 private:
82         ColumnArray m_cols; /**< Column list. */
83         ColumnArray m_defCols; /**< Default columns. */
84         static bool CompareColumnsByLogicalOrder( const column & el1, const column & el2 );
85
86         // Generated message map functions
87         //{{AFX_MSG(CDirColsDlg)
88         virtual BOOL OnInitDialog() override;
89         afx_msg void OnUp();
90         afx_msg void OnDown();
91         virtual void OnOK() override;
92         afx_msg void OnDefaults();
93         //}}AFX_MSG
94         DECLARE_MESSAGE_MAP()
95 public:
96         afx_msg void OnLvnItemchangedColdlgList(NMHDR *pNMHDR, LRESULT *pResult);
97 };