[NEW_FEATURE] Language Menu can be compacted (optional).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@456 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2009-04-24 15:20:58 +00:00
parent 7c5a7bb461
commit 6b0cfa6bb6
8 changed files with 131 additions and 11 deletions

View File

@ -6961,8 +6961,14 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
} }
case WM_CREATE: case WM_CREATE:
{ {
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
// Menu // Menu
_mainMenuHandle = ::GetMenu(_hSelf); _mainMenuHandle = ::GetMenu(_hSelf);
int langPos2BeRemoved = MENUINDEX_LANGUAGE+1;
if (nppGUI._isLangMenuCompact)
langPos2BeRemoved = MENUINDEX_LANGUAGE;
::RemoveMenu(_mainMenuHandle, langPos2BeRemoved, MF_BYPOSITION);
//Views //Views
_pDocTab = &_mainDocTab; _pDocTab = &_mainDocTab;
@ -6977,7 +6983,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
MainFileManager->init(this, &_fileEditView); //get it up and running asap. MainFileManager->init(this, &_fileEditView); //get it up and running asap.
pNppParam->setFontList(hwnd); pNppParam->setFontList(hwnd);
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
_mainWindowStatus = WindowMainActive; _mainWindowStatus = WindowMainActive;
_activeView = MAIN_VIEW; _activeView = MAIN_VIEW;

View File

@ -282,6 +282,9 @@ private:
WindowsMenu _windowsMenu; WindowsMenu _windowsMenu;
HMENU _mainMenuHandle; HMENU _mainMenuHandle;
HMENU _menuLang;
HMENU _menuLangCompact;
bool _sysMenuEntering; bool _sysMenuEntering;
// For FullScreen/PostIt features // For FullScreen/PostIt features

View File

@ -441,7 +441,99 @@ BEGIN
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "User Defined", IDM_LANG_USER MENUITEM "User Defined", IDM_LANG_USER
END END
POPUP "&Language"
BEGIN
POPUP "A"
BEGIN
MENUITEM "Ada", IDM_LANG_ADA
MENUITEM "ASP", IDM_LANG_ASP
MENUITEM "Assembly", IDM_LANG_ASM
MENUITEM "AutoIt", IDM_LANG_AU3
END
MENUITEM "Batch", IDM_LANG_BATCH
POPUP "C"
BEGIN
MENUITEM "C", IDM_LANG_C
MENUITEM "C#", IDM_LANG_CS
MENUITEM "C++", IDM_LANG_CPP
MENUITEM "Caml", IDM_LANG_CAML
MENUITEM "Cmake", IDM_LANG_CMAKE
MENUITEM "CSS", IDM_LANG_CSS
END
MENUITEM "Diff", IDM_LANG_DIFF
POPUP "F"
BEGIN
MENUITEM "Flash actionscript", IDM_LANG_FLASH
MENUITEM "Fortran", IDM_LANG_FORTRAN
END
POPUP "H"
BEGIN
MENUITEM "Haskell", IDM_LANG_HASKELL
MENUITEM "HTML", IDM_LANG_HTML
END
MENUITEM "INNO", IDM_LANG_INNO
POPUP "J"
BEGIN
MENUITEM "Java", IDM_LANG_JAVA
MENUITEM "Javascript", IDM_LANG_JS
END
MENUITEM "KIXtart", IDM_LANG_KIX
POPUP "L"
BEGIN
MENUITEM "LISP", IDM_LANG_LISP
MENUITEM "Lua", IDM_LANG_LUA
END
POPUP "M"
BEGIN
MENUITEM "Makefile", IDM_LANG_MAKEFILE
MENUITEM "Matlab", IDM_LANG_MATLAB
MENUITEM "MS INI file", IDM_LANG_INI
MENUITEM "MS-DOS Style", IDM_LANG_ASCII
END
POPUP "N"
BEGIN
MENUITEM "Normal Text", IDM_LANG_TEXT
MENUITEM "NSIS", IDM_LANG_NSIS
END
MENUITEM "Objective-C", IDM_LANG_OBJC
POPUP "P"
BEGIN
MENUITEM "Pascal", IDM_LANG_PASCAL
MENUITEM "Perl", IDM_LANG_PERL
MENUITEM "PHP", IDM_LANG_PHP
MENUITEM "Postscript", IDM_LANG_PS
MENUITEM "Properties", IDM_LANG_PROPS
MENUITEM "Python", IDM_LANG_PYTHON
END
POPUP "R"
BEGIN
MENUITEM "rc resource file", IDM_LANG_RC
MENUITEM "Ruby", IDM_LANG_RUBY
END
POPUP "S"
BEGIN
MENUITEM "Shell", IDM_LANG_SH
MENUITEM "Scheme", IDM_LANG_SCHEME
MENUITEM "Smalltalk", IDM_LANG_SMALLTALK
MENUITEM "SQL", IDM_LANG_SQL
END
POPUP "T"
BEGIN
MENUITEM "TCL", IDM_LANG_TCL
MENUITEM "TeX", IDM_LANG_TEX
END
POPUP "V"
BEGIN
MENUITEM "VB", IDM_LANG_VB
MENUITEM "VHDL", IDM_LANG_VHDL
MENUITEM "Verilog", IDM_LANG_VERILOG
END
MENUITEM "XML", IDM_LANG_XML
MENUITEM "YAML", IDM_LANG_YAML
MENUITEM SEPARATOR
MENUITEM "User Defined", IDM_LANG_USER
END
POPUP "Se&ttings" POPUP "Se&ttings"
BEGIN BEGIN
MENUITEM "Preferences...", IDM_SETTING_PREFERECE MENUITEM "Preferences...", IDM_SETTING_PREFERECE

View File

@ -2988,6 +2988,10 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
_nppGUI._excludedLangList.push_back(LangMenuItem((LangType)i)); _nppGUI._excludedLangList.push_back(LangMenuItem((LangType)i));
mask <<= 1; mask <<= 1;
} }
val = element->Attribute(TEXT("langMenuCompact"));
if (val)
_nppGUI._isLangMenuCompact = (!lstrcmp(val, TEXT("yes")));
} }
else if (!lstrcmp(nm, TEXT("Print"))) else if (!lstrcmp(nm, TEXT("Print")))
@ -3733,6 +3737,7 @@ bool NppParameters::writeGUIParams()
else if (!lstrcmp(nm, TEXT("langsExcluded"))) else if (!lstrcmp(nm, TEXT("langsExcluded")))
{ {
writeExcludedLangList(element); writeExcludedLangList(element);
element->SetAttribute(TEXT("langMenuCompact"), _nppGUI._isLangMenuCompact?TEXT("yes"):TEXT("no"));
langsExcludedLstExist = true; langsExcludedLstExist = true;
} }
else if (!lstrcmp(nm, TEXT("Print"))) else if (!lstrcmp(nm, TEXT("Print")))
@ -3922,6 +3927,7 @@ bool NppParameters::writeGUIParams()
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("langsExcluded")); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("langsExcluded"));
writeExcludedLangList(GUIConfigElement); writeExcludedLangList(GUIConfigElement);
GUIConfigElement->SetAttribute(TEXT("langMenuCompact"), _nppGUI._isLangMenuCompact?TEXT("yes"):TEXT("no"));
} }
if (!printSettingExist) if (!printSettingExist)

View File

@ -552,7 +552,7 @@ struct NppGUI
_isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\ _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\
_doTaskList(true), _maitainIndent(true), _openSaveDir(dir_followCurrent), _styleMRU(true), _styleURL(0),\ _doTaskList(true), _maitainIndent(true), _openSaveDir(dir_followCurrent), _styleMRU(true), _styleURL(0),\
_autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")), _neverUpdate(false),\ _autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")), _neverUpdate(false),\
_doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _shortTitlebar(false), _themeName(TEXT("")) { _doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _shortTitlebar(false), _themeName(TEXT("")), _isLangMenuCompact(false) {
_appPos.left = 0; _appPos.left = 0;
_appPos.top = 0; _appPos.top = 0;
_appPos.right = 700; _appPos.right = 700;
@ -609,6 +609,8 @@ struct NppGUI
void setTabReplacedBySpace(bool b) {_tabReplacedBySpace = b;}; void setTabReplacedBySpace(bool b) {_tabReplacedBySpace = b;};
const NewDocDefaultSettings & getNewDocDefaultSettings() const {return _newDocDefaultSettings;}; const NewDocDefaultSettings & getNewDocDefaultSettings() const {return _newDocDefaultSettings;};
vector<LangMenuItem> _excludedLangList; vector<LangMenuItem> _excludedLangList;
bool _isLangMenuCompact;
PrintSettings _printSettings; PrintSettings _printSettings;
BackupFeature _backup; BackupFeature _backup;
bool _useDir; bool _useDir;

View File

@ -162,12 +162,13 @@ IDD_PREFERENCE_LANG_BOX DIALOGEX 0, 0, 390, 185
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN BEGIN
LISTBOX IDC_LIST_ENABLEDLANG,80,21,78,140,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP LISTBOX IDC_LIST_ENABLEDLANG,85,39,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LISTBOX IDC_LIST_DISABLEDLANG,226,21,78,140,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP LISTBOX IDC_LIST_DISABLEDLANG,231,39,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "->",IDC_BUTTON_REMOVE,167,53,50,14 PUSHBUTTON "->",IDC_BUTTON_REMOVE,172,71,50,14
PUSHBUTTON "<-",IDC_BUTTON_RESTORE,168,84,50,14 PUSHBUTTON "<-",IDC_BUTTON_RESTORE,173,102,50,14
CTEXT "Available items",IDC_ENABLEDITEMS_STATIC,83,8,72,8 CTEXT "Available items",IDC_ENABLEDITEMS_STATIC,88,26,72,8
CTEXT "Disabled items",IDC_DISABLEDITEMS_STATIC,229,8,72,8 CTEXT "Disabled items",IDC_DISABLEDITEMS_STATIC,234,26,72,8
CONTROL "Make Language Menu compact",IDC_CHECK_LANGMENUCOMPACT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,86,5,174,10
END END
IDD_PREFERENCE_PRINT_BOX DIALOGEX 0, 0, 390, 185 IDD_PREFERENCE_PRINT_BOX DIALOGEX 0, 0, 390, 185

View File

@ -1081,7 +1081,7 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
::SendDlgItemMessage(_hSelf, IDC_LIST_DISABLEDLANG, LB_ADDSTRING, 0, (LPARAM)nppGUI._excludedLangList[i]._langName.c_str()); ::SendDlgItemMessage(_hSelf, IDC_LIST_DISABLEDLANG, LB_ADDSTRING, 0, (LPARAM)nppGUI._excludedLangList[i]._langName.c_str());
} }
::SendDlgItemMessage(_hSelf, IDC_CHECK_LANGMENUCOMPACT, BM_SETCHECK, nppGUI._isLangMenuCompact?BST_CHECKED:BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_REMOVE), FALSE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_REMOVE), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_RESTORE), FALSE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_RESTORE), FALSE);
@ -1132,7 +1132,16 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
} }
return TRUE; return TRUE;
} }
case IDC_CHECK_LANGMENUCOMPACT :
{
nppGUI._isLangMenuCompact = (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_LANGMENUCOMPACT), BM_GETCHECK, 0, 0));
::MessageBox(_hSelf,
nppGUI._isLangMenuCompact?TEXT("This option will be enable on the next launch."):TEXT("This option will be disable on the next launch."),
TEXT("Compact Language Menu"), MB_OK);
return TRUE;
}
case IDC_BUTTON_RESTORE : case IDC_BUTTON_RESTORE :
case IDC_BUTTON_REMOVE : case IDC_BUTTON_REMOVE :
{ {

View File

@ -139,6 +139,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define IDC_BUTTON_RESTORE (IDD_PREFERENCE_LANG_BOX + 4) #define IDC_BUTTON_RESTORE (IDD_PREFERENCE_LANG_BOX + 4)
#define IDC_ENABLEDITEMS_STATIC (IDD_PREFERENCE_LANG_BOX + 5) #define IDC_ENABLEDITEMS_STATIC (IDD_PREFERENCE_LANG_BOX + 5)
#define IDC_DISABLEDITEMS_STATIC (IDD_PREFERENCE_LANG_BOX + 6) #define IDC_DISABLEDITEMS_STATIC (IDD_PREFERENCE_LANG_BOX + 6)
#define IDC_CHECK_LANGMENUCOMPACT (IDD_PREFERENCE_LANG_BOX + 7)
#define IDD_PREFERENCE_PRINT_BOX 6600 //(IDD_PREFERENCE_BOX + 600) #define IDD_PREFERENCE_PRINT_BOX 6600 //(IDD_PREFERENCE_BOX + 600)
#define IDC_CHECK_PRINTLINENUM (IDD_PREFERENCE_PRINT_BOX + 1) #define IDC_CHECK_PRINTLINENUM (IDD_PREFERENCE_PRINT_BOX + 1)