[Libreoffice-commits] core.git: vcl/inc vcl/source

Noel Grandin noel at peralex.com
Wed May 11 06:52:44 UTC 2016


 vcl/inc/brdwin.hxx             |   22 ++++++++++++++--------
 vcl/source/window/brdwin.cxx   |   30 +++++++++++++++---------------
 vcl/source/window/floatwin.cxx |   10 +++++-----
 3 files changed, 34 insertions(+), 28 deletions(-)

New commits:
commit 36028d9010b697ac97da2acc0fa21610ea8731b0
Author: Noel Grandin <noel at peralex.com>
Date:   Tue May 10 13:02:36 2016 +0200

    Convert BORDERWINDOW_TITLE to scoped enum
    
    Change-Id: I9e3088c4ba51010a013f5bbaa2bb545ffa11409b
    Reviewed-on: https://gerrit.libreoffice.org/24836
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/vcl/inc/brdwin.hxx b/vcl/inc/brdwin.hxx
index 72c9935..2a00923 100644
--- a/vcl/inc/brdwin.hxx
+++ b/vcl/inc/brdwin.hxx
@@ -22,6 +22,7 @@
 
 #include <vcl/notebookbar.hxx>
 #include <vcl/window.hxx>
+#include <o3tl/typed_flags_set.hxx>
 
 #include <com/sun/star/frame/XFrame.hpp>
 
@@ -72,11 +73,16 @@ enum class DrawButtonFlags;
                                              BORDERWINDOW_DRAW_PIN  |       \
                                              BORDERWINDOW_DRAW_MENU)
 
-#define BORDERWINDOW_TITLE_NORMAL           ((sal_uInt16)0x0001)
-#define BORDERWINDOW_TITLE_SMALL            ((sal_uInt16)0x0002)
-#define BORDERWINDOW_TITLE_TEAROFF          ((sal_uInt16)0x0004)
-#define BORDERWINDOW_TITLE_POPUP            ((sal_uInt16)0x0008)
-#define BORDERWINDOW_TITLE_NONE             ((sal_uInt16)0x0010)
+enum class BorderWindowTitleType {
+    Normal           = 0x0001,
+    Small            = 0x0002,
+    Tearoff          = 0x0004,
+    Popup            = 0x0008,
+    NONE             = 0x0010
+};
+namespace o3tl {
+    template<> struct typed_flags<BorderWindowTitleType> : is_typed_flags<BorderWindowTitleType, 0x001f> {};
+};
 
 class ImplBorderWindow : public vcl::Window
 {
@@ -95,7 +101,7 @@ private:
     long                    mnMaxHeight;
     long                    mnRollHeight;
     long                    mnOrgMenuHeight;
-    sal_uInt16              mnTitleType;
+    BorderWindowTitleType   mnTitleType;
     WindowBorderStyle       mnBorderStyle;
     bool                    mbFloatWindow;
     bool                    mbSmallOutBorder;
@@ -148,7 +154,7 @@ public:
     void                    Draw( const Rectangle& rRect, OutputDevice* pDev, const Point& rPos );
 
     void                    SetDisplayActive( bool bActive );
-    void                    SetTitleType( sal_uInt16 nTitleType, const Size& rSize );
+    void                    SetTitleType( BorderWindowTitleType nTitleType, const Size& rSize );
     void                    SetBorderStyle( WindowBorderStyle nStyle );
     WindowBorderStyle       GetBorderStyle() const { return mnBorderStyle; }
     void                    SetPin( bool bPin );
@@ -213,7 +219,7 @@ struct ImplBorderFrameData
     DrawButtonFlags          mnMenuState;
     DrawButtonFlags          mnHideState;
     DrawButtonFlags          mnHelpState;
-    sal_uInt16               mnTitleType;
+    BorderWindowTitleType    mnTitleType;
     bool                     mbFloatWindow;
     bool                     mbDragFull;
     bool                     mbTitleClipped;
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index 6dee935..6a4fa7c 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -180,24 +180,24 @@ void ImplBorderWindowView::ImplInitTitle(ImplBorderFrameData* pData)
     ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
 
     if ( !(pBorderWindow->GetStyle() & (WB_MOVEABLE | WB_POPUP)) ||
-          (pData->mnTitleType == BORDERWINDOW_TITLE_NONE) )
+          (pData->mnTitleType == BorderWindowTitleType::NONE) )
     {
-        pData->mnTitleType   = BORDERWINDOW_TITLE_NONE;
+        pData->mnTitleType   = BorderWindowTitleType::NONE;
         pData->mnTitleHeight = 0;
     }
     else
     {
         const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings();
-        if (pData->mnTitleType == BORDERWINDOW_TITLE_TEAROFF)
+        if (pData->mnTitleType == BorderWindowTitleType::Tearoff)
             pData->mnTitleHeight = rStyleSettings.GetTearOffTitleHeight();
         else
         {
-            if (pData->mnTitleType == BORDERWINDOW_TITLE_SMALL)
+            if (pData->mnTitleType == BorderWindowTitleType::Small)
             {
                 pBorderWindow->SetPointFont(*pBorderWindow, rStyleSettings.GetFloatTitleFont() );
                 pData->mnTitleHeight = rStyleSettings.GetFloatTitleHeight();
             }
-            else // pData->mnTitleType == BORDERWINDOW_TITLE_NORMAL
+            else // pData->mnTitleType == BorderWindowTitleType::Normal
             {
                 // FIXME RenderContext
                 pBorderWindow->SetPointFont(*pBorderWindow, rStyleSettings.GetTitleFont());
@@ -1397,9 +1397,9 @@ void ImplStdBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHeigh
     pData->mnTitleType      = pBorderWindow->mnTitleType;
     pData->mbFloatWindow    = pBorderWindow->mbFloatWindow;
 
-    if ( !(pBorderWindow->GetStyle() & (WB_MOVEABLE | WB_POPUP)) || (pData->mnTitleType == BORDERWINDOW_TITLE_NONE) )
+    if ( !(pBorderWindow->GetStyle() & (WB_MOVEABLE | WB_POPUP)) || (pData->mnTitleType == BorderWindowTitleType::NONE) )
         pData->mnBorderSize = 0;
-    else if ( pData->mnTitleType == BORDERWINDOW_TITLE_TEAROFF )
+    else if ( pData->mnTitleType == BorderWindowTitleType::Tearoff )
         pData->mnBorderSize = 0;
     else
         pData->mnBorderSize = rStyleSettings.GetBorderSize();
@@ -1429,7 +1429,7 @@ void ImplStdBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHeigh
         pData->maTitleRect.Top()     = pData->mnTopBorder;
         pData->maTitleRect.Bottom()  = pData->maTitleRect.Top()+pData->mnTitleHeight-1;
 
-        if ( pData->mnTitleType & (BORDERWINDOW_TITLE_NORMAL | BORDERWINDOW_TITLE_SMALL) )
+        if ( pData->mnTitleType & (BorderWindowTitleType::Normal | BorderWindowTitleType::Small) )
         {
             long nLeft          = pData->maTitleRect.Left() + 1;
             long nRight         = pData->maTitleRect.Right() - 3;
@@ -1546,7 +1546,7 @@ void ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, sal
         vcl::Region oldClipRgn(rRenderContext.GetClipRegion());
 
         // for popups, don't draw part of the frame
-        if (pData->mnTitleType == BORDERWINDOW_TITLE_POPUP)
+        if (pData->mnTitleType == BorderWindowTitleType::Popup)
         {
             FloatingWindow* pWin = dynamic_cast<FloatingWindow*>(pData->mpBorderWindow->GetWindow(GetWindowType::Client));
             if (pWin)
@@ -1572,7 +1572,7 @@ void ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, sal
         --aInRect.Bottom();
 
         // restore
-        if (pData->mnTitleType == BORDERWINDOW_TITLE_POPUP)
+        if (pData->mnTitleType == BorderWindowTitleType::Popup)
             rRenderContext.SetClipRegion(oldClipRgn);
     }
     else
@@ -1600,7 +1600,7 @@ void ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, sal
         aInRect = pData->maTitleRect;
 
         // use no gradient anymore, just a static titlecolor
-        if (pData->mnTitleType != BORDERWINDOW_TITLE_POPUP)
+        if (pData->mnTitleType != BorderWindowTitleType::Popup)
             rRenderContext.SetFillColor(aFrameColor);
         else
             rRenderContext.SetFillColor(aFaceColor);
@@ -1611,7 +1611,7 @@ void ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, sal
             aTitleRect.Move(pOffset->X(), pOffset->Y());
         rRenderContext.DrawRect(aTitleRect);
 
-        if (pData->mnTitleType != BORDERWINDOW_TITLE_TEAROFF)
+        if (pData->mnTitleType != BorderWindowTitleType::Tearoff)
         {
             aInRect.Left()  += 2;
             aInRect.Right() -= 2;
@@ -1800,9 +1800,9 @@ void ImplBorderWindow::ImplInit( vcl::Window* pParent,
     mbDisplayActive = IsActive();
 
     if ( nTypeStyle & BORDERWINDOW_STYLE_FLOAT )
-        mnTitleType = BORDERWINDOW_TITLE_SMALL;
+        mnTitleType = BorderWindowTitleType::Small;
     else
-        mnTitleType = BORDERWINDOW_TITLE_NORMAL;
+        mnTitleType = BorderWindowTitleType::Normal;
     mnBorderStyle   = WindowBorderStyle::NORMAL;
     InitView();
 }
@@ -2096,7 +2096,7 @@ void ImplBorderWindow::SetDisplayActive( bool bActive )
     }
 }
 
-void ImplBorderWindow::SetTitleType( sal_uInt16 nTitleType, const Size& rSize )
+void ImplBorderWindow::SetTitleType( BorderWindowTitleType nTitleType, const Size& rSize )
 {
     mnTitleType = nTitleType;
     UpdateView( false, rSize );
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index f3b8e2b..1a6107b 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -648,15 +648,15 @@ void FloatingWindow::SetTitleType( FloatWinTitleType nTitle )
     {
         mnTitle = nTitle;
         Size aOutSize = GetOutputSizePixel();
-        sal_uInt16 nTitleStyle;
+        BorderWindowTitleType nTitleStyle;
         if ( nTitle == FloatWinTitleType::Normal )
-            nTitleStyle = BORDERWINDOW_TITLE_SMALL;
+            nTitleStyle = BorderWindowTitleType::Small;
         else if ( nTitle == FloatWinTitleType::TearOff )
-            nTitleStyle = BORDERWINDOW_TITLE_TEAROFF;
+            nTitleStyle = BorderWindowTitleType::Tearoff;
         else if ( nTitle == FloatWinTitleType::Popup )
-            nTitleStyle = BORDERWINDOW_TITLE_POPUP;
+            nTitleStyle = BorderWindowTitleType::Popup;
         else // nTitle == FloatWinTitleType::NONE
-            nTitleStyle = BORDERWINDOW_TITLE_NONE;
+            nTitleStyle = BorderWindowTitleType::NONE;
         static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetTitleType( nTitleStyle, aOutSize );
         static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
     }


More information about the Libreoffice-commits mailing list