OSDN Git Service

Update ChangeLog&ReleaseNotes (3)
[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         bool GetShowAdditionalProperties() const { return m_showAdditionalProperties; }
54
55 // Dialog Data
56         //{{AFX_DATA(CDirColsDlg)
57         enum { IDD = IDD_DIRCOLS };
58         CListCtrl m_listColumns;
59         bool m_bReset;
60         bool m_showAdditionalProperties;
61         //}}AFX_DATA
62
63
64 // Overrides
65         // ClassWizard generated virtual function overrides
66         //{{AFX_VIRTUAL(CDirColsDlg)
67         protected:
68         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
69         //}}AFX_VIRTUAL
70
71 // Implementation methods
72 protected:
73         void InitList();
74         void LoadLists();
75         void SelectItem(int index);
76         void LoadDefLists();
77         void SortArrayToLogicalOrder();
78         void MoveItem(int index, int newIndex);
79         void MoveSelectedItems(bool bUp);
80         void SanitizeOrder();
81
82 // Implementation data
83 private:
84         ColumnArray m_cols; /**< Column list. */
85         ColumnArray m_defCols; /**< Default columns. */
86         static bool CompareColumnsByLogicalOrder( const column & el1, const column & el2 );
87
88         // Generated message map functions
89         //{{AFX_MSG(CDirColsDlg)
90         virtual BOOL OnInitDialog() override;
91         afx_msg void OnUp();
92         afx_msg void OnDown();
93         afx_msg void OnAdditionalProperties();
94         virtual void OnOK() override;
95         afx_msg void OnDefaults();
96         //}}AFX_MSG
97         DECLARE_MESSAGE_MAP()
98 public:
99         afx_msg void OnLvnItemchangedColdlgList(NMHDR *pNMHDR, LRESULT *pResult);
100 };