1 // this file is part of Function List Plugin for Notepad++ 2 // Copyright (C)2005 Jens Lorenz <jens.plugin.npp@gmx.de> 3 // 4 // This program is free software; you can redistribute it and/or 5 // modify it under the terms of the GNU General Public License 6 // as published by the Free Software Foundation; either 7 // version 2 of the License, or (at your option) any later version. 8 // 9 // Note that the GPL places important restrictions on "derived works", yet 10 // it does not provide a detailed definition of that term. To avoid 11 // misunderstandings, we consider an application to constitute a 12 // "derivative work" for the purpose of this license if it does any of the 13 // following: 14 // 1. Integrates source code from Notepad++. 15 // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable 16 // installer, such as those produced by InstallShield. 17 // 3. Links to a library or executes a program that does any of the above. 18 // 19 // This program is distributed in the hope that it will be useful, 20 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 // GNU General Public License for more details. 23 // 24 // You should have received a copy of the GNU General Public License 25 // along with this program; if not, write to the Free Software 26 /** 27 * 28 * 29 * License: GPL-2.0 or later 30 */ 31 module npp_api.powereditor.wincontrols.dockingwnd.dockingdlginterface; 32 33 34 version (Windows): 35 version (Not_betterC): 36 37 pragma(lib, "kernel32.lib"); 38 pragma(lib, "user32.lib"); 39 40 private static import core.sys.windows.basetsd; 41 private static import core.sys.windows.winbase; 42 private static import core.sys.windows.windef; 43 private static import core.sys.windows.winuser; 44 private static import core.sys.windows.winnt; 45 private static import std.path; 46 private static import std.string; 47 private static import std.utf; 48 private static import npp_api.powereditor.wincontrols.staticdialog.staticdialog; 49 private static import npp_api.powereditor.wincontrols.dockingwnd.dockingresource; 50 private static import npp_api.powereditor.wincontrols.dockingwnd.docking; 51 private static import npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs; 52 private static import npp_api.pluginfunc.npp_msgs; 53 54 class DockingDlgInterface : npp_api.powereditor.wincontrols.staticdialog.staticdialog.StaticDialog 55 { 56 static import core.sys.windows.basetsd; 57 static import core.sys.windows.shlwapi; 58 static import core.sys.windows.winbase; 59 static import core.sys.windows.windef; 60 static import core.sys.windows.winuser; 61 static import core.sys.windows.winnt; 62 static import npp_api.powereditor.wincontrols.staticdialog.staticdialog; 63 static import npp_api.powereditor.wincontrols.dockingwnd.dockingresource; 64 static import npp_api.powereditor.wincontrols.dockingwnd.docking; 65 static import npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs; 66 static import std.string; 67 static import npp_api.pluginfunc.npp_msgs; 68 69 protected: 70 // Handles 71 core.sys.windows.windef.HWND _HSource = core.sys.windows.windef.NULL; 72 int _dlgID = -1; 73 bool _isFloating = true; 74 int _iDockedPos = 0; 75 core.sys.windows.winnt.WCHAR[core.sys.windows.windef.MAX_PATH] _moduleName; 76 core.sys.windows.winnt.WCHAR[core.sys.windows.windef.MAX_PATH] _pluginName; 77 bool _isClosed = false; 78 79 public: 80 pure nothrow @safe @nogc 81 this() 82 83 do 84 { 85 super(); 86 } 87 88 pure nothrow @safe @nogc 89 this(int dlgID) 90 91 do 92 { 93 super(); 94 this._dlgID = dlgID; 95 } 96 97 nothrow @nogc 98 override void initialize(core.sys.windows.windef.HINSTANCE hInst, core.sys.windows.windef.HWND parent) 99 100 do 101 { 102 static import std.path; 103 104 super.initialize(hInst, parent); 105 core.sys.windows.winbase.GetModuleFileNameW(cast(core.sys.windows.windef.HMODULE)(hInst), &(this._moduleName[0]), core.sys.windows.windef.MAX_PATH); 106 107 core.sys.windows.winbase.lstrcpyW(&(this._moduleName[0]), &((std.path.baseName(this._moduleName)[0]))); 108 109 super.initialize(hInst, parent); 110 core.sys.windows.winnt.WCHAR[core.sys.windows.windef.MAX_PATH] temp; 111 core.sys.windows.winbase.GetModuleFileNameW(cast(core.sys.windows.windef.HMODULE)(hInst), &(temp[0]), core.sys.windows.windef.MAX_PATH); 112 113 //this._moduleName = core.sys.windows.shlwapi.PathFindFileNameW(temp); 114 core.sys.windows.winbase.lstrcpyW(&(this._moduleName[0]), &((std.path.baseName(this._moduleName)[0]))); 115 } 116 117 void create(void* dialog_p, ref npp_api.powereditor.wincontrols.dockingwnd.docking.tTbData data, bool isRTL = false) 118 119 in 120 { 121 assert(dialog_p != null); 122 } 123 124 do 125 { 126 super.create(dialog_p, this._dlgID, isRTL); 127 core.sys.windows.winnt.WCHAR[core.sys.windows.windef.MAX_PATH] temp; 128 core.sys.windows.winuser.GetWindowTextW(this._hSelf, &(temp[0]), core.sys.windows.windef.MAX_PATH); 129 static assert(this._pluginName.length == temp.length); 130 static assert(this._pluginName.length == core.sys.windows.windef.MAX_PATH); 131 this._pluginName[0 .. core.sys.windows.windef.MAX_PATH] = temp[0 .. core.sys.windows.windef.MAX_PATH]; 132 133 // user information 134 data.hClient = this._hSelf; 135 data.pszName = &(this._pluginName[0]); 136 137 // supported features by plugin 138 data.uMask = 0; 139 140 // additional info 141 data.pszAddInfo = null; 142 } 143 144 override void create(void* dialog_p, int dialogID, bool isRTL = false, bool msgDestParent = true) 145 146 in 147 { 148 assert(dialog_p != null); 149 } 150 151 do 152 { 153 super.create(dialog_p, dialogID, isRTL, msgDestParent); 154 } 155 156 nothrow @nogc 157 void updateDockingDlg() 158 159 do 160 { 161 npp_api.pluginfunc.npp_msgs.send_NPPM_DMMUPDATEDISPINFO(this._hParent, this._hSelf); 162 } 163 164 pure nothrow @safe @nogc 165 override void destroy() 166 167 do 168 { 169 } 170 171 void setBackgroundColor(core.sys.windows.windef.COLORREF bgColour) = 0; 172 void setForegroundColor(core.sys.windows.windef.COLORREF bgColour) = 0; 173 174 nothrow @nogc 175 override void display(bool toShow = true) 176 177 do 178 { 179 core.sys.windows.winuser.SendMessageW(this._hParent, (toShow) ? (npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.NPPM_DMMSHOW) : (npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.NPPM_DMMHIDE), 0, cast(core.sys.windows.windef.LPARAM)(this._hSelf)); 180 } 181 182 pure nothrow @safe @nogc 183 bool isClosed() const 184 185 do 186 { 187 return this._isClosed; 188 } 189 190 pure nothrow @safe @nogc 191 void setClosed(bool toClose) 192 193 do 194 { 195 this._isClosed = toClose; 196 } 197 198 pure nothrow @safe @nogc 199 const (core.sys.windows.winnt.WCHAR)* getPluginFileName() const 200 201 do 202 { 203 return &(this._moduleName[0]); 204 } 205 206 protected: 207 extern (Windows) 208 nothrow @nogc 209 override core.sys.windows.basetsd.INT_PTR run_dlgProc(core.sys.windows.windef.UINT message, core.sys.windows.windef.WPARAM wParam, core.sys.windows.windef.LPARAM lParam) 210 211 do 212 { 213 switch (message) { 214 case core.sys.windows.winuser.WM_NOTIFY: 215 core.sys.windows.winuser.LPNMHDR pnmh = cast(core.sys.windows.winuser.LPNMHDR)(lParam); 216 217 if ((*pnmh).hwndFrom == this._hParent) { 218 switch (core.sys.windows.windef.LOWORD((*pnmh).code)) { 219 case npp_api.powereditor.wincontrols.dockingwnd.dockingresource.DMN_CLOSE: 220 break; 221 222 case npp_api.powereditor.wincontrols.dockingwnd.dockingresource.DMN_FLOAT: 223 this._isFloating = true; 224 225 break; 226 227 case npp_api.powereditor.wincontrols.dockingwnd.dockingresource.DMN_DOCK: 228 this._iDockedPos = core.sys.windows.windef.HIWORD(pnmh.code); 229 this._isFloating = false; 230 231 break; 232 233 default: 234 break; 235 } 236 } 237 238 break; 239 240 default: 241 break; 242 } 243 244 return core.sys.windows.windef.FALSE; 245 } 246 }