[BUG_FIXED]

1. Fix Project Panel loading non-project file bug.
2. Fix adding/hidding Language Menue item problem in Preference dialog.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@828 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2011-10-16 10:08:46 +00:00
parent 86947350c3
commit 4e7a560874
4 changed files with 87 additions and 83 deletions

Binary file not shown.

View File

@ -1337,51 +1337,91 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
} }
case WM_COMMAND : case WM_COMMAND :
{ {
if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_TABSETTNG) if (HIWORD(wParam) == LBN_SELCHANGE)
{ {
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); if (LOWORD(wParam) == IDC_LIST_TABSETTNG)
if (index == LB_ERR) {
return FALSE; int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), index?SW_SHOW:SW_HIDE); if (index == LB_ERR)
::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), index?SW_SHOW:SW_HIDE); return FALSE;
::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), index?SW_SHOW:SW_HIDE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), index?SW_SHOW:SW_HIDE);
if (index) if (index)
{ {
Lang *lang = pNppParam->getLangFromIndex(index - 1); Lang *lang = pNppParam->getLangFromIndex(index - 1);
if (!lang) return FALSE; if (!lang) return FALSE;
bool useDefaultTab = (lang->_tabSize == -1 || lang->_tabSize == 0); bool useDefaultTab = (lang->_tabSize == -1 || lang->_tabSize == 0);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0); ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab); ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab);
int size = useDefaultTab?nppGUI._tabSize:lang->_tabSize; int size = useDefaultTab?nppGUI._tabSize:lang->_tabSize;
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE);
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab); ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab?nppGUI._tabReplacedBySpace:lang->_isTabReplacedBySpace, 0); ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab?nppGUI._tabReplacedBySpace:lang->_isTabReplacedBySpace, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab);
if (!useDefaultTab) if (!useDefaultTab)
{ {
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, lang->_tabSize, FALSE); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, lang->_tabSize, FALSE);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, lang->_isTabReplacedBySpace, 0); ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, lang->_isTabReplacedBySpace, 0);
} }
} }
else else
{ {
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), TRUE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), TRUE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), TRUE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), TRUE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), SW_SHOW);
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE); ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, nppGUI._tabReplacedBySpace, 0); ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, nppGUI._tabReplacedBySpace, 0);
} }
return TRUE; return TRUE;
}
else if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG)
{
HWND hEnableList = ::GetDlgItem(_hSelf, IDC_LIST_ENABLEDLANG);
HWND hDisableList = ::GetDlgItem(_hSelf, IDC_LIST_DISABLEDLANG);
if (HIWORD(wParam) == LBN_DBLCLK)
{
if (HWND(lParam) == hEnableList)
::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_REMOVE, 0);
else if (HWND(lParam) == hDisableList)
::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_RESTORE, 0);
return TRUE;
}
int idButton2Enable;
int idButton2Disable;
if (LOWORD(wParam) == IDC_LIST_ENABLEDLANG)
{
idButton2Enable = IDC_BUTTON_REMOVE;
idButton2Disable = IDC_BUTTON_RESTORE;
}
else //IDC_LIST_DISABLEDLANG
{
idButton2Enable = IDC_BUTTON_RESTORE;
idButton2Disable = IDC_BUTTON_REMOVE;
}
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
if (i != LB_ERR)
{
::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE);
int idListbox2Disable = (LOWORD(wParam)== IDC_LIST_ENABLEDLANG)?IDC_LIST_DISABLEDLANG:IDC_LIST_ENABLEDLANG;
::SendDlgItemMessage(_hSelf, idListbox2Disable, LB_SETCURSEL, (WPARAM)-1, 0);
::EnableWindow(::GetDlgItem(_hSelf, idButton2Disable), FALSE);
}
return TRUE;
}
} }
switch (wParam) switch (wParam)
@ -1474,44 +1514,6 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
return TRUE; return TRUE;
} }
case IDC_LIST_DISABLEDLANG :
case IDC_LIST_ENABLEDLANG :
{
HWND hEnableList = ::GetDlgItem(_hSelf, IDC_LIST_ENABLEDLANG);
HWND hDisableList = ::GetDlgItem(_hSelf, IDC_LIST_DISABLEDLANG);
if (HIWORD(wParam) == LBN_DBLCLK)
{
if (HWND(lParam) == hEnableList)
::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_REMOVE, 0);
else if (HWND(lParam) == hDisableList)
::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_RESTORE, 0);
return TRUE;
}
int idButton2Enable;
int idButton2Disable;
if (LOWORD(wParam) == IDC_LIST_ENABLEDLANG)
{
idButton2Enable = IDC_BUTTON_REMOVE;
idButton2Disable = IDC_BUTTON_RESTORE;
}
else //IDC_LIST_DISABLEDLANG
{
idButton2Enable = IDC_BUTTON_RESTORE;
idButton2Disable = IDC_BUTTON_REMOVE;
}
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
if (i != LB_ERR)
{
::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE);
int idListbox2Disable = (LOWORD(wParam)== IDC_LIST_ENABLEDLANG)?IDC_LIST_DISABLEDLANG:IDC_LIST_ENABLEDLANG;
::SendDlgItemMessage(_hSelf, idListbox2Disable, LB_SETCURSEL, (WPARAM)-1, 0);
::EnableWindow(::GetDlgItem(_hSelf, idButton2Disable), FALSE);
}
return TRUE;
}
case IDC_CHECK_LANGMENUCOMPACT : case IDC_CHECK_LANGMENUCOMPACT :
{ {
nppGUI._isLangMenuCompact = (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_LANGMENUCOMPACT), BM_GETCHECK, 0, 0)); nppGUI._isLangMenuCompact = (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_LANGMENUCOMPACT), BM_GETCHECK, 0, 0));

View File

@ -265,6 +265,8 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName)
_workSpaceFilePath = projectFileName; _workSpaceFilePath = projectFileName;
_treeView.removeAllItems();
HTREEITEM rootItem = _treeView.addItem(TEXT("Workspace"), TVI_ROOT, INDEX_CLEAN_ROOT); HTREEITEM rootItem = _treeView.addItem(TEXT("Workspace"), TVI_ROOT, INDEX_CLEAN_ROOT);
for ( ; childNode ; childNode = childNode->NextSibling(TEXT("Project"))) for ( ; childNode ; childNode = childNode->NextSibling(TEXT("Project")))
@ -273,7 +275,7 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName)
buildTreeFrom(childNode, projectItem); buildTreeFrom(childNode, projectItem);
} }
setWorkSpaceDirty(false); setWorkSpaceDirty(false);
_treeView.expand(rootItem); _treeView.expand(rootItem);
delete pXmlDocProject; delete pXmlDocProject;
return loadOkay; return loadOkay;
@ -389,7 +391,6 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem)
const TCHAR *v = childNode->Value(); const TCHAR *v = childNode->Value();
if (lstrcmp(TEXT("Folder"), v) == 0) if (lstrcmp(TEXT("Folder"), v) == 0)
{ {
//::MessageBox(NULL, (childNode->ToElement())->Attribute(TEXT("name")), TEXT("Folder"), MB_OK);
HTREEITEM addedItem = _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), hParentItem, INDEX_CLOSED_NODE); HTREEITEM addedItem = _treeView.addItem((childNode->ToElement())->Attribute(TEXT("name")), hParentItem, INDEX_CLOSED_NODE);
if (!childNode->NoChildren()) if (!childNode->NoChildren())
{ {
@ -787,9 +788,11 @@ void ProjectPanel::popupMenuCmd(int cmdID)
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
if (TCHAR *fn = fDlg.doOpenSingleFileDlg()) if (TCHAR *fn = fDlg.doOpenSingleFileDlg())
{ {
_treeView.removeAllItems(); if (!openWorkSpace(fn))
openWorkSpace(fn); {
_workSpaceFilePath = fn; ::MessageBox(_hSelf, TEXT("Opening Workspace failed.\rIt seems the file to open is not valid project file."), TEXT("Open Workspace"), MB_OK);
return;
}
} }
} }
break; break;
@ -811,7 +814,6 @@ void ProjectPanel::popupMenuCmd(int cmdID)
if (::PathFileExists(_workSpaceFilePath.c_str())) if (::PathFileExists(_workSpaceFilePath.c_str()))
{ {
_treeView.removeAllItems();
openWorkSpace(_workSpaceFilePath.c_str()); openWorkSpace(_workSpaceFilePath.c_str());
} }
else else

View File

@ -167,7 +167,7 @@
<Language name="props" ext="properties" commentLine=";"> <Language name="props" ext="properties" commentLine=";">
</Language> </Language>
<Language name="python" ext="py pyw" commentLine="#"> <Language name="python" ext="py pyw" commentLine="#">
<Keywords name="instre1">and as assert break class continue def del elif else except exec finally for from global if import in is lambda None not or pass print raise return triple try while with yield</Keywords> <Keywords name="instre1">and as assert break class continue def del elif else except exec False finally for from global if import in is lambda None not or pass print raise return triple True try while with yield</Keywords>
</Language> </Language>
<Language name="r" ext="r" commentLine="#"> <Language name="r" ext="r" commentLine="#">
<Keywords name="instre1">if else repeat while function for in next break TRUE FALSE NULL NA Inf NaN</Keywords> <Keywords name="instre1">if else repeat while function for in next break TRUE FALSE NULL NA Inf NaN</Keywords>