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

further refactor Menu to use RenderContext

Change-Id: Ied420c8b3349ff1a2e2951c14359cbe1a23e5141
üst a6c85d74
......@@ -1820,7 +1820,7 @@ void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuIt
{
// for symbols: nFontHeight x nFontHeight
long nFontHeight = pWin->GetTextHeight();
long nExtra = nFontHeight/4;
long nExtra = nFontHeight / 4;
long nCheckHeight = 0, nRadioHeight = 0;
ImplGetNativeCheckAndRadioSize( pWin, nCheckHeight, nRadioHeight );
......
......@@ -408,7 +408,7 @@ void MenuBarWindow::MouseMove( const MouseEvent& rMEvt )
if ( rMEvt.IsLeaveWindow() )
{
if ( nRolloveredItem != ITEMPOS_INVALID && nRolloveredItem != nHighlightedItem )
HighlightItem( nRolloveredItem, false );
Invalidate(); //HighlightItem( nRolloveredItem, false );
nRolloveredItem = ITEMPOS_INVALID;
return;
......@@ -420,10 +420,10 @@ void MenuBarWindow::MouseMove( const MouseEvent& rMEvt )
if ( nRolloveredItem != nEntry )
{
if ( nRolloveredItem != ITEMPOS_INVALID )
HighlightItem( nRolloveredItem, false );
Invalidate(); //HighlightItem( nRolloveredItem, false );
nRolloveredItem = nEntry;
HighlightItem( nRolloveredItem, true );
Invalidate(); //HighlightItem( nRolloveredItem, true );
}
return;
}
......@@ -507,7 +507,7 @@ void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool b
if ( nHighlightedItem != ITEMPOS_INVALID )
{
if ( nHighlightedItem != nRolloveredItem )
HighlightItem( nHighlightedItem, false );
Invalidate(); //HighlightItem( nHighlightedItem, false );
pMenu->ImplCallEventListeners( VCLEVENT_MENU_DEHIGHLIGHT, nHighlightedItem );
}
......@@ -515,9 +515,9 @@ void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool b
nHighlightedItem = (sal_uInt16)n;
DBG_ASSERT( ( nHighlightedItem == ITEMPOS_INVALID ) || pMenu->ImplIsVisible( nHighlightedItem ), "ChangeHighlightItem: Not visible!" );
if ( nHighlightedItem != ITEMPOS_INVALID )
HighlightItem( nHighlightedItem, true );
Invalidate(); //HighlightItem( nHighlightedItem, true );
else if ( nRolloveredItem != ITEMPOS_INVALID )
HighlightItem( nRolloveredItem, true );
Invalidate(); //HighlightItem( nRolloveredItem, true );
pMenu->ImplCallHighlight(nHighlightedItem);
if( mbAutoPopup )
......@@ -581,97 +581,91 @@ static void ImplAddNWFSeparator( vcl::RenderContext& rRenderContext, const Menub
}
}
void MenuBarWindow::HighlightItem(sal_uInt16 nPos, bool bHighlight)
void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHighlight)
{
if( ! pMenu )
if (!pMenu)
return;
long nX = 0;
size_t nCount = pMenu->pItemList->size();
for ( size_t n = 0; n < nCount; n++ )
for (size_t n = 0; n < nCount; n++)
{
MenuItemData* pData = pMenu->pItemList->GetDataFromPos( n );
if ( n == nPos )
if (n == nPos)
{
if ( pData->eType != MenuItemType::SEPARATOR )
if (pData->eType != MenuItemType::SEPARATOR)
{
// #107747# give menuitems the height of the menubar
Rectangle aRect = Rectangle( Point( nX, 1 ), Size( pData->aSz.Width(), GetOutputSizePixel().Height()-2 ) );
Push( PushFlags::CLIPREGION );
IntersectClipRegion( aRect );
Rectangle aRect = Rectangle(Point(nX, 1), Size(pData->aSz.Width(), GetOutputSizePixel().Height() - 2));
rRenderContext.Push(PushFlags::CLIPREGION);
rRenderContext.IntersectClipRegion(aRect);
bool bRollover = bHighlight && nPos != nHighlightedItem;
if ( bHighlight )
if (bHighlight)
{
if( IsNativeControlSupported( CTRL_MENUBAR, PART_MENU_ITEM ) &&
IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) )
if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_MENU_ITEM) &&
rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL))
{
// draw background (transparency)
MenubarValue aControlValue;
aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
Erase();
if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
rRenderContext.Erase();
else
{
Point tmp(0,0);
Rectangle aBgRegion( tmp, GetOutputSizePixel() );
DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL,
aBgRegion,
ControlState::ENABLED,
aControlValue,
OUString() );
Rectangle aBgRegion(Point(), rRenderContext.GetOutputSizePixel());
rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL, aBgRegion,
ControlState::ENABLED, aControlValue, OUString());
}
ImplAddNWFSeparator(*this, aControlValue); // FIXME
ImplAddNWFSeparator(rRenderContext, aControlValue);
// draw selected item
ControlState nState = ControlState::ENABLED;
if ( bRollover )
if (bRollover)
nState |= ControlState::ROLLOVER;
else
nState |= ControlState::SELECTED;
DrawNativeControl( CTRL_MENUBAR, PART_MENU_ITEM,
aRect,
nState,
aControlValue,
OUString() );
rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_MENU_ITEM,
aRect, nState, aControlValue, OUString() );
}
else
{
if ( bRollover )
SetFillColor( GetSettings().GetStyleSettings().GetMenuBarRolloverColor() );
if (bRollover)
rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuBarRolloverColor());
else
SetFillColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() );
SetLineColor();
DrawRect( aRect );
rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor());
rRenderContext.SetLineColor();
rRenderContext.DrawRect(aRect);
}
}
else
{
if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) )
if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL))
{
MenubarValue aMenubarValue;
aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
Erase( aRect );
if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty())
rRenderContext.Erase(aRect);
else
{
// use full window size to get proper gradient
// but clip accordingly
Point aPt;
Rectangle aCtrlRect( aPt, GetOutputSizePixel() );
Rectangle aCtrlRect(aPt, rRenderContext.GetOutputSizePixel());
DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString() );
rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL,
aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString());
}
ImplAddNWFSeparator(*this, aMenubarValue); // FIXME
ImplAddNWFSeparator(rRenderContext, aMenubarValue);
}
else
Erase( aRect );
rRenderContext.Erase(aRect);
}
Pop();
pMenu->ImplPaint( this, 0, 0, pData, bHighlight, false, bRollover );
rRenderContext.Pop();
pMenu->ImplPaint(this, 0, 0, pData, bHighlight, false, bRollover);
}
return;
}
......@@ -908,7 +902,7 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
pMenu->ImplPaint(this, 0);
if (nHighlightedItem != ITEMPOS_INVALID)
HighlightItem(nHighlightedItem, true );
HighlightItem(rRenderContext, nHighlightedItem, true);
// in high contrast mode draw a separating line on the lower edge
if (!rRenderContext.IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) &&
......
......@@ -87,7 +87,7 @@ private:
std::map< sal_uInt16, AddButtonEntry > m_aAddButtons;
void HighlightItem( sal_uInt16 nPos, bool bHighlight );
void HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHighlight);
virtual void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus = true, bool bDefaultToDocument = true) SAL_OVERRIDE;
sal_uInt16 ImplFindEntry( const Point& rMousePos ) const;
......@@ -131,7 +131,7 @@ public:
virtual void KillActivePopup() SAL_OVERRIDE;
virtual void PopupClosed(Menu* pMenu) SAL_OVERRIDE;
virtual sal_uInt16 GetHighlightedItem() const SAL_OVERRIDE { return nHighlightedItem; }
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE;
virtual void SetAutoPopup(bool bAuto) SAL_OVERRIDE { mbAutoPopup = bAuto; }
virtual void LayoutChanged() SAL_OVERRIDE;
......
......@@ -36,86 +36,87 @@ class MenuFloatingWindow : public FloatingWindow, public MenuWindow
friend Menu::~Menu();
private:
Menu* pMenu;
PopupMenu* pActivePopup;
Timer aHighlightChangedTimer;
Timer aSubmenuCloseTimer;
Timer aScrollTimer;
sal_uLong nSaveFocusId;
sal_uInt16 nHighlightedItem; // highlighted/selected Item
sal_uInt16 nMBDownPos;
sal_uInt16 nScrollerHeight;
sal_uInt16 nFirstEntry;
sal_uInt16 nBorder;
sal_uInt16 nPosInParent;
bool bInExecute;
bool bScrollMenu;
bool bScrollUp;
bool bScrollDown;
bool bIgnoreFirstMove;
bool bKeyInput;
DECL_LINK(PopupEnd, void *);
DECL_LINK_TYPED( HighlightChanged, Timer*, void );
DECL_LINK_TYPED(SubmenuClose, Timer *, void);
DECL_LINK_TYPED(AutoScroll, Timer *, void);
DECL_LINK( ShowHideListener, VclWindowEvent* );
virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
void InitMenuClipRegion();
Menu* pMenu;
PopupMenu* pActivePopup;
Timer aHighlightChangedTimer;
Timer aSubmenuCloseTimer;
Timer aScrollTimer;
sal_uLong nSaveFocusId;
sal_uInt16 nHighlightedItem; // highlighted/selected Item
sal_uInt16 nMBDownPos;
sal_uInt16 nScrollerHeight;
sal_uInt16 nFirstEntry;
sal_uInt16 nBorder;
sal_uInt16 nPosInParent;
bool bInExecute : 1;
bool bScrollMenu : 1;
bool bScrollUp : 1;
bool bScrollDown : 1;
bool bIgnoreFirstMove : 1;
bool bKeyInput : 1;
DECL_LINK(PopupEnd, void *);
DECL_LINK_TYPED( HighlightChanged, Timer*, void );
DECL_LINK_TYPED(SubmenuClose, Timer *, void);
DECL_LINK_TYPED(AutoScroll, Timer *, void);
DECL_LINK( ShowHideListener, VclWindowEvent* );
virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
void InitMenuClipRegion(vcl::RenderContext& rRenderContext);
protected:
vcl::Region ImplCalcClipRegion( bool bIncludeLogo = true ) const;
void ImplDrawScroller( bool bUp );
vcl::Region ImplCalcClipRegion( bool bIncludeLogo = true ) const;
void ImplDrawScroller(vcl::RenderContext& rRenderContext, bool bUp);
using Window::ImplScroll;
void ImplScroll( const Point& rMousePos );
void ImplScroll( bool bUp );
void ImplCursorUpDown( bool bUp, bool bHomeEnd = false );
void ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDown );
long ImplGetStartY() const;
Rectangle ImplGetItemRect( sal_uInt16 nPos );
void ImplScroll( const Point& rMousePos );
void ImplScroll( bool bUp );
void ImplCursorUpDown( bool bUp, bool bHomeEnd = false );
void ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDown );
long ImplGetStartY() const;
Rectangle ImplGetItemRect( sal_uInt16 nPos );
public:
MenuFloatingWindow( Menu* pMenu, vcl::Window* pParent, WinBits nStyle );
virtual ~MenuFloatingWindow();
virtual void dispose() SAL_OVERRIDE;
void doShutdown();
virtual void dispose() SAL_OVERRIDE;
void doShutdown();
virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void KeyInput( const KeyEvent& rKEvent ) SAL_OVERRIDE;
virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) SAL_OVERRIDE;
virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void KeyInput( const KeyEvent& rKEvent ) SAL_OVERRIDE;
virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
void SetFocusId( sal_uLong nId ) { nSaveFocusId = nId; }
sal_uLong GetFocusId() const { return nSaveFocusId; }
void SetFocusId( sal_uLong nId ) { nSaveFocusId = nId; }
sal_uLong GetFocusId() const { return nSaveFocusId; }
void EnableScrollMenu( bool b );
bool IsScrollMenu() const { return bScrollMenu; }
sal_uInt16 GetScrollerHeight() const { return nScrollerHeight; }
void EnableScrollMenu( bool b );
bool IsScrollMenu() const { return bScrollMenu; }
sal_uInt16 GetScrollerHeight() const { return nScrollerHeight; }
void Execute();
void StopExecute( sal_uLong nFocusId = 0 );
void EndExecute();
void EndExecute( sal_uInt16 nSelectId );
void Execute();
void StopExecute( sal_uLong nFocusId = 0 );
void EndExecute();
void EndExecute( sal_uInt16 nSelectId );
PopupMenu* GetActivePopup() const { return pActivePopup; }
void KillActivePopup( PopupMenu* pThisOnly = NULL );
PopupMenu* GetActivePopup() const { return pActivePopup; }
void KillActivePopup( PopupMenu* pThisOnly = NULL );
void HighlightItem( sal_uInt16 nPos, bool bHighlight );
void ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTimer );
sal_uInt16 GetHighlightedItem() const { return nHighlightedItem; }
void HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHighlight);
void ChangeHighlightItem(sal_uInt16 n, bool bStartPopupTimer);
sal_uInt16 GetHighlightedItem() const { return nHighlightedItem; }
void SetPosInParent( sal_uInt16 nPos ) { nPosInParent = nPos; }
void SetPosInParent( sal_uInt16 nPos ) { nPosInParent = nPos; }
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE;
};
#endif // INCLUDED_VCL_SOURCE_WINDOW_MENUFLOATINGWINDOW_HXX
......
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