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>
This commit is contained in:
parent
607be34d37
commit
1ac2c003a2
@ -40,6 +40,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/BasicIDE,\
|
||||
basctl/uiconfig/basicide/ui/defaultlanguage \
|
||||
basctl/uiconfig/basicide/ui/deletelangdialog \
|
||||
basctl/uiconfig/basicide/ui/dialogpage \
|
||||
basctl/uiconfig/basicide/ui/dockingorganizer \
|
||||
basctl/uiconfig/basicide/ui/exportdialog \
|
||||
basctl/uiconfig/basicide/ui/gotolinedialog \
|
||||
basctl/uiconfig/basicide/ui/importlibdialog \
|
||||
|
@ -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();
|
||||
weld::TreeView& rWidget = m_xTree->get_widget();
|
||||
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
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
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -201,7 +201,6 @@
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="libraries">
|
||||
<property name="width_request">-1</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
@ -210,7 +209,6 @@
|
||||
<property name="model">liststore1</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="search_column">1</property>
|
||||
<property name="show_expanders">True</property>
|
||||
<property name="enable_tree_lines">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="Macro Library List-selection1"/>
|
||||
|
81
basctl/uiconfig/basicide/ui/dockingorganizer.ui
Normal file
81
basctl/uiconfig/basicide/ui/dockingorganizer.ui
Normal file
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface domain="basctl">
|
||||
<requires lib="gtk+" version="3.0"/>
|
||||
<object class="GtkTreeStore" id="liststore1">
|
||||
<columns>
|
||||
<!-- column-name expander -->
|
||||
<column type="GdkPixbuf"/>
|
||||
<!-- column-name text -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name id -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkGrid" id="DockingOrganizer">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="libraries">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="model">liststore1</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="search_column">1</property>
|
||||
<property name="enable_tree_lines">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererPixbuf" id="cellrenderertext4"/>
|
||||
<attributes>
|
||||
<attribute name="pixbuf">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext2"/>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="title">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">libraries</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
Loading…
x
Reference in New Issue
Block a user