|
| 1 | +// This file is part of Notepad++ project |
| 2 | +// Copyright (C)2006 Jens Lorenz <jens.plugin.npp@gmx.de> |
| 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/>. |
| 16 | + |
| 17 | + |
| 18 | +#pragma once |
| 19 | + |
| 20 | +#include "dockingResource.h" |
| 21 | +#include "Docking.h" |
| 22 | + |
| 23 | +#include <assert.h> |
| 24 | +#include <shlwapi.h> |
| 25 | +#include <string> |
| 26 | +#include "StaticDialog.h" |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +class DockingDlgInterface : public StaticDialog |
| 31 | +{ |
| 32 | +public: |
| 33 | + DockingDlgInterface() = default; |
| 34 | + explicit DockingDlgInterface(int dlgID): _dlgID(dlgID) {} |
| 35 | + |
| 36 | + virtual void init(HINSTANCE hInst, HWND parent) { |
| 37 | + StaticDialog::init(hInst, parent); |
| 38 | + TCHAR temp[MAX_PATH]; |
| 39 | + ::GetModuleFileName(reinterpret_cast<HMODULE>(hInst), temp, MAX_PATH); |
| 40 | + _moduleName = ::PathFindFileName(temp); |
| 41 | + } |
| 42 | + |
| 43 | + void create(tTbData* data, bool isRTL = false) { |
| 44 | + assert(data != nullptr); |
| 45 | + StaticDialog::create(_dlgID, isRTL); |
| 46 | + TCHAR temp[MAX_PATH]; |
| 47 | + ::GetWindowText(_hSelf, temp, MAX_PATH); |
| 48 | + _pluginName = temp; |
| 49 | + |
| 50 | + // user information |
| 51 | + data->hClient = _hSelf; |
| 52 | + data->pszName = _pluginName.c_str(); |
| 53 | + |
| 54 | + // supported features by plugin |
| 55 | + data->uMask = 0; |
| 56 | + |
| 57 | + // additional info |
| 58 | + data->pszAddInfo = NULL; |
| 59 | + } |
| 60 | + |
| 61 | + virtual void updateDockingDlg() { |
| 62 | + ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, reinterpret_cast<LPARAM>(_hSelf)); |
| 63 | + } |
| 64 | + |
| 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)); |
| 72 | + } |
| 73 | + |
| 74 | + bool isClosed() const { |
| 75 | + return _isClosed; |
| 76 | + } |
| 77 | + |
| 78 | + void setClosed(bool toClose) { |
| 79 | + _isClosed = toClose; |
| 80 | + } |
| 81 | + |
| 82 | + const TCHAR * getPluginFileName() const { |
| 83 | + return _moduleName.c_str(); |
| 84 | + } |
| 85 | + |
| 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; |
| 93 | + |
| 94 | + virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) { |
| 95 | + switch (message) |
| 96 | + { |
| 97 | + case WM_NOTIFY: |
| 98 | + { |
| 99 | + LPNMHDR pnmh = reinterpret_cast<LPNMHDR>(lParam); |
| 100 | + |
| 101 | + if (pnmh->hwndFrom == _hParent) |
| 102 | + { |
| 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 | + } |
| 123 | + } |
| 124 | + break; |
| 125 | + } |
| 126 | + default: |
| 127 | + break; |
| 128 | + } |
| 129 | + return FALSE; |
| 130 | + }; |
| 131 | +}; |
0 commit comments