diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index 1c17d3b5b..3e9f1857e 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -187,8 +187,8 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV // otherwise it'll be shown. // return value : the old status value - #define NPPM_ISTABBARHIDE (NPPMSG + 52) - // BOOL NPPM_ISTABBARHIDE(0, 0) + #define NPPM_ISTABBARHIDDEN (NPPMSG + 52) + // BOOL NPPM_ISTABBARHIDDEN(0, 0) // returned value : TRUE if tab bar is hidden, otherwise FALSE #define NPPM_CHECKDOCSTATUS (NPPMSG + 53) @@ -286,7 +286,35 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV // BOOL NPPM_ADDREBAR(INT ID, 0) //Use ID assigned with NPPM_ADDREBAR */ + #define NPPM_HIDETOOLBAR (NPPMSG + 70) + // BOOL NPPM_HIDETOOLBAR(0, BOOL hideOrNot) + // if hideOrNot is set as TRUE then tool bar will be hidden + // otherwise it'll be shown. + // return value : the old status value + #define NPPM_ISTOOLBARHIDDEN (NPPMSG + 71) + // BOOL NPPM_ISTOOLBARHIDDEN(0, 0) + // returned value : TRUE if tool bar is hidden, otherwise FALSE + + #define NPPM_HIDEMENU (NPPMSG + 72) + // BOOL NPPM_HIDEMENU(0, BOOL hideOrNot) + // if hideOrNot is set as TRUE then menu will be hidden + // otherwise it'll be shown. + // return value : the old status value + + #define NPPM_ISMENUHIDDEN (NPPMSG + 73) + // BOOL NPPM_ISMENUHIDDEN(0, 0) + // returned value : TRUE if menu is hidden, otherwise FALSE + + #define NPPM_HIDESTATUSBAR (NPPMSG + 74) + // BOOL NPPM_HIDESTATUSBAR(0, BOOL hideOrNot) + // if hideOrNot is set as TRUE then STATUSBAR will be hidden + // otherwise it'll be shown. + // return value : the old status value + + #define NPPM_ISSTATUSBARHIDDEN (NPPMSG + 75) + // BOOL NPPM_ISSTATUSBARHIDDEN(0, 0) + // returned value : TRUE if STATUSBAR is hidden, otherwise FALSE #define RUNCOMMAND_USER (WM_USER + 3000) #define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 1a16fad80..42d77935d 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3420,12 +3420,6 @@ void Notepad_plus::command(int id) _pEditView->collapse(id - IDM_VIEW_UNFOLD - 1, fold_uncollapse); break; - case IDM_VIEW_TOOLBAR_HIDE: - { - bool toSet = !_rebarTop.getIDVisible(REBAR_BAR_TOOLBAR); - _rebarTop.setIDVisible(REBAR_BAR_TOOLBAR, toSet); - } - break; case IDM_VIEW_TOOLBAR_REDUCE: { @@ -3549,27 +3543,61 @@ void Notepad_plus::command(int id) break; } - case IDM_VIEW_STATUSBAR: + case IDM_VIEW_POSTIT : { - RECT rc; - getClientRect(rc); - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); - nppGUI._statusBarShow = !nppGUI._statusBarShow; - _statusBar.display(nppGUI._statusBarShow); - ::SendMessage(_hSelf, WM_SIZE, SIZE_RESTORED, MAKELONG(rc.bottom, rc.right)); - break; - } + DWORD dwStyle = GetWindowLong(_hSelf, GWL_STYLE); + bool isPostItOn = (WS_CAPTION & dwStyle) == 0; + if (isPostItOn) + { + dwStyle |= (WS_CAPTION | WS_SIZEBOX); + ::SetWindowLong(_hSelf, GWL_STYLE, dwStyle); - case IDM_VIEW_HIDEMENU : - { - NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); - nppGUI._menuBarShow = !nppGUI._menuBarShow; - if (nppGUI._menuBarShow) - ::SetMenu(_hSelf, _mainMenuHandle); - else - ::SetMenu(_hSelf, NULL); - break; + if (_beforePostIt.isStatusbarShown) + ::SendMessage(_hSelf, NPPM_HIDESTATUSBAR, 0, FALSE); + if (_beforePostIt.isMenuShown) + ::SendMessage(_hSelf, NPPM_HIDEMENU, 0, FALSE); + if (_beforePostIt.isToolbarShown) + ::SendMessage(_hSelf, NPPM_HIDETOOLBAR, 0, FALSE); + if (_beforePostIt.isTabbarShown) + ::SendMessage(_hSelf, NPPM_HIDETABBAR, 0, FALSE); + + if (!_beforePostIt.isAlwaysOnTop) + ::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0); + + } + else // PostIt + { + NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + // get current status before switch to postIt + _beforePostIt.isPostIt = false; + _beforePostIt.isSizable = true; + _beforePostIt.isAlwaysOnTop = ::GetMenuState(_mainMenuHandle, IDM_VIEW_ALWAYSONTOP, MF_BYCOMMAND) == MF_CHECKED; + _beforePostIt.isMenuShown = ::SendMessage(_hSelf, NPPM_ISMENUHIDDEN, 0, 0) != TRUE; + _beforePostIt.isToolbarShown = ::SendMessage(_hSelf, NPPM_ISTOOLBARHIDDEN, 0, 0) != TRUE; + _beforePostIt.isTabbarShown = ::SendMessage(_hSelf, NPPM_ISTABBARHIDDEN, 0, 0) != TRUE; + _beforePostIt.isStatusbarShown = nppGUI._statusBarShow; + + // PostIt! + dwStyle &= ~(WS_CAPTION | WS_SIZEBOX); + ::SetWindowLong(_hSelf, GWL_STYLE, dwStyle); + + if (nppGUI._statusBarShow) + ::SendMessage(_hSelf, NPPM_HIDESTATUSBAR, 0, TRUE); + if (_beforePostIt.isMenuShown) + ::SendMessage(_hSelf, NPPM_HIDEMENU, 0, TRUE); + + if (_beforePostIt.isTabbarShown) + ::SendMessage(_hSelf, NPPM_HIDETABBAR, 0, TRUE); + if (_beforePostIt.isToolbarShown) + ::SendMessage(_hSelf, NPPM_HIDETOOLBAR, 0, TRUE); + + if (!_beforePostIt.isAlwaysOnTop) + ::SendMessage(_hSelf, WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0); + } + + //::SendMessage(_hSelf, WM_SIZE, 0, 0); } + break; case IDM_VIEW_TAB_SPACE: { @@ -8117,7 +8145,10 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_HIDETABBAR : { bool hide = (lParam != 0); - bool oldVal = DocTabView::setHideTabBarStatus(hide); + bool oldVal = DocTabView::getHideTabBarStatus(); + if (hide == oldVal) return oldVal; + + DocTabView::setHideTabBarStatus(hide); ::SendMessage(_hSelf, WM_SIZE, 0, 0); NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); @@ -8128,11 +8159,70 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return oldVal; } - - case NPPM_ISTABBARHIDE : + case NPPM_ISTABBARHIDDEN : { return _mainDocTab.getHideTabBarStatus(); } + + + case NPPM_HIDETOOLBAR : + { + bool show = (lParam != TRUE); + bool currentStatus = _rebarTop.getIDVisible(REBAR_BAR_TOOLBAR); + if (show != currentStatus) + _rebarTop.setIDVisible(REBAR_BAR_TOOLBAR, show); + return currentStatus; + } + case NPPM_ISTOOLBARHIDDEN : + { + return !_rebarTop.getIDVisible(REBAR_BAR_TOOLBAR); + } + + case NPPM_HIDEMENU : + { + bool hide = (lParam == TRUE); + bool isHidden = ::GetMenu(_hSelf) == NULL; + if (hide == isHidden) + return isHidden; + + NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + nppGUI._menuBarShow = !hide; + if (nppGUI._menuBarShow) + ::SetMenu(_hSelf, _mainMenuHandle); + else + ::SetMenu(_hSelf, NULL); + + return isHidden; + } + case NPPM_ISMENUHIDDEN : + { + return (::GetMenu(_hSelf) == NULL); + } + + case NPPM_HIDESTATUSBAR: + { + bool show = (lParam != TRUE); + NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + bool oldVal = nppGUI._statusBarShow; + if (show == oldVal) + { + return oldVal; + } + RECT rc; + getClientRect(rc); + + nppGUI._statusBarShow = show; + _statusBar.display(nppGUI._statusBarShow); + ::SendMessage(_hSelf, WM_SIZE, SIZE_RESTORED, MAKELONG(rc.bottom, rc.right)); + return oldVal; + } + + case NPPM_ISSTATUSBARHIDDEN : + { + NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); + return !nppGUI._statusBarShow; + } + /* case NPPM_ADDREBAR : { diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index aa7b722e6..9cf4122fb 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -86,6 +86,18 @@ struct iconLocator { : listIndex(iList), iconIndex(iIcon), iconLocation(iconLoc){}; }; +struct PostItConf { + bool isPostIt; // WS_CAPTION + bool isSizable; // WS_SIZEBOX + bool isAlwaysOnTop; + bool isMenuShown; + bool isToolbarShown; + bool isTabbarShown; + bool isStatusbarShown; + PostItConf() : isPostIt(true), isSizable(false), isAlwaysOnTop(true),\ + isMenuShown(false), isToolbarShown(false), isTabbarShown(false), isStatusbarShown(false){}; +}; + class FileDialog; class Notepad_plus : public Window { @@ -368,6 +380,8 @@ private: //User dialog docking void dockUserDlg(); void undockUserDlg(); + //PostItConf _postIt; + PostItConf _beforePostIt; //View visibility void showView(int whichOne); diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 7c26dbf10..d4e74d5f0 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -271,6 +271,7 @@ BEGIN BEGIN MENUITEM "Toggle Full Screen Mode", IDM_VIEW_FULLSCREENTOGGLE MENUITEM "Always on top", IDM_VIEW_ALWAYSONTOP + MENUITEM "PostIt", IDM_VIEW_POSTIT MENUITEM SEPARATOR MENUITEM "Show White Space and TAB", IDM_VIEW_TAB_SPACE diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index a09d12650..850f023ac 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -154,7 +154,7 @@ WinMenuKeyDefinition winKeyDefs[] = { //array of accelerator keys for all std me {VK_NULL, IDM_VIEW_CLONE_TO_ANOTHER_VIEW, false, false, false, NULL}, {VK_NULL, IDM_VIEW_SYNSCROLLV, false, false, false, NULL}, {VK_NULL, IDM_VIEW_SYNSCROLLH, false, false, false, NULL}, - {VK_F8, IDM_VIEW_SWITCHTO_OTHER_VIEW, false, false, false, TEXT("Focus on other view")}, + {VK_F8, IDM_VIEW_SWITCHTO_OTHER_VIEW, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_TODOS, false, false, false, NULL}, {VK_NULL, IDM_FORMAT_TOUNIX, false, false, false, NULL}, @@ -181,7 +181,7 @@ WinMenuKeyDefinition winKeyDefs[] = { //array of accelerator keys for all std me {VK_F5, IDM_EXECUTE, false, false, false, NULL}, -// {VK_NULL, IDM_WINDOW_WINDOWS, false, false, false, NULL}, + {VK_F12, IDM_VIEW_POSTIT, false, false, false, NULL}, {VK_NULL, IDM_HOMESWEETHOME, false, false, false, NULL}, {VK_NULL, IDM_PROJECTPAGE, false, false, false, NULL}, diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 8e42355b5..cee83de75 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -187,12 +187,18 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) switch (wParam) { case IDC_CHECK_SHOWSTATUSBAR : - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_STATUSBAR, 0); - return TRUE; + { + bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_SHOWSTATUSBAR, BM_GETCHECK, 0, 0)); + ::SendMessage(::GetParent(_hParent), NPPM_HIDESTATUSBAR, 0, isChecked?FALSE:TRUE); + } + return TRUE; case IDC_CHECK_HIDEMENUBAR : - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_HIDEMENU, 0); - return TRUE; + { + bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_HIDEMENUBAR, BM_GETCHECK, 0, 0)); + ::SendMessage(::GetParent(_hParent), NPPM_HIDEMENU, 0, isChecked?TRUE:FALSE); + } + return TRUE; case IDC_CHECK_TAB_HIDE : { @@ -245,8 +251,11 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) return TRUE; case IDC_CHECK_HIDE : - ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_TOOLBAR_HIDE, 0); - return TRUE; + { + bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_HIDE, BM_GETCHECK, 0, 0)); + ::SendMessage(::GetParent(_hParent), NPPM_HIDETOOLBAR, 0, isChecked?TRUE:FALSE); + } + return TRUE; case IDC_RADIO_SMALLICON : ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_TOOLBAR_REDUCE, 0); diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 0cbc4b2cd..470343705 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -111,7 +111,7 @@ #define IDM_SEARCH_DELETEMARKEDLINES (IDM_SEARCH + 21) #define IDM_VIEW (IDM + 4000) - #define IDM_VIEW_TOOLBAR_HIDE (IDM_VIEW + 1) + //#define IDM_VIEW_TOOLBAR_HIDE (IDM_VIEW + 1) #define IDM_VIEW_TOOLBAR_REDUCE (IDM_VIEW + 2) #define IDM_VIEW_TOOLBAR_ENLARGE (IDM_VIEW + 3) #define IDM_VIEW_TOOLBAR_STANDARD (IDM_VIEW + 4) @@ -119,7 +119,7 @@ #define IDM_VIEW_LOCKTABBAR (IDM_VIEW + 6) #define IDM_VIEW_DRAWTABBAR_TOPBAR (IDM_VIEW + 7) #define IDM_VIEW_DRAWTABBAR_INACIVETAB (IDM_VIEW + 8) - #define IDM_VIEW_STATUSBAR (IDM_VIEW + 9) + //#define IDM_VIEW_STATUSBAR (IDM_VIEW + 9) #define IDM_VIEW_TOGGLE_FOLDALL (IDM_VIEW + 10) #define IDM_VIEW_USER_DLG (IDM_VIEW + 11) #define IDM_VIEW_LINENUMBER (IDM_VIEW + 12) @@ -155,7 +155,8 @@ #define IDM_VIEW_HIDELINES (IDM_VIEW + 42) #define IDM_VIEW_DRAWTABBAR_VERTICAL (IDM_VIEW + 43) #define IDM_VIEW_DRAWTABBAR_MULTILINE (IDM_VIEW + 44) - #define IDM_VIEW_HIDEMENU (IDM_VIEW + 45) + //#define IDM_VIEW_HIDEMENU (IDM_VIEW + 45) +#define IDM_VIEW_POSTIT (IDM_VIEW + 46) #define IDM_VIEW_FOLD (IDM_VIEW + 50) #define IDM_VIEW_FOLD_1 (IDM_VIEW_FOLD + 1)