[Libreoffice-commits] core.git: include/vcl sc/source svtools/source vcl/source

Noel Grandin noel at peralex.com
Mon May 11 23:15:07 PDT 2015


 include/vcl/decoview.hxx                 |   15 ++++++++++++---
 sc/source/ui/cctrl/checklistmenu.cxx     |    2 +-
 svtools/source/control/toolbarmenu.cxx   |    4 ++--
 vcl/source/control/button.cxx            |    6 +++---
 vcl/source/control/scrbar.cxx            |   12 ++++++------
 vcl/source/control/spinfld.cxx           |   18 +++++++++---------
 vcl/source/window/brdwin.cxx             |    2 +-
 vcl/source/window/decoview.cxx           |   10 +++++-----
 vcl/source/window/menu.cxx               |    4 ++--
 vcl/source/window/menufloatingwindow.cxx |    4 ++--
 10 files changed, 43 insertions(+), 34 deletions(-)

New commits:
commit 4c665178f49952138835fd318edef8978ac806e3
Author: Noel Grandin <noel at peralex.com>
Date:   Fri May 8 15:21:46 2015 +0200

    convert SYMBOL_DRAW constants to scoped enum
    
    Change-Id: I1a2200782941b1c7b826fd9fb03193e009cce697
    Reviewed-on: https://gerrit.libreoffice.org/15676
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/include/vcl/decoview.hxx b/include/vcl/decoview.hxx
index 2de96a5..ef54996 100644
--- a/include/vcl/decoview.hxx
+++ b/include/vcl/decoview.hxx
@@ -23,6 +23,7 @@
 #include <vcl/dllapi.h>
 #include <vcl/vclptr.hxx>
 #include <rsc/rsc-vcl-shared-types.hxx>
+#include <o3tl/typed_flags_set.hxx>
 
 class Rectangle;
 class Point;
@@ -30,8 +31,16 @@ class Color;
 class OutputDevice;
 
 // Flags for DrawSymbol()
-#define SYMBOL_DRAW_MONO                    ((sal_uInt16)0x0001)
-#define SYMBOL_DRAW_DISABLE                 ((sal_uInt16)0x0002)
+enum class DrawSymbolFlags
+{
+    NONE                    = 0x0000,
+    Mono                    = 0x0001,
+    Disable                 = 0x0002,
+};
+namespace o3tl
+{
+    template<> struct typed_flags<DrawSymbolFlags> : is_typed_flags<DrawSymbolFlags, 0x03> {};
+}
 
 // Flags for DrawFrame()
 #define FRAME_DRAW_IN                       ((sal_uInt16)0x0001)
@@ -77,7 +86,7 @@ public:
     DecorationView(OutputDevice* pOutDev);
 
     void                DrawSymbol( const Rectangle& rRect, SymbolType eType,
-                                    const Color& rColor, sal_uInt16 nStyle = 0 );
+                                    const Color& rColor, DrawSymbolFlags nStyle = DrawSymbolFlags::NONE );
     void                DrawFrame( const Rectangle& rRect,
                                    const Color& rLeftTopColor,
                                    const Color& rRightBottomColor );
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index bbd90b1..6944b3b 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -372,7 +372,7 @@ void ScMenuFloatingWindow::drawMenuItem(size_t nPos)
         aMarkerPos.X() += aSize.Width() - nFontHeight + nFontHeight/4;
         Size aMarkerSize(nFontHeight/2, nFontHeight/2);
         aDecoView.DrawSymbol(Rectangle(aMarkerPos, aMarkerSize),
-                             SymbolType::SPIN_RIGHT, GetTextColor(), 0);
+                             SymbolType::SPIN_RIGHT, GetTextColor());
     }
 }
 
diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx
index adc60bb..fe1500c 100644
--- a/svtools/source/control/toolbarmenu.cxx
+++ b/svtools/source/control/toolbarmenu.cxx
@@ -1355,13 +1355,13 @@ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted )
                 long nTextOffsetY = ((pEntry->maSize.Height()-nFontHeight)/2);
 
                 sal_uInt16  nTextStyle   = 0;
-                sal_uInt16  nSymbolStyle = 0;
+                DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
                 sal_uInt16  nImageStyle  = 0;
 
                 if( !pEntry->mbEnabled )
                 {
                     nTextStyle   |= TEXT_DRAW_DISABLE;
-                    nSymbolStyle |= SYMBOL_DRAW_DISABLE;
+                    nSymbolStyle |= DrawSymbolFlags::Disable;
                     nImageStyle  |= IMAGE_DRAW_DISABLE;
                 }
 
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index b036aee..659b25f 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -805,7 +805,7 @@ void PushButton::ImplDrawPushButtonContent(OutputDevice* pDev, sal_uLong nDrawFl
     Color                   aColor;
     OUString                aText = PushButton::GetText(); // PushButton:: because of MoreButton
     sal_uInt16              nTextStyle = ImplGetTextStyle( nDrawFlags );
-    sal_uInt16              nStyle;
+    DrawSymbolFlags         nStyle;
 
     if( aInRect.Right() < aInRect.Left() || aInRect.Bottom() < aInRect.Top() )
         aInRect.SetEmpty();
@@ -827,9 +827,9 @@ void PushButton::ImplDrawPushButtonContent(OutputDevice* pDev, sal_uLong nDrawFl
     pDev->SetTextColor( aColor );
 
     if ( IsEnabled() || (nDrawFlags & WINDOW_DRAW_NODISABLE) )
-        nStyle = 0;
+        nStyle = DrawSymbolFlags::NONE;
     else
-        nStyle = SYMBOL_DRAW_DISABLE;
+        nStyle = DrawSymbolFlags::Disable;
 
     Size aSize = rRect.GetSize();
     Point aPos = rRect.TopLeft();
diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx
index b5baa3e..912e17c 100644
--- a/vcl/source/control/scrbar.cxx
+++ b/vcl/source/control/scrbar.cxx
@@ -658,9 +658,9 @@ void ScrollBar::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFla
             nStyle |= BUTTON_DRAW_PRESSED;
         aTempRect = aDecoView.DrawButton( maBtn1Rect, nStyle );
         ImplCalcSymbolRect( aTempRect );
-        nStyle = 0;
+        DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
         if ((mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) || !bEnabled)
-            nStyle |= SYMBOL_DRAW_DISABLE;
+            nSymbolStyle |= DrawSymbolFlags::Disable;
         if (rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW)
         {
             if (GetStyle() & WB_HORZ)
@@ -675,7 +675,7 @@ void ScrollBar::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFla
             else
                 eSymbolType = SymbolType::SPIN_UP;
         }
-        aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle);
+        aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nSymbolStyle);
     }
 
     if ((nDrawFlags & SCRBAR_DRAW_BTN2) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_BTN2)))
@@ -685,9 +685,9 @@ void ScrollBar::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFla
             nStyle |= BUTTON_DRAW_PRESSED;
         aTempRect = aDecoView.DrawButton(maBtn2Rect, nStyle);
         ImplCalcSymbolRect(aTempRect);
-        nStyle = 0;
+        DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
         if ((mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) || !bEnabled)
-            nStyle |= SYMBOL_DRAW_DISABLE;
+            nSymbolStyle |= DrawSymbolFlags::Disable;
         if (rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW)
         {
             if (GetStyle() & WB_HORZ)
@@ -702,7 +702,7 @@ void ScrollBar::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFla
             else
                 eSymbolType = SymbolType::SPIN_DOWN;
         }
-        aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle);
+        aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nSymbolStyle);
     }
 
     rRenderContext.SetLineColor();
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index 450f51d..6ba5d91 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -144,7 +144,7 @@ void ImplDrawSpinButton(vcl::RenderContext& rRenderContext, vcl::Window* pWindow
     DecorationView aDecoView(&rRenderContext);
 
     sal_uInt16 nStyle = BUTTON_DRAW_NOLEFTLIGHTBORDER;
-    sal_uInt16 nSymStyle = 0;
+    DrawSymbolFlags nSymStyle = DrawSymbolFlags::NONE;
 
     SymbolType eType1, eType2;
 
@@ -268,14 +268,14 @@ void ImplDrawSpinButton(vcl::RenderContext& rRenderContext, vcl::Window* pWindow
             aLowRect.Top()++;
     }
 
-    nTempStyle = nSymStyle;
+    DrawSymbolFlags nTempSymStyle = nSymStyle;
     if (!bUpperEnabled)
-        nTempStyle |= SYMBOL_DRAW_DISABLE;
+        nTempSymStyle |= DrawSymbolFlags::Disable;
     if (!bNativeOK)
-        aDecoView.DrawSymbol(aUpRect, eType1, rStyleSettings.GetButtonTextColor(), nTempStyle);
+        aDecoView.DrawSymbol(aUpRect, eType1, rStyleSettings.GetButtonTextColor(), nTempSymStyle);
 
     if (!bLowerEnabled)
-        nSymStyle |= SYMBOL_DRAW_DISABLE;
+        nSymStyle |= DrawSymbolFlags::Disable;
     if (!bNativeOK)
         aDecoView.DrawSymbol(aLowRect, eType2, rStyleSettings.GetButtonTextColor(), nSymStyle);
 }
@@ -622,8 +622,8 @@ void SpinField::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRec
         if (rRenderContext.GetSettings().GetStyleSettings().GetOptions() & STYLE_OPTION_SPINUPDOWN)
             eSymbol = SymbolType::SPIN_UPDOWN;
 
-        nStyle = IsEnabled() ? 0 : SYMBOL_DRAW_DISABLE;
-        aView.DrawSymbol(aInnerRect, eSymbol, rRenderContext.GetSettings().GetStyleSettings().GetButtonTextColor(), nStyle);
+        DrawSymbolFlags nSymbolStyle = IsEnabled() ? DrawSymbolFlags::NONE : DrawSymbolFlags::Disable;
+        aView.DrawSymbol(aInnerRect, eSymbol, rRenderContext.GetSettings().GetStyleSettings().GetButtonTextColor(), nSymbolStyle);
     }
 
     Edit::Paint(rRenderContext, rRect);
@@ -1029,8 +1029,8 @@ void SpinField::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
             if ( GetSettings().GetStyleSettings().GetOptions() & STYLE_OPTION_SPINUPDOWN )
                 eSymbol = SymbolType::SPIN_UPDOWN;
 
-            nStyle = ( IsEnabled() || ( nFlags & WINDOW_DRAW_NODISABLE ) ) ? 0 : SYMBOL_DRAW_DISABLE;
-            aView.DrawSymbol( aInnerRect, eSymbol, aButtonTextColor, nStyle );
+            DrawSymbolFlags nSymbolStyle = ( IsEnabled() || ( nFlags & WINDOW_DRAW_NODISABLE ) ) ? DrawSymbolFlags::NONE : DrawSymbolFlags::Disable;
+            aView.DrawSymbol( aInnerRect, eSymbol, aButtonTextColor, nSymbolStyle );
         }
 
         if ( GetStyle() & WB_SPIN )
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index 1bf2ac8..90995cb 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -107,7 +107,7 @@ static void ImplDrawBrdWinSymbol( vcl::RenderContext* pDev,
     Rectangle       aTempRect = rRect;
     vcl::Window::ImplCalcSymbolRect( aTempRect );
     aDecoView.DrawSymbol( aTempRect, eSymbol,
-                          pDev->GetSettings().GetStyleSettings().GetButtonTextColor(), 0 );
+                          pDev->GetSettings().GetStyleSettings().GetButtonTextColor() );
 }
 
 static void ImplDrawBrdWinSymbolButton( vcl::RenderContext* pDev,
diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx
index 5bb7b79..1be0a5d 100644
--- a/vcl/source/window/decoview.cxx
+++ b/vcl/source/window/decoview.cxx
@@ -831,7 +831,7 @@ DecorationView::DecorationView(OutputDevice* pOutDev) :
 {}
 
 void DecorationView::DrawSymbol( const Rectangle& rRect, SymbolType eType,
-                                 const Color& rColor, sal_uInt16 nStyle )
+                                 const Color& rColor, DrawSymbolFlags nStyle )
 {
     const StyleSettings&    rStyleSettings  = mpOutDev->GetSettings().GetStyleSettings();
     const Rectangle         aRect           = mpOutDev->LogicToPixel( rRect );
@@ -843,16 +843,16 @@ void DecorationView::DrawSymbol( const Rectangle& rRect, SymbolType eType,
 
     if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ||
          (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) )
-        nStyle |= BUTTON_DRAW_MONO;
+        nStyle |= DrawSymbolFlags::Mono;
 
-    if ( nStyle & SYMBOL_DRAW_MONO )
+    if ( nStyle & DrawSymbolFlags::Mono )
     {
         // Monochrome: set color to black if enabled, to gray if disabled
-        nColor = Color( ( nStyle & SYMBOL_DRAW_DISABLE ) ? COL_GRAY : COL_BLACK );
+        nColor = Color( ( nStyle & DrawSymbolFlags::Disable ) ? COL_GRAY : COL_BLACK );
     }
     else
     {
-        if ( nStyle & SYMBOL_DRAW_DISABLE )
+        if ( nStyle & DrawSymbolFlags::Disable )
         {
             // Draw shifted and brighter symbol for embossed look
             mpOutDev->SetLineColor( rStyleSettings.GetLightColor() );
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 8a40d84..b8e9c98 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1809,7 +1809,7 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
                 if (IsMenuBar())
                     nTextOffsetY += (aOutSz.Height()-pData->aSz.Height()) / 2;
                 sal_uInt16  nTextStyle   = 0;
-                sal_uInt16  nSymbolStyle = 0;
+                DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
                 sal_uInt16  nImageStyle  = 0;
 
                 // submenus without items are not disabled when no items are
@@ -1819,7 +1819,7 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
                 if ( !pData->bEnabled )
                 {
                     nTextStyle   |= TEXT_DRAW_DISABLE;
-                    nSymbolStyle |= SYMBOL_DRAW_DISABLE;
+                    nSymbolStyle |= DrawSymbolFlags::Disable;
                     nImageStyle  |= IMAGE_DRAW_DISABLE;
                 }
 
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index bf7c255..f934010 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -1127,9 +1127,9 @@ void MenuFloatingWindow::ImplDrawScroller( bool bUp )
     DecorationView aDecoView( this );
     SymbolType eSymbol = bUp ? SymbolType::SPIN_UP : SymbolType::SPIN_DOWN;
 
-    sal_uInt16 nStyle = 0;
+    DrawSymbolFlags nStyle = DrawSymbolFlags::NONE;
     if ( ( bUp && !bScrollUp ) || ( !bUp && !bScrollDown ) )
-        nStyle |= SYMBOL_DRAW_DISABLE;
+        nStyle |= DrawSymbolFlags::Disable;
 
     aDecoView.DrawSymbol( aRect, eSymbol, GetSettings().GetStyleSettings().GetButtonTextColor(), nStyle );
 


More information about the Libreoffice-commits mailing list