xref: /trunk/main/sd/source/ui/inc/taskpane/TitleBar.hxx (revision 6c3f46008062a6f976c36b489e4ef55c817e828c)
1c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c45d927aSAndrew Rist  * distributed with this work for additional information
6c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17c45d927aSAndrew Rist  * specific language governing permissions and limitations
18c45d927aSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20c45d927aSAndrew Rist  *************************************************************/
21c45d927aSAndrew Rist 
22cdf0e10cSrcweir #ifndef SD_TASKPANE_TITLE_BAR_HXX
23cdf0e10cSrcweir #define SD_TASKPANE_TITLE_BAR_HXX
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include "taskpane/TaskPaneTreeNode.hxx"
26cdf0e10cSrcweir #include <vcl/image.hxx>
27cdf0e10cSrcweir #include <tools/string.hxx>
28cdf0e10cSrcweir #include <vcl/window.hxx>
29cdf0e10cSrcweir #include <memory>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir class Rectangle;
32cdf0e10cSrcweir class String;
33cdf0e10cSrcweir class VirtualDevice;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace sd { namespace toolpanel {
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /** The title bar above a control in a sub tool panel.
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     <p>The title bar shows two kinds of indicators: 1) Expansion is
40cdf0e10cSrcweir     displayed by two sets of two bitmaps, a triangle pointing to the right
41cdf0e10cSrcweir     resp. a minus in a square indicates that the control is collapsed, a
42cdf0e10cSrcweir     triangle pointing down resp. a plus in a square stands for an expanded
43cdf0e10cSrcweir     control. 2) Keyboard focus is indicated by a dotted rectangle.
44cdf0e10cSrcweir */
45cdf0e10cSrcweir class TitleBar
46cdf0e10cSrcweir     : public ::Window,
47cdf0e10cSrcweir       public TreeNode
48cdf0e10cSrcweir {
49cdf0e10cSrcweir public:
50cdf0e10cSrcweir     enum TitleBarType {
51cdf0e10cSrcweir         TBT_SUB_CONTROL_HEADLINE
52cdf0e10cSrcweir     };
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     /** Create a new title bar whose content, the given title string,
55cdf0e10cSrcweir         will be formatted according to the given type.
56cdf0e10cSrcweir      */
57cdf0e10cSrcweir     TitleBar (
58cdf0e10cSrcweir         ::Window* pParent,
59cdf0e10cSrcweir         const String& rsTitle,
60cdf0e10cSrcweir         TitleBarType eType,
61cdf0e10cSrcweir         bool bIsExpandable);
62cdf0e10cSrcweir     virtual ~TitleBar (void);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     virtual Size GetPreferredSize (void);
65cdf0e10cSrcweir     virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
66cdf0e10cSrcweir     virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
67cdf0e10cSrcweir     virtual bool IsResizable (void);
68cdf0e10cSrcweir     virtual ::Window* GetWindow (void);
69cdf0e10cSrcweir     virtual sal_Int32 GetMinimumWidth (void);
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     virtual void Paint (const Rectangle& rBoundingBox);
72cdf0e10cSrcweir     virtual bool Expand (bool bFlag = true);
73cdf0e10cSrcweir     virtual bool IsExpanded (void) const;
74cdf0e10cSrcweir     virtual void SetEnabledState(bool bFlag);
75cdf0e10cSrcweir     virtual void GetFocus (void);
76cdf0e10cSrcweir     virtual void LoseFocus (void);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     virtual void MouseMove(const MouseEvent& rEvent);
79cdf0e10cSrcweir     /** Empty implementation prevents forwarding to docking window.
80cdf0e10cSrcweir      */
81cdf0e10cSrcweir     virtual void MouseButtonDown (const MouseEvent& rEvent);
82cdf0e10cSrcweir     /** Empty implementation prevents forwarding to docking window.
83cdf0e10cSrcweir      */
84cdf0e10cSrcweir     virtual void MouseButtonUp (const MouseEvent& rEvent);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     virtual void DataChanged (const DataChangedEvent& rEvent);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     String GetTitle (void) const;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
91cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > CreateAccessibleObject (
92cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
93cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessible>& rxParent);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir private:
96cdf0e10cSrcweir     TitleBarType meType;
97cdf0e10cSrcweir     String msTitle;
98cdf0e10cSrcweir     bool mbExpanded;
99cdf0e10cSrcweir     bool mbFocused;
100cdf0e10cSrcweir     // Size of the bounding box that encloses the title string.
101cdf0e10cSrcweir     ::std::auto_ptr<VirtualDevice> mpDevice;
102cdf0e10cSrcweir     bool mbIsExpandable;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     /** Return whether this TitleBar object has an expansion indicator
105cdf0e10cSrcweir         bitmap. It is safe to call GetExpansionIndicator() when this method
106cdf0e10cSrcweir         returns <FALSE/> but unnecessary.
107cdf0e10cSrcweir      */
108cdf0e10cSrcweir     bool HasExpansionIndicator (void) const;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     /** Return the image of the expansion indicator.
111cdf0e10cSrcweir         @return
11269cb9f15Smseidel             When there is no expansion indicator for this TitleBar object,
113cdf0e10cSrcweir             then an empty Image is returned. You better call
114cdf0e10cSrcweir             HasExpansionIndicator() to prevent this.
115cdf0e10cSrcweir      */
116cdf0e10cSrcweir     Image GetExpansionIndicator (void) const;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     /** Calculate the bounding box of the title text. This takes into
119cdf0e10cSrcweir         account indentation due to an expansion indicator and the given
120cdf0e10cSrcweir         available width. When the text can not be displayed on one line, it
121cdf0e10cSrcweir         is broken into multiple lines.
122cdf0e10cSrcweir         @param nAvailableWidth
123cdf0e10cSrcweir             When 0 is given then the natural text width is used, i.e. the
124cdf0e10cSrcweir             text is not broken into multiple lines.
125cdf0e10cSrcweir      */
126cdf0e10cSrcweir     Rectangle CalculateTextBoundingBox (
127cdf0e10cSrcweir         int nAvailableWidth,
128cdf0e10cSrcweir         bool bEmphasizeExpanded);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     /** Add some space to the given text box and return the bounding box of
131cdf0e10cSrcweir         the title bar.
132cdf0e10cSrcweir      */
133cdf0e10cSrcweir     Rectangle CalculateTitleBarBox (
134cdf0e10cSrcweir         const Rectangle& rTextBox,
135cdf0e10cSrcweir         int nTitleBarWidth);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     void PaintSubPanelHeadLineBar (void);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     void PaintBackground (const Rectangle& rTextBox);
140cdf0e10cSrcweir 
141*6c3f4600Smseidel     // Paint a focus indicator that encloses the given rectangle.
142cdf0e10cSrcweir     void PaintFocusIndicator (const Rectangle& rIndicatorBox);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     Rectangle PaintExpansionIndicator (const Rectangle& rTextBox);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     void PaintText (const Rectangle& rTextBox);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     sal_uInt16 GetTextStyle (void);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     const static int snIndentationWidth;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     // Default constructor, copy constructor, and assignment are not supported.
153cdf0e10cSrcweir     TitleBar (void);
154cdf0e10cSrcweir     TitleBar (const TitleBar&);
155cdf0e10cSrcweir     TitleBar& operator= (const TitleBar&);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     using Window::GetWindow;
158cdf0e10cSrcweir };
159cdf0e10cSrcweir 
160cdf0e10cSrcweir } } // end of namespace ::sd::toolpanel
161cdf0e10cSrcweir 
162cdf0e10cSrcweir #endif
163*6c3f4600Smseidel 
164*6c3f4600Smseidel /* vim: set noet sw=4 ts=4: */
165