OSDN Git Service

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