1*c45d927aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*c45d927aSAndrew Rist * distributed with this work for additional information 6*c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9*c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10*c45d927aSAndrew Rist * 11*c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*c45d927aSAndrew Rist * 13*c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*c45d927aSAndrew Rist * software distributed under the License is distributed on an 15*c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17*c45d927aSAndrew Rist * specific language governing permissions and limitations 18*c45d927aSAndrew Rist * under the License. 19*c45d927aSAndrew Rist * 20*c45d927aSAndrew Rist *************************************************************/ 21*c45d927aSAndrew Rist 22*c45d927aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SD_TOOLPANEL_SCROLL_PANEL_HXX 25cdf0e10cSrcweir #define SD_TOOLPANEL_SCROLL_PANEL_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "taskpane/TaskPaneTreeNode.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <vcl/ctrl.hxx> 30cdf0e10cSrcweir #include <vcl/scrbar.hxx> 31cdf0e10cSrcweir #include <memory> 32cdf0e10cSrcweir #include <vector> 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace sd { namespace toolpanel { 35cdf0e10cSrcweir 36cdf0e10cSrcweir class TitledControl; 37cdf0e10cSrcweir 38cdf0e10cSrcweir /** The scroll panel shows its controls one above the other. When their 39cdf0e10cSrcweir total height is larger than the height of the scroll area then only a 40cdf0e10cSrcweir part of the controls is visible. Scroll bars control which part that 41cdf0e10cSrcweir is. 42cdf0e10cSrcweir 43cdf0e10cSrcweir The scroll panel registers itself as window event listener at the 44cdf0e10cSrcweir controls and their title bars (conceptually; it really is the 45cdf0e10cSrcweir TitledControl) to track changes of the selection and focus rectangles. 46cdf0e10cSrcweir On such a change it tries to move the selected or focused part into the 47cdf0e10cSrcweir visible area. At the moment this moving into view only works with 48cdf0e10cSrcweir valuesets and TitleBars. 49cdf0e10cSrcweir */ 50cdf0e10cSrcweir class ScrollPanel 51cdf0e10cSrcweir : public ::Control, 52cdf0e10cSrcweir public TreeNode 53cdf0e10cSrcweir { 54cdf0e10cSrcweir public: 55cdf0e10cSrcweir /** Create a new scroll panel which itself is the root of a TreeNode hierarchy 56cdf0e10cSrcweir parent. This will usually be a child window. 57cdf0e10cSrcweir */ 58cdf0e10cSrcweir ScrollPanel (::Window& i_rParentWindow); 59cdf0e10cSrcweir virtual ~ScrollPanel (void); 60cdf0e10cSrcweir 61cdf0e10cSrcweir /** Add a control to the sub panel. An title bar is added above the 62cdf0e10cSrcweir control. 63cdf0e10cSrcweir @param rTitle 64cdf0e10cSrcweir The title that will be shown in the two title bars that 65cdf0e10cSrcweir belong to the control. 66cdf0e10cSrcweir @param nHelpId 67cdf0e10cSrcweir The help id is set at the title bar not the actual control. 68cdf0e10cSrcweir @return 69cdf0e10cSrcweir The new titled control that contains the given control and a new 70cdf0e10cSrcweir title bar as children is returned. 71cdf0e10cSrcweir */ 72cdf0e10cSrcweir TitledControl* AddControl ( 73cdf0e10cSrcweir ::std::auto_ptr<TreeNode> pControl, 74cdf0e10cSrcweir const String& rTitle, 75cdf0e10cSrcweir const rtl::OString& sHelpId); 76cdf0e10cSrcweir 77cdf0e10cSrcweir /** Add a control to the sub panel without a title bar. 78cdf0e10cSrcweir */ 79cdf0e10cSrcweir void AddControl (::std::auto_ptr<TreeNode> pControl); 80cdf0e10cSrcweir 81cdf0e10cSrcweir virtual void Paint (const Rectangle& rRect); 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** Initiate a rearrangement of the controls and title bars. 84cdf0e10cSrcweir */ 85cdf0e10cSrcweir virtual void Resize (void); 86cdf0e10cSrcweir 87cdf0e10cSrcweir virtual void RequestResize (void); 88cdf0e10cSrcweir 89cdf0e10cSrcweir virtual Size GetPreferredSize (void); 90cdf0e10cSrcweir virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight); 91cdf0e10cSrcweir virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); 92cdf0e10cSrcweir virtual bool IsResizable (void); 93cdf0e10cSrcweir virtual ::Window* GetWindow (void); 94cdf0e10cSrcweir virtual sal_Int32 GetMinimumWidth (void); 95cdf0e10cSrcweir 96cdf0e10cSrcweir virtual void ExpandControl ( 97cdf0e10cSrcweir TreeNode* pControl, 98cdf0e10cSrcweir bool bExpansionState); 99cdf0e10cSrcweir 100cdf0e10cSrcweir bool IsVerticalScrollBarVisible (void) const; 101cdf0e10cSrcweir bool IsHorizontalScrollBarVisible (void) const; 102cdf0e10cSrcweir ScrollBar& GetVerticalScrollBar (void); 103cdf0e10cSrcweir ScrollBar& GetHorizontalScrollBar (void); 104cdf0e10cSrcweir 105cdf0e10cSrcweir // ::Window 106cdf0e10cSrcweir virtual long Notify( NotifyEvent& rNEvt ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 109cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> CreateAccessibleObject ( 110cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 111cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent); 112cdf0e10cSrcweir 113cdf0e10cSrcweir /** Scroll the given rectangle into the visible area. 114cdf0e10cSrcweir @param aRectangle 115cdf0e10cSrcweir The box to move into the visible area in pixel coordinates 116cdf0e10cSrcweir relative to the given window. 117cdf0e10cSrcweir @param pWindow 118cdf0e10cSrcweir This window is used to translate the given coordinates into ones 119cdf0e10cSrcweir that are relative to the scroll panel. 120cdf0e10cSrcweir 121cdf0e10cSrcweir */ 122cdf0e10cSrcweir void MakeRectangleVisible ( 123cdf0e10cSrcweir Rectangle& aRectangle, 124cdf0e10cSrcweir ::Window* pWindow); 125cdf0e10cSrcweir 126cdf0e10cSrcweir private: 127cdf0e10cSrcweir ::Control maScrollWindow; 128cdf0e10cSrcweir ScrollBar maVerticalScrollBar; 129cdf0e10cSrcweir ScrollBar maHorizontalScrollBar; 130cdf0e10cSrcweir ::Window maScrollBarFiller; 131cdf0e10cSrcweir ::Window maScrollWindowFiller; 132cdf0e10cSrcweir Point maScrollOffset; 133cdf0e10cSrcweir bool mbIsRearrangePending; 134cdf0e10cSrcweir bool mbIsLayoutPending; 135cdf0e10cSrcweir sal_uInt32 mnChildrenWidth; 136cdf0e10cSrcweir /// Border above top-most and below bottom-most control. 137cdf0e10cSrcweir const int mnVerticalBorder; 138cdf0e10cSrcweir /// Gap between two controls. 139cdf0e10cSrcweir const int mnVerticalGap; 140cdf0e10cSrcweir /// Border at the left and right of the controls. 141cdf0e10cSrcweir const int mnHorizontalBorder; 142cdf0e10cSrcweir /** List of horizontal stripes that is created from the gaps between 143cdf0e10cSrcweir children when they are layouted. The stripes are painted in Paint() 144cdf0e10cSrcweir to fill the space arround the children. 145cdf0e10cSrcweir */ 146cdf0e10cSrcweir typedef ::std::vector< ::std::pair<int,int> > StripeList; 147cdf0e10cSrcweir StripeList maStripeList; 148cdf0e10cSrcweir 149cdf0e10cSrcweir /** Calculate position, size, and visibility of the controls. 150cdf0e10cSrcweir Call this method after the list of controls, their expansion 151cdf0e10cSrcweir state, or the size of the sub panel has changed. 152cdf0e10cSrcweir */ 153cdf0e10cSrcweir void Rearrange (void); 154cdf0e10cSrcweir 155cdf0e10cSrcweir /** Determine the minimal size that is necessary to show the controls 156cdf0e10cSrcweir one over the other. It may be smaller than the available area. 157cdf0e10cSrcweir */ 158cdf0e10cSrcweir Size GetRequiredSize (void); 159cdf0e10cSrcweir 160cdf0e10cSrcweir /** Place the child windows one above the other and return the size of 161cdf0e10cSrcweir the bounding box. 162cdf0e10cSrcweir */ 163cdf0e10cSrcweir sal_Int32 LayoutChildren (void); 164cdf0e10cSrcweir 165cdf0e10cSrcweir /** ctor-impl 166cdf0e10cSrcweir */ 167cdf0e10cSrcweir void Construct(); 168cdf0e10cSrcweir 169cdf0e10cSrcweir Size SetupScrollBars (const Size& rRequiresSize); 170cdf0e10cSrcweir sal_Int32 SetupVerticalScrollBar (bool bShow, sal_Int32 nRange); 171cdf0e10cSrcweir sal_Int32 SetupHorizontalScrollBar (bool bShow, sal_Int32 nRange); 172cdf0e10cSrcweir 173cdf0e10cSrcweir DECL_LINK(ScrollBarHandler, ScrollBar*); 174cdf0e10cSrcweir DECL_LINK(WindowEventListener, VclSimpleEvent*); 175cdf0e10cSrcweir 176cdf0e10cSrcweir using Window::GetWindow; 177cdf0e10cSrcweir }; 178cdf0e10cSrcweir 179cdf0e10cSrcweir } } // end of namespace ::sd::toolpanel 180cdf0e10cSrcweir 181cdf0e10cSrcweir #endif 182