diff options
author | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2011-02-07 13:02:26 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2011-02-07 13:03:46 +0100 |
commit | 8bf38998ec5892ae82cee340caa6c06715c4aa7d (patch) | |
tree | 478b363e284782f35728a88784d6d1195758862d /svtools/source | |
parent | 320062961251d581407eb6b5171e3ce75e48ab66 (diff) |
Fixed size computation for toolbar menus with controls
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/control/toolbarmenu.cxx | 111 |
1 files changed, 67 insertions, 44 deletions
diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx index 0b4a4d318adc..f0f7c3e20e84 100644 --- a/svtools/source/control/toolbarmenu.cxx +++ b/svtools/source/control/toolbarmenu.cxx @@ -653,6 +653,51 @@ void ToolbarMenu::initWindow() // -------------------------------------------------------------------- +static long ImplGetNativeCheckAndRadioSize( Window* pWin, long& rCheckHeight, long& rRadioHeight, long &rMaxWidth ) +{ + rMaxWidth = rCheckHeight = rRadioHeight = 0; + + ImplControlValue aVal; + Rectangle aNativeBounds; + Rectangle aNativeContent; + Point tmp( 0, 0 ); + Rectangle aCtrlRegion( tmp, Size( 100, 15 ) ); + if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK ) ) + { + if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), + ControlPart(PART_MENU_ITEM_CHECK_MARK), + aCtrlRegion, + ControlState(CTRL_STATE_ENABLED), + aVal, + OUString(), + aNativeBounds, + aNativeContent ) + ) + { + rCheckHeight = aNativeBounds.GetHeight(); + rMaxWidth = aNativeContent.GetWidth(); + } + } + if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK ) ) + { + if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), + ControlPart(PART_MENU_ITEM_RADIO_MARK), + aCtrlRegion, + ControlState(CTRL_STATE_ENABLED), + aVal, + OUString(), + aNativeBounds, + aNativeContent ) + ) + { + rRadioHeight = aNativeBounds.GetHeight(); + rMaxWidth = Max (rMaxWidth, aNativeContent.GetWidth()); + } + } + return (rCheckHeight > rRadioHeight) ? rCheckHeight : rRadioHeight; +} + + Size ToolbarMenu::implCalcSize() { const long nFontHeight = GetTextHeight(); @@ -724,6 +769,28 @@ Size ToolbarMenu::implCalcSize() pEntry->maSize.Height() = aControlSize.Height() + 1; } + if( pEntry->HasCheck() && !pEntry->mbHasImage ) + { + if( this->IsNativeControlSupported( CTRL_MENU_POPUP, + (pEntry->mnBits & MIB_RADIOCHECK) + ? PART_MENU_ITEM_CHECK_MARK + : PART_MENU_ITEM_RADIO_MARK ) ) + { + long nCheckHeight = 0, nRadioHeight = 0, nMaxCheckWidth = 0; + ImplGetNativeCheckAndRadioSize( this, nCheckHeight, nRadioHeight, nMaxCheckWidth ); + + long nCtrlHeight = (pEntry->mnBits & MIB_RADIOCHECK) ? nCheckHeight : nRadioHeight; + nMaxTextWidth += nCtrlHeight + 1; + } + else if( pEntry->mbChecked ) + { + long nSymbolWidth = (nFontHeight*25)/40; + if ( pEntry->mnBits & MIB_RADIOCHECK ) + nSymbolWidth = nFontHeight/2; + + nMaxTextWidth += nSymbolWidth; + } + } } } @@ -1330,50 +1397,6 @@ static void ImplPaintCheckBackground( Window* i_pWindow, const Rectangle& i_rRec } } -static long ImplGetNativeCheckAndRadioSize( Window* pWin, long& rCheckHeight, long& rRadioHeight, long &rMaxWidth ) -{ - rMaxWidth = rCheckHeight = rRadioHeight = 0; - - ImplControlValue aVal; - Rectangle aNativeBounds; - Rectangle aNativeContent; - Point tmp( 0, 0 ); - Rectangle aCtrlRegion( tmp, Size( 100, 15 ) ); - if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK ) ) - { - if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), - ControlPart(PART_MENU_ITEM_CHECK_MARK), - aCtrlRegion, - ControlState(CTRL_STATE_ENABLED), - aVal, - OUString(), - aNativeBounds, - aNativeContent ) - ) - { - rCheckHeight = aNativeBounds.GetHeight(); - rMaxWidth = aNativeContent.GetWidth(); - } - } - if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK ) ) - { - if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), - ControlPart(PART_MENU_ITEM_RADIO_MARK), - aCtrlRegion, - ControlState(CTRL_STATE_ENABLED), - aVal, - OUString(), - aNativeBounds, - aNativeContent ) - ) - { - rRadioHeight = aNativeBounds.GetHeight(); - rMaxWidth = Max (rMaxWidth, aNativeContent.GetWidth()); - } - } - return (rCheckHeight > rRadioHeight) ? rCheckHeight : rRadioHeight; -} - void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted ) { USHORT nBorder = 0; long nStartY = 0; // from Menu implementations, needed when we support native menu background & scrollable menu |