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

Noel Grandin noel at peralex.com
Wed May 20 23:41:08 PDT 2015


 include/vcl/salnativewidgets.hxx         |   30 +++++++++++++++++++-----------
 svtools/source/toolpanel/paneltabbar.cxx |    4 ++--
 vcl/osx/salnativewidgets.cxx             |   16 ++++++++--------
 vcl/source/control/tabctrl.cxx           |    8 ++++----
 4 files changed, 33 insertions(+), 25 deletions(-)

New commits:
commit ebdba869de1de51b4cc7ca24c1a6a639d44de1bf
Author: Noel Grandin <noel at peralex.com>
Date:   Wed May 20 13:29:57 2015 +0200

    convert TABITEM constants to scoped enum
    
    Change-Id: Ia16127a7d97ef7db59bd2b0e6b8d14d8625bc526
    Reviewed-on: https://gerrit.libreoffice.org/15827
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/include/vcl/salnativewidgets.hxx b/include/vcl/salnativewidgets.hxx
index 6cab0ba..5b0bda7 100644
--- a/include/vcl/salnativewidgets.hxx
+++ b/include/vcl/salnativewidgets.hxx
@@ -361,32 +361,40 @@ class VCL_DLLPUBLIC SliderValue : public ImplControlValue
  */
 
 /* TABITEM constants are OR-ed together */
-#define TABITEM_LEFTALIGNED    0x001   // the tabitem is aligned with the left  border of the TabControl
-#define TABITEM_RIGHTALIGNED   0x002   // the tabitem is aligned with the right border of the TabControl
-#define TABITEM_FIRST_IN_GROUP 0x004   // the tabitem is the first in group of tabitems
-#define TABITEM_LAST_IN_GROUP  0x008   // the tabitem is the last in group of tabitems
+enum class TabitemFlags
+{
+    NONE           = 0x00,
+    LeftAligned    = 0x01,   // the tabitem is aligned with the left  border of the TabControl
+    RightAligned   = 0x02,   // the tabitem is aligned with the right border of the TabControl
+    FirstInGroup   = 0x04,   // the tabitem is the first in group of tabitems
+    LastInGroup    = 0x08,   // the tabitem is the last in group of tabitems
+};
+namespace o3tl
+{
+    template<> struct typed_flags<TabitemFlags> : is_typed_flags<TabitemFlags, 0x0f> {};
+}
 
 class VCL_DLLPUBLIC TabitemValue : public ImplControlValue
 {
     public:
-        unsigned int    mnAlignment;
+        TabitemFlags    mnAlignment;
         Rectangle       maContentRect;
 
         TabitemValue(const Rectangle &rContentRect)
             : ImplControlValue( CTRL_TAB_ITEM, BUTTONVALUE_DONTKNOW, 0 )
-            , mnAlignment(0)
+            , mnAlignment(TabitemFlags::NONE)
             , maContentRect(rContentRect)
         {
         }
         virtual ~TabitemValue();
         virtual TabitemValue* clone() const SAL_OVERRIDE;
 
-        bool isLeftAligned() const  { return (mnAlignment & TABITEM_LEFTALIGNED) != 0; }
-        bool isRightAligned() const { return (mnAlignment & TABITEM_RIGHTALIGNED) != 0; }
+        bool isLeftAligned() const  { return bool(mnAlignment & TabitemFlags::LeftAligned); }
+        bool isRightAligned() const { return bool(mnAlignment & TabitemFlags::RightAligned); }
         bool isBothAligned() const  { return isLeftAligned() && isRightAligned(); }
-        bool isNotAligned() const   { return (mnAlignment & (TABITEM_LEFTALIGNED | TABITEM_RIGHTALIGNED)) == 0; }
-        bool isFirst() const        { return (mnAlignment & TABITEM_FIRST_IN_GROUP) != 0; }
-        bool isLast() const         { return (mnAlignment & TABITEM_LAST_IN_GROUP) != 0; }
+        bool isNotAligned() const   { return !(mnAlignment & (TabitemFlags::LeftAligned | TabitemFlags::RightAligned)); }
+        bool isFirst() const        { return bool(mnAlignment & TabitemFlags::FirstInGroup); }
+        bool isLast() const         { return bool(mnAlignment & TabitemFlags::LastInGroup); }
         const Rectangle& getContentRect() const { return maContentRect; }
 };
 
diff --git a/svtools/source/toolpanel/paneltabbar.cxx b/svtools/source/toolpanel/paneltabbar.cxx
index b1f28b5..6352d4c 100644
--- a/svtools/source/toolpanel/paneltabbar.cxx
+++ b/svtools/source/toolpanel/paneltabbar.cxx
@@ -325,9 +325,9 @@ namespace svt
                                        i_rContentRect.Bottom() - TAB_TABOFFSET_Y));
 
         if ( i_nItemFlags & ITEM_POSITION_FIRST )
-            tiValue.mnAlignment |= TABITEM_FIRST_IN_GROUP;
+            tiValue.mnAlignment |= TabitemFlags::FirstInGroup;
         if ( i_nItemFlags & ITEM_POSITION_LAST )
-            tiValue.mnAlignment |= TABITEM_LAST_IN_GROUP;
+            tiValue.mnAlignment |= TabitemFlags::LastInGroup;
 
 
         bool bNativeOK = getTargetDevice().DrawNativeControl( CTRL_TAB_ITEM, PART_ENTIRE_CONTROL, i_rContentRect, nState, tiValue, OUString() );
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index 5aa6f8d..8103b56 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -829,18 +829,18 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
             aTabItemDrawInfo.position=kHIThemeTabPositionMiddle;
 
             TabitemValue const * pTabValue = static_cast<TabitemValue const *>(&aValue);
-            unsigned int nAlignment = pTabValue->mnAlignment;
-            //TABITEM_LEFTALIGNED (and TABITEM_RIGHTALIGNED) for the leftmost (or rightmost) tab
+            TabitemFlags nAlignment = pTabValue->mnAlignment;
+            //TabitemFlags::LeftAligned (and TabitemFlags::RightAligned) for the leftmost (or rightmost) tab
             //when there are several lines of tabs because there is only one first tab and one
-            //last tab and TABITEM_FIRST_IN_GROUP (and TABITEM_LAST_IN_GROUP) because when the
-            //line width is different from window width, there may not be TABITEM_RIGHTALIGNED
-            if( ( (nAlignment & TABITEM_LEFTALIGNED)&&(nAlignment & TABITEM_RIGHTALIGNED) ) ||
-                ( (nAlignment & TABITEM_FIRST_IN_GROUP)&&(nAlignment & TABITEM_LAST_IN_GROUP) )
+            //last tab and TabitemFlags::FirstInGroup (and TabitemFlags::LastInGroup) because when the
+            //line width is different from window width, there may not be TabitemFlags::RightAligned
+            if( ( (nAlignment & TabitemFlags::LeftAligned)&&(nAlignment & TabitemFlags::RightAligned) ) ||
+                ( (nAlignment & TabitemFlags::FirstInGroup)&&(nAlignment & TabitemFlags::LastInGroup) )
                ) //tab alone
                 aTabItemDrawInfo.position=kHIThemeTabPositionOnly;
-            else if((nAlignment & TABITEM_LEFTALIGNED)||(nAlignment & TABITEM_FIRST_IN_GROUP))
+            else if((nAlignment & TabitemFlags::LeftAligned)||(nAlignment & TabitemFlags::FirstInGroup))
                 aTabItemDrawInfo.position=kHIThemeTabPositionFirst;
-            else if((nAlignment & TABITEM_RIGHTALIGNED)||(nAlignment & TABITEM_LAST_IN_GROUP))
+            else if((nAlignment & TabitemFlags::RightAligned)||(nAlignment & TabitemFlags::LastInGroup))
                 aTabItemDrawInfo.position=kHIThemeTabPositionLast;
 
             //support for RTL
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 1558b73..304e263 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -851,13 +851,13 @@ void TabControl::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem* p
                                        pItem->maRect.Top() + TAB_TABOFFSET_Y,
                                        pItem->maRect.Bottom() - TAB_TABOFFSET_Y));
         if (pItem->maRect.Left() < 5)
-            tiValue.mnAlignment |= TABITEM_LEFTALIGNED;
+            tiValue.mnAlignment |= TabitemFlags::LeftAligned;
         if (pItem->maRect.Right() > mnLastWidth - 5)
-            tiValue.mnAlignment |= TABITEM_RIGHTALIGNED;
+            tiValue.mnAlignment |= TabitemFlags::RightAligned;
         if (bFirstInGroup)
-            tiValue.mnAlignment |= TABITEM_FIRST_IN_GROUP;
+            tiValue.mnAlignment |= TabitemFlags::FirstInGroup;
         if (bLastInGroup)
-            tiValue.mnAlignment |= TABITEM_LAST_IN_GROUP;
+            tiValue.mnAlignment |= TabitemFlags::LastInGroup;
 
         Rectangle aCtrlRegion( pItem->maRect );
         bNativeOK = rRenderContext.DrawNativeControl(CTRL_TAB_ITEM, PART_ENTIRE_CONTROL,


More information about the Libreoffice-commits mailing list