OSDN Git Service

Keep selected items visible in Folder Compare columns dialog.
[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 // ID line follows -- this is updated by SVN
9 // $Id$
10
11
12 #if !defined(AFX_DIRCOLSDLG_H__2FCB576C_C609_4623_8C55_F3870F22CA0B__INCLUDED_)
13 #define AFX_DIRCOLSDLG_H__2FCB576C_C609_4623_8C55_F3870F22CA0B__INCLUDED_
14 #pragma once
15
16
17 /////////////////////////////////////////////////////////////////////////////
18 // CDirColsDlg dialog
19
20 /**
21  * @brief A Dialog for choosing visible folder compare columns.
22  * This class implements a dialog for choosing visible columns in folder
23  * compare. Columns can be also re-ordered. There is one listview component
24  * which lists all available columns. Every column name has a checkbox with
25  * it. If the checkbox is checked, the column is visible.
26  *
27  * @note: Due to how columns handling code is implemented, hidden columns
28  * must be always be last in the list with order number -1.
29  * @todo: Allow hidden columns between visible columns.
30  */
31 class CDirColsDlg : public CDialog
32 {
33 // Public types
34 public:
35         /** @brief One column's information. */
36         struct column
37         {
38                 CString name; /**< Column name */
39                 CString desc; /**< Description for column */
40                 int log_col; /**< Logical (shown) order number */
41                 int phy_col; /**< Physical (in memory) order number */
42                 column() : log_col(-1), phy_col(-1) { } /**< default constructor for use in CArray */
43                 column(LPCTSTR sz, LPCTSTR dsc, int log, int phy) : name(sz), desc(dsc), log_col(log), phy_col(phy) { } 
44         };
45         typedef CArray<column, column> ColumnArray;
46
47 // Construction
48 public:
49         CDirColsDlg(CWnd* pParent = NULL);   // standard constructor
50         void AddColumn(LPCTSTR name, LPCTSTR desc, int log, int phy=-1)
51                 { column c(name, desc, log, phy); m_cols.Add(c); }
52         void AddDefColumn(LPCTSTR name, int log, int phy=-1)
53                 { column c(name, _T(""), log, phy); m_defCols.Add(c); }
54         const ColumnArray & GetColumns() const { return m_cols; }
55
56 // Dialog Data
57         //{{AFX_DATA(CDirColsDlg)
58         enum { IDD = IDD_DIRCOLS };
59         CListCtrl m_listColumns;
60         BOOL m_bReset;
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         static int cmpcols(const void * el1, const void * el2);
82
83 // Implementation data
84 private:
85         ColumnArray m_cols; /**< Column list. */
86         ColumnArray m_defCols; /**< Default columns. */
87
88         // Generated message map functions
89         //{{AFX_MSG(CDirColsDlg)
90         virtual BOOL OnInitDialog();
91         afx_msg void OnUp();
92         afx_msg void OnDown();
93         virtual void OnOK();
94         afx_msg void OnDefaults();
95         //}}AFX_MSG
96         DECLARE_MESSAGE_MAP()
97 public:
98         afx_msg void OnLvnItemchangedColdlgList(NMHDR *pNMHDR, LRESULT *pResult);
99 };
100
101 //{{AFX_INSERT_LOCATION}}
102 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
103
104 #endif // !defined(AFX_DIRCOLSDLG_H__2FCB576C_C609_4623_8C55_F3870F22CA0B__INCLUDED_)