2004-07-13 13:40:12 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 21:28:29 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-07-13 13:40:12 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-07-13 13:40:12 +00:00
|
|
|
*
|
2008-04-10 21:28:29 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-07-13 13:40:12 +00:00
|
|
|
*
|
2008-04-10 21:28:29 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-07-13 13:40:12 +00:00
|
|
|
*
|
2008-04-10 21:28:29 +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:40:12 +00:00
|
|
|
*
|
2008-04-10 21:28:29 +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:40:12 +00:00
|
|
|
*
|
2008-04-10 21:28:29 +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:40:12 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 18:16:21 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2005-07-14 09:23:06 +00:00
|
|
|
#include "taskpane/TitledControl.hxx"
|
2004-07-13 13:40:12 +00:00
|
|
|
|
2005-07-14 09:23:06 +00:00
|
|
|
#include "AccessibleTreeNode.hxx"
|
|
|
|
#include "taskpane/ControlContainer.hxx"
|
2004-07-13 13:40:12 +00:00
|
|
|
#include "TaskPaneFocusManager.hxx"
|
2005-03-18 15:59:16 +00:00
|
|
|
#include "taskpane/TaskPaneControlFactory.hxx"
|
2004-07-13 13:40:12 +00:00
|
|
|
#include <vcl/ctrl.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
|
|
|
|
|
|
|
namespace sd { namespace toolpanel {
|
|
|
|
|
|
|
|
|
|
|
|
TitledControl::TitledControl (
|
|
|
|
TreeNode* pParent,
|
|
|
|
::std::auto_ptr<TreeNode> pControl,
|
|
|
|
const String& rTitle,
|
2007-04-03 15:21:29 +00:00
|
|
|
const ClickHandler& rClickHandler,
|
2004-07-13 13:40:12 +00:00
|
|
|
TitleBar::TitleBarType eType)
|
|
|
|
: ::Window (pParent->GetWindow(), WB_TABSTOP),
|
|
|
|
TreeNode(pParent),
|
2005-04-08 15:18:03 +00:00
|
|
|
msTitle(rTitle),
|
|
|
|
mbVisible(true),
|
|
|
|
mpUserData(NULL),
|
2010-04-07 22:36:24 +02:00
|
|
|
mpClickHandler(new ClickHandler(rClickHandler))
|
2004-07-13 13:40:12 +00:00
|
|
|
{
|
2010-05-19 12:08:26 +02:00
|
|
|
mpControlContainer->AddControl (::std::auto_ptr<TreeNode> (
|
|
|
|
new TitleBar (this, rTitle, eType, pControl->IsExpandable())));
|
|
|
|
pControl->SetParentNode (this);
|
2004-07-13 13:40:12 +00:00
|
|
|
mpControlContainer->AddControl (pControl);
|
|
|
|
|
2010-05-19 12:08:26 +02:00
|
|
|
FocusManager::Instance().RegisterDownLink( GetTitleBar()->GetWindow(), GetControl()->GetWindow() );
|
|
|
|
FocusManager::Instance().RegisterUpLink( GetControl()->GetWindow(), GetTitleBar()->GetWindow() );
|
2004-07-13 13:40:12 +00:00
|
|
|
|
|
|
|
SetBackground (Wallpaper());
|
|
|
|
|
|
|
|
GetTitleBar()->GetWindow()->Show ();
|
|
|
|
GetTitleBar()->GetWindow()->AddEventListener (
|
|
|
|
LINK(this,TitledControl,WindowEventListener));
|
|
|
|
|
|
|
|
UpdateStates ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TitledControl::~TitledControl (void)
|
|
|
|
{
|
|
|
|
GetTitleBar()->GetWindow()->RemoveEventListener (
|
|
|
|
LINK(this,TitledControl,WindowEventListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Size TitledControl::GetPreferredSize (void)
|
|
|
|
{
|
|
|
|
Size aPreferredSize;
|
2010-03-22 13:19:00 +01:00
|
|
|
if (GetControl() != NULL)
|
2004-07-13 13:40:12 +00:00
|
|
|
{
|
|
|
|
aPreferredSize = GetControl()->GetPreferredSize();
|
|
|
|
if ( ! IsExpanded())
|
|
|
|
aPreferredSize.Height() = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aPreferredSize = Size (GetSizePixel().Width(), 0);
|
|
|
|
if (aPreferredSize.Width() == 0)
|
|
|
|
aPreferredSize.Width() = 300;
|
|
|
|
aPreferredSize.Height() += GetTitleBar()->GetPreferredHeight(
|
|
|
|
aPreferredSize.Width());
|
|
|
|
|
|
|
|
return aPreferredSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 TitledControl::GetPreferredWidth (sal_Int32 nHeight)
|
|
|
|
{
|
|
|
|
int nPreferredWidth = 0;
|
2010-03-22 13:19:00 +01:00
|
|
|
if (GetControl() != NULL)
|
2004-07-13 13:40:12 +00:00
|
|
|
nPreferredWidth = GetControl()->GetPreferredWidth(
|
|
|
|
nHeight - GetTitleBar()->GetWindow()->GetSizePixel().Height());
|
|
|
|
else
|
|
|
|
nPreferredWidth = GetSizePixel().Width();
|
|
|
|
if (nPreferredWidth == 0)
|
|
|
|
nPreferredWidth = 300;
|
|
|
|
|
|
|
|
return nPreferredWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 TitledControl::GetPreferredHeight (sal_Int32 nWidth)
|
|
|
|
{
|
|
|
|
int nPreferredHeight = 0;
|
2010-03-22 13:19:00 +01:00
|
|
|
if (IsExpanded() && GetControl()!=NULL)
|
2004-07-13 13:40:12 +00:00
|
|
|
nPreferredHeight = GetControl()->GetPreferredHeight(nWidth);
|
|
|
|
nPreferredHeight += GetTitleBar()->GetPreferredHeight(nWidth);
|
|
|
|
|
|
|
|
return nPreferredHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TitledControl::IsResizable (void)
|
|
|
|
{
|
|
|
|
return IsExpanded()
|
|
|
|
&& GetControl()->IsResizable();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::Window* TitledControl::GetWindow (void)
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TitledControl::Resize (void)
|
|
|
|
{
|
|
|
|
Size aWindowSize (GetOutputSizePixel());
|
|
|
|
|
|
|
|
int nTitleBarHeight
|
|
|
|
= GetTitleBar()->GetPreferredHeight(aWindowSize.Width());
|
|
|
|
GetTitleBar()->GetWindow()->SetPosSizePixel (
|
|
|
|
Point (0,0),
|
|
|
|
Size (aWindowSize.Width(), nTitleBarHeight));
|
2005-03-18 15:59:16 +00:00
|
|
|
|
|
|
|
|
2010-03-22 13:19:00 +01:00
|
|
|
TreeNode* pControl = GetControl();
|
2004-07-13 13:40:12 +00:00
|
|
|
if (pControl != NULL
|
|
|
|
&& pControl->GetWindow() != NULL
|
|
|
|
&& pControl->GetWindow()->IsVisible())
|
|
|
|
{
|
|
|
|
pControl->GetWindow()->SetPosSizePixel (
|
|
|
|
Point (0,nTitleBarHeight),
|
|
|
|
Size (aWindowSize.Width(), aWindowSize.Height()-nTitleBarHeight));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TitledControl::GetFocus (void)
|
|
|
|
{
|
|
|
|
::Window::GetFocus();
|
|
|
|
if (GetTitleBar() != NULL)
|
2010-03-17 09:21:56 +01:00
|
|
|
GetTitleBar()->GrabFocus();
|
2004-07-13 13:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TitledControl::KeyInput (const KeyEvent& rEvent)
|
|
|
|
{
|
|
|
|
KeyCode nCode = rEvent.GetKeyCode();
|
|
|
|
if (nCode == KEY_SPACE)
|
|
|
|
{
|
|
|
|
// Toggle the expansion state of the control (when toggling is
|
|
|
|
// supported.) The focus remains on this control.
|
|
|
|
GetParentNode()->GetControlContainer().SetExpansionState (
|
|
|
|
this,
|
|
|
|
ControlContainer::ES_TOGGLE);
|
|
|
|
}
|
|
|
|
else if (nCode == KEY_RETURN)
|
|
|
|
{
|
|
|
|
// Return, also called enter, enters the control and puts the
|
|
|
|
// focus to the first child. If the control is not yet
|
|
|
|
// expanded then do that first.
|
|
|
|
GetParentNode()->GetControlContainer().SetExpansionState (
|
|
|
|
this,
|
|
|
|
ControlContainer::ES_EXPAND);
|
|
|
|
|
2005-07-14 09:23:06 +00:00
|
|
|
if ( ! FocusManager::Instance().TransferFocus(this,nCode))
|
2004-07-13 13:40:12 +00:00
|
|
|
{
|
|
|
|
// When already expanded then put focus on first child.
|
2010-03-22 13:19:00 +01:00
|
|
|
TreeNode* pControl = GetControl();
|
2004-07-13 13:40:12 +00:00
|
|
|
if (pControl!=NULL && IsExpanded())
|
|
|
|
if (pControl->GetWindow() != NULL)
|
|
|
|
pControl->GetWindow()->GrabFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nCode == KEY_ESCAPE)
|
|
|
|
{
|
2005-07-14 09:23:06 +00:00
|
|
|
if ( ! FocusManager::Instance().TransferFocus(this,nCode))
|
2004-07-13 13:40:12 +00:00
|
|
|
// Put focus to parent.
|
|
|
|
GetParent()->GrabFocus();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Window::KeyInput (rEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const String& TitledControl::GetTitle (void) const
|
|
|
|
{
|
|
|
|
return msTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-03-23 13:14:26 +00:00
|
|
|
bool TitledControl::Expand (bool bExpanded)
|
2004-07-13 13:40:12 +00:00
|
|
|
{
|
2005-03-23 13:14:26 +00:00
|
|
|
bool bExpansionStateChanged (false);
|
|
|
|
|
2009-09-09 09:19:53 +00:00
|
|
|
if (IsExpandable() && IsEnabled())
|
2004-07-13 13:40:12 +00:00
|
|
|
{
|
2005-03-23 13:14:26 +00:00
|
|
|
if (GetTitleBar()->IsExpanded() != bExpanded)
|
|
|
|
bExpansionStateChanged |= GetTitleBar()->Expand (bExpanded);
|
2005-03-18 15:59:16 +00:00
|
|
|
// Get the control. Use the bExpanded parameter as argument to
|
|
|
|
// indicate that a control is created via its factory only when it
|
|
|
|
// is to be expanded. When it is collapsed this is not necessary.
|
2010-03-22 13:19:00 +01:00
|
|
|
TreeNode* pControl = GetControl();
|
2005-03-23 13:14:26 +00:00
|
|
|
if (pControl != NULL
|
|
|
|
&& GetControl()->IsExpanded() != bExpanded)
|
|
|
|
{
|
|
|
|
bExpansionStateChanged |= pControl->Expand (bExpanded);
|
|
|
|
}
|
|
|
|
if (bExpansionStateChanged)
|
|
|
|
UpdateStates();
|
2004-07-13 13:40:12 +00:00
|
|
|
}
|
|
|
|
|
2005-03-23 13:14:26 +00:00
|
|
|
return bExpansionStateChanged;
|
2004-07-13 13:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TitledControl::IsExpandable (void) const
|
|
|
|
{
|
2010-03-22 13:19:00 +01:00
|
|
|
const TreeNode* pControl = GetConstControl();
|
2005-03-18 15:59:16 +00:00
|
|
|
if (pControl != NULL)
|
|
|
|
return pControl->IsExpandable();
|
|
|
|
else
|
|
|
|
// When a control factory is given but the control has not yet been
|
|
|
|
// created we assume that the control is expandable.
|
|
|
|
return true;
|
2004-07-13 13:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TitledControl::IsExpanded (void) const
|
|
|
|
{
|
2010-03-22 13:19:00 +01:00
|
|
|
const TreeNode* pControl = GetConstControl();
|
2005-03-18 15:59:16 +00:00
|
|
|
if (pControl != NULL)
|
|
|
|
return pControl->IsExpanded();
|
|
|
|
else
|
|
|
|
return false;
|
2004-07-13 13:40:12 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
void TitledControl::SetEnabledState(bool bFlag)
|
|
|
|
{
|
|
|
|
if (!bFlag)
|
|
|
|
{
|
|
|
|
GetParentNode()->GetControlContainer().SetExpansionState (
|
|
|
|
this,
|
|
|
|
ControlContainer::ES_COLLAPSE);
|
|
|
|
Disable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
GetParentNode()->GetControlContainer().SetExpansionState (
|
|
|
|
this,
|
|
|
|
ControlContainer::ES_EXPAND);
|
|
|
|
*/
|
|
|
|
Enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
GetTitleBar()->SetEnabledState(bFlag);
|
|
|
|
}
|
2004-07-13 13:40:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TitledControl::IsShowing (void) const
|
|
|
|
{
|
|
|
|
return mbVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TitledControl::Show (bool bVisible)
|
|
|
|
{
|
|
|
|
if (mbVisible != bVisible)
|
|
|
|
{
|
|
|
|
mbVisible = bVisible;
|
|
|
|
UpdateStates ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TitledControl::UpdateStates (void)
|
|
|
|
{
|
|
|
|
if (mbVisible)
|
|
|
|
GetWindow()->Show();
|
|
|
|
else
|
|
|
|
GetWindow()->Hide();
|
|
|
|
|
2010-03-22 13:19:00 +01:00
|
|
|
TreeNode* pControl = GetControl();
|
2004-07-13 13:40:12 +00:00
|
|
|
if (pControl!=NULL && pControl->GetWindow() != NULL)
|
2008-12-11 07:05:03 +00:00
|
|
|
{
|
2004-07-13 13:40:12 +00:00
|
|
|
if (IsVisible() && IsExpanded())
|
|
|
|
pControl->GetWindow()->Show();
|
|
|
|
else
|
|
|
|
pControl->GetWindow()->Hide();
|
2008-12-11 07:05:03 +00:00
|
|
|
}
|
2004-07-13 13:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK(TitledControl, WindowEventListener,
|
|
|
|
VclSimpleEvent*, pEvent)
|
|
|
|
{
|
|
|
|
if (pEvent!=NULL && pEvent->ISA(VclWindowEvent))
|
|
|
|
{
|
|
|
|
VclWindowEvent* pWindowEvent = static_cast<VclWindowEvent*>(pEvent);
|
|
|
|
switch (pWindowEvent->GetId())
|
|
|
|
{
|
|
|
|
case VCLEVENT_WINDOW_MOUSEBUTTONUP:
|
2009-09-09 09:19:53 +00:00
|
|
|
if (IsEnabled())
|
|
|
|
(*mpClickHandler)(*this);
|
2004-07-13 13:40:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-22 13:19:00 +01:00
|
|
|
TreeNode* TitledControl::GetControl (void)
|
2004-07-13 13:40:12 +00:00
|
|
|
{
|
2010-03-22 13:19:00 +01:00
|
|
|
return mpControlContainer->GetControl(1);
|
2004-07-13 13:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-22 13:19:00 +01:00
|
|
|
const TreeNode* TitledControl::GetConstControl () const
|
2004-07-13 13:40:12 +00:00
|
|
|
{
|
2010-03-22 13:19:00 +01:00
|
|
|
return const_cast<TitledControl*>(this)->GetControl();
|
2004-07-13 13:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TitleBar* TitledControl::GetTitleBar (void)
|
|
|
|
{
|
|
|
|
return static_cast<TitleBar*>(mpControlContainer->GetControl(0));
|
|
|
|
}
|
|
|
|
|
2005-07-14 09:23:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::accessibility::XAccessible> TitledControl::CreateAccessibleObject (
|
|
|
|
const ::com::sun::star::uno::Reference<
|
2006-12-12 17:44:50 +00:00
|
|
|
::com::sun::star::accessibility::XAccessible>& )
|
2005-07-14 09:23:06 +00:00
|
|
|
{
|
|
|
|
return new ::accessibility::AccessibleTreeNode(
|
|
|
|
*this,
|
|
|
|
GetTitle(),
|
|
|
|
GetTitle(),
|
2006-01-19 11:55:22 +00:00
|
|
|
::com::sun::star::accessibility::AccessibleRole::LIST_ITEM);
|
2005-07-14 09:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-04-03 15:21:29 +00:00
|
|
|
|
|
|
|
//===== TitledControlStandardClickHandler =====================================
|
|
|
|
|
|
|
|
TitledControlStandardClickHandler::TitledControlStandardClickHandler (
|
|
|
|
ControlContainer& rControlContainer,
|
|
|
|
ControlContainer::ExpansionState eExpansionState)
|
|
|
|
: mrControlContainer(rControlContainer),
|
|
|
|
meExpansionState(eExpansionState)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TitledControlStandardClickHandler::operator () (TitledControl& rTitledControl)
|
|
|
|
{
|
|
|
|
// Toggle expansion.
|
|
|
|
mrControlContainer.SetExpansionState (&rTitledControl, meExpansionState);
|
|
|
|
}
|
|
|
|
|
2004-07-13 13:40:12 +00:00
|
|
|
} } // end of namespace ::sd::toolpanel
|