Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / basctl / source / basicide / objdlg.cxx
blob34846e67e1fa8e9ac860e456d2844cf5f139598d
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 <strings.hrc>
22 #include <objdlg.hxx>
23 #include <helpids.h>
25 #include <svl/itemset.hxx>
26 #include <vcl/taskpanelist.hxx>
28 namespace basctl
31 ObjectCatalog::ObjectCatalog (vcl::Window* pParent)
32 : DockingWindow(pParent)
33 , aTitle(VclPtr<FixedText>::Create(this))
34 , aTree(VclPtr<TreeListBox>::Create(this, WB_TABSTOP))
36 SetHelpId("basctl:FloatingWindow:RID_BASICIDE_OBJCAT");
37 SetText(IDEResId(RID_BASICIDE_OBJCAT));
39 // title
40 aTitle->SetText(IDEResId(RID_BASICIDE_OBJCAT));
41 aTitle->SetStyle(WB_CENTER);
43 // tree list
44 aTree->Hide();
45 aTree->SetStyle(
46 WB_BORDER | WB_TABSTOP | WB_HSCROLL |
47 WB_HASLINES | WB_HASLINESATROOT |
48 WB_HASBUTTONS | WB_HASBUTTONSATROOT
50 aTree->SetAccessibleName(IDEResId(RID_STR_TLB_MACROS));
51 aTree->SetHelpId(HID_BASICIDE_OBJECTCAT);
52 aTree->ScanAllEntries();
53 aTree->GrabFocus();
56 // centered after AppWin:
57 Window const& rParent = *GetParent();
58 Point aPos = rParent.OutputToScreenPixel(Point(0, 0));
59 Size const aParentSize = rParent.GetSizePixel();
60 Size const aSize = GetSizePixel();
61 aPos.AdjustX((aParentSize.Width() - aSize.Width()) / 2 );
62 aPos.AdjustY((aParentSize.Height() - aSize.Height()) / 2 );
63 SetPosPixel(aPos);
66 // make object catalog keyboard accessible
67 GetParent()->GetSystemWindow()->GetTaskPaneList()->AddWindow(this);
70 ObjectCatalog::~ObjectCatalog()
72 disposeOnce();
75 void ObjectCatalog::dispose()
77 if (!IsDisposed())
78 GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this);
79 aTitle.disposeAndClear();
80 aTree.disposeAndClear();
81 DockingWindow::dispose();
84 // Resize() -- called by Window
85 void ObjectCatalog::Resize ()
87 // arranging the controls
88 ArrangeWindows();
91 // ToggleFloatingMode() -- called by DockingWindow when IsFloatingMode() changes
92 void ObjectCatalog::ToggleFloatingMode ()
94 // base class version
95 DockingWindow::ToggleFloatingMode();
96 // rearranging the controls (title)
97 ArrangeWindows();
100 // ArrangeWindows() -- arranges the controls to the size of the ObjectCatalog
101 void ObjectCatalog::ArrangeWindows()
103 if (!aTitle || !aTree)
104 return;
106 Size const aSize = GetOutputSizePixel();
107 bool const bFloating = IsFloatingMode();
109 // title
110 // (showing only if no title bar)
111 if (bFloating)
112 aTitle->Hide();
113 else
115 Size aTitleSize = LogicToPixel(Size(3, 10), MapMode(MapUnit::MapAppFont));
116 aTitleSize.setWidth( aSize.Width() - 2*aTitleSize.Width() );
117 aTitle->SetPosPixel(LogicToPixel(Point(3, 3), MapMode(MapUnit::MapAppFont)));
118 aTitle->SetSizePixel(aTitleSize);
119 aTitle->Show();
122 // tree
123 Point const aTreePos = LogicToPixel(Point(3, bFloating ? 3 : 16), MapMode(MapUnit::MapAppFont));
124 long const nMargin = aTreePos.X();
125 Size const aTreeSize(
126 aSize.Width() - 2*nMargin,
127 aSize.Height() - aTreePos.Y() - nMargin
129 if (aTreeSize.Height() > 0)
131 aTree->SetPosSizePixel(aTreePos, aTreeSize);
132 aTree->Show();
134 else
135 aTree->Hide();
138 void ObjectCatalog::SetCurrentEntry (BaseWindow* pCurWin)
140 EntryDescriptor aDescriptor;
141 if (pCurWin)
142 aDescriptor = pCurWin->CreateEntryDescriptor();
143 aTree->SetCurrentEntry(aDescriptor);
147 } // namespace basctl
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */