Skip to content

Commit

Permalink
[BUG_FIXED]
Browse files Browse the repository at this point in the history
1. Fix Project Panel loading non-project file bug.
2. Fix adding/hidding Language Menue item problem in Preference dialog.

- Notepad-plus svn trunk @ 828
  • Loading branch information
donho committed Oct 16, 2011
1 parent 55176a9 commit 0073c83
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 83 deletions.
154 changes: 78 additions & 76 deletions PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,51 +1337,91 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
}
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 (index == LB_ERR)
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 (LOWORD(wParam) == IDC_LIST_TABSETTNG)
{
int index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR)
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)
{
Lang *lang = pNppParam->getLangFromIndex(index - 1);
if (!lang) return FALSE;
bool useDefaultTab = (lang->_tabSize == -1 || lang->_tabSize == 0);
if (index)
{
Lang *lang = pNppParam->getLangFromIndex(index - 1);
if (!lang) return FALSE;
bool useDefaultTab = (lang->_tabSize == -1 || lang->_tabSize == 0);

::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab);

int size = useDefaultTab?nppGUI._tabSize:lang->_tabSize;
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE);
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE);
int size = useDefaultTab?nppGUI._tabSize:lang->_tabSize;
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE);
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE);

::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
::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_TABSIZEVAL_STATIC), !useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab?nppGUI._tabReplacedBySpace:lang->_isTabReplacedBySpace, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab);

if (!useDefaultTab)
{
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, lang->_tabSize, FALSE);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, lang->_isTabReplacedBySpace, 0);
}
}
else
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), TRUE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), TRUE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), SW_SHOW);
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, nppGUI._tabReplacedBySpace, 0);
}
if (!useDefaultTab)
{
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, lang->_tabSize, FALSE);
::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, lang->_isTabReplacedBySpace, 0);
}
}
else
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), TRUE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), TRUE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), SW_SHOW);
::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE);
::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)
Expand Down Expand Up @@ -1474,44 +1514,6 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
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 :
{
nppGUI._isLangMenuCompact = (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_LANGMENUCOMPACT), BM_GETCHECK, 0, 0));
Expand Down
14 changes: 8 additions & 6 deletions PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName)

_workSpaceFilePath = projectFileName;

_treeView.removeAllItems();

HTREEITEM rootItem = _treeView.addItem(TEXT("Workspace"), TVI_ROOT, INDEX_CLEAN_ROOT);

for ( ; childNode ; childNode = childNode->NextSibling(TEXT("Project")))
Expand All @@ -273,7 +275,7 @@ bool ProjectPanel::openWorkSpace(const TCHAR *projectFileName)
buildTreeFrom(childNode, projectItem);
}
setWorkSpaceDirty(false);
_treeView.expand(rootItem);
_treeView.expand(rootItem);

delete pXmlDocProject;
return loadOkay;
Expand Down Expand Up @@ -389,7 +391,6 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem)
const TCHAR *v = childNode->Value();
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);
if (!childNode->NoChildren())
{
Expand Down Expand Up @@ -787,9 +788,11 @@ void ProjectPanel::popupMenuCmd(int cmdID)
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
if (TCHAR *fn = fDlg.doOpenSingleFileDlg())
{
_treeView.removeAllItems();
openWorkSpace(fn);
_workSpaceFilePath = fn;
if (!openWorkSpace(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;
Expand All @@ -811,7 +814,6 @@ void ProjectPanel::popupMenuCmd(int cmdID)

if (::PathFileExists(_workSpaceFilePath.c_str()))
{
_treeView.removeAllItems();
openWorkSpace(_workSpaceFilePath.c_str());
}
else
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/langs.model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<Language name="props" ext="properties" commentLine=";">
</Language>
<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 name="r" ext="r" commentLine="#">
<Keywords name="instre1">if else repeat while function for in next break TRUE FALSE NULL NA Inf NaN</Keywords>
Expand Down

0 comments on commit 0073c83

Please sign in to comment.