diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-11 12:15:00 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-12 17:55:12 +0100 |
commit | 1ac2c003a237af28132d34946f76b57652e20a47 (patch) | |
tree | 55a7465e775f7d97d361dea13acca0003d398b56 /basctl/source | |
parent | 607be34d37ecba57e570aecd1978b79d1d3ad32c (diff) |
weld ObjectCatalog
Change-Id: I1979c6f8f5705360aa0df8cb7aeaeca00cd66ce9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88448
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl/source')
-rw-r--r-- | basctl/source/basicide/ObjectCatalog.cxx | 93 | ||||
-rw-r--r-- | basctl/source/basicide/bastypes.cxx | 6 | ||||
-rw-r--r-- | basctl/source/inc/ObjectCatalog.hxx | 17 | ||||
-rw-r--r-- | basctl/source/inc/bastypes.hxx | 1 |
4 files changed, 40 insertions, 77 deletions
diff --git a/basctl/source/basicide/ObjectCatalog.cxx b/basctl/source/basicide/ObjectCatalog.cxx index 0a32d327f860..3c06ddb5201e 100644 --- a/basctl/source/basicide/ObjectCatalog.cxx +++ b/basctl/source/basicide/ObjectCatalog.cxx @@ -24,40 +24,35 @@ #include <helpids.h> #include <vcl/taskpanelist.hxx> +#include <vcl/svapp.hxx> +#include <vcl/layout.hxx> namespace basctl { ObjectCatalog::ObjectCatalog(vcl::Window* pParent) - : DockingWindow(pParent) - , aTitle(VclPtr<FixedText>::Create(this)) - , aTree(VclPtr<TreeListBox>::Create(this, WB_TABSTOP)) + : DockingWindow(pParent, "DockingWindow", "sfx/ui/dockingwindow.ui") { + m_xVclContentArea = VclPtr<VclVBox>::Create(this); + m_xVclContentArea->Show(); + m_xBuilder.reset(Application::CreateInterimBuilder(m_xVclContentArea, + "modules/BasicIDE/ui/dockingorganizer.ui")); + m_xContainer = m_xBuilder->weld_container("DockingOrganizer"); + + m_xTitle = m_xBuilder->weld_label("title"); + m_xTree.reset(new SbTreeListBox(m_xBuilder->weld_tree_view("libraries"), GetFrameWeld())); + SetHelpId("basctl:FloatingWindow:RID_BASICIDE_OBJCAT"); SetText(IDEResId(RID_BASICIDE_OBJCAT)); // title - aTitle->SetText(IDEResId(RID_BASICIDE_OBJCAT)); - aTitle->SetStyle(WB_CENTER); + m_xTitle->set_label(IDEResId(RID_BASICIDE_OBJCAT)); // tree list - aTree->Hide(); - aTree->SetStyle(WB_BORDER | WB_TABSTOP | WB_HSCROLL | WB_HASLINES | WB_HASLINESATROOT - | WB_HASBUTTONS | WB_HASBUTTONSATROOT); - aTree->SetAccessibleName(IDEResId(RID_STR_TLB_MACROS)); - aTree->SetHelpId(HID_BASICIDE_OBJECTCAT); - aTree->ScanAllEntries(); - aTree->GrabFocus(); - - { - // centered after AppWin: - Window const& rParent = *GetParent(); - Point aPos = rParent.OutputToScreenPixel(Point(0, 0)); - Size const aParentSize = rParent.GetSizePixel(); - Size const aSize = GetSizePixel(); - aPos.AdjustX((aParentSize.Width() - aSize.Width()) / 2); - aPos.AdjustY((aParentSize.Height() - aSize.Height()) / 2); - SetPosPixel(aPos); - } + weld::TreeView& rWidget = m_xTree->get_widget(); + + rWidget.set_help_id(HID_BASICIDE_OBJECTCAT); + m_xTree->ScanAllEntries(); + rWidget.grab_focus(); // make object catalog keyboard accessible GetParent()->GetSystemWindow()->GetTaskPaneList()->AddWindow(this); @@ -69,60 +64,22 @@ void ObjectCatalog::dispose() { if (!IsDisposed()) GetParent()->GetSystemWindow()->GetTaskPaneList()->RemoveWindow(this); - aTitle.disposeAndClear(); - aTree.disposeAndClear(); + m_xTitle.reset(); + m_xTree.reset(); + m_xContainer.reset(); + m_xBuilder.reset(); + m_xVclContentArea.disposeAndClear(); DockingWindow::dispose(); } -// Resize() -- called by Window -void ObjectCatalog::Resize() -{ - // arranging the controls - ArrangeWindows(); -} - // ToggleFloatingMode() -- called by DockingWindow when IsFloatingMode() changes void ObjectCatalog::ToggleFloatingMode() { // base class version DockingWindow::ToggleFloatingMode(); - // rearranging the controls (title) - ArrangeWindows(); -} - -// ArrangeWindows() -- arranges the controls to the size of the ObjectCatalog -void ObjectCatalog::ArrangeWindows() -{ - if (!aTitle || !aTree) - return; - Size const aSize = GetOutputSizePixel(); bool const bFloating = IsFloatingMode(); - - // title - // (showing only if no title bar) - if (bFloating) - aTitle->Hide(); - else - { - Size aTitleSize = LogicToPixel(Size(3, 10), MapMode(MapUnit::MapAppFont)); - aTitleSize.setWidth(aSize.Width() - 2 * aTitleSize.Width()); - aTitle->SetPosPixel(LogicToPixel(Point(3, 3), MapMode(MapUnit::MapAppFont))); - aTitle->SetSizePixel(aTitleSize); - aTitle->Show(); - } - - // tree - Point const aTreePos = LogicToPixel(Point(3, bFloating ? 3 : 16), MapMode(MapUnit::MapAppFont)); - long const nMargin = aTreePos.X(); - Size const aTreeSize(aSize.Width() - 2 * nMargin, aSize.Height() - aTreePos.Y() - nMargin); - if (aTreeSize.Height() > 0) - { - aTree->SetPosSizePixel(aTreePos, aTreeSize); - aTree->Show(); - } - else - aTree->Hide(); + m_xTitle->set_visible(!bFloating); } void ObjectCatalog::SetCurrentEntry(BaseWindow* pCurWin) @@ -130,7 +87,7 @@ void ObjectCatalog::SetCurrentEntry(BaseWindow* pCurWin) EntryDescriptor aDescriptor; if (pCurWin) aDescriptor = pCurWin->CreateEntryDescriptor(); - aTree->SetCurrentEntry(aDescriptor); + m_xTree->SetCurrentEntry(aDescriptor); } } // namespace basctl diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index e79452377198..6c54d770ee58 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -261,6 +261,12 @@ DockingWindow::DockingWindow (vcl::Window* pParent) : nShowCount(0) { } +DockingWindow::DockingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription) : + ::DockingWindow(pParent, rID, rUIXMLDescription), + pLayout(nullptr), + nShowCount(0) +{ } + DockingWindow::DockingWindow (Layout* pParent) : ::DockingWindow(pParent, StyleBits), pLayout(pParent), diff --git a/basctl/source/inc/ObjectCatalog.hxx b/basctl/source/inc/ObjectCatalog.hxx index fbe37f249306..e18a37fdfa0c 100644 --- a/basctl/source/inc/ObjectCatalog.hxx +++ b/basctl/source/inc/ObjectCatalog.hxx @@ -23,7 +23,7 @@ #include "bastype2.hxx" #include "bastypes.hxx" -#include <vcl/fixed.hxx> +#include <vcl/weld.hxx> namespace basctl { @@ -42,23 +42,22 @@ public: virtual void dispose() override; /// Update the entries of Object Catalog Treelist - void UpdateEntries() { aTree->UpdateEntries(); } + void UpdateEntries() { m_xTree->UpdateEntries(); } void SetCurrentEntry(BaseWindow* pCurWin); private: - VclPtr<FixedText> aTitle; ///< Title of the Object Catalog window - VclPtr<TreeListBox> aTree; ///< The Treelist of the objects in window + std::unique_ptr<weld::Builder> m_xBuilder; + VclPtr<vcl::Window> m_xVclContentArea; + std::unique_ptr<weld::Container> m_xContainer; + + std::unique_ptr<weld::Label> m_xTitle; ///< Title of the Object Catalog window + std::unique_ptr<SbTreeListBox> m_xTree; ///< The Treelist of the objects in window - /// Function is called by Window. Use only for arranging the controls. - virtual void Resize() override; /*! * Function for resize by DockingWindow. * It is called by DockingWindow when IsFloatingMode() changes. */ virtual void ToggleFloatingMode() override; - - /// Uses by Resize() and ToggleFloatingMode() functions for resizing - void ArrangeWindows(); }; } // namespace basctl diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx index fcebade1d7af..58e007bf6268 100644 --- a/basctl/source/inc/bastypes.hxx +++ b/basctl/source/inc/bastypes.hxx @@ -81,6 +81,7 @@ class DockingWindow : public ::DockingWindow { public: DockingWindow (vcl::Window* pParent); + DockingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription); DockingWindow (Layout* pParent); virtual ~DockingWindow() override; virtual void dispose() override; |