summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-08-07 16:55:33 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-08-08 14:29:08 +0100
commitd07184581894740f08bdcaa4c06f39ed32b73874 (patch)
tree1a25801af5a550c3373a5a806448d170e9fa81e3
parent0ccf1e3bab080a74c4aea96dd3bb9ad29aac81e4 (diff)
Related: tdf#92530 turn the HintWindow into an Overlay
Change-Id: I4cde152cfb4a3ec4127442a6ced9a80ef6235c8f
-rw-r--r--sc/source/ui/inc/hintwin.hxx44
-rw-r--r--sc/source/ui/inc/overlayobject.hxx16
-rw-r--r--sc/source/ui/inc/tabview.hxx3
-rw-r--r--sc/source/ui/view/hintwin.cxx120
-rw-r--r--sc/source/ui/view/tabview.cxx3
-rw-r--r--sc/source/ui/view/tabview3.cxx53
-rw-r--r--sc/source/ui/view/tabview5.cxx4
7 files changed, 91 insertions, 152 deletions
diff --git a/sc/source/ui/inc/hintwin.hxx b/sc/source/ui/inc/hintwin.hxx
deleted file mode 100644
index 386e340eb650..000000000000
--- a/sc/source/ui/inc/hintwin.hxx
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_SC_SOURCE_UI_INC_HINTWIN_HXX
-#define INCLUDED_SC_SOURCE_UI_INC_HINTWIN_HXX
-
-#include <vcl/window.hxx>
-
-class ScHintWindow : public vcl::Window
-{
-private:
- OUString m_aTitle;
- OUString m_aMessage;
- Point m_aTextStart;
- long m_nTextHeight;
- vcl::Font m_aTextFont;
- vcl::Font m_aHeadFont;
-
-protected:
- virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
-
-public:
- ScHintWindow(vcl::Window* pParent, const OUString& rTit, const OUString& rMsg);
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/overlayobject.hxx b/sc/source/ui/inc/overlayobject.hxx
index 559a868ab412..64746bf874c9 100644
--- a/sc/source/ui/inc/overlayobject.hxx
+++ b/sc/source/ui/inc/overlayobject.hxx
@@ -21,6 +21,8 @@
#define INCLUDED_SC_SOURCE_UI_INC_OVERLAYOBJECT_HXX
#include <svx/sdr/overlay/overlayobject.hxx>
+#include <vcl/font.hxx>
+#include <vcl/mapmod.hxx>
class ScOverlayDashedBorder : public sdr::overlay::OverlayObject
{
@@ -40,23 +42,25 @@ private:
bool mbToggle;
};
-namespace vcl
-{
- class Font;
-}
-
class ScOverlayHint : public sdr::overlay::OverlayObject
{
public:
ScOverlayHint(const OUString& rTit, const OUString& rMsg, const Color& rColor, const vcl::Font& rFont);
+ Size GetSizePixel() const;
+ void SetPos(const Point& rPos, const MapMode& rMode);
public:
virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence() override;
private:
+ drawinglayer::primitive2d::Primitive2DContainer createOverlaySequence(sal_Int32 nLeft, sal_Int32 nTop, const MapMode &rMapMode, basegfx::B2DRange &rRange) const;
+
const OUString m_aTitle;
const OUString m_aMessage;
- const vcl::Font& m_rTextFont;
+ const vcl::Font m_aTextFont;
+ MapMode m_aMapMode;
+ sal_Int32 m_nLeft;
+ sal_Int32 m_nTop;
};
#endif
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 685de7d276df..c068063a80f3 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -48,7 +48,6 @@ class Splitter;
class ScTabSplitter;
class SdrView;
class SdrObject;
-class ScHintWindow;
class ScPageBreakData;
class SdrHdlList;
class TabBar;
@@ -116,7 +115,7 @@ private:
VclPtr<ScCornerButton> aTopButton;
VclPtr<ScrollBarBox> aScrollBarBox;
- VclPtr<ScHintWindow> mpInputHintWindow; // popup window for data validation
+ std::unique_ptr<sdr::overlay::OverlayObjectList> mxInputHintOO; // help hint for data validation
ScPageBreakData* pPageBreakData;
std::vector<ScHighlightEntry> maHighlightRanges;
diff --git a/sc/source/ui/view/hintwin.cxx b/sc/source/ui/view/hintwin.cxx
index c0787597867a..41bce2332042 100644
--- a/sc/source/ui/view/hintwin.cxx
+++ b/sc/source/ui/view/hintwin.cxx
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "hintwin.hxx"
#include "global.hxx"
#include "overlayobject.hxx"
#include "scmod.hxx"
@@ -40,55 +39,30 @@
#define HINT_INDENT 3
#define HINT_MARGIN 4
-ScHintWindow::ScHintWindow( vcl::Window* pParent, const OUString& rTit, const OUString& rMsg ) :
- Window( pParent, 0 ),
- m_aTitle( rTit ),
- m_aMessage( convertLineEnd(rMsg, LINEEND_CR) )
-{
- m_aTextFont = GetFont();
- m_aTextFont.SetTransparent( true );
- m_aTextFont.SetWeight( WEIGHT_NORMAL );
- m_aHeadFont = m_aTextFont;
- m_aHeadFont.SetWeight( WEIGHT_BOLD );
-
- SetFont( m_aHeadFont );
- Size aHeadSize( GetTextWidth( m_aTitle ), GetTextHeight() );
- SetFont( m_aTextFont );
-
- Size aTextSize;
- sal_Int32 nIndex = 0;
- while ( nIndex != -1 )
- {
- OUString aLine = m_aMessage.getToken( 0, '\r', nIndex );
- Size aLineSize( GetTextWidth( aLine ), GetTextHeight() );
- m_nTextHeight = aLineSize.Height();
- aTextSize.Height() += m_nTextHeight;
- if ( aLineSize.Width() > aTextSize.Width() )
- aTextSize.Width() = aLineSize.Width();
- }
- aTextSize.Width() += HINT_INDENT;
-
- m_aTextStart = Point( HINT_MARGIN + HINT_INDENT,
- aHeadSize.Height() + HINT_MARGIN + HINT_LINESPACE );
-
- Size aWinSize( std::max( aHeadSize.Width(), aTextSize.Width() ) + 2 * HINT_MARGIN + 1,
- aHeadSize.Height() + aTextSize.Height() + HINT_LINESPACE + 2 * HINT_MARGIN + 1 );
- SetOutputSizePixel( aWinSize );
-}
-
ScOverlayHint::ScOverlayHint(const OUString& rTit, const OUString& rMsg, const Color& rColor, const vcl::Font& rFont)
: OverlayObject(rColor)
, m_aTitle(rTit)
, m_aMessage(convertLineEnd(rMsg, LINEEND_CR))
- , m_rTextFont(rFont)
+ , m_aTextFont(rFont)
+ , m_aMapMode(MAP_PIXEL)
+ , m_nLeft(0)
+ , m_nTop(0)
{
}
-drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlayObjectPrimitive2DSequence()
+drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlaySequence(sal_Int32 nLeft, sal_Int32 nTop,
+ const MapMode &rMapMode,
+ basegfx::B2DRange &rRange) const
{
+ OutputDevice* pDefaultDev = Application::GetDefaultDevice();
+ MapMode aOld = pDefaultDev->GetMapMode();
+ pDefaultDev->SetMapMode(rMapMode);
+
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
- const Color& rColor = rStyleSettings.GetWindowTextColor();
- vcl::Font aHeadFont = m_rTextFont;
+ const Color& rColor = rStyleSettings.GetLabelTextColor();
+ vcl::Font aTextFont = m_aTextFont;
+ aTextFont.SetFontSize(pDefaultDev->PixelToLogic(aTextFont.GetFontSize(), rMapMode));
+ vcl::Font aHeadFont = aTextFont;
aHeadFont.SetWeight(WEIGHT_BOLD);
// Create the text primitive for the title
@@ -96,16 +70,16 @@ drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlayObje
drawinglayer::attribute::FontAttribute aFontAttr =
drawinglayer::primitive2d::getFontAttributeFromVclFont(aFontSize, aHeadFont, false, false);
- OutputDevice* pDefaultDev = Application::GetDefaultDevice();
-
FontMetric aFontMetric = pDefaultDev->GetFontMetric(aHeadFont);
- double nTextOffsetY = HINT_MARGIN + aFontMetric.GetAscent();
- Point aTextPos(HINT_MARGIN, nTextOffsetY);
- basegfx::B2DRange aRange(0, 0, HINT_MARGIN, nTextOffsetY);
+ Size aHintMargin = pDefaultDev->PixelToLogic(Size(HINT_MARGIN, HINT_MARGIN), rMapMode);
+ Size aIndent = pDefaultDev->PixelToLogic(Size(HINT_INDENT, HINT_LINESPACE), rMapMode);
+ double nTextOffsetY = nTop + aHintMargin.Height() + aFontMetric.GetAscent();
+ Point aTextPos(nLeft + aHintMargin.Width() , nTextOffsetY);
+ rRange = basegfx::B2DRange(nLeft, nTop, nLeft + aHintMargin.Width(), nTop + aHintMargin.Height());
basegfx::B2DHomMatrix aTextMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix(
aFontSize.getX(), aFontSize.getY(),
- double(aTextPos.X()), double(aTextPos.Y())));
+ aTextPos.X(), aTextPos.Y()));
drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pTitle =
new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
@@ -115,21 +89,24 @@ drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlayObje
const drawinglayer::primitive2d::Primitive2DReference aTitle(pTitle);
- Point m_aTextStart(HINT_MARGIN + HINT_INDENT, HINT_MARGIN + aFontMetric.GetLineHeight() + HINT_LINESPACE);
+ Point aTextStart(nLeft + aHintMargin.Width() + aIndent.Width(),
+ nTop + aHintMargin.Height() + aFontMetric.GetLineHeight() + aIndent.Height());
drawinglayer::geometry::ViewInformation2D aDummy;
- aRange.expand(pTitle->getB2DRange(aDummy));
+ rRange.expand(pTitle->getB2DRange(aDummy));
drawinglayer::primitive2d::Primitive2DContainer aSeq { aTitle };
- aFontMetric = pDefaultDev->GetFontMetric(m_rTextFont);
+ aFontMetric = pDefaultDev->GetFontMetric(aTextFont);
+ pDefaultDev->SetMapMode(aOld);
nTextOffsetY = aFontMetric.GetAscent();
+ sal_Int32 nLineHeight = aFontMetric.GetLineHeight();
- aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(aFontSize, m_rTextFont, false, false);
+ aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(aFontSize, aTextFont, false, false);
sal_Int32 nIndex = 0;
- Point aLineStart = m_aTextStart;
+ Point aLineStart = aTextStart;
while (nIndex != -1)
{
OUString aLine = m_aMessage.getToken( 0, '\r', nIndex );
@@ -145,17 +122,18 @@ drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlayObje
std::vector<double>(), aFontAttr, css::lang::Locale(),
rColor.getBColor());
- aRange.expand(pMessage->getB2DRange(aDummy));
+ rRange.expand(pMessage->getB2DRange(aDummy));
const drawinglayer::primitive2d::Primitive2DReference aMessage(pMessage);
aSeq.push_back(aMessage);
- aLineStart.Y() += aFontMetric.GetLineHeight();
+ aLineStart.Y() += nLineHeight;
}
- aRange.grow(HINT_MARGIN);
+ rRange.expand(basegfx::B2DTuple(rRange.getMaxX() + aHintMargin.Width(),
+ rRange.getMaxY() + aHintMargin.Height()));
- basegfx::B2DPolygon aPoly(basegfx::tools::createPolygonFromRect(aRange));
+ basegfx::B2DPolygon aPoly(basegfx::tools::createPolygonFromRect(rRange));
const drawinglayer::primitive2d::Primitive2DReference aBg(
new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPoly), getBaseColor().getBColor()));
@@ -165,30 +143,30 @@ drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlayObje
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
aPoly, aBorderColor));
-
aSeq.insert(aSeq.begin(), aBorder);
aSeq.insert(aSeq.begin(), aBg);
return aSeq;
}
-void ScHintWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /* rRect */)
+drawinglayer::primitive2d::Primitive2DContainer ScOverlayHint::createOverlayObjectPrimitive2DSequence()
{
- // Create the processor and process the primitives
- const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
- std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> xProcessor(
- drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(rRenderContext, aNewViewInfos));
-
- const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
- Color aCommentColor = rColorCfg.GetColorValue(svtools::CALCNOTESBACKGROUND).nColor;
-
- ScOverlayHint* pHint = new ScOverlayHint(m_aTitle, m_aMessage, aCommentColor, GetFont());
-
- drawinglayer::primitive2d::Primitive2DContainer aSeq = pHint->createOverlayObjectPrimitive2DSequence();
+ basegfx::B2DRange aRange;
+ return createOverlaySequence(m_nLeft, m_nTop, m_aMapMode, aRange);
+}
- delete pHint;
+Size ScOverlayHint::GetSizePixel() const
+{
+ basegfx::B2DRange aRange;
+ createOverlaySequence(0, 0, MAP_PIXEL, aRange);
+ return Size(aRange.getWidth(), aRange.getHeight());
+}
- xProcessor->process(aSeq);
+void ScOverlayHint::SetPos(const Point& rPos, const MapMode& rMode)
+{
+ m_nLeft = rPos.X();
+ m_nTop = rPos.Y();
+ m_aMapMode = rMode;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 79f2adadb175..aa81b31001f1 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -44,7 +44,6 @@
#include "AccessibilityHints.hxx"
#include "appoptio.hxx"
#include "attrib.hxx"
-#include "hintwin.hxx"
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
@@ -204,7 +203,7 @@ ScTabView::ScTabView( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell*
aCornerButton( VclPtr<ScCornerButton>::Create( pFrameWin, &aViewData, false ) ),
aTopButton( VclPtr<ScCornerButton>::Create( pFrameWin, &aViewData, true ) ),
aScrollBarBox( VclPtr<ScrollBarBox>::Create( pFrameWin, WB_SIZEABLE ) ),
- mpInputHintWindow( nullptr ),
+ mxInputHintOO(),
pPageBreakData( nullptr ),
pBrushDocument( nullptr ),
pDrawBrushSet( nullptr ),
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 459ab62a68b7..b26530519cc6 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -24,6 +24,7 @@
#include <editeng/brushitem.hxx>
#include <editeng/editview.hxx>
#include <svx/fmshell.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
#include <svx/svdoole2.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/viewfrm.hxx>
@@ -34,6 +35,7 @@
#include "docsh.hxx"
#include "gridwin.hxx"
#include "olinewin.hxx"
+#include "overlayobject.hxx"
#include "colrowba.hxx"
#include "tabcont.hxx"
#include "scmod.hxx"
@@ -44,7 +46,6 @@
#include "inputhdl.hxx"
#include "inputwin.hxx"
#include "validat.hxx"
-#include "hintwin.hxx"
#include "inputopt.hxx"
#include "rfindlst.hxx"
#include "hiranges.hxx"
@@ -646,6 +647,8 @@ void ScTabView::TestHintWindow()
{
// show input help window and list drop-down button for validity
+ mxInputHintOO.reset();
+
bool bListValButton = false;
ScAddress aListValPos;
@@ -660,12 +663,9 @@ void ScTabView::TestHintWindow()
const ScValidationData* pData = pDoc->GetValidationEntry( pItem->GetValue() );
OSL_ENSURE(pData,"ValidationData not found");
OUString aTitle, aMessage;
+
if ( pData && pData->GetInput( aTitle, aMessage ) && !aMessage.isEmpty() )
{
- //! check if on the same spot !!!!
-
- mpInputHintWindow.disposeAndClear();
-
ScSplitPos eWhich = aViewData.GetActivePart();
ScGridWindow* pWin = pGridWin[eWhich];
SCCOL nCol = aViewData.GetCurX();
@@ -677,23 +677,30 @@ void ScTabView::TestHintWindow()
nRow >= aViewData.GetPosY(WhichV(eWhich)) &&
aPos.X() < aWinSize.Width() && aPos.Y() < aWinSize.Height() )
{
- // create HintWindow, determines its size by itself
- mpInputHintWindow.reset(VclPtr<ScHintWindow>::Create(pWin, aTitle, aMessage));
- Size aHintWndSize = mpInputHintWindow->GetSizePixel();
- long nCellSizeX = 0;
- long nCellSizeY = 0;
- aViewData.GetMergeSizePixel(nCol, nRow, nCellSizeX, nCellSizeY);
-
- Point aHintPos = calcHintWindowPosition(
- aPos, Size(nCellSizeX,nCellSizeY), aWinSize, aHintWndSize);
-
- mpInputHintWindow->SetPosPixel( aHintPos );
- mpInputHintWindow->ToTop();
- mpInputHintWindow->Show();
+ rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = pWin->getOverlayManager();
+ if (xOverlayManager.is())
+ {
+ const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
+ Color aCommentColor = rColorCfg.GetColorValue(svtools::CALCNOTESBACKGROUND).nColor;
+ // create HintWindow, determines its size by itself
+ ScOverlayHint* pOverlay = new ScOverlayHint(aTitle, aMessage, aCommentColor, pFrameWin->GetFont());
+
+ Size aHintWndSize = pOverlay->GetSizePixel();
+ long nCellSizeX = 0;
+ long nCellSizeY = 0;
+ aViewData.GetMergeSizePixel(nCol, nRow, nCellSizeX, nCellSizeY);
+
+ Point aHintPos = calcHintWindowPosition(
+ aPos, Size(nCellSizeX,nCellSizeY), aWinSize, aHintWndSize);
+
+ pOverlay->SetPos(pWin->PixelToLogic(aHintPos, pWin->GetDrawMapMode()), pWin->GetDrawMapMode());
+
+ xOverlayManager->add(*pOverlay);
+ mxInputHintOO.reset(new sdr::overlay::OverlayObjectList);
+ mxInputHintOO->append(*pOverlay);
+ }
}
}
- else
- mpInputHintWindow.disposeAndClear();
// list drop-down button
if ( pData && pData->HasSelectionList() )
@@ -702,8 +709,6 @@ void ScTabView::TestHintWindow()
bListValButton = true;
}
}
- else
- mpInputHintWindow.disposeAndClear();
for (VclPtr<ScGridWindow> & pWin : pGridWin)
if ( pWin && pWin->IsVisible() )
@@ -712,12 +717,12 @@ void ScTabView::TestHintWindow()
bool ScTabView::HasHintWindow() const
{
- return mpInputHintWindow.get() != nullptr;
+ return mxInputHintOO.get() != nullptr;
}
void ScTabView::RemoveHintWindow()
{
- mpInputHintWindow.disposeAndClear();
+ mxInputHintOO.reset();
}
// find window that should not be over the cursor
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index ee9c6fde29e0..6a7b796a2362 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -35,7 +35,6 @@
#include "tabsplit.hxx"
#include "colrowba.hxx"
#include "tabcont.hxx"
-#include "hintwin.hxx"
#include "sc.hrc"
#include "pagedata.hxx"
#include "hiranges.hxx"
@@ -176,8 +175,7 @@ ScTabView::~ScTabView()
delete pSelEngine;
- // Delete this before the grid windows, since it's a child window of one of them.
- mpInputHintWindow.disposeAndClear();
+ mxInputHintOO.reset();
for (i=0; i<4; i++)
pGridWin[i].disposeAndClear();