[Libreoffice-commits] .: svtools/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Mon Feb 7 04:04:04 PST 2011


 svtools/source/control/toolbarmenu.cxx |  111 +++++++++++++++++++--------------
 1 file changed, 67 insertions(+), 44 deletions(-)

New commits:
commit 8fc079ad197755ecb6191181de79fb60a6f6ae86
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Mon Feb 7 13:02:26 2011 +0100

    Fixed size computation for toolbar menus with controls

diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx
index e8b4141..1a11b21 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


More information about the Libreoffice-commits mailing list