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