Branch libreoffice-5-0-4
[LibreOffice.git] / sfx2 / source / sidebar / SidebarChildWindow.cxx
blob0925bf83e4c0d7c78febaa7cab592b79492722cc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "TabBar.hxx"
21 #include <sfx2/bindings.hxx>
22 #include <sfx2/sidebar/SidebarChildWindow.hxx>
23 #include "SidebarDockingWindow.hxx"
24 #include <sfx2/sfxsids.hrc>
25 #include "helpid.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);
64 pWindow->Show();
67 sal_Int32 SidebarChildWindow::GetDefaultWidth (vcl::Window* pWindow)
69 if (pWindow != NULL)
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();
77 else
78 return 0;
81 } } // end of namespace sfx2::sidebar
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */