|
1 | | -/* |
2 | | -this file is part of Function List Plugin for Notepad++ |
3 | | -Copyright (C)2005 Jens Lorenz <[email protected]> |
| 1 | +// This file is part of Notepad++ project |
| 2 | +// Copyright (C)2006 Jens Lorenz <[email protected]> |
| 3 | + |
| 4 | +// This program is free software: you can redistribute it and/or modify |
| 5 | +// it under the terms of the GNU General Public License as published by |
| 6 | +// the Free Software Foundation, either version 3 of the License, or |
| 7 | +// at your option any later version. |
| 8 | +// |
| 9 | +// This program is distributed in the hope that it will be useful, |
| 10 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +// GNU General Public License for more details. |
| 13 | +// |
| 14 | +// You should have received a copy of the GNU General Public License |
| 15 | +// along with this program. If not, see <https://www.gnu.org/licenses/>. |
4 | 16 |
|
5 | | -This program is free software; you can redistribute it and/or |
6 | | -modify it under the terms of the GNU General Public License |
7 | | -as published by the Free Software Foundation; either |
8 | | -version 2 of the License, or (at your option) any later version. |
9 | | -
|
10 | | -This program is distributed in the hope that it will be useful, |
11 | | -but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | | -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | | -GNU General Public License for more details. |
14 | | -
|
15 | | -You should have received a copy of the GNU General Public License |
16 | | -along with this program; if not, write to the Free Software |
17 | | -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | | -*/ |
19 | 17 |
|
20 | 18 | #pragma once |
21 | 19 |
|
22 | | -#include "StaticDialog.h" |
23 | 20 | #include "dockingResource.h" |
24 | 21 | #include "Docking.h" |
| 22 | + |
| 23 | +#include <assert.h> |
25 | 24 | #include <shlwapi.h> |
| 25 | +#include <string> |
| 26 | +#include "StaticDialog.h" |
| 27 | + |
26 | 28 |
|
27 | 29 |
|
28 | 30 | class DockingDlgInterface : public StaticDialog |
29 | 31 | { |
30 | 32 | public: |
31 | | - DockingDlgInterface() : StaticDialog() {}; |
32 | | - DockingDlgInterface(int dlgID) : StaticDialog(), _dlgID(dlgID) {}; |
| 33 | + DockingDlgInterface() = default; |
| 34 | + explicit DockingDlgInterface(int dlgID): _dlgID(dlgID) {} |
33 | 35 |
|
34 | | - virtual void init(HINSTANCE hInst, HWND parent) |
35 | | - { |
| 36 | + virtual void init(HINSTANCE hInst, HWND parent) { |
36 | 37 | StaticDialog::init(hInst, parent); |
37 | | - ::GetModuleFileName((HMODULE)hInst, _moduleName, MAX_PATH); |
38 | | - lstrcpy(_moduleName, PathFindFileName(_moduleName)); |
| 38 | + TCHAR temp[MAX_PATH]; |
| 39 | + ::GetModuleFileName(reinterpret_cast<HMODULE>(hInst), temp, MAX_PATH); |
| 40 | + _moduleName = ::PathFindFileName(temp); |
39 | 41 | } |
40 | 42 |
|
41 | | - void create(tTbData * data, bool isRTL = false) |
42 | | - { |
| 43 | + void create(tTbData* data, bool isRTL = false) { |
| 44 | + assert(data != nullptr); |
43 | 45 | StaticDialog::create(_dlgID, isRTL); |
44 | | - ::GetWindowText(_hSelf, _pluginName, _countof(_pluginName)); |
| 46 | + TCHAR temp[MAX_PATH]; |
| 47 | + ::GetWindowText(_hSelf, temp, MAX_PATH); |
| 48 | + _pluginName = temp; |
45 | 49 |
|
46 | | - // user information |
| 50 | + // user information |
47 | 51 | data->hClient = _hSelf; |
48 | | - data->pszName = _pluginName; |
| 52 | + data->pszName = _pluginName.c_str(); |
49 | 53 |
|
50 | 54 | // supported features by plugin |
51 | 55 | data->uMask = 0; |
52 | 56 |
|
53 | 57 | // additional info |
54 | 58 | data->pszAddInfo = NULL; |
55 | | - _data = data; |
| 59 | + } |
56 | 60 |
|
| 61 | + virtual void updateDockingDlg() { |
| 62 | + ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, reinterpret_cast<LPARAM>(_hSelf)); |
57 | 63 | } |
58 | 64 |
|
59 | | - virtual void updateDockingDlg(void) |
60 | | - { |
61 | | - ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, (LPARAM)_hSelf); |
| 65 | + virtual void destroy() {} |
| 66 | + |
| 67 | + virtual void setBackgroundColor(COLORREF) {} |
| 68 | + virtual void setForegroundColor(COLORREF) {} |
| 69 | + |
| 70 | + virtual void display(bool toShow = true) const { |
| 71 | + ::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, reinterpret_cast<LPARAM>(_hSelf)); |
62 | 72 | } |
63 | 73 |
|
64 | | - virtual void destroy() {} |
| 74 | + bool isClosed() const { |
| 75 | + return _isClosed; |
| 76 | + } |
65 | 77 |
|
66 | | - virtual void display(bool toShow = true) const |
67 | | - { |
68 | | - ::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, (LPARAM)_hSelf); |
| 78 | + void setClosed(bool toClose) { |
| 79 | + _isClosed = toClose; |
69 | 80 | } |
70 | 81 |
|
71 | | - const TCHAR * getPluginFileName() const { return _moduleName; } |
| 82 | + const TCHAR * getPluginFileName() const { |
| 83 | + return _moduleName.c_str(); |
| 84 | + } |
72 | 85 |
|
73 | | -protected: |
74 | | - virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM /*wParam*/, LPARAM lParam) |
75 | | - { |
76 | | - switch (message) |
77 | | - { |
| 86 | +protected : |
| 87 | + int _dlgID = -1; |
| 88 | + bool _isFloating = true; |
| 89 | + int _iDockedPos = 0; |
| 90 | + std::wstring _moduleName; |
| 91 | + std::wstring _pluginName; |
| 92 | + bool _isClosed = false; |
78 | 93 |
|
79 | | - case WM_NOTIFY: |
| 94 | + virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) { |
| 95 | + switch (message) |
80 | 96 | { |
81 | | - LPNMHDR pnmh = (LPNMHDR)lParam; |
82 | | - |
83 | | - if (pnmh->hwndFrom == _hParent) |
| 97 | + case WM_NOTIFY: |
84 | 98 | { |
85 | | - switch (LOWORD(pnmh->code)) |
86 | | - { |
87 | | - case DMN_CLOSE: |
88 | | - { |
89 | | - break; |
90 | | - } |
91 | | - case DMN_FLOAT: |
92 | | - { |
93 | | - _isFloating = true; |
94 | | - break; |
95 | | - } |
96 | | - case DMN_DOCK: |
| 99 | + LPNMHDR pnmh = reinterpret_cast<LPNMHDR>(lParam); |
| 100 | + |
| 101 | + if (pnmh->hwndFrom == _hParent) |
97 | 102 | { |
98 | | - _isFloating = false; |
99 | | - break; |
100 | | - } |
101 | | - default: |
102 | | - break; |
| 103 | + switch (LOWORD(pnmh->code)) |
| 104 | + { |
| 105 | + case DMN_CLOSE: |
| 106 | + { |
| 107 | + break; |
| 108 | + } |
| 109 | + case DMN_FLOAT: |
| 110 | + { |
| 111 | + _isFloating = true; |
| 112 | + break; |
| 113 | + } |
| 114 | + case DMN_DOCK: |
| 115 | + { |
| 116 | + _iDockedPos = HIWORD(pnmh->code); |
| 117 | + _isFloating = false; |
| 118 | + break; |
| 119 | + } |
| 120 | + default: |
| 121 | + break; |
| 122 | + } |
103 | 123 | } |
| 124 | + break; |
104 | 125 | } |
105 | | - break; |
106 | | - } |
107 | | - default: |
108 | | - break; |
| 126 | + default: |
| 127 | + break; |
109 | 128 | } |
110 | 129 | return FALSE; |
111 | 130 | }; |
112 | | - |
113 | | - // Handles |
114 | | - HWND _HSource = nullptr; |
115 | | - tTbData* _data = nullptr; |
116 | | - int _dlgID = 0; |
117 | | - bool _isFloating = false; |
118 | | - TCHAR _moduleName[MAX_PATH] = {}; |
119 | | - TCHAR _pluginName[MAX_PATH] = {}; |
120 | 131 | }; |
0 commit comments