diff options
author | George Hazan <george.hazan@gmail.com> | 2014-05-22 14:31:16 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-05-22 14:31:16 +0000 |
commit | 794b3c318b582abb7eab83dd9a32c9a894048b0b (patch) | |
tree | dd4bc56f8c70d9366295ae5fad9ec18048b55a36 /plugins/SpellChecker/src/ardialog.cpp | |
parent | 6d6d5591b1ee1002ccf1da0f98942f7aa78ccb80 (diff) |
- unused error message removed;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@9277 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SpellChecker/src/ardialog.cpp')
-rw-r--r-- | plugins/SpellChecker/src/ardialog.cpp | 106 |
1 files changed, 47 insertions, 59 deletions
diff --git a/plugins/SpellChecker/src/ardialog.cpp b/plugins/SpellChecker/src/ardialog.cpp index cfaacbb770..22634c8858 100644 --- a/plugins/SpellChecker/src/ardialog.cpp +++ b/plugins/SpellChecker/src/ardialog.cpp @@ -37,8 +37,8 @@ struct Data };
BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal,
- Dictionary *dict, const TCHAR *find, const TCHAR *replace, BOOL useVariables,
- BOOL findReadOnly, AutoReplaceDialogCallback callback, void *param)
+ Dictionary *dict, const TCHAR *find, const TCHAR *replace, BOOL useVariables,
+ BOOL findReadOnly, AutoReplaceDialogCallback callback, void *param)
{
Data *data = new Data();
data->dict = dict;
@@ -55,20 +55,14 @@ BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal, data->replace = replace;
if (modal)
- {
- return DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ADD_REPLACEMENT), parent,
- AddReplacementDlgProc, (LPARAM) data);
- }
- else
- {
- HWND hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_REPLACEMENT), parent,
- AddReplacementDlgProc, (LPARAM) data);
- SetForegroundWindow(hwnd);
- SetFocus(hwnd);
- SetFocus(GetDlgItem(hwnd, IDC_NEW));
- ShowWindow(hwnd, SW_SHOW);
- return TRUE;
- }
+ return DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ADD_REPLACEMENT), parent, AddReplacementDlgProc, (LPARAM)data);
+
+ HWND hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_REPLACEMENT), parent, AddReplacementDlgProc, (LPARAM)data);
+ SetForegroundWindow(hwnd);
+ SetFocus(hwnd);
+ SetFocus(GetDlgItem(hwnd, IDC_NEW));
+ ShowWindow(hwnd, SW_SHOW);
+ return TRUE;
}
@@ -102,20 +96,17 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP switch(msg) {
case EM_PASTESPECIAL:
case WM_PASTE:
- {
- TCHAR text[256];
- GetWindowText(hwnd, text, SIZEOF(text));
+ TCHAR text[256];
+ GetWindowText(hwnd, text, SIZEOF(text));
- scoped_free<TCHAR> dest = data->dict->autoReplace->filterText(text);
- SetWindowText(hwnd, dest);
- break;
- }
+ scoped_free<TCHAR> dest = data->dict->autoReplace->filterText(text);
+ SetWindowText(hwnd, dest);
+ break;
}
return ret;
}
-
static BOOL CenterParent(HWND hwnd)
{
HWND hwndParent = GetParent(hwnd);
@@ -126,16 +117,16 @@ static BOOL CenterParent(HWND hwnd) GetWindowRect(hwnd, &rect);
GetWindowRect(hwndParent, &rectP);
- int width = rect.right - rect.left;
+ int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
- int x = ((rectP.right-rectP.left) - width) / 2 + rectP.left;
- int y = ((rectP.bottom-rectP.top) - height) / 2 + rectP.top;
+ int x = ((rectP.right - rectP.left) - width) / 2 + rectP.left;
+ int y = ((rectP.bottom - rectP.top) - height) / 2 + rectP.top;
- int screenwidth = GetSystemMetrics(SM_CXSCREEN);
+ int screenwidth = GetSystemMetrics(SM_CXSCREEN);
int screenheight = GetSystemMetrics(SM_CYSCREEN);
- if (x + width > screenwidth) x = screenwidth - width;
+ if (x + width > screenwidth) x = screenwidth - width;
if (y + height > screenheight) y = screenheight - height;
if (x < 0) x = 0;
if (y < 0) y = 0;
@@ -147,12 +138,12 @@ static BOOL CenterParent(HWND hwnd) static void Close(HWND hwndDlg, int ret)
{
- Data *data = (Data *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Data *data = (Data *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (!ret)
- data->callback(TRUE, data->dict,
- data->find.c_str(), data->replace.c_str(), data->useVariables,
- data->find.c_str(), data->param);
+ data->callback(TRUE, data->dict,
+ data->find.c_str(), data->replace.c_str(), data->useVariables,
+ data->find.c_str(), data->param);
if (data->modal)
EndDialog(hwndDlg, ret);
@@ -168,14 +159,14 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
- Data *data = (Data *) lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) data);
+ Data *data = (Data *)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)data);
- SetWindowLongPtr( GetDlgItem(hwndDlg, IDC_OLD), GWLP_USERDATA, (LONG_PTR)data);
- mir_subclassWindow( GetDlgItem(hwndDlg, IDC_OLD), OnlyCharsEditProc);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_OLD), GWLP_USERDATA, (LONG_PTR)data);
+ mir_subclassWindow(GetDlgItem(hwndDlg, IDC_OLD), OnlyCharsEditProc);
HICON hIcon = Skin_GetIcon("spellchecker_enabled");
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
Skin_ReleaseIcon(hIcon);
SendDlgItemMessage(hwndDlg, IDC_OLD, EM_LIMITTEXT, 256, 0);
@@ -205,9 +196,9 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa GetWindowRect(GetDlgItem(hwndDlg, IDC_NEW), &rc_new);
rc_new.right = rc_old.right;
- SetWindowPos(GetDlgItem(hwndDlg, IDC_NEW), NULL, 0, 0,
- rc_new.right - rc_new.left, rc_new.bottom - rc_new.top,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER);
+ SetWindowPos(GetDlgItem(hwndDlg, IDC_NEW), NULL, 0, 0,
+ rc_new.right - rc_new.left, rc_new.bottom - rc_new.top,
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER);
}
else {
variables_skin_helpbutton(hwndDlg, IDC_VAR_HELP);
@@ -219,10 +210,10 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa return TRUE;
case WM_COMMAND:
- switch(wParam) {
+ switch (wParam) {
case IDOK:
{
- Data *data = (Data *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Data *data = (Data *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
TCHAR find[256];
if (data->findReadOnly)
@@ -236,22 +227,19 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa GetDlgItemText(hwndDlg, IDC_NEW, replace, SIZEOF(replace));
lstrtrim(replace);
- if (!data->findReadOnly && find[0] == 0) {
- MessageBox(hwndDlg, TranslateT("The wrong word can't be empty!"), TranslateT("Wrong Correction"),
- MB_OK | MB_ICONERROR);
- }
- else if (replace[0] == 0) {
- MessageBox(hwndDlg, TranslateT("The correction can't be empty!"), TranslateT("Wrong Correction"),
- MB_OK | MB_ICONERROR);
- }
- else if (_tcscmp(find, replace) == 0) {
- MessageBox(hwndDlg, TranslateT("The correction can't be equal to the wrong word!"), TranslateT("Wrong Correction"),
- MB_OK | MB_ICONERROR);
- }
+ if (!data->findReadOnly && find[0] == 0)
+ MessageBox(hwndDlg, TranslateT("The wrong word can't be empty!"), TranslateT("Wrong Correction"), MB_OK | MB_ICONERROR);
+
+ else if (replace[0] == 0)
+ MessageBox(hwndDlg, TranslateT("The correction can't be empty!"), TranslateT("Wrong Correction"), MB_OK | MB_ICONERROR);
+
+ else if (_tcscmp(find, replace) == 0)
+ MessageBox(hwndDlg, TranslateT("The correction can't be equal to the wrong word!"), TranslateT("Wrong Correction"), MB_OK | MB_ICONERROR);
+
else {
- data->callback(FALSE, data->dict,
- find, replace, IsDlgButtonChecked(hwndDlg, IDC_VARIABLES),
- data->find.c_str(), data->param);
+ data->callback(FALSE, data->dict,
+ find, replace, IsDlgButtonChecked(hwndDlg, IDC_VARIABLES),
+ data->find.c_str(), data->param);
Close(hwndDlg, 1);
}
}
@@ -275,6 +263,6 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa Close(hwndDlg, 0);
break;
}
-
+
return FALSE;
}
|