summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Arnhold <thomas@arnhold.org>2014-05-27 23:19:53 +0200
committerThomas Arnhold <thomas@arnhold.org>2014-05-28 01:41:00 +0200
commit8e9a261b6d605ead0de82397c2493254ba5815fd (patch)
treec56cf489766a8fcea6f2c65718e67e6003d6f49c
parent2217cb71b762ffbc32ac6c4e5d613fd32f4fa05c (diff)
Resolves: fdo#65583 Elements Dock window needs scroll bar
Based on the patch on Bugzilla by Marcos Paulo de Souza <marcos.souza.org@gmail.com> Change-Id: I215b83894f228b1cc8908f98858b85c8d5378ddb
-rw-r--r--starmath/inc/ElementsDockingWindow.hxx11
-rw-r--r--starmath/source/ElementsDockingWindow.cxx67
2 files changed, 66 insertions, 12 deletions
diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx
index 752954e44a99..e2ab95c9ab0f 100644
--- a/starmath/inc/ElementsDockingWindow.hxx
+++ b/starmath/inc/ElementsDockingWindow.hxx
@@ -16,11 +16,14 @@
* 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_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
#define INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
+#include <boost/scoped_ptr.hpp>
#include <sfx2/dockwin.hxx>
#include <svx/dlgctrl.hxx>
+#include <vcl/scrbar.hxx>
#include <document.hxx>
#include <node.hxx>
@@ -67,7 +70,6 @@ public:
class SmElementsControl : public Control
{
-
static const sal_uInt16 aUnaryBinaryOperatorsList[][2];
static const sal_uInt16 aRelationsList[][2];
static const sal_uInt16 aSetOperations[][2];
@@ -95,6 +97,7 @@ class SmElementsControl : public Control
SmElementList maElementList;
Size maMaxElementDimensions;
bool mbVerticalMode;
+ boost::scoped_ptr< ScrollBar > mpScroll;
void addElement(const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText);
@@ -113,6 +116,9 @@ public:
void setVerticalMode(bool bVertical);
void SetSelectHdl(const Link& rLink) { aSelectHdlLink = rLink; }
+
+ DECL_LINK( ScrollHdl, void* );
+ void DoScroll(long nDelta);
};
class SmElementsDockingWindow : public SfxDockingWindow
@@ -151,7 +157,6 @@ protected:
virtual ~SmElementsDockingWindowWrapper();
};
-
-#endif // _SYMBOLDOCKINGWINDOW_HXX_
+#endif // INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx
index d46f350e5f02..2b14ac2f13a9 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -27,6 +27,7 @@
#include <svl/stritem.hxx>
#include <sfx2/dispatch.hxx>
+#include <vcl/settings.hxx>
typedef tools::SvRef<SmDocShell> SmDocShellRef;
@@ -217,8 +218,12 @@ SmElementsControl::SmElementsControl(Window *pParent, const ResId& rResId)
, maCurrentSetId(0)
, mpCurrentElement(NULL)
, mbVerticalMode(true)
+ , mpScroll(new ScrollBar(this, WB_VERT))
{
maFormat.SetBaseSize(PixelToLogic(Size(0, 24)));
+
+ mpScroll->SetScrollHdl( LINK(this, SmElementsControl, ScrollHdl) );
+ mpScroll->Show();
}
SmElementsControl::~SmElementsControl()
@@ -240,27 +245,34 @@ void SmElementsControl::Paint(const Rectangle&)
SetLayoutMode( TEXT_LAYOUT_BIDI_LTR );
SetDigitLanguage( LANGUAGE_ENGLISH );
+ bool bOldVisibleState = mpScroll->IsVisible();
+
+ sal_Int32 nScrollbarWidth = bOldVisibleState ? GetSettings().GetStyleSettings().GetScrollBarSize() : 0;
+
+ sal_Int32 nControlWidth = GetOutputSizePixel().Width() - nScrollbarWidth;
+ sal_Int32 nControlHeight = GetOutputSizePixel().Height();
+
sal_Int32 boxX = maMaxElementDimensions.Width() + 10;
sal_Int32 boxY = maMaxElementDimensions.Height() + 10;
sal_Int32 x = 0;
- sal_Int32 y = 0;
+ sal_Int32 y = -mpScroll->GetThumbPos();
sal_Int32 perLine = 0;
if (mbVerticalMode)
- perLine = GetOutputSizePixel().Height() / boxY;
+ perLine = nControlHeight / boxY;
else
- perLine = GetOutputSizePixel().Width() / boxX;
+ perLine = nControlWidth / boxX;
if(perLine <= 0) {
perLine = 1;
}
if (mbVerticalMode)
- boxY = GetOutputSizePixel().Height() / perLine;
+ boxY = nControlHeight / perLine;
else
- boxX = GetOutputSizePixel().Width() / perLine;
+ boxX = nControlWidth / perLine;
for (sal_uInt16 i = 0; i < maElementList.size() ; i++)
{
@@ -274,7 +286,7 @@ void SmElementsControl::Paint(const Rectangle&)
Rectangle aSelectionRectangle(
x+5-1, y+5,
- x+5+1, GetOutputSizePixel().Height() - 5);
+ x+5+1, nControlHeight - 5);
DrawRect(PixelToLogic(aSelectionRectangle));
x += 10;
@@ -286,7 +298,7 @@ void SmElementsControl::Paint(const Rectangle&)
Rectangle aSelectionRectangle(
x+5, y+5-1,
- GetOutputSizePixel().Width() - 5, y+5+1);
+ nControlWidth - 5, y+5+1);
DrawRect(PixelToLogic(aSelectionRectangle));
y += 10;
@@ -297,7 +309,7 @@ void SmElementsControl::Paint(const Rectangle&)
Size aSizePixel = LogicToPixel(Size(element->getNode()->GetWidth(), element->getNode()->GetHeight()));
if(mbVerticalMode)
{
- if ( y + boxY > GetOutputSizePixel().Height())
+ if ( y + boxY > nControlHeight)
{
x += boxX;
y = 0;
@@ -305,7 +317,7 @@ void SmElementsControl::Paint(const Rectangle&)
}
else
{
- if ( x + boxX > GetOutputSizePixel().Width())
+ if ( x + boxX > nControlWidth)
{
x = 0;
y += boxY;
@@ -335,6 +347,26 @@ void SmElementsControl::Paint(const Rectangle&)
}
}
+ sal_Int32 nTotalControlHeight = y + boxY + mpScroll->GetThumbPos();
+
+ if (nTotalControlHeight > GetOutputSizePixel().Height())
+ {
+ mpScroll->SetRangeMax(nTotalControlHeight);
+ mpScroll->SetPosSizePixel(Point(nControlWidth, 0), Size(nScrollbarWidth, nControlHeight));
+ mpScroll->SetVisibleSize(nControlHeight);
+ mpScroll->Show();
+ }
+ else
+ {
+ mpScroll->SetThumbPos(0);
+ mpScroll->Hide();
+ }
+
+ // If scrollbar visibility changed, we have to go through the
+ // calculation once more, see nScrollbarWidth
+ if (bOldVisibleState != mpScroll->IsVisible())
+ Invalidate();
+
Pop();
}
@@ -390,6 +422,21 @@ void SmElementsControl::MouseButtonDown(const MouseEvent& rMouseEvent)
}
}
+IMPL_LINK_NOARG( SmElementsControl, ScrollHdl )
+{
+ DoScroll(mpScroll->GetDelta());
+ return 0;
+}
+
+void SmElementsControl::DoScroll(long nDelta)
+{
+ Point aNewPoint = mpScroll->GetPosPixel();
+ Rectangle aRect(Point(), GetOutputSize());
+ aRect.Right() -= mpScroll->GetSizePixel().Width();
+ Scroll( 0, -nDelta, aRect );
+ mpScroll->SetPosPixel(aNewPoint);
+}
+
void SmElementsControl::addSeparator()
{
SmElementPointer pElement(new SmElementSeparator());
@@ -578,6 +625,8 @@ void SmElementsDockingWindow::ToggleFloatingMode()
if (GetFloatingWindow())
GetFloatingWindow()->SetMinOutputSizePixel( Size(100, 100) );
+
+ Invalidate();
}
void SmElementsDockingWindow::EndDocking( const Rectangle& rReactangle, bool bFloatMode)