Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 32 additions & 34 deletions external/npp/Docking.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
/*
this file is part of Function List Plugin for Notepad++
Copyright (C)2005 Jens Lorenz <jens.plugin.npp@gmx.de>
// This file is part of Notepad++ project
// Copyright (C)2025 Don HO <don.h@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 2 of the License, or (at your option) any later version.
// 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/>.

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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once

#ifndef DOCKING_H
#define DOCKING_H
#include <windows.h>

// ATTENTION : It's a part of interface header, so don't include the others header here

Expand All @@ -37,6 +36,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define DWS_ICONTAB 0x00000001 // Icon for tabs are available
#define DWS_ICONBAR 0x00000002 // Icon for icon bar are available (currently not supported)
#define DWS_ADDINFO 0x00000004 // Additional information are in use
#define DWS_USEOWNDARKMODE 0x00000008 // Use plugin's own dark mode
#define DWS_PARAMSALL (DWS_ICONTAB|DWS_ICONBAR|DWS_ADDINFO)

// default docking values for first call of plugin
Expand All @@ -47,31 +47,29 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define DWS_DF_FLOATING 0x80000000 // default state is floating


typedef struct {
HWND hClient; // client Window Handle
TCHAR *pszName; // name of plugin (shown in window)
int dlgID; // a funcItem provides the function pointer to start a dialog. Please parse here these ID
struct tTbData {
HWND hClient = nullptr; // client Window Handle
const wchar_t* pszName = nullptr; // name of plugin (shown in window)
int dlgID = 0; // a funcItem provides the function pointer to start a dialog. Please parse here these ID

// user modifications
UINT uMask; // mask params: look to above defines
HICON hIconTab; // icon for tabs
TCHAR *pszAddInfo; // for plugin to display additional informations
UINT uMask = 0; // mask params: look to above defines
HICON hIconTab = nullptr; // icon for tabs
const wchar_t* pszAddInfo = nullptr; // for plugin to display additional information

// internal data, do not use !!!
RECT rcFloat; // floating position
int iPrevCont; // stores the privious container (toggling between float and dock)
const TCHAR* pszModuleName; // it's the plugin file name. It's used to identify the plugin
} tTbData;
RECT rcFloat = {}; // floating position
int iPrevCont = 0; // stores the privious container (toggling between float and dock)
const wchar_t* pszModuleName = nullptr; // it's the plugin file name. It's used to identify the plugin
};


typedef struct {
HWND hWnd; // the docking manager wnd
RECT rcRegion[DOCKCONT_MAX]; // position of docked dialogs
} tDockMgr;
struct tDockMgr {
HWND hWnd = nullptr; // the docking manager wnd
RECT rcRegion[DOCKCONT_MAX] = {{}}; // position of docked dialogs
};


#define HIT_TEST_THICKNESS 20
#define SPLITTER_WIDTH 4


#endif // DOCKING_H
163 changes: 87 additions & 76 deletions external/npp/DockingDlgInterface.h
Original file line number Diff line number Diff line change
@@ -1,120 +1,131 @@
/*
this file is part of Function List Plugin for Notepad++
Copyright (C)2005 Jens Lorenz <jens.plugin.npp@gmx.de>
// This file is part of Notepad++ project
// Copyright (C)2006 Jens Lorenz <jens.plugin.npp@gmx.de>

// 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/>.

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 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#pragma once

#include "StaticDialog.h"
#include "dockingResource.h"
#include "Docking.h"

#include <assert.h>
#include <shlwapi.h>
#include <string>
#include "StaticDialog.h"



class DockingDlgInterface : public StaticDialog
{
public:
DockingDlgInterface() : StaticDialog() {};
DockingDlgInterface(int dlgID) : StaticDialog(), _dlgID(dlgID) {};
DockingDlgInterface() = default;
explicit DockingDlgInterface(int dlgID): _dlgID(dlgID) {}

virtual void init(HINSTANCE hInst, HWND parent)
{
virtual void init(HINSTANCE hInst, HWND parent) {
StaticDialog::init(hInst, parent);
::GetModuleFileName((HMODULE)hInst, _moduleName, MAX_PATH);
lstrcpy(_moduleName, PathFindFileName(_moduleName));
TCHAR temp[MAX_PATH];
::GetModuleFileName(reinterpret_cast<HMODULE>(hInst), temp, MAX_PATH);
_moduleName = ::PathFindFileName(temp);
}

void create(tTbData * data, bool isRTL = false)
{
void create(tTbData* data, bool isRTL = false) {
assert(data != nullptr);
StaticDialog::create(_dlgID, isRTL);
::GetWindowText(_hSelf, _pluginName, _countof(_pluginName));
TCHAR temp[MAX_PATH];
::GetWindowText(_hSelf, temp, MAX_PATH);
_pluginName = temp;

// user information
// user information
data->hClient = _hSelf;
data->pszName = _pluginName;
data->pszName = _pluginName.c_str();

// supported features by plugin
data->uMask = 0;

// additional info
data->pszAddInfo = NULL;
_data = data;
}

virtual void updateDockingDlg() {
::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, reinterpret_cast<LPARAM>(_hSelf));
}

virtual void updateDockingDlg(void)
{
::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, (LPARAM)_hSelf);
virtual void destroy() {}

virtual void setBackgroundColor(COLORREF) {}
virtual void setForegroundColor(COLORREF) {}

virtual void display(bool toShow = true) const {
::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, reinterpret_cast<LPARAM>(_hSelf));
}

virtual void destroy() {}
bool isClosed() const {
return _isClosed;
}

virtual void display(bool toShow = true) const
{
::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, (LPARAM)_hSelf);
void setClosed(bool toClose) {
_isClosed = toClose;
}

const TCHAR * getPluginFileName() const { return _moduleName; }
const TCHAR * getPluginFileName() const {
return _moduleName.c_str();
}

protected:
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM /*wParam*/, LPARAM lParam)
{
switch (message)
{
protected :
int _dlgID = -1;
bool _isFloating = true;
int _iDockedPos = 0;
std::wstring _moduleName;
std::wstring _pluginName;
bool _isClosed = false;

case WM_NOTIFY:
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) {
switch (message)
{
LPNMHDR pnmh = (LPNMHDR)lParam;

if (pnmh->hwndFrom == _hParent)
case WM_NOTIFY:
{
switch (LOWORD(pnmh->code))
{
case DMN_CLOSE:
{
break;
}
case DMN_FLOAT:
{
_isFloating = true;
break;
}
case DMN_DOCK:
LPNMHDR pnmh = reinterpret_cast<LPNMHDR>(lParam);

if (pnmh->hwndFrom == _hParent)
{
_isFloating = false;
break;
}
default:
break;
switch (LOWORD(pnmh->code))
{
case DMN_CLOSE:
{
break;
}
case DMN_FLOAT:
{
_isFloating = true;
break;
}
case DMN_DOCK:
{
_iDockedPos = HIWORD(pnmh->code);
_isFloating = false;
break;
}
default:
break;
}
}
break;
}
break;
}
default:
break;
default:
break;
}
return FALSE;
};

// Handles
HWND _HSource = nullptr;
tTbData* _data = nullptr;
int _dlgID = 0;
bool _isFloating = false;
TCHAR _moduleName[MAX_PATH] = {};
TCHAR _pluginName[MAX_PATH] = {};
};
Loading