*
* @brief Implementation of the dialog used to select codepages
*/
-// ID line follows -- this is updated by SVN
-// $Id: LoadSaveCodepageDlg.cpp 5394 2008-05-29 09:47:36Z kimmov $
#include "stdafx.h"
#include "LoadSaveCodepageDlg.h"
-#include "Merge.h"
#include "resource.h"
-#include "unicoder.h"
#include "ExConverter.h"
#ifdef _DEBUG
#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLoadSaveCodepageDlg dialog
-CLoadSaveCodepageDlg::CLoadSaveCodepageDlg(int nFiles, CWnd* pParent /*=NULL*/)
-: CDialog(CLoadSaveCodepageDlg::IDD, pParent)
-, m_bAffectsLeft(TRUE)
-, m_bAffectsMiddle(TRUE)
-, m_bAffectsRight(TRUE)
-, m_bLoadSaveSameCodepage(TRUE)
-// CString m_sAffectsLeftString
-// CString m_sAffectsRightString
+CLoadSaveCodepageDlg::CLoadSaveCodepageDlg(int nFiles, CWnd* pParent /*= nullptr*/)
+: CTrDialog(CLoadSaveCodepageDlg::IDD, pParent)
+, m_bAffectsLeft(true)
+, m_bAffectsMiddle(true)
+, m_bAffectsRight(true)
+, m_bLoadSaveSameCodepage(true)
+// String m_sAffectsLeftString
+// String m_sAffectsRightString
+, m_bSaveCodepageBOM(false)
, m_nLoadCodepage(-1)
, m_nSaveCodepage(-1)
, m_bEnableSaveCodepage(false)
//}}AFX_DATA_INIT
}
-void CLoadSaveCodepageDlg::SetLeftRightAffectStrings(const CString & sAffectsLeft, const CString & sAffectsMiddle, const CString & sAffectsRight)
+void CLoadSaveCodepageDlg::SetLeftRightAffectStrings(const String & sAffectsLeft, const String & sAffectsMiddle, const String & sAffectsRight)
{
m_sAffectsLeftString = sAffectsLeft;
m_sAffectsMiddleString = sAffectsMiddle;
void CLoadSaveCodepageDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
+ CTrDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLoadSaveCodepageDlg)
DDX_Check(pDX, IDC_AFFECTS_LEFT_BTN, m_bAffectsLeft);
DDX_Check(pDX, IDC_AFFECTS_MIDDLE_BTN, m_bAffectsMiddle);
DDX_Control(pDX, IDC_AFFECTS_RIGHT_BTN, m_AffectsRightBtn);
DDX_Text(pDX, IDC_LOAD_CODEPAGE_TEXTBOX, m_nLoadCodepage);
DDX_Text(pDX, IDC_SAVE_CODEPAGE_TEXTBOX, m_nSaveCodepage);
+ DDX_Check(pDX, IDC_SAVE_CODEPAGE_BOM, m_bSaveCodepageBOM);
//}}AFX_DATA_MAP
}
-BEGIN_MESSAGE_MAP(CLoadSaveCodepageDlg, CDialog)
+BEGIN_MESSAGE_MAP(CLoadSaveCodepageDlg, CTrDialog)
//{{AFX_MSG_MAP(CLoadSaveCodepageDlg)
ON_BN_CLICKED(IDC_AFFECTS_LEFT_BTN, OnAffectsLeftBtnClicked)
ON_BN_CLICKED(IDC_AFFECTS_MIDDLE_BTN, OnAffectsMiddleBtnClicked)
*/
BOOL CLoadSaveCodepageDlg::OnInitDialog()
{
- theApp.TranslateDialog(m_hWnd);
- CDialog::OnInitDialog();
-
- // setup handler for resizing this dialog
- m_constraint.InitializeCurrentSize(this);
- // configure how individual controls adjust when dialog resizes
- m_constraint.ConstrainItem(IDC_AFFECTS_GROUP, 0, 1, 0, 0); // grows right
- // IDC_AFFECTS_LEFT_BTN doesn't move or grow
- m_constraint.ConstrainItem(IDC_LEFT_FILES_LABEL, 0, 1, 0, 0); // grows right
- // IDC_AFFECTS_RIGHT_BTN doesn't move or grow
- m_constraint.ConstrainItem(IDC_RIGHT_FILES_LABEL, 0, 1, 0, 0); // grows right
- m_constraint.ConstrainItem(IDC_LOADING_GROUP, 0, 1, 0, 0); // grows right
- m_constraint.ConstrainItem(IDC_LOAD_CODEPAGE_TEXTBOX, 0, 1, 0, 0); // grows right
- m_constraint.ConstrainItem(IDC_SAVING_GROUP, 0, 1, 0, 0); // grows right
- m_constraint.ConstrainItem(IDC_SAVE_CODEPAGE_TEXTBOX, 0, 1, 0, 0); // grows right
- m_constraint.ConstrainItem(IDOK, 0.33, 0, 0, 0); // floats right
- m_constraint.ConstrainItem(IDCANCEL, 0.67, 0, 0, 0); // floats right
- m_constraint.DisallowHeightGrowth();
- m_constraint.SubclassWnd(); // install subclassing
- m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("LoadSaveCodepageDlg"), false); // persist size via registry
+ CTrDialog::OnInitDialog();
IExconverter *pexconv = Exconverter::getInstance();
- if (pexconv != NULL)
+ if (pexconv != nullptr)
{
CComboBox combol, combos;
combol.Attach(::GetDlgItem(m_hWnd, IDC_LOAD_CODEPAGE_TEXTBOX));
combos.Attach(::GetDlgItem(m_hWnd, IDC_SAVE_CODEPAGE_TEXTBOX));
- CodePageInfo cpi[256];
- int count = pexconv->enumCodePages(cpi, sizeof(cpi)/sizeof(CodePageInfo));
- int i, j;
- for (i = 0, j = 0; i < count; i++)
+ std::vector<CodePageInfo> cpi = pexconv->enumCodePages();
+ for (size_t i = 0, j = 0; i < cpi.size(); i++)
{
- if (cpi[i].codepage == CP_UCS2LE)
- continue;
- TCHAR desc[256];
- wsprintf(desc, _T("%05d - %ls"), cpi[i].codepage, cpi[i].desc);
- combol.AddString(desc);
- combol.SetItemData(j, cpi[i].codepage);
- combos.AddString(desc);
- combos.SetItemData(j, cpi[i].codepage);
+ String desc = strutils::format(_T("%05d - %s"), cpi[i].codepage, cpi[i].desc);
+ combol.AddString(desc.c_str());
+ combos.AddString(desc.c_str());
if (cpi[i].codepage == m_nLoadCodepage)
{
- combol.SetCurSel(j);
- combos.SetCurSel(j);
+ combol.SetCurSel(static_cast<int>(j));
+ combos.SetCurSel(static_cast<int>(j));
}
j++;
}
combos.Detach();
}
- AfxGetMainWnd()->CenterWindow(this);
+ CenterWindow();
SetDlgItemText(IDC_LEFT_FILES_LABEL, m_sAffectsLeftString);
SetDlgItemText(IDC_MIDDLE_FILES_LABEL, m_sAffectsMiddleString);
}
/**
- * @brief Shortcut to enable or disable a control
- */
-void CLoadSaveCodepageDlg::EnableDlgItem(int item, bool enable)
-{
- GetDlgItem(item)->EnableWindow(!!enable);
-}
-
-/**
* @brief If user unchecks left, then check right (to ensure never have nothing checked)
*/
void CLoadSaveCodepageDlg::OnAffectsLeftBtnClicked()
EnableDlgItem(IDC_LOAD_SAVE_SAME_CODEPAGE, false);
bool EnableSave = m_bEnableSaveCodepage && !m_bLoadSaveSameCodepage;
EnableDlgItem(IDC_SAVE_CODEPAGE_TEXTBOX, EnableSave);
+ EnableDlgItem(IDC_SAVE_CODEPAGE_BOM, EnableSave);
}
/**
*/
void CLoadSaveCodepageDlg::OnOK ()
{
- CDialog::OnOK();
+ CTrDialog::OnOK();
if (m_bLoadSaveSameCodepage)
{
m_nSaveCodepage = m_nLoadCodepage;