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