1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SD_TASKPANE_SUB_TOOL_PANEL_HXX 29 #define SD_TASKPANE_SUB_TOOL_PANEL_HXX 30 31 #include "taskpane/TaskPaneTreeNode.hxx" 32 33 #include <vcl/ctrl.hxx> 34 #include <vcl/scrbar.hxx> 35 #include <memory> 36 #include <vector> 37 38 39 class Window; 40 41 namespace sd { namespace toolpanel { 42 43 /** The sub tool panel is in function similar to the tool panel. It 44 differes in two points. First, it is a control that can be used 45 as element in a tool panel and thus is actually a nested tool 46 panel. 47 48 <p>Secondly, it formats its elements differently. The actual controls 49 are placed one below the other with a title bar above each control. 50 Clicking on the title bar expands or collapses the control. When there 51 is not enough space then scroll bars are shown.</p> 52 53 <p>To avoid flickering when painting the sub tool panel the background 54 is made transparent and painting it is done by this class. While 55 layouting its children it remembers the gaps between children and stores 56 them in maStripeList. In Paint() those gaps as well as the border 57 arround all children are painted in the background color.</p> 58 */ 59 class SubToolPanel 60 : public Control, 61 public TreeNode 62 { 63 public: 64 /** Create a new sub tool panel with the given window as its 65 parent. This will usually be a child window. 66 */ 67 SubToolPanel (Window& i_rParentWindow); 68 virtual ~SubToolPanel (void); 69 70 virtual void Paint (const Rectangle& rRect); 71 72 /** Initiate a rearrangement of the controls and title bars. 73 */ 74 virtual void Resize (void); 75 76 virtual void RequestResize (void); 77 78 virtual Size GetPreferredSize (void); 79 virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight); 80 virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); 81 virtual bool IsResizable (void); 82 virtual ::Window* GetWindow (void); 83 virtual sal_Int32 GetMinimumWidth (void); 84 85 virtual void ExpandControl ( 86 TreeNode* pControl, 87 bool bExpansionState); 88 89 virtual ::com::sun::star::uno::Reference< 90 ::com::sun::star::accessibility::XAccessible> CreateAccessibleObject ( 91 const ::com::sun::star::uno::Reference< 92 ::com::sun::star::accessibility::XAccessible>& rxParent); 93 94 using Window::GetWindow; 95 private: 96 ::Window maWindowFiller; 97 bool mbIsRearrangePending; 98 bool mbIsLayoutPending; 99 sal_uInt32 mnChildrenWidth; 100 /// Border above top-most and below bottom-most control. 101 const int mnVerticalBorder; 102 /// Gap between two controls. 103 const int mnVerticalGap; 104 /// Border at the left and right of the controls. 105 const int mnHorizontalBorder; 106 /** List of horizontal stripes that is created from the gaps between 107 children when they are layouted. The stripes are painted in Paint() 108 to fill the space arround the children. 109 */ 110 typedef ::std::vector< ::std::pair<int,int> > StripeList; 111 StripeList maStripeList; 112 113 /** Calculate position, size, and visibility of the controls. 114 Call this method after the list of controls, their expansion 115 state, or the size of the sub panel has changed. 116 */ 117 void Rearrange (void); 118 119 /** Determine the minimal size that is necessary to show the controls 120 one over the other. It may be smaller than the available area. 121 */ 122 Size GetRequiredSize (void); 123 124 /** Place the child windows one above the other and return the size of 125 the bounding box. 126 */ 127 sal_Int32 LayoutChildren (void); 128 129 DECL_LINK(WindowEventListener, VclSimpleEvent*); 130 }; 131 132 } } // end of namespace ::sd::toolpanel 133 134 #endif 135