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