diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-05 12:52:30 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-05 12:52:30 +0000 |
commit | 3576b67db9fa0a3d8d5c1747cc3560504d31d125 (patch) | |
tree | f6a6cb9916cbf1aab83bac572fec8822f6ad065e /plugins/HistoryStats/src/dlgoption.cpp | |
parent | 73e6231455372205e912963083624aaa371bab0b (diff) |
- adaptation for standard Windows ways of handling Unicode;
- obsoleted code removed;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@8407 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HistoryStats/src/dlgoption.cpp')
-rw-r--r-- | plugins/HistoryStats/src/dlgoption.cpp | 221 |
1 files changed, 89 insertions, 132 deletions
diff --git a/plugins/HistoryStats/src/dlgoption.cpp b/plugins/HistoryStats/src/dlgoption.cpp index e48b3bdb7a..d66d2d24a9 100644 --- a/plugins/HistoryStats/src/dlgoption.cpp +++ b/plugins/HistoryStats/src/dlgoption.cpp @@ -13,57 +13,46 @@ INT_PTR CALLBACK DlgOption::staticDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LP {
DlgOption* pDlg = reinterpret_cast<DlgOption*>(GetWindowLong(hDlg, DWLP_USER));
- switch (msg)
- {
- case WM_INITDIALOG:
- pDlg = new DlgOption(hDlg);
- SetWindowLong(hDlg, DWLP_USER, reinterpret_cast<LONG>(pDlg));
- pDlg->onWMInitDialog();
- return TRUE;
-
- case WM_DESTROY:
- delete pDlg;
- SetWindowLong(hDlg, DWLP_USER, 0);
+ switch (msg) {
+ case WM_INITDIALOG:
+ pDlg = new DlgOption(hDlg);
+ SetWindowLong(hDlg, DWLP_USER, reinterpret_cast<LONG>(pDlg));
+ pDlg->onWMInitDialog();
+ return TRUE;
+
+ case WM_DESTROY:
+ delete pDlg;
+ SetWindowLong(hDlg, DWLP_USER, 0);
+ break;
+
+ case WM_WINDOWPOSCHANGED:
+ pDlg->rearrangeControls();
+ return TRUE;
+
+ case WM_NOTIFY:
+ NMHDR* p = reinterpret_cast<NMHDR*>(lParam);
+ switch (p->idFrom) {
+ case 0:
+ if (p->code == PSN_APPLY)
+ pDlg->saveSettings();
break;
- case WM_WINDOWPOSCHANGED:
- pDlg->rearrangeControls();
- return TRUE;
-
- case WM_NOTIFY:
- {
- NMHDR* p = reinterpret_cast<NMHDR*>(lParam);
-
- switch (p->idFrom)
- {
- case 0:
- if (p->code == PSN_APPLY)
- {
- pDlg->saveSettings();
- }
- break;
-
- case IDC_BAND:
- {
- if (p->code == BandCtrl::BCN_CLICKED)
- {
- BandCtrl::NMBANDCTRL* pNM = reinterpret_cast<BandCtrl::NMBANDCTRL*>(lParam);
-
- pDlg->onBandClicked(pNM->hButton, pNM->dwData);
- }
- else if (p->code == BandCtrl::BCN_DROPDOWN)
- {
- BandCtrl::NMBANDCTRL* pNM = reinterpret_cast<BandCtrl::NMBANDCTRL*>(lParam);
-
- pDlg->onBandDropDown(pNM->hButton, pNM->dwData);
- }
- }
- break;
- }
+ case IDC_BAND:
+ if (p->code == BandCtrl::BCN_CLICKED) {
+ BandCtrl::NMBANDCTRL* pNM = reinterpret_cast<BandCtrl::NMBANDCTRL*>(lParam);
+
+ pDlg->onBandClicked(pNM->hButton, pNM->dwData);
+ }
+ else if (p->code == BandCtrl::BCN_DROPDOWN) {
+ BandCtrl::NMBANDCTRL* pNM = reinterpret_cast<BandCtrl::NMBANDCTRL*>(lParam);
+
+ pDlg->onBandDropDown(pNM->hButton, pNM->dwData);
}
break;
+ }
+ break;
}
-
+
return FALSE;
}
@@ -76,8 +65,7 @@ void DlgOption::onWMInitDialog() // init band control
m_Band << GetDlgItem(m_hWnd, IDC_BAND);
- if (!g_bConfigureLock)
- {
+ if (!g_bConfigureLock) {
// lock configure dialog for us
g_bConfigureLock = true;
m_bAcquiredLock = true;
@@ -86,11 +74,11 @@ void DlgOption::onWMInitDialog() m_Band.setLayout(7);
// init pages
- m_pPage[opGlobal] = new SubGlobal();
+ m_pPage[opGlobal] = new SubGlobal();
m_pPage[opExclude] = new SubExclude();
- m_pPage[opInput] = new SubInput();
+ m_pPage[opInput] = new SubInput();
m_pPage[opColumns] = new SubColumns();
- m_pPage[opOutput] = new SubOutput();
+ m_pPage[opOutput] = new SubOutput();
RECT rPage, rBand;
@@ -99,22 +87,24 @@ void DlgOption::onWMInitDialog() rPage.top += rBand.bottom;
- static const struct {
+ static const struct
+ {
WORD iconId;
- mu_text* szText;
- mu_text* szTooltip;
+ TCHAR* szText;
+ TCHAR* szTooltip;
bool bRight;
WORD dlgId;
bool bVisible;
bool bDropDown;
- } pageBand[] = {
- { IDI_SETT_GLOBAL , I18N(muT("Global")) , I18N(muT("Global settings")) , false, IDD_SUB_GLOBAL , true , false },
- { IDI_SETT_EXCLUDE , I18N(muT("Exclude")), I18N(muT("Exclude contacts")) , false, IDD_SUB_EXCLUDE, true , false },
- { IDI_SETT_INPUT , I18N(muT("Input")) , I18N(muT("Input settings")) , false, IDD_SUB_INPUT , true , false },
- { IDI_SETT_COLUMNS , I18N(muT("Columns")), I18N(muT("Column settings")) , false, IDD_SUB_COLUMNS, true , false },
- { IDI_SETT_OUTPUT , I18N(muT("Output")) , I18N(muT("Output settings")) , false, IDD_SUB_OUTPUT , true , false },
- { IDI_CREATE , I18N(muT("Create")) , I18N(muT("Create statistics")) , true , 0 , true , true },
- { IDI_CREATE_WARNING, I18N(muT("Create")) , I18N(muT("Create statistics (there are warnings)")), true , 0 , false, true },
+ }
+ pageBand[] = {
+ { IDI_SETT_GLOBAL, LPGENT("Global"), LPGENT("Global settings"), false, IDD_SUB_GLOBAL, true, false },
+ { IDI_SETT_EXCLUDE, LPGENT("Exclude"), LPGENT("Exclude contacts"), false, IDD_SUB_EXCLUDE, true, false },
+ { IDI_SETT_INPUT, LPGENT("Input"), LPGENT("Input settings"), false, IDD_SUB_INPUT, true, false },
+ { IDI_SETT_COLUMNS, LPGENT("Columns"), LPGENT("Column settings"), false, IDD_SUB_COLUMNS, true, false },
+ { IDI_SETT_OUTPUT, LPGENT("Output"), LPGENT("Output settings"), false, IDD_SUB_OUTPUT, true, false },
+ { IDI_CREATE, LPGENT("Create"), LPGENT("Create statistics"), true, 0, true, true },
+ { IDI_CREATE_WARNING, LPGENT("Create"), LPGENT("Create statistics (there are warnings)"), true, 0, false, true },
};
array_each_(i, pageBand)
@@ -127,30 +117,24 @@ void DlgOption::onWMInitDialog() dwFlags |= pageBand[i].bVisible ? 0 : BandCtrl::BCF_HIDDEN;
dwFlags |= pageBand[i].bDropDown ? BandCtrl::BCF_DROPDOWN : 0;
- HANDLE hButton = m_Band.addButton(dwFlags, hIcon, i, i18n(pageBand[i].szTooltip), i18n(pageBand[i].szText));
+ HANDLE hButton = m_Band.addButton(dwFlags, hIcon, i, TranslateTS(pageBand[i].szTooltip), TranslateTS(pageBand[i].szText));
DestroyIcon(hIcon);
- if (i >= opFirstPage && i <= opLastPage)
- {
+ if (i >= opFirstPage && i <= opLastPage) {
m_hPageButton[i] = hButton;
m_pPage[i]->createWindow(this, pageBand[i].dlgId, rPage);
}
else if (i == opCreate)
- {
m_hCreateButton = hButton;
- }
else if (i == opCreateWarn)
- {
m_hCreateWarnButton = hButton;
- }
}
// init first tab
int nNewPage = g_pSettings->getLastPage();
- if (nNewPage < opFirstPage || nNewPage > opLastPage)
- {
+ if (nNewPage < opFirstPage || nNewPage > opLastPage) {
nNewPage = opGlobal;
}
@@ -159,13 +143,12 @@ void DlgOption::onWMInitDialog() // show/hide info about possible problems with PNG output
updateProblemInfo();
}
- else
- {
+ else {
// inform the user that he can't simultaneously access the options with two dialogs
ShowWindow(m_Band, SW_HIDE);
ShowWindow(GetDlgItem(m_hWnd, IDC_MESSAGE), SW_SHOW);
- SetDlgItemText(m_hWnd, IDC_MESSAGE, i18n(muT("You can't access the options of HistoryStats as long as the stand-alone configuration dialog of HistoryStats is open. Please close the stand-alone dialog before opening the options dialog of Miranda IM to see the options of HistoryStats here.\r\n\r\nNote that the options offered by both dialogs are the same.")));
+ SetDlgItemText(m_hWnd, IDC_MESSAGE, TranslateT("You can't access the options of HistoryStats as long as the stand-alone configuration dialog of HistoryStats is open. Please close the stand-alone dialog before opening the options dialog of Miranda IM to see the options of HistoryStats here.\r\n\r\nNote that the options offered by both dialogs are the same."));
}
// reset flag
@@ -174,22 +157,15 @@ void DlgOption::onWMInitDialog() void DlgOption::onRunStats()
{
- if (m_bSettingsModified)
- {
- int svar = MessageBox(
- m_hWnd,
- i18n(muT("You have unsaved settings. Do you want to save before running HistoryStats?")),
- i18n(muT("HistoryStats")),
- MB_YESNOCANCEL);
+ if (m_bSettingsModified) {
+ int svar = MessageBox(m_hWnd,
+ TranslateT("You have unsaved settings. Do you want to save before running HistoryStats?"),
+ TranslateT("HistoryStats"), MB_YESNOCANCEL);
if (svar == IDYES)
- {
saveSettings();
- }
else
- {
return;
- }
}
Statistic::run(*g_pSettings, Statistic::fromOptions, g_hInst, m_hWnd);
@@ -197,12 +173,9 @@ void DlgOption::onRunStats() void DlgOption::onBandClicked(HANDLE hButton, DWORD dwData)
{
- if (dwData >= opFirstPage && dwData <= opLastPage && dwData != m_nCurPage)
- {
- if (m_nCurPage != dwData)
- {
- if (m_nCurPage != -1)
- {
+ if (dwData >= opFirstPage && dwData <= opLastPage && dwData != m_nCurPage) {
+ if (m_nCurPage != dwData) {
+ if (m_nCurPage != -1) {
m_Band.checkButton(m_hPageButton[m_nCurPage], false);
m_pPage[m_nCurPage]->hide();
}
@@ -214,15 +187,12 @@ void DlgOption::onBandClicked(HANDLE hButton, DWORD dwData) m_pPage[m_nCurPage]->show();
}
else if (dwData == opCreate || dwData == opCreateWarn)
- {
onRunStats();
- }
}
void DlgOption::onBandDropDown(HANDLE hButton, DWORD dwData)
{
- if (dwData == opCreate || dwData == opCreateWarn)
- {
+ if (dwData == opCreate || dwData == opCreateWarn) {
// determine position for popup menu
RECT rItem = m_Band.getButtonRect(hButton);
@@ -233,15 +203,14 @@ void DlgOption::onBandDropDown(HANDLE hButton, DWORD dwData) // create and display popup menu
HMENU hPopup = CreatePopupMenu();
- if (dwData == opCreateWarn)
- {
- AppendMenu(hPopup, MF_STRING, 1, i18n(muT("Show warnings...")));
+ if (dwData == opCreateWarn) {
+ AppendMenu(hPopup, MF_STRING, 1, TranslateT("Show warnings..."));
AppendMenu(hPopup, MF_SEPARATOR, 0, NULL);
}
UINT iMenuFlags = g_pSettings->canShowStatistics() ? 0 : (MF_DISABLED | MF_GRAYED);
- AppendMenu(hPopup, iMenuFlags | MF_STRING, 2, i18n(muT("Show statistics")));
+ AppendMenu(hPopup, iMenuFlags | MF_STRING, 2, TranslateT("Show statistics"));
int nShowInfo = TrackPopupMenu(
hPopup,
@@ -254,15 +223,14 @@ void DlgOption::onBandDropDown(HANDLE hButton, DWORD dwData) DestroyMenu(hPopup);
- switch (nShowInfo)
- {
- case 1:
- onProblemInfo();
- break;
+ switch (nShowInfo) {
+ case 1:
+ onProblemInfo();
+ break;
- case 2:
- g_pSettings->showStatistics();
- break;
+ case 2:
+ g_pSettings->showStatistics();
+ break;
}
}
}
@@ -272,28 +240,22 @@ void DlgOption::onProblemInfo() HelpVec help;
bool bAreProblems = reinterpret_cast<SubColumns*>(m_pPage[opColumns])->configHasConflicts(&help);
- if (bAreProblems && help.size() > 0)
- {
- ext::string msg = i18n(muT("There are some potential conflicts in your settings. However, this is only a warning and can in general be ignored. The details:"));
+ if (bAreProblems && help.size() > 0) {
+ ext::string msg = TranslateT("There are some potential conflicts in your settings. However, this is only a warning and can in general be ignored. The details:");
citer_each_(HelpVec, i, help)
{
- msg += muT("\r\n\r\n");
+ msg += _T("\r\n\r\n");
msg += i->first;
- if (!i->second.empty())
- {
- msg += muT("\r\n - ");
+ if (!i->second.empty()) {
+ msg += _T("\r\n - ");
msg += i->second;
}
}
- MessageBox(
- m_hWnd,
- msg.c_str(),
- i18n(muT("HistoryStats - Warning")),
- MB_ICONWARNING | MB_OK);
+ MessageBox(m_hWnd, msg.c_str(), TranslateT("HistoryStats - Warning"), MB_ICONWARNING | MB_OK);
}
}
@@ -307,8 +269,7 @@ void DlgOption::rearrangeControls() rOther.right = rClient.right;
utils::moveWindow(m_Band, rOther);
- if (m_bAcquiredLock)
- {
+ if (m_bAcquiredLock) {
rOther.top = rOther.bottom;
rOther.bottom = rClient.bottom;
@@ -321,8 +282,7 @@ void DlgOption::rearrangeControls() void DlgOption::settingsChanged()
{
- if (!m_bSettingsModified)
- {
+ if (!m_bSettingsModified) {
m_bSettingsModified = true;
SendMessage(GetParent(m_hWnd), PSM_CHANGED, 0, 0);
}
@@ -330,8 +290,7 @@ void DlgOption::settingsChanged() int DlgOption::saveSettings()
{
- if (m_bAcquiredLock)
- {
+ if (m_bAcquiredLock) {
// force all pages to write to local settings store
array_each_(i, m_pPage)
{
@@ -365,21 +324,19 @@ void DlgOption::updateProblemInfo() bool bShowProblemInfo = reinterpret_cast<SubColumns*>(m_pPage[opColumns])->configHasConflicts(NULL);
m_Band.showButton(m_hCreateButton, !bShowProblemInfo);
- m_Band.showButton(m_hCreateWarnButton,bShowProblemInfo);
+ m_Band.showButton(m_hCreateWarnButton, bShowProblemInfo);
}
-DlgOption::DlgOption(HWND hWnd)
- : m_hWnd(hWnd), m_bSettingsModified(false), m_nCurPage(-1), m_LocalS(*g_pSettings),
+DlgOption::DlgOption(HWND hWnd) :
+ m_hWnd(hWnd), m_bSettingsModified(false), m_nCurPage(-1), m_LocalS(*g_pSettings),
m_hCreateButton(NULL), m_hCreateWarnButton(NULL), m_bAcquiredLock(false)
-{
-}
+{}
DlgOption::~DlgOption()
{
// this destructor is called upon WM_DESTROY
- if (m_bAcquiredLock)
- {
+ if (m_bAcquiredLock) {
// release configure dialog lock
m_bAcquiredLock = false;
g_bConfigureLock = false;
|