2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-07-13 13:35:51 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 21:24:04 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-07-13 13:35:51 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-07-13 13:35:51 +00:00
|
|
|
*
|
2008-04-10 21:24:04 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-07-13 13:35:51 +00:00
|
|
|
*
|
2008-04-10 21:24:04 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-07-13 13:35:51 +00:00
|
|
|
*
|
2008-04-10 21:24:04 +00:00
|
|
|
* 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.
|
2004-07-13 13:35:51 +00:00
|
|
|
*
|
2008-04-10 21:24:04 +00:00
|
|
|
* 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).
|
2004-07-13 13:35:51 +00:00
|
|
|
*
|
2008-04-10 21:24:04 +00:00
|
|
|
* 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.
|
2004-07-13 13:35:51 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 18:13:56 +00:00
|
|
|
|
2005-03-18 15:56:31 +00:00
|
|
|
#include "taskpane/SubToolPanel.hxx"
|
2004-07-13 13:35:51 +00:00
|
|
|
|
|
|
|
#include "TaskPaneFocusManager.hxx"
|
2005-07-14 09:20:50 +00:00
|
|
|
#include "taskpane/TitleBar.hxx"
|
|
|
|
#include "taskpane/TitledControl.hxx"
|
|
|
|
#include "taskpane/ControlContainer.hxx"
|
|
|
|
#include "AccessibleTreeNode.hxx"
|
2004-07-13 13:35:51 +00:00
|
|
|
#include <vcl/decoview.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
|
|
|
namespace sd { namespace toolpanel {
|
|
|
|
|
|
|
|
|
slidecopy: initial version of a "Tool Panel"
At the moment, this implementation is parallel to the existing TaskPane implementation, but on the medium term, it is
intended to replace it. No change in functionality is planned for the moment, just the panel selection is done via
a tab bar, instead of the the "jumping drawers".
Pending tasks (as known so far):
- Accessibility. No implementation at all, yet.
- showing/hiding tool panels from the "View" drop down menu
- connection to the resource framework. At the moment, de/activating panels completely bypasses the resource
framework.
- alternative implementation of the PanelDeckLayouter which mimics the old design. To be activated by default, for
the moment.
- removal of the (old, by then) TaskPane implementation. Care needs to be taken that the framework API stays
unchanged, i.e., the current ToolPanel resource must be renamed back to RightPane when RightPane is not
occupied anymore by the old implementation. Same for other resource names.
2010-03-15 13:53:19 +01:00
|
|
|
SubToolPanel::SubToolPanel (
|
|
|
|
Window& i_rParentWindow)
|
|
|
|
: Control (&i_rParentWindow, WB_DIALOGCONTROL),
|
|
|
|
TreeNode(NULL),
|
|
|
|
maWindowFiller(this),
|
|
|
|
mbIsRearrangePending(true),
|
|
|
|
mbIsLayoutPending(true),
|
|
|
|
mnChildrenWidth(0),
|
|
|
|
mnVerticalBorder(0),
|
|
|
|
mnVerticalGap(3),
|
|
|
|
mnHorizontalBorder(2)
|
|
|
|
{
|
2012-04-08 20:11:18 -03:00
|
|
|
SetAccessibleName (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Sub Task Panel")));
|
slidecopy: initial version of a "Tool Panel"
At the moment, this implementation is parallel to the existing TaskPane implementation, but on the medium term, it is
intended to replace it. No change in functionality is planned for the moment, just the panel selection is done via
a tab bar, instead of the the "jumping drawers".
Pending tasks (as known so far):
- Accessibility. No implementation at all, yet.
- showing/hiding tool panels from the "View" drop down menu
- connection to the resource framework. At the moment, de/activating panels completely bypasses the resource
framework.
- alternative implementation of the PanelDeckLayouter which mimics the old design. To be activated by default, for
the moment.
- removal of the (old, by then) TaskPane implementation. Care needs to be taken that the framework API stays
unchanged, i.e., the current ToolPanel resource must be renamed back to RightPane when RightPane is not
occupied anymore by the old implementation. Same for other resource names.
2010-03-15 13:53:19 +01:00
|
|
|
mpControlContainer->SetMultiSelection (true);
|
|
|
|
|
|
|
|
SetBorderStyle (WINDOW_BORDER_NORMAL);
|
|
|
|
SetMapMode (MapMode(MAP_PIXEL));
|
|
|
|
|
|
|
|
// To reduce flickering during repaints make the container windows
|
|
|
|
// transparent and rely on their children to paint the whole area.
|
|
|
|
SetBackground(Wallpaper());
|
|
|
|
maWindowFiller.SetBackground(
|
2004-07-13 13:35:51 +00:00
|
|
|
Application::GetSettings().GetStyleSettings().GetWindowColor());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SubToolPanel::~SubToolPanel (void)
|
|
|
|
{
|
|
|
|
sal_uInt32 nCount = mpControlContainer->GetControlCount();
|
|
|
|
for (sal_uInt32 nIndex=0; nIndex<nCount; nIndex++)
|
|
|
|
{
|
|
|
|
TitledControl* pControl = static_cast<TitledControl*>(
|
|
|
|
mpControlContainer->GetControl(nIndex));
|
|
|
|
pControl->GetControl()->GetWindow()->RemoveEventListener(
|
|
|
|
LINK(this,SubToolPanel,WindowEventListener));
|
|
|
|
}
|
|
|
|
mpControlContainer->DeleteChildren();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SubToolPanel::Paint (const Rectangle& rRect)
|
|
|
|
{
|
|
|
|
if (mbIsRearrangePending)
|
|
|
|
Rearrange();
|
|
|
|
if (mbIsLayoutPending)
|
|
|
|
LayoutChildren();
|
|
|
|
::Window::Paint (rRect);
|
|
|
|
|
|
|
|
// Paint the outer border and the space between every two children.
|
|
|
|
Color aOriginalLineColor (GetLineColor());
|
|
|
|
Color aOriginalFillColor (GetFillColor());
|
|
|
|
|
|
|
|
SetLineColor ();
|
|
|
|
SetFillColor (GetSettings().GetStyleSettings().GetWindowColor());
|
|
|
|
|
|
|
|
Size aSize (GetOutputSizePixel());
|
|
|
|
// Paint left and right vertical border.
|
|
|
|
Rectangle aVerticalArea (
|
|
|
|
Point(0,0),
|
|
|
|
Size(mnHorizontalBorder,aSize.Height()));
|
|
|
|
DrawRect (aVerticalArea);
|
|
|
|
aVerticalArea.Right() += mnHorizontalBorder + mnChildrenWidth - 1;
|
|
|
|
aVerticalArea.Left() = aVerticalArea.Right() + mnHorizontalBorder;
|
|
|
|
DrawRect (aVerticalArea);
|
|
|
|
|
|
|
|
// Paint horizontal stripes.
|
|
|
|
Rectangle aStripeArea (
|
|
|
|
Point (mnHorizontalBorder,0),
|
|
|
|
Size(mnChildrenWidth,0));
|
|
|
|
StripeList::const_iterator iStripe;
|
2011-01-07 10:57:29 +00:00
|
|
|
for (iStripe=maStripeList.begin(); iStripe!=maStripeList.end(); ++iStripe)
|
2004-07-13 13:35:51 +00:00
|
|
|
{
|
|
|
|
aStripeArea.Top() = iStripe->first;
|
|
|
|
aStripeArea.Bottom() = iStripe->second;
|
|
|
|
if (aStripeArea.Bottom() < 0)
|
|
|
|
continue;
|
|
|
|
if (aStripeArea.Top() >= aSize.Height())
|
|
|
|
break;
|
|
|
|
DrawRect (aStripeArea);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLineColor (aOriginalLineColor);
|
|
|
|
SetFillColor (aOriginalFillColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SubToolPanel::Resize (void)
|
|
|
|
{
|
|
|
|
::Window::Resize();
|
|
|
|
mbIsRearrangePending = true;
|
|
|
|
mbIsLayoutPending = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SubToolPanel::RequestResize (void)
|
|
|
|
{
|
|
|
|
mbIsRearrangePending = true;
|
|
|
|
mbIsLayoutPending = true;
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Size SubToolPanel::GetPreferredSize (void)
|
|
|
|
{
|
|
|
|
return GetRequiredSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-12-12 17:42:59 +00:00
|
|
|
sal_Int32 SubToolPanel::GetPreferredWidth (sal_Int32 )
|
2004-07-13 13:35:51 +00:00
|
|
|
{
|
|
|
|
return GetPreferredSize().Width();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-12-12 17:42:59 +00:00
|
|
|
sal_Int32 SubToolPanel::GetPreferredHeight (sal_Int32 )
|
2004-07-13 13:35:51 +00:00
|
|
|
{
|
|
|
|
return GetPreferredSize().Height();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool SubToolPanel::IsResizable (void)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::Window* SubToolPanel::GetWindow (void)
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 SubToolPanel::GetMinimumWidth (void)
|
|
|
|
{
|
|
|
|
return TreeNode::GetMinimumWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SubToolPanel::ExpandControl (
|
|
|
|
TreeNode* pControl,
|
|
|
|
bool bExpansionState)
|
|
|
|
{
|
|
|
|
// Toggle expand status.
|
|
|
|
pControl->Expand (bExpansionState);
|
|
|
|
|
|
|
|
Rearrange ();
|
|
|
|
Invalidate ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** This control shows an expansion bar for every control and in a
|
|
|
|
separate area below that expansion area it shows all controls each
|
|
|
|
with its title bar. When there is not enough space then show a
|
|
|
|
scroll bar in the control area.
|
|
|
|
*/
|
|
|
|
void SubToolPanel::Rearrange (void)
|
|
|
|
{
|
|
|
|
Size aRequiredSize (GetRequiredSize());
|
|
|
|
if (aRequiredSize.Width()>0 && aRequiredSize.Height()>0)
|
|
|
|
{
|
|
|
|
Size aAvailableSize (GetOutputSizePixel());
|
|
|
|
|
|
|
|
// Make the children at least as wide as the sub tool panel.
|
|
|
|
if (aRequiredSize.Width() < aAvailableSize.Width())
|
|
|
|
aRequiredSize.Width() = aAvailableSize.Width();
|
|
|
|
mnChildrenWidth = -2*mnHorizontalBorder;
|
|
|
|
mnChildrenWidth += aAvailableSize.Width();
|
|
|
|
|
2006-12-12 17:42:59 +00:00
|
|
|
LayoutChildren();
|
2004-07-13 13:35:51 +00:00
|
|
|
|
|
|
|
mbIsRearrangePending = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Size SubToolPanel::GetRequiredSize (void)
|
|
|
|
{
|
|
|
|
// First determine the width of the children. This is the maximum of
|
|
|
|
// the current window width and the individual minimum widths of the
|
|
|
|
// children.
|
|
|
|
int nChildrenWidth (GetSizePixel().Width());
|
|
|
|
unsigned int nCount = mpControlContainer->GetControlCount();
|
|
|
|
unsigned int nIndex;
|
|
|
|
for (nIndex=0; nIndex<nCount; nIndex++)
|
|
|
|
{
|
|
|
|
TreeNode* pChild = mpControlContainer->GetControl (nIndex);
|
|
|
|
int nMinimumWidth (pChild->GetMinimumWidth());
|
|
|
|
if (nMinimumWidth > nChildrenWidth)
|
|
|
|
nChildrenWidth = nMinimumWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Determine the accumulated width of all children when scaled to the
|
|
|
|
// minimum width.
|
|
|
|
nChildrenWidth -= 2*mnHorizontalBorder;
|
|
|
|
Size aTotalSize (nChildrenWidth,
|
|
|
|
2*mnVerticalBorder + (nCount-1) * mnVerticalGap);
|
|
|
|
for (nIndex=0; nIndex<nCount; nIndex++)
|
|
|
|
{
|
|
|
|
TreeNode* pChild = mpControlContainer->GetControl (nIndex);
|
|
|
|
sal_Int32 nHeight = pChild->GetPreferredHeight(nChildrenWidth);
|
|
|
|
aTotalSize.Height() += nHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aTotalSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 SubToolPanel::LayoutChildren (void)
|
|
|
|
{
|
|
|
|
// Determine vertical space that can be distributed to sizable children.
|
|
|
|
unsigned int nCount (mpControlContainer->GetControlCount());
|
|
|
|
unsigned int nResizableCount = 0;
|
|
|
|
int nAvailableHeight = GetSizePixel().Height() - 2*mnVerticalBorder;
|
|
|
|
unsigned int nIndex;
|
|
|
|
for (nIndex=0; nIndex<nCount; nIndex++)
|
|
|
|
{
|
|
|
|
TreeNode* pChild = mpControlContainer->GetControl (nIndex);
|
|
|
|
int nControlHeight = pChild->GetPreferredHeight(mnChildrenWidth);
|
|
|
|
if (pChild->IsResizable())
|
|
|
|
nResizableCount++;
|
|
|
|
else
|
|
|
|
nAvailableHeight -= nControlHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
maStripeList.clear();
|
|
|
|
|
|
|
|
Point aPosition (0,0);
|
|
|
|
aPosition.X() += mnHorizontalBorder;
|
|
|
|
maStripeList.push_back( ::std::pair<int,int>(
|
|
|
|
aPosition.Y(),
|
|
|
|
aPosition.Y() + mnVerticalBorder - 1));
|
|
|
|
aPosition.Y() += mnVerticalBorder;
|
|
|
|
|
|
|
|
// Place the controls one over the other.
|
|
|
|
for (nIndex=0; nIndex<nCount; nIndex++)
|
|
|
|
{
|
|
|
|
if (nIndex > 0)
|
|
|
|
{
|
|
|
|
maStripeList.push_back( ::std::pair<int,int>(
|
|
|
|
aPosition.Y(),
|
|
|
|
aPosition.Y() + mnVerticalGap - 1));
|
|
|
|
aPosition.Y() += mnVerticalGap;
|
|
|
|
}
|
|
|
|
TreeNode* pChild = mpControlContainer->GetControl (nIndex);
|
|
|
|
int nControlHeight = pChild->GetPreferredHeight(mnChildrenWidth);
|
|
|
|
if (pChild->IsResizable())
|
|
|
|
{
|
|
|
|
nControlHeight = nAvailableHeight / nResizableCount;
|
|
|
|
nResizableCount--;
|
|
|
|
}
|
|
|
|
nAvailableHeight -= nControlHeight;
|
|
|
|
pChild->GetWindow()->SetPosSizePixel(
|
|
|
|
aPosition,
|
|
|
|
Size(mnChildrenWidth, nControlHeight));
|
|
|
|
aPosition.Y() += nControlHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the children do not cover their parent window completely
|
|
|
|
// (regarding the height) we put a filler below that is responsible for
|
|
|
|
// painting the remaining space.
|
|
|
|
int nWindowHeight = GetSizePixel().Height();
|
|
|
|
if (aPosition.Y() < nWindowHeight)
|
|
|
|
{
|
|
|
|
maWindowFiller.SetPosSizePixel (
|
|
|
|
aPosition,
|
|
|
|
Size(mnChildrenWidth, nWindowHeight-aPosition.Y()));
|
|
|
|
maStripeList.push_back( ::std::pair<int,int>(
|
|
|
|
aPosition.Y(),
|
|
|
|
nWindowHeight-1));
|
|
|
|
// maScrollWindowFiller.Show();
|
|
|
|
aPosition.Y() = nWindowHeight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
maWindowFiller.Hide();
|
|
|
|
|
|
|
|
aPosition.Y() += mnVerticalBorder;
|
|
|
|
mbIsLayoutPending = false;
|
|
|
|
|
|
|
|
return aPosition.Y();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK(SubToolPanel, WindowEventListener, VclSimpleEvent*, pEvent)
|
|
|
|
{
|
|
|
|
if (pEvent!=NULL && pEvent->ISA(VclWindowEvent))
|
|
|
|
{
|
|
|
|
VclWindowEvent* pWindowEvent = static_cast<VclWindowEvent*>(pEvent);
|
|
|
|
switch (pWindowEvent->GetId())
|
|
|
|
{
|
|
|
|
case VCLEVENT_WINDOW_SHOW:
|
|
|
|
case VCLEVENT_WINDOW_HIDE:
|
|
|
|
case VCLEVENT_WINDOW_ACTIVATE:
|
|
|
|
case VCLEVENT_WINDOW_RESIZE:
|
|
|
|
RequestResize();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-14 09:20:50 +00:00
|
|
|
::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::accessibility::XAccessible> SubToolPanel::CreateAccessibleObject (
|
|
|
|
const ::com::sun::star::uno::Reference<
|
2006-12-12 17:42:59 +00:00
|
|
|
::com::sun::star::accessibility::XAccessible>& )
|
2005-07-14 09:20:50 +00:00
|
|
|
{
|
|
|
|
return new ::accessibility::AccessibleTreeNode (
|
|
|
|
*this,
|
2012-04-08 20:11:18 -03:00
|
|
|
"Sub Task Panel",
|
|
|
|
"Sub Task Panel",
|
2005-07-14 09:20:50 +00:00
|
|
|
::com::sun::star::accessibility::AccessibleRole::PANEL);
|
|
|
|
}
|
|
|
|
|
2004-07-13 13:35:51 +00:00
|
|
|
} } // end of namespace ::sd::toolpanel
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|