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