diff options
author | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2011-02-07 13:02:26 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-02-11 13:26:56 +0000 |
commit | 071354e24035aa359b416b17dcd53b6ae8e17f87 (patch) | |
tree | 16cca25bd513d6d702131386912782013487f4fe | |
parent | 8dd029aa89f4e980442ddc0361c8831421190823 (diff) |
Fixed size computation for toolbar menus with controls
(cherry picked from commit 8fc079ad197755ecb6191181de79fb60a6f6ae86)
Signed-off-by: Caolán McNamara <caolanm@redhat.com>
-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 1ac3b9d2c1..e86644ab5c 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 |