-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathHelpDialog.cpp
More file actions
136 lines (122 loc) · 4.88 KB
/
Copy pathHelpDialog.cpp
File metadata and controls
136 lines (122 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* -------------------------------------
This file is part of AnalysePlugin for NotePad++
Copyright (c) 2022 Matthias H. mattesh(at)gmx.net
partly copied from the NotePad++ project from
Don HO don.h(at)free.fr
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
------------------------------------- */
//#include "stdafx.h"
#include "HelpDialog.h"
#include "PluginInterface.h"
#include "resource.h"
#include "PowerEditor\src\resource.h" // for NPP Version info
#include <windows.h>
#define MDBG_COMP "HlpDlg:"
#include "myDebug.h"
void HelpDlg::doDialog(int FuncCmdId)
{
if (!isCreated()) {
create(IDD_ANALYSE_HELP_DLG);
}
_cmdId = FuncCmdId;
goToCenter();
}
INT_PTR CALLBACK HelpDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM /*lParam*/)
{
switch (Message)
{
case WM_INITDIALOG :
{
// mono spaced font for manual
LOGFONT font1;
HFONT hf1 = (HFONT)::SendDlgItemMessage(_hSelf, IDC_DIALOG_DESCRIPTION, WM_GETFONT, 0, 0);
::GetObject(hf1, sizeof(LOGFONT), &font1);
generic_strncpy(font1.lfFaceName, TEXT("Courier New"), 12);
hf1 = CreateFontIndirect(&font1);
::SendDlgItemMessage(_hSelf, IDC_DIALOG_DESCRIPTION, WM_SETFONT, (WPARAM)hf1, 0);
// headline size
LOGFONT font2;
HFONT hf2 = (HFONT)::SendDlgItemMessage(_hSelf, IDC_TITLE_TEXT, WM_GETFONT, 0, 0);
::GetObject(hf2, sizeof(LOGFONT), &font2);
font2.lfHeight = -16;
font2.lfWeight |= FW_BOLD;
hf2 = CreateFontIndirect(&font2);
::SendDlgItemMessage(_hSelf, IDC_TITLE_TEXT, WM_SETFONT, (WPARAM)hf2, 0);
::SendDlgItemMessage(_hSelf, IDC_EMAIL_LINK, WM_SETTEXT, 0, (LPARAM)EMAIL_LINK);
_emailLink.init(_hInst, _hSelf);
_emailLink.create(::GetDlgItem(_hSelf, IDC_EMAIL_LINK), EMAIL_LINK);
::SendDlgItemMessage(_hSelf, IDC_NPP_PLUGINS_URL, WM_SETTEXT, 0, (LPARAM)NPP_PLUGINS_URL);
_urlNppPlugins.init(_hInst, _hSelf);
_urlNppPlugins.create(::GetDlgItem(_hSelf, IDC_NPP_PLUGINS_URL), NPP_PLUGINS_URL);
::SendDlgItemMessage(_hSelf, IDC_VERSION_STRING, WM_SETTEXT, 0, (LPARAM)_VersionString.c_str());
::SendDlgItemMessage(_hSelf, IDC_AUTHOR_NAME, WM_SETTEXT, 0, (LPARAM)AUTHOR_NAME);
::SendDlgItemMessage(_hSelf, IDC_DIALOG_DESCRIPTION, WM_SETTEXT, 0, (LPARAM)mManual.c_str());
::SendDlgItemMessage(_hSelf, IDC_NPP_VERSION_TEXT, WM_SETTEXT, 0, (LPARAM)NOTEPAD_PLUS_VERSION);
resizeWindow();
return TRUE;
}
case WM_CLOSE :
{
::SendMessage(_hParent, NPPM_SETMENUITEMCHECK, (WPARAM)_cmdId, (LPARAM)false);
break;
}
case WM_COMMAND :
{
switch (wParam)
{
case IDOK :
case IDCANCEL :
::SendMessage(_hParent, NPPM_SETMENUITEMCHECK, (WPARAM)_cmdId, (LPARAM)false);
display(FALSE);
return TRUE;
case IDC_BTN_MANUAL:
::SendDlgItemMessage(_hSelf, IDC_DIALOG_DESCRIPTION, WM_SETTEXT, 0, (LPARAM)mManual.c_str());
return TRUE;
case IDC_BTN_CHANGES:
::SendDlgItemMessage(_hSelf, IDC_DIALOG_DESCRIPTION, WM_SETTEXT, 0, (LPARAM)mChanges.c_str());
return TRUE;
default :
break;
}
break;
}
case WM_SIZE :
{
resizeWindow();
break;
} // case WM_SIZE
}
return FALSE;
}
void HelpDlg::resizeWindow() {
RECT rcDlg, rcText;// , rcOk;
getClientRect(rcDlg);
//HWND hOk = ::GetDlgItem(_hSelf, IDOK);
HWND hText = ::GetDlgItem(_hSelf,IDC_DIALOG_DESCRIPTION);
::GetClientRect(hText, &rcText);
//::GetClientRect(hOk, &rcOk);
//POINT pOk = getTopPoint(hOk);
POINT pText = getTopPoint(hText);
int dWidth = rcDlg.right-rcDlg.left-20; // for border
int dTextHeight = rcDlg.bottom-rcDlg.top-pText.y-10; // for border
if(dWidth>=0) {
if(dTextHeight>=0){
::MoveWindow(hText, pText.x, pText.y, dWidth, dTextHeight, TRUE);
}
// ::MoveWindow(hOk, pOk.x, pOk.y, dWidth, rcOk.bottom, TRUE);
redraw();
}
}
INT_PTR CALLBACK HelpDlg::run_dlgProc(HWND /*hwnd*/, UINT Message, WPARAM wParam, LPARAM lParam)
{
return run_dlgProc(Message, wParam, lParam);
}