2014-09-11 14:10:21 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <vcl/layout.hxx>
|
2016-03-29 11:13:57 +02:00
|
|
|
#include <vcl/notebookbar.hxx>
|
2016-06-17 23:54:00 +02:00
|
|
|
#include <cppuhelper/queryinterface.hxx>
|
2014-09-11 14:10:21 +02:00
|
|
|
|
2016-03-29 11:13:57 +02:00
|
|
|
NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame)
|
2014-09-11 14:10:21 +02:00
|
|
|
: Control(pParent)
|
|
|
|
{
|
|
|
|
SetStyle(GetStyle() | WB_DIALOGCONTROL);
|
|
|
|
m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID, rFrame);
|
2016-06-17 23:54:00 +02:00
|
|
|
get(m_pTabControl, "notebook1");
|
2014-09-11 14:10:21 +02:00
|
|
|
}
|
|
|
|
|
2016-03-29 11:13:57 +02:00
|
|
|
NotebookBar::~NotebookBar()
|
2014-09-11 14:10:21 +02:00
|
|
|
{
|
|
|
|
disposeOnce();
|
|
|
|
}
|
|
|
|
|
2016-03-29 11:13:57 +02:00
|
|
|
void NotebookBar::dispose()
|
2014-09-11 14:10:21 +02:00
|
|
|
{
|
|
|
|
disposeBuilder();
|
|
|
|
Control::dispose();
|
|
|
|
}
|
|
|
|
|
2016-03-29 11:13:57 +02:00
|
|
|
Size NotebookBar::GetOptimalSize() const
|
2014-09-11 14:10:21 +02:00
|
|
|
{
|
|
|
|
if (isLayoutEnabled(this))
|
|
|
|
return VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild));
|
|
|
|
|
|
|
|
return Control::GetOptimalSize();
|
|
|
|
}
|
|
|
|
|
2016-03-29 11:13:57 +02:00
|
|
|
void NotebookBar::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags)
|
2014-09-11 14:10:21 +02:00
|
|
|
{
|
|
|
|
bool bCanHandleSmallerWidth = false;
|
|
|
|
bool bCanHandleSmallerHeight = false;
|
|
|
|
|
|
|
|
bool bIsLayoutEnabled = isLayoutEnabled(this);
|
|
|
|
Window *pChild = GetWindow(GetWindowType::FirstChild);
|
|
|
|
|
|
|
|
if (bIsLayoutEnabled && pChild->GetType() == WINDOW_SCROLLWINDOW)
|
|
|
|
{
|
|
|
|
WinBits nStyle = pChild->GetStyle();
|
|
|
|
if (nStyle & (WB_AUTOHSCROLL | WB_HSCROLL))
|
|
|
|
bCanHandleSmallerWidth = true;
|
|
|
|
if (nStyle & (WB_AUTOVSCROLL | WB_VSCROLL))
|
|
|
|
bCanHandleSmallerHeight = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Size aSize(GetOptimalSize());
|
|
|
|
if (!bCanHandleSmallerWidth)
|
|
|
|
nWidth = std::max(nWidth, aSize.Width());
|
|
|
|
if (!bCanHandleSmallerHeight)
|
|
|
|
nHeight = std::max(nHeight, aSize.Height());
|
|
|
|
|
|
|
|
Control::setPosSizePixel(nX, nY, nWidth, nHeight, nFlags);
|
|
|
|
|
|
|
|
if (bIsLayoutEnabled && (nFlags & PosSizeFlags::Size))
|
|
|
|
VclContainer::setLayoutAllocation(*pChild, Point(0, 0), Size(nWidth, nHeight));
|
|
|
|
}
|
|
|
|
|
2016-03-29 11:13:57 +02:00
|
|
|
void NotebookBar::StateChanged(StateChangedType nType)
|
2016-03-18 13:55:24 +01:00
|
|
|
{
|
|
|
|
if (nType == StateChangedType::Visible)
|
|
|
|
{
|
|
|
|
// visibility changed, update the container
|
|
|
|
GetParent()->Resize();
|
|
|
|
}
|
|
|
|
|
|
|
|
Control::StateChanged(nType);
|
|
|
|
}
|
|
|
|
|
2016-06-17 23:54:00 +02:00
|
|
|
void SAL_CALL NotebookBar::notifyContextChangeEvent(const css::ui::ContextChangeEventObject& rEvent)
|
|
|
|
throw (css::uno::RuntimeException, std::exception)
|
|
|
|
{
|
|
|
|
m_pTabControl->SetContext(vcl::EnumContext::GetContextEnum(rEvent.ContextName));
|
|
|
|
}
|
|
|
|
|
|
|
|
::css::uno::Any SAL_CALL NotebookBar::queryInterface(const ::css::uno::Type& aType)
|
|
|
|
throw (::css::uno::RuntimeException, ::std::exception)
|
|
|
|
{
|
|
|
|
return ::cppu::queryInterface(aType, static_cast<css::ui::XContextChangeEventListener*>(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL NotebookBar::acquire() throw ()
|
|
|
|
{
|
|
|
|
Control::acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL NotebookBar::release() throw ()
|
|
|
|
{
|
|
|
|
Control::release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL NotebookBar::disposing(const ::css::lang::EventObject&)
|
|
|
|
throw (::css::uno::RuntimeException, ::std::exception)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-11 14:10:21 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|