[Libreoffice-commits] core.git: Branch 'feature/rendercontext' - 3 commits - cui/source include/vcl vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Tue May 5 00:22:11 PDT 2015
cui/source/dialogs/hangulhanjadlg.cxx | 4
include/vcl/button.hxx | 20 -
include/vcl/status.hxx | 12
vcl/source/control/button.cxx | 525 +++++++++++++++++-----------------
vcl/source/control/fixed.cxx | 114 +++----
vcl/source/window/status.cxx | 34 +-
6 files changed, 358 insertions(+), 351 deletions(-)
New commits:
commit f0b0510a6aec11c625d474f39562b6f8644c15e6
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue May 5 16:20:53 2015 +0900
Refactor Buttons to use RenderContext when painting
Change-Id: I4ebecb2bda44319a3590a62a2c113c73c94ba974
diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx
index c607375..7414297 100644
--- a/cui/source/dialogs/hangulhanjadlg.cxx
+++ b/cui/source/dialogs/hangulhanjadlg.cxx
@@ -234,7 +234,7 @@ namespace svx
}
- void RubyRadioButton::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+ void RubyRadioButton::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
{
HideFocus();
@@ -289,7 +289,7 @@ namespace svx
aImageLocation.Top() = aPrimaryTextLocation.Top() + ( nTextHeight - aImageSize.Height() ) / 2;
aImageLocation.Bottom() = aImageLocation.Top() + aImageSize.Height();
SetStateRect( aImageLocation );
- DrawRadioButtonState( );
+ DrawRadioButtonState(rRenderContext);
// mouse clicks should be recognized in a rect which is one pixel larger in each direction, plus
// includes the image
diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx
index 8fb9ded..392f7a8 100644
--- a/include/vcl/button.hxx
+++ b/include/vcl/button.hxx
@@ -49,7 +49,7 @@ public:
SAL_DLLPRIVATE sal_uInt16 ImplGetButtonState() const;
SAL_DLLPRIVATE sal_uInt16& ImplGetButtonState();
SAL_DLLPRIVATE sal_uInt16 ImplGetTextStyle( OUString& rText, WinBits nWinStyle, sal_uLong nDrawFlags );
- SAL_DLLPRIVATE void ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, Size& rSize,
+ SAL_DLLPRIVATE void ImplDrawAlignedImage(OutputDevice* pDev, Point& rPos, Size& rSize,
bool bLayout, sal_uLong nImageSep, sal_uLong nDrawFlags,
sal_uInt16 nTextStyle, Rectangle *pSymbolRect=NULL, bool bAddImageSep = false );
SAL_DLLPRIVATE void ImplSetFocusRect( const Rectangle &rFocusRect );
@@ -121,8 +121,8 @@ protected:
SAL_DLLPRIVATE void ImplInitPushButtonData();
SAL_DLLPRIVATE WinBits ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle );
SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
- SAL_DLLPRIVATE void ImplDrawPushButtonContent( OutputDevice* pDev, sal_uLong nDrawFlags,
- const Rectangle& rRect, bool bLayout, bool bMenuBtnSep );
+ SAL_DLLPRIVATE void ImplDrawPushButtonContent(OutputDevice* pDev, sal_uLong nDrawFlags,
+ const Rectangle& rRect, bool bLayout, bool bMenuBtnSep);
SAL_DLLPRIVATE void ImplDrawPushButton(vcl::RenderContext& rRenderContext, bool bLayout = false);
using Button::ImplGetTextStyle;
SAL_DLLPRIVATE sal_uInt16 ImplGetTextStyle( sal_uLong nDrawFlags ) const;
@@ -139,8 +139,8 @@ protected:
using Window::ImplInit;
public:
SAL_DLLPRIVATE void ImplSetDefButton( bool bSet );
- SAL_DLLPRIVATE static void ImplDrawPushButtonFrame( vcl::Window* pDev, Rectangle& rRect, sal_uInt16 nStyle );
- SAL_DLLPRIVATE static bool ImplHitTestPushButton( vcl::Window* pDev, const Point& rPos );
+ SAL_DLLPRIVATE void ImplDrawPushButtonFrame(vcl::RenderContext& rRenderContext, Rectangle& rRect, sal_uInt16 nStyle);
+ SAL_DLLPRIVATE static bool ImplHitTestPushButton(vcl::Window* pDev, const Point& rPos);
SAL_DLLPRIVATE bool ImplIsDefButton() const;
protected:
@@ -291,13 +291,12 @@ private:
SAL_DLLPRIVATE void ImplInitRadioButtonData();
SAL_DLLPRIVATE WinBits ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle );
SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
- SAL_DLLPRIVATE void ImplDrawRadioButtonState();
+ SAL_DLLPRIVATE void ImplDrawRadioButtonState(vcl::RenderContext& rRenderContext);
SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
const Point& rPos, const Size& rSize,
const Size& rImageSize, Rectangle& rStateRect,
Rectangle& rMouseRect, bool bLayout = false );
SAL_DLLPRIVATE void ImplDrawRadioButton(vcl::RenderContext& rRenderContext, bool bLayout = false );
- SAL_DLLPRIVATE void ImplInvalidateOrDrawRadioButtonState();
SAL_DLLPRIVATE void ImplUncheckAllOther();
SAL_DLLPRIVATE Size ImplGetRadioImageSize() const;
SAL_DLLPRIVATE long ImplGetImageToTextDistance() const;
@@ -329,7 +328,7 @@ protected:
// draws the radio button (the knob image), in its current state (pressed/checked)
// at the usual location, which can be overridden with SetStateRect
- void DrawRadioButtonState( );
+ void DrawRadioButtonState(vcl::RenderContext& rRenderContext);
public:
explicit RadioButton( vcl::Window* pParent, WinBits nWinStyle = 0 );
@@ -420,7 +419,6 @@ private:
SAL_DLLPRIVATE void ImplInitCheckBoxData();
SAL_DLLPRIVATE WinBits ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle );
SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
- SAL_DLLPRIVATE void ImplInvalidateOrDrawCheckBoxState();
SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
const Point& rPos, const Size& rSize,
const Size& rImageSize, Rectangle& rStateRect,
@@ -441,7 +439,7 @@ protected:
virtual const vcl::Font& GetCanonicalFont( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
virtual const Color& GetCanonicalTextColor( const StyleSettings& _rStyle ) const SAL_OVERRIDE;
- virtual void ImplDrawCheckBoxState();
+ virtual void ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext);
SAL_DLLPRIVATE const Rectangle& GetStateRect() const { return maStateRect; }
SAL_DLLPRIVATE const Rectangle& GetMouseRect() const { return maMouseRect; }
@@ -543,7 +541,7 @@ public:
class VCL_DLLPUBLIC DisclosureButton : public CheckBox
{
protected:
- SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState() SAL_OVERRIDE;
+ SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
public:
explicit DisclosureButton( vcl::Window* pParent, WinBits nStyle = 0 );
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 3128f11..7dbc31b 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -210,7 +210,7 @@ void Button::ImplSetSeparatorX( long nX )
sal_uInt16 Button::ImplGetTextStyle( OUString& rText, WinBits nWinStyle,
sal_uLong nDrawFlags )
{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
sal_uInt16 nTextStyle = FixedText::ImplGetTextStyle( nWinStyle & ~WB_DEFBUTTON );
if ( nDrawFlags & WINDOW_DRAW_NOMNEMONIC )
@@ -701,30 +701,30 @@ void PushButton::ImplInitSettings( bool bFont,
}
}
-void PushButton::ImplDrawPushButtonFrame( vcl::Window* pDev,
- Rectangle& rRect, sal_uInt16 nStyle )
+void PushButton::ImplDrawPushButtonFrame(vcl::RenderContext& rRenderContext,
+ Rectangle& rRect, sal_uInt16 nStyle)
{
- if ( !(pDev->GetStyle() & (WB_RECTSTYLE | WB_SMALLSTYLE)) )
+ if (!(GetStyle() & (WB_RECTSTYLE | WB_SMALLSTYLE)))
{
- StyleSettings aStyleSettings = pDev->GetSettings().GetStyleSettings();
- if ( pDev->IsControlBackground() )
- aStyleSettings.Set3DColors( pDev->GetControlBackground() );
+ StyleSettings aStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ if (IsControlBackground())
+ aStyleSettings.Set3DColors(GetControlBackground());
}
- DecorationView aDecoView( pDev );
- if ( pDev->IsControlBackground() )
+ DecorationView aDecoView(&rRenderContext);
+ if (IsControlBackground())
{
- AllSettings aSettings = pDev->GetSettings();
- AllSettings aOldSettings = aSettings;
- StyleSettings aStyleSettings = aSettings.GetStyleSettings();
- aStyleSettings.Set3DColors( pDev->GetControlBackground() );
- aSettings.SetStyleSettings( aStyleSettings );
- pDev->OutputDevice::SetSettings( aSettings );
- rRect = aDecoView.DrawButton( rRect, nStyle );
- pDev->OutputDevice::SetSettings( aOldSettings );
+ AllSettings aSettings = rRenderContext.GetSettings();
+ AllSettings aOldSettings = aSettings;
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.Set3DColors(GetControlBackground());
+ aSettings.SetStyleSettings(aStyleSettings);
+ rRenderContext.SetSettings(aSettings);
+ rRect = aDecoView.DrawButton(rRect, nStyle);
+ rRenderContext.SetSettings(aOldSettings);
}
else
- rRect = aDecoView.DrawButton( rRect, nStyle );
+ rRect = aDecoView.DrawButton(rRect, nStyle);
}
bool PushButton::ImplHitTestPushButton( vcl::Window* pDev,
@@ -797,11 +797,8 @@ static void ImplDrawBtnDropDownArrow( OutputDevice* pDev,
pDev->SetFillColor( aOldFillColor );
}
-void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, sal_uLong nDrawFlags,
- const Rectangle& rRect,
- bool bLayout,
- bool bMenuBtnSep
- )
+void PushButton::ImplDrawPushButtonContent(OutputDevice* pDev, sal_uLong nDrawFlags,
+ const Rectangle& rRect, bool bLayout, bool bMenuBtnSep)
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
Rectangle aInRect = rRect;
@@ -914,25 +911,25 @@ void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, sal_uLong nDrawF
pDev->Pop(); // restore clipregion
}
-void PushButton::ImplDrawPushButton(vcl::RenderContext& /*rRenderContext*/, bool bLayout)
+void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext, bool bLayout)
{
- if( !bLayout )
+ if (!bLayout)
HideFocus();
- sal_uInt16 nButtonStyle = ImplGetButtonState();
- Point aPoint;
- Size aOutSz( GetOutputSizePixel() );
- Rectangle aRect( aPoint, aOutSz );
- Rectangle aInRect = aRect;
- bool bNativeOK = false;
+ sal_uInt16 nButtonStyle = ImplGetButtonState();
+ Point aPoint;
+ Size aOutSz(GetOutputSizePixel());
+ Rectangle aRect(aPoint, aOutSz);
+ Rectangle aInRect = aRect;
+ bool bNativeOK = false;
// adjust style if button should be rendered 'pressed'
- if ( mbPressed )
+ if (mbPressed)
nButtonStyle |= BUTTON_DRAW_PRESSED;
// TODO: move this to Window class or make it a member !!!
ControlType aCtrlType = 0;
- switch( GetParent()->GetType() )
+ switch(GetParent()->GetType())
{
case WINDOW_LISTBOX:
case WINDOW_MULTILISTBOX:
@@ -958,68 +955,79 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& /*rRenderContext*/, bool
if( bDropDown && (aCtrlType == CTRL_COMBOBOX || aCtrlType == CTRL_LISTBOX ) )
{
- if( GetParent()->IsNativeControlSupported( aCtrlType, PART_ENTIRE_CONTROL) )
+ if (GetParent()->IsNativeControlSupported(aCtrlType, PART_ENTIRE_CONTROL))
{
// skip painting if the button was already drawn by the theme
- if( aCtrlType == CTRL_COMBOBOX )
+ if (aCtrlType == CTRL_COMBOBOX)
{
Edit* pEdit = static_cast<Edit*>(GetParent());
- if( pEdit->ImplUseNativeBorder( pEdit->GetStyle() ) )
+ if (pEdit->ImplUseNativeBorder(pEdit->GetStyle()))
bNativeOK = true;
}
- else if( GetParent()->IsNativeControlSupported( aCtrlType, HAS_BACKGROUND_TEXTURE) )
+ else if (GetParent()->IsNativeControlSupported(aCtrlType, HAS_BACKGROUND_TEXTURE))
{
bNativeOK = true;
}
- if( !bNativeOK && GetParent()->IsNativeControlSupported( aCtrlType, PART_BUTTON_DOWN ) )
+
+ if (!bNativeOK && GetParent()->IsNativeControlSupported(aCtrlType, PART_BUTTON_DOWN))
{
// let the theme draw it, note we then need support
// for CTRL_LISTBOX/PART_BUTTON_DOWN and CTRL_COMBOBOX/PART_BUTTON_DOWN
- ImplControlValue aControlValue;
- ControlState nState = ControlState::NONE;
-
- if ( mbPressed ) nState |= ControlState::PRESSED;
- if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= ControlState::PRESSED;
- if ( HasFocus() ) nState |= ControlState::FOCUSED;
- if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= ControlState::DEFAULT;
- if ( Window::IsEnabled() ) nState |= ControlState::ENABLED;
-
- if ( IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ) )
+ ImplControlValue aControlValue;
+ ControlState nState = ControlState::NONE;
+
+ if (mbPressed)
+ nState |= ControlState::PRESSED;
+ if (ImplGetButtonState() & BUTTON_DRAW_PRESSED)
+ nState |= ControlState::PRESSED;
+ if (HasFocus())
+ nState |= ControlState::FOCUSED;
+ if (ImplGetButtonState() & BUTTON_DRAW_DEFAULT)
+ nState |= ControlState::DEFAULT;
+ if (Window::IsEnabled())
+ nState |= ControlState::ENABLED;
+
+ if (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()))
nState |= ControlState::ROLLOVER;
- bNativeOK = DrawNativeControl( aCtrlType, PART_BUTTON_DOWN, aInRect, nState,
- aControlValue, OUString() );
+ bNativeOK = rRenderContext.DrawNativeControl(aCtrlType, PART_BUTTON_DOWN, aInRect, nState,
+ aControlValue, OUString());
}
}
}
- if( bNativeOK )
+ if (bNativeOK)
return;
- bool bRollOver = (IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ));
+ bool bRollOver = IsMouseOver() && aInRect.IsInside(GetPointerPosPixel());
bool bDrawMenuSep = true;
- if( (GetStyle() & WB_FLATBUTTON) )
+ if (GetStyle() & WB_FLATBUTTON)
{
- if( ! bRollOver && ! HasFocus() )
+ if (!bRollOver && !HasFocus())
bDrawMenuSep = false;
}
- if ( (bNativeOK=IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)) )
+ if ((bNativeOK = IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)))
{
PushButtonValue aControlValue;
- Rectangle aCtrlRegion( aInRect );
- ControlState nState = ControlState::NONE;
-
- if ( mbPressed || IsChecked() ) nState |= ControlState::PRESSED;
- if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= ControlState::PRESSED;
- if ( HasFocus() ) nState |= ControlState::FOCUSED;
- if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= ControlState::DEFAULT;
- if ( Window::IsEnabled() ) nState |= ControlState::ENABLED;
-
- if ( bRollOver )
+ Rectangle aCtrlRegion(aInRect);
+ ControlState nState = ControlState::NONE;
+
+ if (mbPressed || IsChecked())
+ nState |= ControlState::PRESSED;
+ if (ImplGetButtonState() & BUTTON_DRAW_PRESSED)
+ nState |= ControlState::PRESSED;
+ if (HasFocus())
+ nState |= ControlState::FOCUSED;
+ if (ImplGetButtonState() & BUTTON_DRAW_DEFAULT)
+ nState |= ControlState::DEFAULT;
+ if (Window::IsEnabled())
+ nState |= ControlState::ENABLED;
+
+ if (bRollOver)
nState |= ControlState::ROLLOVER;
- if( GetStyle() & WB_BEVELBUTTON )
+ if (GetStyle() & WB_BEVELBUTTON)
aControlValue.mbBevelButton = true;
// draw frame into invisible window to have aInRect modified correctly
@@ -1036,15 +1044,15 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& /*rRenderContext*/, bool
// prepare single line hint (needed on mac to decide between normal push button and
// rectangular bevel button look)
- Size aFontSize( Application::GetSettings().GetStyleSettings().GetPushButtonFont().GetSize() );
- aFontSize = LogicToPixel( aFontSize, MapMode( MAP_POINT ) );
- Size aInRectSize( LogicToPixel( Size( aInRect.GetWidth(), aInRect.GetHeight() ) ) );
- aControlValue.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height() );
+ Size aFontSize(Application::GetSettings().GetStyleSettings().GetPushButtonFont().GetSize());
+ aFontSize = LogicToPixel(aFontSize, MapMode(MAP_POINT));
+ Size aInRectSize(LogicToPixel(Size(aInRect.GetWidth(), aInRect.GetHeight())));
+ aControlValue.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height());
- if( ((nState & ControlState::ROLLOVER)) || ! (GetStyle() & WB_FLATBUTTON) )
+ if (((nState & ControlState::ROLLOVER)) || !(GetStyle() & WB_FLATBUTTON))
{
- bNativeOK = DrawNativeControl( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
- aControlValue, OUString()/*PushButton::GetText()*/ );
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
+ aControlValue, OUString() /*PushButton::GetText()*/);
}
else
{
@@ -1052,22 +1060,21 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& /*rRenderContext*/, bool
}
// draw content using the same aInRect as non-native VCL would do
- ImplDrawPushButtonContent( this,
- (nState&ControlState::ROLLOVER) ? WINDOW_DRAW_ROLLOVER : 0,
- aInRect, bLayout, bDrawMenuSep );
+ ImplDrawPushButtonContent(this, (nState&ControlState::ROLLOVER) ? WINDOW_DRAW_ROLLOVER : 0,
+ aInRect, bLayout, bDrawMenuSep);
- if ( HasFocus() )
- ShowFocus( ImplGetFocusRect() );
+ if (HasFocus())
+ ShowFocus(ImplGetFocusRect());
}
- if ( !bNativeOK )
+ if (!bNativeOK)
{
// draw PushButtonFrame, aInRect has content size afterwards
- if( (GetStyle() & WB_FLATBUTTON) )
+ if (GetStyle() & WB_FLATBUTTON)
{
- Rectangle aTempRect( aInRect );
- if( ! bLayout && bRollOver )
- ImplDrawPushButtonFrame( this, aTempRect, nButtonStyle );
+ Rectangle aTempRect(aInRect);
+ if (!bLayout && bRollOver)
+ ImplDrawPushButtonFrame(rRenderContext, aTempRect, nButtonStyle);
aInRect.Left() += 2;
aInRect.Top() += 2;
aInRect.Right() -= 2;
@@ -1075,16 +1082,16 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& /*rRenderContext*/, bool
}
else
{
- if( ! bLayout )
- ImplDrawPushButtonFrame( this, aInRect, nButtonStyle );
+ if (!bLayout)
+ ImplDrawPushButtonFrame(rRenderContext, aInRect, nButtonStyle);
}
// draw content
- ImplDrawPushButtonContent( this, 0, aInRect, bLayout, bDrawMenuSep );
+ ImplDrawPushButtonContent(&rRenderContext, 0, aInRect, bLayout, bDrawMenuSep);
- if( ! bLayout && HasFocus() )
+ if (!bLayout && HasFocus())
{
- ShowFocus( ImplGetFocusRect() );
+ ShowFocus(ImplGetFocusRect());
}
}
}
@@ -1847,131 +1854,119 @@ void RadioButton::ImplInitSettings( bool bFont,
}
}
-void RadioButton::DrawRadioButtonState( )
+void RadioButton::DrawRadioButtonState(vcl::RenderContext& rRenderContext)
{
- ImplDrawRadioButtonState( );
+ ImplDrawRadioButtonState(rRenderContext);
}
-void RadioButton::ImplInvalidateOrDrawRadioButtonState()
+void RadioButton::ImplDrawRadioButtonState(vcl::RenderContext& rRenderContext)
{
- if( ImplGetSVData()->maNWFData.mbCheckBoxNeedsErase )
- {
- if ( IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL) )
- {
- Invalidate();
- Update();
- return;
- }
- }
- ImplDrawRadioButtonState();
-}
-
-void RadioButton::ImplDrawRadioButtonState()
-{
- bool bNativeOK = false;
+ bool bNativeOK = false;
// no native drawing for image radio buttons
- if ( !maImage && (bNativeOK=IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL)) )
- {
- ImplControlValue aControlValue( mbChecked ? BUTTONVALUE_ON : BUTTONVALUE_OFF );
- Rectangle aCtrlRect( maStateRect.TopLeft(), maStateRect.GetSize() );
- ControlState nState = ControlState::NONE;
-
- if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= ControlState::PRESSED;
- if ( HasFocus() ) nState |= ControlState::FOCUSED;
- if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= ControlState::DEFAULT;
- if ( IsEnabled() ) nState |= ControlState::ENABLED;
-
- if ( IsMouseOver() && maMouseRect.IsInside( GetPointerPosPixel() ) )
+ if (!maImage && (bNativeOK = rRenderContext.IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL)))
+ {
+ ImplControlValue aControlValue( mbChecked ? BUTTONVALUE_ON : BUTTONVALUE_OFF );
+ Rectangle aCtrlRect(maStateRect.TopLeft(), maStateRect.GetSize());
+ ControlState nState = ControlState::NONE;
+
+ if (ImplGetButtonState() & BUTTON_DRAW_PRESSED)
+ nState |= ControlState::PRESSED;
+ if (HasFocus())
+ nState |= ControlState::FOCUSED;
+ if (ImplGetButtonState() & BUTTON_DRAW_DEFAULT)
+ nState |= ControlState::DEFAULT;
+ if (IsEnabled())
+ nState |= ControlState::ENABLED;
+
+ if (IsMouseOver() && maMouseRect.IsInside(GetPointerPosPixel()))
nState |= ControlState::ROLLOVER;
- bNativeOK = DrawNativeControl( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRect, nState,
- aControlValue,OUString() );
-
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRect,
+ nState, aControlValue, OUString());
}
- if ( !bNativeOK )
+ if (!bNativeOK)
{
- // kein Image-RadioButton
- if ( !maImage )
+ if (!maImage)
{
sal_uInt16 nStyle = ImplGetButtonState();
- if ( !IsEnabled() )
+ if (!IsEnabled())
nStyle |= BUTTON_DRAW_DISABLED;
- if ( mbChecked )
+ if (mbChecked)
nStyle |= BUTTON_DRAW_CHECKED;
- Image aImage = GetRadioImage( GetSettings(), nStyle );
- if ( IsZoom() )
- DrawImage( maStateRect.TopLeft(), maStateRect.GetSize(), aImage );
+ Image aImage = GetRadioImage(rRenderContext.GetSettings(), nStyle);
+ if (IsZoom())
+ rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage);
else
- DrawImage( maStateRect.TopLeft(), aImage );
+ rRenderContext.DrawImage(maStateRect.TopLeft(), aImage);
}
else
{
HideFocus();
- DecorationView aDecoView( this );
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- Rectangle aImageRect = maStateRect;
- Size aImageSize = maImage.GetSizePixel();
- bool bEnabled = IsEnabled();
+ DecorationView aDecoView(&rRenderContext);
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ Rectangle aImageRect = maStateRect;
+ Size aImageSize = maImage.GetSizePixel();
+ bool bEnabled = IsEnabled();
sal_uInt16 nButtonStyle = FRAME_DRAW_DOUBLEIN;
- aImageSize.Width() = CalcZoom( aImageSize.Width() );
- aImageSize.Height() = CalcZoom( aImageSize.Height() );
+ aImageSize.Width() = CalcZoom(aImageSize.Width());
+ aImageSize.Height() = CalcZoom(aImageSize.Height());
// display border and selection status
- aImageRect = aDecoView.DrawFrame( aImageRect, nButtonStyle );
- if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) || !bEnabled )
- SetFillColor( rStyleSettings.GetFaceColor() );
+ aImageRect = aDecoView.DrawFrame(aImageRect, nButtonStyle);
+ if ((ImplGetButtonState() & BUTTON_DRAW_PRESSED) || !bEnabled)
+ rRenderContext.SetFillColor( rStyleSettings.GetFaceColor());
else
- SetFillColor( rStyleSettings.GetFieldColor() );
- SetLineColor();
- DrawRect( aImageRect );
+ rRenderContext.SetFillColor(rStyleSettings.GetFieldColor());
+ rRenderContext.SetLineColor();
+ rRenderContext.DrawRect(aImageRect);
// display image
nButtonStyle = 0;
- if ( !bEnabled )
+ if (!bEnabled)
nButtonStyle |= IMAGE_DRAW_DISABLE;
- Image *pImage = &maImage;
+ Image* pImage = &maImage;
- Point aImagePos( aImageRect.TopLeft() );
- aImagePos.X() += (aImageRect.GetWidth()-aImageSize.Width())/2;
- aImagePos.Y() += (aImageRect.GetHeight()-aImageSize.Height())/2;
- if ( IsZoom() )
- DrawImage( aImagePos, aImageSize, *pImage, nButtonStyle );
+ Point aImagePos(aImageRect.TopLeft());
+ aImagePos.X() += (aImageRect.GetWidth() - aImageSize.Width()) / 2;
+ aImagePos.Y() += (aImageRect.GetHeight() - aImageSize.Height()) / 2;
+ if (IsZoom())
+ rRenderContext.DrawImage(aImagePos, aImageSize, *pImage, nButtonStyle);
else
- DrawImage( aImagePos, *pImage, nButtonStyle );
+ rRenderContext.DrawImage(aImagePos, *pImage, nButtonStyle);
aImageRect.Left()++;
aImageRect.Top()++;
aImageRect.Right()--;
aImageRect.Bottom()--;
- ImplSetFocusRect( aImageRect );
+ ImplSetFocusRect(aImageRect);
- if ( mbChecked )
+ if (mbChecked)
{
- SetLineColor( rStyleSettings.GetHighlightColor() );
- SetFillColor();
- if ( (aImageSize.Width() >= 20) || (aImageSize.Height() >= 20) )
+ rRenderContext.SetLineColor(rStyleSettings.GetHighlightColor());
+ rRenderContext.SetFillColor();
+ if ((aImageSize.Width() >= 20) || (aImageSize.Height() >= 20))
{
aImageRect.Left()++;
aImageRect.Top()++;
aImageRect.Right()--;
aImageRect.Bottom()--;
}
- DrawRect( aImageRect );
+ rRenderContext.DrawRect(aImageRect);
aImageRect.Left()++;
aImageRect.Top()++;
aImageRect.Right()--;
aImageRect.Bottom()--;
- DrawRect( aImageRect );
+ rRenderContext.DrawRect(aImageRect);
}
- if ( HasFocus() )
- ShowFocus( ImplGetFocusRect() );
+ if (HasFocus())
+ ShowFocus(ImplGetFocusRect());
}
}
}
@@ -2112,29 +2107,30 @@ void RadioButton::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
pDev->Pop();
}
-void RadioButton::ImplDrawRadioButton(vcl::RenderContext& /*rRenderContext*/, bool bLayout)
+void RadioButton::ImplDrawRadioButton(vcl::RenderContext& rRenderContext, bool bLayout)
{
- if( !bLayout )
+ if (!bLayout)
HideFocus();
Size aImageSize;
- if ( !maImage )
+ if (!maImage)
aImageSize = ImplGetRadioImageSize();
else
aImageSize = maImage.GetSizePixel();
- aImageSize.Width() = CalcZoom( aImageSize.Width() );
- aImageSize.Height() = CalcZoom( aImageSize.Height() );
+
+ aImageSize.Width() = CalcZoom(aImageSize.Width());
+ aImageSize.Height() = CalcZoom(aImageSize.Height());
// Draw control text
- ImplDraw( this, 0, Point(), GetOutputSizePixel(),
- aImageSize, maStateRect, maMouseRect, bLayout );
+ ImplDraw(&rRenderContext, 0, Point(), GetOutputSizePixel(),
+ aImageSize, maStateRect, maMouseRect, bLayout);
- if( !bLayout || IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL) )
+ if (!bLayout || rRenderContext.IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL))
{
- if ( !maImage && HasFocus() )
- ShowFocus( ImplGetFocusRect() );
+ if (!maImage && HasFocus())
+ ShowFocus(ImplGetFocusRect());
- ImplDrawRadioButtonState();
+ ImplDrawRadioButtonState(rRenderContext);
}
}
@@ -2252,7 +2248,8 @@ void RadioButton::ImplCallClick( bool bGrabFocus, sal_uInt16 nFocusFlags )
mbStateChanged = !mbChecked;
mbChecked = true;
mpWindowImpl->mnStyle |= WB_TABSTOP;
- ImplInvalidateOrDrawRadioButtonState();
+ Invalidate();
+ Update();
ImplDelData aDelData;
ImplAddDel( &aDelData );
if ( mbRadioCheck )
@@ -2325,7 +2322,8 @@ void RadioButton::MouseButtonDown( const MouseEvent& rMEvt )
if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
{
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawRadioButtonState();
+ Invalidate();
+ Update();
StartTracking();
return;
}
@@ -2348,7 +2346,10 @@ void RadioButton::Tracking( const TrackingEvent& rTEvt )
if ( !rTEvt.IsTrackingCanceled() )
ImplCallClick();
else
- ImplInvalidateOrDrawRadioButtonState();
+ {
+ Invalidate();
+ Update();
+ }
}
}
else
@@ -2358,7 +2359,8 @@ void RadioButton::Tracking( const TrackingEvent& rTEvt )
if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
{
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawRadioButtonState();
+ Invalidate();
+ Update();
}
}
else
@@ -2366,7 +2368,8 @@ void RadioButton::Tracking( const TrackingEvent& rTEvt )
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
{
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawRadioButtonState();
+ Invalidate();
+ Update();
}
}
}
@@ -2381,13 +2384,15 @@ void RadioButton::KeyInput( const KeyEvent& rKEvt )
if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
{
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawRadioButtonState();
+ Invalidate();
+ Update();
}
}
else if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_ESCAPE) )
{
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawRadioButtonState();
+ Invalidate();
+ Update();
}
else
Button::KeyInput( rKEvt );
@@ -2509,7 +2514,8 @@ void RadioButton::LoseFocus()
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
{
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawRadioButtonState();
+ Invalidate();
+ Update();
}
HideFocus();
@@ -2975,61 +2981,51 @@ void CheckBox::ImplLoadRes( const ResId& rResId )
Check( true );
}
-void CheckBox::ImplInvalidateOrDrawCheckBoxState()
+void CheckBox::ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext)
{
- if( ImplGetSVData()->maNWFData.mbCheckBoxNeedsErase )
- {
- if ( IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL) )
- {
- Invalidate();
- Update();
- return;
- }
- }
- ImplDrawCheckBoxState();
-}
+ bool bNativeOK = true;
-void CheckBox::ImplDrawCheckBoxState()
-{
- bool bNativeOK = true;
-
- if ( (bNativeOK=IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL)) )
+ if ((bNativeOK = rRenderContext.IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL)))
{
- ImplControlValue aControlValue( meState == TRISTATE_TRUE ? BUTTONVALUE_ON : BUTTONVALUE_OFF );
- Rectangle aCtrlRegion( maStateRect );
- ControlState nState = ControlState::NONE;
+ ImplControlValue aControlValue(meState == TRISTATE_TRUE ? BUTTONVALUE_ON : BUTTONVALUE_OFF);
+ Rectangle aCtrlRegion(maStateRect);
+ ControlState nState = ControlState::NONE;
- if ( HasFocus() ) nState |= ControlState::FOCUSED;
- if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= ControlState::DEFAULT;
- if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= ControlState::PRESSED;
- if ( IsEnabled() ) nState |= ControlState::ENABLED;
+ if (HasFocus())
+ nState |= ControlState::FOCUSED;
+ if (ImplGetButtonState() & BUTTON_DRAW_DEFAULT)
+ nState |= ControlState::DEFAULT;
+ if (ImplGetButtonState() & BUTTON_DRAW_PRESSED)
+ nState |= ControlState::PRESSED;
+ if (IsEnabled())
+ nState |= ControlState::ENABLED;
- if ( meState == TRISTATE_TRUE )
- aControlValue.setTristateVal( BUTTONVALUE_ON );
- else if ( meState == TRISTATE_INDET )
- aControlValue.setTristateVal( BUTTONVALUE_MIXED );
+ if (meState == TRISTATE_TRUE)
+ aControlValue.setTristateVal(BUTTONVALUE_ON);
+ else if (meState == TRISTATE_INDET)
+ aControlValue.setTristateVal(BUTTONVALUE_MIXED);
- if ( IsMouseOver() && maMouseRect.IsInside( GetPointerPosPixel() ) )
+ if (IsMouseOver() && maMouseRect.IsInside(GetPointerPosPixel()))
nState |= ControlState::ROLLOVER;
- bNativeOK = DrawNativeControl( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
- aControlValue, OUString() );
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
+ nState, aControlValue, OUString());
}
- if ( !bNativeOK )
+ if (!bNativeOK)
{
sal_uInt16 nStyle = ImplGetButtonState();
- if ( !IsEnabled() )
+ if (!IsEnabled())
nStyle |= BUTTON_DRAW_DISABLED;
- if ( meState == TRISTATE_INDET )
+ if (meState == TRISTATE_INDET)
nStyle |= BUTTON_DRAW_DONTKNOW;
- else if ( meState == TRISTATE_TRUE )
+ else if (meState == TRISTATE_TRUE)
nStyle |= BUTTON_DRAW_CHECKED;
- Image aImage = GetCheckImage( GetSettings(), nStyle );
- if ( IsZoom() )
- DrawImage( maStateRect.TopLeft(), maStateRect.GetSize(), aImage );
+ Image aImage = GetCheckImage(GetSettings(), nStyle);
+ if (IsZoom())
+ rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage);
else
- DrawImage( maStateRect.TopLeft(), aImage );
+ rRenderContext.DrawImage(maStateRect.TopLeft(), aImage);
}
}
@@ -3142,17 +3138,17 @@ void CheckBox::ImplDrawCheckBox(vcl::RenderContext& rRenderContext, bool bLayout
aImageSize.Width() = CalcZoom( aImageSize.Width() );
aImageSize.Height() = CalcZoom( aImageSize.Height() );
- if( !bLayout )
+ if (!bLayout)
HideFocus();
- ImplDraw( &rRenderContext, 0, Point(), GetOutputSizePixel(), aImageSize,
- maStateRect, maMouseRect, bLayout );
+ ImplDraw(&rRenderContext, 0, Point(), GetOutputSizePixel(),
+ aImageSize, maStateRect, maMouseRect, bLayout);
- if( !bLayout )
+ if (!bLayout)
{
- ImplDrawCheckBoxState();
- if ( HasFocus() )
- ShowFocus( ImplGetFocusRect() );
+ ImplDrawCheckBoxState(rRenderContext);
+ if (HasFocus())
+ ShowFocus(ImplGetFocusRect());
}
}
@@ -3173,7 +3169,8 @@ void CheckBox::ImplCheck()
ImplAddDel( &aDelData );
if( (GetStyle() & WB_EARLYTOGGLE) )
Toggle();
- ImplInvalidateOrDrawCheckBoxState();
+ Invalidate();
+ Update();
if( ! (GetStyle() & WB_EARLYTOGGLE) )
Toggle();
if ( aDelData.IsDead() )
@@ -3207,7 +3204,8 @@ void CheckBox::MouseButtonDown( const MouseEvent& rMEvt )
if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
{
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawCheckBoxState();
+ Invalidate();
+ Update();
StartTracking();
return;
}
@@ -3230,7 +3228,10 @@ void CheckBox::Tracking( const TrackingEvent& rTEvt )
if ( !rTEvt.IsTrackingCanceled() )
ImplCheck();
else
- ImplInvalidateOrDrawCheckBoxState();
+ {
+ Invalidate();
+ Update();
+ }
}
}
else
@@ -3240,7 +3241,8 @@ void CheckBox::Tracking( const TrackingEvent& rTEvt )
if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
{
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawCheckBoxState();
+ Invalidate();
+ Update();
}
}
else
@@ -3248,7 +3250,8 @@ void CheckBox::Tracking( const TrackingEvent& rTEvt )
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
{
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawCheckBoxState();
+ Invalidate();
+ Update();
}
}
}
@@ -3263,13 +3266,15 @@ void CheckBox::KeyInput( const KeyEvent& rKEvt )
if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
{
ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawCheckBoxState();
+ Invalidate();
+ Update();
}
}
else if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_ESCAPE) )
{
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawCheckBoxState();
+ Invalidate();
+ Update();
}
else
Button::KeyInput( rKEvt );
@@ -3294,7 +3299,7 @@ void CheckBox::FillLayoutData() const
const_cast<CheckBox*>(this)->Invalidate();
}
-void CheckBox::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
+void CheckBox::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
ImplDrawCheckBox(rRenderContext);
}
@@ -3430,7 +3435,8 @@ void CheckBox::LoseFocus()
if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
{
ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
- ImplInvalidateOrDrawCheckBoxState();
+ Invalidate();
+ Update();
}
HideFocus();
@@ -3790,7 +3796,7 @@ DisclosureButton::DisclosureButton( vcl::Window* pParent, WinBits nStyle ) :
{
}
-void DisclosureButton::ImplDrawCheckBoxState()
+void DisclosureButton::ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext)
{
/* HACK: DisclosureButton is currently assuming, that the disclosure sign
will fit into the rectangle occupied by a normal checkbox on all themes.
@@ -3799,44 +3805,47 @@ void DisclosureButton::ImplDrawCheckBoxState()
for CTRL_LISTNODE would have to be implemented and taken into account
*/
- Rectangle aStateRect( GetStateRect() );
+ Rectangle aStateRect(GetStateRect());
- ImplControlValue aControlValue( GetState() == TRISTATE_TRUE ? BUTTONVALUE_ON : BUTTONVALUE_OFF );
- Rectangle aCtrlRegion( aStateRect );
- ControlState nState = ControlState::NONE;
+ ImplControlValue aControlValue(GetState() == TRISTATE_TRUE ? BUTTONVALUE_ON : BUTTONVALUE_OFF);
+ Rectangle aCtrlRegion(aStateRect);
+ ControlState nState = ControlState::NONE;
- if ( HasFocus() ) nState |= ControlState::FOCUSED;
- if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= ControlState::DEFAULT;
- if ( Window::IsEnabled() ) nState |= ControlState::ENABLED;
- if ( IsMouseOver() && GetMouseRect().IsInside( GetPointerPosPixel() ) )
+ if (HasFocus())
+ nState |= ControlState::FOCUSED;
+ if (ImplGetButtonState() & BUTTON_DRAW_DEFAULT)
+ nState |= ControlState::DEFAULT;
+ if (Window::IsEnabled())
+ nState |= ControlState::ENABLED;
+ if (IsMouseOver() && GetMouseRect().IsInside(GetPointerPosPixel()))
nState |= ControlState::ROLLOVER;
- if( ! DrawNativeControl( CTRL_LISTNODE, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
- aControlValue, OUString() ) )
+ if (!rRenderContext.DrawNativeControl(CTRL_LISTNODE, PART_ENTIRE_CONTROL, aCtrlRegion,
+ nState, aControlValue, OUString()))
{
- ImplSVCtrlData& rCtrlData( ImplGetSVData()->maCtrlData );
- if( ! rCtrlData.mpDisclosurePlus )
- rCtrlData.mpDisclosurePlus = new Image( BitmapEx( VclResId( SV_DISCLOSURE_PLUS ) ) );
- if( ! rCtrlData.mpDisclosureMinus )
- rCtrlData.mpDisclosureMinus = new Image( BitmapEx( VclResId( SV_DISCLOSURE_MINUS ) ) );
+ ImplSVCtrlData& rCtrlData(ImplGetSVData()->maCtrlData);
+ if (!rCtrlData.mpDisclosurePlus)
+ rCtrlData.mpDisclosurePlus = new Image(BitmapEx(VclResId(SV_DISCLOSURE_PLUS)));
+ if (!rCtrlData.mpDisclosureMinus)
+ rCtrlData.mpDisclosureMinus = new Image(BitmapEx(VclResId(SV_DISCLOSURE_MINUS)));
Image* pImg = NULL;
pImg = IsChecked() ? rCtrlData.mpDisclosureMinus : rCtrlData.mpDisclosurePlus;
- DBG_ASSERT( pImg, "no disclosure image" );
- if( ! pImg )
+ DBG_ASSERT(pImg, "no disclosure image");
+ if (!pImg)
return;
sal_uInt16 nStyle = 0;
- if( ! IsEnabled() )
+ if (!IsEnabled())
nStyle |= IMAGE_DRAW_DISABLE;
- Size aSize( aStateRect.GetSize() );
- Size aImgSize( pImg->GetSizePixel() );
- Point aOff( (aSize.Width() - aImgSize.Width())/2,
- (aSize.Height() - aImgSize.Height())/2 );
+ Size aSize(aStateRect.GetSize());
+ Size aImgSize(pImg->GetSizePixel());
+ Point aOff((aSize.Width() - aImgSize.Width()) / 2,
+ (aSize.Height() - aImgSize.Height()) / 2);
aOff += aStateRect.TopLeft();
- DrawImage( aOff, *pImg, nStyle );
+ rRenderContext.DrawImage(aOff, *pImg, nStyle);
}
}
commit 4d88455f155db79772137bca57d3079c3992c4a4
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue May 5 16:16:34 2015 +0900
convert FixedText to use RenderContext when painting
Change-Id: If4c3265f76987d9f59388d3c12441ccb2b03a308
diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index c8acbd1..1971a46 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -188,16 +188,15 @@ sal_uInt16 FixedText::ImplGetTextStyle( WinBits nWinStyle )
return nTextStyle;
}
-void FixedText::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
- const Point& rPos, const Size& rSize,
- bool bFillLayout
- ) const
+void FixedText::ImplDraw(OutputDevice* pDev, sal_uLong nDrawFlags,
+ const Point& rPos, const Size& rSize,
+ bool bFillLayout) const
{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- WinBits nWinStyle = GetStyle();
- OUString aText( GetText() );
- sal_uInt16 nTextStyle = FixedText::ImplGetTextStyle( nWinStyle );
- Point aPos = rPos;
+ const StyleSettings& rStyleSettings = pDev->GetSettings().GetStyleSettings();
+ WinBits nWinStyle = GetStyle();
+ OUString aText(GetText());
+ sal_uInt16 nTextStyle = FixedText::ImplGetTextStyle( nWinStyle );
+ Point aPos = rPos;
if ( nWinStyle & WB_EXTRAOFFSET )
aPos.X() += 2;
@@ -228,10 +227,9 @@ void FixedText::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
(mpControlData->mpLayoutData->m_aDisplayText).clear();
Rectangle aRect( Rectangle( aPos, rSize ) );
- DrawControlText( *pDev, aRect, aText, nTextStyle,
+ DrawControlText(*pDev, aRect, aText, nTextStyle,
bFillLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL,
- bFillLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL
- );
+ bFillLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL);
}
void FixedText::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
@@ -543,75 +541,75 @@ void FixedLine::ImplInitSettings( bool bFont,
}
}
-void FixedLine::ImplDraw(vcl::RenderContext& /*rRenderContext*/, bool bLayout)
+void FixedLine::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout)
{
- Size aOutSize = GetOutputSizePixel();
- OUString aText = GetText();
- WinBits nWinStyle = GetStyle();
- MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
- OUString* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
+ Size aOutSize = rRenderContext.GetOutputSizePixel();
+ OUString aText = GetText();
+ WinBits nWinStyle = GetStyle();
+ MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
+ OUString* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
- DecorationView aDecoView( this );
- if ( aText.isEmpty() )
+ DecorationView aDecoView(&rRenderContext);
+ if (aText.isEmpty())
{
- if( !pVector )
+ if (!pVector)
{
- if ( nWinStyle & WB_VERT )
+ if (nWinStyle & WB_VERT)
{
- long nX = (aOutSize.Width()-1)/2;
- aDecoView.DrawSeparator( Point( nX, 0 ), Point( nX, aOutSize.Height()-1 ) );
+ long nX = (aOutSize.Width() - 1) / 2;
+ aDecoView.DrawSeparator(Point(nX, 0), Point(nX, aOutSize.Height() - 1));
}
else
{
- long nY = (aOutSize.Height()-1)/2;
- aDecoView.DrawSeparator( Point( 0, nY ), Point( aOutSize.Width()-1, nY ), false );
+ long nY = (aOutSize.Height() - 1) / 2;
+ aDecoView.DrawSeparator(Point(0, nY), Point(aOutSize.Width() - 1, nY), false);
}
}
}
- else if( (nWinStyle & WB_VERT) )
+ else if (nWinStyle & WB_VERT)
{
- long nWidth = GetTextWidth( aText );
- Push( PushFlags::FONT );
- vcl::Font aFont( GetFont() );
- aFont.SetOrientation( 900 );
- SetFont( aFont );
- Point aStartPt( aOutSize.Width()/2, aOutSize.Height()-1 );
- if( (nWinStyle & WB_VCENTER) )
- aStartPt.Y() -= (aOutSize.Height() - nWidth)/2;
- Point aTextPt( aStartPt );
- aTextPt.X() -= GetTextHeight()/2;
- DrawText( aTextPt, aText, 0, aText.getLength(), pVector, pDisplayText );
- Pop();
- if( aOutSize.Height() - aStartPt.Y() > FIXEDLINE_TEXT_BORDER )
- aDecoView.DrawSeparator( Point( aStartPt.X(), aOutSize.Height()-1 ),
- Point( aStartPt.X(), aStartPt.Y() + FIXEDLINE_TEXT_BORDER ) );
- if( aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER > 0 )
- aDecoView.DrawSeparator( Point( aStartPt.X(), aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER ),
- Point( aStartPt.X(), 0 ) );
+ long nWidth = rRenderContext.GetTextWidth(aText);
+ rRenderContext.Push(PushFlags::FONT);
+ vcl::Font aFont(rRenderContext.GetFont());
+ aFont.SetOrientation(00);
+ SetFont(aFont);
+ Point aStartPt(aOutSize.Width() / 2, aOutSize.Height() - 1);
+ if (nWinStyle & WB_VCENTER)
+ aStartPt.Y() -= (aOutSize.Height() - nWidth) / 2;
+ Point aTextPt(aStartPt);
+ aTextPt.X() -= GetTextHeight() / 2;
+ rRenderContext.DrawText(aTextPt, aText, 0, aText.getLength(), pVector, pDisplayText);
+ rRenderContext.Pop();
+ if (aOutSize.Height() - aStartPt.Y() > FIXEDLINE_TEXT_BORDER)
+ aDecoView.DrawSeparator(Point(aStartPt.X(), aOutSize.Height() - 1),
+ Point(aStartPt.X(), aStartPt.Y() + FIXEDLINE_TEXT_BORDER));
+ if (aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER > 0)
+ aDecoView.DrawSeparator(Point(aStartPt.X(), aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER),
+ Point(aStartPt.X(), 0));
}
else
{
- sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS;
- Rectangle aRect( 0, 0, aOutSize.Width(), aOutSize.Height() );
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- if( (nWinStyle & WB_CENTER) )
+ sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS;
+ Rectangle aRect(0, 0, aOutSize.Width(), aOutSize.Height());
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ if (nWinStyle & WB_CENTER)
nStyle |= TEXT_DRAW_CENTER;
- if ( !IsEnabled() )
+ if (!IsEnabled())
nStyle |= TEXT_DRAW_DISABLE;
- if ( GetStyle() & WB_NOLABEL )
+ if (GetStyle() & WB_NOLABEL)
nStyle &= ~TEXT_DRAW_MNEMONIC;
- if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
+ if (rStyleSettings.GetOptions() & STYLE_OPTION_MONO)
nStyle |= TEXT_DRAW_MONO;
- DrawControlText( *this, aRect, aText, nStyle, pVector, pDisplayText );
+ DrawControlText(*this, aRect, aText, nStyle, pVector, pDisplayText);
- if( !pVector )
+ if (!pVector)
{
- long nTop = aRect.Top() + ((aRect.GetHeight()-1)/2);
- aDecoView.DrawSeparator( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop ), Point( aOutSize.Width()-1, nTop ), false );
- if( aRect.Left() > FIXEDLINE_TEXT_BORDER )
- aDecoView.DrawSeparator( Point( 0, nTop ), Point( aRect.Left()-FIXEDLINE_TEXT_BORDER, nTop ), false );
+ long nTop = aRect.Top() + ((aRect.GetHeight() - 1) / 2);
+ aDecoView.DrawSeparator(Point(aRect.Right() + FIXEDLINE_TEXT_BORDER, nTop), Point(aOutSize.Width() - 1, nTop), false);
+ if (aRect.Left() > FIXEDLINE_TEXT_BORDER)
+ aDecoView.DrawSeparator(Point(0, nTop), Point(aRect.Left() - FIXEDLINE_TEXT_BORDER, nTop), false);
}
}
}
commit b35a9f8613f27b550ea69d3aa6562a2e08a3bdca
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu Apr 30 18:53:41 2015 +0900
refactor to use RenderContext for vcl StatusBar
Change-Id: I3f3797d323ea6f438d4fdcb7f89c28b658e75b57
diff --git a/include/vcl/status.hxx b/include/vcl/status.hxx
index 50b52f9..782316b 100644
--- a/include/vcl/status.hxx
+++ b/include/vcl/status.hxx
@@ -101,11 +101,13 @@ private:
SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
SAL_DLLPRIVATE void ImplFormat();
SAL_DLLPRIVATE bool ImplIsItemUpdate();
- using OutputDevice::ImplDrawText;
- SAL_DLLPRIVATE void ImplDrawText( bool bOffScreen, long nOldTextWidth );
- SAL_DLLPRIVATE void ImplDrawItem( bool bOffScreen, sal_uInt16 nPos, bool bDrawText, bool bDrawFrame );
- SAL_DLLPRIVATE void ImplDrawProgress( bool bPaint,
- sal_uInt16 nOldPerc, sal_uInt16 nNewPerc );
+
+ SAL_DLLPRIVATE void ImplDrawText(vcl::RenderContext& rRenderContext, bool bOffScreen,
+ long nOldTextWidth);
+ SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen,
+ sal_uInt16 nPos, bool bDrawText, bool bDrawFrame);
+ SAL_DLLPRIVATE void ImplDrawProgress(vcl::RenderContext& rRenderContext, bool bPaint,
+ sal_uInt16 nOldPerc, sal_uInt16 nNewPerc);
SAL_DLLPRIVATE void ImplCalcProgressRect();
SAL_DLLPRIVATE Rectangle ImplGetItemRectPos( sal_uInt16 nPos ) const;
SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisiblePos() const;
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 37397f9..53d48b9 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -334,7 +334,7 @@ sal_uInt16 StatusBar::ImplGetFirstVisiblePos() const
return SAL_MAX_UINT16;
}
-void StatusBar::ImplDrawText( bool bOffScreen, long nOldTextWidth )
+void StatusBar::ImplDrawText(vcl::RenderContext& /*rRenderContext*/, bool bOffScreen, long nOldTextWidth)
{
// prevent item box from being overwritten
Rectangle aTextRect;
@@ -369,7 +369,7 @@ void StatusBar::ImplDrawText( bool bOffScreen, long nOldTextWidth )
}
}
-void StatusBar::ImplDrawItem( bool bOffScreen, sal_uInt16 nPos, bool bDrawText, bool bDrawFrame )
+void StatusBar::ImplDrawItem(vcl::RenderContext& /*rRenderContext*/, bool bOffScreen, sal_uInt16 nPos, bool bDrawText, bool bDrawFrame)
{
Rectangle aRect = ImplGetItemRectPos( nPos );
@@ -584,17 +584,17 @@ void DrawProgress( vcl::Window* pWindow, const Point& rPos,
}
}
-void StatusBar::ImplDrawProgress( bool bPaint,
- sal_uInt16 nPercent1, sal_uInt16 nPercent2 )
+void StatusBar::ImplDrawProgress(vcl::RenderContext& rRenderContext, bool bPaint,
+ sal_uInt16 nPercent1, sal_uInt16 nPercent2)
{
bool bNative = IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL );
// bPaint: draw text also, else only update progress
- if ( bPaint )
+ if (bPaint)
{
DrawText( maPrgsTxtPos, maPrgsTxt );
if( ! bNative )
{
- DecorationView aDecoView( this );
+ DecorationView aDecoView(&rRenderContext);
aDecoView.DrawFrame( maPrgsFrameRect, FRAME_DRAW_IN );
}
}
@@ -607,8 +607,8 @@ void StatusBar::ImplDrawProgress( bool bPaint,
aPos = maPrgsFrameRect.TopLeft();
nPrgsHeight = maPrgsFrameRect.GetHeight();
}
- DrawProgress( this, aPos, mnPrgsSize/2, mnPrgsSize, nPrgsHeight,
- nPercent1*100, nPercent2*100, mnPercentCount, maPrgsFrameRect );
+ DrawProgress( this, aPos, mnPrgsSize / 2, mnPrgsSize, nPrgsHeight,
+ nPercent1 * 100, nPercent2 * 100, mnPercentCount, maPrgsFrameRect );
}
void StatusBar::ImplCalcProgressRect()
@@ -700,7 +700,7 @@ void StatusBar::MouseButtonDown( const MouseEvent& rMEvt )
}
}
-void StatusBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void StatusBar::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
if ( mbFormat )
ImplFormat();
@@ -708,18 +708,18 @@ void StatusBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle&
sal_uInt16 nItemCount = sal_uInt16( mpItemList->size() );
if ( mbProgressMode )
- ImplDrawProgress( true, 0, mnPercent );
+ ImplDrawProgress(rRenderContext, true, 0, mnPercent);
else
{
// draw text
if ( !mbVisibleItems || (GetStyle() & WB_RIGHT) )
- ImplDrawText( false, 0 );
+ ImplDrawText(rRenderContext, false, 0);
// draw items
if ( mbVisibleItems )
{
for ( sal_uInt16 i = 0; i < nItemCount; i++ )
- ImplDrawItem( false, i, true, true );
+ ImplDrawItem(rRenderContext, false, i, true, true);
}
}
@@ -1166,7 +1166,7 @@ void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText )
if ( pItem->mbVisible && !mbFormat && ImplIsItemUpdate() )
{
Update();
- ImplDrawItem( true, nPos, true, false );
+ ImplDrawItem(*this, true, nPos, true, false);
Flush();
}
}
@@ -1219,7 +1219,7 @@ void StatusBar::SetItemData( sal_uInt16 nItemId, void* pNewData )
!mbFormat && ImplIsItemUpdate() )
{
Update();
- ImplDrawItem( true, nPos, false, false );
+ ImplDrawItem(*this, true, nPos, false, false);
Flush();
}
}
@@ -1249,7 +1249,7 @@ void StatusBar::RedrawItem( sal_uInt16 nItemId )
pItem->mbVisible && ImplIsItemUpdate() )
{
Update();
- ImplDrawItem( true, nPos, false, false );
+ ImplDrawItem(*this, true, nPos, false, false);
Flush();
}
}
@@ -1364,7 +1364,7 @@ void StatusBar::SetProgressValue( sal_uInt16 nNewPercent )
{
Update();
SetLineColor();
- ImplDrawProgress( false, mnPercent, nNewPercent );
+ ImplDrawProgress(*this, false, mnPercent, nNewPercent);
Flush();
}
mnPercent = nNewPercent;
@@ -1402,7 +1402,7 @@ void StatusBar::SetText( const OUString& rText )
Update();
long nOldTextWidth = GetTextWidth( GetText() );
Window::SetText( rText );
- ImplDrawText( true, nOldTextWidth );
+ ImplDrawText(*this, true, nOldTextWidth);
Flush();
}
}
More information about the Libreoffice-commits
mailing list