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_TITLE_BAR_HXX 25cdf0e10cSrcweir #define SD_TASKPANE_TITLE_BAR_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "taskpane/TaskPaneTreeNode.hxx" 28cdf0e10cSrcweir #include <vcl/image.hxx> 29cdf0e10cSrcweir #include <tools/string.hxx> 30cdf0e10cSrcweir #include <vcl/window.hxx> 31cdf0e10cSrcweir #include <memory> 32cdf0e10cSrcweir 33cdf0e10cSrcweir class Rectangle; 34cdf0e10cSrcweir class String; 35cdf0e10cSrcweir class VirtualDevice; 36cdf0e10cSrcweir 37cdf0e10cSrcweir namespace sd { namespace toolpanel { 38cdf0e10cSrcweir 39cdf0e10cSrcweir 40cdf0e10cSrcweir /** The title bar above a control in a sub tool panel. 41cdf0e10cSrcweir 42cdf0e10cSrcweir <p>The title bar shows two kinds of indicators: 1) Expansion is 43cdf0e10cSrcweir displayed by two sets of two bitmaps, a triangle pointing to the right 44cdf0e10cSrcweir resp. a minus in a square indicates that the control is collapsed, a 45cdf0e10cSrcweir triangle pointing down resp. a plus in a square stands for an expanded 46cdf0e10cSrcweir control. 2) Keyboard focus is indicated by a dotted rectangle. 47cdf0e10cSrcweir */ 48cdf0e10cSrcweir class TitleBar 49cdf0e10cSrcweir : public ::Window, 50cdf0e10cSrcweir public TreeNode 51cdf0e10cSrcweir { 52cdf0e10cSrcweir public: 53cdf0e10cSrcweir enum TitleBarType { 54cdf0e10cSrcweir TBT_SUB_CONTROL_HEADLINE 55cdf0e10cSrcweir }; 56cdf0e10cSrcweir 57cdf0e10cSrcweir /** Create a new title bar whose content, the given title string, 58cdf0e10cSrcweir will be formatted according to the given type. 59cdf0e10cSrcweir */ 60cdf0e10cSrcweir TitleBar ( 61cdf0e10cSrcweir ::Window* pParent, 62cdf0e10cSrcweir const String& rsTitle, 63cdf0e10cSrcweir TitleBarType eType, 64cdf0e10cSrcweir bool bIsExpandable); 65cdf0e10cSrcweir virtual ~TitleBar (void); 66cdf0e10cSrcweir 67cdf0e10cSrcweir virtual Size GetPreferredSize (void); 68cdf0e10cSrcweir virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight); 69cdf0e10cSrcweir virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); 70cdf0e10cSrcweir virtual bool IsResizable (void); 71cdf0e10cSrcweir virtual ::Window* GetWindow (void); 72cdf0e10cSrcweir virtual sal_Int32 GetMinimumWidth (void); 73cdf0e10cSrcweir 74cdf0e10cSrcweir virtual void Paint (const Rectangle& rBoundingBox); 75cdf0e10cSrcweir virtual bool Expand (bool bFlag = true); 76cdf0e10cSrcweir virtual bool IsExpanded (void) const; 77cdf0e10cSrcweir virtual void SetEnabledState(bool bFlag); 78cdf0e10cSrcweir virtual void GetFocus (void); 79cdf0e10cSrcweir virtual void LoseFocus (void); 80cdf0e10cSrcweir 81cdf0e10cSrcweir virtual void MouseMove(const MouseEvent& rEvent); 82cdf0e10cSrcweir /** Empty implementation prevents forwarding to docking window. 83cdf0e10cSrcweir */ 84cdf0e10cSrcweir virtual void MouseButtonDown (const MouseEvent& rEvent); 85cdf0e10cSrcweir /** Empty implementation prevents forwarding to docking window. 86cdf0e10cSrcweir */ 87cdf0e10cSrcweir virtual void MouseButtonUp (const MouseEvent& rEvent); 88cdf0e10cSrcweir 89cdf0e10cSrcweir virtual void DataChanged (const DataChangedEvent& rEvent); 90cdf0e10cSrcweir 91cdf0e10cSrcweir String GetTitle (void) const; 92cdf0e10cSrcweir 93cdf0e10cSrcweir ::com::sun::star::uno::Reference< 94cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible > CreateAccessibleObject ( 95cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 96cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent); 97cdf0e10cSrcweir 98cdf0e10cSrcweir private: 99cdf0e10cSrcweir TitleBarType meType; 100cdf0e10cSrcweir String msTitle; 101cdf0e10cSrcweir bool mbExpanded; 102cdf0e10cSrcweir bool mbFocused; 103cdf0e10cSrcweir // Size of the bounding box that encloses the title string. 104cdf0e10cSrcweir ::std::auto_ptr<VirtualDevice> mpDevice; 105cdf0e10cSrcweir bool mbIsExpandable; 106cdf0e10cSrcweir 107cdf0e10cSrcweir /** Return whether this TitleBar object has an expansion indicator 108cdf0e10cSrcweir bitmap. It is safe to call GetExpansionIndicator() when this method 109cdf0e10cSrcweir returns <FALSE/> but unnecessary. 110cdf0e10cSrcweir */ 111cdf0e10cSrcweir bool HasExpansionIndicator (void) const; 112cdf0e10cSrcweir 113cdf0e10cSrcweir /** Return the image of the expansion indicator. 114cdf0e10cSrcweir @return 115cdf0e10cSrcweir When there is no expansion indictor for this TitleBar object, 116cdf0e10cSrcweir then an empty Image is returned. You better call 117cdf0e10cSrcweir HasExpansionIndicator() to prevent this. 118cdf0e10cSrcweir */ 119cdf0e10cSrcweir Image GetExpansionIndicator (void) const; 120cdf0e10cSrcweir 121cdf0e10cSrcweir /** Calculate the bounding box of the title text. This takes into 122cdf0e10cSrcweir account indentation due to an expansion indicator and the given 123cdf0e10cSrcweir available width. When the text can not be displayed on one line, it 124cdf0e10cSrcweir is broken into multiple lines. 125cdf0e10cSrcweir @param nAvailableWidth 126cdf0e10cSrcweir When 0 is given then the natural text width is used, i.e. the 127cdf0e10cSrcweir text is not broken into multiple lines. 128cdf0e10cSrcweir */ 129cdf0e10cSrcweir Rectangle CalculateTextBoundingBox ( 130cdf0e10cSrcweir int nAvailableWidth, 131cdf0e10cSrcweir bool bEmphasizeExpanded); 132cdf0e10cSrcweir 133cdf0e10cSrcweir /** Add some space to the given text box and return the bounding box of 134cdf0e10cSrcweir the title bar. 135cdf0e10cSrcweir */ 136cdf0e10cSrcweir Rectangle CalculateTitleBarBox ( 137cdf0e10cSrcweir const Rectangle& rTextBox, 138cdf0e10cSrcweir int nTitleBarWidth); 139cdf0e10cSrcweir 140cdf0e10cSrcweir void PaintSubPanelHeadLineBar (void); 141cdf0e10cSrcweir 142cdf0e10cSrcweir void PaintBackground (const Rectangle& rTextBox); 143cdf0e10cSrcweir 144cdf0e10cSrcweir /// Paint a focus indicator that encloses the given rectangle. 145cdf0e10cSrcweir void PaintFocusIndicator (const Rectangle& rIndicatorBox); 146cdf0e10cSrcweir 147cdf0e10cSrcweir Rectangle PaintExpansionIndicator (const Rectangle& rTextBox); 148cdf0e10cSrcweir 149cdf0e10cSrcweir void PaintText (const Rectangle& rTextBox); 150cdf0e10cSrcweir 151cdf0e10cSrcweir sal_uInt16 GetTextStyle (void); 152cdf0e10cSrcweir 153cdf0e10cSrcweir const static int snIndentationWidth; 154cdf0e10cSrcweir 155cdf0e10cSrcweir // Default constructor, copy constructor, and assignment are not supported. 156cdf0e10cSrcweir TitleBar (void); 157cdf0e10cSrcweir TitleBar (const TitleBar&); 158cdf0e10cSrcweir TitleBar& operator= (const TitleBar&); 159cdf0e10cSrcweir 160cdf0e10cSrcweir using Window::GetWindow; 161cdf0e10cSrcweir }; 162cdf0e10cSrcweir 163cdf0e10cSrcweir } } // end of namespace ::sd::toolpanel 164cdf0e10cSrcweir 165cdf0e10cSrcweir #endif 166