1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <sfx2/bindings.hxx>
22 #include <sfx2/sidebar/SidebarChildWindow.hxx>
23 #include "SidebarDockingWindow.hxx"
24 #include <sfx2/sfxsids.hrc>
26 #include <sfx2/dockwin.hxx>
27 #include <sfx2/sidebar/ResourceDefinitions.hrc>
29 namespace sfx2
{ namespace sidebar
{
31 SFX_IMPL_DOCKINGWINDOW_WITHID(SidebarChildWindow
, SID_SIDEBAR
);
33 SidebarChildWindow::SidebarChildWindow (vcl::Window
* pParentWindow
, sal_uInt16 nId
,
34 SfxBindings
* pBindings
, SfxChildWinInfo
* pInfo
)
35 : SfxChildWindow(pParentWindow
, nId
)
37 pWindow
.reset(VclPtr
<SidebarDockingWindow
>::Create(pBindings
, *this, pParentWindow
,
38 WB_STDDOCKWIN
| WB_OWNERDRAWDECORATION
|
39 WB_CLIPCHILDREN
| WB_SIZEABLE
|
40 WB_3DLOOK
| WB_ROLLABLE
));
41 eChildAlignment
= SfxChildAlignment::RIGHT
;
43 pWindow
->SetHelpId(HID_SIDEBAR_WINDOW
);
44 pWindow
->SetOutputSizePixel(Size(GetDefaultWidth(pWindow
), 450));
46 SfxDockingWindow
* pDockingParent
= dynamic_cast<SfxDockingWindow
*>(pWindow
.get());
47 if (pDockingParent
!= NULL
)
49 if (pInfo
&& pInfo
->aExtraString
.isEmpty() && pInfo
->aModule
!= "sdraw" && pInfo
->aModule
!= "simpress")
51 // When this is the first start (never had the sidebar open yet),
52 // default to non-expanded sidebars in Writer and Calc.
54 // HACK: unfortunately I haven't found a clean solution to do
55 // this, so do it this way:
57 pDockingParent
->SetSizePixel(Size(TabBar::GetDefaultWidth() * pWindow
->GetDPIScaleFactor(),
58 pDockingParent
->GetSizePixel().Height()));
60 pDockingParent
->Initialize(pInfo
);
62 SetHideNotDelete(true);
67 sal_Int32
SidebarChildWindow::GetDefaultWidth (vcl::Window
* pWindow
)
71 // Width of the paragraph panel.
72 const static sal_Int32
nMaxPropertyPageWidth (115);
74 return pWindow
->LogicToPixel(Point(nMaxPropertyPageWidth
,1), MAP_APPFONT
).X()
75 + TabBar::GetDefaultWidth() * pWindow
->GetDPIScaleFactor();
81 } } // end of namespace sfx2::sidebar
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */