diff options
-rw-r--r-- | include/vcl/toolbox.hxx | 5 | ||||
-rw-r--r-- | vcl/source/window/dockmgr.cxx | 136 | ||||
-rw-r--r-- | vcl/source/window/toolbox.cxx | 113 |
3 files changed, 95 insertions, 159 deletions
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx index f2881b8fbc01..3edb3b8022bd 100644 --- a/include/vcl/toolbox.hxx +++ b/include/vcl/toolbox.hxx @@ -223,9 +223,14 @@ public: SAL_DLLPRIVATE void ImplDisableFlatButtons(); static SAL_DLLPRIVATE int ImplGetDragWidth( ToolBox* pThis ); + static SAL_DLLPRIVATE int ImplGetDragWidth( const vcl::RenderContext& rRenderContext, + bool bHorz ); static SAL_DLLPRIVATE void ImplUpdateDragArea( ToolBox *pThis ); static SAL_DLLPRIVATE void ImplCalcBorder( WindowAlign eAlign, long& rLeft, long& rTop, long& rRight, long& rBottom, const ToolBox *pThis ); + static SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext, + const Rectangle &aDragArea, int nDragWidth, + WindowAlign eAlign, bool bHorz); SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext); SAL_DLLPRIVATE void ImplDrawGradientBackground(vcl::RenderContext& rRenderContext, ImplDockingWindowWrapper *pWrapper); diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx index 7f32e74a9a8d..a508927b68f8 100644 --- a/vcl/source/window/dockmgr.cxx +++ b/vcl/source/window/dockmgr.cxx @@ -424,29 +424,10 @@ Rectangle DockingManager::GetPosSizePixel( const vcl::Window *pWindow ) return aRect; } -// special floating window for popup mode -// main purpose: provides tear-off area for undocking - -// if TEAROFF_DASHED defined a single dashed line is used -// otherwise multiple smaller lines will be painted -//#define TEAROFF_DASHED - -// size of the drag area -#ifdef TEAROFF_DASHED -#define POPUP_DRAGBORDER 2 -#define POPUP_DRAGGRIP 5 -#else -#define POPUP_DRAGBORDER 3 -#define POPUP_DRAGGRIP 5 -#endif -#define POPUP_DRAGHEIGHT (POPUP_DRAGGRIP+POPUP_DRAGBORDER+POPUP_DRAGBORDER) -#define POPUP_DRAGWIDTH 20 - class ImplPopupFloatWin : public FloatingWindow { private: ImplDockingWindowWrapper* mpDockingWin; - bool mbHighlight; bool mbMoving; bool mbTrackingEnabled; Point maDelta; @@ -454,7 +435,8 @@ private: void ImplSetBorder(); public: - ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip ); + ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, + bool bHasGrip, bool bUsePopupWin ); virtual ~ImplPopupFloatWin() override; virtual void dispose() override; @@ -467,22 +449,23 @@ public: virtual void Resize() override; Rectangle GetDragRect() const; + Point GetToolboxPosition() const; void DrawGrip(vcl::RenderContext& rRenderContext); void DrawBorder(vcl::RenderContext& rRenderContext); bool hasGrip() const { return mbHasGrip; } }; -ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip ) : - FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW) +ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, + bool bHasGrip, bool bUsePopupWin ) : + FloatingWindow( pParent, bUsePopupWin ? WB_STDPOPUP : WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW) { mpWindowImpl->mbToolbarFloatingWindow = true; // indicate window type, required for accessibility // which should not see this window as a toplevel window mpDockingWin = pDockingWin; - mbHighlight = false; mbMoving = false; mbTrackingEnabled = false; - mbHasGrip = bHasGrip; + mbHasGrip = !bUsePopupWin && bHasGrip; ImplSetBorder(); } @@ -517,7 +500,7 @@ void ImplPopupFloatWin::ImplSetBorder() // be used to set the proper window size mpWindowImpl->mnTopBorder = 1; if( hasGrip() ) - mpWindowImpl->mnTopBorder += POPUP_DRAGHEIGHT+2; + mpWindowImpl->mnTopBorder += 2 + ToolBox::ImplGetDragWidth( *this, false ); mpWindowImpl->mnBottomBorder = 1; mpWindowImpl->mnLeftBorder = 1; mpWindowImpl->mnRightBorder = 1; @@ -533,9 +516,14 @@ Rectangle ImplPopupFloatWin::GetDragRect() const { if( !hasGrip() ) return Rectangle(); + return Rectangle( 1, 1, GetOutputSizePixel().Width() - 1, + 2 + ToolBox::ImplGetDragWidth( *this, false ) ); +} - return Rectangle( 1, GetOutputSizePixel().Height() - 3 - POPUP_DRAGHEIGHT, - GetOutputSizePixel().Width() - 1, GetOutputSizePixel().Height() - 1 ); +Point ImplPopupFloatWin::GetToolboxPosition() const +{ + // return inner position where a toolbox could be placed + return Point( 1, 1 + GetDragRect().getHeight() ); // grip + border } void ImplPopupFloatWin::DrawBorder(vcl::RenderContext& rRenderContext) @@ -570,76 +558,10 @@ void ImplPopupFloatWin::DrawGrip(vcl::RenderContext& rRenderContext) bool bFillcolor = rRenderContext.IsFillColor(); Color aFillcolor = rRenderContext.GetFillColor(); - // draw background - Rectangle aRect(GetDragRect()); - aRect.Top() += POPUP_DRAGBORDER; - aRect.Bottom() -= POPUP_DRAGBORDER; - aRect.Left() += 3; - aRect.Right() -= 3; - - if (mbHighlight) - { - rRenderContext.Erase(aRect); - vcl::RenderTools::DrawSelectionBackground(rRenderContext, *this, aRect, 2, false, true, false); - } - else - { - rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetFaceColor()); - rRenderContext.SetLineColor(); - rRenderContext.DrawRect(aRect); - } - if (!ToolBox::AlwaysLocked()) // no grip if toolboxes are locked { -#ifdef TEAROFF_DASHED - // draw single dashed line - LineInfo aLineInfo(LineStyle::Dash); - aLineInfo.SetDistance(4); - aLineInfo.SetDashLen(12); - aLineInfo.SetDashCount(1); - - aRect.Left() += 2; - aRect.Right()-= 2; - - aRect.Top() += 2; - aRect.Bottom() = aRect.Top(); - rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetDarkShadowColor()); - rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight(), aLineInfo); - - if (!mbHighlight) - { - ++aRect.Top(); - ++aRect.Bottom(); - rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetLightColor()); - rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight(), aLineInfo); - } - -#else - // draw several grip lines - rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor()); - aRect.Top()++; - aRect.Bottom() = aRect.Top(); - - int width = POPUP_DRAGWIDTH; - while(width >= aRect.getWidth()) - { - width -= 4; - } - if (width <= 0) - width = aRect.getWidth(); - //aRect.nLeft = aRect.nLeft + (aRect.getWidth() - width) / 2; - aRect.Left() = (aRect.Left() + aRect.Right() - width) / 2; - aRect.Right() = aRect.Left() + width; - - int i = 0; - while (i < POPUP_DRAGGRIP) - { - rRenderContext.DrawRect(aRect); - aRect.Top() += 2; - aRect.Bottom() += 2; - i += 2; - } -#endif + ToolBox::ImplDrawGrip(rRenderContext, GetDragRect(), + ToolBox::ImplGetDragWidth( *this, false ), WindowAlign::Left, false ); } if (bLinecolor) @@ -674,15 +596,15 @@ void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt ) StartTracking( StartTrackingFlags::NoKeyCancel ); return; } - if( !mbHighlight && GetDragRect().IsInside( aMousePos ) ) + if( GetDragRect().IsInside( aMousePos ) ) { - mbHighlight = true; - Invalidate(); + if( GetPointer().GetStyle() != PointerStyle::Move ) + SetPointer( Pointer( PointerStyle::Move ) ); } - if (mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) ) + if( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) { - mbHighlight = false; - Invalidate(); + if( GetPointer().GetStyle() != PointerStyle::Arrow ) + SetPointer( Pointer( PointerStyle::Arrow ) ); } } } @@ -1053,12 +975,8 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, FloatWin bool bIsToolBox = GetWindow()->GetType() == WINDOW_TOOLBOX; // the new parent for popup mode - VclPtr<FloatingWindow> pWin; - if ( bAllowTearOff && !bIsToolBox ) - pWin = VclPtr<FloatingWindow>::Create( mpParent, WB_STDPOPUP ); - else - pWin = VclPtr<ImplPopupFloatWin>::Create( mpParent, this, bAllowTearOff ); - + VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, this, bAllowTearOff, + bAllowTearOff && !bIsToolBox ); pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) ); pWin->SetText( GetWindow()->GetText() ); @@ -1070,8 +988,8 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, FloatWin GetWindow()->mpWindowImpl->mnRightBorder = 0; GetWindow()->mpWindowImpl->mnBottomBorder = 0; - // position toolbox above DragRect - GetWindow()->SetPosPixel( Point( 1, 1 ) ); + // position toolbox below the drag grip + GetWindow()->SetPosPixel( pWin->GetToolboxPosition() ); // reparent borderwindow and window if ( mpOldBorderWin ) diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 5095ef21ed45..3dedc787ad53 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -148,30 +148,36 @@ static ImplTBDragMgr* ImplGetTBDragMgr() return pSVData->maCtrlData.mpTBDragMgr; } -int ToolBox::ImplGetDragWidth( ToolBox* pThis ) +int ToolBox::ImplGetDragWidth( const vcl::RenderContext& rRenderContext, bool bHorz ) { int nWidth = TB_DRAGWIDTH; - if( pThis->IsNativeControlSupported( ControlType::Toolbar, ControlPart::Entire ) ) + if( rRenderContext.IsNativeControlSupported( ControlType::Toolbar, ControlPart::Entire ) ) { ImplControlValue aControlValue; Point aPoint; Rectangle aContent, aBound; - Rectangle aArea( aPoint, pThis->GetOutputSizePixel() ); + Rectangle aArea( aPoint, rRenderContext.GetOutputSizePixel() ); - if ( pThis->GetNativeControlRegion(ControlType::Toolbar, pThis->mbHorz ? ControlPart::ThumbVert : ControlPart::ThumbHorz, + if ( rRenderContext.GetNativeControlRegion(ControlType::Toolbar, + bHorz ? ControlPart::ThumbVert : ControlPart::ThumbHorz, aArea, ControlState::NONE, aControlValue, OUString(), aBound, aContent) ) { - nWidth = pThis->mbHorz ? aContent.GetWidth() : aContent.GetHeight(); + nWidth = bHorz ? aContent.GetWidth() : aContent.GetHeight(); } } // increase the hit area of the drag handle according to DPI scale factor - nWidth *= pThis->GetDPIScaleFactor(); + nWidth *= rRenderContext.GetDPIScaleFactor(); return nWidth; } +int ToolBox::ImplGetDragWidth( ToolBox* pThis ) +{ + return ToolBox::ImplGetDragWidth( *pThis, pThis->mbHorz ); +} + ButtonType determineButtonType( ImplToolItem* pItem, ButtonType defaultType ) { ButtonType tmpButtonType = defaultType; @@ -263,65 +269,72 @@ static void ImplCheckUpdate(ToolBox* pThis) pThis->Update(); } -void ToolBox::ImplDrawGrip(vcl::RenderContext& rRenderContext) +void ToolBox::ImplDrawGrip(vcl::RenderContext& rRenderContext, + const Rectangle &aDragArea, int nDragWidth, WindowAlign eAlign, bool bHorz) { - ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper(this); - if( pWrapper && !pWrapper->GetDragArea().IsEmpty() ) + bool bNativeOk = false; + const ControlPart ePart = bHorz ? ControlPart::ThumbVert : ControlPart::ThumbHorz; + const Size aSz( rRenderContext.GetOutputSizePixel() ); + if (rRenderContext.IsNativeControlSupported(ControlType::Toolbar, ePart)) { - // execute pending paint requests - ImplCheckUpdate(this); + ToolbarValue aToolbarValue; + aToolbarValue.maGripRect = aDragArea; - bool bNativeOk = false; - if (rRenderContext.IsNativeControlSupported(ControlType::Toolbar, mbHorz ? ControlPart::ThumbHorz : ControlPart::ThumbVert)) - { - ToolbarValue aToolbarValue; - aToolbarValue.maGripRect = pWrapper->GetDragArea(); + Point aPt; + Rectangle aCtrlRegion(aPt, aSz); + ControlState nState = ControlState::ENABLED; - Point aPt; - Rectangle aCtrlRegion(aPt, GetOutputSizePixel()); - ControlState nState = ControlState::ENABLED; - - bNativeOk = rRenderContext.DrawNativeControl( ControlType::Toolbar, mbHorz ? ControlPart::ThumbVert : ControlPart::ThumbHorz, - aCtrlRegion, nState, aToolbarValue, OUString() ); - } + bNativeOk = rRenderContext.DrawNativeControl( ControlType::Toolbar, ePart, + aCtrlRegion, nState, aToolbarValue, OUString() ); + } - if( bNativeOk ) - return; + if( bNativeOk ) + return; - const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); - rRenderContext.SetFillColor(rStyleSettings.GetShadowColor()); + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); + rRenderContext.SetFillColor(rStyleSettings.GetShadowColor()); - Size aSz(GetOutputSizePixel()); - float fScaleFactor = rRenderContext.GetDPIScaleFactor(); + float fScaleFactor = rRenderContext.GetDPIScaleFactor(); - if (meAlign == WindowAlign::Top || meAlign == WindowAlign::Bottom) + if (eAlign == WindowAlign::Top || eAlign == WindowAlign::Bottom) + { + int height = (int) (0.6 * aSz.Height() + 0.5); + int i = (aSz.Height() - height) / 2; + height += i; + while (i <= height) { - int height = (int) (0.6 * aSz.Height() + 0.5); - int i = (aSz.Height() - height) / 2; - height += i; - while (i <= height) - { - int x = ImplGetDragWidth(this) / 2; - rRenderContext.DrawEllipse(Rectangle(Point(x, i), Size(2 * fScaleFactor, 2 * fScaleFactor))); - i += 4 * fScaleFactor; - } + int x = nDragWidth / 2; + rRenderContext.DrawEllipse(Rectangle(Point(x, i), Size(2 * fScaleFactor, 2 * fScaleFactor))); + i += 4 * fScaleFactor; } - else + } + else + { + int width = (int) (0.6 * aSz.Width() + 0.5); + int i = (aSz.Width() - width) / 2; + width += i; + while (i <= width) { - int width = (int) (0.6 * aSz.Width() + 0.5); - int i = (aSz.Width() - width) / 2; - width += i; - while (i <= width) - { - int y = ImplGetDragWidth(this) / 2; - rRenderContext.DrawEllipse(Rectangle(Point(i, y), Size(2 * fScaleFactor, 2 * fScaleFactor))); - i += 4 * fScaleFactor; - } + int y = nDragWidth / 2; + rRenderContext.DrawEllipse(Rectangle(Point(i, y), Size(2 * fScaleFactor, 2 * fScaleFactor))); + i += 4 * fScaleFactor; } } } +void ToolBox::ImplDrawGrip(vcl::RenderContext& rRenderContext) +{ + ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper(this); + if( pWrapper && !pWrapper->GetDragArea().IsEmpty() ) + { + // execute pending paint requests + ImplCheckUpdate(this); + ImplDrawGrip( rRenderContext, pWrapper->GetDragArea(), + ImplGetDragWidth(this), meAlign, mbHorz ); + } +} + void ToolBox::ImplDrawGradientBackground(vcl::RenderContext& rRenderContext, ImplDockingWindowWrapper*) { // draw a nice gradient |