summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2016-05-28 14:56:29 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-05-30 08:32:06 +0000
commita499d1b980be1eb2bd6ccfa07b1d87c02fcb1343 (patch)
tree9c81b8f52ee76c9c756209ed1c549eb7a811b9f1
parent4405180546bce4b4237f1a23c0bc5bcc5d7bb3a7 (diff)
Convert WINDOW flags to scoped enum
Change-Id: I952fcc940cfe4daca5a810a406a2b8ecd3bd6f47 Reviewed-on: https://gerrit.libreoffice.org/25582 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r--include/tools/rc.h24
-rw-r--r--include/vcl/window.hxx7
-rw-r--r--rsc/source/parser/rscicpx.cxx20
-rw-r--r--vcl/source/window/resource.cxx31
4 files changed, 40 insertions, 42 deletions
diff --git a/include/tools/rc.h b/include/tools/rc.h
index ff8ea1347cb8..eb531bf60d16 100644
--- a/include/tools/rc.h
+++ b/include/tools/rc.h
@@ -38,16 +38,20 @@ namespace o3tl {
template<> struct typed_flags<RSWND> : is_typed_flags<RSWND, 0x03> {};
}
-#define WINDOW_XYMAPMODE 0x0001
-#define WINDOW_X 0x0002
-#define WINDOW_Y 0x0004
-#define WINDOW_WHMAPMODE 0x0008
-#define WINDOW_WIDTH 0x0010
-#define WINDOW_HEIGHT 0x0020
-#define WINDOW_TEXT 0x0040
-#define WINDOW_HELPTEXT 0x0080
-#define WINDOW_QUICKTEXT 0x0100
-#define WINDOW_HELPID 0x0200
+enum class RscWindowFlags {
+ XYMapMode = 0x0001,
+ X = 0x0002,
+ Y = 0x0004,
+ WHMapMode = 0x0008,
+ Width = 0x0010,
+ Height = 0x0020,
+ Text = 0x0040,
+ QuickText = 0x0100,
+ HelpId = 0x0200
+};
+namespace o3tl {
+ template<> struct typed_flags<RscWindowFlags> : is_typed_flags<RscWindowFlags, 0x07> {};
+}
// For "FixedImage" resource:
#define RSC_FIXEDIMAGE_IMAGE 0x0001
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index dea60a940d06..62e8c6448a5e 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -466,12 +466,13 @@ class LifecycleTest;
namespace svt { class PopupWindowControllerImpl; }
enum class RSWND;
+enum class RscWindowFlags;
struct WindowResHeader
{
- sal_uLong nObjMask;
- OString aHelpId;
- RSWND nRSStyle;
+ RscWindowFlags nObjMask;
+ OString aHelpId;
+ RSWND nRSStyle;
};
enum class WindowHitTest {
diff --git a/rsc/source/parser/rscicpx.cxx b/rsc/source/parser/rscicpx.cxx
index 73b58cab67ea..a23761d7157b 100644
--- a/rsc/source/parser/rscicpx.cxx
+++ b/rsc/source/parser/rscicpx.cxx
@@ -251,31 +251,29 @@ RscTop * RscTypCont::InitClassWindow( RscTop * pSuper, RscEnum * pMapUnit,
InsWinBit( pClassWindow, "DialogControl", nTabControlId );
nId = aNmTb.Put( "HelpID", VARNAME );
- pClassWindow->SetVariable( nId, &aStringLiteral, nullptr, 0, WINDOW_HELPID );
+ pClassWindow->SetVariable( nId, &aStringLiteral, nullptr, 0, (sal_uInt32)RscWindowFlags::HelpId );
nRsc_XYMAPMODEId = nId = aNmTb.Put( "_XYMapMode", VARNAME );
- pClassWindow->SetVariable( nId, pMapUnit, nullptr, 0, WINDOW_XYMAPMODE );
+ pClassWindow->SetVariable( nId, pMapUnit, nullptr, 0, (sal_uInt32)RscWindowFlags::XYMapMode );
nRsc_X = nId = aNmTb.Put( "_X", VARNAME );
- pClassWindow->SetVariable( nId, &aLong, nullptr, 0, WINDOW_X );
+ pClassWindow->SetVariable( nId, &aLong, nullptr, 0, (sal_uInt32)RscWindowFlags::X );
nRsc_Y = nId = aNmTb.Put( "_Y", VARNAME );
- pClassWindow->SetVariable( nId, &aLong, nullptr, 0, WINDOW_Y );
+ pClassWindow->SetVariable( nId, &aLong, nullptr, 0, (sal_uInt32)RscWindowFlags::Y );
nRsc_WHMAPMODEId = nId = aNmTb.Put( "_WHMapMode", VARNAME );
- pClassWindow->SetVariable( nId, pMapUnit, nullptr, 0, WINDOW_WHMAPMODE );
+ pClassWindow->SetVariable( nId, pMapUnit, nullptr, 0, (sal_uInt32)RscWindowFlags::WHMapMode );
nRsc_WIDTH = nId = aNmTb.Put( "_Width", VARNAME );
- pClassWindow->SetVariable( nId, &aLong, nullptr, 0, WINDOW_WIDTH );
+ pClassWindow->SetVariable( nId, &aLong, nullptr, 0, (sal_uInt32)RscWindowFlags::Width );
nRsc_HEIGHT = nId = aNmTb.Put( "_Height", VARNAME );
- pClassWindow->SetVariable( nId, &aLong, nullptr, 0, WINDOW_HEIGHT );
+ pClassWindow->SetVariable( nId, &aLong, nullptr, 0, (sal_uInt32)RscWindowFlags::Height );
nRsc_DELTALANG = nId = aNmTb.Put( "DeltaLang", VARNAME );
pClassWindow->SetVariable( nId, pLangGeo, nullptr, VAR_NORC | VAR_NOENUM);
nId = aNmTb.Put( "Text", VARNAME );
- pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, WINDOW_TEXT );
- nId = aNmTb.Put( "HelpText", VARNAME );
- pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, WINDOW_HELPTEXT );
+ pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, (sal_uInt32)RscWindowFlags::Text );
nId = aNmTb.Put( "QuickHelpText", VARNAME );
- pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, WINDOW_QUICKTEXT );
+ pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, (sal_uInt32)RscWindowFlags::QuickText );
return pClassWindow;
}
diff --git a/vcl/source/window/resource.cxx b/vcl/source/window/resource.cxx
index 5f627e8f29d5..12536be7b543 100644
--- a/vcl/source/window/resource.cxx
+++ b/vcl/source/window/resource.cxx
@@ -50,7 +50,7 @@ WindowResHeader Window::ImplLoadResHeader( const ResId& rResId )
{
WindowResHeader aHeader;
- aHeader.nObjMask = ReadLongRes();
+ aHeader.nObjMask = (RscWindowFlags)ReadLongRes();
// we need to calculate auto helpids before the resource gets closed
// if the resource only contains flags, it will be closed before we try to read a help id
@@ -63,7 +63,7 @@ WindowResHeader Window::ImplLoadResHeader( const ResId& rResId )
// WinBits
ReadLongRes();
- if( aHeader.nObjMask & WINDOW_HELPID )
+ if( aHeader.nObjMask & RscWindowFlags::HelpId )
aHeader.aHelpId = ReadByteStringRes();
return aHeader;
@@ -75,40 +75,40 @@ void Window::ImplLoadRes( const ResId& rResId )
SetHelpId( aHeader.aHelpId );
- sal_uLong nObjMask = aHeader.nObjMask;
+ RscWindowFlags nObjMask = aHeader.nObjMask;
bool bPos = false;
bool bSize = false;
Point aPos;
Size aSize;
- if ( nObjMask & (WINDOW_XYMAPMODE | WINDOW_X | WINDOW_Y) )
+ if ( nObjMask & (RscWindowFlags::XYMapMode | RscWindowFlags::X | RscWindowFlags::Y) )
{
// use size as per resource
MapUnit ePosMap = MAP_PIXEL;
bPos = true;
- if ( nObjMask & WINDOW_XYMAPMODE )
+ if ( nObjMask & RscWindowFlags::XYMapMode )
ePosMap = (MapUnit)ReadLongRes();
- if ( nObjMask & WINDOW_X )
+ if ( nObjMask & RscWindowFlags::X )
aPos.X() = ImplLogicUnitToPixelX( ReadLongRes(), ePosMap );
- if ( nObjMask & WINDOW_Y )
+ if ( nObjMask & RscWindowFlags::Y )
aPos.Y() = ImplLogicUnitToPixelY( ReadLongRes(), ePosMap );
}
- if ( nObjMask & (WINDOW_WHMAPMODE | WINDOW_WIDTH | WINDOW_HEIGHT) )
+ if ( nObjMask & (RscWindowFlags::WHMapMode | RscWindowFlags::Width | RscWindowFlags::Height) )
{
// use size as per resource
MapUnit eSizeMap = MAP_PIXEL;
bSize = true;
- if ( nObjMask & WINDOW_WHMAPMODE )
+ if ( nObjMask & RscWindowFlags::WHMapMode )
eSizeMap = (MapUnit)ReadLongRes();
- if ( nObjMask & WINDOW_WIDTH )
+ if ( nObjMask & RscWindowFlags::Width )
aSize.Width() = ImplLogicUnitToPixelX( ReadLongRes(), eSizeMap );
- if ( nObjMask & WINDOW_HEIGHT )
+ if ( nObjMask & RscWindowFlags::Height )
aSize.Height() = ImplLogicUnitToPixelY( ReadLongRes(), eSizeMap );
}
@@ -132,14 +132,9 @@ void Window::ImplLoadRes( const ResId& rResId )
if ( nRSStyle & RSWND::DISABLED )
Enable( false );
- if ( nObjMask & WINDOW_TEXT )
+ if ( nObjMask & RscWindowFlags::Text )
SetText( ReadStringRes() );
- if ( nObjMask & WINDOW_HELPTEXT )
- {
- SetHelpText( ReadStringRes() );
- mpWindowImpl->mbHelpTextDynamic = true;
- }
- if ( nObjMask & WINDOW_QUICKTEXT )
+ if ( nObjMask & RscWindowFlags::QuickText )
SetQuickHelpText( ReadStringRes() );
}