[NEW_FEDATURE] Make dockable dialog settings memorizable for Notepad++ internal use.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@750 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2011-04-22 01:07:55 +00:00
parent aa30b8cb46
commit 7bef0d0f37
2 changed files with 76 additions and 64 deletions

View File

@ -35,6 +35,8 @@ enum tb_stat {tb_saved, tb_unsaved, tb_ro};
#define DIR_LEFT true #define DIR_LEFT true
#define DIR_RIGHT false #define DIR_RIGHT false
#define NPP_INTERNAL_FUCTION_STR TEXT("Notepad++::InternalFunction")
int docTabIconIDs[] = {IDI_SAVED_ICON, IDI_UNSAVED_ICON, IDI_READONLY_ICON}; int docTabIconIDs[] = {IDI_SAVED_ICON, IDI_UNSAVED_ICON, IDI_READONLY_ICON};
ToolBarButtonUnit toolBarIcons[] = { ToolBarButtonUnit toolBarIcons[] = {
@ -577,9 +579,17 @@ LRESULT Notepad_plus::init(HWND hwnd)
for (size_t i = 0 ; i < dmd._pluginDockInfo.size() ; i++) for (size_t i = 0 ; i < dmd._pluginDockInfo.size() ; i++)
{ {
PlugingDlgDockingInfo & pdi = dmd._pluginDockInfo[i]; PlugingDlgDockingInfo & pdi = dmd._pluginDockInfo[i];
if (pdi._isVisible) if (pdi._isVisible)
_pluginsManager.runPluginCommand(pdi._name.c_str(), pdi._internalID); {
if (pdi._name == NPP_INTERNAL_FUCTION_STR)
{
::SendMessage(hwnd, WM_COMMAND, pdi._internalID, 0);
}
else
{
_pluginsManager.runPluginCommand(pdi._name.c_str(), pdi._internalID);
}
}
} }
for (size_t i = 0 ; i < dmd._containerTabInfo.size() ; i++) for (size_t i = 0 ; i < dmd._containerTabInfo.size() ; i++)
@ -4582,11 +4592,12 @@ void Notepad_plus::launchClipboardHistoryPanel()
data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_FIND_RESULT_ICON), IMAGE_ICON, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT); data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_FIND_RESULT_ICON), IMAGE_ICON, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
//data.pszAddInfo = _findAllResultStr; //data.pszAddInfo = _findAllResultStr;
data.pszModuleName = TEXT("dummy"); data.pszModuleName = NPP_INTERNAL_FUCTION_STR;
// the dlgDlg should be the index of funcItem where the current function pointer is // the dlgDlg should be the index of funcItem where the current function pointer is
// in this case is DOCKABLE_DEMO_INDEX // in this case is DOCKABLE_DEMO_INDEX
data.dlgID = 0; // In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog
data.dlgID = IDM_EDIT_CLIPBOARDHISTORY_PANEL;
::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data); ::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data);
} }
_pClipboardHistoryPanel->display(); _pClipboardHistoryPanel->display();
@ -4609,11 +4620,12 @@ void Notepad_plus::launchAnsiCharPanel()
data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_FIND_RESULT_ICON), IMAGE_ICON, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT); data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_FIND_RESULT_ICON), IMAGE_ICON, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
//data.pszAddInfo = _findAllResultStr; //data.pszAddInfo = _findAllResultStr;
data.pszModuleName = TEXT("dummy"); data.pszModuleName = NPP_INTERNAL_FUCTION_STR;
// the dlgDlg should be the index of funcItem where the current function pointer is // the dlgDlg should be the index of funcItem where the current function pointer is
// in this case is DOCKABLE_DEMO_INDEX // in this case is DOCKABLE_DEMO_INDEX
data.dlgID = 0; // In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog
data.dlgID = IDM_EDIT_CHAR_PANEL;
::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data); ::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data);
} }
//::SendMessage(_pAnsiCharPanel->getHSelf(), WM_SIZE, 0, 0); //::SendMessage(_pAnsiCharPanel->getHSelf(), WM_SIZE, 0, 0);

View File

@ -30,7 +30,7 @@ static HWND hWndServer = NULL;
static HHOOK gWinCallHook = NULL; static HHOOK gWinCallHook = NULL;
LRESULT CALLBACK FocusWndProc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK FocusWndProc(int nCode, WPARAM wParam, LPARAM lParam);
/* Callback function that handles messages (to test focus) */ // Callback function that handles messages (to test focus)
LRESULT CALLBACK FocusWndProc(int nCode, WPARAM wParam, LPARAM lParam) { LRESULT CALLBACK FocusWndProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode == HC_ACTION && hWndServer) { if (nCode == HC_ACTION && hWndServer) {
DockingManager *pDockingManager = (DockingManager *)::GetWindowLongPtr(hWndServer, GWL_USERDATA); DockingManager *pDockingManager = (DockingManager *)::GetWindowLongPtr(hWndServer, GWL_USERDATA);
@ -64,7 +64,7 @@ DockingManager::DockingManager()
_iContMap[2] = CONT_TOP; _iContMap[2] = CONT_TOP;
_iContMap[3] = CONT_BOTTOM; _iContMap[3] = CONT_BOTTOM;
/* create four containers with splitters */ // create four containers with splitters
for (int i = 0; i < DOCKCONT_MAX; i++) for (int i = 0; i < DOCKCONT_MAX; i++)
{ {
DockingCont *_pDockCont = new DockingCont; DockingCont *_pDockCont = new DockingCont;
@ -129,7 +129,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin)
setClientWnd(ppWin); setClientWnd(ppWin);
/* create docking container */ // create docking container
for (int iCont = 0; iCont < DOCKCONT_MAX; iCont++) for (int iCont = 0; iCont < DOCKCONT_MAX; iCont++)
{ {
_vContainer[iCont]->init(_hInst, _hSelf); _vContainer[iCont]->init(_hInst, _hSelf);
@ -141,7 +141,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin)
else else
_vSplitter[iCont]->init(_hInst, _hParent, _hSelf, DMS_VERTICAL); _vSplitter[iCont]->init(_hInst, _hParent, _hSelf, DMS_VERTICAL);
} }
/* register window event hooking */ // register window event hooking
if (!hWndServer) if (!hWndServer)
hWndServer = _hSelf; hWndServer = _hSelf;
CoInitialize(NULL); CoInitialize(NULL);
@ -543,95 +543,95 @@ void DockingManager::reSizeTo(RECT & rc)
void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible) void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible)
{ {
/* add icons */ // add icons
if (data.uMask & DWS_ICONTAB) if (data.uMask & DWS_ICONTAB)
{ {
/* create image list if not exist */ // create image list if not exist
if (_hImageList == NULL) if (_hImageList == NULL)
{ {
_hImageList = ::ImageList_Create(14,14,ILC_COLOR8, 0, 0); _hImageList = ::ImageList_Create(14,14,ILC_COLOR8, 0, 0);
} }
/* add icon */ // add icon
::ImageList_AddIcon(_hImageList, data.hIconTab); ::ImageList_AddIcon(_hImageList, data.hIconTab);
/* do the reference here to find later the correct position */ // do the reference here to find later the correct position
_vImageList.push_back(data.hClient); _vImageList.push_back(data.hClient);
} }
/* create additional containers if necessary */ // create additional containers if necessary
RECT rc = {0,0,0,0}; RECT rc = {0,0,0,0};
DockingCont* pCont = NULL; DockingCont* pCont = NULL;
/* if floated rect not set */ // if floated rect not set
if (memcmp(&data.rcFloat, &rc, sizeof(RECT)) == 0) if (memcmp(&data.rcFloat, &rc, sizeof(RECT)) == 0)
{ {
/* set default rect state */ // set default rect state
::GetWindowRect(data.hClient, &data.rcFloat); ::GetWindowRect(data.hClient, &data.rcFloat);
/* test if dialog is first time created */ // test if dialog is first time created
if (iCont == -1) if (iCont == -1)
{ {
/* set default visible state */ // set default visible state
isVisible = (::IsWindowVisible(data.hClient) == TRUE); isVisible = (::IsWindowVisible(data.hClient) == TRUE);
if (data.uMask & DWS_DF_FLOATING) if (data.uMask & DWS_DF_FLOATING)
{ {
/* create new container */ // create new container
pCont = new DockingCont; pCont = new DockingCont;
_vContainer.push_back(pCont); _vContainer.push_back(pCont);
/* initialize */ // initialize
pCont->init(_hInst, _hSelf); pCont->init(_hInst, _hSelf);
pCont->doDialog(isVisible, true); pCont->doDialog(isVisible, true);
/* get previous position and set container id */ // get previous position and set container id
data.iPrevCont = (data.uMask & 0x30000000) >> 28; data.iPrevCont = (data.uMask & 0x30000000) >> 28;
iCont = _vContainer.size()-1; iCont = _vContainer.size()-1;
} }
else else
{ {
/* set position */ // set position
iCont = (data.uMask & 0x30000000) >> 28; iCont = (data.uMask & 0x30000000) >> 28;
/* previous container is not selected */ // previous container is not selected
data.iPrevCont = -1; data.iPrevCont = -1;
} }
} }
} }
/* if one of the container was not created before */ // if one of the container was not created before
else if ((iCont >= DOCKCONT_MAX) || (data.iPrevCont >= DOCKCONT_MAX)) else if ((iCont >= DOCKCONT_MAX) || (data.iPrevCont >= DOCKCONT_MAX))
{ {
/* test if current container is in floating state */ // test if current container is in floating state
if (iCont >= DOCKCONT_MAX) if (iCont >= DOCKCONT_MAX)
{ {
/* no mapping for available store mapping */ // no mapping for available store mapping
if (_iContMap[iCont] == -1) if (_iContMap[iCont] == -1)
{ {
/* create new container */ // create new container
pCont = new DockingCont; pCont = new DockingCont;
_vContainer.push_back(pCont); _vContainer.push_back(pCont);
/* initialize and map container id */ // initialize and map container id
pCont->init(_hInst, _hSelf); pCont->init(_hInst, _hSelf);
pCont->doDialog(isVisible, true); pCont->doDialog(isVisible, true);
_iContMap[iCont] = _vContainer.size()-1; _iContMap[iCont] = _vContainer.size()-1;
} }
/* get current container from map */ // get current container from map
iCont = _iContMap[iCont]; iCont = _iContMap[iCont];
} }
/* previous container is in floating state */ // previous container is in floating state
else else
{ {
/* no mapping for available store mapping */ // no mapping for available store mapping
if (_iContMap[data.iPrevCont] == -1) if (_iContMap[data.iPrevCont] == -1)
{ {
/* create new container */ // create new container
pCont = new DockingCont; pCont = new DockingCont;
_vContainer.push_back(pCont); _vContainer.push_back(pCont);
/* initialize and map container id */ // initialize and map container id
pCont->init(_hInst, _hSelf); pCont->init(_hInst, _hSelf);
pCont->doDialog(false, true); pCont->doDialog(false, true);
pCont->reSizeToWH(data.rcFloat); pCont->reSizeToWH(data.rcFloat);
@ -645,7 +645,7 @@ void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible)
if (_vContainer.size() > (size_t)iCont && _vContainer[iCont] != NULL) if (_vContainer.size() > (size_t)iCont && _vContainer[iCont] != NULL)
_vContainer[iCont]->createToolbar(data); _vContainer[iCont]->createToolbar(data);
/* notify client app */ // notify client app
if (iCont < DOCKCONT_MAX) if (iCont < DOCKCONT_MAX)
SendNotify(data.hClient, MAKELONG(DMN_DOCK, iCont)); SendNotify(data.hClient, MAKELONG(DMN_DOCK, iCont));
else else
@ -727,7 +727,7 @@ DockingCont* DockingManager::toggleActiveTb(DockingCont* pContSrc, UINT message,
BOOL isCont = ContExists(iContPrev); BOOL isCont = ContExists(iContPrev);
DockingCont* pContTgt = NULL; DockingCont* pContTgt = NULL;
/* if new float position is given */ // if new float position is given
if (prcFloat != NULL) if (prcFloat != NULL)
{ {
TbData.rcFloat = *prcFloat; TbData.rcFloat = *prcFloat;
@ -735,17 +735,17 @@ DockingCont* DockingManager::toggleActiveTb(DockingCont* pContSrc, UINT message,
if ((isCont == FALSE) || (bNew == TRUE)) if ((isCont == FALSE) || (bNew == TRUE))
{ {
/* find an empty container */ // find an empty container
int iContNew = FindEmptyContainer(); int iContNew = FindEmptyContainer();
if (iContNew == -1) if (iContNew == -1)
{ {
/* if no free container is available create a new one */ // if no free container is available create a new one
pContTgt = new DockingCont; pContTgt = new DockingCont;
pContTgt->init(_hInst, _hSelf); pContTgt->init(_hInst, _hSelf);
pContTgt->doDialog(true, true); pContTgt->doDialog(true, true);
/* change only on toggling */ // change only on toggling
if ((bNew == FALSE) || (!pContSrc->isFloating())) if ((bNew == FALSE) || (!pContSrc->isFloating()))
TbData.iPrevCont = iContSrc; TbData.iPrevCont = iContSrc;
@ -754,10 +754,10 @@ DockingCont* DockingManager::toggleActiveTb(DockingCont* pContSrc, UINT message,
} }
else else
{ {
/* set new target */ // set new target
pContTgt = _vContainer[iContNew]; pContTgt = _vContainer[iContNew];
/* change only on toggling */ // change only on toggling
if ((pContSrc->isFloating()) != (pContTgt->isFloating())) if ((pContSrc->isFloating()) != (pContTgt->isFloating()))
TbData.iPrevCont = iContSrc; TbData.iPrevCont = iContSrc;
@ -766,18 +766,18 @@ DockingCont* DockingManager::toggleActiveTb(DockingCont* pContSrc, UINT message,
} }
else else
{ {
/* set new target */ // set new target
pContTgt = _vContainer[iContPrev]; pContTgt = _vContainer[iContPrev];
/* change data normaly */ // change data normaly
TbData.iPrevCont = iContSrc; TbData.iPrevCont = iContSrc;
pContTgt->createToolbar(TbData); pContTgt->createToolbar(TbData);
} }
/* notify client app */ // notify client app
SendNotify(TbData.hClient, MAKELONG(message==DMM_DOCK?DMN_DOCK:DMN_FLOAT, GetContainer(pContTgt))); SendNotify(TbData.hClient, MAKELONG(message==DMM_DOCK?DMN_DOCK:DMN_FLOAT, GetContainer(pContTgt)));
/* remove toolbar from source */ // remove toolbar from source
_vContainer[iContSrc]->removeToolbar(TbData); _vContainer[iContSrc]->removeToolbar(TbData);
return pContTgt; return pContTgt;
@ -793,16 +793,16 @@ DockingCont* DockingManager::toggleVisTb(DockingCont* pContSrc, UINT message, LP
BOOL isCont = ContExists(iContPrev); BOOL isCont = ContExists(iContPrev);
DockingCont* pContTgt = NULL; DockingCont* pContTgt = NULL;
/* at first hide container and resize */ // at first hide container and resize
pContSrc->doDialog(false); pContSrc->doDialog(false);
onSize(); onSize();
for (size_t iTb = 0; iTb < vTbData.size(); iTb++) for (size_t iTb = 0; iTb < vTbData.size(); iTb++)
{ {
/* get data one by another */ // get data one by another
tTbData TbData = *vTbData[iTb]; tTbData TbData = *vTbData[iTb];
/* if new float position is given */ // if new float position is given
if (prcFloat != NULL) if (prcFloat != NULL)
{ {
TbData.rcFloat = *prcFloat; TbData.rcFloat = *prcFloat;
@ -810,7 +810,7 @@ DockingCont* DockingManager::toggleVisTb(DockingCont* pContSrc, UINT message, LP
if (isCont == FALSE) if (isCont == FALSE)
{ {
/* create new container */ // create new container
pContTgt = new DockingCont; pContTgt = new DockingCont;
pContTgt->init(_hInst, _hSelf); pContTgt->init(_hInst, _hSelf);
pContTgt->doDialog(true, true); pContTgt->doDialog(true, true);
@ -819,13 +819,13 @@ DockingCont* DockingManager::toggleVisTb(DockingCont* pContSrc, UINT message, LP
pContTgt->createToolbar(TbData); pContTgt->createToolbar(TbData);
_vContainer.push_back(pContTgt); _vContainer.push_back(pContTgt);
/* now container exists */ // now container exists
isCont = TRUE; isCont = TRUE;
iContPrev = GetContainer(pContTgt); iContPrev = GetContainer(pContTgt);
} }
else else
{ {
/* set new target */ // set new target
pContTgt = _vContainer[iContPrev]; pContTgt = _vContainer[iContPrev];
TbData.iPrevCont = iContSrc; TbData.iPrevCont = iContSrc;
@ -834,7 +834,7 @@ DockingCont* DockingManager::toggleVisTb(DockingCont* pContSrc, UINT message, LP
SendNotify(TbData.hClient, MAKELONG(message==DMM_DOCK?DMN_DOCK:DMN_FLOAT, GetContainer(pContTgt))); SendNotify(TbData.hClient, MAKELONG(message==DMM_DOCK?DMN_DOCK:DMN_FLOAT, GetContainer(pContTgt)));
/* remove toolbar from anywhere */ // remove toolbar from anywhere
_vContainer[iContSrc]->removeToolbar(TbData); _vContainer[iContSrc]->removeToolbar(TbData);
} }
@ -854,13 +854,13 @@ void DockingManager::toggleVisTb(DockingCont* pContSrc, DockingCont* pContTgt)
vector<tTbData*> vTbData = pContSrc->getDataOfVisTb(); vector<tTbData*> vTbData = pContSrc->getDataOfVisTb();
tTbData* pTbData = pContSrc->getDataOfActiveTb(); tTbData* pTbData = pContSrc->getDataOfActiveTb();
/* at first hide container and resize */ // at first hide container and resize
pContSrc->doDialog(false); pContSrc->doDialog(false);
onSize(); onSize();
for (size_t iTb = 0; iTb < vTbData.size(); iTb++) for (size_t iTb = 0; iTb < vTbData.size(); iTb++)
{ {
/* get data one by another */ // get data one by another
tTbData TbData = *vTbData[iTb]; tTbData TbData = *vTbData[iTb];
toggleTb(pContSrc, pContTgt, TbData); toggleTb(pContSrc, pContTgt, TbData);
} }
@ -872,24 +872,24 @@ void DockingManager::toggleTb(DockingCont* pContSrc, DockingCont* pContTgt, tTbD
int iContSrc = GetContainer(pContSrc); int iContSrc = GetContainer(pContSrc);
int iContTgt = GetContainer(pContTgt); int iContTgt = GetContainer(pContTgt);
/* test if container state changes from docking to floating or vice versa */ // test if container state changes from docking to floating or vice versa
if (((iContSrc < DOCKCONT_MAX) && (iContTgt >= DOCKCONT_MAX)) || if (((iContSrc < DOCKCONT_MAX) && (iContTgt >= DOCKCONT_MAX)) ||
((iContSrc >= DOCKCONT_MAX) && (iContTgt < DOCKCONT_MAX))) ((iContSrc >= DOCKCONT_MAX) && (iContTgt < DOCKCONT_MAX)))
{ {
/* change states */ // change states
TbData.iPrevCont = iContSrc; TbData.iPrevCont = iContSrc;
} }
/* notify client app */ // notify client app
if (iContTgt < DOCKCONT_MAX) if (iContTgt < DOCKCONT_MAX)
SendNotify(TbData.hClient, MAKELONG(DMN_DOCK, iContTgt)); SendNotify(TbData.hClient, MAKELONG(DMN_DOCK, iContTgt));
else else
SendNotify(TbData.hClient, MAKELONG(DMN_FLOAT, iContTgt)); SendNotify(TbData.hClient, MAKELONG(DMN_FLOAT, iContTgt));
/* create new toolbar */ // create new toolbar
pContTgt->createToolbar(TbData); pContTgt->createToolbar(TbData);
/* remove toolbar from source */ // remove toolbar from source
_vContainer[iContSrc]->removeToolbar(TbData); _vContainer[iContSrc]->removeToolbar(TbData);
} }
@ -927,13 +927,13 @@ int DockingManager::FindEmptyContainer()
BOOL* pPrevDockList = (BOOL*) new BOOL[_vContainer.size()+1]; BOOL* pPrevDockList = (BOOL*) new BOOL[_vContainer.size()+1];
BOOL* pArrayPos = &pPrevDockList[1]; BOOL* pArrayPos = &pPrevDockList[1];
/* delete all entries */ // delete all entries
for (size_t iCont = 0; iCont < _vContainer.size()+1; iCont++) for (size_t iCont = 0; iCont < _vContainer.size()+1; iCont++)
{ {
pPrevDockList[iCont] = FALSE; pPrevDockList[iCont] = FALSE;
} }
/* search for used floated containers */ // search for used floated containers
for (size_t iCont = 0; iCont < DOCKCONT_MAX; iCont++) for (size_t iCont = 0; iCont < DOCKCONT_MAX; iCont++)
{ {
vector<tTbData*> vTbData = _vContainer[iCont]->getDataOfAllTb(); vector<tTbData*> vTbData = _vContainer[iCont]->getDataOfAllTb();
@ -944,12 +944,12 @@ int DockingManager::FindEmptyContainer()
} }
} }
/* find free container */ // find free container
for (size_t iCont = DOCKCONT_MAX; iCont < _vContainer.size(); iCont++) for (size_t iCont = DOCKCONT_MAX; iCont < _vContainer.size(); iCont++)
{ {
if (pArrayPos[iCont] == FALSE) if (pArrayPos[iCont] == FALSE)
{ {
/* and test if container is hidden */ // and test if container is hidden
if (!_vContainer[iCont]->isVisible()) if (!_vContainer[iCont]->isVisible())
{ {
iRetCont = iCont; iRetCont = iCont;
@ -960,7 +960,7 @@ int DockingManager::FindEmptyContainer()
delete [] pPrevDockList; delete [] pPrevDockList;
/* search for empty arrays */ // search for empty arrays
return iRetCont; return iRetCont;
} }