Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : */
9 :
10 : #include <com/sun/star/frame/XDispatchProvider.hpp>
11 : #include <com/sun/star/util/URL.hpp>
12 : #include <com/sun/star/util/URLTransformer.hpp>
13 : #include <comphelper/processfactory.hxx>
14 : #include <svx/sidebar/PanelLayout.hxx>
15 : #include <vcl/layout.hxx>
16 :
17 0 : PanelLayout::PanelLayout(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> &rFrame)
18 : : Control(pParent)
19 0 : , m_bInClose(false)
20 : {
21 0 : SetStyle(GetStyle() | WB_DIALOGCONTROL);
22 0 : m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID, rFrame);
23 0 : m_aPanelLayoutTimer.SetTimeout(50);
24 0 : m_aPanelLayoutTimer.SetTimeoutHdl( LINK( this, PanelLayout, ImplHandlePanelLayoutTimerHdl ) );
25 0 : }
26 :
27 0 : PanelLayout::~PanelLayout()
28 : {
29 0 : m_bInClose = true;
30 0 : m_aPanelLayoutTimer.Stop();
31 0 : }
32 :
33 0 : Size PanelLayout::GetOptimalSize() const
34 : {
35 0 : if (isLayoutEnabled(this))
36 0 : return VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD));
37 :
38 0 : return Control::GetOptimalSize();
39 : }
40 :
41 0 : bool PanelLayout::hasPanelPendingLayout() const
42 : {
43 0 : return m_aPanelLayoutTimer.IsActive();
44 : }
45 :
46 0 : void PanelLayout::queue_resize()
47 : {
48 0 : if (m_bInClose)
49 0 : return;
50 0 : if (hasPanelPendingLayout())
51 0 : return;
52 0 : if (!isLayoutEnabled(this))
53 0 : return;
54 0 : m_aPanelLayoutTimer.Start();
55 : }
56 :
57 0 : IMPL_LINK( PanelLayout, ImplHandlePanelLayoutTimerHdl, void*, EMPTYARG )
58 : {
59 0 : Window *pChild = GetWindow(WINDOW_FIRSTCHILD);
60 : assert(pChild);
61 0 : VclContainer::setLayoutAllocation(*pChild, Point(0, 0), GetSizePixel());
62 0 : return 0;
63 : }
64 :
65 0 : void PanelLayout::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags)
66 : {
67 0 : bool bCanHandleSmallerWidth = false;
68 0 : bool bCanHandleSmallerHeight = false;
69 :
70 0 : bool bIsLayoutEnabled = isLayoutEnabled(this);
71 0 : Window *pChild = GetWindow(WINDOW_FIRSTCHILD);
72 :
73 0 : if (bIsLayoutEnabled && pChild->GetType() == WINDOW_SCROLLWINDOW)
74 : {
75 0 : WinBits nStyle = pChild->GetStyle();
76 0 : if (nStyle & (WB_AUTOHSCROLL | WB_HSCROLL))
77 0 : bCanHandleSmallerWidth = true;
78 0 : if (nStyle & (WB_AUTOVSCROLL | WB_VSCROLL))
79 0 : bCanHandleSmallerHeight = true;
80 : }
81 :
82 0 : Size aSize(GetOptimalSize());
83 0 : if (!bCanHandleSmallerWidth)
84 0 : nWidth = std::max(nWidth,aSize.Width());
85 0 : if (!bCanHandleSmallerHeight)
86 0 : nHeight = std::max(nHeight,aSize.Height());
87 :
88 0 : Control::setPosSizePixel(nX, nY, nWidth, nHeight, nFlags);
89 :
90 0 : if (bIsLayoutEnabled && (nFlags & WINDOW_POSSIZE_SIZE))
91 0 : VclContainer::setLayoutAllocation(*pChild, Point(0, 0), Size(nWidth, nHeight));
92 0 : }
93 :
94 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|