OSDN Git Service

MergeLang.vcxproj*: Add *.po files for ShellExtension
[winmerge-jp/winmerge-jp.git] / Src / DirColsDlg.cpp
index eb8e5a5..9adda03 100644 (file)
@@ -5,19 +5,14 @@
  *
  * @date  Created: 2003-08-19
  */
-// ID line follows -- this is updated by SVN
-// $Id$
 
 
 #include "stdafx.h"
 #include "DirColsDlg.h"
 #include <algorithm>
-#include "Merge.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
 #endif
 
 /////////////////////////////////////////////////////////////////////////////
@@ -27,8 +22,8 @@ static char THIS_FILE[] = __FILE__;
  * @brief Default dialog constructor.
  * @param [in] pParent Dialog's parent component (window).
  */
-CDirColsDlg::CDirColsDlg(CWnd* pParent /*=NULL*/)
-       : CDialog(CDirColsDlg::IDD, pParent)
+CDirColsDlg::CDirColsDlg(CWnd* pParent /*= nullptr*/)
+       : CTrDialog(CDirColsDlg::IDD, pParent)
        , m_bReset(false)
 {
 }
@@ -38,13 +33,13 @@ CDirColsDlg::CDirColsDlg(CWnd* pParent /*=NULL*/)
  */
 void CDirColsDlg::DoDataExchange(CDataExchange* pDX)
 {
-       CDialog::DoDataExchange(pDX);
+       CTrDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(CDirColsDlg)
        DDX_Control(pDX, IDC_COLDLG_LIST, m_listColumns);
        //}}AFX_DATA_MAP
 }
 
-BEGIN_MESSAGE_MAP(CDirColsDlg, CDialog)
+BEGIN_MESSAGE_MAP(CDirColsDlg, CTrDialog)
        //{{AFX_MSG_MAP(CDirColsDlg)
        ON_BN_CLICKED(IDC_UP, OnUp)
        ON_BN_CLICKED(IDC_DOWN, OnDown)
@@ -61,10 +56,13 @@ END_MESSAGE_MAP()
  */
 void CDirColsDlg::InitList()
 {
+       const int lpx = CClientDC(this).GetDeviceCaps(LOGPIXELSX);
+       auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
+
        // Show selection across entire row.
        // Also enable infotips.
        m_listColumns.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
-       m_listColumns.InsertColumn(0, _T(""), LVCFMT_LEFT, 150);
+       m_listColumns.InsertColumn(0, _T(""), LVCFMT_LEFT, pointToPixel(148));
 }
 
 /**
@@ -72,8 +70,7 @@ void CDirColsDlg::InitList()
  */
 BOOL CDirColsDlg::OnInitDialog() 
 {
-       theApp.TranslateDialog(m_hWnd);
-       CDialog::OnInitDialog();
+       CTrDialog::OnInitDialog();
        InitList();
        LoadLists();
        
@@ -154,7 +151,7 @@ void CDirColsDlg::MoveItem(int index, int newIndex)
 {
        // Get current column data
        String text =  m_listColumns.GetItemText(index, 0);
-       BOOL checked = m_listColumns.GetCheck(index);
+       bool checked = !!m_listColumns.GetCheck(index);
        UINT state = m_listColumns.GetItemState(index, LVIS_SELECTED);
        DWORD_PTR data = m_listColumns.GetItemData(index);
 
@@ -171,15 +168,15 @@ void CDirColsDlg::MoveItem(int index, int newIndex)
 
 /**
  * @brief Move selected items one position up or down.
- * @param [in] bUp If TRUE items are moved up,
- *  if FALSE items are moved down.
+ * @param [in] bUp If `true` items are moved up,
+ *  if `false` items are moved down.
  */
 void CDirColsDlg::MoveSelectedItems(bool bUp)
 {
        int firstInd = -1;
        POSITION pos = m_listColumns.GetFirstSelectedItemPosition();
 
-       while (pos)
+       while (pos != nullptr)
        {
                int ind = m_listColumns.GetNextSelectedItem(pos);
                int newInd = bUp ? ind - 1: ind + 1;
@@ -197,7 +194,7 @@ void CDirColsDlg::MoveSelectedItems(bool bUp)
  */
 void CDirColsDlg::OnUp()
 {
-       MoveSelectedItems(TRUE);
+       MoveSelectedItems(true);
 }
 
 /**
@@ -205,7 +202,7 @@ void CDirColsDlg::OnUp()
  */
 void CDirColsDlg::OnDown() 
 {
-       MoveSelectedItems(FALSE);
+       MoveSelectedItems(false);
 }
 
 /**
@@ -241,7 +238,7 @@ void CDirColsDlg::OnOK()
 
        for (int i = 0; i < m_listColumns.GetItemCount(); i++)
        {
-               BOOL checked = m_listColumns.GetCheck(i);
+               bool checked = !!m_listColumns.GetCheck(i);
                DWORD_PTR data = m_listColumns.GetItemData(i);
                column & col1 = m_cols[data];
                if (checked)
@@ -250,7 +247,7 @@ void CDirColsDlg::OnOK()
                        col1.phy_col = -1;
        }
 
-       CDialog::OnOK();
+       CTrDialog::OnOK();
 }
 
 /**
@@ -270,7 +267,7 @@ void CDirColsDlg::OnLvnItemchangedColdlgList(NMHDR *pNMHDR, LRESULT *pResult)
 {
        POSITION pos = m_listColumns.GetFirstSelectedItemPosition();
 
-       if (pos)
+       if (pos != nullptr)
        {
                int ind = m_listColumns.GetNextSelectedItem(pos);
                DWORD_PTR data = m_listColumns.GetItemData(ind);
@@ -278,22 +275,15 @@ void CDirColsDlg::OnLvnItemchangedColdlgList(NMHDR *pNMHDR, LRESULT *pResult)
                ColumnArray::size_type j;
                for (j = 0; j < m_cols.size(); j++)
                {
-                       if (m_cols[j].log_col == data)
+                       if (static_cast<DWORD_PTR>(m_cols[j].log_col) == data)
                                break;
                }
-               GetDlgItem(IDC_COLDLG_DESC)->SetWindowText(m_cols[j].desc.c_str());
+               SetDlgItemText(IDC_COLDLG_DESC, m_cols[j].desc);
 
                // Disable Up/Down -buttons when first/last items are selected.
-               if (ind == 0)
-                       GetDlgItem(IDC_UP)->EnableWindow(FALSE);
-               else
-                       GetDlgItem(IDC_UP)->EnableWindow(TRUE);
-
-               if (ind == m_listColumns.GetItemCount() - m_listColumns.GetSelectedCount())
-                       GetDlgItem(IDC_DOWN)->EnableWindow(FALSE);
-               else
-                       GetDlgItem(IDC_DOWN)->EnableWindow(TRUE);
-
+               EnableDlgItem(IDC_UP, ind != 0);
+               EnableDlgItem(IDC_DOWN,
+                       ind != m_listColumns.GetItemCount() - static_cast<int>(m_listColumns.GetSelectedCount()));
        }
        *pResult = 0;
 }