Update ooo320-m1
[ooovba.git] / sd / source / ui / inc / taskpane / TitleBar.hxx
blobb5271e85cc192febaad41f8b2bffad078e009cee
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TitleBar.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TASKPANE_TITLE_BAR_HXX
32 #define SD_TASKPANE_TITLE_BAR_HXX
34 #include "taskpane/TaskPaneTreeNode.hxx"
35 #include <vcl/image.hxx>
36 #include <tools/string.hxx>
37 #include <vcl/window.hxx>
38 #include <memory>
40 class Rectangle;
41 class String;
42 class VirtualDevice;
44 namespace sd { namespace toolpanel {
47 /** The title bar above a control in a tool panel or sub tool panel.
48 The way the title bar is displayed depends on the TitleBarType
49 given to the constructor. TBT_CONTROL_TITLE and
50 TBT_SUB_CONTROL_HEADLINE both show a expansion indicator in front of
51 the title string that shows whether the associated control is
52 visible (expanded) or not.
53 A title bar with TBT_WINDOW_TITLE is typically used only once as the
54 title bar of the whole task pane.
56 <p>The title bar shows three kinds of indicators: 1) Expansion is
57 displayed by two sets of two bitmaps, a triangle pointing to the right
58 resp. a minus in a square indicates that the control is collapsed, a
59 triangle pointing down resp. a plus in a square stands for an expanded
60 control. 2) Keyboard focus is indicated by a dotted rectangle. 3) An
61 underlined title string is a mouse over indicator for a
62 selectable/expandable control.</p>
64 class TitleBar
65 : public ::Window,
66 public TreeNode
68 public:
69 enum TitleBarType {
70 TBT_WINDOW_TITLE,
71 TBT_CONTROL_TITLE,
72 TBT_SUB_CONTROL_HEADLINE
75 /** Create a new title bar whose content, the given title string,
76 will be formatted according to the given type.
78 TitleBar (
79 ::Window* pParent,
80 const String& rsTitle,
81 TitleBarType eType,
82 bool bIsExpandable);
83 virtual ~TitleBar (void);
85 virtual Size GetPreferredSize (void);
86 virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
87 virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
88 virtual bool IsResizable (void);
89 virtual ::Window* GetWindow (void);
90 virtual sal_Int32 GetMinimumWidth (void);
92 virtual void Paint (const Rectangle& rBoundingBox);
93 virtual bool Expand (bool bFlag = true);
94 virtual bool IsExpanded (void) const;
95 virtual void SetEnabledState(bool bFlag);
97 void SetFocus (bool bFlag);
99 virtual void MouseMove(const MouseEvent& rEvent);
100 /** Empty implementation prevents forwarding to docking window.
102 virtual void MouseButtonDown (const MouseEvent& rEvent);
103 /** Empty implementation prevents forwarding to docking window.
105 virtual void MouseButtonUp (const MouseEvent& rEvent);
107 virtual void DataChanged (const DataChangedEvent& rEvent);
109 String GetTitle (void) const;
111 ::com::sun::star::uno::Reference<
112 ::com::sun::star::accessibility::XAccessible > CreateAccessibleObject (
113 const ::com::sun::star::uno::Reference<
114 ::com::sun::star::accessibility::XAccessible>& rxParent);
116 private:
117 TitleBarType meType;
118 String msTitle;
119 bool mbExpanded;
120 bool mbFocused;
121 bool mbMouseOver;
122 // Size of the bounding box that encloses the title string.
123 Size maStringBox;
124 ::std::auto_ptr<VirtualDevice> mpDevice;
125 bool mbIsExpandable;
127 /** Set the mbMouseOver flag to the given value and paint the
128 title bar accordingly.
130 void SetMouseOver (bool bFlag);
132 /** Return whether this TitleBar object has an expansion indicator
133 bitmap. It is safe to call GetExpansionIndicator() when this method
134 returns <FALSE/> but unnecessary.
136 bool HasExpansionIndicator (void) const;
138 /** Return the image of the expansion indicator.
139 @return
140 When there is no expansion indictor for this TitleBar object,
141 then an empty Image is returned. You better call
142 HasExpansionIndicator() to prevent this.
144 Image GetExpansionIndicator (void) const;
146 /** Calculate the bounding box of the title text. This takes into
147 account indentation due to an expansion indicator and the given
148 available width. When the text can not be displayed on one line, it
149 is broken into multiple lines.
150 @param nAvailableWidth
151 When 0 is given then the natural text width is used, i.e. the
152 text is not broken into multiple lines.
154 Rectangle CalculateTextBoundingBox (
155 int nAvailableWidth,
156 bool bEmphasizeExpanded);
158 /** Add some space to the given text box and return the bounding box of
159 the title bar.
161 Rectangle CalculateTitleBarBox (
162 const Rectangle& rTextBox,
163 int nTitleBarWidth);
165 void PaintWindowTitleBar (void);
166 void PaintPanelControlTitle (void);
167 void PaintSubPanelHeadLineBar (void);
169 void PaintBackground (const Rectangle& rTextBox);
171 /// Paint a focus indicator that encloses the given rectangle.
172 void PaintFocusIndicator (const Rectangle& rIndicatorBox);
174 /** Paint a mouse over indicator. If the mouse is over the title
175 bar than the text enclosed by the given rectangle is
176 underlined.
178 void PaintMouseOverIndicator (const Rectangle& rIndicatorBox);
180 Rectangle PaintExpansionIndicator (const Rectangle& rTextBox);
182 void PaintText (const Rectangle& rTextBox);
184 USHORT GetTextStyle (void);
186 const static int snIndentationWidth;
188 // Default constructor, copy constructor, and assignment are not supported.
189 TitleBar (void);
190 TitleBar (const TitleBar&);
191 TitleBar& operator= (const TitleBar&);
193 using Window::GetWindow;
196 } } // end of namespace ::sd::toolpanel
198 #endif