[NEW_FEATURE] Finish IE7 style menu (auto hide).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@172 f5eea248-9336-0410-98b8-ebc06183d4e3
pull/343/head^2
donho 2008-04-20 00:31:10 +00:00
parent 9e26b31e3a
commit 544a4916d9
8 changed files with 75 additions and 15 deletions

View File

@ -61,7 +61,7 @@ struct SortTaskListPred
Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL),
_pMainSplitter(NULL), _isfullScreen(false),
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _isRTL(false),
_linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _isSaving(false), _hideMenu(true), _sysMenuEntering(false)
_linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _isSaving(false), _sysMenuEntering(false)
{
ZeroMemory(&_prevSelectedRange, sizeof(_prevSelectedRange));
@ -298,7 +298,7 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLi
scnN.nmhdr.idFrom = 0;
_pluginsManager.notify(&scnN);
if (_hideMenu)
if (!nppGUI._menuBarShow)
::SetMenu(_hSelf, NULL);
::ShowWindow(_hSelf, nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW);
@ -3292,13 +3292,24 @@ void Notepad_plus::command(int id)
{
RECT rc;
getClientRect(rc);
NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI();
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;
}
case IDM_VIEW_HIDEMENU :
{
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
nppGUI._menuBarShow = !nppGUI._menuBarShow;
if (nppGUI._menuBarShow)
::SetMenu(_hSelf, _mainMenuHandle);
else
::SetMenu(_hSelf, NULL);
break;
}
case IDM_VIEW_TAB_SPACE:
{
bool isChecked = !(::GetMenuState(_mainMenuHandle, IDM_VIEW_TAB_SPACE, MF_BYCOMMAND) == MF_CHECKED);
@ -7783,7 +7794,8 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_ENTERMENULOOP:
{
if (_hideMenu && !wParam && !_sysMenuEntering)
NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI());
if (!nppgui._menuBarShow && !wParam && !_sysMenuEntering)
::SetMenu(_hSelf, _mainMenuHandle);
return TRUE;
@ -7791,7 +7803,8 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
case WM_EXITMENULOOP:
{
if (_hideMenu && !wParam && !_sysMenuEntering)
NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI());
if (!nppgui._menuBarShow && !wParam && !_sysMenuEntering)
::SetMenu(_hSelf, NULL);
_sysMenuEntering = false;
return FALSE;
@ -7933,7 +7946,11 @@ void Notepad_plus::fullScreenToggle()
{
//Hide window for updating, restore style and menu then restore position and Z-Order
::ShowWindow(_hSelf, SW_HIDE);
::SetMenu(_hSelf, _mainMenuHandle);
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
if (nppGUI._menuBarShow)
::SetMenu(_hSelf, _mainMenuHandle);
::SetWindowLongPtr( _hSelf, GWL_STYLE, _prevStyles);
::SetWindowPos(_hSelf, HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER);
@ -7943,7 +7960,6 @@ void Notepad_plus::fullScreenToggle()
if (_winPlace.length)
{
if (_winPlace.showCmd == SW_SHOWMAXIMIZED)
{
::ShowWindow(_hSelf, SW_RESTORE);

View File

@ -220,7 +220,6 @@ private:
WindowsMenu _windowsMenu;
HMENU _mainMenuHandle;
bool _hideMenu;
bool _sysMenuEntering;
LONG_PTR _prevStyles;

View File

@ -2076,6 +2076,21 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
}
}
}
else if (!strcmp(nm, "MenuBar"))
{
TiXmlNode *n = childNode->FirstChild();
if (n)
{
val = n->Value();
if (val)
{
if (!strcmp(val, "hide"))
_nppGUI._menuBarShow = false;
else if (!strcmp(val, "show"))
_nppGUI._menuBarShow = true;
}
}
}
else if (!strcmp(nm, "TabBar"))
{
bool isFailed = false;
@ -2985,6 +3000,7 @@ bool NppParameters::writeGUIParams()
bool autocExist = false;
bool sessionExtExist = false;
bool noUpdateExist = false;
bool menuBarExist = false;
TiXmlNode *dockingParamNode = NULL;
@ -3017,6 +3033,17 @@ bool NppParameters::writeGUIParams()
else
childNode->InsertEndChild(TiXmlText(pStr));
}
else if (!strcmp(nm, "MenuBar"))
{
const char *pStr = _nppGUI._menuBarShow?"show":"hide";
TiXmlNode *n = childNode->FirstChild();
if (n)
n->SetValue(pStr);
else
childNode->InsertEndChild(TiXmlText(pStr));
menuBarExist = true;
}
else if (!strcmp(nm, "TabBar"))
{
const char *pStr = (_nppGUI._tabStatus & TAB_DRAWTOPBAR)?"yes":"no";
@ -3418,6 +3445,14 @@ bool NppParameters::writeGUIParams()
GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._definedSessionExt.c_str()));
}
if (!menuBarExist)
{
//const char *pStr = bVal?"yes":"no";
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement();
GUIConfigElement->SetAttribute("name", "MenuBar");
GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._menuBarShow?"show":"hide"));
}
insertDockingParamNode(GUIRoot);
return true;
}

View File

@ -523,7 +523,7 @@ struct PrintSettings {
struct NppGUI
{
NppGUI() : _toolBarStatus(TB_LARGE), _toolbarShow(true), _statusBarShow(true), \
NppGUI() : _toolBarStatus(TB_LARGE), _toolbarShow(true), _statusBarShow(true), _menuBarShow(true),\
_tabStatus(TAB_DRAWTOPBAR | TAB_DRAWINACTIVETAB | TAB_DRAGNDROP),\
_splitterPos(POS_HORIZOTAL), _userDefineDlgStatus(UDD_DOCKED), _tabSize(8),\
_tabReplacedBySpace(false), _fileAutoDetection(cdEnabled), _checkHistoryFiles(true),\
@ -540,6 +540,7 @@ struct NppGUI
toolBarStatusType _toolBarStatus; // small, large ou standard
bool _toolbarShow;
bool _statusBarShow; // show ou hide
bool _menuBarShow;
// 1st bit : draw top bar;
// 2nd bit : draw inactive tabs
@ -803,6 +804,8 @@ public:
return _langList[i];
};
int getNbLang() const {return _nbLang;};
const char * getLangExtFromName(const char *langName) const {
for (int i = 0 ; i < _nbLang ; i++)
{

View File

@ -342,14 +342,14 @@ private :
bool _reloadOnSwitchBack;
Lang * getCurrentLang() const {
int i = 0 ;
Lang *l = NppParameters::getInstance()->getLangFromIndex(i++);
while (l)
NppParameters *pNppParam = NppParameters::getInstance();
int i = pNppParam->getNbLang();
while (i >= 0)
{
Lang *l = pNppParam->getLangFromIndex(i--);
if (l->_langID == _lang)
return l;
l = (NppParameters::getInstance())->getLangFromIndex(i++);
//l = (NppParameters::getInstance())->getLangFromIndex(i++);
}
return NULL;
};

View File

@ -118,6 +118,7 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
int tabBarStatus = nppGUI._tabStatus;
bool showTool = nppGUI._toolbarShow;
bool showStatus = nppGUI._statusBarShow;
bool showMenu = nppGUI._menuBarShow;
::SendDlgItemMessage(_hSelf, IDC_CHECK_HIDE, BM_SETCHECK, showTool?BST_UNCHECKED:BST_CHECKED, 0);
@ -148,6 +149,7 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
::SendDlgItemMessage(_hSelf, IDC_CHECK_TAB_HIDE, BM_SETCHECK, tabBarStatus & TAB_HIDE, 0);
::SendMessage(_hSelf, WM_COMMAND, IDC_CHECK_TAB_HIDE, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_SHOWSTATUSBAR, BM_SETCHECK, showStatus, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_HIDEMENUBAR, BM_SETCHECK, !showMenu, 0);
if (!nppGUI._doTaskList)
{
@ -169,6 +171,10 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_STATUSBAR, 0);
return TRUE;
case IDC_CHECK_HIDEMENUBAR :
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_HIDEMENU, 0);
return TRUE;
case IDC_CHECK_TAB_HIDE :
{
bool toBeHidden = (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_TAB_HIDE), BM_GETCHECK, 0, 0));

View File

@ -92,6 +92,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define IDC_CHECK_AUTOUPDATE (IDD_PREFERENCE_SETTING_BOX + 23)
#define IDC_DOCUMENTSWITCHER_STATIC (IDD_PREFERENCE_SETTING_BOX + 24)
#define IDC_CHECK_UPDATEGOTOEOF (IDD_PREFERENCE_SETTING_BOX + 25)
#define IDC_CHECK_ENABLEMAEKALLWORDS (IDD_PREFERENCE_SETTING_BOX + 26)
#define IDD_PREFERENCE_NEWDOCSETTING_BOX 6400 //(IDD_PREFERENCE_BOX + 400)
#define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_NEWDOCSETTING_BOX + 1)

View File

@ -147,7 +147,7 @@
#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 + 45)
#define IDM_VIEW_HIDEMENU (IDM_VIEW + 45)
#define IDM_VIEW_FOLD (IDM_VIEW + 50)
#define IDM_VIEW_FOLD_1 (IDM_VIEW_FOLD + 1)