xref: /aoo42x/main/sd/source/ui/inc/taskpane/TitleBar.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SD_TASKPANE_TITLE_BAR_HXX
29*cdf0e10cSrcweir #define SD_TASKPANE_TITLE_BAR_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "taskpane/TaskPaneTreeNode.hxx"
32*cdf0e10cSrcweir #include <vcl/image.hxx>
33*cdf0e10cSrcweir #include <tools/string.hxx>
34*cdf0e10cSrcweir #include <vcl/window.hxx>
35*cdf0e10cSrcweir #include <memory>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir class Rectangle;
38*cdf0e10cSrcweir class String;
39*cdf0e10cSrcweir class VirtualDevice;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir namespace sd { namespace toolpanel {
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir /** The title bar above a control in a sub tool panel.
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir     <p>The title bar shows two kinds of indicators: 1) Expansion is
47*cdf0e10cSrcweir     displayed by two sets of two bitmaps, a triangle pointing to the right
48*cdf0e10cSrcweir     resp. a minus in a square indicates that the control is collapsed, a
49*cdf0e10cSrcweir     triangle pointing down resp. a plus in a square stands for an expanded
50*cdf0e10cSrcweir     control. 2) Keyboard focus is indicated by a dotted rectangle.
51*cdf0e10cSrcweir */
52*cdf0e10cSrcweir class TitleBar
53*cdf0e10cSrcweir     : public ::Window,
54*cdf0e10cSrcweir       public TreeNode
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir public:
57*cdf0e10cSrcweir     enum TitleBarType {
58*cdf0e10cSrcweir         TBT_SUB_CONTROL_HEADLINE
59*cdf0e10cSrcweir     };
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     /** Create a new title bar whose content, the given title string,
62*cdf0e10cSrcweir         will be formatted according to the given type.
63*cdf0e10cSrcweir     */
64*cdf0e10cSrcweir     TitleBar (
65*cdf0e10cSrcweir         ::Window* pParent,
66*cdf0e10cSrcweir         const String& rsTitle,
67*cdf0e10cSrcweir         TitleBarType eType,
68*cdf0e10cSrcweir         bool bIsExpandable);
69*cdf0e10cSrcweir     virtual ~TitleBar (void);
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     virtual Size GetPreferredSize (void);
72*cdf0e10cSrcweir     virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
73*cdf0e10cSrcweir     virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
74*cdf0e10cSrcweir     virtual bool IsResizable (void);
75*cdf0e10cSrcweir     virtual ::Window* GetWindow (void);
76*cdf0e10cSrcweir     virtual sal_Int32 GetMinimumWidth (void);
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     virtual void Paint (const Rectangle& rBoundingBox);
79*cdf0e10cSrcweir     virtual bool Expand (bool bFlag = true);
80*cdf0e10cSrcweir     virtual bool IsExpanded (void) const;
81*cdf0e10cSrcweir     virtual void SetEnabledState(bool bFlag);
82*cdf0e10cSrcweir     virtual void GetFocus (void);
83*cdf0e10cSrcweir     virtual void LoseFocus (void);
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     virtual void MouseMove(const MouseEvent& rEvent);
86*cdf0e10cSrcweir     /** Empty implementation prevents forwarding to docking window.
87*cdf0e10cSrcweir     */
88*cdf0e10cSrcweir     virtual void MouseButtonDown (const MouseEvent& rEvent);
89*cdf0e10cSrcweir     /** Empty implementation prevents forwarding to docking window.
90*cdf0e10cSrcweir     */
91*cdf0e10cSrcweir     virtual void MouseButtonUp (const MouseEvent& rEvent);
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     virtual void DataChanged (const DataChangedEvent& rEvent);
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     String GetTitle (void) const;
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
98*cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > CreateAccessibleObject (
99*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
100*cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessible>& rxParent);
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir private:
103*cdf0e10cSrcweir     TitleBarType meType;
104*cdf0e10cSrcweir     String msTitle;
105*cdf0e10cSrcweir     bool mbExpanded;
106*cdf0e10cSrcweir     bool mbFocused;
107*cdf0e10cSrcweir     // Size of the bounding box that encloses the title string.
108*cdf0e10cSrcweir     ::std::auto_ptr<VirtualDevice> mpDevice;
109*cdf0e10cSrcweir     bool mbIsExpandable;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     /** Return whether this TitleBar object has an expansion indicator
112*cdf0e10cSrcweir         bitmap.  It is safe to call GetExpansionIndicator() when this method
113*cdf0e10cSrcweir         returns <FALSE/> but unnecessary.
114*cdf0e10cSrcweir     */
115*cdf0e10cSrcweir     bool HasExpansionIndicator (void) const;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     /** Return the image of the expansion indicator.
118*cdf0e10cSrcweir         @return
119*cdf0e10cSrcweir             When there is no expansion indictor for this TitleBar object,
120*cdf0e10cSrcweir             then an empty Image is returned.  You better call
121*cdf0e10cSrcweir             HasExpansionIndicator() to prevent this.
122*cdf0e10cSrcweir     */
123*cdf0e10cSrcweir     Image GetExpansionIndicator (void) const;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     /** Calculate the bounding box of the title text.  This takes into
126*cdf0e10cSrcweir         account indentation due to an expansion indicator and the given
127*cdf0e10cSrcweir         available width.  When the text can not be displayed on one line, it
128*cdf0e10cSrcweir         is broken into multiple lines.
129*cdf0e10cSrcweir         @param nAvailableWidth
130*cdf0e10cSrcweir             When 0 is given then the natural text width is used, i.e. the
131*cdf0e10cSrcweir             text is not broken into multiple lines.
132*cdf0e10cSrcweir     */
133*cdf0e10cSrcweir     Rectangle CalculateTextBoundingBox (
134*cdf0e10cSrcweir         int nAvailableWidth,
135*cdf0e10cSrcweir         bool bEmphasizeExpanded);
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     /** Add some space to the given text box and return the bounding box of
138*cdf0e10cSrcweir         the title bar.
139*cdf0e10cSrcweir     */
140*cdf0e10cSrcweir     Rectangle CalculateTitleBarBox (
141*cdf0e10cSrcweir         const Rectangle& rTextBox,
142*cdf0e10cSrcweir         int nTitleBarWidth);
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     void PaintSubPanelHeadLineBar (void);
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     void PaintBackground (const Rectangle& rTextBox);
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     /// Paint a focus indicator that encloses the given rectangle.
149*cdf0e10cSrcweir     void PaintFocusIndicator (const Rectangle& rIndicatorBox);
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     Rectangle PaintExpansionIndicator (const Rectangle& rTextBox);
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     void PaintText (const Rectangle& rTextBox);
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     sal_uInt16 GetTextStyle (void);
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     const static int snIndentationWidth;
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     // Default constructor, copy constructor, and assignment are not supported.
160*cdf0e10cSrcweir     TitleBar (void);
161*cdf0e10cSrcweir     TitleBar (const TitleBar&);
162*cdf0e10cSrcweir     TitleBar& operator= (const TitleBar&);
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 	using Window::GetWindow;
165*cdf0e10cSrcweir };
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir } } // end of namespace ::sd::toolpanel
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir #endif
170