assume for all menus we reserve space for checkboxes

so menus have consistent whitespace at left regardless of containing
checkboxes/radiobutton entries. Its nasty to have menus "suddenly"
appear without whitespace as submenus of ones with whitespace.

This is a logical consequence of MENU_FLAG_SHOWCHECKIMAGES always
set (in the absence of SetMenuFlags where usage has generally
dropped MENU_FLAG_SHOWCHECKIMAGES accidentally)

Change-Id: I9501381b91415131eff5143a0c88142221530fb6
This commit is contained in:
Caolán McNamara
2012-06-03 23:32:48 +01:00
parent e7e6d0f72b
commit 76f02c23ff
5 changed files with 24 additions and 57 deletions

View File

@@ -831,7 +831,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu )
nFlag &= ~MENU_FLAG_HIDEDISABLEDENTRIES;
else
nFlag |= MENU_FLAG_HIDEDISABLEDENTRIES;
pMenu->SetMenuFlags( nFlag | MENU_FLAG_SHOWCHECKIMAGES );
pMenu->SetMenuFlags( nFlag );
if ( m_bActive )
return 0;

View File

@@ -1780,9 +1780,6 @@ PopupMenu * ToolBarManager::GetToolBarCustomMenu(ToolBox* pToolBar)
if( !(pToolBar->GetFloatStyle() & WB_CLOSEABLE) )
aPopupMenu.EnableItem(MENUITEM_TOOLBAR_CLOSE, sal_False);
pItemMenu->SetMenuFlags (pItemMenu->GetMenuFlags () |
MENU_FLAG_SHOWCHECKIMAGES);
for ( nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
{
if ( m_pToolBar->GetItemType(nPos) == TOOLBOXITEM_BUTTON )
@@ -1827,9 +1824,6 @@ PopupMenu * ToolBarManager::GetToolBarCustomMenu(ToolBox* pToolBar)
// create an own submenu to avoid auto-delete when resource menu is deleted
PopupMenu *pItemMenu = new PopupMenu();
pItemMenu->SetMenuFlags (pItemMenu->GetMenuFlags () |
MENU_FLAG_SHOWCHECKIMAGES);
for( i=0; i< aPopupMenu.GetPopupMenu( 1 )->GetItemCount(); i++)
pItemMenu->CopyItem( *aPopupMenu.GetPopupMenu( 1 ), i, MENU_APPEND );

View File

@@ -1473,16 +1473,12 @@ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted )
// Image:
if( pEntry->mbHasImage && bUseImages )
{
// Don't render an image for a check thing
/* if((nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES) || !pEntry->HasCheck() )*/
{
if( pEntry->mbChecked )
ImplPaintCheckBackground( this, aOuterCheckRect, pThisOnly && bHighlighted );
aTmpPos = aOuterCheckRect.TopLeft();
aTmpPos.X() += (aOuterCheckRect.GetWidth()-pEntry->maImage.GetSizePixel().Width())/2;
aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pEntry->maImage.GetSizePixel().Height())/2;
DrawImage( aTmpPos, pEntry->maImage, nImageStyle );
}
if( pEntry->mbChecked )
ImplPaintCheckBackground( this, aOuterCheckRect, pThisOnly && bHighlighted );
aTmpPos = aOuterCheckRect.TopLeft();
aTmpPos.X() += (aOuterCheckRect.GetWidth()-pEntry->maImage.GetSizePixel().Width())/2;
aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pEntry->maImage.GetSizePixel().Height())/2;
DrawImage( aTmpPos, pEntry->maImage, nImageStyle );
}
// Text:

View File

@@ -101,9 +101,6 @@ typedef sal_uInt16 MenuItemBits;
// overrides default hiding of disabled entries in popup menus
#define MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES 0x0004
// forces images & toggle visibility for toolbar config popup
#define MENU_FLAG_SHOWCHECKIMAGES 0x0008
struct ImplMenuDelData
{
ImplMenuDelData* mpNext;

View File

@@ -959,7 +959,7 @@ void Menu::ImplInit()
{
mnHighlightedItemPos = ITEMPOS_INVALID;
mpSalMenu = NULL;
nMenuFlags = MENU_FLAG_SHOWCHECKIMAGES;
nMenuFlags = 0;
nDefaultItem = 0;
//bIsMenuBar = sal_False; // this is now set in the ctor, must not be changed here!!!
nSelectedId = 0;
@@ -2360,10 +2360,6 @@ Size Menu::ImplCalcSize( Window* pWin )
if( aMaxSize.Height() > nMinMenuItemHeight )
nMinMenuItemHeight = aMaxSize.Height();
// When no native rendering of the checkbox & no image in the menu, we
// have to add some extra space even in the MENU_FLAG_SHOWCHECKIMAGES case
bool bSpaceForCheckbox = ( aMaxSize.Height() == 0 );
Size aMaxImgSz;
const StyleSettings& rSettings = pWin->GetSettings().GetStyleSettings();
@@ -2379,9 +2375,6 @@ Size Menu::ImplCalcSize( Window* pWin )
)
)
{
// we have an icon, don't add the extra space
bSpaceForCheckbox = false;
Size aImgSz = pData->aImage.GetSizePixel();
if ( aImgSz.Height() > aMaxImgSz.Height() )
aMaxImgSz.Height() = aImgSz.Height();
@@ -2432,12 +2425,9 @@ Size Menu::ImplCalcSize( Window* pWin )
if ( !bIsMenuBar && pData->HasCheck() )
{
nCheckWidth = aMaxSize.Width();
if ( ( nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES ) || bSpaceForCheckbox )
{
// checks / images take the same place
if( ! ( ( pData->eType == MENUITEM_IMAGE ) || ( pData->eType == MENUITEM_STRINGIMAGE ) ) )
nWidth += nCheckWidth + nExtra * 2;
}
// checks / images take the same place
if( ! ( ( pData->eType == MENUITEM_IMAGE ) || ( pData->eType == MENUITEM_STRINGIMAGE ) ) )
nWidth += nCheckWidth + nExtra * 2;
}
// Text:
@@ -2503,20 +2493,13 @@ Size Menu::ImplCalcSize( Window* pWin )
sal_uInt16 gfxExtra = (sal_uInt16) Max( nExtra, 7L ); // #107710# increase space between checkmarks/images/text
nImgOrChkPos = (sal_uInt16)nExtra;
if ( ( nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES ) || bSpaceForCheckbox )
{
long nImgOrChkWidth = 0;
if( aMaxSize.Height() > 0 ) // NWF case
nImgOrChkWidth = aMaxSize.Height() + nExtra;
else // non NWF case
nImgOrChkWidth = nFontHeight/2 + gfxExtra;
nImgOrChkWidth = Max( nImgOrChkWidth, aMaxImgSz.Width() + gfxExtra );
nTextPos = (sal_uInt16)(nImgOrChkPos + nImgOrChkWidth);
}
else
{
nTextPos = (sal_uInt16)(nImgOrChkPos + Max( aMaxImgSz.Width(), nCheckWidth ));
}
long nImgOrChkWidth = 0;
if( aMaxSize.Height() > 0 ) // NWF case
nImgOrChkWidth = aMaxSize.Height() + nExtra;
else // non NWF case
nImgOrChkWidth = nFontHeight/2 + gfxExtra;
nImgOrChkWidth = Max( nImgOrChkWidth, aMaxImgSz.Width() + gfxExtra );
nTextPos = (sal_uInt16)(nImgOrChkPos + nImgOrChkWidth);
nTextPos = nTextPos + gfxExtra;
aSz.Width() = nTextPos + nMaxWidth + nExtra;
@@ -2811,15 +2794,12 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa
if ( !bLayout && !bIsMenuBar && ( ( pData->eType == MENUITEM_IMAGE ) || ( pData->eType == MENUITEM_STRINGIMAGE ) ) )
{
// Don't render an image for a check thing
if ((nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES) || !pData->HasCheck() )
{
if( pData->bChecked )
ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted );
aTmpPos = aOuterCheckRect.TopLeft();
aTmpPos.X() += (aOuterCheckRect.GetWidth()-pData->aImage.GetSizePixel().Width())/2;
aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pData->aImage.GetSizePixel().Height())/2;
pWin->DrawImage( aTmpPos, pData->aImage, nImageStyle );
}
if( pData->bChecked )
ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted );
aTmpPos = aOuterCheckRect.TopLeft();
aTmpPos.X() += (aOuterCheckRect.GetWidth()-pData->aImage.GetSizePixel().Width())/2;
aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pData->aImage.GetSizePixel().Height())/2;
pWin->DrawImage( aTmpPos, pData->aImage, nImageStyle );
}
// Text: