diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-14 21:45:34 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-14 21:45:34 +0000 |
commit | 322628ed561643404f8ecb123d054bbd677288bb (patch) | |
tree | 406d2ea32e4ac5267cb7dfa8b196f44615af4aa8 /src | |
parent | 24762a4ffa51b4a392fa5aebe979df675b06335c (diff) |
minor menu cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@420 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/miranda.h | 1 | ||||
-rw-r--r-- | src/modules/clist/genmenu.cpp | 104 | ||||
-rw-r--r-- | src/modules/langpack/lpservices.cpp | 15 |
3 files changed, 54 insertions, 66 deletions
diff --git a/src/core/miranda.h b/src/core/miranda.h index 044b807fa7..3488c4ddd7 100644 --- a/src/core/miranda.h +++ b/src/core/miranda.h @@ -182,6 +182,7 @@ int LangPackGetDefaultCodePage(); int LangPackGetDefaultLocale();
TCHAR* LangPackPcharToTchar( const char* pszStr );
char* LangPackTranslateString(struct LangPackMuuid* pUuid, const char *szEnglish, const int W);
+TCHAR* LangPackTranslateStringT(int hLangpack, const TCHAR* tszEnglish);
unsigned int __fastcall hash(const void * key, unsigned int len);
diff --git a/src/modules/clist/genmenu.cpp b/src/modules/clist/genmenu.cpp index e981d8e8c7..d38f0fbfc4 100644 --- a/src/modules/clist/genmenu.cpp +++ b/src/modules/clist/genmenu.cpp @@ -774,82 +774,64 @@ static int WhereToPlace( HMENU hMenu, PMO_MenuItem mi ) static void InsertMenuItemWithSeparators(HMENU hMenu, int uItem, MENUITEMINFO *lpmii)
{
- int needSeparator = 0;
- MENUITEMINFO mii;
-
PMO_IntMenuItem pimi = MO_GetIntMenuItem(( HGENMENU )lpmii->dwItemData );
- if ( pimi == NULL )
+ if (pimi == NULL)
return;
- int thisItemPosition = pimi->mi.position;
-
- ZeroMemory( &mii, sizeof( mii ));
+ MENUITEMINFO mii = { 0 };
mii.cbSize = MENUITEMINFO_V4_SIZE;
//check for separator before
if ( uItem ) {
mii.fMask = MIIM_SUBMENU | MIIM_DATA | MIIM_TYPE;
GetMenuItemInfo( hMenu, uItem-1, TRUE, &mii );
- pimi = MO_GetIntMenuItem(( HGENMENU )mii.dwItemData );
- if ( pimi != NULL ) {
- if ( mii.fType == MFT_SEPARATOR )
- needSeparator = 0;
- else
- needSeparator = ( pimi->mi.position / SEPARATORPOSITIONINTERVAL ) != thisItemPosition / SEPARATORPOSITIONINTERVAL;
- }
- if ( needSeparator) {
- //but might be supposed to be after the next one instead
- mii.fType = 0;
- if ( uItem < GetMenuItemCount( hMenu )) {
- mii.fMask = MIIM_SUBMENU | MIIM_DATA | MIIM_TYPE;
- GetMenuItemInfo( hMenu, uItem, TRUE, &mii );
- }
- if ( mii.fType != MFT_SEPARATOR) {
- mii.fMask = MIIM_TYPE;
- mii.fType = MFT_SEPARATOR;
- InsertMenuItem( hMenu, uItem, TRUE, &mii );
- }
- uItem++;
- } }
+ PMO_IntMenuItem p = MO_GetIntMenuItem(( HGENMENU )mii.dwItemData );
+ if ( p != NULL && mii.fType != MFT_SEPARATOR) {
+ int needSeparator = (p->mi.position / SEPARATORPOSITIONINTERVAL) != (pimi->mi.position / SEPARATORPOSITIONINTERVAL);
+ if ( needSeparator) {
+ //but might be supposed to be after the next one instead
+ mii.fType = 0;
+ if ( uItem < GetMenuItemCount( hMenu )) {
+ mii.fMask = MIIM_SUBMENU | MIIM_DATA | MIIM_TYPE;
+ GetMenuItemInfo( hMenu, uItem, TRUE, &mii );
+ }
+ if ( mii.fType != MFT_SEPARATOR) {
+ mii.fMask = MIIM_TYPE;
+ mii.fType = MFT_SEPARATOR;
+ InsertMenuItem( hMenu, uItem, TRUE, &mii );
+ }
+ uItem++;
+ } } }
//check for separator after
if ( uItem < GetMenuItemCount( hMenu )) {
mii.fMask = MIIM_SUBMENU | MIIM_DATA | MIIM_TYPE;
mii.cch = 0;
GetMenuItemInfo( hMenu, uItem, TRUE, &mii );
- pimi = MO_GetIntMenuItem(( HGENMENU )mii.dwItemData );
- if ( pimi != NULL ) {
- if ( mii.fType == MFT_SEPARATOR )
- needSeparator=0;
- else
- needSeparator = pimi->mi.position / SEPARATORPOSITIONINTERVAL != thisItemPosition / SEPARATORPOSITIONINTERVAL;
- }
- if ( needSeparator) {
- mii.fMask = MIIM_TYPE;
- mii.fType = MFT_SEPARATOR;
- InsertMenuItem( hMenu, uItem, TRUE, &mii );
- } }
-
- if ( uItem == GetMenuItemCount( hMenu )-1 ) {
- TCHAR str[32];
- mii.fMask = MIIM_SUBMENU | MIIM_DATA | MIIM_TYPE;
- mii.dwTypeData = str;
- mii.cch = SIZEOF( str );
- GetMenuItemInfo( hMenu, uItem, TRUE, &mii );
- }
+ PMO_IntMenuItem p = MO_GetIntMenuItem(( HGENMENU )mii.dwItemData );
+ if ( p != NULL && mii.fType == MFT_SEPARATOR ) {
+ int needSeparator = (p->mi.position / SEPARATORPOSITIONINTERVAL) != (pimi->mi.position / SEPARATORPOSITIONINTERVAL);
+ if ( needSeparator) {
+ mii.fMask = MIIM_TYPE;
+ mii.fType = MFT_SEPARATOR;
+ InsertMenuItem( hMenu, uItem, TRUE, &mii );
+ } } }
// create local copy *lpmii so we can change some flags
- MENUITEMINFO mii_copy = *lpmii;
- lpmii = &mii_copy;
+ mii = *lpmii;
- if (( GetMenuItemCount( hMenu ) % 35 ) == 33 /* will be 34 after addition :) */ && pimi != NULL )
+ int count = GetMenuItemCount( hMenu );
+ if (count != 0 && (count % 33 ) == 0)
if ( pimi->mi.root != NULL ) {
- if ( !( lpmii->fMask & MIIM_FTYPE ))
- lpmii->fType = 0;
- lpmii->fMask |= MIIM_FTYPE;
- lpmii->fType |= MFT_MENUBARBREAK;
+ if ( !( mii.fMask & MIIM_FTYPE ))
+ mii.fType = 0;
+ mii.fMask |= MIIM_FTYPE;
+ mii.fType |= MFT_MENUBARBREAK;
}
- InsertMenuItem( hMenu, uItem, TRUE, lpmii );
+ if ( !( pimi->mi.flags & CMIF_KEEPUNTRANSLATED))
+ mii.dwTypeData = LangPackTranslateStringT(pimi->mi.hLangpack, mii.dwTypeData);
+
+ InsertMenuItem( hMenu, uItem, TRUE, &mii);
}
//wparam started hMenu
@@ -993,15 +975,15 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para pmi->hBmp = ConvertIconToBitmap(NULL, pmi->parent->m_hMenuIcons, pmi->iconId);
mii.hbmpItem = pmi->hBmp;
}
- else
- mii.hbmpItem = HBMMENU_CALLBACK;
+ else mii.hbmpItem = HBMMENU_CALLBACK;
}
}
mii.fMask |= MIIM_STATE;
mii.fState = (( pmi->mi.flags & CMIF_GRAYED ) ? MFS_GRAYED : MFS_ENABLED );
mii.fState |= (( pmi->mi.flags & CMIF_CHECKED) ? MFS_CHECKED : MFS_UNCHECKED );
- if ( pmi->mi.flags & CMIF_DEFAULT ) mii.fState |= MFS_DEFAULT;
+ if ( pmi->mi.flags & CMIF_DEFAULT )
+ mii.fState |= MFS_DEFAULT;
mii.dwTypeData = ( pmi->CustomName ) ? pmi->CustomName : mi->ptszName;
@@ -1018,9 +1000,9 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para }
#endif
- InsertMenuItemWithSeparators( hMenu, i, &mii);
+ InsertMenuItemWithSeparators(hMenu, i, &mii);
localparam.rootlevel = LPARAM( pmi );
- BuildRecursiveMenu( mii.hSubMenu, pmi->submenu.first, &localparam );
+ BuildRecursiveMenu(mii.hSubMenu, pmi->submenu.first, &localparam);
}
else {
mii.wID = pmi->iCommand;
diff --git a/src/modules/langpack/lpservices.cpp b/src/modules/langpack/lpservices.cpp index 0de43ecb6a..4cb0c597bb 100644 --- a/src/modules/langpack/lpservices.cpp +++ b/src/modules/langpack/lpservices.cpp @@ -38,18 +38,23 @@ static INT_PTR TranslateString(WPARAM wParam, LPARAM lParam) return (INT_PTR)LangPackTranslateString( LangPackLookupUuid(wParam), (const char *)lParam, (wParam & LANG_UNICODE) ? 1 : 0);
}
+TCHAR* LangPackTranslateStringT(int hLangpack, const TCHAR* tszEnglish)
+{
+ LangPackMuuid* pUuid = (hLangpack) ? LangPackLookupUuid(hLangpack) : 0;
+ return (TCHAR*)LangPackTranslateString(pUuid, (LPCSTR)tszEnglish, 1);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
static INT_PTR TranslateMenu(WPARAM wParam, LPARAM lParam)
{
- HMENU hMenu = ( HMENU )wParam;
- int i;
- MENUITEMINFO mii;
- TCHAR str[256];
+ HMENU hMenu = ( HMENU )wParam;
LangPackMuuid* uuid = LangPackLookupUuid( lParam );
+ MENUITEMINFO mii;
mii.cbSize = MENUITEMINFO_V4_SIZE;
- for ( i = GetMenuItemCount( hMenu )-1; i >= 0; i--) {
+ for (int i = GetMenuItemCount( hMenu )-1; i >= 0; i--) {
+ TCHAR str[256];
mii.fMask = MIIM_TYPE|MIIM_SUBMENU;
mii.dwTypeData = ( TCHAR* )str;
mii.cch = SIZEOF(str);
|