summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-05-24 09:21:33 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-05-24 13:07:03 +0000
commitfe0bba96ac0682eeba1757ede42b5fdef22764b8 (patch)
tree3770076b3d171dccefaa3ef68dcdddd021e0e28c
parent9ff8c95e54bed9ffd6ae4636c9e8385ad3160643 (diff)
Convert VclPackType to scoped enum
Change-Id: I5bcc4f8686c1ce5bf7def948ce50837fa542786f Reviewed-on: https://gerrit.libreoffice.org/25394 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r--include/o3tl/enumarray.hxx1
-rw-r--r--include/vcl/vclenum.hxx7
-rw-r--r--vcl/source/window/builder.cxx8
-rw-r--r--vcl/source/window/layout.cxx14
-rw-r--r--vcl/source/window/window.cxx2
5 files changed, 18 insertions, 14 deletions
diff --git a/include/o3tl/enumarray.hxx b/include/o3tl/enumarray.hxx
index 0e88142e0857..766d9670b34a 100644
--- a/include/o3tl/enumarray.hxx
+++ b/include/o3tl/enumarray.hxx
@@ -22,6 +22,7 @@
#include <iterator>
#include <type_traits>
+#include <cassert>
namespace o3tl {
diff --git a/include/vcl/vclenum.hxx b/include/vcl/vclenum.hxx
index 28a68883750e..45f9ed29d1ac 100644
--- a/include/vcl/vclenum.hxx
+++ b/include/vcl/vclenum.hxx
@@ -107,10 +107,11 @@ enum VclAlign
VCL_ALIGN_CENTER
};
-enum VclPackType
+enum class VclPackType
{
- VCL_PACK_START = 0,
- VCL_PACK_END = 1
+ Start = 0,
+ End = 1,
+ LAST = End
};
// Return Values from Dialog::Execute
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 2a466ad97688..17c3b8ff558e 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1997,14 +1997,14 @@ bool VclBuilder::sortIntoBestTabTraversalOrder::operator()(const vcl::Window *pA
return false;
}
//honour relative box positions with pack group, (numerical order is reversed
- //for VCL_PACK_END, they are packed from the end back, but here we need
+ //for VclPackType::End, they are packed from the end back, but here we need
//them in visual layout order so that tabbing works as expected)
sal_Int32 nPackA = m_pBuilder->get_window_packing_data(pA).m_nPosition;
sal_Int32 nPackB = m_pBuilder->get_window_packing_data(pB).m_nPosition;
if (nPackA < nPackB)
- return ePackA == VCL_PACK_START;
+ return ePackA == VclPackType::Start;
if (nPackA > nPackB)
- return ePackA != VCL_PACK_START;
+ return ePackA != VclPackType::Start;
//sort labels of Frames before body
if (pA->GetParent() == pB->GetParent())
{
@@ -2956,7 +2956,7 @@ void VclBuilder::applyPackingProperty(vcl::Window *pCurrent,
}
else if (sKey == "pack-type")
{
- VclPackType ePackType = (!sValue.isEmpty() && (sValue[0] == 'e' || sValue[0] == 'E')) ? VCL_PACK_END : VCL_PACK_START;
+ VclPackType ePackType = (!sValue.isEmpty() && (sValue[0] == 'e' || sValue[0] == 'E')) ? VclPackType::End : VclPackType::Start;
pCurrent->set_pack_type(ePackType);
}
else if (sKey == "left-attach")
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index a3761389b208..5e82e4a7c017 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -8,6 +8,8 @@
*/
#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <o3tl/enumarray.hxx>
+#include <o3tl/enumrange.hxx>
#include <vcl/dialog.hxx>
#include <vcl/layout.hxx>
#include <vcl/msgbox.hxx>
@@ -231,25 +233,25 @@ void VclBox::setAllocation(const Size &rAllocation)
}
//Split into those we pack from the start onwards, and those we pack from the end backwards
- std::vector<vcl::Window*> aWindows[2];
+ o3tl::enumarray<VclPackType,std::vector<vcl::Window*>> aWindows;
for (vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next))
{
if (!pChild->IsVisible())
continue;
- sal_Int32 ePacking = pChild->get_pack_type();
+ VclPackType ePacking = pChild->get_pack_type();
aWindows[ePacking].push_back(pChild);
}
//See VclBuilder::sortIntoBestTabTraversalOrder for why they are in visual
//order under the parent which requires us to reverse them here to
//pack from the end back
- std::reverse(aWindows[VCL_PACK_END].begin(),aWindows[VCL_PACK_END].end());
+ std::reverse(aWindows[VclPackType::End].begin(),aWindows[VclPackType::End].end());
- for (sal_Int32 ePackType = VCL_PACK_START; ePackType <= VCL_PACK_END; ++ePackType)
+ for (VclPackType ePackType : o3tl::enumrange<VclPackType>())
{
Point aPos(0, 0);
- if (ePackType == VCL_PACK_END)
+ if (ePackType == VclPackType::End)
{
long nPrimaryCoordinate = getPrimaryCoordinate(aPos);
setPrimaryCoordinate(aPos, nPrimaryCoordinate + nAllocPrimaryDimension);
@@ -297,7 +299,7 @@ void VclBox::setAllocation(const Size &rAllocation)
}
long nDiff = getPrimaryDimension(aBoxSize) + m_nSpacing;
- if (ePackType == VCL_PACK_START)
+ if (ePackType == VclPackType::Start)
setPrimaryCoordinate(aPos, nPrimaryCoordinate + nDiff);
else
{
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 547bc2cdea75..623275beb0d8 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -641,7 +641,7 @@ WindowImpl::WindowImpl( WindowType nType )
meAlwaysInputMode = AlwaysInputNone; // neither AlwaysEnableInput nor AlwaysDisableInput called
meHalign = VCL_ALIGN_FILL;
meValign = VCL_ALIGN_FILL;
- mePackType = VCL_PACK_START;
+ mePackType = VclPackType::Start;
mnPadding = 0;
mnGridHeight = 1;
mnGridLeftAttach = -1;