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_TASKPANE_SUB_TOOL_PANEL_HXX 29*cdf0e10cSrcweir #define SD_TASKPANE_SUB_TOOL_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 39*cdf0e10cSrcweir class Window; 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir namespace sd { namespace toolpanel { 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir /** The sub tool panel is in function similar to the tool panel. It 44*cdf0e10cSrcweir differes in two points. First, it is a control that can be used 45*cdf0e10cSrcweir as element in a tool panel and thus is actually a nested tool 46*cdf0e10cSrcweir panel. 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir <p>Secondly, it formats its elements differently. The actual controls 49*cdf0e10cSrcweir are placed one below the other with a title bar above each control. 50*cdf0e10cSrcweir Clicking on the title bar expands or collapses the control. When there 51*cdf0e10cSrcweir is not enough space then scroll bars are shown.</p> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir <p>To avoid flickering when painting the sub tool panel the background 54*cdf0e10cSrcweir is made transparent and painting it is done by this class. While 55*cdf0e10cSrcweir layouting its children it remembers the gaps between children and stores 56*cdf0e10cSrcweir them in maStripeList. In Paint() those gaps as well as the border 57*cdf0e10cSrcweir arround all children are painted in the background color.</p> 58*cdf0e10cSrcweir */ 59*cdf0e10cSrcweir class SubToolPanel 60*cdf0e10cSrcweir : public Control, 61*cdf0e10cSrcweir public TreeNode 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir public: 64*cdf0e10cSrcweir /** Create a new sub tool panel with the given window as its 65*cdf0e10cSrcweir parent. This will usually be a child window. 66*cdf0e10cSrcweir */ 67*cdf0e10cSrcweir SubToolPanel (Window& i_rParentWindow); 68*cdf0e10cSrcweir virtual ~SubToolPanel (void); 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir virtual void Paint (const Rectangle& rRect); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir /** Initiate a rearrangement of the controls and title bars. 73*cdf0e10cSrcweir */ 74*cdf0e10cSrcweir virtual void Resize (void); 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir virtual void RequestResize (void); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir virtual Size GetPreferredSize (void); 79*cdf0e10cSrcweir virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight); 80*cdf0e10cSrcweir virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); 81*cdf0e10cSrcweir virtual bool IsResizable (void); 82*cdf0e10cSrcweir virtual ::Window* GetWindow (void); 83*cdf0e10cSrcweir virtual sal_Int32 GetMinimumWidth (void); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir virtual void ExpandControl ( 86*cdf0e10cSrcweir TreeNode* pControl, 87*cdf0e10cSrcweir bool bExpansionState); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 90*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> CreateAccessibleObject ( 91*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 92*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir using Window::GetWindow; 95*cdf0e10cSrcweir private: 96*cdf0e10cSrcweir ::Window maWindowFiller; 97*cdf0e10cSrcweir bool mbIsRearrangePending; 98*cdf0e10cSrcweir bool mbIsLayoutPending; 99*cdf0e10cSrcweir sal_uInt32 mnChildrenWidth; 100*cdf0e10cSrcweir /// Border above top-most and below bottom-most control. 101*cdf0e10cSrcweir const int mnVerticalBorder; 102*cdf0e10cSrcweir /// Gap between two controls. 103*cdf0e10cSrcweir const int mnVerticalGap; 104*cdf0e10cSrcweir /// Border at the left and right of the controls. 105*cdf0e10cSrcweir const int mnHorizontalBorder; 106*cdf0e10cSrcweir /** List of horizontal stripes that is created from the gaps between 107*cdf0e10cSrcweir children when they are layouted. The stripes are painted in Paint() 108*cdf0e10cSrcweir to fill the space arround the children. 109*cdf0e10cSrcweir */ 110*cdf0e10cSrcweir typedef ::std::vector< ::std::pair<int,int> > StripeList; 111*cdf0e10cSrcweir StripeList maStripeList; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir /** Calculate position, size, and visibility of the controls. 114*cdf0e10cSrcweir Call this method after the list of controls, their expansion 115*cdf0e10cSrcweir state, or the size of the sub panel has changed. 116*cdf0e10cSrcweir */ 117*cdf0e10cSrcweir void Rearrange (void); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir /** Determine the minimal size that is necessary to show the controls 120*cdf0e10cSrcweir one over the other. It may be smaller than the available area. 121*cdf0e10cSrcweir */ 122*cdf0e10cSrcweir Size GetRequiredSize (void); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir /** Place the child windows one above the other and return the size of 125*cdf0e10cSrcweir the bounding box. 126*cdf0e10cSrcweir */ 127*cdf0e10cSrcweir sal_Int32 LayoutChildren (void); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir DECL_LINK(WindowEventListener, VclSimpleEvent*); 130*cdf0e10cSrcweir }; 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir } } // end of namespace ::sd::toolpanel 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir #endif 135