diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx index e3b1e8f..81b52be 100644 --- a/starmath/inc/ElementsDockingWindow.hxx +++ b/starmath/inc/ElementsDockingWindow.hxx @@ -19,8 +19,10 @@ #ifndef INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX #define INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX +#include #include #include +#include #include #include @@ -108,6 +110,8 @@ public: void SetSelectHdl(const Link& rLink) { aSelectHdlLink = rLink; } + SmElementList getList() const { return maElementList; } + void setColorBlack(const OUString color) { maColorBlack = color; } OUString colorBlack() { return maColorBlack; } @@ -138,6 +142,7 @@ public: void setStringFont(const OUString string) { maStringFont = string; } OUString stringFont() { return maStringFont; } + private: OUString maColorBlack; OUString maColorBlue; @@ -172,6 +177,12 @@ public: ~SmElementsDockingWindow(); virtual void EndDocking( const Rectangle& rReactangle, sal_Bool bFloatMode); + + DECL_LINK( ScrollHdl, void* ); + void DoScroll(long nDelta); + +private: + boost::scoped_ptr< ScrollBar > mpScroll; }; class SmElementsDockingWindowWrapper : public SfxChildWindow diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx index 7837e23..e954fc9 100644 --- a/starmath/source/ElementsDockingWindow.cxx +++ b/starmath/source/ElementsDockingWindow.cxx @@ -494,7 +494,8 @@ const sal_uInt16 SmElementsDockingWindow::aCategories[] = { SmElementsDockingWindow::SmElementsDockingWindow(SfxBindings* pInputBindings, SfxChildWindow* pChildWindow, Window* pParent) : SfxDockingWindow(pInputBindings, pChildWindow, pParent, SmResId(RID_ELEMENTSDOCKINGWINDOW)), maElementsControl (this, SmResId(1)), - maElementListBox (this, SmResId(1)) + maElementListBox (this, SmResId(1)), + mpScroll(new ScrollBar(this, WB_VERT)) { maElementsControl.SetBorderStyle( WINDOW_BORDER_MONO ); maElementsControl.setColorBlack(SmResId(STR_BLACK)); @@ -512,9 +513,7 @@ SmElementsDockingWindow::SmElementsDockingWindow(SfxBindings* pInputBindings, Sf maElementListBox.SetDropDownLineCount( 10 ); for (sal_uInt16 i = 0; i < sizeof(aCategories) / sizeof(sal_uInt16) ; i++) - { maElementListBox.InsertEntry(SM_RESSTR(aCategories[i])); - } maElementListBox.SetSelectHdl(LINK(this, SmElementsDockingWindow, ElementSelectedHandle)); @@ -527,6 +526,10 @@ SmElementsDockingWindow::SmElementsDockingWindow(SfxBindings* pInputBindings, Sf maElementListBox.SelectEntry(SM_RESSTR(RID_CATEGORY_UNARY_BINARY_OPERATORS)); maElementsControl.setElementSetId(RID_CATEGORY_UNARY_BINARY_OPERATORS); + mpScroll->SetScrollHdl( LINK(this, SmElementsDockingWindow, ScrollHdl) ); + mpScroll->EnableDrag(); + mpScroll->Show(); + FreeResource(); } @@ -534,6 +537,21 @@ SmElementsDockingWindow::~SmElementsDockingWindow () { } +IMPL_LINK_NOARG( SmElementsDockingWindow, ScrollHdl ) +{ + DoScroll(mpScroll->GetDelta()); + return 0; +} + +void SmElementsDockingWindow::DoScroll(long nDelta) +{ + Point aNewPoint = mpScroll->GetPosPixel(); + Rectangle aRect(Point(), GetOutputSize()); + aRect.Right() -= mpScroll->GetSizePixel().Width(); + Scroll( 0, -nDelta, aRect ); + mpScroll->SetPosPixel(aNewPoint); +} + void SmElementsDockingWindow::EndDocking( const Rectangle& rReactangle, sal_Bool bFloatMode) { SfxDockingWindow::EndDocking(rReactangle, bFloatMode); @@ -585,14 +603,31 @@ void SmElementsDockingWindow::Resize() sal_uInt32 aElementsSetsHeight = 23; sal_uInt32 aPadding = 5; - Rectangle aRect1 = Rectangle(aPadding, aPadding, aWidth - aPadding, aElementsSetsHeight + aPadding); + Rectangle aRect = Rectangle(aPadding, aElementsSetsHeight + aPadding + aPadding, aWidth - aPadding, aHeight - aPadding); maElementListBox.SetPosSizePixel(aRect1.TopLeft(), aRect1.GetSize()); + maElementsControl.SetPosSizePixel(aRect.TopLeft(), aRect.GetSize()); - Rectangle aRect = Rectangle(aPadding, aElementsSetsHeight + aPadding + aPadding, aWidth - aPadding, aHeight - aPadding); + sal_uInt32 nEnd = maElementsControl.getList()[maElementsControl.getList().size() - 1].get()->mBoxLocation.Y(); - maElementsControl.SetPosSizePixel(aRect.TopLeft(), aRect.GetSize()); + if (static_cast(nEnd) > GetOutputSizePixel().Height()) + { + mpScroll->SetRangeMax(nEnd); + sal_uInt32 nScrollbarWidth = GetSettings().GetStyleSettings().GetScrollBarSize(); + mpScroll->SetPosSizePixel(Point(aWidth - nScrollbarWidth, 0), Size(nScrollbarWidth, aHeight)); + mpScroll->SetVisibleSize(aHeight); + mpScroll->Show(); + aRect1.setWidth(aRect1.GetWidth() - nScrollbarWidth); + aRect.setWidth(aRect.GetWidth() - nScrollbarWidth); + + maElementListBox.SetPosSizePixel(aRect1.TopLeft(), aRect1.GetSize()); + maElementsControl.SetPosSizePixel(aRect.TopLeft(), aRect.GetSize()); + } + else + { + mpScroll->Hide(); + } SfxDockingWindow::Resize(); Invalidate();