Files
libreoffice/sd/source/ui/inc/taskpane/TitleBar.hxx
Kurt Zenker dd4245f93a INTEGRATION: CWS impress51 (1.1.2); FILE ADDED
2005/05/19 09:36:11 af 1.1.2.2: #i48247# Renamed TreeNode::{Get,Create}Accessible() to {Get,Create}AccessibleObject().
2005/05/04 13:38:15 af 1.1.2.1: #i48247# Moved here from sd/source/ui/toolpanel.
2005-07-14 09:14:44 +00:00

232 lines
7.8 KiB
C++

/*************************************************************************
*
* $RCSfile: TitleBar.hxx,v $
*
* $Revision: 1.2 $
*
* last change: $Author: kz $ $Date: 2005-07-14 10:14:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef SD_TASKPANE_TITLE_BAR_HXX
#define SD_TASKPANE_TITLE_BAR_HXX
#include "taskpane/TaskPaneTreeNode.hxx"
#ifndef _SV_IMAGE_HXX
#include <vcl/image.hxx>
#endif
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif
#include <vcl/window.hxx>
#include <memory>
class Rectangle;
class String;
class VirtualDevice;
namespace sd { namespace toolpanel {
/** The title bar above a control in a tool panel or sub tool panel.
The way the title bar is displayed depends on the TitleBarType
given to the constructor. TBT_CONTROL_TITLE and
TBT_SUB_CONTROL_HEADLINE both show a expansion indicator in front of
the title string that shows whether the associated control is
visible (expanded) or not.
A title bar with TBT_WINDOW_TITLE is typically used only once as the
title bar of the whole task pane.
<p>The title bar shows three kinds of indicators: 1) Expansion is
displayed by two sets of two bitmaps, a triangle pointing to the right
resp. a minus in a square indicates that the control is collapsed, a
triangle pointing down resp. a plus in a square stands for an expanded
control. 2) Keyboard focus is indicated by a dotted rectangle. 3) An
underlined title string is a mouse over indicator for a
selectable/expandable control.</p>
*/
class TitleBar
: public ::Window,
public TreeNode
{
public:
enum TitleBarType {
TBT_WINDOW_TITLE,
TBT_CONTROL_TITLE,
TBT_SUB_CONTROL_HEADLINE
};
/** Create a new title bar whose content, the given title string,
will be formatted according to the given type.
*/
TitleBar (
::Window* pParent,
const String& rsTitle,
TitleBarType eType,
bool bIsExpandable);
virtual ~TitleBar (void);
virtual Size GetPreferredSize (void);
virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
virtual bool IsResizable (void);
virtual ::Window* GetWindow (void);
virtual sal_Int32 GetMinimumWidth (void);
virtual void Paint (const Rectangle& rBoundingBox);
virtual bool Expand (bool bFlag = true);
virtual bool IsExpanded (void) const;
void SetFocus (bool bFlag);
virtual void MouseMove(const MouseEvent& rEvent);
/** Empty implementation prevents forwarding to docking window.
*/
virtual void MouseButtonDown (const MouseEvent& rEvent);
/** Empty implementation prevents forwarding to docking window.
*/
virtual void MouseButtonUp (const MouseEvent& rEvent);
virtual void DataChanged (const DataChangedEvent& rEvent);
String GetTitle (void) const;
::com::sun::star::uno::Reference<
::com::sun::star::accessibility::XAccessible > CreateAccessibleObject (
const ::com::sun::star::uno::Reference<
::com::sun::star::accessibility::XAccessible>& rxParent);
private:
TitleBarType meType;
String msTitle;
bool mbExpanded;
bool mbFocused;
bool mbMouseOver;
// Size of the bounding box that encloses the title string.
Size maStringBox;
::std::auto_ptr<VirtualDevice> mpDevice;
bool mbIsExpandable;
/** Set the mbMouseOver flag to the given value and paint the
title bar accordingly.
*/
void SetMouseOver (bool bFlag);
/** Return whether this TitleBar object has an expansion indicator
bitmap. It is safe to call GetExpansionIndicator() when this method
returns <FALSE/> but unnecessary.
*/
bool HasExpansionIndicator (void) const;
/** Return the image of the expansion indicator.
@return
When there is no expansion indictor for this TitleBar object,
then an empty Image is returned. You better call
HasExpansionIndicator() to prevent this.
*/
Image GetExpansionIndicator (void) const;
/** Calculate the bounding box of the title text. This takes into
account indentation due to an expansion indicator and the given
available width. When the text can not be displayed on one line, it
is broken into multiple lines.
@param nAvailableWidth
When 0 is given then the natural text width is used, i.e. the
text is not broken into multiple lines.
*/
Rectangle CalculateTextBoundingBox (
int nAvailableWidth,
bool bEmphasizeExpanded);
/** Add some space to the given text box and return the bounding box of
the title bar.
*/
Rectangle CalculateTitleBarBox (
const Rectangle& rTextBox,
int nTitleBarWidth);
void PaintWindowTitleBar (void);
void PaintPanelControlTitle (void);
void PaintSubPanelHeadLineBar (void);
void PaintBackground (const Rectangle& rTextBox);
/// Paint a focus indicator that encloses the given rectangle.
void PaintFocusIndicator (const Rectangle& rIndicatorBox);
/** Paint a mouse over indicator. If the mouse is over the title
bar than the text enclosed by the given rectangle is
underlined.
*/
void PaintMouseOverIndicator (const Rectangle& rIndicatorBox);
Rectangle PaintExpansionIndicator (const Rectangle& rTextBox);
void PaintText (const Rectangle& rTextBox);
USHORT GetTextStyle (void);
const static int snIndentationWidth;
// Default constructor, copy constructor, and assignment are not supported.
TitleBar (void);
TitleBar (const TitleBar&);
TitleBar& operator= (const TitleBar&);
};
} } // end of namespace ::sd::toolpanel
#endif