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