[NEW_FEATURE] Add PostIt feature (F12 to toggle it).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@371 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-12-21 16:09:14 +00:00
parent 22bf2fe477
commit bc95071907
7 changed files with 183 additions and 40 deletions

View File

@ -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. // otherwise it'll be shown.
// return value : the old status value // return value : the old status value
#define NPPM_ISTABBARHIDE (NPPMSG + 52) #define NPPM_ISTABBARHIDDEN (NPPMSG + 52)
// BOOL NPPM_ISTABBARHIDE(0, 0) // BOOL NPPM_ISTABBARHIDDEN(0, 0)
// returned value : TRUE if tab bar is hidden, otherwise FALSE // returned value : TRUE if tab bar is hidden, otherwise FALSE
#define NPPM_CHECKDOCSTATUS (NPPMSG + 53) #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) // BOOL NPPM_ADDREBAR(INT ID, 0)
//Use ID assigned with NPPM_ADDREBAR //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 RUNCOMMAND_USER (WM_USER + 3000)
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH) #define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)

View File

@ -3420,12 +3420,6 @@ void Notepad_plus::command(int id)
_pEditView->collapse(id - IDM_VIEW_UNFOLD - 1, fold_uncollapse); _pEditView->collapse(id - IDM_VIEW_UNFOLD - 1, fold_uncollapse);
break; 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: case IDM_VIEW_TOOLBAR_REDUCE:
{ {
@ -3549,27 +3543,61 @@ void Notepad_plus::command(int id)
break; break;
} }
case IDM_VIEW_STATUSBAR: case IDM_VIEW_POSTIT :
{ {
RECT rc; DWORD dwStyle = GetWindowLong(_hSelf, GWL_STYLE);
getClientRect(rc); bool isPostItOn = (WS_CAPTION & dwStyle) == 0;
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); if (isPostItOn)
nppGUI._statusBarShow = !nppGUI._statusBarShow; {
_statusBar.display(nppGUI._statusBarShow); dwStyle |= (WS_CAPTION | WS_SIZEBOX);
::SendMessage(_hSelf, WM_SIZE, SIZE_RESTORED, MAKELONG(rc.bottom, rc.right)); ::SetWindowLong(_hSelf, GWL_STYLE, dwStyle);
break;
}
case IDM_VIEW_HIDEMENU : if (_beforePostIt.isStatusbarShown)
{ ::SendMessage(_hSelf, NPPM_HIDESTATUSBAR, 0, FALSE);
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); if (_beforePostIt.isMenuShown)
nppGUI._menuBarShow = !nppGUI._menuBarShow; ::SendMessage(_hSelf, NPPM_HIDEMENU, 0, FALSE);
if (nppGUI._menuBarShow) if (_beforePostIt.isToolbarShown)
::SetMenu(_hSelf, _mainMenuHandle); ::SendMessage(_hSelf, NPPM_HIDETOOLBAR, 0, FALSE);
else if (_beforePostIt.isTabbarShown)
::SetMenu(_hSelf, NULL); ::SendMessage(_hSelf, NPPM_HIDETABBAR, 0, FALSE);
break;
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: case IDM_VIEW_TAB_SPACE:
{ {
@ -8117,7 +8145,10 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case NPPM_HIDETABBAR : case NPPM_HIDETABBAR :
{ {
bool hide = (lParam != 0); 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); ::SendMessage(_hSelf, WM_SIZE, 0, 0);
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
@ -8128,11 +8159,70 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
return oldVal; return oldVal;
} }
case NPPM_ISTABBARHIDDEN :
case NPPM_ISTABBARHIDE :
{ {
return _mainDocTab.getHideTabBarStatus(); 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 : case NPPM_ADDREBAR :
{ {

View File

@ -86,6 +86,18 @@ struct iconLocator {
: listIndex(iList), iconIndex(iIcon), iconLocation(iconLoc){}; : 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 FileDialog;
class Notepad_plus : public Window { class Notepad_plus : public Window {
@ -368,6 +380,8 @@ private:
//User dialog docking //User dialog docking
void dockUserDlg(); void dockUserDlg();
void undockUserDlg(); void undockUserDlg();
//PostItConf _postIt;
PostItConf _beforePostIt;
//View visibility //View visibility
void showView(int whichOne); void showView(int whichOne);

View File

@ -271,6 +271,7 @@ BEGIN
BEGIN BEGIN
MENUITEM "Toggle Full Screen Mode", IDM_VIEW_FULLSCREENTOGGLE MENUITEM "Toggle Full Screen Mode", IDM_VIEW_FULLSCREENTOGGLE
MENUITEM "Always on top", IDM_VIEW_ALWAYSONTOP MENUITEM "Always on top", IDM_VIEW_ALWAYSONTOP
MENUITEM "PostIt", IDM_VIEW_POSTIT
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "Show White Space and TAB", IDM_VIEW_TAB_SPACE MENUITEM "Show White Space and TAB", IDM_VIEW_TAB_SPACE

View File

@ -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_CLONE_TO_ANOTHER_VIEW, false, false, false, NULL},
{VK_NULL, IDM_VIEW_SYNSCROLLV, false, false, false, NULL}, {VK_NULL, IDM_VIEW_SYNSCROLLV, false, false, false, NULL},
{VK_NULL, IDM_VIEW_SYNSCROLLH, 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_TODOS, false, false, false, NULL},
{VK_NULL, IDM_FORMAT_TOUNIX, 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_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_HOMESWEETHOME, false, false, false, NULL},
{VK_NULL, IDM_PROJECTPAGE, false, false, false, NULL}, {VK_NULL, IDM_PROJECTPAGE, false, false, false, NULL},

View File

@ -187,12 +187,18 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
switch (wParam) switch (wParam)
{ {
case IDC_CHECK_SHOWSTATUSBAR : 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 : 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 : case IDC_CHECK_TAB_HIDE :
{ {
@ -245,8 +251,11 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
return TRUE; return TRUE;
case IDC_CHECK_HIDE : 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 : case IDC_RADIO_SMALLICON :
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_TOOLBAR_REDUCE, 0); ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_TOOLBAR_REDUCE, 0);

View File

@ -111,7 +111,7 @@
#define IDM_SEARCH_DELETEMARKEDLINES (IDM_SEARCH + 21) #define IDM_SEARCH_DELETEMARKEDLINES (IDM_SEARCH + 21)
#define IDM_VIEW (IDM + 4000) #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_REDUCE (IDM_VIEW + 2)
#define IDM_VIEW_TOOLBAR_ENLARGE (IDM_VIEW + 3) #define IDM_VIEW_TOOLBAR_ENLARGE (IDM_VIEW + 3)
#define IDM_VIEW_TOOLBAR_STANDARD (IDM_VIEW + 4) #define IDM_VIEW_TOOLBAR_STANDARD (IDM_VIEW + 4)
@ -119,7 +119,7 @@
#define IDM_VIEW_LOCKTABBAR (IDM_VIEW + 6) #define IDM_VIEW_LOCKTABBAR (IDM_VIEW + 6)
#define IDM_VIEW_DRAWTABBAR_TOPBAR (IDM_VIEW + 7) #define IDM_VIEW_DRAWTABBAR_TOPBAR (IDM_VIEW + 7)
#define IDM_VIEW_DRAWTABBAR_INACIVETAB (IDM_VIEW + 8) #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_TOGGLE_FOLDALL (IDM_VIEW + 10)
#define IDM_VIEW_USER_DLG (IDM_VIEW + 11) #define IDM_VIEW_USER_DLG (IDM_VIEW + 11)
#define IDM_VIEW_LINENUMBER (IDM_VIEW + 12) #define IDM_VIEW_LINENUMBER (IDM_VIEW + 12)
@ -155,7 +155,8 @@
#define IDM_VIEW_HIDELINES (IDM_VIEW + 42) #define IDM_VIEW_HIDELINES (IDM_VIEW + 42)
#define IDM_VIEW_DRAWTABBAR_VERTICAL (IDM_VIEW + 43) #define IDM_VIEW_DRAWTABBAR_VERTICAL (IDM_VIEW + 43)
#define IDM_VIEW_DRAWTABBAR_MULTILINE (IDM_VIEW + 44) #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 (IDM_VIEW + 50)
#define IDM_VIEW_FOLD_1 (IDM_VIEW_FOLD + 1) #define IDM_VIEW_FOLD_1 (IDM_VIEW_FOLD + 1)