summaryrefslogtreecommitdiff
path: root/vcl/source/control/spinfld.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-02-18 14:16:23 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-02-18 15:48:31 +0000
commit55b33456c14aa5311fb0e3d71f1cad4fbd73cbef (patch)
tree60e0fb3c97d93739c338462c7cb4ccd78743e2a1 /vcl/source/control/spinfld.cxx
parent548c2274c9ba7542d6bcae5fefd1400ee4e22fc3 (diff)
refactor ImplDrawSpinButton
there is (supposed to be anyway) no logic change here, just unwind the overly complex flow Change-Id: I9c96f41b0480a60c486b476f383d856b464cd62d
Diffstat (limited to 'vcl/source/control/spinfld.cxx')
-rw-r--r--vcl/source/control/spinfld.cxx103
1 files changed, 50 insertions, 53 deletions
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index e0bcf16eeb77..126152f3e704 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -158,49 +158,7 @@ void ImplDrawSpinButton(vcl::RenderContext& rRenderContext, vcl::Window* pWindow
bool bUpperIn, bool bLowerIn, bool bUpperEnabled, bool bLowerEnabled,
bool bHorz, bool bMirrorHorz)
{
- DecorationView aDecoView(&rRenderContext);
-
- DrawButtonFlags nStyle = DrawButtonFlags::NoLeftLightBorder;
- DrawSymbolFlags nSymStyle = DrawSymbolFlags::NONE;
-
- SymbolType eType1, eType2;
-
- const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
- if ( rStyleSettings.GetOptions() & StyleSettingsOptions::SpinArrow )
- {
- // arrows are only use in OS/2 look
- if ( bHorz )
- {
- eType1 = bMirrorHorz ? SymbolType::ARROW_RIGHT : SymbolType::ARROW_LEFT;
- eType2 = bMirrorHorz ? SymbolType::ARROW_LEFT : SymbolType::ARROW_RIGHT;
- }
- else
- {
- eType1 = SymbolType::ARROW_UP;
- eType2 = SymbolType::ARROW_DOWN;
- }
- }
- else
- {
- if ( bHorz )
- {
- eType1 = bMirrorHorz ? SymbolType::SPIN_RIGHT : SymbolType::SPIN_LEFT;
- eType2 = bMirrorHorz ? SymbolType::SPIN_LEFT : SymbolType::SPIN_RIGHT;
- }
- else
- {
- eType1 = SymbolType::SPIN_UP;
- eType2 = SymbolType::SPIN_DOWN;
- }
- }
-
- // draw upper/left Button
- DrawButtonFlags nTempStyle = nStyle;
- if (bUpperIn)
- nTempStyle |= DrawButtonFlags::Pressed;
-
bool bNativeOK = false;
- Rectangle aUpRect;
if (pWindow)
{
@@ -236,15 +194,55 @@ void ImplDrawSpinButton(vcl::RenderContext& rRenderContext, vcl::Window* pWindow
bNativeOK = ImplDrawNativeSpinbuttons(rRenderContext, aValue);
}
- if (!bNativeOK)
- aUpRect = aDecoView.DrawButton(rUpperRect, nTempStyle);
+ if (bNativeOK)
+ return;
+
+ DecorationView aDecoView(&rRenderContext);
+ SymbolType eType1, eType2;
+
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ if ( rStyleSettings.GetOptions() & StyleSettingsOptions::SpinArrow )
+ {
+ // arrows are only use in OS/2 look
+ if ( bHorz )
+ {
+ eType1 = bMirrorHorz ? SymbolType::ARROW_RIGHT : SymbolType::ARROW_LEFT;
+ eType2 = bMirrorHorz ? SymbolType::ARROW_LEFT : SymbolType::ARROW_RIGHT;
+ }
+ else
+ {
+ eType1 = SymbolType::ARROW_UP;
+ eType2 = SymbolType::ARROW_DOWN;
+ }
+ }
+ else
+ {
+ if ( bHorz )
+ {
+ eType1 = bMirrorHorz ? SymbolType::SPIN_RIGHT : SymbolType::SPIN_LEFT;
+ eType2 = bMirrorHorz ? SymbolType::SPIN_LEFT : SymbolType::SPIN_RIGHT;
+ }
+ else
+ {
+ eType1 = SymbolType::SPIN_UP;
+ eType2 = SymbolType::SPIN_DOWN;
+ }
+ }
+
+ DrawButtonFlags nStyle = DrawButtonFlags::NoLeftLightBorder;
+ // draw upper/left Button
+ if (bUpperIn)
+ nStyle |= DrawButtonFlags::Pressed;
+
+ Rectangle aUpRect = aDecoView.DrawButton(rUpperRect, nStyle);
+
+ nStyle = DrawButtonFlags::NoLeftLightBorder;
// draw lower/right Button
if (bLowerIn)
nStyle |= DrawButtonFlags::Pressed;
- Rectangle aLowRect;
- if(!bNativeOK)
- aLowRect = aDecoView.DrawButton(rLowerRect, nStyle);
+
+ Rectangle aLowRect = aDecoView.DrawButton(rLowerRect, nStyle);
// make use of additional default edge
aUpRect.Left()--;
@@ -285,16 +283,15 @@ void ImplDrawSpinButton(vcl::RenderContext& rRenderContext, vcl::Window* pWindow
aLowRect.Top()++;
}
- DrawSymbolFlags nTempSymStyle = nSymStyle;
+ DrawSymbolFlags nSymStyle = DrawSymbolFlags::NONE;
if (!bUpperEnabled)
- nTempSymStyle |= DrawSymbolFlags::Disable;
- if (!bNativeOK)
- aDecoView.DrawSymbol(aUpRect, eType1, rStyleSettings.GetButtonTextColor(), nTempSymStyle);
+ nSymStyle |= DrawSymbolFlags::Disable;
+ aDecoView.DrawSymbol(aUpRect, eType1, rStyleSettings.GetButtonTextColor(), nSymStyle);
+ nSymStyle = DrawSymbolFlags::NONE;
if (!bLowerEnabled)
nSymStyle |= DrawSymbolFlags::Disable;
- if (!bNativeOK)
- aDecoView.DrawSymbol(aLowRect, eType2, rStyleSettings.GetButtonTextColor(), nSymStyle);
+ aDecoView.DrawSymbol(aLowRect, eType2, rStyleSettings.GetButtonTextColor(), nSymStyle);
}
void SpinField::ImplInitSpinFieldData()