2010-10-14 01:27:31 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2010-04-07 15:36:24 -05:00
|
|
|
/*************************************************************************
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* This file is part of OpenOffice.org.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "toolpaneldrawer.hxx"
|
2010-04-07 15:36:25 -05:00
|
|
|
#include "toolpaneldrawerpeer.hxx"
|
2012-04-25 09:33:16 -05:00
|
|
|
#include "svtools/svtresid.hxx"
|
2010-04-09 04:05:09 -05:00
|
|
|
#include "svtools/svtools.hrc"
|
2010-04-07 15:36:24 -05:00
|
|
|
|
|
|
|
#include <com/sun/star/accessibility/AccessibleRole.hpp>
|
|
|
|
|
|
|
|
#include <vcl/lineinfo.hxx>
|
|
|
|
#include <vcl/image.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
2010-04-07 15:36:25 -05:00
|
|
|
#include <vcl/vclevent.hxx>
|
2010-04-07 15:36:24 -05:00
|
|
|
|
|
|
|
//......................................................................................................................
|
|
|
|
namespace svt
|
|
|
|
{
|
|
|
|
//......................................................................................................................
|
|
|
|
|
2010-04-07 15:36:25 -05:00
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::awt::XWindowPeer;
|
2010-04-07 15:36:24 -05:00
|
|
|
namespace AccessibleRole = ::com::sun::star::accessibility::AccessibleRole;
|
|
|
|
|
|
|
|
static const int s_nIndentationWidth = 16;
|
|
|
|
|
2010-04-21 06:43:11 -05:00
|
|
|
//==================================================================================================================
|
|
|
|
//= DrawerVisualization
|
|
|
|
//==================================================================================================================
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
DrawerVisualization::DrawerVisualization( ToolPanelDrawer& i_rParent )
|
|
|
|
:Window( &i_rParent )
|
|
|
|
,m_rDrawer( i_rParent )
|
|
|
|
{
|
2010-11-04 21:31:15 -05:00
|
|
|
SetMouseTransparent( sal_True );
|
2010-04-21 06:43:11 -05:00
|
|
|
Show();
|
|
|
|
SetAccessibleRole( AccessibleRole::LABEL );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
DrawerVisualization::~DrawerVisualization()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DrawerVisualization::Paint( const Rectangle& i_rBoundingBox )
|
|
|
|
{
|
|
|
|
Window::Paint( i_rBoundingBox );
|
|
|
|
m_rDrawer.Paint();
|
|
|
|
}
|
|
|
|
|
2010-04-07 15:36:24 -05:00
|
|
|
//==================================================================================================================
|
|
|
|
//= ToolPanelDrawer
|
|
|
|
//==================================================================================================================
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2010-04-07 15:36:25 -05:00
|
|
|
ToolPanelDrawer::ToolPanelDrawer( Window& i_rParent, const ::rtl::OUString& i_rTitle )
|
2010-04-07 15:36:25 -05:00
|
|
|
:Window( &i_rParent, WB_TABSTOP )
|
2010-04-07 15:36:24 -05:00
|
|
|
,m_pPaintDevice( new VirtualDevice( *this ) )
|
2010-04-21 06:43:11 -05:00
|
|
|
,m_aVisualization( *this )
|
2010-04-07 15:36:24 -05:00
|
|
|
,m_bFocused( false )
|
|
|
|
,m_bExpanded( false )
|
|
|
|
{
|
2010-11-04 21:31:15 -05:00
|
|
|
EnableMapMode( sal_False );
|
2010-04-07 15:36:24 -05:00
|
|
|
SetBackground( Wallpaper() );
|
|
|
|
SetPointer( POINTER_REFHAND );
|
|
|
|
|
2010-04-21 06:43:11 -05:00
|
|
|
SetAccessibleRole( AccessibleRole::LIST_ITEM );
|
2010-04-07 15:36:25 -05:00
|
|
|
|
|
|
|
SetText( i_rTitle );
|
|
|
|
SetAccessibleName( i_rTitle );
|
|
|
|
SetAccessibleDescription( i_rTitle );
|
2010-04-21 06:43:11 -05:00
|
|
|
|
|
|
|
m_aVisualization.SetAccessibleName( i_rTitle );
|
|
|
|
m_aVisualization.SetAccessibleDescription( i_rTitle );
|
2010-04-07 15:36:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
ToolPanelDrawer::~ToolPanelDrawer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2010-04-07 15:36:25 -05:00
|
|
|
long ToolPanelDrawer::GetPreferredHeightPixel() const
|
2010-04-07 15:36:24 -05:00
|
|
|
{
|
|
|
|
Rectangle aTitleBarBox( impl_calcTitleBarBox( impl_calcTextBoundingBox() ) );
|
|
|
|
return aTitleBarBox.GetHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2010-04-21 06:43:11 -05:00
|
|
|
void ToolPanelDrawer::Paint()
|
2010-04-07 15:36:24 -05:00
|
|
|
{
|
|
|
|
m_pPaintDevice->SetMapMode( GetMapMode() );
|
|
|
|
m_pPaintDevice->SetOutputSize( GetOutputSizePixel() );
|
|
|
|
m_pPaintDevice->SetSettings( GetSettings() );
|
|
|
|
m_pPaintDevice->SetDrawMode( GetDrawMode() );
|
|
|
|
|
|
|
|
const Rectangle aTextBox( impl_calcTextBoundingBox() );
|
|
|
|
impl_paintBackground( impl_calcTitleBarBox( aTextBox ) );
|
|
|
|
|
|
|
|
Rectangle aFocusBox( impl_paintExpansionIndicator( aTextBox ) );
|
|
|
|
|
|
|
|
m_pPaintDevice->DrawText( aTextBox, GetText(), impl_getTextStyle() );
|
|
|
|
|
|
|
|
aFocusBox.Union( aTextBox );
|
|
|
|
aFocusBox.Left() += 2;
|
|
|
|
impl_paintFocusIndicator( aFocusBox );
|
|
|
|
|
2010-04-21 06:43:11 -05:00
|
|
|
m_aVisualization.DrawOutDev(
|
2010-04-07 15:36:24 -05:00
|
|
|
Point(), GetOutputSizePixel(),
|
|
|
|
Point(), GetOutputSizePixel(),
|
|
|
|
*m_pPaintDevice
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Rectangle ToolPanelDrawer::impl_paintExpansionIndicator( const Rectangle& i_rTextBox )
|
|
|
|
{
|
|
|
|
Rectangle aExpansionIndicatorArea;
|
|
|
|
|
|
|
|
Image aImage( impl_getExpansionIndicator() );
|
|
|
|
const int nHeight( aImage.GetSizePixel().Height() );
|
|
|
|
if ( nHeight > 0 )
|
|
|
|
{
|
|
|
|
Point aPosition(
|
|
|
|
0,
|
|
|
|
i_rTextBox.Top() + ( GetTextHeight() - nHeight ) / 2
|
|
|
|
);
|
|
|
|
m_pPaintDevice->DrawImage( aPosition, aImage );
|
|
|
|
|
|
|
|
aExpansionIndicatorArea = Rectangle( aPosition, aImage.GetSizePixel() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return aExpansionIndicatorArea;
|
|
|
|
}
|
|
|
|
|
2010-11-11 07:55:06 -06:00
|
|
|
|
2010-04-07 15:36:24 -05:00
|
|
|
Image ToolPanelDrawer::impl_getExpansionIndicator() const
|
|
|
|
{
|
2010-11-04 21:31:15 -05:00
|
|
|
sal_uInt16 nResourceId = 0;
|
2010-04-07 15:36:24 -05:00
|
|
|
if ( m_bExpanded )
|
2010-11-11 07:55:06 -06:00
|
|
|
nResourceId = IMG_TRIANGLE_DOWN;
|
2010-04-07 15:36:24 -05:00
|
|
|
else
|
2010-11-11 07:55:06 -06:00
|
|
|
nResourceId = IMG_TRIANGLE_RIGHT;
|
2010-04-07 15:36:24 -05:00
|
|
|
return Image( SvtResId( nResourceId ) );
|
|
|
|
}
|
|
|
|
|
2010-11-11 07:55:06 -06:00
|
|
|
|
2010-11-04 21:31:15 -05:00
|
|
|
sal_uInt16 ToolPanelDrawer::impl_getTextStyle() const
|
2010-04-07 15:36:24 -05:00
|
|
|
{
|
2010-11-04 21:31:15 -05:00
|
|
|
const sal_uInt16 nBasicStyle = TEXT_DRAW_LEFT
|
2010-04-07 15:36:24 -05:00
|
|
|
| TEXT_DRAW_TOP
|
|
|
|
| TEXT_DRAW_WORDBREAK;
|
|
|
|
|
|
|
|
if ( IsEnabled() )
|
|
|
|
return nBasicStyle;
|
|
|
|
|
|
|
|
return nBasicStyle | TEXT_DRAW_DISABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void ToolPanelDrawer::impl_paintBackground( const Rectangle& i_rTitleBarBox )
|
|
|
|
{
|
|
|
|
m_pPaintDevice->SetFillColor( GetSettings().GetStyleSettings().GetDialogColor() );
|
|
|
|
m_pPaintDevice->DrawRect( i_rTitleBarBox );
|
|
|
|
|
|
|
|
m_pPaintDevice->SetFillColor();
|
|
|
|
m_pPaintDevice->SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
|
|
|
|
m_pPaintDevice->DrawLine( i_rTitleBarBox.TopLeft(), i_rTitleBarBox.TopRight() );
|
|
|
|
m_pPaintDevice->DrawLine( i_rTitleBarBox.TopLeft(), i_rTitleBarBox.BottomLeft() );
|
|
|
|
|
|
|
|
m_pPaintDevice->SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
|
|
|
|
m_pPaintDevice->DrawLine( i_rTitleBarBox.BottomLeft(), i_rTitleBarBox.BottomRight() );
|
|
|
|
m_pPaintDevice->DrawLine( i_rTitleBarBox.TopRight(), i_rTitleBarBox.BottomRight() );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void ToolPanelDrawer::impl_paintFocusIndicator( const Rectangle& i_rTextBox )
|
|
|
|
{
|
|
|
|
if ( m_bFocused )
|
|
|
|
{
|
|
|
|
const Rectangle aTextPixelBox( m_pPaintDevice->LogicToPixel( i_rTextBox ) );
|
|
|
|
|
2010-11-04 21:31:15 -05:00
|
|
|
m_pPaintDevice->EnableMapMode( sal_False );
|
2010-04-07 15:36:24 -05:00
|
|
|
m_pPaintDevice->SetFillColor();
|
|
|
|
|
|
|
|
Rectangle aBox( i_rTextBox );
|
|
|
|
aBox.Top() -= 1;
|
|
|
|
aBox.Bottom() += 1;
|
|
|
|
|
|
|
|
m_pPaintDevice->DrawRect( aTextPixelBox );
|
|
|
|
|
|
|
|
LineInfo aDottedStyle( LINE_DASH );
|
|
|
|
aDottedStyle.SetDashCount( 0 );
|
|
|
|
aDottedStyle.SetDotCount( 1 );
|
|
|
|
aDottedStyle.SetDotLen( 1 );
|
|
|
|
aDottedStyle.SetDistance( 1 );
|
|
|
|
|
|
|
|
m_pPaintDevice->SetLineColor( COL_BLACK );
|
|
|
|
m_pPaintDevice->DrawPolyLine( Polygon( aTextPixelBox ), aDottedStyle );
|
2010-11-04 21:31:15 -05:00
|
|
|
m_pPaintDevice->EnableMapMode( sal_False );
|
2010-04-07 15:36:24 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
HideFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void ToolPanelDrawer::GetFocus()
|
|
|
|
{
|
|
|
|
m_bFocused = true;
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void ToolPanelDrawer::LoseFocus()
|
|
|
|
{
|
|
|
|
m_bFocused = false;
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2010-04-21 06:43:11 -05:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void ToolPanelDrawer::Resize()
|
|
|
|
{
|
|
|
|
Window::Resize();
|
|
|
|
m_aVisualization.SetPosSizePixel( Point(), GetOutputSizePixel() );
|
|
|
|
}
|
|
|
|
|
2010-04-14 03:37:41 -05:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void ToolPanelDrawer::MouseButtonDown( const MouseEvent& i_rMouseEvent )
|
|
|
|
{
|
|
|
|
// consume this event, and do not forward to the base class - it would sent a NotifyEvent, which in turn, when
|
|
|
|
// we live in a DockingWindow, would start undocking
|
2010-04-14 14:22:47 -05:00
|
|
|
(void)i_rMouseEvent;
|
2010-04-14 03:37:41 -05:00
|
|
|
}
|
|
|
|
|
2010-04-07 15:36:24 -05:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void ToolPanelDrawer::DataChanged( const DataChangedEvent& i_rEvent )
|
|
|
|
{
|
|
|
|
Window::DataChanged( i_rEvent );
|
|
|
|
|
|
|
|
switch ( i_rEvent.GetType() )
|
|
|
|
{
|
|
|
|
case DATACHANGED_SETTINGS:
|
|
|
|
if ( ( i_rEvent.GetFlags() & SETTINGS_STYLE ) == 0 )
|
|
|
|
break;
|
|
|
|
SetSettings( Application::GetSettings() );
|
|
|
|
m_pPaintDevice.reset( new VirtualDevice( *this ) );
|
|
|
|
|
|
|
|
// fall through.
|
|
|
|
|
|
|
|
case DATACHANGED_FONTS:
|
|
|
|
case DATACHANGED_FONTSUBSTITUTION:
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings( GetSettings().GetStyleSettings() );
|
|
|
|
|
|
|
|
// Font.
|
|
|
|
Font aFont = rStyleSettings.GetAppFont();
|
|
|
|
if ( IsControlFont() )
|
|
|
|
aFont.Merge( GetControlFont() );
|
|
|
|
SetZoomedPointFont( aFont );
|
|
|
|
|
|
|
|
// Color.
|
|
|
|
Color aColor;
|
|
|
|
if ( IsControlForeground() )
|
|
|
|
aColor = GetControlForeground();
|
|
|
|
else
|
|
|
|
aColor = rStyleSettings.GetButtonTextColor();
|
|
|
|
SetTextColor( aColor );
|
|
|
|
SetTextFillColor();
|
|
|
|
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2010-11-04 21:31:15 -05:00
|
|
|
Reference< XWindowPeer > ToolPanelDrawer::GetComponentInterface( sal_Bool i_bCreate )
|
2010-04-07 15:36:24 -05:00
|
|
|
{
|
2010-11-04 21:31:15 -05:00
|
|
|
Reference< XWindowPeer > xWindowPeer( Window::GetComponentInterface( sal_False ) );
|
2010-04-07 15:36:25 -05:00
|
|
|
if ( !xWindowPeer.is() && i_bCreate )
|
|
|
|
{
|
|
|
|
xWindowPeer.set( new ToolPanelDrawerPeer() );
|
|
|
|
SetComponentInterface( xWindowPeer );
|
|
|
|
}
|
|
|
|
return xWindowPeer;
|
2010-04-07 15:36:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2010-04-07 15:36:25 -05:00
|
|
|
Rectangle ToolPanelDrawer::impl_calcTextBoundingBox() const
|
2010-04-07 15:36:24 -05:00
|
|
|
{
|
|
|
|
Font aFont( GetFont() );
|
|
|
|
if ( m_bExpanded )
|
|
|
|
aFont.SetWeight( m_bExpanded ? WEIGHT_BOLD : WEIGHT_NORMAL );
|
|
|
|
m_pPaintDevice->SetFont( aFont );
|
|
|
|
|
|
|
|
int nAvailableWidth = m_pPaintDevice->GetTextWidth( GetText() );
|
|
|
|
|
|
|
|
Rectangle aTextBox(
|
|
|
|
Point(),
|
|
|
|
Size(
|
|
|
|
nAvailableWidth,
|
|
|
|
GetSettings().GetStyleSettings().GetTitleHeight()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
aTextBox.Top() += ( aTextBox.GetHeight() - GetTextHeight() ) / 2;
|
|
|
|
aTextBox.Left() += s_nIndentationWidth;
|
|
|
|
aTextBox.Right() -= 1;
|
|
|
|
|
|
|
|
aTextBox = m_pPaintDevice->GetTextRect( aTextBox, GetText(), impl_getTextStyle() );
|
|
|
|
return aTextBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2010-04-07 15:36:25 -05:00
|
|
|
Rectangle ToolPanelDrawer::impl_calcTitleBarBox( const Rectangle& i_rTextBox ) const
|
2010-04-07 15:36:24 -05:00
|
|
|
{
|
|
|
|
Rectangle aTitleBarBox( i_rTextBox );
|
|
|
|
aTitleBarBox.Bottom() += aTitleBarBox.Top();
|
|
|
|
aTitleBarBox.Top() = 0;
|
|
|
|
aTitleBarBox.Left() = 0;
|
|
|
|
|
|
|
|
const long nWidth = GetOutputSizePixel().Width();
|
|
|
|
if ( aTitleBarBox.GetWidth() < nWidth )
|
|
|
|
aTitleBarBox.Right() = nWidth - 1;
|
|
|
|
|
|
|
|
return aTitleBarBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void ToolPanelDrawer::SetExpanded( const bool i_bExpanded )
|
|
|
|
{
|
|
|
|
if ( m_bExpanded != i_bExpanded )
|
|
|
|
{
|
|
|
|
m_bExpanded = i_bExpanded;
|
2010-04-07 15:36:25 -05:00
|
|
|
CallEventListeners( m_bExpanded ? VCLEVENT_ITEM_EXPANDED : VCLEVENT_ITEM_COLLAPSED );
|
2010-04-07 15:36:24 -05:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//......................................................................................................................
|
|
|
|
} // namespace svt
|
|
|
|
//......................................................................................................................
|
2010-10-14 01:27:31 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|