summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorThomas Arnhold <thomas@arnhold.org>2014-05-27 23:19:53 +0200
committerAndras Timar <andras.timar@collabora.com>2014-06-02 19:01:55 +0200
commit07dbf38ddafcfb9cb852a88f3f1005826847c5d4 (patch)
treeaf1f18aaedab01a575f0add2d5f6ffc8d930b45a /starmath
parent32b0b40da50f09412d10c9bdba4f088a145af63d (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> Includes b521c754cba4ef96cf02e0d8913ffcf14fe168d4 Conflicts: starmath/source/ElementsDockingWindow.cxx Change-Id: I215b83894f228b1cc8908f98858b85c8d5378ddb Reviewed-on: https://gerrit.libreoffice.org/9526 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/ElementsDockingWindow.hxx11
-rw-r--r--starmath/source/ElementsDockingWindow.cxx70
2 files changed, 68 insertions, 13 deletions
diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx
index ac2f3b4be8d7..2a726c43a7ba 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(OUString aElementVisual, OUString aElementSource, 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 eee6938ab72a..dc1a3bb9bb6f 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>
SV_DECL_REF(SmDocShell)
SV_IMPL_REF(SmDocShell)
@@ -207,9 +208,13 @@ SmElementsControl::SmElementsControl(Window *pParent, const ResId& rResId) :
Control(pParent, rResId),
mpDocShell(new SmDocShell(SFXOBJECTSHELL_STD_NORMAL)),
mpCurrentElement(NULL),
- mbVerticalMode(true)
+ mbVerticalMode(true),
+ mpScroll(new ScrollBar(this, WB_VERT))
{
maFormat.SetBaseSize(PixelToLogic(Size(0, 24)));
+
+ mpScroll->SetScrollHdl( LINK(this, SmElementsControl, ScrollHdl) );
+ mpScroll->Show();
}
SmElementsControl::~SmElementsControl()
@@ -231,27 +236,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++)
{
@@ -265,7 +277,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;
@@ -277,7 +289,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;
@@ -288,7 +300,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;
@@ -296,7 +308,7 @@ void SmElementsControl::Paint(const Rectangle&)
}
else
{
- if ( x + boxX > GetOutputSizePixel().Width())
+ if ( x + boxX > nControlWidth)
{
x = 0;
y += boxY;
@@ -326,6 +338,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();
}
@@ -381,6 +413,22 @@ 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);
+ Invalidate();
+}
+
void SmElementsControl::addSeparator()
{
SmElementPointer pElement(new SmElementSeparator());
@@ -569,6 +617,8 @@ void SmElementsDockingWindow::ToggleFloatingMode()
if (GetFloatingWindow())
GetFloatingWindow()->SetMinOutputSizePixel( Size(100, 100) );
+
+ Invalidate();
}
void SmElementsDockingWindow::EndDocking( const Rectangle& rReactangle, sal_Bool bFloatMode)