OSDN Git Service

autoit.cpp - Macros >> User 1 ..... Variable >> User 2 (#749) (2)
[winmerge-jp/winmerge-jp.git] / Src / DirColsDlg.h
index bc490e4..519b589 100644 (file)
@@ -5,53 +5,57 @@
  *
  * @date  Created: 2003-08-19
  */
-// RCS ID line follows -- this is updated by CVS
-// $Id$
-
-
-#if !defined(AFX_DIRCOLSDLG_H__2FCB576C_C609_4623_8C55_F3870F22CA0B__INCLUDED_)
-#define AFX_DIRCOLSDLG_H__2FCB576C_C609_4623_8C55_F3870F22CA0B__INCLUDED_
 #pragma once
 
-#include "HScrollListBox.h"
+#include <vector>
+#include "TrDialogs.h"
+#include "UnicodeString.h"
 
 /////////////////////////////////////////////////////////////////////////////
 // CDirColsDlg dialog
 
 /**
- * @brief Dialog to choose & order columns to be shown in dirview of differing files
+ * @brief A Dialog for choosing visible folder compare columns.
+ * This class implements a dialog for choosing visible columns in folder
+ * compare. Columns can be also re-ordered. There is one listview component
+ * which lists all available columns. Every column name has a checkbox with
+ * it. If the checkbox is checked, the column is visible.
+ *
+ * @note: Due to how columns handling code is implemented, hidden columns
+ * must be always be last in the list with order number -1.
+ * @todo: Allow hidden columns between visible columns.
  */
-class CDirColsDlg : public CDialog
+class CDirColsDlg : public CTrDialog
 {
 // Public types
 public:
        /** @brief One column's information. */
        struct column
        {
-               CString name; /**< Column name */
-               CString desc; /**< Description for column */
+               String name; /**< Column name */
+               String desc; /**< Description for column */
                int log_col; /**< Logical (shown) order number */
                int phy_col; /**< Physical (in memory) order number */
-               column() : log_col(-1), phy_col(-1) { } /**< default constructor for use in CArray */
-               column(LPCTSTR sz, LPCTSTR dsc, int log, int phy) : name(sz), desc(dsc), log_col(log), phy_col(phy) { } 
+               column(const String & colName, const String & dsc, int log, int phy)
+                       : name(colName), desc(dsc), log_col(log), phy_col(phy)
+               { } 
        };
-       typedef CArray<column, column> ColumnArray;
+       typedef std::vector<column> ColumnArray;
 
 // Construction
 public:
-       CDirColsDlg(CWnd* pParent = NULL);   // standard constructor
-       void AddColumn(CString name, CString desc, int log, int phy=-1)
-               { column c(name, desc, log, phy); m_cols.Add(c); }
-       void AddDefColumn(CString name, int log, int phy=-1)
-               { column c(name, _T(""), log, phy); m_defCols.Add(c); }
+       explicit CDirColsDlg(CWnd* pParent = nullptr);   // standard constructor
+       void AddColumn(const String & name, const String & desc, int log, int phy=-1)
+               { column c(name, desc, log, phy); m_cols.push_back(c); }
+       void AddDefColumn(const String & name, int log, int phy=-1)
+               { column c(name, _T(""), log, phy); m_defCols.push_back(c); }
        const ColumnArray & GetColumns() const { return m_cols; }
 
 // Dialog Data
        //{{AFX_DATA(CDirColsDlg)
        enum { IDD = IDD_DIRCOLS };
-       CHScrollListBox m_list_show;
-       CHScrollListBox m_list_hide;
-       BOOL            m_bReset;
+       CListCtrl m_listColumns;
+       bool m_bReset;
        //}}AFX_DATA
 
 
@@ -60,43 +64,34 @@ public:
        //{{AFX_VIRTUAL(CDirColsDlg)
        protected:
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
-       virtual BOOL PreTranslateMessage(MSG* pMsg);
        //}}AFX_VIRTUAL
 
 // Implementation methods
 protected:
+       void InitList();
        void LoadLists();
+       void SelectItem(int index);
        void LoadDefLists();
-       void MoveItems(CHScrollListBox * list1, CHScrollListBox * list2, bool top);
-       void UpdateEnables();
        void SortArrayToLogicalOrder();
-       static int cmpcols(const void * el1, const void * el2);
+       void MoveItem(int index, int newIndex);
+       void MoveSelectedItems(bool bUp);
+       void SanitizeOrder();
 
 // Implementation data
 private:
-       ColumnArray m_cols;
-       ColumnArray m_defCols;
-       BOOL m_bFromKeyboard; /**< Is up/down movement originating from keyboard? */
+       ColumnArray m_cols; /**< Column list. */
+       ColumnArray m_defCols; /**< Default columns. */
+       static bool CompareColumnsByLogicalOrder( const column & el1, const column & el2 );
 
        // Generated message map functions
        //{{AFX_MSG(CDirColsDlg)
-       virtual BOOL OnInitDialog();
+       virtual BOOL OnInitDialog() override;
        afx_msg void OnUp();
        afx_msg void OnDown();
-       afx_msg void OnAdd();
-       afx_msg void OnRemove();
-       virtual void OnOK();
+       virtual void OnOK() override;
        afx_msg void OnDefaults();
-       afx_msg void OnLbnSelchangeListShow();
-       afx_msg void OnLbnSelchangeListHide();
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 public:
-       afx_msg void OnLbnDblclkListShow();
-       afx_msg void OnLbnDblclkListHide();
+       afx_msg void OnLvnItemchangedColdlgList(NMHDR *pNMHDR, LRESULT *pResult);
 };
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_DIRCOLSDLG_H__2FCB576C_C609_4623_8C55_F3870F22CA0B__INCLUDED_)