Kaydet (Commit) d28e29c8 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor ToolBarMenu to use RenderContext

Change-Id: I26c5ad18445faeb55961030edc9f1daab2edab59
üst dfb70a8f
...@@ -46,9 +46,9 @@ class SVT_DLLPUBLIC ToolbarMenu : public DockingWindow ...@@ -46,9 +46,9 @@ class SVT_DLLPUBLIC ToolbarMenu : public DockingWindow
friend class ToolbarMenuStatusListener; friend class ToolbarMenuStatusListener;
friend struct ToolbarMenu_Impl; friend struct ToolbarMenu_Impl;
public: public:
ToolbarMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, ToolbarMenu(const css::uno::Reference<css::frame::XFrame>& rFrame,
vcl::Window* pParentWindow, vcl::Window* pParentWindow,
WinBits nBits ); WinBits nBits );
virtual ~ToolbarMenu(); virtual ~ToolbarMenu();
virtual void dispose() SAL_OVERRIDE; virtual void dispose() SAL_OVERRIDE;
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
void highlightFirstEntry(); void highlightFirstEntry();
protected: protected:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE; virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE;
// todo: move to new base class that will replace SfxPopupWindow // todo: move to new base class that will replace SfxPopupWindow
void AddStatusListener( const OUString& rCommandURL ); void AddStatusListener( const OUString& rCommandURL );
...@@ -99,7 +99,7 @@ protected: ...@@ -99,7 +99,7 @@ protected:
// Forwared from XStatusListener (subclasses must override this one to get // Forwared from XStatusListener (subclasses must override this one to get
// the status updates): // the status updates):
virtual void statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); virtual void statusChanged(const css::frame::FeatureStateEvent& Event ) throw (css::uno::RuntimeException);
void StateChanged( StateChangedType nType ) SAL_OVERRIDE; void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE; void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
...@@ -109,17 +109,17 @@ private: ...@@ -109,17 +109,17 @@ private:
void initStatusListener(); void initStatusListener();
void implInit( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); void implInit(const css::uno::Reference<css::frame::XFrame>& rFrame);
void initWindow(); void initWindow();
Size implCalcSize(); Size implCalcSize();
void appendEntry( ToolbarMenuEntry* pEntry ); void appendEntry(ToolbarMenuEntry* pEntry);
void implPaint( ToolbarMenuEntry* pThisOnly = NULL, bool bHighlight = false ); void implPaint(vcl::RenderContext& rRenderContext, ToolbarMenuEntry* pThisOnly = NULL, bool bHighlight = false);
void implHighlightEntry( int nHighlightEntry, bool bHighlight ); void implHighlightEntry(vcl::RenderContext& rRenderContext, int nHighlightEntry, bool bHighlight);
void implHighlightEntry( const MouseEvent& rMEvt, bool bMBDown ); void implHighlightAtPosition(const MouseEvent& rMEvt, bool bMBDown);
void implChangeHighlightEntry( int nEntry ); void implChangeHighlightEntry( int nEntry );
void implSelectEntry( int nSelectedEntry ); void implSelectEntry( int nSelectedEntry );
......
...@@ -39,8 +39,6 @@ using namespace ::com::sun::star::accessibility; ...@@ -39,8 +39,6 @@ using namespace ::com::sun::star::accessibility;
namespace svtools { namespace svtools {
static vcl::Window* GetTopMostParentSystemWindow( vcl::Window* pWindow ) static vcl::Window* GetTopMostParentSystemWindow( vcl::Window* pWindow )
{ {
OSL_ASSERT( pWindow ); OSL_ASSERT( pWindow );
...@@ -372,7 +370,7 @@ void ToolbarMenu_Impl::clearAccessibleSelection() ...@@ -372,7 +370,7 @@ void ToolbarMenu_Impl::clearAccessibleSelection()
{ {
if( mnHighlightedEntry != -1 ) if( mnHighlightedEntry != -1 )
{ {
mrMenu.implHighlightEntry( mnHighlightedEntry, false ); mrMenu.Invalidate();
mnHighlightedEntry = -1; mnHighlightedEntry = -1;
} }
} }
...@@ -580,7 +578,7 @@ void ToolbarMenu::initWindow() ...@@ -580,7 +578,7 @@ void ToolbarMenu::initWindow()
static long ImplGetNativeCheckAndRadioSize( vcl::Window* pWin, long& rCheckHeight, long& rRadioHeight, long &rMaxWidth ) static long ImplGetNativeCheckAndRadioSize(vcl::RenderContext& rRenderContext, long& rCheckHeight, long& rRadioHeight, long &rMaxWidth )
{ {
rMaxWidth = rCheckHeight = rRadioHeight = 0; rMaxWidth = rCheckHeight = rRadioHeight = 0;
...@@ -589,32 +587,22 @@ static long ImplGetNativeCheckAndRadioSize( vcl::Window* pWin, long& rCheckHeigh ...@@ -589,32 +587,22 @@ static long ImplGetNativeCheckAndRadioSize( vcl::Window* pWin, long& rCheckHeigh
Rectangle aNativeContent; Rectangle aNativeContent;
Point tmp( 0, 0 ); Point tmp( 0, 0 );
Rectangle aCtrlRegion( tmp, Size( 100, 15 ) ); Rectangle aCtrlRegion( tmp, Size( 100, 15 ) );
if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK ) ) if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK))
{ {
if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), if (rRenderContext.GetNativeControlRegion(ControlType(CTRL_MENU_POPUP), ControlPart(PART_MENU_ITEM_CHECK_MARK),
ControlPart(PART_MENU_ITEM_CHECK_MARK), aCtrlRegion, ControlState(ControlState::ENABLED), aVal, OUString(),
aCtrlRegion, aNativeBounds, aNativeContent)
ControlState(ControlState::ENABLED),
aVal,
OUString(),
aNativeBounds,
aNativeContent )
) )
{ {
rCheckHeight = aNativeBounds.GetHeight(); rCheckHeight = aNativeBounds.GetHeight();
rMaxWidth = aNativeContent.GetWidth(); rMaxWidth = aNativeContent.GetWidth();
} }
} }
if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK ) ) if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK))
{ {
if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), if (rRenderContext.GetNativeControlRegion(ControlType(CTRL_MENU_POPUP), ControlPart(PART_MENU_ITEM_RADIO_MARK),
ControlPart(PART_MENU_ITEM_RADIO_MARK), aCtrlRegion, ControlState(ControlState::ENABLED), aVal, OUString(),
aCtrlRegion, aNativeBounds, aNativeContent)
ControlState(ControlState::ENABLED),
aVal,
OUString(),
aNativeBounds,
aNativeContent )
) )
{ {
rRadioHeight = aNativeBounds.GetHeight(); rRadioHeight = aNativeBounds.GetHeight();
...@@ -693,13 +681,12 @@ Size ToolbarMenu::implCalcSize() ...@@ -693,13 +681,12 @@ Size ToolbarMenu::implCalcSize()
if( pEntry->HasCheck() && !pEntry->mbHasImage ) if( pEntry->HasCheck() && !pEntry->mbHasImage )
{ {
if( this->IsNativeControlSupported( CTRL_MENU_POPUP, if (IsNativeControlSupported(CTRL_MENU_POPUP, (pEntry->mnBits & MenuItemBits::RADIOCHECK)
(pEntry->mnBits & MenuItemBits::RADIOCHECK)
? PART_MENU_ITEM_CHECK_MARK ? PART_MENU_ITEM_CHECK_MARK
: PART_MENU_ITEM_RADIO_MARK ) ) : PART_MENU_ITEM_RADIO_MARK ) )
{ {
long nCheckHeight = 0, nRadioHeight = 0, nMaxCheckWidth = 0; long nCheckHeight = 0, nRadioHeight = 0, nMaxCheckWidth = 0;
ImplGetNativeCheckAndRadioSize( this, nCheckHeight, nRadioHeight, nMaxCheckWidth ); ImplGetNativeCheckAndRadioSize(*this, nCheckHeight, nRadioHeight, nMaxCheckWidth);
long nCtrlHeight = (pEntry->mnBits & MenuItemBits::RADIOCHECK) ? nCheckHeight : nRadioHeight; long nCtrlHeight = (pEntry->mnBits & MenuItemBits::RADIOCHECK) ? nCheckHeight : nRadioHeight;
nMaxTextWidth += nCtrlHeight + gfxExtra; nMaxTextWidth += nCtrlHeight + gfxExtra;
...@@ -724,7 +711,7 @@ Size ToolbarMenu::implCalcSize() ...@@ -724,7 +711,7 @@ Size ToolbarMenu::implCalcSize()
{ {
ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry]; ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry];
if( pEntry ) if (pEntry)
{ {
pEntry->maSize.Width() = nMaxTextWidth; pEntry->maSize.Width() = nMaxTextWidth;
...@@ -807,9 +794,9 @@ void ToolbarMenu::appendEntry( int nEntryId, Control* pControl, MenuItemBits nIt ...@@ -807,9 +794,9 @@ void ToolbarMenu::appendEntry( int nEntryId, Control* pControl, MenuItemBits nIt
void ToolbarMenu::appendEntry( ToolbarMenuEntry* pEntry ) void ToolbarMenu::appendEntry( ToolbarMenuEntry* pEntry )
{ {
mpImpl->maEntryVector.push_back( pEntry ); mpImpl->maEntryVector.push_back(pEntry);
mpImpl->maSize = implCalcSize(); mpImpl->maSize = implCalcSize();
if( IsVisible() ) if (IsVisible())
Invalidate(); Invalidate();
} }
...@@ -859,25 +846,26 @@ ToolbarMenuEntry* ToolbarMenu::implSearchEntry( int nEntryId ) const ...@@ -859,25 +846,26 @@ ToolbarMenuEntry* ToolbarMenu::implSearchEntry( int nEntryId ) const
void ToolbarMenu::implHighlightEntry( int nHighlightEntry, bool bHighlight ) void ToolbarMenu::implHighlightEntry(vcl::RenderContext& rRenderContext, int nHighlightEntry, bool bHighlight)
{ {
Size aSz( GetOutputSizePixel() ); Size aSz(rRenderContext.GetOutputSizePixel());
long nX = 0, nY = 0; long nX = 0;
long nY = 0;
const int nEntryCount = mpImpl->maEntryVector.size(); const int nEntryCount = mpImpl->maEntryVector.size();
int nEntry;
for( nEntry = 0; nEntry < nEntryCount; nEntry++ ) for (int nEntry = 0; nEntry < nEntryCount; nEntry++)
{ {
ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry]; ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry];
if( pEntry && (nEntry == nHighlightEntry) ) if (pEntry && (nEntry == nHighlightEntry))
{ {
// no highlights for controls only items // no highlights for controls only items
if( pEntry->mpControl ) if (pEntry->mpControl)
{ {
if( !bHighlight ) if (!bHighlight)
{ {
ValueSet* pValueSet = dynamic_cast< ValueSet* >( pEntry->mpControl.get() ); ValueSet* pValueSet = dynamic_cast<ValueSet*>(pEntry->mpControl.get());
if( pValueSet ) if (pValueSet)
{ {
pValueSet->SetNoSelection(); pValueSet->SetNoSelection();
} }
...@@ -889,62 +877,62 @@ void ToolbarMenu::implHighlightEntry( int nHighlightEntry, bool bHighlight ) ...@@ -889,62 +877,62 @@ void ToolbarMenu::implHighlightEntry( int nHighlightEntry, bool bHighlight )
Color oldLineColor; Color oldLineColor;
bool bDrawItemRect = true; bool bDrawItemRect = true;
Rectangle aItemRect( Point( nX, nY ), Size( aSz.Width(), pEntry->maSize.Height() ) ); Rectangle aItemRect(Point(nX, nY), Size(aSz.Width(), pEntry->maSize.Height()));
if ( pEntry->mnBits & MenuItemBits::POPUPSELECT ) if (pEntry->mnBits & MenuItemBits::POPUPSELECT)
{ {
long nFontHeight = GetTextHeight(); long nFontHeight = GetTextHeight();
aItemRect.Right() -= nFontHeight + nFontHeight/4; aItemRect.Right() -= nFontHeight + nFontHeight / 4;
} }
if( IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ) ) if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL))
{ {
Size aPxSize( GetOutputSizePixel() ); Size aPxSize(rRenderContext.GetOutputSizePixel());
Push( PushFlags::CLIPREGION ); rRenderContext.Push(PushFlags::CLIPREGION);
IntersectClipRegion( Rectangle( Point( nX, nY ), Size( aSz.Width(), pEntry->maSize.Height() ) ) ); rRenderContext.IntersectClipRegion(Rectangle(Point(nX, nY), Size(aSz.Width(), pEntry->maSize.Height())));
Rectangle aCtrlRect( Point( nX, 0 ), Size( aPxSize.Width()-nX, aPxSize.Height() ) ); Rectangle aCtrlRect(Point(nX, 0), Size(aPxSize.Width() - nX, aPxSize.Height()));
DrawNativeControl( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, aCtrlRect,
aCtrlRect, ControlState::ENABLED, ImplControlValue(), OUString());
ControlState::ENABLED, if (bHighlight && rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM))
ImplControlValue(),
OUString() );
if( bHighlight && IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM ) )
{ {
bDrawItemRect = false; bDrawItemRect = false;
if( !DrawNativeControl( CTRL_MENU_POPUP, PART_MENU_ITEM, ControlState eState = ControlState::SELECTED | (pEntry->mbEnabled ? ControlState::ENABLED : ControlState::NONE);
aItemRect, if (!rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_MENU_ITEM, aItemRect,
ControlState::SELECTED | ( pEntry->mbEnabled ? ControlState::ENABLED : ControlState::NONE ), eState, ImplControlValue(), OUString()))
ImplControlValue(),
OUString() ) )
{ {
bDrawItemRect = bHighlight; bDrawItemRect = bHighlight;
} }
} }
else else
{
bDrawItemRect = bHighlight; bDrawItemRect = bHighlight;
Pop(); }
rRenderContext.Pop();
} }
if( bDrawItemRect ) if (bDrawItemRect)
{ {
if ( bHighlight ) if (bHighlight)
{ {
if( pEntry->mbEnabled ) if (pEntry->mbEnabled)
SetFillColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() ); {
rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor());
}
else else
{ {
SetFillColor(); rRenderContext.SetFillColor();
oldLineColor = GetLineColor(); oldLineColor = rRenderContext.GetLineColor();
SetLineColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() ); rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor());
bRestoreLineColor = true; bRestoreLineColor = true;
} }
} }
else else
SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() ); {
rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
DrawRect( aItemRect ); }
rRenderContext.DrawRect(aItemRect);
} }
implPaint( pEntry, bHighlight ); implPaint(rRenderContext, pEntry, bHighlight);
if( bRestoreLineColor ) if (bRestoreLineColor)
SetLineColor( oldLineColor ); rRenderContext.SetLineColor(oldLineColor);
break; break;
} }
...@@ -970,9 +958,8 @@ void ToolbarMenu::implSelectEntry( int nSelectedEntry ) ...@@ -970,9 +958,8 @@ void ToolbarMenu::implSelectEntry( int nSelectedEntry )
void ToolbarMenu::MouseButtonDown( const MouseEvent& rMEvt ) void ToolbarMenu::MouseButtonDown( const MouseEvent& rMEvt )
{ {
implHighlightEntry( rMEvt, true ); implHighlightAtPosition(rMEvt, true);
implSelectEntry(mpImpl->mnHighlightedEntry);
implSelectEntry( mpImpl->mnHighlightedEntry );
} }
...@@ -985,15 +972,15 @@ void ToolbarMenu::MouseButtonUp( const MouseEvent& ) ...@@ -985,15 +972,15 @@ void ToolbarMenu::MouseButtonUp( const MouseEvent& )
void ToolbarMenu::MouseMove( const MouseEvent& rMEvt ) void ToolbarMenu::MouseMove( const MouseEvent& rMEvt )
{ {
if ( !IsVisible() ) if (!IsVisible())
return; return;
implHighlightEntry( rMEvt, false ); implHighlightAtPosition(rMEvt, false);
} }
void ToolbarMenu::implHighlightEntry( const MouseEvent& rMEvt, bool /*bMBDown*/ ) void ToolbarMenu::implHighlightAtPosition(const MouseEvent& rMEvt, bool /*bMBDown*/)
{ {
long nMouseY = rMEvt.GetPosPixel().Y(); long nMouseY = rMEvt.GetPosPixel().Y();
Size aOutSz = GetOutputSizePixel(); Size aOutSz = GetOutputSizePixel();
...@@ -1040,21 +1027,11 @@ void ToolbarMenu::implHighlightEntry( const MouseEvent& rMEvt, bool /*bMBDown*/ ...@@ -1040,21 +1027,11 @@ void ToolbarMenu::implHighlightEntry( const MouseEvent& rMEvt, bool /*bMBDown*/
void ToolbarMenu::implChangeHighlightEntry( int nEntry ) void ToolbarMenu::implChangeHighlightEntry(int nEntry)
{ {
if( mpImpl->mnHighlightedEntry != -1 )
{
implHighlightEntry( mpImpl->mnHighlightedEntry, false );
}
mpImpl->mnHighlightedEntry = nEntry; mpImpl->mnHighlightedEntry = nEntry;
Invalidate(); Invalidate();
if( mpImpl->mnHighlightedEntry != -1 )
{
implHighlightEntry( mpImpl->mnHighlightedEntry, true );
}
mpImpl->notifyHighlightedEntry(); mpImpl->notifyHighlightedEntry();
} }
...@@ -1279,113 +1256,111 @@ void ToolbarMenu::KeyInput( const KeyEvent& rKEvent ) ...@@ -1279,113 +1256,111 @@ void ToolbarMenu::KeyInput( const KeyEvent& rKEvent )
} }
static void ImplPaintCheckBackground( vcl::Window* i_pWindow, const Rectangle& i_rRect, bool i_bHighlight ) static void ImplPaintCheckBackground(vcl::RenderContext& rRenderContext, vcl::Window& rWindow, const Rectangle& i_rRect, bool i_bHighlight )
{ {
bool bNativeOk = false; bool bNativeOk = false;
if( i_pWindow->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) if (rRenderContext.IsNativeControlSupported(CTRL_TOOLBAR, PART_BUTTON))
{ {
ImplControlValue aControlValue; ImplControlValue aControlValue;
ControlState nState = ControlState::PRESSED | ControlState::ENABLED; ControlState nState = ControlState::PRESSED | ControlState::ENABLED;
aControlValue.setTristateVal( BUTTONVALUE_ON ); aControlValue.setTristateVal(BUTTONVALUE_ON);
bNativeOk = i_pWindow->DrawNativeControl( CTRL_TOOLBAR, PART_BUTTON, bNativeOk = rRenderContext.DrawNativeControl(CTRL_TOOLBAR, PART_BUTTON,
i_rRect, nState, aControlValue, i_rRect, nState, aControlValue, OUString());
OUString() );
} }
if( ! bNativeOk ) if (!bNativeOk)
{ {
const StyleSettings& rSettings = i_pWindow->GetSettings().GetStyleSettings(); const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
Color aColor( i_bHighlight ? rSettings.GetMenuHighlightTextColor() : rSettings.GetHighlightColor() ); Color aColor(i_bHighlight ? rSettings.GetMenuHighlightTextColor() : rSettings.GetHighlightColor());
i_pWindow->DrawSelectionBackground( i_rRect, 0, i_bHighlight, true, false, 2, NULL, &aColor ); vcl::RenderTools::DrawSelectionBackground(rRenderContext, rWindow, i_rRect, 0, i_bHighlight, true, false, NULL, 2, &aColor);
} }
} }
void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted ) void ToolbarMenu::implPaint(vcl::RenderContext& rRenderContext, ToolbarMenuEntry* pThisOnly, bool bHighlighted)
{ {
sal_uInt16 nBorder = 0; long nStartY = 0; // from Menu implementations, needed when we support native menu background & scrollable menu sal_uInt16 nBorder = 0; long nStartY = 0; // from Menu implementations, needed when we support native menu background & scrollable menu
long nFontHeight = GetTextHeight(); long nFontHeight = GetTextHeight();
// long nExtra = nFontHeight/4;
long nCheckHeight = 0, nRadioHeight = 0, nMaxCheckWidth = 0; long nCheckHeight = 0, nRadioHeight = 0, nMaxCheckWidth = 0;
ImplGetNativeCheckAndRadioSize( this, nCheckHeight, nRadioHeight, nMaxCheckWidth ); ImplGetNativeCheckAndRadioSize(rRenderContext, nCheckHeight, nRadioHeight, nMaxCheckWidth);
DecorationView aDecoView( this ); DecorationView aDecoView(&rRenderContext);
const StyleSettings& rSettings = GetSettings().GetStyleSettings(); const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
const bool bUseImages = rSettings.GetUseImagesInMenus(); const bool bUseImages = rSettings.GetUseImagesInMenus();
int nOuterSpace = 0; // ImplGetSVData()->maNWFData.mnMenuFormatExtraBorder; int nOuterSpace = 0; // ImplGetSVData()->maNWFData.mnMenuFormatExtraBorder;
Point aTopLeft( nOuterSpace, nOuterSpace ), aTmpPos; Point aTopLeft(nOuterSpace, nOuterSpace), aTmpPos;
Size aOutSz( GetOutputSizePixel() ); Size aOutSz(rRenderContext.GetOutputSizePixel());
const int nEntryCount = mpImpl->maEntryVector.size(); const int nEntryCount = mpImpl->maEntryVector.size();
int nEntry; int nEntry;
for( nEntry = 0; nEntry < nEntryCount; nEntry++ ) for (nEntry = 0; nEntry < nEntryCount; nEntry++)
{ {
ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry]; ToolbarMenuEntry* pEntry = mpImpl->maEntryVector[nEntry];
Point aPos( aTopLeft ); Point aPos(aTopLeft);
aPos.Y() += nBorder; aPos.Y() += nBorder;
aPos.Y() += nStartY; aPos.Y() += nStartY;
if ((pEntry == 0) && !pThisOnly)
if( (pEntry == 0) && !pThisOnly )
{ {
// Separator // Separator
aTmpPos.Y() = aPos.Y() + ((SEPARATOR_HEIGHT-2)/2); aTmpPos.Y() = aPos.Y() + ((SEPARATOR_HEIGHT - 2) / 2);
aTmpPos.X() = aPos.X() + 2 + nOuterSpace; aTmpPos.X() = aPos.X() + 2 + nOuterSpace;
SetLineColor( rSettings.GetShadowColor() ); rRenderContext.SetLineColor(rSettings.GetShadowColor());
DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpace, aTmpPos.Y() ) ); rRenderContext.DrawLine(aTmpPos, Point(aOutSz.Width() - 3 - 2 * nOuterSpace, aTmpPos.Y()));
aTmpPos.Y()++; aTmpPos.Y()++;
SetLineColor( rSettings.GetLightColor() ); rRenderContext.SetLineColor(rSettings.GetLightColor());
DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpace, aTmpPos.Y() ) ); rRenderContext.DrawLine(aTmpPos, Point( aOutSz.Width() - 3 - 2 * nOuterSpace, aTmpPos.Y()));
SetLineColor(); rRenderContext.SetLineColor();
} }
else if( !pThisOnly || ( pEntry == pThisOnly ) ) else if (!pThisOnly || (pEntry == pThisOnly))
{ {
const bool bTitle = pEntry->mnEntryId == TITLE_ID; const bool bTitle = pEntry->mnEntryId == TITLE_ID;
if ( pThisOnly && bHighlighted ) if (pThisOnly && bHighlighted)
SetTextColor( rSettings.GetMenuHighlightTextColor() ); rRenderContext.SetTextColor(rSettings.GetMenuHighlightTextColor());
if( aPos.Y() >= 0 ) if( aPos.Y() >= 0 )
{ {
long nTextOffsetY = ((pEntry->maSize.Height()-nFontHeight)/2); long nTextOffsetY = ((pEntry->maSize.Height() - nFontHeight) / 2);
sal_uInt16 nTextStyle = 0; sal_uInt16 nTextStyle = 0;
DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE; DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
sal_uInt16 nImageStyle = 0; sal_uInt16 nImageStyle = 0;
if( !pEntry->mbEnabled ) if (!pEntry->mbEnabled)
{ {
nTextStyle |= TEXT_DRAW_DISABLE; nTextStyle |= TEXT_DRAW_DISABLE;
nSymbolStyle |= DrawSymbolFlags::Disable; nSymbolStyle |= DrawSymbolFlags::Disable;
nImageStyle |= IMAGE_DRAW_DISABLE; nImageStyle |= IMAGE_DRAW_DISABLE;
} }
Rectangle aOuterCheckRect( Point( aPos.X()+mpImpl->mnCheckPos, aPos.Y() ), Size( pEntry->maSize.Height(), pEntry->maSize.Height() ) ); Rectangle aOuterCheckRect(Point(aPos.X() + mpImpl->mnCheckPos, aPos.Y()),
aOuterCheckRect.Left() += 1; Size(pEntry->maSize.Height(), pEntry->maSize.Height()));
aOuterCheckRect.Right() -= 1; aOuterCheckRect.Left() += 1;
aOuterCheckRect.Top() += 1; aOuterCheckRect.Right() -= 1;
aOuterCheckRect.Bottom() -= 1; aOuterCheckRect.Top() += 1;
aOuterCheckRect.Bottom() -= 1;
if( bTitle ) if (bTitle)
{ {
// fill the background // fill the background
Rectangle aRect( aTopLeft, Size( aOutSz.Width(), pEntry->maSize.Height() ) ); Rectangle aRect(aTopLeft, Size(aOutSz.Width(), pEntry->maSize.Height()));
SetFillColor(rSettings.GetDialogColor()); rRenderContext.SetFillColor(rSettings.GetDialogColor());
SetLineColor(); rRenderContext.SetLineColor();
DrawRect(aRect); rRenderContext.DrawRect(aRect);
SetLineColor( rSettings.GetLightColor() ); rRenderContext.SetLineColor(rSettings.GetLightColor());
DrawLine( aRect.TopLeft(), aRect.TopRight() ); rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight());
SetLineColor( rSettings.GetShadowColor() ); rRenderContext.SetLineColor(rSettings.GetShadowColor());
DrawLine( aRect.BottomLeft(), aRect.BottomRight() ); rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
} }
// CheckMark // CheckMark
if ( pEntry->HasCheck() ) if (pEntry->HasCheck())
{ {
// draw selection transparent marker if checked // draw selection transparent marker if checked
// onto that either a checkmark or the item image // onto that either a checkmark or the item image
...@@ -1393,12 +1368,12 @@ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted ) ...@@ -1393,12 +1368,12 @@ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted )
// however do not do this if native checks will be painted since // however do not do this if native checks will be painted since
// the selection color too often does not fit the theme's check and/or radio // the selection color too often does not fit the theme's check and/or radio
if( !pEntry->mbHasImage ) if (!pEntry->mbHasImage)
{ {
if( this->IsNativeControlSupported( CTRL_MENU_POPUP, if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP,
(pEntry->mnBits & MenuItemBits::RADIOCHECK) (pEntry->mnBits & MenuItemBits::RADIOCHECK)
? PART_MENU_ITEM_CHECK_MARK ? PART_MENU_ITEM_CHECK_MARK
: PART_MENU_ITEM_RADIO_MARK ) ) : PART_MENU_ITEM_RADIO_MARK))
{ {
ControlPart nPart = ((pEntry->mnBits & MenuItemBits::RADIOCHECK) ControlPart nPart = ((pEntry->mnBits & MenuItemBits::RADIOCHECK)
? PART_MENU_ITEM_RADIO_MARK ? PART_MENU_ITEM_RADIO_MARK
...@@ -1406,75 +1381,76 @@ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted ) ...@@ -1406,75 +1381,76 @@ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted )
ControlState nState = ControlState::NONE; ControlState nState = ControlState::NONE;
if ( pEntry->mbChecked ) if (pEntry->mbChecked)
nState |= ControlState::PRESSED; nState |= ControlState::PRESSED;
if ( pEntry->mbEnabled ) if (pEntry->mbEnabled)
nState |= ControlState::ENABLED; nState |= ControlState::ENABLED;
if ( bHighlighted ) if ( bHighlighted )
nState |= ControlState::SELECTED; nState |= ControlState::SELECTED;
long nCtrlHeight = (pEntry->mnBits & MenuItemBits::RADIOCHECK) ? nCheckHeight : nRadioHeight; long nCtrlHeight = (pEntry->mnBits & MenuItemBits::RADIOCHECK) ? nCheckHeight : nRadioHeight;
aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - nCtrlHeight)/2; aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - nCtrlHeight) / 2;
aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - nCtrlHeight)/2; aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - nCtrlHeight) / 2;
Rectangle aCheckRect( aTmpPos, Size( nCtrlHeight, nCtrlHeight ) ); Rectangle aCheckRect(aTmpPos, Size(nCtrlHeight, nCtrlHeight));
DrawNativeControl( CTRL_MENU_POPUP, nPart, aCheckRect, nState, ImplControlValue(), OUString() ); rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, nPart, aCheckRect,
aPos.setX( aPos.getX() + nCtrlHeight + gfxExtra ); nState, ImplControlValue(), OUString());
aPos.setX(aPos.getX() + nCtrlHeight + gfxExtra);
} }
else if ( pEntry->mbChecked ) // by default do nothing for unchecked items else if (pEntry->mbChecked) // by default do nothing for unchecked items
{ {
ImplPaintCheckBackground( this, aOuterCheckRect, pThisOnly && bHighlighted ); ImplPaintCheckBackground(rRenderContext, *this, aOuterCheckRect, pThisOnly && bHighlighted);
SymbolType eSymbol; SymbolType eSymbol;
Size aSymbolSize; Size aSymbolSize;
if ( pEntry->mnBits & MenuItemBits::RADIOCHECK ) if (pEntry->mnBits & MenuItemBits::RADIOCHECK)
{ {
eSymbol = SymbolType::RADIOCHECKMARK; eSymbol = SymbolType::RADIOCHECKMARK;
aSymbolSize = Size( nFontHeight/2, nFontHeight/2 ); aSymbolSize = Size(nFontHeight / 2, nFontHeight / 2);
} }
else else
{ {
eSymbol = SymbolType::CHECKMARK; eSymbol = SymbolType::CHECKMARK;
aSymbolSize = Size( (nFontHeight*25)/40, nFontHeight/2 ); aSymbolSize = Size((nFontHeight * 25) / 40, nFontHeight / 2);
} }
aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - aSymbolSize.Width())/2; aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - aSymbolSize.Width())/2;
aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - aSymbolSize.Height())/2; aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - aSymbolSize.Height())/2;
Rectangle aRect( aTmpPos, aSymbolSize ); Rectangle aRect( aTmpPos, aSymbolSize );
aDecoView.DrawSymbol( aRect, eSymbol, GetTextColor(), nSymbolStyle ); aDecoView.DrawSymbol(aRect, eSymbol, GetTextColor(), nSymbolStyle);
aPos.setX( aPos.getX() + aSymbolSize.getWidth( ) + gfxExtra ); aPos.setX(aPos.getX() + aSymbolSize.getWidth( ) + gfxExtra);
} }
} }
} }
// Image: // Image:
if( pEntry->mbHasImage && bUseImages ) if (pEntry->mbHasImage && bUseImages)
{ {
if( pEntry->mbChecked ) if (pEntry->mbChecked)
ImplPaintCheckBackground( this, aOuterCheckRect, pThisOnly && bHighlighted ); ImplPaintCheckBackground(rRenderContext, *this, aOuterCheckRect, pThisOnly && bHighlighted);
aTmpPos = aOuterCheckRect.TopLeft(); aTmpPos = aOuterCheckRect.TopLeft();
aTmpPos.X() += (aOuterCheckRect.GetWidth()-pEntry->maImage.GetSizePixel().Width())/2; aTmpPos.X() += (aOuterCheckRect.GetWidth()-pEntry->maImage.GetSizePixel().Width())/2;
aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pEntry->maImage.GetSizePixel().Height())/2; aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pEntry->maImage.GetSizePixel().Height())/2;
DrawImage( aTmpPos, pEntry->maImage, nImageStyle ); rRenderContext.DrawImage( aTmpPos, pEntry->maImage, nImageStyle );
} }
// Text: // Text:
if( pEntry->mbHasText ) if (pEntry->mbHasText)
{ {
aTmpPos.X() = aPos.X() + (bTitle ? 4 : mpImpl->mnTextPos); aTmpPos.X() = aPos.X() + (bTitle ? 4 : mpImpl->mnTextPos);
aTmpPos.Y() = aPos.Y(); aTmpPos.Y() = aPos.Y();
aTmpPos.Y() += nTextOffsetY; aTmpPos.Y() += nTextOffsetY;
sal_uInt16 nStyle = nTextStyle|TEXT_DRAW_MNEMONIC; sal_uInt16 nStyle = nTextStyle|TEXT_DRAW_MNEMONIC;
DrawCtrlText( aTmpPos, pEntry->maText, 0, pEntry->maText.getLength(), nStyle, NULL, NULL ); // pVector, pDisplayText ); rRenderContext.DrawCtrlText(aTmpPos, pEntry->maText, 0, pEntry->maText.getLength(), nStyle, NULL, NULL);
} }
if ( pThisOnly && bHighlighted ) if (pThisOnly && bHighlighted)
{ {
// This restores the normal menu or menu bar text // This restores the normal menu or menu bar text
// color for when it is no longer highlighted. // color for when it is no longer highlighted.
SetTextColor( rSettings.GetMenuTextColor() ); rRenderContext.SetTextColor(rSettings.GetMenuTextColor());
} }
} }
} }
...@@ -1483,16 +1459,14 @@ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted ) ...@@ -1483,16 +1459,14 @@ void ToolbarMenu::implPaint( ToolbarMenuEntry* pThisOnly, bool bHighlighted )
} }
} }
void ToolbarMenu::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
void ToolbarMenu::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
{ {
SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() ); rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
implPaint(); implPaint(rRenderContext);
if( mpImpl->mnHighlightedEntry != -1 ) if (mpImpl->mnHighlightedEntry != -1)
implHighlightEntry( mpImpl->mnHighlightedEntry, true ); implHighlightEntry(rRenderContext, mpImpl->mnHighlightedEntry, true);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment